duckdb 0.3.5-dev54.0 → 0.3.5-dev544.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +29253 -22694
- package/src/duckdb.hpp +1168 -993
- package/src/parquet-amalgamation.cpp +36762 -36756
- package/test/prepare.test.js +2 -2
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.5-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "c1f798f1c"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.5-dev544"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -622,6 +622,7 @@ using std::vector;
|
|
|
622
622
|
}
|
|
623
623
|
|
|
624
624
|
|
|
625
|
+
#include <limits>
|
|
625
626
|
|
|
626
627
|
namespace duckdb {
|
|
627
628
|
|
|
@@ -631,7 +632,7 @@ class Value;
|
|
|
631
632
|
class TypeCatalogEntry;
|
|
632
633
|
class Vector;
|
|
633
634
|
//! Type used to represent dates (days since 1970-01-01)
|
|
634
|
-
struct date_t {
|
|
635
|
+
struct date_t { // NOLINT
|
|
635
636
|
int32_t days;
|
|
636
637
|
|
|
637
638
|
date_t() = default;
|
|
@@ -655,10 +656,15 @@ struct date_t {
|
|
|
655
656
|
// in-place operators
|
|
656
657
|
inline date_t &operator+=(const int32_t &days) {this->days += days; return *this;};
|
|
657
658
|
inline date_t &operator-=(const int32_t &days) {this->days -= days; return *this;};
|
|
659
|
+
|
|
660
|
+
// special values
|
|
661
|
+
static inline date_t infinity() {return date_t(std::numeric_limits<int32_t>::max()); } // NOLINT
|
|
662
|
+
static inline date_t ninfinity() {return date_t(-std::numeric_limits<int32_t>::max()); } // NOLINT
|
|
663
|
+
static inline date_t epoch() {return date_t(0); } // NOLINT
|
|
658
664
|
};
|
|
659
665
|
|
|
660
666
|
//! Type used to represent time (microseconds)
|
|
661
|
-
struct dtime_t {
|
|
667
|
+
struct dtime_t { // NOLINT
|
|
662
668
|
int64_t micros;
|
|
663
669
|
|
|
664
670
|
dtime_t() = default;
|
|
@@ -689,10 +695,13 @@ struct dtime_t {
|
|
|
689
695
|
inline dtime_t &operator+=(const int64_t µs) {this->micros += micros; return *this;};
|
|
690
696
|
inline dtime_t &operator-=(const int64_t µs) {this->micros -= micros; return *this;};
|
|
691
697
|
inline dtime_t &operator+=(const dtime_t &other) {this->micros += other.micros; return *this;};
|
|
698
|
+
|
|
699
|
+
// special values
|
|
700
|
+
static inline dtime_t allballs() {return dtime_t(0); } // NOLINT
|
|
692
701
|
};
|
|
693
702
|
|
|
694
703
|
//! Type used to represent timestamps (seconds,microseconds,milliseconds or nanoseconds since 1970-01-01)
|
|
695
|
-
struct timestamp_t {
|
|
704
|
+
struct timestamp_t { // NOLINT
|
|
696
705
|
int64_t value;
|
|
697
706
|
|
|
698
707
|
timestamp_t() = default;
|
|
@@ -717,6 +726,11 @@ struct timestamp_t {
|
|
|
717
726
|
// in-place operators
|
|
718
727
|
inline timestamp_t &operator+=(const int64_t &value) {this->value += value; return *this;};
|
|
719
728
|
inline timestamp_t &operator-=(const int64_t &value) {this->value -= value; return *this;};
|
|
729
|
+
|
|
730
|
+
// special values
|
|
731
|
+
static inline timestamp_t infinity() {return timestamp_t(std::numeric_limits<int64_t>::max()); } // NOLINT
|
|
732
|
+
static inline timestamp_t ninfinity() {return timestamp_t(-std::numeric_limits<int64_t>::max()); } // NOLINT
|
|
733
|
+
static inline timestamp_t epoch() {return timestamp_t(0); } // NOLINT
|
|
720
734
|
};
|
|
721
735
|
|
|
722
736
|
struct interval_t {
|
|
@@ -2789,7 +2803,7 @@ public:
|
|
|
2789
2803
|
DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
|
|
2790
2804
|
//! Create an empty list with the specified child-type
|
|
2791
2805
|
DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
|
|
2792
|
-
//!
|
|
2806
|
+
//! Create a map value from a (key, value) pair
|
|
2793
2807
|
DUCKDB_API static Value MAP(Value key, Value value);
|
|
2794
2808
|
|
|
2795
2809
|
//! Create a blob Value from a data pointer and a length: no bytes are interpreted
|
|
@@ -2882,6 +2896,8 @@ public:
|
|
|
2882
2896
|
//! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
|
|
2883
2897
|
//! function, NULL values are equivalent and floating point values that are close are equivalent.
|
|
2884
2898
|
DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
|
|
2899
|
+
//! Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.
|
|
2900
|
+
DUCKDB_API static bool NotDistinctFrom(const Value &lvalue, const Value &rvalue);
|
|
2885
2901
|
|
|
2886
2902
|
friend std::ostream &operator<<(std::ostream &out, const Value &val) {
|
|
2887
2903
|
out << val.ToString();
|
|
@@ -3094,6 +3110,8 @@ template <>
|
|
|
3094
3110
|
DUCKDB_API timestamp_t Value::GetValue() const;
|
|
3095
3111
|
template <>
|
|
3096
3112
|
DUCKDB_API interval_t Value::GetValue() const;
|
|
3113
|
+
template <>
|
|
3114
|
+
DUCKDB_API Value Value::GetValue() const;
|
|
3097
3115
|
|
|
3098
3116
|
template <>
|
|
3099
3117
|
DUCKDB_API bool Value::GetValueUnsafe() const;
|
|
@@ -3172,6 +3190,10 @@ template <>
|
|
|
3172
3190
|
DUCKDB_API bool Value::IsFinite(float input);
|
|
3173
3191
|
template <>
|
|
3174
3192
|
DUCKDB_API bool Value::IsFinite(double input);
|
|
3193
|
+
template <>
|
|
3194
|
+
DUCKDB_API bool Value::IsFinite(date_t input);
|
|
3195
|
+
template <>
|
|
3196
|
+
DUCKDB_API bool Value::IsFinite(timestamp_t input);
|
|
3175
3197
|
|
|
3176
3198
|
} // namespace duckdb
|
|
3177
3199
|
|
|
@@ -3974,6 +3996,9 @@ struct SequenceVector {
|
|
|
3974
3996
|
extern "C" {
|
|
3975
3997
|
#endif
|
|
3976
3998
|
|
|
3999
|
+
#ifndef ARROW_C_DATA_INTERFACE
|
|
4000
|
+
#define ARROW_C_DATA_INTERFACE
|
|
4001
|
+
|
|
3977
4002
|
#define ARROW_FLAG_DICTIONARY_ORDERED 1
|
|
3978
4003
|
#define ARROW_FLAG_NULLABLE 2
|
|
3979
4004
|
#define ARROW_FLAG_MAP_KEYS_SORTED 4
|
|
@@ -4010,7 +4035,10 @@ struct ArrowArray {
|
|
|
4010
4035
|
// Opaque producer-specific data
|
|
4011
4036
|
void *private_data;
|
|
4012
4037
|
};
|
|
4038
|
+
#endif
|
|
4013
4039
|
|
|
4040
|
+
#ifndef ARROW_C_STREAM_INTERFACE
|
|
4041
|
+
#define ARROW_C_STREAM_INTERFACE
|
|
4014
4042
|
// EXPERIMENTAL
|
|
4015
4043
|
struct ArrowArrayStream {
|
|
4016
4044
|
// Callback to get the stream type
|
|
@@ -4035,6 +4063,7 @@ struct ArrowArrayStream {
|
|
|
4035
4063
|
// Opaque producer-specific data
|
|
4036
4064
|
void *private_data;
|
|
4037
4065
|
};
|
|
4066
|
+
#endif
|
|
4038
4067
|
|
|
4039
4068
|
#ifdef __cplusplus
|
|
4040
4069
|
}
|
|
@@ -4909,9 +4938,23 @@ public:
|
|
|
4909
4938
|
|
|
4910
4939
|
namespace duckdb {
|
|
4911
4940
|
|
|
4941
|
+
struct TernaryLambdaWrapper {
|
|
4942
|
+
template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
|
|
4943
|
+
static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
|
|
4944
|
+
return fun(a, b, c);
|
|
4945
|
+
}
|
|
4946
|
+
};
|
|
4947
|
+
|
|
4948
|
+
struct TernaryLambdaWrapperWithNulls {
|
|
4949
|
+
template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
|
|
4950
|
+
static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
|
|
4951
|
+
return fun(a, b, c, mask, idx);
|
|
4952
|
+
}
|
|
4953
|
+
};
|
|
4954
|
+
|
|
4912
4955
|
struct TernaryExecutor {
|
|
4913
4956
|
private:
|
|
4914
|
-
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class FUN>
|
|
4957
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
|
|
4915
4958
|
static inline void ExecuteLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
|
|
4916
4959
|
RESULT_TYPE *__restrict result_data, idx_t count, const SelectionVector &asel,
|
|
4917
4960
|
const SelectionVector &bsel, const SelectionVector &csel, ValidityMask &avalidity,
|
|
@@ -4923,7 +4966,8 @@ private:
|
|
|
4923
4966
|
auto bidx = bsel.get_index(i);
|
|
4924
4967
|
auto cidx = csel.get_index(i);
|
|
4925
4968
|
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx) && cvalidity.RowIsValid(cidx)) {
|
|
4926
|
-
result_data[i] =
|
|
4969
|
+
result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
4970
|
+
fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
|
|
4927
4971
|
} else {
|
|
4928
4972
|
result_validity.SetInvalid(i);
|
|
4929
4973
|
}
|
|
@@ -4933,15 +4977,15 @@ private:
|
|
|
4933
4977
|
auto aidx = asel.get_index(i);
|
|
4934
4978
|
auto bidx = bsel.get_index(i);
|
|
4935
4979
|
auto cidx = csel.get_index(i);
|
|
4936
|
-
result_data[i] =
|
|
4980
|
+
result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
4981
|
+
fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
|
|
4937
4982
|
}
|
|
4938
4983
|
}
|
|
4939
4984
|
}
|
|
4940
4985
|
|
|
4941
4986
|
public:
|
|
4942
|
-
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
4943
|
-
|
|
4944
|
-
static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
4987
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
|
|
4988
|
+
static void ExecuteGeneric(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
4945
4989
|
if (a.GetVectorType() == VectorType::CONSTANT_VECTOR && b.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
4946
4990
|
c.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
4947
4991
|
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
@@ -4952,7 +4996,9 @@ public:
|
|
|
4952
4996
|
auto bdata = ConstantVector::GetData<B_TYPE>(b);
|
|
4953
4997
|
auto cdata = ConstantVector::GetData<C_TYPE>(c);
|
|
4954
4998
|
auto result_data = ConstantVector::GetData<RESULT_TYPE>(result);
|
|
4955
|
-
|
|
4999
|
+
auto &result_validity = ConstantVector::Validity(result);
|
|
5000
|
+
result_data[0] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
5001
|
+
fun, adata[0], bdata[0], cdata[0], result_validity, 0);
|
|
4956
5002
|
}
|
|
4957
5003
|
} else {
|
|
4958
5004
|
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
@@ -4962,13 +5008,26 @@ public:
|
|
|
4962
5008
|
b.Orrify(count, bdata);
|
|
4963
5009
|
c.Orrify(count, cdata);
|
|
4964
5010
|
|
|
4965
|
-
ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
5011
|
+
ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, OPWRAPPER>(
|
|
4966
5012
|
(A_TYPE *)adata.data, (B_TYPE *)bdata.data, (C_TYPE *)cdata.data,
|
|
4967
5013
|
FlatVector::GetData<RESULT_TYPE>(result), count, *adata.sel, *bdata.sel, *cdata.sel, adata.validity,
|
|
4968
5014
|
bdata.validity, cdata.validity, FlatVector::Validity(result), fun);
|
|
4969
5015
|
}
|
|
4970
5016
|
}
|
|
4971
5017
|
|
|
5018
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
5019
|
+
class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE)>>
|
|
5020
|
+
static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
5021
|
+
ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapper, FUN>(a, b, c, result, count, fun);
|
|
5022
|
+
}
|
|
5023
|
+
|
|
5024
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
5025
|
+
class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE, ValidityMask &, idx_t)>>
|
|
5026
|
+
static void ExecuteWithNulls(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
5027
|
+
ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapperWithNulls, FUN>(a, b, c, result, count,
|
|
5028
|
+
fun);
|
|
5029
|
+
}
|
|
5030
|
+
|
|
4972
5031
|
private:
|
|
4973
5032
|
template <class A_TYPE, class B_TYPE, class C_TYPE, class OP, bool NO_NULL, bool HAS_TRUE_SEL, bool HAS_FALSE_SEL>
|
|
4974
5033
|
static inline idx_t SelectLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
|
|
@@ -5315,195 +5374,6 @@ using std::chrono::system_clock;
|
|
|
5315
5374
|
using std::chrono::time_point;
|
|
5316
5375
|
} // namespace duckdb
|
|
5317
5376
|
|
|
5318
|
-
//===----------------------------------------------------------------------===//
|
|
5319
|
-
// DuckDB
|
|
5320
|
-
//
|
|
5321
|
-
// duckdb/common/random_engine.hpp
|
|
5322
|
-
//
|
|
5323
|
-
//
|
|
5324
|
-
//===----------------------------------------------------------------------===//
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
//===----------------------------------------------------------------------===//
|
|
5330
|
-
// DuckDB
|
|
5331
|
-
//
|
|
5332
|
-
// duckdb/common/limits.hpp
|
|
5333
|
-
//
|
|
5334
|
-
//
|
|
5335
|
-
//===----------------------------------------------------------------------===//
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
namespace duckdb {
|
|
5342
|
-
|
|
5343
|
-
template <class T>
|
|
5344
|
-
struct NumericLimits {
|
|
5345
|
-
static T Minimum();
|
|
5346
|
-
static T Maximum();
|
|
5347
|
-
static bool IsSigned();
|
|
5348
|
-
static idx_t Digits();
|
|
5349
|
-
};
|
|
5350
|
-
|
|
5351
|
-
template <>
|
|
5352
|
-
struct NumericLimits<int8_t> {
|
|
5353
|
-
static int8_t Minimum();
|
|
5354
|
-
static int8_t Maximum();
|
|
5355
|
-
static bool IsSigned() {
|
|
5356
|
-
return true;
|
|
5357
|
-
}
|
|
5358
|
-
static idx_t Digits() {
|
|
5359
|
-
return 3;
|
|
5360
|
-
}
|
|
5361
|
-
};
|
|
5362
|
-
template <>
|
|
5363
|
-
struct NumericLimits<int16_t> {
|
|
5364
|
-
static int16_t Minimum();
|
|
5365
|
-
static int16_t Maximum();
|
|
5366
|
-
static bool IsSigned() {
|
|
5367
|
-
return true;
|
|
5368
|
-
}
|
|
5369
|
-
static idx_t Digits() {
|
|
5370
|
-
return 5;
|
|
5371
|
-
}
|
|
5372
|
-
};
|
|
5373
|
-
template <>
|
|
5374
|
-
struct NumericLimits<int32_t> {
|
|
5375
|
-
static int32_t Minimum();
|
|
5376
|
-
static int32_t Maximum();
|
|
5377
|
-
static bool IsSigned() {
|
|
5378
|
-
return true;
|
|
5379
|
-
}
|
|
5380
|
-
static idx_t Digits() {
|
|
5381
|
-
return 10;
|
|
5382
|
-
}
|
|
5383
|
-
};
|
|
5384
|
-
template <>
|
|
5385
|
-
struct NumericLimits<int64_t> {
|
|
5386
|
-
static int64_t Minimum();
|
|
5387
|
-
static int64_t Maximum();
|
|
5388
|
-
static bool IsSigned() {
|
|
5389
|
-
return true;
|
|
5390
|
-
}
|
|
5391
|
-
static idx_t Digits() {
|
|
5392
|
-
return 19;
|
|
5393
|
-
}
|
|
5394
|
-
};
|
|
5395
|
-
template <>
|
|
5396
|
-
struct NumericLimits<hugeint_t> {
|
|
5397
|
-
static hugeint_t Minimum();
|
|
5398
|
-
static hugeint_t Maximum();
|
|
5399
|
-
static bool IsSigned() {
|
|
5400
|
-
return true;
|
|
5401
|
-
}
|
|
5402
|
-
static idx_t Digits() {
|
|
5403
|
-
return 39;
|
|
5404
|
-
}
|
|
5405
|
-
};
|
|
5406
|
-
template <>
|
|
5407
|
-
struct NumericLimits<uint8_t> {
|
|
5408
|
-
static uint8_t Minimum();
|
|
5409
|
-
static uint8_t Maximum();
|
|
5410
|
-
static bool IsSigned() {
|
|
5411
|
-
return false;
|
|
5412
|
-
}
|
|
5413
|
-
static idx_t Digits() {
|
|
5414
|
-
return 3;
|
|
5415
|
-
}
|
|
5416
|
-
};
|
|
5417
|
-
template <>
|
|
5418
|
-
struct NumericLimits<uint16_t> {
|
|
5419
|
-
static uint16_t Minimum();
|
|
5420
|
-
static uint16_t Maximum();
|
|
5421
|
-
static bool IsSigned() {
|
|
5422
|
-
return false;
|
|
5423
|
-
}
|
|
5424
|
-
static idx_t Digits() {
|
|
5425
|
-
return 5;
|
|
5426
|
-
}
|
|
5427
|
-
};
|
|
5428
|
-
template <>
|
|
5429
|
-
struct NumericLimits<uint32_t> {
|
|
5430
|
-
static uint32_t Minimum();
|
|
5431
|
-
static uint32_t Maximum();
|
|
5432
|
-
static bool IsSigned() {
|
|
5433
|
-
return false;
|
|
5434
|
-
}
|
|
5435
|
-
static idx_t Digits() {
|
|
5436
|
-
return 10;
|
|
5437
|
-
}
|
|
5438
|
-
};
|
|
5439
|
-
template <>
|
|
5440
|
-
struct NumericLimits<uint64_t> {
|
|
5441
|
-
static uint64_t Minimum();
|
|
5442
|
-
static uint64_t Maximum();
|
|
5443
|
-
static bool IsSigned() {
|
|
5444
|
-
return false;
|
|
5445
|
-
}
|
|
5446
|
-
static idx_t Digits() {
|
|
5447
|
-
return 20;
|
|
5448
|
-
}
|
|
5449
|
-
};
|
|
5450
|
-
template <>
|
|
5451
|
-
struct NumericLimits<float> {
|
|
5452
|
-
static float Minimum();
|
|
5453
|
-
static float Maximum();
|
|
5454
|
-
static bool IsSigned() {
|
|
5455
|
-
return true;
|
|
5456
|
-
}
|
|
5457
|
-
static idx_t Digits() {
|
|
5458
|
-
return 127;
|
|
5459
|
-
}
|
|
5460
|
-
};
|
|
5461
|
-
template <>
|
|
5462
|
-
struct NumericLimits<double> {
|
|
5463
|
-
static double Minimum();
|
|
5464
|
-
static double Maximum();
|
|
5465
|
-
static bool IsSigned() {
|
|
5466
|
-
return true;
|
|
5467
|
-
}
|
|
5468
|
-
static idx_t Digits() {
|
|
5469
|
-
return 250;
|
|
5470
|
-
}
|
|
5471
|
-
};
|
|
5472
|
-
|
|
5473
|
-
} // namespace duckdb
|
|
5474
|
-
|
|
5475
|
-
#include <random>
|
|
5476
|
-
|
|
5477
|
-
namespace duckdb {
|
|
5478
|
-
|
|
5479
|
-
struct RandomEngine {
|
|
5480
|
-
std::mt19937 random_engine;
|
|
5481
|
-
RandomEngine(int64_t seed = -1) {
|
|
5482
|
-
if (seed < 0) {
|
|
5483
|
-
std::random_device rd;
|
|
5484
|
-
random_engine.seed(rd());
|
|
5485
|
-
} else {
|
|
5486
|
-
random_engine.seed(seed);
|
|
5487
|
-
}
|
|
5488
|
-
}
|
|
5489
|
-
|
|
5490
|
-
//! Generate a random number between min and max
|
|
5491
|
-
double NextRandom(double min, double max) {
|
|
5492
|
-
std::uniform_real_distribution<double> dist(min, max);
|
|
5493
|
-
return dist(random_engine);
|
|
5494
|
-
}
|
|
5495
|
-
//! Generate a random number between 0 and 1
|
|
5496
|
-
double NextRandom() {
|
|
5497
|
-
return NextRandom(0, 1);
|
|
5498
|
-
}
|
|
5499
|
-
uint32_t NextRandomInteger() {
|
|
5500
|
-
std::uniform_int_distribution<uint32_t> dist(0, NumericLimits<uint32_t>::Maximum());
|
|
5501
|
-
return dist(random_engine);
|
|
5502
|
-
}
|
|
5503
|
-
};
|
|
5504
|
-
|
|
5505
|
-
} // namespace duckdb
|
|
5506
|
-
|
|
5507
5377
|
|
|
5508
5378
|
namespace duckdb {
|
|
5509
5379
|
|
|
@@ -5561,7 +5431,6 @@ private:
|
|
|
5561
5431
|
|
|
5562
5432
|
} // namespace duckdb
|
|
5563
5433
|
|
|
5564
|
-
|
|
5565
5434
|
//===----------------------------------------------------------------------===//
|
|
5566
5435
|
// DuckDB
|
|
5567
5436
|
//
|
|
@@ -6074,7 +5943,7 @@ public:
|
|
|
6074
5943
|
//! Convert the Expression to a String
|
|
6075
5944
|
virtual string ToString() const = 0;
|
|
6076
5945
|
//! Print the expression to stdout
|
|
6077
|
-
void Print();
|
|
5946
|
+
void Print() const;
|
|
6078
5947
|
|
|
6079
5948
|
//! Creates a hash value of this expression. It is important that if two expressions are identical (i.e.
|
|
6080
5949
|
//! Expression::Equals() returns true), that their hash value is identical as well.
|
|
@@ -6137,7 +6006,7 @@ public:
|
|
|
6137
6006
|
static bool RequiresQuotes(const string &text);
|
|
6138
6007
|
|
|
6139
6008
|
//! Writes a string that is optionally quoted + escaped so it can be used as an identifier
|
|
6140
|
-
static string WriteOptionallyQuoted(const string &text);
|
|
6009
|
+
static string WriteOptionallyQuoted(const string &text, char quote = '"');
|
|
6141
6010
|
};
|
|
6142
6011
|
|
|
6143
6012
|
} // namespace duckdb
|
|
@@ -6390,14 +6259,19 @@ struct PragmaInfo;
|
|
|
6390
6259
|
struct FunctionData {
|
|
6391
6260
|
DUCKDB_API virtual ~FunctionData();
|
|
6392
6261
|
|
|
6393
|
-
DUCKDB_API virtual unique_ptr<FunctionData> Copy();
|
|
6394
|
-
DUCKDB_API virtual bool Equals(FunctionData &other);
|
|
6395
|
-
DUCKDB_API static bool Equals(FunctionData *left, FunctionData *right);
|
|
6262
|
+
DUCKDB_API virtual unique_ptr<FunctionData> Copy() const = 0;
|
|
6263
|
+
DUCKDB_API virtual bool Equals(const FunctionData &other) const = 0;
|
|
6264
|
+
DUCKDB_API static bool Equals(const FunctionData *left, const FunctionData *right);
|
|
6396
6265
|
};
|
|
6397
6266
|
|
|
6398
6267
|
struct TableFunctionData : public FunctionData {
|
|
6399
6268
|
// used to pass on projections to table functions that support them. NB, can contain COLUMN_IDENTIFIER_ROW_ID
|
|
6400
6269
|
vector<idx_t> column_ids;
|
|
6270
|
+
|
|
6271
|
+
DUCKDB_API virtual ~TableFunctionData();
|
|
6272
|
+
|
|
6273
|
+
DUCKDB_API unique_ptr<FunctionData> Copy() const override;
|
|
6274
|
+
DUCKDB_API bool Equals(const FunctionData &other) const override;
|
|
6401
6275
|
};
|
|
6402
6276
|
|
|
6403
6277
|
struct FunctionParameters {
|
|
@@ -6427,11 +6301,14 @@ public:
|
|
|
6427
6301
|
//! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
|
|
6428
6302
|
//! returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6429
6303
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
|
|
6430
|
-
vector<LogicalType> &arguments, string &error);
|
|
6304
|
+
vector<LogicalType> &arguments, string &error, bool &cast_parameters);
|
|
6431
6305
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
|
|
6432
|
-
vector<unique_ptr<Expression>> &arguments, string &error
|
|
6306
|
+
vector<unique_ptr<Expression>> &arguments, string &error,
|
|
6307
|
+
bool &cast_parameters);
|
|
6433
6308
|
//! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
|
|
6434
6309
|
//! function, returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6310
|
+
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
6311
|
+
vector<LogicalType> &arguments, string &error, bool &cast_parameters);
|
|
6435
6312
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
6436
6313
|
vector<LogicalType> &arguments, string &error);
|
|
6437
6314
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
@@ -6477,10 +6354,6 @@ public:
|
|
|
6477
6354
|
public:
|
|
6478
6355
|
DUCKDB_API string ToString() override;
|
|
6479
6356
|
DUCKDB_API bool HasNamedParameters();
|
|
6480
|
-
|
|
6481
|
-
DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> ¶meters,
|
|
6482
|
-
named_parameter_map_t &named_parameters,
|
|
6483
|
-
vector<unique_ptr<ParsedExpression>> &children);
|
|
6484
6357
|
};
|
|
6485
6358
|
|
|
6486
6359
|
class BaseScalarFunction : public SimpleFunction {
|
|
@@ -6502,7 +6375,8 @@ public:
|
|
|
6502
6375
|
DUCKDB_API hash_t Hash() const;
|
|
6503
6376
|
|
|
6504
6377
|
//! Cast a set of expressions to the arguments of this function
|
|
6505
|
-
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children
|
|
6378
|
+
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children,
|
|
6379
|
+
bool cast_parameter_expressions = true);
|
|
6506
6380
|
|
|
6507
6381
|
DUCKDB_API string ToString() override;
|
|
6508
6382
|
};
|
|
@@ -6574,6 +6448,7 @@ namespace duckdb {
|
|
|
6574
6448
|
class Expression;
|
|
6575
6449
|
class ExpressionExecutor;
|
|
6576
6450
|
struct ExpressionExecutorState;
|
|
6451
|
+
struct FunctionLocalState;
|
|
6577
6452
|
|
|
6578
6453
|
struct ExpressionState {
|
|
6579
6454
|
ExpressionState(const Expression &expr, ExpressionExecutorState &root);
|
|
@@ -6594,13 +6469,13 @@ public:
|
|
|
6594
6469
|
};
|
|
6595
6470
|
|
|
6596
6471
|
struct ExecuteFunctionState : public ExpressionState {
|
|
6597
|
-
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root)
|
|
6598
|
-
|
|
6472
|
+
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root);
|
|
6473
|
+
~ExecuteFunctionState();
|
|
6599
6474
|
|
|
6600
|
-
unique_ptr<
|
|
6475
|
+
unique_ptr<FunctionLocalState> local_state;
|
|
6601
6476
|
|
|
6602
6477
|
public:
|
|
6603
|
-
static
|
|
6478
|
+
static FunctionLocalState *GetFunctionState(ExpressionState &state) {
|
|
6604
6479
|
return ((ExecuteFunctionState &)state).local_state.get();
|
|
6605
6480
|
}
|
|
6606
6481
|
};
|
|
@@ -6651,42 +6526,187 @@ struct ExpressionExecutorState {
|
|
|
6651
6526
|
|
|
6652
6527
|
|
|
6653
6528
|
|
|
6529
|
+
//===----------------------------------------------------------------------===//
|
|
6530
|
+
// DuckDB
|
|
6531
|
+
//
|
|
6532
|
+
// duckdb/common/limits.hpp
|
|
6533
|
+
//
|
|
6534
|
+
//
|
|
6535
|
+
//===----------------------------------------------------------------------===//
|
|
6654
6536
|
|
|
6655
6537
|
|
|
6656
6538
|
|
|
6657
|
-
namespace duckdb {
|
|
6658
6539
|
|
|
6659
|
-
//! The Hugeint class contains static operations for the INT128 type
|
|
6660
|
-
class Hugeint {
|
|
6661
|
-
public:
|
|
6662
|
-
//! Convert a string to a hugeint object
|
|
6663
|
-
static bool FromString(string str, hugeint_t &result);
|
|
6664
|
-
//! Convert a string to a hugeint object
|
|
6665
|
-
static bool FromCString(const char *str, idx_t len, hugeint_t &result);
|
|
6666
|
-
//! Convert a hugeint object to a string
|
|
6667
|
-
static string ToString(hugeint_t input);
|
|
6668
6540
|
|
|
6669
|
-
|
|
6670
|
-
hugeint_t result;
|
|
6671
|
-
FromString(str, result);
|
|
6672
|
-
return result;
|
|
6673
|
-
}
|
|
6541
|
+
namespace duckdb {
|
|
6674
6542
|
|
|
6675
|
-
|
|
6676
|
-
|
|
6543
|
+
template <class T>
|
|
6544
|
+
struct NumericLimits {
|
|
6545
|
+
static T Minimum();
|
|
6546
|
+
static T Maximum();
|
|
6547
|
+
static bool IsSigned();
|
|
6548
|
+
static idx_t Digits();
|
|
6549
|
+
};
|
|
6677
6550
|
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6551
|
+
template <>
|
|
6552
|
+
struct NumericLimits<int8_t> {
|
|
6553
|
+
static int8_t Minimum();
|
|
6554
|
+
static int8_t Maximum();
|
|
6555
|
+
static bool IsSigned() {
|
|
6556
|
+
return true;
|
|
6683
6557
|
}
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6558
|
+
static idx_t Digits() {
|
|
6559
|
+
return 3;
|
|
6560
|
+
}
|
|
6561
|
+
};
|
|
6562
|
+
template <>
|
|
6563
|
+
struct NumericLimits<int16_t> {
|
|
6564
|
+
static int16_t Minimum();
|
|
6565
|
+
static int16_t Maximum();
|
|
6566
|
+
static bool IsSigned() {
|
|
6567
|
+
return true;
|
|
6568
|
+
}
|
|
6569
|
+
static idx_t Digits() {
|
|
6570
|
+
return 5;
|
|
6571
|
+
}
|
|
6572
|
+
};
|
|
6573
|
+
template <>
|
|
6574
|
+
struct NumericLimits<int32_t> {
|
|
6575
|
+
static int32_t Minimum();
|
|
6576
|
+
static int32_t Maximum();
|
|
6577
|
+
static bool IsSigned() {
|
|
6578
|
+
return true;
|
|
6579
|
+
}
|
|
6580
|
+
static idx_t Digits() {
|
|
6581
|
+
return 10;
|
|
6582
|
+
}
|
|
6583
|
+
};
|
|
6584
|
+
template <>
|
|
6585
|
+
struct NumericLimits<int64_t> {
|
|
6586
|
+
static int64_t Minimum();
|
|
6587
|
+
static int64_t Maximum();
|
|
6588
|
+
static bool IsSigned() {
|
|
6589
|
+
return true;
|
|
6590
|
+
}
|
|
6591
|
+
static idx_t Digits() {
|
|
6592
|
+
return 19;
|
|
6593
|
+
}
|
|
6594
|
+
};
|
|
6595
|
+
template <>
|
|
6596
|
+
struct NumericLimits<hugeint_t> {
|
|
6597
|
+
static hugeint_t Minimum();
|
|
6598
|
+
static hugeint_t Maximum();
|
|
6599
|
+
static bool IsSigned() {
|
|
6600
|
+
return true;
|
|
6601
|
+
}
|
|
6602
|
+
static idx_t Digits() {
|
|
6603
|
+
return 39;
|
|
6604
|
+
}
|
|
6605
|
+
};
|
|
6606
|
+
template <>
|
|
6607
|
+
struct NumericLimits<uint8_t> {
|
|
6608
|
+
static uint8_t Minimum();
|
|
6609
|
+
static uint8_t Maximum();
|
|
6610
|
+
static bool IsSigned() {
|
|
6611
|
+
return false;
|
|
6612
|
+
}
|
|
6613
|
+
static idx_t Digits() {
|
|
6614
|
+
return 3;
|
|
6615
|
+
}
|
|
6616
|
+
};
|
|
6617
|
+
template <>
|
|
6618
|
+
struct NumericLimits<uint16_t> {
|
|
6619
|
+
static uint16_t Minimum();
|
|
6620
|
+
static uint16_t Maximum();
|
|
6621
|
+
static bool IsSigned() {
|
|
6622
|
+
return false;
|
|
6623
|
+
}
|
|
6624
|
+
static idx_t Digits() {
|
|
6625
|
+
return 5;
|
|
6626
|
+
}
|
|
6627
|
+
};
|
|
6628
|
+
template <>
|
|
6629
|
+
struct NumericLimits<uint32_t> {
|
|
6630
|
+
static uint32_t Minimum();
|
|
6631
|
+
static uint32_t Maximum();
|
|
6632
|
+
static bool IsSigned() {
|
|
6633
|
+
return false;
|
|
6634
|
+
}
|
|
6635
|
+
static idx_t Digits() {
|
|
6636
|
+
return 10;
|
|
6637
|
+
}
|
|
6638
|
+
};
|
|
6639
|
+
template <>
|
|
6640
|
+
struct NumericLimits<uint64_t> {
|
|
6641
|
+
static uint64_t Minimum();
|
|
6642
|
+
static uint64_t Maximum();
|
|
6643
|
+
static bool IsSigned() {
|
|
6644
|
+
return false;
|
|
6645
|
+
}
|
|
6646
|
+
static idx_t Digits() {
|
|
6647
|
+
return 20;
|
|
6648
|
+
}
|
|
6649
|
+
};
|
|
6650
|
+
template <>
|
|
6651
|
+
struct NumericLimits<float> {
|
|
6652
|
+
static float Minimum();
|
|
6653
|
+
static float Maximum();
|
|
6654
|
+
static bool IsSigned() {
|
|
6655
|
+
return true;
|
|
6656
|
+
}
|
|
6657
|
+
static idx_t Digits() {
|
|
6658
|
+
return 127;
|
|
6659
|
+
}
|
|
6660
|
+
};
|
|
6661
|
+
template <>
|
|
6662
|
+
struct NumericLimits<double> {
|
|
6663
|
+
static double Minimum();
|
|
6664
|
+
static double Maximum();
|
|
6665
|
+
static bool IsSigned() {
|
|
6666
|
+
return true;
|
|
6667
|
+
}
|
|
6668
|
+
static idx_t Digits() {
|
|
6669
|
+
return 250;
|
|
6670
|
+
}
|
|
6671
|
+
};
|
|
6672
|
+
|
|
6673
|
+
} // namespace duckdb
|
|
6674
|
+
|
|
6675
|
+
|
|
6676
|
+
|
|
6677
|
+
namespace duckdb {
|
|
6678
|
+
|
|
6679
|
+
//! The Hugeint class contains static operations for the INT128 type
|
|
6680
|
+
class Hugeint {
|
|
6681
|
+
public:
|
|
6682
|
+
//! Convert a string to a hugeint object
|
|
6683
|
+
static bool FromString(string str, hugeint_t &result);
|
|
6684
|
+
//! Convert a string to a hugeint object
|
|
6685
|
+
static bool FromCString(const char *str, idx_t len, hugeint_t &result);
|
|
6686
|
+
//! Convert a hugeint object to a string
|
|
6687
|
+
static string ToString(hugeint_t input);
|
|
6688
|
+
|
|
6689
|
+
static hugeint_t FromString(string str) {
|
|
6690
|
+
hugeint_t result;
|
|
6691
|
+
FromString(str, result);
|
|
6692
|
+
return result;
|
|
6693
|
+
}
|
|
6694
|
+
|
|
6695
|
+
template <class T>
|
|
6696
|
+
static bool TryCast(hugeint_t input, T &result);
|
|
6697
|
+
|
|
6698
|
+
template <class T>
|
|
6699
|
+
static T Cast(hugeint_t input) {
|
|
6700
|
+
T value;
|
|
6701
|
+
TryCast(input, value);
|
|
6702
|
+
return value;
|
|
6703
|
+
}
|
|
6704
|
+
|
|
6705
|
+
template <class T>
|
|
6706
|
+
static bool TryConvert(T value, hugeint_t &result);
|
|
6707
|
+
|
|
6708
|
+
template <class T>
|
|
6709
|
+
static hugeint_t Convert(T value) {
|
|
6690
6710
|
hugeint_t result;
|
|
6691
6711
|
if (!TryConvert(value, result)) { // LCOV_EXCL_START
|
|
6692
6712
|
throw ValueOutOfRangeException(double(value), GetTypeId<T>(), GetTypeId<hugeint_t>());
|
|
@@ -7196,32 +7216,46 @@ class FieldWriter;
|
|
|
7196
7216
|
class FieldReader;
|
|
7197
7217
|
class Vector;
|
|
7198
7218
|
class ValidityStatistics;
|
|
7219
|
+
class DistinctStatistics;
|
|
7220
|
+
struct VectorData;
|
|
7221
|
+
|
|
7222
|
+
enum StatisticsType { LOCAL_STATS = 0, GLOBAL_STATS = 1 };
|
|
7199
7223
|
|
|
7200
7224
|
class BaseStatistics {
|
|
7201
7225
|
public:
|
|
7202
|
-
|
|
7226
|
+
BaseStatistics(LogicalType type, StatisticsType stats_type);
|
|
7203
7227
|
virtual ~BaseStatistics();
|
|
7204
7228
|
|
|
7205
7229
|
//! The type of the logical segment
|
|
7206
7230
|
LogicalType type;
|
|
7207
7231
|
//! The validity stats of the column (if any)
|
|
7208
7232
|
unique_ptr<BaseStatistics> validity_stats;
|
|
7233
|
+
//! The approximate count distinct stats of the column (if any)
|
|
7234
|
+
unique_ptr<BaseStatistics> distinct_stats;
|
|
7235
|
+
//! Whether these are 'global' stats, i.e., over a whole table, or just over a segment
|
|
7236
|
+
//! Some statistics are more expensive to keep, therefore we only keep them globally
|
|
7237
|
+
StatisticsType stats_type;
|
|
7209
7238
|
|
|
7210
7239
|
public:
|
|
7240
|
+
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type, StatisticsType stats_type);
|
|
7241
|
+
|
|
7211
7242
|
bool CanHaveNull() const;
|
|
7212
7243
|
bool CanHaveNoNull() const;
|
|
7213
7244
|
|
|
7245
|
+
void UpdateDistinctStatistics(Vector &v, idx_t count);
|
|
7246
|
+
|
|
7214
7247
|
virtual bool IsConstant() const {
|
|
7215
7248
|
return false;
|
|
7216
7249
|
}
|
|
7217
7250
|
|
|
7218
|
-
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type);
|
|
7219
|
-
|
|
7220
7251
|
virtual void Merge(const BaseStatistics &other);
|
|
7221
7252
|
|
|
7222
7253
|
virtual unique_ptr<BaseStatistics> Copy() const;
|
|
7223
|
-
void
|
|
7254
|
+
void CopyBase(const BaseStatistics &orig);
|
|
7255
|
+
|
|
7256
|
+
virtual void Serialize(Serializer &serializer) const;
|
|
7224
7257
|
virtual void Serialize(FieldWriter &writer) const;
|
|
7258
|
+
|
|
7225
7259
|
static unique_ptr<BaseStatistics> Deserialize(Deserializer &source, LogicalType type);
|
|
7226
7260
|
|
|
7227
7261
|
//! Verify that a vector does not violate the statistics
|
|
@@ -7229,12 +7263,20 @@ public:
|
|
|
7229
7263
|
void Verify(Vector &vector, idx_t count) const;
|
|
7230
7264
|
|
|
7231
7265
|
virtual string ToString() const;
|
|
7266
|
+
|
|
7267
|
+
protected:
|
|
7268
|
+
void InitializeBase();
|
|
7232
7269
|
};
|
|
7233
7270
|
|
|
7234
7271
|
} // namespace duckdb
|
|
7235
7272
|
|
|
7236
7273
|
|
|
7237
7274
|
namespace duckdb {
|
|
7275
|
+
|
|
7276
|
+
struct FunctionLocalState {
|
|
7277
|
+
DUCKDB_API virtual ~FunctionLocalState();
|
|
7278
|
+
};
|
|
7279
|
+
|
|
7238
7280
|
class BoundFunctionExpression;
|
|
7239
7281
|
class ScalarFunctionCatalogEntry;
|
|
7240
7282
|
|
|
@@ -7243,7 +7285,8 @@ typedef std::function<void(DataChunk &, ExpressionState &, Vector &)> scalar_fun
|
|
|
7243
7285
|
//! Binds the scalar function and creates the function data
|
|
7244
7286
|
typedef unique_ptr<FunctionData> (*bind_scalar_function_t)(ClientContext &context, ScalarFunction &bound_function,
|
|
7245
7287
|
vector<unique_ptr<Expression>> &arguments);
|
|
7246
|
-
typedef unique_ptr<
|
|
7288
|
+
typedef unique_ptr<FunctionLocalState> (*init_local_state_t)(const BoundFunctionExpression &expr,
|
|
7289
|
+
FunctionData *bind_data);
|
|
7247
7290
|
typedef unique_ptr<BaseStatistics> (*function_statistics_t)(ClientContext &context, BoundFunctionExpression &expr,
|
|
7248
7291
|
FunctionData *bind_data,
|
|
7249
7292
|
vector<unique_ptr<BaseStatistics>> &child_stats);
|
|
@@ -7285,10 +7328,9 @@ public:
|
|
|
7285
7328
|
vector<unique_ptr<Expression>> children,
|
|
7286
7329
|
string &error, bool is_operator = false);
|
|
7287
7330
|
|
|
7288
|
-
DUCKDB_API static unique_ptr<BoundFunctionExpression>
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
bool is_operator = false);
|
|
7331
|
+
DUCKDB_API static unique_ptr<BoundFunctionExpression>
|
|
7332
|
+
BindScalarFunction(ClientContext &context, ScalarFunction bound_function, vector<unique_ptr<Expression>> children,
|
|
7333
|
+
bool is_operator = false, bool cast_parameters = true);
|
|
7292
7334
|
|
|
7293
7335
|
DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
|
|
7294
7336
|
DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
|
|
@@ -7716,13 +7758,13 @@ public:
|
|
|
7716
7758
|
}
|
|
7717
7759
|
|
|
7718
7760
|
template <class STATE_TYPE, class OP>
|
|
7719
|
-
static void Combine(Vector &source, Vector &target, idx_t count) {
|
|
7761
|
+
static void Combine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
7720
7762
|
D_ASSERT(source.GetType().id() == LogicalTypeId::POINTER && target.GetType().id() == LogicalTypeId::POINTER);
|
|
7721
7763
|
auto sdata = FlatVector::GetData<const STATE_TYPE *>(source);
|
|
7722
7764
|
auto tdata = FlatVector::GetData<STATE_TYPE *>(target);
|
|
7723
7765
|
|
|
7724
7766
|
for (idx_t i = 0; i < count; i++) {
|
|
7725
|
-
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i]);
|
|
7767
|
+
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i], bind_data);
|
|
7726
7768
|
}
|
|
7727
7769
|
}
|
|
7728
7770
|
|
|
@@ -8351,6 +8393,9 @@ public:
|
|
|
8351
8393
|
//! Gets the "schema.name" entry without a specified type, if entry does not exist an exception is thrown
|
|
8352
8394
|
DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &schema, const string &name);
|
|
8353
8395
|
|
|
8396
|
+
//! Fetches a logical type from the catalog
|
|
8397
|
+
DUCKDB_API LogicalType GetType(ClientContext &context, const string &schema, const string &name);
|
|
8398
|
+
|
|
8354
8399
|
template <class T>
|
|
8355
8400
|
T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
|
|
8356
8401
|
QueryErrorContext error_context = QueryErrorContext());
|
|
@@ -8409,6 +8454,9 @@ DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &conte
|
|
|
8409
8454
|
template <>
|
|
8410
8455
|
DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
8411
8456
|
bool if_exists, QueryErrorContext error_context);
|
|
8457
|
+
template <>
|
|
8458
|
+
DUCKDB_API TypeCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
8459
|
+
bool if_exists, QueryErrorContext error_context);
|
|
8412
8460
|
|
|
8413
8461
|
} // namespace duckdb
|
|
8414
8462
|
|
|
@@ -8953,8 +9001,8 @@ typedef void (*aggregate_initialize_t)(data_ptr_t state);
|
|
|
8953
9001
|
//! The type used for updating hashed aggregate functions
|
|
8954
9002
|
typedef void (*aggregate_update_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, Vector &state,
|
|
8955
9003
|
idx_t count);
|
|
8956
|
-
//! The type used for combining hashed aggregate states
|
|
8957
|
-
typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, idx_t count);
|
|
9004
|
+
//! The type used for combining hashed aggregate states
|
|
9005
|
+
typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count);
|
|
8958
9006
|
//! The type used for finalizing hashed aggregate function payloads
|
|
8959
9007
|
typedef void (*aggregate_finalize_t)(Vector &state, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset);
|
|
8960
9008
|
//! The type used for propagating statistics in aggregate functions (optional)
|
|
@@ -9058,7 +9106,8 @@ public:
|
|
|
9058
9106
|
DUCKDB_API static unique_ptr<BoundAggregateExpression>
|
|
9059
9107
|
BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
|
|
9060
9108
|
vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
|
|
9061
|
-
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr
|
|
9109
|
+
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr,
|
|
9110
|
+
bool cast_parameters = true);
|
|
9062
9111
|
|
|
9063
9112
|
DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
|
|
9064
9113
|
vector<unique_ptr<Expression>> &children,
|
|
@@ -9164,8 +9213,8 @@ public:
|
|
|
9164
9213
|
}
|
|
9165
9214
|
|
|
9166
9215
|
template <class STATE, class OP>
|
|
9167
|
-
static void StateCombine(Vector &source, Vector &target, idx_t count) {
|
|
9168
|
-
AggregateExecutor::Combine<STATE, OP>(source, target, count);
|
|
9216
|
+
static void StateCombine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
9217
|
+
AggregateExecutor::Combine<STATE, OP>(source, target, bind_data, count);
|
|
9169
9218
|
}
|
|
9170
9219
|
|
|
9171
9220
|
template <class STATE, class RESULT_TYPE, class OP>
|
|
@@ -9748,7 +9797,32 @@ enum class StatementType : uint8_t {
|
|
|
9748
9797
|
};
|
|
9749
9798
|
|
|
9750
9799
|
string StatementTypeToString(StatementType type);
|
|
9751
|
-
|
|
9800
|
+
|
|
9801
|
+
enum class StatementReturnType : uint8_t {
|
|
9802
|
+
QUERY_RESULT, // the statement returns a query result (e.g. for display to the user)
|
|
9803
|
+
CHANGED_ROWS, // the statement returns a single row containing the number of changed rows (e.g. an insert stmt)
|
|
9804
|
+
NOTHING // the statement returns nothing
|
|
9805
|
+
};
|
|
9806
|
+
|
|
9807
|
+
//! A struct containing various properties of a SQL statement
|
|
9808
|
+
struct StatementProperties {
|
|
9809
|
+
StatementProperties()
|
|
9810
|
+
: read_only(true), requires_valid_transaction(true), allow_stream_result(false), bound_all_parameters(true),
|
|
9811
|
+
return_type(StatementReturnType::QUERY_RESULT) {
|
|
9812
|
+
}
|
|
9813
|
+
|
|
9814
|
+
//! Whether or not the statement is a read-only statement, or whether it can result in changes to the database
|
|
9815
|
+
bool read_only;
|
|
9816
|
+
//! Whether or not the statement requires a valid transaction. Almost all statements require this, with the
|
|
9817
|
+
//! exception of
|
|
9818
|
+
bool requires_valid_transaction;
|
|
9819
|
+
//! Whether or not the result can be streamed to the client
|
|
9820
|
+
bool allow_stream_result;
|
|
9821
|
+
//! Whether or not all parameters have successfully had their types determined
|
|
9822
|
+
bool bound_all_parameters;
|
|
9823
|
+
//! What type of data the statement returns
|
|
9824
|
+
StatementReturnType return_type;
|
|
9825
|
+
};
|
|
9752
9826
|
|
|
9753
9827
|
} // namespace duckdb
|
|
9754
9828
|
|
|
@@ -9763,11 +9837,9 @@ enum class QueryResultType : uint8_t { MATERIALIZED_RESULT, STREAM_RESULT, PENDI
|
|
|
9763
9837
|
|
|
9764
9838
|
class BaseQueryResult {
|
|
9765
9839
|
public:
|
|
9766
|
-
//! Creates a successful empty query result
|
|
9767
|
-
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type);
|
|
9768
9840
|
//! Creates a successful query result with the specified names and types
|
|
9769
|
-
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type,
|
|
9770
|
-
vector<string> names);
|
|
9841
|
+
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
9842
|
+
vector<LogicalType> types, vector<string> names);
|
|
9771
9843
|
//! Creates an unsuccessful query result with error condition
|
|
9772
9844
|
DUCKDB_API BaseQueryResult(QueryResultType type, string error);
|
|
9773
9845
|
DUCKDB_API virtual ~BaseQueryResult();
|
|
@@ -9776,6 +9848,8 @@ public:
|
|
|
9776
9848
|
QueryResultType type;
|
|
9777
9849
|
//! The type of the statement that created this result
|
|
9778
9850
|
StatementType statement_type;
|
|
9851
|
+
//! Properties of the statement
|
|
9852
|
+
StatementProperties properties;
|
|
9779
9853
|
//! The SQL types of the result
|
|
9780
9854
|
vector<LogicalType> types;
|
|
9781
9855
|
//! The names of the result
|
|
@@ -9796,11 +9870,9 @@ public:
|
|
|
9796
9870
|
//! incrementally fetch data from the database.
|
|
9797
9871
|
class QueryResult : public BaseQueryResult {
|
|
9798
9872
|
public:
|
|
9799
|
-
//! Creates a successful empty query result
|
|
9800
|
-
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type);
|
|
9801
9873
|
//! Creates a successful query result with the specified names and types
|
|
9802
|
-
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type,
|
|
9803
|
-
vector<string> names);
|
|
9874
|
+
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
9875
|
+
vector<LogicalType> types, vector<string> names);
|
|
9804
9876
|
//! Creates an unsuccessful query result with error condition
|
|
9805
9877
|
DUCKDB_API QueryResult(QueryResultType type, string error);
|
|
9806
9878
|
DUCKDB_API virtual ~QueryResult() override;
|
|
@@ -9836,7 +9908,10 @@ public:
|
|
|
9836
9908
|
}
|
|
9837
9909
|
}
|
|
9838
9910
|
|
|
9839
|
-
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names
|
|
9911
|
+
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names,
|
|
9912
|
+
string &config_timezone);
|
|
9913
|
+
|
|
9914
|
+
static string GetConfigTimezone(QueryResult &query_result);
|
|
9840
9915
|
|
|
9841
9916
|
private:
|
|
9842
9917
|
//! The current chunk used by the iterator
|
|
@@ -9914,17 +9989,25 @@ private:
|
|
|
9914
9989
|
|
|
9915
9990
|
namespace duckdb {
|
|
9916
9991
|
|
|
9992
|
+
class ClientContext;
|
|
9993
|
+
|
|
9917
9994
|
class MaterializedQueryResult : public QueryResult {
|
|
9918
9995
|
public:
|
|
9996
|
+
friend class ClientContext;
|
|
9919
9997
|
//! Creates an empty successful query result
|
|
9920
9998
|
DUCKDB_API explicit MaterializedQueryResult(StatementType statement_type);
|
|
9921
9999
|
//! Creates a successful query result with the specified names and types
|
|
9922
|
-
DUCKDB_API MaterializedQueryResult(StatementType statement_type,
|
|
10000
|
+
DUCKDB_API MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
|
|
10001
|
+
vector<LogicalType> types, vector<string> names,
|
|
10002
|
+
const shared_ptr<ClientContext> &context);
|
|
9923
10003
|
//! Creates an unsuccessful query result with error condition
|
|
9924
10004
|
DUCKDB_API explicit MaterializedQueryResult(string error);
|
|
9925
10005
|
|
|
9926
10006
|
ChunkCollection collection;
|
|
9927
10007
|
|
|
10008
|
+
//! The client context this MaterializedQueryResult belongs to
|
|
10009
|
+
std::weak_ptr<ClientContext> context;
|
|
10010
|
+
|
|
9928
10011
|
public:
|
|
9929
10012
|
//! Fetches a DataChunk from the query result.
|
|
9930
10013
|
//! This will consume the result (i.e. the chunks are taken directly from the ChunkCollection).
|
|
@@ -10352,9 +10435,12 @@ public:
|
|
|
10352
10435
|
|
|
10353
10436
|
|
|
10354
10437
|
|
|
10438
|
+
|
|
10439
|
+
|
|
10355
10440
|
#include <functional>
|
|
10356
10441
|
|
|
10357
10442
|
namespace duckdb {
|
|
10443
|
+
|
|
10358
10444
|
class BaseStatistics;
|
|
10359
10445
|
class LogicalGet;
|
|
10360
10446
|
struct ParallelState;
|
|
@@ -10397,10 +10483,14 @@ typedef unique_ptr<FunctionOperatorData> (*table_function_init_t)(ClientContext
|
|
|
10397
10483
|
typedef unique_ptr<BaseStatistics> (*table_statistics_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10398
10484
|
column_t column_index);
|
|
10399
10485
|
typedef void (*table_function_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10400
|
-
FunctionOperatorData *operator_state, DataChunk
|
|
10486
|
+
FunctionOperatorData *operator_state, DataChunk &output);
|
|
10487
|
+
|
|
10488
|
+
typedef OperatorResultType (*table_in_out_function_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10489
|
+
FunctionOperatorData *operator_state, DataChunk &input,
|
|
10490
|
+
DataChunk &output);
|
|
10401
10491
|
|
|
10402
10492
|
typedef void (*table_function_parallel_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10403
|
-
FunctionOperatorData *operator_state, DataChunk
|
|
10493
|
+
FunctionOperatorData *operator_state, DataChunk &output,
|
|
10404
10494
|
ParallelState *parallel_state);
|
|
10405
10495
|
|
|
10406
10496
|
typedef void (*table_function_cleanup_t)(ClientContext &context, const FunctionData *bind_data,
|
|
@@ -10439,7 +10529,8 @@ public:
|
|
|
10439
10529
|
table_function_parallel_t parallel_function = nullptr,
|
|
10440
10530
|
table_function_init_parallel_t parallel_init = nullptr,
|
|
10441
10531
|
table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
|
|
10442
|
-
bool filter_pushdown = false, table_function_progress_t query_progress = nullptr
|
|
10532
|
+
bool filter_pushdown = false, table_function_progress_t query_progress = nullptr,
|
|
10533
|
+
table_in_out_function_t in_out_function = nullptr);
|
|
10443
10534
|
DUCKDB_API
|
|
10444
10535
|
TableFunction(const vector<LogicalType> &arguments, table_function_t function, table_function_bind_t bind = nullptr,
|
|
10445
10536
|
table_function_init_t init = nullptr, table_statistics_t statistics = nullptr,
|
|
@@ -10451,7 +10542,8 @@ public:
|
|
|
10451
10542
|
table_function_parallel_t parallel_function = nullptr,
|
|
10452
10543
|
table_function_init_parallel_t parallel_init = nullptr,
|
|
10453
10544
|
table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
|
|
10454
|
-
bool filter_pushdown = false, table_function_progress_t query_progress = nullptr
|
|
10545
|
+
bool filter_pushdown = false, table_function_progress_t query_progress = nullptr,
|
|
10546
|
+
table_in_out_function_t in_out_function = nullptr);
|
|
10455
10547
|
DUCKDB_API TableFunction();
|
|
10456
10548
|
|
|
10457
10549
|
//! Bind function
|
|
@@ -10464,6 +10556,8 @@ public:
|
|
|
10464
10556
|
table_function_init_t init;
|
|
10465
10557
|
//! The main function
|
|
10466
10558
|
table_function_t function;
|
|
10559
|
+
//! The table in-out function (if this is an in-out function)
|
|
10560
|
+
table_in_out_function_t in_out_function;
|
|
10467
10561
|
//! (Optional) statistics function
|
|
10468
10562
|
//! Returns the statistics of a specified column
|
|
10469
10563
|
table_statistics_t statistics;
|
|
@@ -10611,11 +10705,11 @@ struct ProducerToken {
|
|
|
10611
10705
|
|
|
10612
10706
|
//! The TaskScheduler is responsible for managing tasks and threads
|
|
10613
10707
|
class TaskScheduler {
|
|
10614
|
-
// timeout for semaphore wait, default
|
|
10615
|
-
constexpr static int64_t TASK_TIMEOUT_USECS =
|
|
10708
|
+
// timeout for semaphore wait, default 5ms
|
|
10709
|
+
constexpr static int64_t TASK_TIMEOUT_USECS = 5000;
|
|
10616
10710
|
|
|
10617
10711
|
public:
|
|
10618
|
-
TaskScheduler();
|
|
10712
|
+
TaskScheduler(DatabaseInstance &db);
|
|
10619
10713
|
~TaskScheduler();
|
|
10620
10714
|
|
|
10621
10715
|
static TaskScheduler &GetScheduler(ClientContext &context);
|
|
@@ -10628,6 +10722,8 @@ public:
|
|
|
10628
10722
|
bool GetTaskFromProducer(ProducerToken &token, unique_ptr<Task> &task);
|
|
10629
10723
|
//! Run tasks forever until "marker" is set to false, "marker" must remain valid until the thread is joined
|
|
10630
10724
|
void ExecuteForever(atomic<bool> *marker);
|
|
10725
|
+
//! Run tasks until `max_tasks` have been completed, or until there are no more tasks available
|
|
10726
|
+
void ExecuteTasks(idx_t max_tasks);
|
|
10631
10727
|
|
|
10632
10728
|
//! Sets the amount of active threads executing tasks for the system; n-1 background threads will be launched.
|
|
10633
10729
|
//! The main thread will also be used for execution
|
|
@@ -10638,6 +10734,8 @@ public:
|
|
|
10638
10734
|
private:
|
|
10639
10735
|
void SetThreadsInternal(int32_t n);
|
|
10640
10736
|
|
|
10737
|
+
private:
|
|
10738
|
+
DatabaseInstance &db;
|
|
10641
10739
|
//! The task queue
|
|
10642
10740
|
unique_ptr<ConcurrentQueue> queue;
|
|
10643
10741
|
//! The active background threads of the task scheduler
|
|
@@ -10968,6 +11066,8 @@ public:
|
|
|
10968
11066
|
idx_t ColumnCount();
|
|
10969
11067
|
//! Returns the statement type of the underlying prepared statement object
|
|
10970
11068
|
StatementType GetStatementType();
|
|
11069
|
+
//! Returns the underlying statement properties
|
|
11070
|
+
StatementProperties GetStatementProperties();
|
|
10971
11071
|
//! Returns the result SQL types of the prepared statement
|
|
10972
11072
|
const vector<LogicalType> &GetTypes();
|
|
10973
11073
|
//! Returns the result names of the prepared statement
|
|
@@ -13124,6 +13224,7 @@ public:
|
|
|
13124
13224
|
string Bind(unique_ptr<ParsedExpression> *expr, idx_t depth, bool root_expression = false);
|
|
13125
13225
|
|
|
13126
13226
|
unique_ptr<ParsedExpression> CreateStructExtract(unique_ptr<ParsedExpression> base, string field_name);
|
|
13227
|
+
unique_ptr<ParsedExpression> CreateStructPack(ColumnRefExpression &colref);
|
|
13127
13228
|
BindResult BindQualifiedColumnName(ColumnRefExpression &colref, const string &table_name);
|
|
13128
13229
|
|
|
13129
13230
|
unique_ptr<ParsedExpression> QualifyColumnName(const string &column_name, string &error_message);
|
|
@@ -13147,9 +13248,6 @@ public:
|
|
|
13147
13248
|
static bool ContainsType(const LogicalType &type, LogicalTypeId target);
|
|
13148
13249
|
static LogicalType ExchangeType(const LogicalType &type, LogicalTypeId target, LogicalType new_type);
|
|
13149
13250
|
|
|
13150
|
-
static void ResolveParameterType(LogicalType &type);
|
|
13151
|
-
static void ResolveParameterType(unique_ptr<Expression> &expr);
|
|
13152
|
-
|
|
13153
13251
|
//! Bind the given expresion. Unlike Bind(), this does *not* mute the given ParsedExpression.
|
|
13154
13252
|
//! Exposed to be used from sub-binders that aren't subclasses of ExpressionBinder.
|
|
13155
13253
|
virtual BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
|
|
@@ -13171,7 +13269,6 @@ protected:
|
|
|
13171
13269
|
BindResult BindExpression(OperatorExpression &expr, idx_t depth);
|
|
13172
13270
|
BindResult BindExpression(ParameterExpression &expr, idx_t depth);
|
|
13173
13271
|
BindResult BindExpression(PositionalReferenceExpression &ref, idx_t depth);
|
|
13174
|
-
BindResult BindExpression(StarExpression &expr, idx_t depth);
|
|
13175
13272
|
BindResult BindExpression(SubqueryExpression &expr, idx_t depth);
|
|
13176
13273
|
|
|
13177
13274
|
protected:
|
|
@@ -13421,7 +13518,6 @@ private:
|
|
|
13421
13518
|
|
|
13422
13519
|
|
|
13423
13520
|
|
|
13424
|
-
//#include "duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp"
|
|
13425
13521
|
|
|
13426
13522
|
namespace duckdb {
|
|
13427
13523
|
class BoundResultModifier;
|
|
@@ -13483,12 +13579,10 @@ public:
|
|
|
13483
13579
|
vector<CorrelatedColumnInfo> correlated_columns;
|
|
13484
13580
|
//! The set of parameter expressions bound by this binder
|
|
13485
13581
|
vector<BoundParameterExpression *> *parameters;
|
|
13486
|
-
//!
|
|
13487
|
-
|
|
13488
|
-
//!
|
|
13489
|
-
|
|
13490
|
-
//! Whether or not the statement can be streamed to the client
|
|
13491
|
-
bool allow_stream_result;
|
|
13582
|
+
//! The types of the prepared statement parameters, if any
|
|
13583
|
+
vector<LogicalType> *parameter_types;
|
|
13584
|
+
//! Statement properties
|
|
13585
|
+
StatementProperties properties;
|
|
13492
13586
|
//! The alias for the currently processing subquery, if it exists
|
|
13493
13587
|
string alias;
|
|
13494
13588
|
//! Macro parameter bindings (if any)
|
|
@@ -13641,9 +13735,12 @@ private:
|
|
|
13641
13735
|
unique_ptr<BoundTableRef> Bind(EmptyTableRef &ref);
|
|
13642
13736
|
unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
|
|
13643
13737
|
|
|
13644
|
-
bool
|
|
13645
|
-
|
|
13646
|
-
|
|
13738
|
+
bool BindTableFunctionParameters(TableFunctionCatalogEntry &table_function,
|
|
13739
|
+
vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
|
|
13740
|
+
vector<Value> ¶meters, named_parameter_map_t &named_parameters,
|
|
13741
|
+
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
13742
|
+
bool BindTableInTableOutFunction(vector<unique_ptr<ParsedExpression>> &expressions,
|
|
13743
|
+
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
13647
13744
|
|
|
13648
13745
|
unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
|
|
13649
13746
|
unique_ptr<LogicalOperator> CreatePlan(BoundCrossProductRef &ref);
|
|
@@ -13781,6 +13878,7 @@ public:
|
|
|
13781
13878
|
|
|
13782
13879
|
|
|
13783
13880
|
namespace duckdb {
|
|
13881
|
+
|
|
13784
13882
|
//! SQLStatement is the base class of any type of SQL statement.
|
|
13785
13883
|
class SQLStatement {
|
|
13786
13884
|
public:
|
|
@@ -13803,6 +13901,9 @@ protected:
|
|
|
13803
13901
|
SQLStatement(const SQLStatement &other) = default;
|
|
13804
13902
|
|
|
13805
13903
|
public:
|
|
13904
|
+
virtual string ToString() const {
|
|
13905
|
+
throw InternalException("ToString not supported for this type of SQLStatement");
|
|
13906
|
+
}
|
|
13806
13907
|
//! Create a copy of this SelectStatement
|
|
13807
13908
|
virtual unique_ptr<SQLStatement> Copy() const = 0;
|
|
13808
13909
|
};
|
|
@@ -13907,7 +14008,9 @@ public:
|
|
|
13907
14008
|
|
|
13908
14009
|
public:
|
|
13909
14010
|
//! Convert the object to a string
|
|
13910
|
-
virtual string ToString() const;
|
|
14011
|
+
virtual string ToString() const = 0;
|
|
14012
|
+
string BaseToString(string result) const;
|
|
14013
|
+
string BaseToString(string result, const vector<string> &column_name_alias) const;
|
|
13911
14014
|
void Print();
|
|
13912
14015
|
|
|
13913
14016
|
virtual bool Equals(const TableRef *other) const;
|
|
@@ -13944,6 +14047,8 @@ protected:
|
|
|
13944
14047
|
SelectStatement(const SelectStatement &other);
|
|
13945
14048
|
|
|
13946
14049
|
public:
|
|
14050
|
+
//! Convert the SELECT statement to a string
|
|
14051
|
+
string ToString() const override;
|
|
13947
14052
|
//! Create a copy of this SelectStatement
|
|
13948
14053
|
unique_ptr<SQLStatement> Copy() const override;
|
|
13949
14054
|
//! Serializes a SelectStatement to a stand-alone binary blob
|
|
@@ -13995,6 +14100,9 @@ public:
|
|
|
13995
14100
|
virtual const vector<unique_ptr<ParsedExpression>> &GetSelectList() const = 0;
|
|
13996
14101
|
|
|
13997
14102
|
public:
|
|
14103
|
+
//! Convert the query node to a string
|
|
14104
|
+
virtual string ToString() const = 0;
|
|
14105
|
+
|
|
13998
14106
|
virtual bool Equals(const QueryNode *other) const;
|
|
13999
14107
|
|
|
14000
14108
|
//! Create a copy of this QueryNode
|
|
@@ -14006,6 +14114,9 @@ public:
|
|
|
14006
14114
|
//! Deserializes a blob back into a QueryNode
|
|
14007
14115
|
DUCKDB_API static unique_ptr<QueryNode> Deserialize(Deserializer &source);
|
|
14008
14116
|
|
|
14117
|
+
string CTEToString() const;
|
|
14118
|
+
string ResultModifiersToString() const;
|
|
14119
|
+
|
|
14009
14120
|
protected:
|
|
14010
14121
|
//! Copy base QueryNode properties from another expression to this one,
|
|
14011
14122
|
//! used in Copy method
|
|
@@ -14818,6 +14929,11 @@ private:
|
|
|
14818
14929
|
void DeleteMapping(ClientContext &context, const string &name);
|
|
14819
14930
|
void DropEntryDependencies(ClientContext &context, idx_t entry_index, CatalogEntry &entry, bool cascade);
|
|
14820
14931
|
|
|
14932
|
+
//! Create all default entries
|
|
14933
|
+
void CreateDefaultEntries(ClientContext &context, unique_lock<mutex> &lock);
|
|
14934
|
+
//! Attempt to create a default entry with the specified name. Returns the entry if successful, nullptr otherwise.
|
|
14935
|
+
CatalogEntry *CreateDefaultEntry(ClientContext &context, const string &name, unique_lock<mutex> &lock);
|
|
14936
|
+
|
|
14821
14937
|
private:
|
|
14822
14938
|
Catalog &catalog;
|
|
14823
14939
|
//! The catalog lock is used to make changes to the data
|
|
@@ -16896,6 +17012,19 @@ Closes the result and de-allocates all memory allocated for the arrow result.
|
|
|
16896
17012
|
*/
|
|
16897
17013
|
DUCKDB_API void duckdb_destroy_arrow(duckdb_arrow *result);
|
|
16898
17014
|
|
|
17015
|
+
//===--------------------------------------------------------------------===//
|
|
17016
|
+
// Threading Information
|
|
17017
|
+
//===--------------------------------------------------------------------===//
|
|
17018
|
+
/*!
|
|
17019
|
+
Execute DuckDB tasks on this thread.
|
|
17020
|
+
|
|
17021
|
+
Will return after `max_tasks` have been executed, or if there are no more tasks present.
|
|
17022
|
+
|
|
17023
|
+
* database: The database object to execute tasks for
|
|
17024
|
+
* max_tasks: The maximum amount of tasks to execute
|
|
17025
|
+
*/
|
|
17026
|
+
DUCKDB_API void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks);
|
|
17027
|
+
|
|
16899
17028
|
#ifdef __cplusplus
|
|
16900
17029
|
}
|
|
16901
17030
|
#endif
|
|
@@ -17014,8 +17143,8 @@ class StreamQueryResult : public QueryResult {
|
|
|
17014
17143
|
public:
|
|
17015
17144
|
//! Create a successful StreamQueryResult. StreamQueryResults should always be successful initially (it makes no
|
|
17016
17145
|
//! sense to stream an error).
|
|
17017
|
-
DUCKDB_API StreamQueryResult(StatementType statement_type,
|
|
17018
|
-
vector<LogicalType> types, vector<string> names);
|
|
17146
|
+
DUCKDB_API StreamQueryResult(StatementType statement_type, StatementProperties properties,
|
|
17147
|
+
shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names);
|
|
17019
17148
|
DUCKDB_API ~StreamQueryResult() override;
|
|
17020
17149
|
|
|
17021
17150
|
public:
|
|
@@ -17031,7 +17160,6 @@ public:
|
|
|
17031
17160
|
//! Closes the StreamQueryResult
|
|
17032
17161
|
DUCKDB_API void Close();
|
|
17033
17162
|
|
|
17034
|
-
private:
|
|
17035
17163
|
//! The client context this StreamQueryResult belongs to
|
|
17036
17164
|
shared_ptr<ClientContext> context;
|
|
17037
17165
|
|
|
@@ -17128,7 +17256,6 @@ private:
|
|
|
17128
17256
|
} // namespace duckdb
|
|
17129
17257
|
|
|
17130
17258
|
|
|
17131
|
-
#include <random>
|
|
17132
17259
|
|
|
17133
17260
|
//===----------------------------------------------------------------------===//
|
|
17134
17261
|
// DuckDB
|
|
@@ -17187,6 +17314,8 @@ struct ClientConfig {
|
|
|
17187
17314
|
//! Preserve identifier case while parsing.
|
|
17188
17315
|
//! If false, all unquoted identifiers are lower-cased (e.g. "MyTable" -> "mytable").
|
|
17189
17316
|
bool preserve_identifier_case = true;
|
|
17317
|
+
//! The maximum expression depth limit in the parser
|
|
17318
|
+
idx_t max_expression_depth = 1000;
|
|
17190
17319
|
|
|
17191
17320
|
// Whether or not aggressive query verification is enabled
|
|
17192
17321
|
bool query_verification_enabled = false;
|
|
@@ -17210,6 +17339,8 @@ struct ClientConfig {
|
|
|
17210
17339
|
|
|
17211
17340
|
public:
|
|
17212
17341
|
static ClientConfig &GetConfig(ClientContext &context);
|
|
17342
|
+
|
|
17343
|
+
static string ExtractTimezoneFromConfig(ClientConfig &config);
|
|
17213
17344
|
};
|
|
17214
17345
|
|
|
17215
17346
|
} // namespace duckdb
|
|
@@ -17248,12 +17379,12 @@ class PreparedStatementData;
|
|
|
17248
17379
|
class Relation;
|
|
17249
17380
|
class BufferedFileWriter;
|
|
17250
17381
|
class QueryProfiler;
|
|
17251
|
-
class QueryProfilerHistory;
|
|
17252
17382
|
class ClientContextLock;
|
|
17253
17383
|
struct CreateScalarFunctionInfo;
|
|
17254
17384
|
class ScalarFunctionCatalogEntry;
|
|
17255
17385
|
struct ActiveQueryContext;
|
|
17256
17386
|
struct ParserOptions;
|
|
17387
|
+
struct ClientData;
|
|
17257
17388
|
|
|
17258
17389
|
//! The ClientContext holds information relevant to the current client session
|
|
17259
17390
|
//! during execution
|
|
@@ -17266,10 +17397,6 @@ public:
|
|
|
17266
17397
|
DUCKDB_API explicit ClientContext(shared_ptr<DatabaseInstance> db);
|
|
17267
17398
|
DUCKDB_API ~ClientContext();
|
|
17268
17399
|
|
|
17269
|
-
//! Query profiler
|
|
17270
|
-
shared_ptr<QueryProfiler> profiler;
|
|
17271
|
-
//! QueryProfiler History
|
|
17272
|
-
unique_ptr<QueryProfilerHistory> query_profiler_history;
|
|
17273
17400
|
//! The database that this client is connected to
|
|
17274
17401
|
shared_ptr<DatabaseInstance> db;
|
|
17275
17402
|
//! Data for the currently running transaction
|
|
@@ -17279,20 +17406,10 @@ public:
|
|
|
17279
17406
|
//! External Objects (e.g., Python objects) that views depend of
|
|
17280
17407
|
unordered_map<string, vector<shared_ptr<ExternalDependency>>> external_dependencies;
|
|
17281
17408
|
|
|
17282
|
-
unique_ptr<SchemaCatalogEntry> temporary_objects;
|
|
17283
|
-
unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
|
|
17284
|
-
|
|
17285
|
-
//! The writer used to log queries (if logging is enabled)
|
|
17286
|
-
unique_ptr<BufferedFileWriter> log_query_writer;
|
|
17287
|
-
//! The random generator used by random(). Its seed value can be set by setseed().
|
|
17288
|
-
std::mt19937 random_engine;
|
|
17289
|
-
|
|
17290
|
-
const unique_ptr<CatalogSearchPath> catalog_search_path;
|
|
17291
|
-
|
|
17292
|
-
unique_ptr<FileOpener> file_opener;
|
|
17293
|
-
|
|
17294
17409
|
//! The client configuration
|
|
17295
17410
|
ClientConfig config;
|
|
17411
|
+
//! The set of client-specific data
|
|
17412
|
+
unique_ptr<ClientData> client_data;
|
|
17296
17413
|
|
|
17297
17414
|
public:
|
|
17298
17415
|
DUCKDB_API Transaction &ActiveTransaction() {
|
|
@@ -17421,7 +17538,8 @@ private:
|
|
|
17421
17538
|
|
|
17422
17539
|
//! Internally prepare a SQL statement. Caller must hold the context_lock.
|
|
17423
17540
|
shared_ptr<PreparedStatementData> CreatePreparedStatement(ClientContextLock &lock, const string &query,
|
|
17424
|
-
unique_ptr<SQLStatement> statement
|
|
17541
|
+
unique_ptr<SQLStatement> statement,
|
|
17542
|
+
vector<Value> *values = nullptr);
|
|
17425
17543
|
unique_ptr<PendingQueryResult> PendingStatementInternal(ClientContextLock &lock, const string &query,
|
|
17426
17544
|
unique_ptr<SQLStatement> statement);
|
|
17427
17545
|
unique_ptr<QueryResult> RunStatementInternal(ClientContextLock &lock, const string &query,
|
|
@@ -18158,6 +18276,8 @@ public:
|
|
|
18158
18276
|
idx_t maximum_memory = (idx_t)-1;
|
|
18159
18277
|
//! The maximum amount of CPU threads used by the database system. Default: all available.
|
|
18160
18278
|
idx_t maximum_threads = (idx_t)-1;
|
|
18279
|
+
//! The number of external threads that work on DuckDB tasks. Default: none.
|
|
18280
|
+
idx_t external_threads = 0;
|
|
18161
18281
|
//! Whether or not to create and use a temporary directory to store intermediates that do not fit in memory
|
|
18162
18282
|
bool use_temporary_directory = true;
|
|
18163
18283
|
//! Directory to store temporary structures that do not fit in memory
|
|
@@ -18427,14 +18547,14 @@ public:
|
|
|
18427
18547
|
static const int8_t MONTH_PER_DAY_OF_YEAR[365];
|
|
18428
18548
|
static const int8_t LEAP_MONTH_PER_DAY_OF_YEAR[366];
|
|
18429
18549
|
|
|
18430
|
-
// min date is 5877642-06-
|
|
18550
|
+
// min date is 5877642-06-25 (BC) (-2^31+2)
|
|
18431
18551
|
constexpr static const int32_t DATE_MIN_YEAR = -5877641;
|
|
18432
18552
|
constexpr static const int32_t DATE_MIN_MONTH = 6;
|
|
18433
|
-
constexpr static const int32_t DATE_MIN_DAY =
|
|
18434
|
-
// max date is 5881580-07-
|
|
18553
|
+
constexpr static const int32_t DATE_MIN_DAY = 25;
|
|
18554
|
+
// max date is 5881580-07-10 (2^31-2)
|
|
18435
18555
|
constexpr static const int32_t DATE_MAX_YEAR = 5881580;
|
|
18436
18556
|
constexpr static const int32_t DATE_MAX_MONTH = 7;
|
|
18437
|
-
constexpr static const int32_t DATE_MAX_DAY =
|
|
18557
|
+
constexpr static const int32_t DATE_MAX_DAY = 10;
|
|
18438
18558
|
constexpr static const int32_t EPOCH_YEAR = 1970;
|
|
18439
18559
|
|
|
18440
18560
|
constexpr static const int32_t YEAR_INTERVAL = 400;
|
|
@@ -18467,6 +18587,11 @@ public:
|
|
|
18467
18587
|
//! date
|
|
18468
18588
|
DUCKDB_API static bool IsValid(int32_t year, int32_t month, int32_t day);
|
|
18469
18589
|
|
|
18590
|
+
//! Returns true if the specified date is finite
|
|
18591
|
+
static inline bool IsFinite(date_t date) {
|
|
18592
|
+
return date != date_t::infinity() && date != date_t::ninfinity();
|
|
18593
|
+
}
|
|
18594
|
+
|
|
18470
18595
|
//! The max number of days in a month of a given year
|
|
18471
18596
|
DUCKDB_API static int32_t MonthDays(int32_t year, int32_t month);
|
|
18472
18597
|
|
|
@@ -18667,15 +18792,6 @@ public:
|
|
|
18667
18792
|
|
|
18668
18793
|
namespace duckdb {
|
|
18669
18794
|
|
|
18670
|
-
struct timestamp_struct {
|
|
18671
|
-
int32_t year;
|
|
18672
|
-
int8_t month;
|
|
18673
|
-
int8_t day;
|
|
18674
|
-
int8_t hour;
|
|
18675
|
-
int8_t min;
|
|
18676
|
-
int8_t sec;
|
|
18677
|
-
int16_t msec;
|
|
18678
|
-
};
|
|
18679
18795
|
//! The Timestamp class is a static class that holds helper functions for the Timestamp
|
|
18680
18796
|
//! type.
|
|
18681
18797
|
class Timestamp {
|
|
@@ -18700,6 +18816,11 @@ public:
|
|
|
18700
18816
|
DUCKDB_API static timestamp_t FromDatetime(date_t date, dtime_t time);
|
|
18701
18817
|
DUCKDB_API static bool TryFromDatetime(date_t date, dtime_t time, timestamp_t &result);
|
|
18702
18818
|
|
|
18819
|
+
//! Is the timestamp finite or infinite?
|
|
18820
|
+
static inline bool IsFinite(timestamp_t timestamp) {
|
|
18821
|
+
return timestamp != timestamp_t::infinity() && timestamp != timestamp_t::ninfinity();
|
|
18822
|
+
}
|
|
18823
|
+
|
|
18703
18824
|
//! Extract the date and time from a given timestamp object
|
|
18704
18825
|
DUCKDB_API static void Convert(timestamp_t date, date_t &out_date, dtime_t &out_time);
|
|
18705
18826
|
//! Returns current timestamp
|
|
@@ -21373,6 +21494,7 @@ namespace duckdb {
|
|
|
21373
21494
|
|
|
21374
21495
|
struct ParserOptions {
|
|
21375
21496
|
bool preserve_identifier_case = true;
|
|
21497
|
+
idx_t max_expression_depth = 1000;
|
|
21376
21498
|
};
|
|
21377
21499
|
|
|
21378
21500
|
//! The parser is responsible for parsing the query and converting it into a set
|
|
@@ -21616,7 +21738,7 @@ class Vector;
|
|
|
21616
21738
|
|
|
21617
21739
|
class ValidityStatistics : public BaseStatistics {
|
|
21618
21740
|
public:
|
|
21619
|
-
ValidityStatistics(bool has_null = false, bool has_no_null = true);
|
|
21741
|
+
explicit ValidityStatistics(bool has_null = false, bool has_no_null = true);
|
|
21620
21742
|
|
|
21621
21743
|
//! Whether or not the segment can contain NULL values
|
|
21622
21744
|
bool has_null;
|
|
@@ -21629,8 +21751,10 @@ public:
|
|
|
21629
21751
|
bool IsConstant() const override;
|
|
21630
21752
|
|
|
21631
21753
|
unique_ptr<BaseStatistics> Copy() const override;
|
|
21754
|
+
|
|
21632
21755
|
void Serialize(FieldWriter &writer) const override;
|
|
21633
|
-
static unique_ptr<
|
|
21756
|
+
static unique_ptr<ValidityStatistics> Deserialize(FieldReader &reader);
|
|
21757
|
+
|
|
21634
21758
|
void Verify(Vector &vector, const SelectionVector &sel, idx_t count) const override;
|
|
21635
21759
|
|
|
21636
21760
|
static unique_ptr<BaseStatistics> Combine(const unique_ptr<BaseStatistics> &lstats,
|
|
@@ -21649,7 +21773,7 @@ public:
|
|
|
21649
21773
|
constexpr static uint32_t MAX_STRING_MINMAX_SIZE = 8;
|
|
21650
21774
|
|
|
21651
21775
|
public:
|
|
21652
|
-
explicit StringStatistics(LogicalType type);
|
|
21776
|
+
explicit StringStatistics(LogicalType type, StatisticsType stats_type);
|
|
21653
21777
|
|
|
21654
21778
|
//! The minimum value of the segment, potentially truncated
|
|
21655
21779
|
data_t min[MAX_STRING_MINMAX_SIZE];
|
|
@@ -21743,8 +21867,8 @@ namespace duckdb {
|
|
|
21743
21867
|
|
|
21744
21868
|
class NumericStatistics : public BaseStatistics {
|
|
21745
21869
|
public:
|
|
21746
|
-
explicit NumericStatistics(LogicalType type);
|
|
21747
|
-
NumericStatistics(LogicalType type, Value min, Value max);
|
|
21870
|
+
explicit NumericStatistics(LogicalType type, StatisticsType stats_type);
|
|
21871
|
+
NumericStatistics(LogicalType type, Value min, Value max, StatisticsType stats_type);
|
|
21748
21872
|
|
|
21749
21873
|
//! The minimum value of the segment
|
|
21750
21874
|
Value min;
|
|
@@ -21905,6 +22029,8 @@ public:
|
|
|
21905
22029
|
|
|
21906
22030
|
|
|
21907
22031
|
|
|
22032
|
+
#include <algorithm>
|
|
22033
|
+
|
|
21908
22034
|
namespace duckdb {
|
|
21909
22035
|
|
|
21910
22036
|
enum class StrTimeSpecifier : uint8_t {
|
|
@@ -21952,7 +22078,11 @@ public:
|
|
|
21952
22078
|
virtual ~StrTimeFormat() {
|
|
21953
22079
|
}
|
|
21954
22080
|
|
|
21955
|
-
static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
|
|
22081
|
+
DUCKDB_API static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
|
|
22082
|
+
|
|
22083
|
+
inline bool HasFormatSpecifier(StrTimeSpecifier s) const {
|
|
22084
|
+
return std::find(specifiers.begin(), specifiers.end(), s) != specifiers.end();
|
|
22085
|
+
}
|
|
21956
22086
|
|
|
21957
22087
|
protected:
|
|
21958
22088
|
//! The format specifiers
|
|
@@ -21968,13 +22098,13 @@ protected:
|
|
|
21968
22098
|
|
|
21969
22099
|
protected:
|
|
21970
22100
|
void AddLiteral(string literal);
|
|
21971
|
-
virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
|
|
22101
|
+
DUCKDB_API virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
|
|
21972
22102
|
};
|
|
21973
22103
|
|
|
21974
22104
|
struct StrfTimeFormat : public StrTimeFormat {
|
|
21975
|
-
idx_t GetLength(date_t date, dtime_t time);
|
|
22105
|
+
DUCKDB_API idx_t GetLength(date_t date, dtime_t time, int32_t utc_offset, const char *tz_name);
|
|
21976
22106
|
|
|
21977
|
-
void FormatString(date_t date, int32_t data[
|
|
22107
|
+
DUCKDB_API void FormatString(date_t date, int32_t data[8], const char *tz_name, char *target);
|
|
21978
22108
|
void FormatString(date_t date, dtime_t time, char *target);
|
|
21979
22109
|
|
|
21980
22110
|
DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
|
|
@@ -21987,8 +22117,9 @@ protected:
|
|
|
21987
22117
|
vector<bool> is_date_specifier;
|
|
21988
22118
|
|
|
21989
22119
|
protected:
|
|
21990
|
-
void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
21991
|
-
static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time
|
|
22120
|
+
DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
22121
|
+
static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time, int32_t utc_offset,
|
|
22122
|
+
const char *tz_name);
|
|
21992
22123
|
char *WriteString(char *target, const string_t &str);
|
|
21993
22124
|
char *Write2(char *target, uint8_t value);
|
|
21994
22125
|
char *WritePadded2(char *target, uint32_t value);
|
|
@@ -21996,20 +22127,21 @@ protected:
|
|
|
21996
22127
|
char *WritePadded(char *target, uint32_t value, size_t padding);
|
|
21997
22128
|
bool IsDateSpecifier(StrTimeSpecifier specifier);
|
|
21998
22129
|
char *WriteDateSpecifier(StrTimeSpecifier specifier, date_t date, char *target);
|
|
21999
|
-
char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], char *target);
|
|
22130
|
+
char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], const char *tz_name, char *target);
|
|
22000
22131
|
};
|
|
22001
22132
|
|
|
22002
22133
|
struct StrpTimeFormat : public StrTimeFormat {
|
|
22003
22134
|
public:
|
|
22004
22135
|
//! Type-safe parsing argument
|
|
22005
22136
|
struct ParseResult {
|
|
22006
|
-
int32_t data[
|
|
22137
|
+
int32_t data[8]; // year, month, day, hour, min, sec, µs, offset
|
|
22138
|
+
string tz;
|
|
22007
22139
|
string error_message;
|
|
22008
22140
|
idx_t error_position = DConstants::INVALID_INDEX;
|
|
22009
22141
|
|
|
22010
22142
|
date_t ToDate();
|
|
22011
22143
|
timestamp_t ToTimestamp();
|
|
22012
|
-
string FormatError(string_t input, const string &format_specifier);
|
|
22144
|
+
DUCKDB_API string FormatError(string_t input, const string &format_specifier);
|
|
22013
22145
|
};
|
|
22014
22146
|
|
|
22015
22147
|
public:
|
|
@@ -22019,7 +22151,7 @@ public:
|
|
|
22019
22151
|
public:
|
|
22020
22152
|
DUCKDB_API static ParseResult Parse(const string &format, const string &text);
|
|
22021
22153
|
|
|
22022
|
-
bool Parse(string_t str, ParseResult &result);
|
|
22154
|
+
DUCKDB_API bool Parse(string_t str, ParseResult &result);
|
|
22023
22155
|
|
|
22024
22156
|
bool TryParseDate(string_t str, date_t &result, string &error_message);
|
|
22025
22157
|
bool TryParseTimestamp(string_t str, timestamp_t &result, string &error_message);
|
|
@@ -22029,7 +22161,7 @@ public:
|
|
|
22029
22161
|
|
|
22030
22162
|
protected:
|
|
22031
22163
|
static string FormatStrpTimeError(const string &input, idx_t position);
|
|
22032
|
-
void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
22164
|
+
DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
22033
22165
|
int NumericSpecifierWidth(StrTimeSpecifier specifier);
|
|
22034
22166
|
int32_t TryParseCollection(const char *data, idx_t &pos, idx_t size, const string_t collection[],
|
|
22035
22167
|
idx_t collection_count);
|
|
@@ -22080,13 +22212,10 @@ struct TextSearchShiftArray {
|
|
|
22080
22212
|
};
|
|
22081
22213
|
|
|
22082
22214
|
struct BufferedCSVReaderOptions {
|
|
22083
|
-
|
|
22084
|
-
|
|
22085
|
-
|
|
22086
|
-
|
|
22087
|
-
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
|
22088
|
-
//! Whether or not to automatically detect dialect and datatypes
|
|
22089
|
-
bool auto_detect = false;
|
|
22215
|
+
//===--------------------------------------------------------------------===//
|
|
22216
|
+
// CommonCSVOptions
|
|
22217
|
+
//===--------------------------------------------------------------------===//
|
|
22218
|
+
|
|
22090
22219
|
//! Whether or not a delimiter was defined by the user
|
|
22091
22220
|
bool has_delimiter = false;
|
|
22092
22221
|
//! Delimiter to separate columns within each line
|
|
@@ -22103,26 +22232,51 @@ struct BufferedCSVReaderOptions {
|
|
|
22103
22232
|
bool has_header = false;
|
|
22104
22233
|
//! Whether or not the file has a header line
|
|
22105
22234
|
bool header = false;
|
|
22106
|
-
//! Whether or not
|
|
22107
|
-
bool
|
|
22108
|
-
//! How many leading rows to skip
|
|
22109
|
-
idx_t skip_rows = 0;
|
|
22235
|
+
//! Whether or not we should ignore InvalidInput errors
|
|
22236
|
+
bool ignore_errors = false;
|
|
22110
22237
|
//! Expected number of columns
|
|
22111
22238
|
idx_t num_cols = 0;
|
|
22112
|
-
//! Specifies the string that represents a null value
|
|
22113
|
-
string null_str;
|
|
22114
|
-
//! True, if column with that index must skip null check
|
|
22115
|
-
vector<bool> force_not_null;
|
|
22116
|
-
//! Size of sample chunk used for dialect and type detection
|
|
22117
|
-
idx_t sample_chunk_size = STANDARD_VECTOR_SIZE;
|
|
22118
|
-
//! Number of sample chunks used for type detection
|
|
22119
|
-
idx_t sample_chunks = 10;
|
|
22120
22239
|
//! Number of samples to buffer
|
|
22121
22240
|
idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
|
|
22122
|
-
//!
|
|
22123
|
-
|
|
22241
|
+
//! Specifies the string that represents a null value
|
|
22242
|
+
string null_str;
|
|
22243
|
+
//! Whether file is compressed or not, and if so which compression type
|
|
22244
|
+
//! AUTO_DETECT (default; infer from file extension)
|
|
22245
|
+
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
|
22246
|
+
|
|
22247
|
+
//===--------------------------------------------------------------------===//
|
|
22248
|
+
// ReadCSVOptions
|
|
22249
|
+
//===--------------------------------------------------------------------===//
|
|
22250
|
+
|
|
22251
|
+
//! How many leading rows to skip
|
|
22252
|
+
idx_t skip_rows = 0;
|
|
22124
22253
|
//! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
|
|
22125
22254
|
idx_t maximum_line_size = 2097152;
|
|
22255
|
+
//! Whether or not header names shall be normalized
|
|
22256
|
+
bool normalize_names = false;
|
|
22257
|
+
//! True, if column with that index must skip null check
|
|
22258
|
+
vector<bool> force_not_null;
|
|
22259
|
+
//! Consider all columns to be of type varchar
|
|
22260
|
+
bool all_varchar = false;
|
|
22261
|
+
//! Size of sample chunk used for dialect and type detection
|
|
22262
|
+
idx_t sample_chunk_size = STANDARD_VECTOR_SIZE;
|
|
22263
|
+
//! Number of sample chunks used for type detection
|
|
22264
|
+
idx_t sample_chunks = 10;
|
|
22265
|
+
//! Whether or not to automatically detect dialect and datatypes
|
|
22266
|
+
bool auto_detect = false;
|
|
22267
|
+
//! The file path of the CSV file to read
|
|
22268
|
+
string file_path;
|
|
22269
|
+
//! Whether or not to include a file name column
|
|
22270
|
+
bool include_file_name = false;
|
|
22271
|
+
|
|
22272
|
+
//===--------------------------------------------------------------------===//
|
|
22273
|
+
// WriteCSVOptions
|
|
22274
|
+
//===--------------------------------------------------------------------===//
|
|
22275
|
+
|
|
22276
|
+
//! The column names of the columns to write
|
|
22277
|
+
vector<string> names;
|
|
22278
|
+
//! True, if column with that index must be quoted
|
|
22279
|
+
vector<bool> force_quote;
|
|
22126
22280
|
|
|
22127
22281
|
//! The date format to use (if any is specified)
|
|
22128
22282
|
std::map<LogicalTypeId, StrpTimeFormat> date_format = {{LogicalTypeId::DATE, {}}, {LogicalTypeId::TIMESTAMP, {}}};
|
|
@@ -22130,6 +22284,16 @@ struct BufferedCSVReaderOptions {
|
|
|
22130
22284
|
std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
|
|
22131
22285
|
|
|
22132
22286
|
void SetDelimiter(const string &delimiter);
|
|
22287
|
+
//! Set an option that is supported by both reading and writing functions, called by
|
|
22288
|
+
//! the SetReadOption and SetWriteOption methods
|
|
22289
|
+
bool SetBaseOption(const string &loption, const Value &value);
|
|
22290
|
+
|
|
22291
|
+
//! loption - lowercase string
|
|
22292
|
+
//! set - argument(s) to the option
|
|
22293
|
+
//! expected_names - names expected if the option is "columns"
|
|
22294
|
+
void SetReadOption(const string &loption, const Value &value, vector<string> &expected_names);
|
|
22295
|
+
|
|
22296
|
+
void SetWriteOption(const string &loption, const Value &value);
|
|
22133
22297
|
|
|
22134
22298
|
std::string ToString() const;
|
|
22135
22299
|
};
|
|
@@ -22255,6 +22419,10 @@ private:
|
|
|
22255
22419
|
const vector<LogicalType> &requested_types,
|
|
22256
22420
|
vector<vector<LogicalType>> &best_sql_types_candidates,
|
|
22257
22421
|
map<LogicalTypeId, vector<string>> &best_format_candidates);
|
|
22422
|
+
|
|
22423
|
+
private:
|
|
22424
|
+
//! Whether or not the current row's columns have overflown sql_types.size()
|
|
22425
|
+
bool error_column_overflow = false;
|
|
22258
22426
|
};
|
|
22259
22427
|
|
|
22260
22428
|
} // namespace duckdb
|
|
@@ -22405,46 +22573,7 @@ private:
|
|
|
22405
22573
|
//===----------------------------------------------------------------------===//
|
|
22406
22574
|
// DuckDB
|
|
22407
22575
|
//
|
|
22408
|
-
// duckdb/parser/expression/
|
|
22409
|
-
//
|
|
22410
|
-
//
|
|
22411
|
-
//===----------------------------------------------------------------------===//
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22416
|
-
|
|
22417
|
-
|
|
22418
|
-
namespace duckdb {
|
|
22419
|
-
|
|
22420
|
-
//! LambdaExpression represents either:
|
|
22421
|
-
//! 1. A lambda operator that can be used for e.g. mapping an expression to a list
|
|
22422
|
-
//! 2. An OperatorExpression with the "->" operator
|
|
22423
|
-
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
22424
|
-
class LambdaExpression : public ParsedExpression {
|
|
22425
|
-
public:
|
|
22426
|
-
LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
|
|
22427
|
-
|
|
22428
|
-
unique_ptr<ParsedExpression> lhs;
|
|
22429
|
-
unique_ptr<ParsedExpression> rhs;
|
|
22430
|
-
|
|
22431
|
-
public:
|
|
22432
|
-
string ToString() const override;
|
|
22433
|
-
|
|
22434
|
-
static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
|
|
22435
|
-
hash_t Hash() const override;
|
|
22436
|
-
|
|
22437
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
22438
|
-
|
|
22439
|
-
void Serialize(FieldWriter &writer) const override;
|
|
22440
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22441
|
-
};
|
|
22442
|
-
|
|
22443
|
-
} // namespace duckdb
|
|
22444
|
-
//===----------------------------------------------------------------------===//
|
|
22445
|
-
// DuckDB
|
|
22446
|
-
//
|
|
22447
|
-
// duckdb/parser/expression/collate_expression.hpp
|
|
22576
|
+
// duckdb/parser/expression/operator_expression.hpp
|
|
22448
22577
|
//
|
|
22449
22578
|
//
|
|
22450
22579
|
//===----------------------------------------------------------------------===//
|
|
@@ -22453,56 +22582,23 @@ public:
|
|
|
22453
22582
|
|
|
22454
22583
|
|
|
22455
22584
|
|
|
22456
|
-
namespace duckdb {
|
|
22457
|
-
|
|
22458
|
-
//! CollateExpression represents a COLLATE statement
|
|
22459
|
-
class CollateExpression : public ParsedExpression {
|
|
22460
|
-
public:
|
|
22461
|
-
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
22462
|
-
|
|
22463
|
-
//! The child of the cast expression
|
|
22464
|
-
unique_ptr<ParsedExpression> child;
|
|
22465
|
-
//! The collation clause
|
|
22466
|
-
string collation;
|
|
22467
|
-
|
|
22468
|
-
public:
|
|
22469
|
-
string ToString() const override;
|
|
22470
|
-
|
|
22471
|
-
static bool Equals(const CollateExpression *a, const CollateExpression *b);
|
|
22472
|
-
|
|
22473
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
22474
|
-
|
|
22475
|
-
void Serialize(FieldWriter &writer) const override;
|
|
22476
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22477
|
-
};
|
|
22478
|
-
} // namespace duckdb
|
|
22479
|
-
//===----------------------------------------------------------------------===//
|
|
22480
|
-
// DuckDB
|
|
22481
|
-
//
|
|
22482
|
-
// duckdb/parser/expression/between_expression.hpp
|
|
22483
|
-
//
|
|
22484
|
-
//
|
|
22485
|
-
//===----------------------------------------------------------------------===//
|
|
22486
|
-
|
|
22487
|
-
|
|
22488
22585
|
|
|
22489
22586
|
|
|
22490
22587
|
|
|
22491
22588
|
namespace duckdb {
|
|
22492
|
-
|
|
22493
|
-
class
|
|
22589
|
+
//! Represents a built-in operator expression
|
|
22590
|
+
class OperatorExpression : public ParsedExpression {
|
|
22494
22591
|
public:
|
|
22495
|
-
|
|
22496
|
-
|
|
22592
|
+
DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
|
|
22593
|
+
unique_ptr<ParsedExpression> right = nullptr);
|
|
22594
|
+
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
22497
22595
|
|
|
22498
|
-
unique_ptr<ParsedExpression
|
|
22499
|
-
unique_ptr<ParsedExpression> lower;
|
|
22500
|
-
unique_ptr<ParsedExpression> upper;
|
|
22596
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
22501
22597
|
|
|
22502
22598
|
public:
|
|
22503
22599
|
string ToString() const override;
|
|
22504
22600
|
|
|
22505
|
-
static bool Equals(const
|
|
22601
|
+
static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
|
|
22506
22602
|
|
|
22507
22603
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22508
22604
|
|
|
@@ -22512,16 +22608,72 @@ public:
|
|
|
22512
22608
|
public:
|
|
22513
22609
|
template <class T, class BASE>
|
|
22514
22610
|
static string ToString(const T &entry) {
|
|
22515
|
-
|
|
22611
|
+
auto op = ExpressionTypeToOperator(entry.type);
|
|
22612
|
+
if (!op.empty()) {
|
|
22613
|
+
// use the operator string to represent the operator
|
|
22614
|
+
D_ASSERT(entry.children.size() == 2);
|
|
22615
|
+
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
22616
|
+
}
|
|
22617
|
+
switch (entry.type) {
|
|
22618
|
+
case ExpressionType::COMPARE_IN:
|
|
22619
|
+
case ExpressionType::COMPARE_NOT_IN: {
|
|
22620
|
+
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
22621
|
+
string in_child = entry.children[0]->ToString();
|
|
22622
|
+
string child_list = "(";
|
|
22623
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22624
|
+
if (i > 1) {
|
|
22625
|
+
child_list += ", ";
|
|
22626
|
+
}
|
|
22627
|
+
child_list += entry.children[i]->ToString();
|
|
22628
|
+
}
|
|
22629
|
+
child_list += ")";
|
|
22630
|
+
return "(" + in_child + op_type + child_list + ")";
|
|
22631
|
+
}
|
|
22632
|
+
case ExpressionType::OPERATOR_NOT:
|
|
22633
|
+
case ExpressionType::GROUPING_FUNCTION:
|
|
22634
|
+
case ExpressionType::OPERATOR_COALESCE: {
|
|
22635
|
+
string result = ExpressionTypeToString(entry.type);
|
|
22636
|
+
result += "(";
|
|
22637
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22638
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22639
|
+
result += ")";
|
|
22640
|
+
return result;
|
|
22641
|
+
}
|
|
22642
|
+
case ExpressionType::OPERATOR_IS_NULL:
|
|
22643
|
+
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
22644
|
+
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
22645
|
+
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
22646
|
+
case ExpressionType::ARRAY_EXTRACT:
|
|
22647
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
22648
|
+
case ExpressionType::ARRAY_SLICE:
|
|
22649
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
22650
|
+
entry.children[2]->ToString() + "]";
|
|
22651
|
+
case ExpressionType::STRUCT_EXTRACT: {
|
|
22652
|
+
D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
|
|
22653
|
+
auto child_string = entry.children[1]->ToString();
|
|
22654
|
+
D_ASSERT(child_string.size() >= 3);
|
|
22655
|
+
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
22656
|
+
return "(" + entry.children[0]->ToString() + ")." +
|
|
22657
|
+
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
22658
|
+
}
|
|
22659
|
+
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
22660
|
+
string result = "(ARRAY[";
|
|
22661
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22662
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22663
|
+
result += "])";
|
|
22664
|
+
return result;
|
|
22665
|
+
}
|
|
22666
|
+
default:
|
|
22667
|
+
throw InternalException("Unrecognized operator type");
|
|
22668
|
+
}
|
|
22516
22669
|
}
|
|
22517
22670
|
};
|
|
22518
|
-
} // namespace duckdb
|
|
22519
|
-
|
|
22520
22671
|
|
|
22672
|
+
} // namespace duckdb
|
|
22521
22673
|
//===----------------------------------------------------------------------===//
|
|
22522
22674
|
// DuckDB
|
|
22523
22675
|
//
|
|
22524
|
-
// duckdb/parser/expression/
|
|
22676
|
+
// duckdb/parser/expression/star_expression.hpp
|
|
22525
22677
|
//
|
|
22526
22678
|
//
|
|
22527
22679
|
//===----------------------------------------------------------------------===//
|
|
@@ -22533,44 +22685,29 @@ public:
|
|
|
22533
22685
|
|
|
22534
22686
|
namespace duckdb {
|
|
22535
22687
|
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
unique_ptr<ParsedExpression> then_expr;
|
|
22539
|
-
};
|
|
22540
|
-
|
|
22541
|
-
//! The CaseExpression represents a CASE expression in the query
|
|
22542
|
-
class CaseExpression : public ParsedExpression {
|
|
22688
|
+
//! Represents a * expression in the SELECT clause
|
|
22689
|
+
class StarExpression : public ParsedExpression {
|
|
22543
22690
|
public:
|
|
22544
|
-
|
|
22691
|
+
StarExpression(string relation_name = string());
|
|
22545
22692
|
|
|
22546
|
-
|
|
22547
|
-
|
|
22693
|
+
//! The relation name in case of tbl.*, or empty if this is a normal *
|
|
22694
|
+
string relation_name;
|
|
22695
|
+
//! List of columns to exclude from the STAR expression
|
|
22696
|
+
case_insensitive_set_t exclude_list;
|
|
22697
|
+
//! List of columns to replace with another expression
|
|
22698
|
+
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
22548
22699
|
|
|
22549
22700
|
public:
|
|
22550
22701
|
string ToString() const override;
|
|
22551
22702
|
|
|
22552
|
-
static bool Equals(const
|
|
22703
|
+
static bool Equals(const StarExpression *a, const StarExpression *b);
|
|
22553
22704
|
|
|
22554
22705
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22555
22706
|
|
|
22556
22707
|
void Serialize(FieldWriter &writer) const override;
|
|
22557
22708
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22558
|
-
|
|
22559
|
-
public:
|
|
22560
|
-
template <class T, class BASE>
|
|
22561
|
-
static string ToString(const T &entry) {
|
|
22562
|
-
string case_str = "CASE ";
|
|
22563
|
-
for (auto &check : entry.case_checks) {
|
|
22564
|
-
case_str += " WHEN (" + check.when_expr->ToString() + ")";
|
|
22565
|
-
case_str += " THEN (" + check.then_expr->ToString() + ")";
|
|
22566
|
-
}
|
|
22567
|
-
case_str += " ELSE " + entry.else_expr->ToString();
|
|
22568
|
-
case_str += " END";
|
|
22569
|
-
return case_str;
|
|
22570
|
-
}
|
|
22571
22709
|
};
|
|
22572
22710
|
} // namespace duckdb
|
|
22573
|
-
|
|
22574
22711
|
//===----------------------------------------------------------------------===//
|
|
22575
22712
|
// DuckDB
|
|
22576
22713
|
//
|
|
@@ -22616,13 +22753,10 @@ public:
|
|
|
22616
22753
|
}
|
|
22617
22754
|
};
|
|
22618
22755
|
} // namespace duckdb
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
22756
|
//===----------------------------------------------------------------------===//
|
|
22623
22757
|
// DuckDB
|
|
22624
22758
|
//
|
|
22625
|
-
// duckdb/parser/expression/
|
|
22759
|
+
// duckdb/parser/expression/positional_reference_expression.hpp
|
|
22626
22760
|
//
|
|
22627
22761
|
//
|
|
22628
22762
|
//===----------------------------------------------------------------------===//
|
|
@@ -22632,34 +22766,27 @@ public:
|
|
|
22632
22766
|
|
|
22633
22767
|
|
|
22634
22768
|
namespace duckdb {
|
|
22635
|
-
|
|
22636
|
-
//! and has two children.
|
|
22637
|
-
class ComparisonExpression : public ParsedExpression {
|
|
22769
|
+
class PositionalReferenceExpression : public ParsedExpression {
|
|
22638
22770
|
public:
|
|
22639
|
-
DUCKDB_API
|
|
22640
|
-
unique_ptr<ParsedExpression> right);
|
|
22771
|
+
DUCKDB_API PositionalReferenceExpression(idx_t index);
|
|
22641
22772
|
|
|
22642
|
-
|
|
22643
|
-
unique_ptr<ParsedExpression> right;
|
|
22773
|
+
idx_t index;
|
|
22644
22774
|
|
|
22645
22775
|
public:
|
|
22646
|
-
|
|
22776
|
+
bool IsScalar() const override {
|
|
22777
|
+
return false;
|
|
22778
|
+
}
|
|
22647
22779
|
|
|
22648
|
-
|
|
22780
|
+
string ToString() const override;
|
|
22649
22781
|
|
|
22782
|
+
static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
|
|
22650
22783
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22784
|
+
hash_t Hash() const override;
|
|
22651
22785
|
|
|
22652
22786
|
void Serialize(FieldWriter &writer) const override;
|
|
22653
22787
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22654
|
-
|
|
22655
|
-
public:
|
|
22656
|
-
template <class T, class BASE>
|
|
22657
|
-
static string ToString(const T &entry) {
|
|
22658
|
-
return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
|
|
22659
|
-
}
|
|
22660
22788
|
};
|
|
22661
22789
|
} // namespace duckdb
|
|
22662
|
-
|
|
22663
22790
|
//===----------------------------------------------------------------------===//
|
|
22664
22791
|
// DuckDB
|
|
22665
22792
|
//
|
|
@@ -22700,19 +22827,18 @@ public:
|
|
|
22700
22827
|
public:
|
|
22701
22828
|
template <class T, class BASE>
|
|
22702
22829
|
static string ToString(const T &entry) {
|
|
22703
|
-
string result = entry.children[0]->ToString();
|
|
22830
|
+
string result = "(" + entry.children[0]->ToString();
|
|
22704
22831
|
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22705
22832
|
result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
|
|
22706
22833
|
}
|
|
22707
|
-
return result;
|
|
22834
|
+
return result + ")";
|
|
22708
22835
|
}
|
|
22709
22836
|
};
|
|
22710
22837
|
} // namespace duckdb
|
|
22711
|
-
|
|
22712
22838
|
//===----------------------------------------------------------------------===//
|
|
22713
22839
|
// DuckDB
|
|
22714
22840
|
//
|
|
22715
|
-
// duckdb/parser/expression/
|
|
22841
|
+
// duckdb/parser/expression/parameter_expression.hpp
|
|
22716
22842
|
//
|
|
22717
22843
|
//
|
|
22718
22844
|
//===----------------------------------------------------------------------===//
|
|
@@ -22721,35 +22847,69 @@ public:
|
|
|
22721
22847
|
|
|
22722
22848
|
|
|
22723
22849
|
|
|
22724
|
-
|
|
22725
22850
|
namespace duckdb {
|
|
22851
|
+
class ParameterExpression : public ParsedExpression {
|
|
22852
|
+
public:
|
|
22853
|
+
ParameterExpression();
|
|
22854
|
+
|
|
22855
|
+
idx_t parameter_nr;
|
|
22726
22856
|
|
|
22727
|
-
//! ConstantExpression represents a constant value in the query
|
|
22728
|
-
class ConstantExpression : public ParsedExpression {
|
|
22729
22857
|
public:
|
|
22730
|
-
|
|
22858
|
+
bool IsScalar() const override {
|
|
22859
|
+
return true;
|
|
22860
|
+
}
|
|
22861
|
+
bool HasParameter() const override {
|
|
22862
|
+
return true;
|
|
22863
|
+
}
|
|
22864
|
+
|
|
22865
|
+
string ToString() const override;
|
|
22866
|
+
|
|
22867
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
22868
|
+
hash_t Hash() const override;
|
|
22869
|
+
|
|
22870
|
+
void Serialize(FieldWriter &writer) const override;
|
|
22871
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22872
|
+
};
|
|
22873
|
+
} // namespace duckdb
|
|
22874
|
+
//===----------------------------------------------------------------------===//
|
|
22875
|
+
// DuckDB
|
|
22876
|
+
//
|
|
22877
|
+
// duckdb/parser/expression/collate_expression.hpp
|
|
22878
|
+
//
|
|
22879
|
+
//
|
|
22880
|
+
//===----------------------------------------------------------------------===//
|
|
22881
|
+
|
|
22882
|
+
|
|
22731
22883
|
|
|
22732
|
-
|
|
22733
|
-
|
|
22884
|
+
|
|
22885
|
+
|
|
22886
|
+
namespace duckdb {
|
|
22887
|
+
|
|
22888
|
+
//! CollateExpression represents a COLLATE statement
|
|
22889
|
+
class CollateExpression : public ParsedExpression {
|
|
22890
|
+
public:
|
|
22891
|
+
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
22892
|
+
|
|
22893
|
+
//! The child of the cast expression
|
|
22894
|
+
unique_ptr<ParsedExpression> child;
|
|
22895
|
+
//! The collation clause
|
|
22896
|
+
string collation;
|
|
22734
22897
|
|
|
22735
22898
|
public:
|
|
22736
22899
|
string ToString() const override;
|
|
22737
22900
|
|
|
22738
|
-
static bool Equals(const
|
|
22739
|
-
hash_t Hash() const override;
|
|
22901
|
+
static bool Equals(const CollateExpression *a, const CollateExpression *b);
|
|
22740
22902
|
|
|
22741
22903
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22742
22904
|
|
|
22743
22905
|
void Serialize(FieldWriter &writer) const override;
|
|
22744
22906
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22745
22907
|
};
|
|
22746
|
-
|
|
22747
22908
|
} // namespace duckdb
|
|
22748
|
-
|
|
22749
22909
|
//===----------------------------------------------------------------------===//
|
|
22750
22910
|
// DuckDB
|
|
22751
22911
|
//
|
|
22752
|
-
// duckdb/parser/expression/
|
|
22912
|
+
// duckdb/parser/expression/subquery_expression.hpp
|
|
22753
22913
|
//
|
|
22754
22914
|
//
|
|
22755
22915
|
//===----------------------------------------------------------------------===//
|
|
@@ -22758,26 +22918,171 @@ public:
|
|
|
22758
22918
|
|
|
22759
22919
|
|
|
22760
22920
|
|
|
22921
|
+
|
|
22922
|
+
|
|
22761
22923
|
namespace duckdb {
|
|
22762
|
-
|
|
22763
|
-
|
|
22924
|
+
|
|
22925
|
+
//! Represents a subquery
|
|
22926
|
+
class SubqueryExpression : public ParsedExpression {
|
|
22764
22927
|
public:
|
|
22765
|
-
|
|
22928
|
+
SubqueryExpression();
|
|
22929
|
+
|
|
22930
|
+
//! The actual subquery
|
|
22931
|
+
unique_ptr<SelectStatement> subquery;
|
|
22932
|
+
//! The subquery type
|
|
22933
|
+
SubqueryType subquery_type;
|
|
22934
|
+
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
22935
|
+
//! subquery)
|
|
22936
|
+
unique_ptr<ParsedExpression> child;
|
|
22937
|
+
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
22938
|
+
ExpressionType comparison_type;
|
|
22766
22939
|
|
|
22767
22940
|
public:
|
|
22941
|
+
bool HasSubquery() const override {
|
|
22942
|
+
return true;
|
|
22943
|
+
}
|
|
22768
22944
|
bool IsScalar() const override {
|
|
22769
22945
|
return false;
|
|
22770
22946
|
}
|
|
22771
22947
|
|
|
22772
22948
|
string ToString() const override;
|
|
22773
22949
|
|
|
22950
|
+
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
22951
|
+
|
|
22774
22952
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22775
22953
|
|
|
22776
22954
|
void Serialize(FieldWriter &writer) const override;
|
|
22777
22955
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22778
22956
|
};
|
|
22779
22957
|
} // namespace duckdb
|
|
22958
|
+
//===----------------------------------------------------------------------===//
|
|
22959
|
+
// DuckDB
|
|
22960
|
+
//
|
|
22961
|
+
// duckdb/parser/expression/between_expression.hpp
|
|
22962
|
+
//
|
|
22963
|
+
//
|
|
22964
|
+
//===----------------------------------------------------------------------===//
|
|
22965
|
+
|
|
22966
|
+
|
|
22967
|
+
|
|
22968
|
+
|
|
22780
22969
|
|
|
22970
|
+
namespace duckdb {
|
|
22971
|
+
|
|
22972
|
+
class BetweenExpression : public ParsedExpression {
|
|
22973
|
+
public:
|
|
22974
|
+
DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
|
|
22975
|
+
unique_ptr<ParsedExpression> upper);
|
|
22976
|
+
|
|
22977
|
+
unique_ptr<ParsedExpression> input;
|
|
22978
|
+
unique_ptr<ParsedExpression> lower;
|
|
22979
|
+
unique_ptr<ParsedExpression> upper;
|
|
22980
|
+
|
|
22981
|
+
public:
|
|
22982
|
+
string ToString() const override;
|
|
22983
|
+
|
|
22984
|
+
static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
|
|
22985
|
+
|
|
22986
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
22987
|
+
|
|
22988
|
+
void Serialize(FieldWriter &writer) const override;
|
|
22989
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22990
|
+
|
|
22991
|
+
public:
|
|
22992
|
+
template <class T, class BASE>
|
|
22993
|
+
static string ToString(const T &entry) {
|
|
22994
|
+
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
22995
|
+
}
|
|
22996
|
+
};
|
|
22997
|
+
} // namespace duckdb
|
|
22998
|
+
//===----------------------------------------------------------------------===//
|
|
22999
|
+
// DuckDB
|
|
23000
|
+
//
|
|
23001
|
+
// duckdb/parser/expression/case_expression.hpp
|
|
23002
|
+
//
|
|
23003
|
+
//
|
|
23004
|
+
//===----------------------------------------------------------------------===//
|
|
23005
|
+
|
|
23006
|
+
|
|
23007
|
+
|
|
23008
|
+
|
|
23009
|
+
|
|
23010
|
+
|
|
23011
|
+
namespace duckdb {
|
|
23012
|
+
|
|
23013
|
+
struct CaseCheck {
|
|
23014
|
+
unique_ptr<ParsedExpression> when_expr;
|
|
23015
|
+
unique_ptr<ParsedExpression> then_expr;
|
|
23016
|
+
};
|
|
23017
|
+
|
|
23018
|
+
//! The CaseExpression represents a CASE expression in the query
|
|
23019
|
+
class CaseExpression : public ParsedExpression {
|
|
23020
|
+
public:
|
|
23021
|
+
DUCKDB_API CaseExpression();
|
|
23022
|
+
|
|
23023
|
+
vector<CaseCheck> case_checks;
|
|
23024
|
+
unique_ptr<ParsedExpression> else_expr;
|
|
23025
|
+
|
|
23026
|
+
public:
|
|
23027
|
+
string ToString() const override;
|
|
23028
|
+
|
|
23029
|
+
static bool Equals(const CaseExpression *a, const CaseExpression *b);
|
|
23030
|
+
|
|
23031
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23032
|
+
|
|
23033
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23034
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23035
|
+
|
|
23036
|
+
public:
|
|
23037
|
+
template <class T, class BASE>
|
|
23038
|
+
static string ToString(const T &entry) {
|
|
23039
|
+
string case_str = "CASE ";
|
|
23040
|
+
for (auto &check : entry.case_checks) {
|
|
23041
|
+
case_str += " WHEN (" + check.when_expr->ToString() + ")";
|
|
23042
|
+
case_str += " THEN (" + check.then_expr->ToString() + ")";
|
|
23043
|
+
}
|
|
23044
|
+
case_str += " ELSE " + entry.else_expr->ToString();
|
|
23045
|
+
case_str += " END";
|
|
23046
|
+
return case_str;
|
|
23047
|
+
}
|
|
23048
|
+
};
|
|
23049
|
+
} // namespace duckdb
|
|
23050
|
+
//===----------------------------------------------------------------------===//
|
|
23051
|
+
// DuckDB
|
|
23052
|
+
//
|
|
23053
|
+
// duckdb/parser/expression/constant_expression.hpp
|
|
23054
|
+
//
|
|
23055
|
+
//
|
|
23056
|
+
//===----------------------------------------------------------------------===//
|
|
23057
|
+
|
|
23058
|
+
|
|
23059
|
+
|
|
23060
|
+
|
|
23061
|
+
|
|
23062
|
+
|
|
23063
|
+
namespace duckdb {
|
|
23064
|
+
|
|
23065
|
+
//! ConstantExpression represents a constant value in the query
|
|
23066
|
+
class ConstantExpression : public ParsedExpression {
|
|
23067
|
+
public:
|
|
23068
|
+
DUCKDB_API explicit ConstantExpression(Value val);
|
|
23069
|
+
|
|
23070
|
+
//! The constant value referenced
|
|
23071
|
+
Value value;
|
|
23072
|
+
|
|
23073
|
+
public:
|
|
23074
|
+
string ToString() const override;
|
|
23075
|
+
|
|
23076
|
+
static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
|
|
23077
|
+
hash_t Hash() const override;
|
|
23078
|
+
|
|
23079
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23080
|
+
|
|
23081
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23082
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23083
|
+
};
|
|
23084
|
+
|
|
23085
|
+
} // namespace duckdb
|
|
22781
23086
|
//===----------------------------------------------------------------------===//
|
|
22782
23087
|
// DuckDB
|
|
22783
23088
|
//
|
|
@@ -22840,7 +23145,7 @@ public:
|
|
|
22840
23145
|
template <class T, class BASE>
|
|
22841
23146
|
static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
|
|
22842
23147
|
bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
|
|
22843
|
-
bool export_state = false) {
|
|
23148
|
+
bool export_state = false, bool add_alias = false) {
|
|
22844
23149
|
if (is_operator) {
|
|
22845
23150
|
// built-in operator
|
|
22846
23151
|
D_ASSERT(!distinct);
|
|
@@ -22862,8 +23167,11 @@ public:
|
|
|
22862
23167
|
if (distinct) {
|
|
22863
23168
|
result += "DISTINCT ";
|
|
22864
23169
|
}
|
|
22865
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22866
|
-
|
|
23170
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
|
|
23171
|
+
return child->alias.empty() || !add_alias
|
|
23172
|
+
? child->ToString()
|
|
23173
|
+
: KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
|
|
23174
|
+
});
|
|
22867
23175
|
// ordered aggregate
|
|
22868
23176
|
if (order_bys && !order_bys->orders.empty()) {
|
|
22869
23177
|
if (entry.children.empty()) {
|
|
@@ -22894,10 +23202,14 @@ public:
|
|
|
22894
23202
|
} // namespace duckdb
|
|
22895
23203
|
|
|
22896
23204
|
|
|
23205
|
+
|
|
23206
|
+
|
|
23207
|
+
|
|
23208
|
+
|
|
22897
23209
|
//===----------------------------------------------------------------------===//
|
|
22898
23210
|
// DuckDB
|
|
22899
23211
|
//
|
|
22900
|
-
// duckdb/parser/expression/
|
|
23212
|
+
// duckdb/parser/expression/comparison_expression.hpp
|
|
22901
23213
|
//
|
|
22902
23214
|
//
|
|
22903
23215
|
//===----------------------------------------------------------------------===//
|
|
@@ -22906,23 +23218,21 @@ public:
|
|
|
22906
23218
|
|
|
22907
23219
|
|
|
22908
23220
|
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
23221
|
namespace duckdb {
|
|
22913
|
-
//!
|
|
22914
|
-
|
|
23222
|
+
//! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
|
|
23223
|
+
//! and has two children.
|
|
23224
|
+
class ComparisonExpression : public ParsedExpression {
|
|
22915
23225
|
public:
|
|
22916
|
-
DUCKDB_API
|
|
22917
|
-
|
|
22918
|
-
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23226
|
+
DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
23227
|
+
unique_ptr<ParsedExpression> right);
|
|
22919
23228
|
|
|
22920
|
-
|
|
23229
|
+
unique_ptr<ParsedExpression> left;
|
|
23230
|
+
unique_ptr<ParsedExpression> right;
|
|
22921
23231
|
|
|
22922
23232
|
public:
|
|
22923
23233
|
string ToString() const override;
|
|
22924
23234
|
|
|
22925
|
-
static bool Equals(const
|
|
23235
|
+
static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
|
|
22926
23236
|
|
|
22927
23237
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22928
23238
|
|
|
@@ -22932,73 +23242,17 @@ public:
|
|
|
22932
23242
|
public:
|
|
22933
23243
|
template <class T, class BASE>
|
|
22934
23244
|
static string ToString(const T &entry) {
|
|
22935
|
-
|
|
22936
|
-
if (!op.empty()) {
|
|
22937
|
-
// use the operator string to represent the operator
|
|
22938
|
-
D_ASSERT(entry.children.size() == 2);
|
|
22939
|
-
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
22940
|
-
}
|
|
22941
|
-
switch (entry.type) {
|
|
22942
|
-
case ExpressionType::COMPARE_IN:
|
|
22943
|
-
case ExpressionType::COMPARE_NOT_IN: {
|
|
22944
|
-
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
22945
|
-
string in_child = entry.children[0]->ToString();
|
|
22946
|
-
string child_list = "(";
|
|
22947
|
-
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22948
|
-
if (i > 1) {
|
|
22949
|
-
child_list += ", ";
|
|
22950
|
-
}
|
|
22951
|
-
child_list += entry.children[i]->ToString();
|
|
22952
|
-
}
|
|
22953
|
-
child_list += ")";
|
|
22954
|
-
return "(" + in_child + op_type + child_list + ")";
|
|
22955
|
-
}
|
|
22956
|
-
case ExpressionType::OPERATOR_NOT:
|
|
22957
|
-
case ExpressionType::GROUPING_FUNCTION:
|
|
22958
|
-
case ExpressionType::OPERATOR_COALESCE: {
|
|
22959
|
-
string result = ExpressionTypeToString(entry.type);
|
|
22960
|
-
result += "(";
|
|
22961
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22962
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22963
|
-
result += ")";
|
|
22964
|
-
return result;
|
|
22965
|
-
}
|
|
22966
|
-
case ExpressionType::OPERATOR_IS_NULL:
|
|
22967
|
-
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
22968
|
-
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
22969
|
-
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
22970
|
-
case ExpressionType::ARRAY_EXTRACT:
|
|
22971
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
22972
|
-
case ExpressionType::ARRAY_SLICE:
|
|
22973
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
22974
|
-
entry.children[2]->ToString() + "]";
|
|
22975
|
-
case ExpressionType::STRUCT_EXTRACT: {
|
|
22976
|
-
D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
|
|
22977
|
-
auto child_string = entry.children[1]->ToString();
|
|
22978
|
-
D_ASSERT(child_string.size() >= 3);
|
|
22979
|
-
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
22980
|
-
return "(" + entry.children[0]->ToString() + ")." +
|
|
22981
|
-
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
22982
|
-
}
|
|
22983
|
-
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
22984
|
-
string result = "ARRAY[";
|
|
22985
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22986
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22987
|
-
result += "]";
|
|
22988
|
-
return result;
|
|
22989
|
-
}
|
|
22990
|
-
default:
|
|
22991
|
-
throw InternalException("Unrecognized operator type");
|
|
22992
|
-
}
|
|
23245
|
+
return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
|
|
22993
23246
|
}
|
|
22994
23247
|
};
|
|
22995
|
-
|
|
22996
23248
|
} // namespace duckdb
|
|
22997
23249
|
|
|
23250
|
+
|
|
23251
|
+
|
|
22998
23252
|
//===----------------------------------------------------------------------===//
|
|
22999
23253
|
// DuckDB
|
|
23000
23254
|
//
|
|
23001
|
-
// duckdb/parser/expression/
|
|
23255
|
+
// duckdb/parser/expression/default_expression.hpp
|
|
23002
23256
|
//
|
|
23003
23257
|
//
|
|
23004
23258
|
//===----------------------------------------------------------------------===//
|
|
@@ -23008,34 +23262,30 @@ public:
|
|
|
23008
23262
|
|
|
23009
23263
|
|
|
23010
23264
|
namespace duckdb {
|
|
23011
|
-
|
|
23265
|
+
//! Represents the default value of a column
|
|
23266
|
+
class DefaultExpression : public ParsedExpression {
|
|
23012
23267
|
public:
|
|
23013
|
-
|
|
23014
|
-
|
|
23015
|
-
idx_t parameter_nr;
|
|
23268
|
+
DefaultExpression();
|
|
23016
23269
|
|
|
23017
23270
|
public:
|
|
23018
23271
|
bool IsScalar() const override {
|
|
23019
|
-
return
|
|
23020
|
-
}
|
|
23021
|
-
bool HasParameter() const override {
|
|
23022
|
-
return true;
|
|
23272
|
+
return false;
|
|
23023
23273
|
}
|
|
23024
23274
|
|
|
23025
23275
|
string ToString() const override;
|
|
23026
23276
|
|
|
23027
23277
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23028
|
-
hash_t Hash() const override;
|
|
23029
23278
|
|
|
23030
23279
|
void Serialize(FieldWriter &writer) const override;
|
|
23031
23280
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23032
23281
|
};
|
|
23033
23282
|
} // namespace duckdb
|
|
23034
23283
|
|
|
23284
|
+
|
|
23035
23285
|
//===----------------------------------------------------------------------===//
|
|
23036
23286
|
// DuckDB
|
|
23037
23287
|
//
|
|
23038
|
-
// duckdb/parser/expression/
|
|
23288
|
+
// duckdb/parser/expression/lambda_expression.hpp
|
|
23039
23289
|
//
|
|
23040
23290
|
//
|
|
23041
23291
|
//===----------------------------------------------------------------------===//
|
|
@@ -23044,33 +23294,44 @@ public:
|
|
|
23044
23294
|
|
|
23045
23295
|
|
|
23046
23296
|
|
|
23297
|
+
|
|
23047
23298
|
namespace duckdb {
|
|
23048
|
-
|
|
23299
|
+
|
|
23300
|
+
//! LambdaExpression represents either:
|
|
23301
|
+
//! 1. A lambda operator that can be used for e.g. mapping an expression to a list
|
|
23302
|
+
//! 2. An OperatorExpression with the "->" operator
|
|
23303
|
+
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
23304
|
+
class LambdaExpression : public ParsedExpression {
|
|
23049
23305
|
public:
|
|
23050
|
-
|
|
23306
|
+
LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
|
|
23051
23307
|
|
|
23052
|
-
|
|
23308
|
+
unique_ptr<ParsedExpression> lhs;
|
|
23309
|
+
unique_ptr<ParsedExpression> rhs;
|
|
23053
23310
|
|
|
23054
23311
|
public:
|
|
23055
|
-
bool IsScalar() const override {
|
|
23056
|
-
return false;
|
|
23057
|
-
}
|
|
23058
|
-
|
|
23059
23312
|
string ToString() const override;
|
|
23060
23313
|
|
|
23061
|
-
static bool Equals(const
|
|
23062
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23314
|
+
static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
|
|
23063
23315
|
hash_t Hash() const override;
|
|
23064
23316
|
|
|
23317
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23318
|
+
|
|
23065
23319
|
void Serialize(FieldWriter &writer) const override;
|
|
23066
23320
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23067
23321
|
};
|
|
23322
|
+
|
|
23068
23323
|
} // namespace duckdb
|
|
23069
23324
|
|
|
23325
|
+
|
|
23326
|
+
|
|
23327
|
+
|
|
23328
|
+
|
|
23329
|
+
|
|
23330
|
+
|
|
23070
23331
|
//===----------------------------------------------------------------------===//
|
|
23071
23332
|
// DuckDB
|
|
23072
23333
|
//
|
|
23073
|
-
// duckdb/parser/
|
|
23334
|
+
// duckdb/parser/parsed_data/create_aggregate_function_info.hpp
|
|
23074
23335
|
//
|
|
23075
23336
|
//
|
|
23076
23337
|
//===----------------------------------------------------------------------===//
|
|
@@ -23082,34 +23343,36 @@ public:
|
|
|
23082
23343
|
|
|
23083
23344
|
namespace duckdb {
|
|
23084
23345
|
|
|
23085
|
-
|
|
23086
|
-
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
|
|
23090
|
-
|
|
23091
|
-
string relation_name;
|
|
23092
|
-
//! List of columns to exclude from the STAR expression
|
|
23093
|
-
case_insensitive_set_t exclude_list;
|
|
23094
|
-
//! List of columns to replace with another expression
|
|
23095
|
-
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
23096
|
-
|
|
23097
|
-
public:
|
|
23098
|
-
string ToString() const override;
|
|
23346
|
+
struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
|
|
23347
|
+
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
23348
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
23349
|
+
this->name = function.name;
|
|
23350
|
+
functions.AddFunction(move(function));
|
|
23351
|
+
}
|
|
23099
23352
|
|
|
23100
|
-
|
|
23353
|
+
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
23354
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
23355
|
+
this->name = functions.name;
|
|
23356
|
+
for (auto &func : functions.functions) {
|
|
23357
|
+
func.name = functions.name;
|
|
23358
|
+
}
|
|
23359
|
+
}
|
|
23101
23360
|
|
|
23102
|
-
|
|
23361
|
+
AggregateFunctionSet functions;
|
|
23103
23362
|
|
|
23104
|
-
|
|
23105
|
-
|
|
23363
|
+
public:
|
|
23364
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23365
|
+
auto result = make_unique<CreateAggregateFunctionInfo>(functions);
|
|
23366
|
+
CopyProperties(*result);
|
|
23367
|
+
return move(result);
|
|
23368
|
+
}
|
|
23106
23369
|
};
|
|
23107
|
-
} // namespace duckdb
|
|
23108
23370
|
|
|
23371
|
+
} // namespace duckdb
|
|
23109
23372
|
//===----------------------------------------------------------------------===//
|
|
23110
23373
|
// DuckDB
|
|
23111
23374
|
//
|
|
23112
|
-
// duckdb/parser/
|
|
23375
|
+
// duckdb/parser/parsed_data/drop_info.hpp
|
|
23113
23376
|
//
|
|
23114
23377
|
//
|
|
23115
23378
|
//===----------------------------------------------------------------------===//
|
|
@@ -23119,44 +23382,37 @@ public:
|
|
|
23119
23382
|
|
|
23120
23383
|
|
|
23121
23384
|
|
|
23122
|
-
|
|
23123
23385
|
namespace duckdb {
|
|
23124
23386
|
|
|
23125
|
-
|
|
23126
|
-
|
|
23127
|
-
|
|
23128
|
-
SubqueryExpression();
|
|
23387
|
+
struct DropInfo : public ParseInfo {
|
|
23388
|
+
DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
|
|
23389
|
+
}
|
|
23129
23390
|
|
|
23130
|
-
//! The
|
|
23131
|
-
|
|
23132
|
-
//!
|
|
23133
|
-
|
|
23134
|
-
//!
|
|
23135
|
-
|
|
23136
|
-
|
|
23137
|
-
|
|
23138
|
-
|
|
23391
|
+
//! The catalog type to drop
|
|
23392
|
+
CatalogType type;
|
|
23393
|
+
//! Schema name to drop from, if any
|
|
23394
|
+
string schema;
|
|
23395
|
+
//! Element name to drop
|
|
23396
|
+
string name;
|
|
23397
|
+
//! Ignore if the entry does not exist instead of failing
|
|
23398
|
+
bool if_exists = false;
|
|
23399
|
+
//! Cascade drop (drop all dependents instead of throwing an error if there
|
|
23400
|
+
//! are any)
|
|
23401
|
+
bool cascade = false;
|
|
23139
23402
|
|
|
23140
23403
|
public:
|
|
23141
|
-
|
|
23142
|
-
|
|
23143
|
-
|
|
23144
|
-
|
|
23145
|
-
|
|
23404
|
+
unique_ptr<DropInfo> Copy() const {
|
|
23405
|
+
auto result = make_unique<DropInfo>();
|
|
23406
|
+
result->type = type;
|
|
23407
|
+
result->schema = schema;
|
|
23408
|
+
result->name = name;
|
|
23409
|
+
result->if_exists = if_exists;
|
|
23410
|
+
result->cascade = cascade;
|
|
23411
|
+
return result;
|
|
23146
23412
|
}
|
|
23147
|
-
|
|
23148
|
-
string ToString() const override;
|
|
23149
|
-
|
|
23150
|
-
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
23151
|
-
|
|
23152
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23153
|
-
|
|
23154
|
-
void Serialize(FieldWriter &writer) const override;
|
|
23155
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23156
23413
|
};
|
|
23157
|
-
} // namespace duckdb
|
|
23158
|
-
|
|
23159
23414
|
|
|
23415
|
+
} // namespace duckdb
|
|
23160
23416
|
//===----------------------------------------------------------------------===//
|
|
23161
23417
|
// DuckDB
|
|
23162
23418
|
//
|
|
@@ -23198,33 +23454,6 @@ public:
|
|
|
23198
23454
|
}
|
|
23199
23455
|
};
|
|
23200
23456
|
|
|
23201
|
-
} // namespace duckdb
|
|
23202
|
-
//===----------------------------------------------------------------------===//
|
|
23203
|
-
// DuckDB
|
|
23204
|
-
//
|
|
23205
|
-
// duckdb/parser/parsed_data/create_schema_info.hpp
|
|
23206
|
-
//
|
|
23207
|
-
//
|
|
23208
|
-
//===----------------------------------------------------------------------===//
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
namespace duckdb {
|
|
23215
|
-
|
|
23216
|
-
struct CreateSchemaInfo : public CreateInfo {
|
|
23217
|
-
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
23218
|
-
}
|
|
23219
|
-
|
|
23220
|
-
public:
|
|
23221
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
23222
|
-
auto result = make_unique<CreateSchemaInfo>();
|
|
23223
|
-
CopyProperties(*result);
|
|
23224
|
-
return move(result);
|
|
23225
|
-
}
|
|
23226
|
-
};
|
|
23227
|
-
|
|
23228
23457
|
} // namespace duckdb
|
|
23229
23458
|
//===----------------------------------------------------------------------===//
|
|
23230
23459
|
// DuckDB
|
|
@@ -23248,56 +23477,24 @@ struct ShowSelectInfo : public ParseInfo {
|
|
|
23248
23477
|
unique_ptr<QueryNode> query;
|
|
23249
23478
|
//! Aliases of projected columns
|
|
23250
23479
|
vector<string> aliases;
|
|
23251
|
-
//! Whether or not we are requesting a summary or a describe
|
|
23252
|
-
bool is_summary;
|
|
23253
|
-
|
|
23254
|
-
unique_ptr<ShowSelectInfo> Copy() {
|
|
23255
|
-
auto result = make_unique<ShowSelectInfo>();
|
|
23256
|
-
result->types = types;
|
|
23257
|
-
result->query = query->Copy();
|
|
23258
|
-
result->aliases = aliases;
|
|
23259
|
-
result->is_summary = is_summary;
|
|
23260
|
-
return result;
|
|
23261
|
-
}
|
|
23262
|
-
};
|
|
23263
|
-
|
|
23264
|
-
} // namespace duckdb
|
|
23265
|
-
//===----------------------------------------------------------------------===//
|
|
23266
|
-
// DuckDB
|
|
23267
|
-
//
|
|
23268
|
-
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23269
|
-
//
|
|
23270
|
-
//
|
|
23271
|
-
//===----------------------------------------------------------------------===//
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
namespace duckdb {
|
|
23278
|
-
|
|
23279
|
-
struct VacuumInfo : public ParseInfo {
|
|
23280
|
-
// nothing for now
|
|
23281
|
-
};
|
|
23282
|
-
|
|
23283
|
-
} // namespace duckdb
|
|
23284
|
-
//===----------------------------------------------------------------------===//
|
|
23285
|
-
// DuckDB
|
|
23286
|
-
//
|
|
23287
|
-
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
23288
|
-
//
|
|
23289
|
-
//
|
|
23290
|
-
//===----------------------------------------------------------------------===//
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23480
|
+
//! Whether or not we are requesting a summary or a describe
|
|
23481
|
+
bool is_summary;
|
|
23295
23482
|
|
|
23483
|
+
unique_ptr<ShowSelectInfo> Copy() {
|
|
23484
|
+
auto result = make_unique<ShowSelectInfo>();
|
|
23485
|
+
result->types = types;
|
|
23486
|
+
result->query = query->Copy();
|
|
23487
|
+
result->aliases = aliases;
|
|
23488
|
+
result->is_summary = is_summary;
|
|
23489
|
+
return result;
|
|
23490
|
+
}
|
|
23491
|
+
};
|
|
23296
23492
|
|
|
23493
|
+
} // namespace duckdb
|
|
23297
23494
|
//===----------------------------------------------------------------------===//
|
|
23298
23495
|
// DuckDB
|
|
23299
23496
|
//
|
|
23300
|
-
// duckdb/parser/
|
|
23497
|
+
// duckdb/parser/parsed_data/transaction_info.hpp
|
|
23301
23498
|
//
|
|
23302
23499
|
//
|
|
23303
23500
|
//===----------------------------------------------------------------------===//
|
|
@@ -23306,73 +23503,23 @@ struct VacuumInfo : public ParseInfo {
|
|
|
23306
23503
|
|
|
23307
23504
|
|
|
23308
23505
|
|
|
23309
|
-
|
|
23310
23506
|
namespace duckdb {
|
|
23311
|
-
//! Represents a TableReference to a base table in the schema
|
|
23312
|
-
class BaseTableRef : public TableRef {
|
|
23313
|
-
public:
|
|
23314
|
-
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
23315
|
-
}
|
|
23316
|
-
|
|
23317
|
-
//! Schema name
|
|
23318
|
-
string schema_name;
|
|
23319
|
-
//! Table name
|
|
23320
|
-
string table_name;
|
|
23321
|
-
//! Aliases for the column names
|
|
23322
|
-
vector<string> column_name_alias;
|
|
23323
|
-
|
|
23324
|
-
public:
|
|
23325
|
-
string ToString() const override;
|
|
23326
|
-
bool Equals(const TableRef *other_p) const override;
|
|
23327
|
-
|
|
23328
|
-
unique_ptr<TableRef> Copy() override;
|
|
23329
|
-
|
|
23330
|
-
//! Serializes a blob into a BaseTableRef
|
|
23331
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
23332
|
-
//! Deserializes a blob back into a BaseTableRef
|
|
23333
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23334
|
-
};
|
|
23335
|
-
} // namespace duckdb
|
|
23336
23507
|
|
|
23508
|
+
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
23337
23509
|
|
|
23338
|
-
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
struct CreateIndexInfo : public CreateInfo {
|
|
23342
|
-
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
23510
|
+
struct TransactionInfo : public ParseInfo {
|
|
23511
|
+
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23343
23512
|
}
|
|
23344
23513
|
|
|
23345
|
-
//!
|
|
23346
|
-
|
|
23347
|
-
//! Name of the Index
|
|
23348
|
-
string index_name;
|
|
23349
|
-
//! If it is an unique index
|
|
23350
|
-
bool unique = false;
|
|
23351
|
-
//! The table to create the index on
|
|
23352
|
-
unique_ptr<BaseTableRef> table;
|
|
23353
|
-
//! Set of expressions to index by
|
|
23354
|
-
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23355
|
-
|
|
23356
|
-
public:
|
|
23357
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
23358
|
-
auto result = make_unique<CreateIndexInfo>();
|
|
23359
|
-
CopyProperties(*result);
|
|
23360
|
-
result->index_type = index_type;
|
|
23361
|
-
result->index_name = index_name;
|
|
23362
|
-
result->unique = unique;
|
|
23363
|
-
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
23364
|
-
for (auto &expr : expressions) {
|
|
23365
|
-
result->expressions.push_back(expr->Copy());
|
|
23366
|
-
}
|
|
23367
|
-
return move(result);
|
|
23368
|
-
}
|
|
23514
|
+
//! The type of transaction statement
|
|
23515
|
+
TransactionType type;
|
|
23369
23516
|
};
|
|
23370
23517
|
|
|
23371
23518
|
} // namespace duckdb
|
|
23372
23519
|
//===----------------------------------------------------------------------===//
|
|
23373
23520
|
// DuckDB
|
|
23374
23521
|
//
|
|
23375
|
-
// duckdb/parser/parsed_data/
|
|
23522
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23376
23523
|
//
|
|
23377
23524
|
//
|
|
23378
23525
|
//===----------------------------------------------------------------------===//
|
|
@@ -23383,14 +23530,19 @@ public:
|
|
|
23383
23530
|
|
|
23384
23531
|
namespace duckdb {
|
|
23385
23532
|
|
|
23386
|
-
enum class
|
|
23533
|
+
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
23387
23534
|
|
|
23388
|
-
struct
|
|
23389
|
-
|
|
23390
|
-
|
|
23535
|
+
struct LoadInfo : public ParseInfo {
|
|
23536
|
+
std::string filename;
|
|
23537
|
+
LoadType load_type;
|
|
23391
23538
|
|
|
23392
|
-
|
|
23393
|
-
|
|
23539
|
+
public:
|
|
23540
|
+
unique_ptr<LoadInfo> Copy() const {
|
|
23541
|
+
auto result = make_unique<LoadInfo>();
|
|
23542
|
+
result->filename = filename;
|
|
23543
|
+
result->load_type = load_type;
|
|
23544
|
+
return result;
|
|
23545
|
+
}
|
|
23394
23546
|
};
|
|
23395
23547
|
|
|
23396
23548
|
} // namespace duckdb
|
|
@@ -23435,7 +23587,7 @@ public:
|
|
|
23435
23587
|
//===----------------------------------------------------------------------===//
|
|
23436
23588
|
// DuckDB
|
|
23437
23589
|
//
|
|
23438
|
-
// duckdb/parser/parsed_data/
|
|
23590
|
+
// duckdb/parser/parsed_data/create_schema_info.hpp
|
|
23439
23591
|
//
|
|
23440
23592
|
//
|
|
23441
23593
|
//===----------------------------------------------------------------------===//
|
|
@@ -23444,32 +23596,16 @@ public:
|
|
|
23444
23596
|
|
|
23445
23597
|
|
|
23446
23598
|
|
|
23447
|
-
|
|
23448
23599
|
namespace duckdb {
|
|
23449
23600
|
|
|
23450
|
-
struct
|
|
23451
|
-
|
|
23452
|
-
}
|
|
23453
|
-
CreateViewInfo(string schema, string view_name)
|
|
23454
|
-
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
23601
|
+
struct CreateSchemaInfo : public CreateInfo {
|
|
23602
|
+
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
23455
23603
|
}
|
|
23456
23604
|
|
|
23457
|
-
//! Table name to insert to
|
|
23458
|
-
string view_name;
|
|
23459
|
-
//! Aliases of the view
|
|
23460
|
-
vector<string> aliases;
|
|
23461
|
-
//! Return types
|
|
23462
|
-
vector<LogicalType> types;
|
|
23463
|
-
//! The SelectStatement of the view
|
|
23464
|
-
unique_ptr<SelectStatement> query;
|
|
23465
|
-
|
|
23466
23605
|
public:
|
|
23467
23606
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23468
|
-
auto result = make_unique<
|
|
23607
|
+
auto result = make_unique<CreateSchemaInfo>();
|
|
23469
23608
|
CopyProperties(*result);
|
|
23470
|
-
result->aliases = aliases;
|
|
23471
|
-
result->types = types;
|
|
23472
|
-
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23473
23609
|
return move(result);
|
|
23474
23610
|
}
|
|
23475
23611
|
};
|
|
@@ -23478,7 +23614,7 @@ public:
|
|
|
23478
23614
|
//===----------------------------------------------------------------------===//
|
|
23479
23615
|
// DuckDB
|
|
23480
23616
|
//
|
|
23481
|
-
// duckdb/parser/parsed_data/
|
|
23617
|
+
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
23482
23618
|
//
|
|
23483
23619
|
//
|
|
23484
23620
|
//===----------------------------------------------------------------------===//
|
|
@@ -23486,74 +23622,78 @@ public:
|
|
|
23486
23622
|
|
|
23487
23623
|
|
|
23488
23624
|
|
|
23625
|
+
|
|
23626
|
+
|
|
23489
23627
|
//===----------------------------------------------------------------------===//
|
|
23490
23628
|
// DuckDB
|
|
23491
23629
|
//
|
|
23492
|
-
// duckdb/
|
|
23630
|
+
// duckdb/parser/tableref/basetableref.hpp
|
|
23493
23631
|
//
|
|
23494
23632
|
//
|
|
23495
23633
|
//===----------------------------------------------------------------------===//
|
|
23496
23634
|
|
|
23497
23635
|
|
|
23498
|
-
//! The SelectStatement of the view
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
23502
23636
|
|
|
23503
23637
|
|
|
23504
23638
|
|
|
23505
23639
|
|
|
23506
23640
|
namespace duckdb {
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
class MacroFunction {
|
|
23641
|
+
//! Represents a TableReference to a base table in the schema
|
|
23642
|
+
class BaseTableRef : public TableRef {
|
|
23511
23643
|
public:
|
|
23512
|
-
|
|
23513
|
-
|
|
23644
|
+
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
23645
|
+
}
|
|
23514
23646
|
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
23647
|
+
//! Schema name
|
|
23648
|
+
string schema_name;
|
|
23649
|
+
//! Table name
|
|
23650
|
+
string table_name;
|
|
23651
|
+
//! Aliases for the column names
|
|
23652
|
+
vector<string> column_name_alias;
|
|
23522
23653
|
|
|
23523
23654
|
public:
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
void CopyProperties(MacroFunction &other);
|
|
23655
|
+
string ToString() const override;
|
|
23656
|
+
bool Equals(const TableRef *other_p) const override;
|
|
23528
23657
|
|
|
23529
|
-
|
|
23658
|
+
unique_ptr<TableRef> Copy() override;
|
|
23530
23659
|
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
|
|
23534
|
-
|
|
23660
|
+
//! Serializes a blob into a BaseTableRef
|
|
23661
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
23662
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
23663
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23535
23664
|
};
|
|
23536
|
-
|
|
23537
23665
|
} // namespace duckdb
|
|
23538
23666
|
|
|
23539
23667
|
|
|
23540
|
-
namespace duckdb {
|
|
23541
23668
|
|
|
23542
|
-
|
|
23543
|
-
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
23544
|
-
}
|
|
23669
|
+
namespace duckdb {
|
|
23545
23670
|
|
|
23546
|
-
|
|
23671
|
+
struct CreateIndexInfo : public CreateInfo {
|
|
23672
|
+
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
23547
23673
|
}
|
|
23548
23674
|
|
|
23549
|
-
|
|
23675
|
+
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
23676
|
+
IndexType index_type;
|
|
23677
|
+
//! Name of the Index
|
|
23678
|
+
string index_name;
|
|
23679
|
+
//! If it is an unique index
|
|
23680
|
+
bool unique = false;
|
|
23681
|
+
//! The table to create the index on
|
|
23682
|
+
unique_ptr<BaseTableRef> table;
|
|
23683
|
+
//! Set of expressions to index by
|
|
23684
|
+
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23550
23685
|
|
|
23551
23686
|
public:
|
|
23552
23687
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23553
|
-
auto result = make_unique<
|
|
23554
|
-
result->function = function->Copy();
|
|
23555
|
-
result->name = name;
|
|
23688
|
+
auto result = make_unique<CreateIndexInfo>();
|
|
23556
23689
|
CopyProperties(*result);
|
|
23690
|
+
result->index_type = index_type;
|
|
23691
|
+
result->index_name = index_name;
|
|
23692
|
+
result->unique = unique;
|
|
23693
|
+
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
23694
|
+
for (auto &expr : expressions) {
|
|
23695
|
+
result->expressions.push_back(expr->Copy());
|
|
23696
|
+
}
|
|
23557
23697
|
return move(result);
|
|
23558
23698
|
}
|
|
23559
23699
|
};
|
|
@@ -23598,7 +23738,7 @@ struct BoundExportData : public ParseInfo {
|
|
|
23598
23738
|
//===----------------------------------------------------------------------===//
|
|
23599
23739
|
// DuckDB
|
|
23600
23740
|
//
|
|
23601
|
-
// duckdb/parser/parsed_data/
|
|
23741
|
+
// duckdb/parser/parsed_data/create_macro_info.hpp
|
|
23602
23742
|
//
|
|
23603
23743
|
//
|
|
23604
23744
|
//===----------------------------------------------------------------------===//
|
|
@@ -23606,106 +23746,75 @@ struct BoundExportData : public ParseInfo {
|
|
|
23606
23746
|
|
|
23607
23747
|
|
|
23608
23748
|
|
|
23609
|
-
|
|
23610
|
-
namespace duckdb {
|
|
23611
|
-
|
|
23612
|
-
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
23613
|
-
|
|
23614
|
-
struct LoadInfo : public ParseInfo {
|
|
23615
|
-
std::string filename;
|
|
23616
|
-
LoadType load_type;
|
|
23617
|
-
|
|
23618
|
-
public:
|
|
23619
|
-
unique_ptr<LoadInfo> Copy() const {
|
|
23620
|
-
auto result = make_unique<LoadInfo>();
|
|
23621
|
-
result->filename = filename;
|
|
23622
|
-
result->load_type = load_type;
|
|
23623
|
-
return result;
|
|
23624
|
-
}
|
|
23625
|
-
};
|
|
23626
|
-
|
|
23627
|
-
} // namespace duckdb
|
|
23628
23749
|
//===----------------------------------------------------------------------===//
|
|
23629
23750
|
// DuckDB
|
|
23630
23751
|
//
|
|
23631
|
-
// duckdb/
|
|
23752
|
+
// duckdb/function/macro_function.hpp
|
|
23632
23753
|
//
|
|
23633
23754
|
//
|
|
23634
23755
|
//===----------------------------------------------------------------------===//
|
|
23635
23756
|
|
|
23636
23757
|
|
|
23758
|
+
//! The SelectStatement of the view
|
|
23637
23759
|
|
|
23638
23760
|
|
|
23639
23761
|
|
|
23640
23762
|
|
|
23641
|
-
namespace duckdb {
|
|
23642
23763
|
|
|
23643
|
-
struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
|
|
23644
|
-
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
23645
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
23646
|
-
this->name = function.name;
|
|
23647
|
-
functions.AddFunction(move(function));
|
|
23648
|
-
}
|
|
23649
23764
|
|
|
23650
|
-
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
23651
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
23652
|
-
this->name = functions.name;
|
|
23653
|
-
for (auto &func : functions.functions) {
|
|
23654
|
-
func.name = functions.name;
|
|
23655
|
-
}
|
|
23656
|
-
}
|
|
23657
23765
|
|
|
23658
|
-
|
|
23766
|
+
namespace duckdb {
|
|
23767
|
+
|
|
23768
|
+
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
23659
23769
|
|
|
23770
|
+
class MacroFunction {
|
|
23660
23771
|
public:
|
|
23661
|
-
unique_ptr<
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
|
|
23665
|
-
|
|
23666
|
-
|
|
23772
|
+
// explicit MacroFunction(unique_ptr<ParsedExpression> expression);
|
|
23773
|
+
MacroFunction(MacroType type);
|
|
23774
|
+
|
|
23775
|
+
// MacroFunction(void);
|
|
23776
|
+
// The type
|
|
23777
|
+
MacroType type;
|
|
23778
|
+
//! The positional parameters
|
|
23779
|
+
vector<unique_ptr<ParsedExpression>> parameters;
|
|
23780
|
+
//! The default parameters and their associated values
|
|
23781
|
+
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
23667
23782
|
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
//
|
|
23672
|
-
// duckdb/parser/parsed_data/drop_info.hpp
|
|
23673
|
-
//
|
|
23674
|
-
//
|
|
23675
|
-
//===----------------------------------------------------------------------===//
|
|
23783
|
+
public:
|
|
23784
|
+
virtual ~MacroFunction() {
|
|
23785
|
+
}
|
|
23676
23786
|
|
|
23787
|
+
void CopyProperties(MacroFunction &other);
|
|
23677
23788
|
|
|
23789
|
+
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
23678
23790
|
|
|
23791
|
+
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
23792
|
+
FunctionExpression &function_expr,
|
|
23793
|
+
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
23794
|
+
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
23795
|
+
};
|
|
23679
23796
|
|
|
23797
|
+
} // namespace duckdb
|
|
23680
23798
|
|
|
23681
23799
|
|
|
23682
23800
|
namespace duckdb {
|
|
23683
23801
|
|
|
23684
|
-
struct
|
|
23685
|
-
|
|
23802
|
+
struct CreateMacroInfo : public CreateFunctionInfo {
|
|
23803
|
+
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
23686
23804
|
}
|
|
23687
23805
|
|
|
23688
|
-
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
//! Element name to drop
|
|
23693
|
-
string name;
|
|
23694
|
-
//! Ignore if the entry does not exist instead of failing
|
|
23695
|
-
bool if_exists = false;
|
|
23696
|
-
//! Cascade drop (drop all dependents instead of throwing an error if there
|
|
23697
|
-
//! are any)
|
|
23698
|
-
bool cascade = false;
|
|
23806
|
+
CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
|
|
23807
|
+
}
|
|
23808
|
+
|
|
23809
|
+
unique_ptr<MacroFunction> function;
|
|
23699
23810
|
|
|
23700
23811
|
public:
|
|
23701
|
-
unique_ptr<
|
|
23702
|
-
auto result = make_unique<
|
|
23703
|
-
result->
|
|
23704
|
-
result->schema = schema;
|
|
23812
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23813
|
+
auto result = make_unique<CreateMacroInfo>();
|
|
23814
|
+
result->function = function->Copy();
|
|
23705
23815
|
result->name = name;
|
|
23706
|
-
result
|
|
23707
|
-
result
|
|
23708
|
-
return result;
|
|
23816
|
+
CopyProperties(*result);
|
|
23817
|
+
return move(result);
|
|
23709
23818
|
}
|
|
23710
23819
|
};
|
|
23711
23820
|
|
|
@@ -23753,7 +23862,7 @@ public:
|
|
|
23753
23862
|
//===----------------------------------------------------------------------===//
|
|
23754
23863
|
// DuckDB
|
|
23755
23864
|
//
|
|
23756
|
-
// duckdb/parser/
|
|
23865
|
+
// duckdb/parser/parsed_data/create_view_info.hpp
|
|
23757
23866
|
//
|
|
23758
23867
|
//
|
|
23759
23868
|
//===----------------------------------------------------------------------===//
|
|
@@ -23763,38 +23872,59 @@ public:
|
|
|
23763
23872
|
|
|
23764
23873
|
|
|
23765
23874
|
|
|
23875
|
+
namespace duckdb {
|
|
23766
23876
|
|
|
23877
|
+
struct CreateViewInfo : public CreateInfo {
|
|
23878
|
+
CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
|
|
23879
|
+
}
|
|
23880
|
+
CreateViewInfo(string schema, string view_name)
|
|
23881
|
+
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
23882
|
+
}
|
|
23883
|
+
|
|
23884
|
+
//! Table name to insert to
|
|
23885
|
+
string view_name;
|
|
23886
|
+
//! Aliases of the view
|
|
23887
|
+
vector<string> aliases;
|
|
23888
|
+
//! Return types
|
|
23889
|
+
vector<LogicalType> types;
|
|
23890
|
+
//! The SelectStatement of the view
|
|
23891
|
+
unique_ptr<SelectStatement> query;
|
|
23767
23892
|
|
|
23768
|
-
namespace duckdb {
|
|
23769
|
-
//! Represents an expression list as generated by a VALUES statement
|
|
23770
|
-
class ExpressionListRef : public TableRef {
|
|
23771
23893
|
public:
|
|
23772
|
-
|
|
23894
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23895
|
+
auto result = make_unique<CreateViewInfo>(schema, view_name);
|
|
23896
|
+
CopyProperties(*result);
|
|
23897
|
+
result->aliases = aliases;
|
|
23898
|
+
result->types = types;
|
|
23899
|
+
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23900
|
+
return move(result);
|
|
23773
23901
|
}
|
|
23902
|
+
};
|
|
23774
23903
|
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
|
|
23780
|
-
|
|
23904
|
+
} // namespace duckdb
|
|
23905
|
+
//===----------------------------------------------------------------------===//
|
|
23906
|
+
// DuckDB
|
|
23907
|
+
//
|
|
23908
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23909
|
+
//
|
|
23910
|
+
//
|
|
23911
|
+
//===----------------------------------------------------------------------===//
|
|
23781
23912
|
|
|
23782
|
-
public:
|
|
23783
|
-
bool Equals(const TableRef *other_p) const override;
|
|
23784
23913
|
|
|
23785
|
-
unique_ptr<TableRef> Copy() override;
|
|
23786
23914
|
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23915
|
+
|
|
23916
|
+
|
|
23917
|
+
namespace duckdb {
|
|
23918
|
+
|
|
23919
|
+
struct VacuumInfo : public ParseInfo {
|
|
23920
|
+
// nothing for now
|
|
23791
23921
|
};
|
|
23792
|
-
} // namespace duckdb
|
|
23793
23922
|
|
|
23923
|
+
} // namespace duckdb
|
|
23794
23924
|
//===----------------------------------------------------------------------===//
|
|
23795
23925
|
// DuckDB
|
|
23796
23926
|
//
|
|
23797
|
-
// duckdb/parser/tableref/
|
|
23927
|
+
// duckdb/parser/tableref/emptytableref.hpp
|
|
23798
23928
|
//
|
|
23799
23929
|
//
|
|
23800
23930
|
//===----------------------------------------------------------------------===//
|
|
@@ -23805,32 +23935,27 @@ public:
|
|
|
23805
23935
|
|
|
23806
23936
|
namespace duckdb {
|
|
23807
23937
|
//! Represents a cross product
|
|
23808
|
-
class
|
|
23938
|
+
class EmptyTableRef : public TableRef {
|
|
23809
23939
|
public:
|
|
23810
|
-
|
|
23940
|
+
EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
|
|
23811
23941
|
}
|
|
23812
23942
|
|
|
23813
|
-
//! The left hand side of the cross product
|
|
23814
|
-
unique_ptr<TableRef> left;
|
|
23815
|
-
//! The right hand side of the cross product
|
|
23816
|
-
unique_ptr<TableRef> right;
|
|
23817
|
-
|
|
23818
23943
|
public:
|
|
23944
|
+
string ToString() const override;
|
|
23819
23945
|
bool Equals(const TableRef *other_p) const override;
|
|
23820
23946
|
|
|
23821
23947
|
unique_ptr<TableRef> Copy() override;
|
|
23822
23948
|
|
|
23823
|
-
//! Serializes a blob into a
|
|
23949
|
+
//! Serializes a blob into a DummyTableRef
|
|
23824
23950
|
void Serialize(FieldWriter &serializer) const override;
|
|
23825
|
-
//! Deserializes a blob back into a
|
|
23951
|
+
//! Deserializes a blob back into a DummyTableRef
|
|
23826
23952
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23827
23953
|
};
|
|
23828
23954
|
} // namespace duckdb
|
|
23829
|
-
|
|
23830
23955
|
//===----------------------------------------------------------------------===//
|
|
23831
23956
|
// DuckDB
|
|
23832
23957
|
//
|
|
23833
|
-
// duckdb/parser/tableref/
|
|
23958
|
+
// duckdb/parser/tableref/table_function_ref.hpp
|
|
23834
23959
|
//
|
|
23835
23960
|
//
|
|
23836
23961
|
//===----------------------------------------------------------------------===//
|
|
@@ -23839,30 +23964,38 @@ public:
|
|
|
23839
23964
|
|
|
23840
23965
|
|
|
23841
23966
|
|
|
23967
|
+
|
|
23968
|
+
|
|
23969
|
+
|
|
23842
23970
|
namespace duckdb {
|
|
23843
|
-
//! Represents a
|
|
23844
|
-
class
|
|
23971
|
+
//! Represents a Table producing function
|
|
23972
|
+
class TableFunctionRef : public TableRef {
|
|
23845
23973
|
public:
|
|
23846
|
-
|
|
23847
|
-
|
|
23974
|
+
DUCKDB_API TableFunctionRef();
|
|
23975
|
+
|
|
23976
|
+
unique_ptr<ParsedExpression> function;
|
|
23977
|
+
vector<string> column_name_alias;
|
|
23978
|
+
|
|
23979
|
+
// if the function takes a subquery as argument its in here
|
|
23980
|
+
unique_ptr<SelectStatement> subquery;
|
|
23848
23981
|
|
|
23849
23982
|
public:
|
|
23983
|
+
string ToString() const override;
|
|
23984
|
+
|
|
23850
23985
|
bool Equals(const TableRef *other_p) const override;
|
|
23851
23986
|
|
|
23852
23987
|
unique_ptr<TableRef> Copy() override;
|
|
23853
23988
|
|
|
23854
|
-
//! Serializes a blob into a
|
|
23989
|
+
//! Serializes a blob into a BaseTableRef
|
|
23855
23990
|
void Serialize(FieldWriter &serializer) const override;
|
|
23856
|
-
//! Deserializes a blob back into a
|
|
23991
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
23857
23992
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23858
23993
|
};
|
|
23859
23994
|
} // namespace duckdb
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
23995
|
//===----------------------------------------------------------------------===//
|
|
23863
23996
|
// DuckDB
|
|
23864
23997
|
//
|
|
23865
|
-
// duckdb/parser/tableref/
|
|
23998
|
+
// duckdb/parser/tableref/expressionlistref.hpp
|
|
23866
23999
|
//
|
|
23867
24000
|
//
|
|
23868
24001
|
//===----------------------------------------------------------------------===//
|
|
@@ -23874,39 +24007,32 @@ public:
|
|
|
23874
24007
|
|
|
23875
24008
|
|
|
23876
24009
|
|
|
23877
|
-
|
|
23878
24010
|
namespace duckdb {
|
|
23879
|
-
//! Represents
|
|
23880
|
-
class
|
|
24011
|
+
//! Represents an expression list as generated by a VALUES statement
|
|
24012
|
+
class ExpressionListRef : public TableRef {
|
|
23881
24013
|
public:
|
|
23882
|
-
|
|
24014
|
+
ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
|
|
23883
24015
|
}
|
|
23884
24016
|
|
|
23885
|
-
//!
|
|
23886
|
-
unique_ptr<
|
|
23887
|
-
//!
|
|
23888
|
-
|
|
23889
|
-
//! The
|
|
23890
|
-
|
|
23891
|
-
//! The join type
|
|
23892
|
-
JoinType type;
|
|
23893
|
-
//! Natural join
|
|
23894
|
-
bool is_natural;
|
|
23895
|
-
//! The set of USING columns (if any)
|
|
23896
|
-
vector<string> using_columns;
|
|
24017
|
+
//! Value list, only used for VALUES statement
|
|
24018
|
+
vector<vector<unique_ptr<ParsedExpression>>> values;
|
|
24019
|
+
//! Expected SQL types
|
|
24020
|
+
vector<LogicalType> expected_types;
|
|
24021
|
+
//! The set of expected names
|
|
24022
|
+
vector<string> expected_names;
|
|
23897
24023
|
|
|
23898
24024
|
public:
|
|
24025
|
+
string ToString() const override;
|
|
23899
24026
|
bool Equals(const TableRef *other_p) const override;
|
|
23900
24027
|
|
|
23901
24028
|
unique_ptr<TableRef> Copy() override;
|
|
23902
24029
|
|
|
23903
|
-
//! Serializes a blob into a
|
|
24030
|
+
//! Serializes a blob into a ExpressionListRef
|
|
23904
24031
|
void Serialize(FieldWriter &serializer) const override;
|
|
23905
|
-
//! Deserializes a blob back into a
|
|
24032
|
+
//! Deserializes a blob back into a ExpressionListRef
|
|
23906
24033
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23907
24034
|
};
|
|
23908
24035
|
} // namespace duckdb
|
|
23909
|
-
|
|
23910
24036
|
//===----------------------------------------------------------------------===//
|
|
23911
24037
|
// DuckDB
|
|
23912
24038
|
//
|
|
@@ -23932,6 +24058,7 @@ public:
|
|
|
23932
24058
|
vector<string> column_name_alias;
|
|
23933
24059
|
|
|
23934
24060
|
public:
|
|
24061
|
+
string ToString() const override;
|
|
23935
24062
|
bool Equals(const TableRef *other_p) const override;
|
|
23936
24063
|
|
|
23937
24064
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23946,7 +24073,46 @@ public:
|
|
|
23946
24073
|
//===----------------------------------------------------------------------===//
|
|
23947
24074
|
// DuckDB
|
|
23948
24075
|
//
|
|
23949
|
-
// duckdb/parser/tableref/
|
|
24076
|
+
// duckdb/parser/tableref/crossproductref.hpp
|
|
24077
|
+
//
|
|
24078
|
+
//
|
|
24079
|
+
//===----------------------------------------------------------------------===//
|
|
24080
|
+
|
|
24081
|
+
|
|
24082
|
+
|
|
24083
|
+
|
|
24084
|
+
|
|
24085
|
+
namespace duckdb {
|
|
24086
|
+
//! Represents a cross product
|
|
24087
|
+
class CrossProductRef : public TableRef {
|
|
24088
|
+
public:
|
|
24089
|
+
CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
|
|
24090
|
+
}
|
|
24091
|
+
|
|
24092
|
+
//! The left hand side of the cross product
|
|
24093
|
+
unique_ptr<TableRef> left;
|
|
24094
|
+
//! The right hand side of the cross product
|
|
24095
|
+
unique_ptr<TableRef> right;
|
|
24096
|
+
|
|
24097
|
+
public:
|
|
24098
|
+
string ToString() const override;
|
|
24099
|
+
bool Equals(const TableRef *other_p) const override;
|
|
24100
|
+
|
|
24101
|
+
unique_ptr<TableRef> Copy() override;
|
|
24102
|
+
|
|
24103
|
+
//! Serializes a blob into a CrossProductRef
|
|
24104
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
24105
|
+
//! Deserializes a blob back into a CrossProductRef
|
|
24106
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24107
|
+
};
|
|
24108
|
+
} // namespace duckdb
|
|
24109
|
+
|
|
24110
|
+
|
|
24111
|
+
|
|
24112
|
+
//===----------------------------------------------------------------------===//
|
|
24113
|
+
// DuckDB
|
|
24114
|
+
//
|
|
24115
|
+
// duckdb/parser/tableref/joinref.hpp
|
|
23950
24116
|
//
|
|
23951
24117
|
//
|
|
23952
24118
|
//===----------------------------------------------------------------------===//
|
|
@@ -23958,30 +24124,39 @@ public:
|
|
|
23958
24124
|
|
|
23959
24125
|
|
|
23960
24126
|
|
|
24127
|
+
|
|
23961
24128
|
namespace duckdb {
|
|
23962
|
-
//! Represents a
|
|
23963
|
-
class
|
|
24129
|
+
//! Represents a JOIN between two expressions
|
|
24130
|
+
class JoinRef : public TableRef {
|
|
23964
24131
|
public:
|
|
23965
|
-
|
|
24132
|
+
JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
|
|
23966
24133
|
}
|
|
23967
24134
|
|
|
23968
|
-
|
|
23969
|
-
|
|
23970
|
-
|
|
23971
|
-
|
|
23972
|
-
|
|
24135
|
+
//! The left hand side of the join
|
|
24136
|
+
unique_ptr<TableRef> left;
|
|
24137
|
+
//! The right hand side of the join
|
|
24138
|
+
unique_ptr<TableRef> right;
|
|
24139
|
+
//! The join condition
|
|
24140
|
+
unique_ptr<ParsedExpression> condition;
|
|
24141
|
+
//! The join type
|
|
24142
|
+
JoinType type;
|
|
24143
|
+
//! Natural join
|
|
24144
|
+
bool is_natural;
|
|
24145
|
+
//! The set of USING columns (if any)
|
|
24146
|
+
vector<string> using_columns;
|
|
23973
24147
|
|
|
23974
24148
|
public:
|
|
23975
24149
|
string ToString() const override;
|
|
23976
|
-
|
|
23977
24150
|
bool Equals(const TableRef *other_p) const override;
|
|
23978
24151
|
|
|
23979
24152
|
unique_ptr<TableRef> Copy() override;
|
|
23980
24153
|
|
|
23981
|
-
//! Serializes a blob into a
|
|
24154
|
+
//! Serializes a blob into a JoinRef
|
|
23982
24155
|
void Serialize(FieldWriter &serializer) const override;
|
|
23983
|
-
//! Deserializes a blob back into a
|
|
24156
|
+
//! Deserializes a blob back into a JoinRef
|
|
23984
24157
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23985
24158
|
};
|
|
23986
24159
|
} // namespace duckdb
|
|
23987
24160
|
|
|
24161
|
+
|
|
24162
|
+
|