duckdb 0.3.5-dev116.0 → 0.3.5-dev1167.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/configure +2 -2
- package/lib/duckdb-binding.js +2 -4
- package/package.json +1 -1
- package/src/connection.cpp +7 -0
- package/src/duckdb.cpp +38712 -29277
- package/src/duckdb.hpp +1643 -1139
- package/src/parquet-amalgamation.cpp +31328 -31133
- package/src/parquet-amalgamation.hpp +186 -16
- package/src/statement.cpp +85 -64
- package/test/data_type_support.test.js +63 -6
- 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 "9c978fb3c"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.5-dev1167"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -162,6 +162,8 @@ typedef idx_t transaction_t;
|
|
|
162
162
|
|
|
163
163
|
//! Type used for column identifiers
|
|
164
164
|
typedef idx_t column_t;
|
|
165
|
+
//! Type used for storage (column) identifiers
|
|
166
|
+
typedef idx_t storage_t;
|
|
165
167
|
//! Special value used to signify the ROW ID of a table
|
|
166
168
|
extern const column_t COLUMN_IDENTIFIER_ROW_ID;
|
|
167
169
|
|
|
@@ -622,6 +624,7 @@ using std::vector;
|
|
|
622
624
|
}
|
|
623
625
|
|
|
624
626
|
|
|
627
|
+
#include <limits>
|
|
625
628
|
|
|
626
629
|
namespace duckdb {
|
|
627
630
|
|
|
@@ -631,7 +634,7 @@ class Value;
|
|
|
631
634
|
class TypeCatalogEntry;
|
|
632
635
|
class Vector;
|
|
633
636
|
//! Type used to represent dates (days since 1970-01-01)
|
|
634
|
-
struct date_t {
|
|
637
|
+
struct date_t { // NOLINT
|
|
635
638
|
int32_t days;
|
|
636
639
|
|
|
637
640
|
date_t() = default;
|
|
@@ -655,10 +658,15 @@ struct date_t {
|
|
|
655
658
|
// in-place operators
|
|
656
659
|
inline date_t &operator+=(const int32_t &days) {this->days += days; return *this;};
|
|
657
660
|
inline date_t &operator-=(const int32_t &days) {this->days -= days; return *this;};
|
|
661
|
+
|
|
662
|
+
// special values
|
|
663
|
+
static inline date_t infinity() {return date_t(std::numeric_limits<int32_t>::max()); } // NOLINT
|
|
664
|
+
static inline date_t ninfinity() {return date_t(-std::numeric_limits<int32_t>::max()); } // NOLINT
|
|
665
|
+
static inline date_t epoch() {return date_t(0); } // NOLINT
|
|
658
666
|
};
|
|
659
667
|
|
|
660
668
|
//! Type used to represent time (microseconds)
|
|
661
|
-
struct dtime_t {
|
|
669
|
+
struct dtime_t { // NOLINT
|
|
662
670
|
int64_t micros;
|
|
663
671
|
|
|
664
672
|
dtime_t() = default;
|
|
@@ -689,10 +697,13 @@ struct dtime_t {
|
|
|
689
697
|
inline dtime_t &operator+=(const int64_t µs) {this->micros += micros; return *this;};
|
|
690
698
|
inline dtime_t &operator-=(const int64_t µs) {this->micros -= micros; return *this;};
|
|
691
699
|
inline dtime_t &operator+=(const dtime_t &other) {this->micros += other.micros; return *this;};
|
|
700
|
+
|
|
701
|
+
// special values
|
|
702
|
+
static inline dtime_t allballs() {return dtime_t(0); } // NOLINT
|
|
692
703
|
};
|
|
693
704
|
|
|
694
705
|
//! Type used to represent timestamps (seconds,microseconds,milliseconds or nanoseconds since 1970-01-01)
|
|
695
|
-
struct timestamp_t {
|
|
706
|
+
struct timestamp_t { // NOLINT
|
|
696
707
|
int64_t value;
|
|
697
708
|
|
|
698
709
|
timestamp_t() = default;
|
|
@@ -717,6 +728,11 @@ struct timestamp_t {
|
|
|
717
728
|
// in-place operators
|
|
718
729
|
inline timestamp_t &operator+=(const int64_t &value) {this->value += value; return *this;};
|
|
719
730
|
inline timestamp_t &operator-=(const int64_t &value) {this->value -= value; return *this;};
|
|
731
|
+
|
|
732
|
+
// special values
|
|
733
|
+
static inline timestamp_t infinity() {return timestamp_t(std::numeric_limits<int64_t>::max()); } // NOLINT
|
|
734
|
+
static inline timestamp_t ninfinity() {return timestamp_t(-std::numeric_limits<int64_t>::max()); } // NOLINT
|
|
735
|
+
static inline timestamp_t epoch() {return timestamp_t(0); } // NOLINT
|
|
720
736
|
};
|
|
721
737
|
|
|
722
738
|
struct interval_t {
|
|
@@ -1031,8 +1047,12 @@ struct LogicalType {
|
|
|
1031
1047
|
DUCKDB_API bool IsIntegral() const;
|
|
1032
1048
|
DUCKDB_API bool IsNumeric() const;
|
|
1033
1049
|
DUCKDB_API hash_t Hash() const;
|
|
1050
|
+
DUCKDB_API void SetAlias(string &alias);
|
|
1051
|
+
DUCKDB_API string GetAlias() const;
|
|
1034
1052
|
|
|
1035
1053
|
DUCKDB_API static LogicalType MaxLogicalType(const LogicalType &left, const LogicalType &right);
|
|
1054
|
+
DUCKDB_API static void SetCatalog(LogicalType &type, TypeCatalogEntry* catalog_entry);
|
|
1055
|
+
DUCKDB_API static TypeCatalogEntry* GetCatalog(const LogicalType &type);
|
|
1036
1056
|
|
|
1037
1057
|
//! Gets the decimal properties of a numeric type. Fails if the type is not numeric.
|
|
1038
1058
|
DUCKDB_API bool GetDecimalProperties(uint8_t &width, uint8_t &scale) const;
|
|
@@ -1090,6 +1110,7 @@ public:
|
|
|
1090
1110
|
DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
|
|
1091
1111
|
DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
|
|
1092
1112
|
DUCKDB_API static LogicalType ENUM(const string &enum_name, Vector &ordered_data, idx_t size); // NOLINT
|
|
1113
|
+
DUCKDB_API static LogicalType DEDUP_POINTER_ENUM(); // NOLINT
|
|
1093
1114
|
DUCKDB_API static LogicalType USER(const string &user_type_name); // NOLINT
|
|
1094
1115
|
//! A list of all NUMERIC types (integral and floating point types)
|
|
1095
1116
|
DUCKDB_API static const vector<LogicalType> Numeric();
|
|
@@ -1124,7 +1145,7 @@ struct EnumType{
|
|
|
1124
1145
|
DUCKDB_API static const string GetValue(const Value &val);
|
|
1125
1146
|
DUCKDB_API static void SetCatalog(LogicalType &type, TypeCatalogEntry* catalog_entry);
|
|
1126
1147
|
DUCKDB_API static TypeCatalogEntry* GetCatalog(const LogicalType &type);
|
|
1127
|
-
DUCKDB_API static PhysicalType GetPhysicalType(
|
|
1148
|
+
DUCKDB_API static PhysicalType GetPhysicalType(const LogicalType &type);
|
|
1128
1149
|
};
|
|
1129
1150
|
|
|
1130
1151
|
struct StructType {
|
|
@@ -1249,8 +1270,8 @@ struct ExceptionFormatValue {
|
|
|
1249
1270
|
|
|
1250
1271
|
ExceptionFormatValueType type;
|
|
1251
1272
|
|
|
1252
|
-
double dbl_val;
|
|
1253
|
-
int64_t int_val;
|
|
1273
|
+
double dbl_val = 0;
|
|
1274
|
+
int64_t int_val = 0;
|
|
1254
1275
|
string str_val;
|
|
1255
1276
|
|
|
1256
1277
|
public:
|
|
@@ -2789,7 +2810,7 @@ public:
|
|
|
2789
2810
|
DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
|
|
2790
2811
|
//! Create an empty list with the specified child-type
|
|
2791
2812
|
DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
|
|
2792
|
-
//!
|
|
2813
|
+
//! Create a map value from a (key, value) pair
|
|
2793
2814
|
DUCKDB_API static Value MAP(Value key, Value value);
|
|
2794
2815
|
|
|
2795
2816
|
//! Create a blob Value from a data pointer and a length: no bytes are interpreted
|
|
@@ -2882,6 +2903,8 @@ public:
|
|
|
2882
2903
|
//! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
|
|
2883
2904
|
//! function, NULL values are equivalent and floating point values that are close are equivalent.
|
|
2884
2905
|
DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
|
|
2906
|
+
//! Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.
|
|
2907
|
+
DUCKDB_API static bool NotDistinctFrom(const Value &lvalue, const Value &rvalue);
|
|
2885
2908
|
|
|
2886
2909
|
friend std::ostream &operator<<(std::ostream &out, const Value &val) {
|
|
2887
2910
|
out << val.ToString();
|
|
@@ -3094,6 +3117,8 @@ template <>
|
|
|
3094
3117
|
DUCKDB_API timestamp_t Value::GetValue() const;
|
|
3095
3118
|
template <>
|
|
3096
3119
|
DUCKDB_API interval_t Value::GetValue() const;
|
|
3120
|
+
template <>
|
|
3121
|
+
DUCKDB_API Value Value::GetValue() const;
|
|
3097
3122
|
|
|
3098
3123
|
template <>
|
|
3099
3124
|
DUCKDB_API bool Value::GetValueUnsafe() const;
|
|
@@ -3172,6 +3197,10 @@ template <>
|
|
|
3172
3197
|
DUCKDB_API bool Value::IsFinite(float input);
|
|
3173
3198
|
template <>
|
|
3174
3199
|
DUCKDB_API bool Value::IsFinite(double input);
|
|
3200
|
+
template <>
|
|
3201
|
+
DUCKDB_API bool Value::IsFinite(date_t input);
|
|
3202
|
+
template <>
|
|
3203
|
+
DUCKDB_API bool Value::IsFinite(timestamp_t input);
|
|
3175
3204
|
|
|
3176
3205
|
} // namespace duckdb
|
|
3177
3206
|
|
|
@@ -3852,7 +3881,6 @@ struct FlatVector {
|
|
|
3852
3881
|
D_ASSERT(vector.GetVectorType() == VectorType::FLAT_VECTOR);
|
|
3853
3882
|
return !vector.validity.RowIsValid(idx);
|
|
3854
3883
|
}
|
|
3855
|
-
DUCKDB_API static const SelectionVector *IncrementalSelectionVector(idx_t count, SelectionVector &owned_sel);
|
|
3856
3884
|
DUCKDB_API static const SelectionVector *IncrementalSelectionVector();
|
|
3857
3885
|
};
|
|
3858
3886
|
|
|
@@ -3974,6 +4002,9 @@ struct SequenceVector {
|
|
|
3974
4002
|
extern "C" {
|
|
3975
4003
|
#endif
|
|
3976
4004
|
|
|
4005
|
+
#ifndef ARROW_C_DATA_INTERFACE
|
|
4006
|
+
#define ARROW_C_DATA_INTERFACE
|
|
4007
|
+
|
|
3977
4008
|
#define ARROW_FLAG_DICTIONARY_ORDERED 1
|
|
3978
4009
|
#define ARROW_FLAG_NULLABLE 2
|
|
3979
4010
|
#define ARROW_FLAG_MAP_KEYS_SORTED 4
|
|
@@ -4010,7 +4041,10 @@ struct ArrowArray {
|
|
|
4010
4041
|
// Opaque producer-specific data
|
|
4011
4042
|
void *private_data;
|
|
4012
4043
|
};
|
|
4044
|
+
#endif
|
|
4013
4045
|
|
|
4046
|
+
#ifndef ARROW_C_STREAM_INTERFACE
|
|
4047
|
+
#define ARROW_C_STREAM_INTERFACE
|
|
4014
4048
|
// EXPERIMENTAL
|
|
4015
4049
|
struct ArrowArrayStream {
|
|
4016
4050
|
// Callback to get the stream type
|
|
@@ -4035,6 +4069,7 @@ struct ArrowArrayStream {
|
|
|
4035
4069
|
// Opaque producer-specific data
|
|
4036
4070
|
void *private_data;
|
|
4037
4071
|
};
|
|
4072
|
+
#endif
|
|
4038
4073
|
|
|
4039
4074
|
#ifdef __cplusplus
|
|
4040
4075
|
}
|
|
@@ -4867,9 +4902,8 @@ public:
|
|
|
4867
4902
|
template <class LEFT_TYPE, class RIGHT_TYPE, class OP>
|
|
4868
4903
|
static idx_t Select(Vector &left, Vector &right, const SelectionVector *sel, idx_t count, SelectionVector *true_sel,
|
|
4869
4904
|
SelectionVector *false_sel) {
|
|
4870
|
-
SelectionVector owned_sel;
|
|
4871
4905
|
if (!sel) {
|
|
4872
|
-
sel = FlatVector::IncrementalSelectionVector(
|
|
4906
|
+
sel = FlatVector::IncrementalSelectionVector();
|
|
4873
4907
|
}
|
|
4874
4908
|
if (left.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
4875
4909
|
right.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
@@ -4909,9 +4943,23 @@ public:
|
|
|
4909
4943
|
|
|
4910
4944
|
namespace duckdb {
|
|
4911
4945
|
|
|
4946
|
+
struct TernaryLambdaWrapper {
|
|
4947
|
+
template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
|
|
4948
|
+
static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
|
|
4949
|
+
return fun(a, b, c);
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
|
|
4953
|
+
struct TernaryLambdaWrapperWithNulls {
|
|
4954
|
+
template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
|
|
4955
|
+
static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
|
|
4956
|
+
return fun(a, b, c, mask, idx);
|
|
4957
|
+
}
|
|
4958
|
+
};
|
|
4959
|
+
|
|
4912
4960
|
struct TernaryExecutor {
|
|
4913
4961
|
private:
|
|
4914
|
-
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class FUN>
|
|
4962
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
|
|
4915
4963
|
static inline void ExecuteLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
|
|
4916
4964
|
RESULT_TYPE *__restrict result_data, idx_t count, const SelectionVector &asel,
|
|
4917
4965
|
const SelectionVector &bsel, const SelectionVector &csel, ValidityMask &avalidity,
|
|
@@ -4923,7 +4971,8 @@ private:
|
|
|
4923
4971
|
auto bidx = bsel.get_index(i);
|
|
4924
4972
|
auto cidx = csel.get_index(i);
|
|
4925
4973
|
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx) && cvalidity.RowIsValid(cidx)) {
|
|
4926
|
-
result_data[i] =
|
|
4974
|
+
result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
4975
|
+
fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
|
|
4927
4976
|
} else {
|
|
4928
4977
|
result_validity.SetInvalid(i);
|
|
4929
4978
|
}
|
|
@@ -4933,15 +4982,15 @@ private:
|
|
|
4933
4982
|
auto aidx = asel.get_index(i);
|
|
4934
4983
|
auto bidx = bsel.get_index(i);
|
|
4935
4984
|
auto cidx = csel.get_index(i);
|
|
4936
|
-
result_data[i] =
|
|
4985
|
+
result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
4986
|
+
fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
|
|
4937
4987
|
}
|
|
4938
4988
|
}
|
|
4939
4989
|
}
|
|
4940
4990
|
|
|
4941
4991
|
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) {
|
|
4992
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
|
|
4993
|
+
static void ExecuteGeneric(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
4945
4994
|
if (a.GetVectorType() == VectorType::CONSTANT_VECTOR && b.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
4946
4995
|
c.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
4947
4996
|
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
@@ -4952,7 +5001,9 @@ public:
|
|
|
4952
5001
|
auto bdata = ConstantVector::GetData<B_TYPE>(b);
|
|
4953
5002
|
auto cdata = ConstantVector::GetData<C_TYPE>(c);
|
|
4954
5003
|
auto result_data = ConstantVector::GetData<RESULT_TYPE>(result);
|
|
4955
|
-
|
|
5004
|
+
auto &result_validity = ConstantVector::Validity(result);
|
|
5005
|
+
result_data[0] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
5006
|
+
fun, adata[0], bdata[0], cdata[0], result_validity, 0);
|
|
4956
5007
|
}
|
|
4957
5008
|
} else {
|
|
4958
5009
|
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
@@ -4962,13 +5013,26 @@ public:
|
|
|
4962
5013
|
b.Orrify(count, bdata);
|
|
4963
5014
|
c.Orrify(count, cdata);
|
|
4964
5015
|
|
|
4965
|
-
ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
5016
|
+
ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, OPWRAPPER>(
|
|
4966
5017
|
(A_TYPE *)adata.data, (B_TYPE *)bdata.data, (C_TYPE *)cdata.data,
|
|
4967
5018
|
FlatVector::GetData<RESULT_TYPE>(result), count, *adata.sel, *bdata.sel, *cdata.sel, adata.validity,
|
|
4968
5019
|
bdata.validity, cdata.validity, FlatVector::Validity(result), fun);
|
|
4969
5020
|
}
|
|
4970
5021
|
}
|
|
4971
5022
|
|
|
5023
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
5024
|
+
class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE)>>
|
|
5025
|
+
static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
5026
|
+
ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapper, FUN>(a, b, c, result, count, fun);
|
|
5027
|
+
}
|
|
5028
|
+
|
|
5029
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
5030
|
+
class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE, ValidityMask &, idx_t)>>
|
|
5031
|
+
static void ExecuteWithNulls(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
5032
|
+
ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapperWithNulls, FUN>(a, b, c, result, count,
|
|
5033
|
+
fun);
|
|
5034
|
+
}
|
|
5035
|
+
|
|
4972
5036
|
private:
|
|
4973
5037
|
template <class A_TYPE, class B_TYPE, class C_TYPE, class OP, bool NO_NULL, bool HAS_TRUE_SEL, bool HAS_FALSE_SEL>
|
|
4974
5038
|
static inline idx_t SelectLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
|
|
@@ -5038,9 +5102,8 @@ public:
|
|
|
5038
5102
|
template <class A_TYPE, class B_TYPE, class C_TYPE, class OP>
|
|
5039
5103
|
static idx_t Select(Vector &a, Vector &b, Vector &c, const SelectionVector *sel, idx_t count,
|
|
5040
5104
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
5041
|
-
SelectionVector owned_sel;
|
|
5042
5105
|
if (!sel) {
|
|
5043
|
-
sel = FlatVector::IncrementalSelectionVector(
|
|
5106
|
+
sel = FlatVector::IncrementalSelectionVector();
|
|
5044
5107
|
}
|
|
5045
5108
|
VectorData adata, bdata, cdata;
|
|
5046
5109
|
a.Orrify(count, adata);
|
|
@@ -5315,195 +5378,6 @@ using std::chrono::system_clock;
|
|
|
5315
5378
|
using std::chrono::time_point;
|
|
5316
5379
|
} // namespace duckdb
|
|
5317
5380
|
|
|
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
5381
|
|
|
5508
5382
|
namespace duckdb {
|
|
5509
5383
|
|
|
@@ -5561,7 +5435,6 @@ private:
|
|
|
5561
5435
|
|
|
5562
5436
|
} // namespace duckdb
|
|
5563
5437
|
|
|
5564
|
-
|
|
5565
5438
|
//===----------------------------------------------------------------------===//
|
|
5566
5439
|
// DuckDB
|
|
5567
5440
|
//
|
|
@@ -6013,6 +5886,9 @@ enum class ExpressionClass : uint8_t {
|
|
|
6013
5886
|
DUCKDB_API string ExpressionTypeToString(ExpressionType type);
|
|
6014
5887
|
string ExpressionTypeToOperator(ExpressionType type);
|
|
6015
5888
|
|
|
5889
|
+
// Operator String to ExpressionType (e.g. + => OPERATOR_ADD)
|
|
5890
|
+
ExpressionType OperatorToExpressionType(const string &op);
|
|
5891
|
+
|
|
6016
5892
|
//! Negate a comparison expression, turning e.g. = into !=, or < into >=
|
|
6017
5893
|
ExpressionType NegateComparisionExpression(ExpressionType type);
|
|
6018
5894
|
//! Flip a comparison expression, turning e.g. < into >, or = into =
|
|
@@ -6074,7 +5950,7 @@ public:
|
|
|
6074
5950
|
//! Convert the Expression to a String
|
|
6075
5951
|
virtual string ToString() const = 0;
|
|
6076
5952
|
//! Print the expression to stdout
|
|
6077
|
-
void Print();
|
|
5953
|
+
void Print() const;
|
|
6078
5954
|
|
|
6079
5955
|
//! Creates a hash value of this expression. It is important that if two expressions are identical (i.e.
|
|
6080
5956
|
//! Expression::Equals() returns true), that their hash value is identical as well.
|
|
@@ -6137,7 +6013,7 @@ public:
|
|
|
6137
6013
|
static bool RequiresQuotes(const string &text);
|
|
6138
6014
|
|
|
6139
6015
|
//! Writes a string that is optionally quoted + escaped so it can be used as an identifier
|
|
6140
|
-
static string WriteOptionallyQuoted(const string &text);
|
|
6016
|
+
static string WriteOptionallyQuoted(const string &text, char quote = '"');
|
|
6141
6017
|
};
|
|
6142
6018
|
|
|
6143
6019
|
} // namespace duckdb
|
|
@@ -6338,31 +6214,104 @@ string CompressionTypeToString(CompressionType type);
|
|
|
6338
6214
|
|
|
6339
6215
|
} // namespace duckdb
|
|
6340
6216
|
|
|
6217
|
+
//===----------------------------------------------------------------------===//
|
|
6218
|
+
// DuckDB
|
|
6219
|
+
//
|
|
6220
|
+
// duckdb/catalog/catalog_entry/table_column_type.hpp
|
|
6221
|
+
//
|
|
6222
|
+
//
|
|
6223
|
+
//===----------------------------------------------------------------------===//
|
|
6224
|
+
|
|
6225
|
+
|
|
6226
|
+
|
|
6227
|
+
|
|
6228
|
+
|
|
6229
|
+
namespace duckdb {
|
|
6230
|
+
|
|
6231
|
+
enum class TableColumnType : uint8_t { STANDARD = 0, GENERATED = 1 };
|
|
6232
|
+
|
|
6233
|
+
} // namespace duckdb
|
|
6234
|
+
|
|
6235
|
+
|
|
6341
6236
|
|
|
6342
6237
|
namespace duckdb {
|
|
6343
6238
|
|
|
6239
|
+
struct RenameColumnInfo;
|
|
6240
|
+
struct RenameTableInfo;
|
|
6241
|
+
|
|
6242
|
+
class ColumnDefinition;
|
|
6243
|
+
|
|
6344
6244
|
//! A column of a table.
|
|
6345
6245
|
class ColumnDefinition {
|
|
6346
6246
|
public:
|
|
6347
6247
|
DUCKDB_API ColumnDefinition(string name, LogicalType type);
|
|
6348
|
-
DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression>
|
|
6248
|
+
DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression> expression,
|
|
6249
|
+
TableColumnType category);
|
|
6349
6250
|
|
|
6350
|
-
//! The name of the entry
|
|
6351
|
-
string name;
|
|
6352
|
-
//! The index of the column in the table
|
|
6353
|
-
idx_t oid;
|
|
6354
|
-
//! The type of the column
|
|
6355
|
-
LogicalType type;
|
|
6356
6251
|
//! The default value of the column (if any)
|
|
6357
6252
|
unique_ptr<ParsedExpression> default_value;
|
|
6358
|
-
//! Compression Type used for this column
|
|
6359
|
-
CompressionType compression_type = CompressionType::COMPRESSION_AUTO;
|
|
6360
6253
|
|
|
6361
6254
|
public:
|
|
6255
|
+
//! default_value
|
|
6256
|
+
const unique_ptr<ParsedExpression> &DefaultValue() const;
|
|
6257
|
+
void SetDefaultValue(unique_ptr<ParsedExpression> default_value);
|
|
6258
|
+
|
|
6259
|
+
//! type
|
|
6260
|
+
DUCKDB_API const LogicalType &Type() const;
|
|
6261
|
+
LogicalType &TypeMutable();
|
|
6262
|
+
void SetType(const LogicalType &type);
|
|
6263
|
+
|
|
6264
|
+
//! name
|
|
6265
|
+
DUCKDB_API const string &Name() const;
|
|
6266
|
+
void SetName(const string &name);
|
|
6267
|
+
|
|
6268
|
+
//! compression_type
|
|
6269
|
+
const duckdb::CompressionType &CompressionType() const;
|
|
6270
|
+
void SetCompressionType(duckdb::CompressionType compression_type);
|
|
6271
|
+
|
|
6272
|
+
//! storage_oid
|
|
6273
|
+
const storage_t &StorageOid() const;
|
|
6274
|
+
void SetStorageOid(storage_t storage_oid);
|
|
6275
|
+
|
|
6276
|
+
//! oid
|
|
6277
|
+
const column_t &Oid() const;
|
|
6278
|
+
void SetOid(column_t oid);
|
|
6279
|
+
|
|
6280
|
+
//! category
|
|
6281
|
+
const TableColumnType &Category() const;
|
|
6282
|
+
//! Whether this column is a Generated Column
|
|
6283
|
+
bool Generated() const;
|
|
6362
6284
|
DUCKDB_API ColumnDefinition Copy() const;
|
|
6363
6285
|
|
|
6364
6286
|
DUCKDB_API void Serialize(Serializer &serializer) const;
|
|
6365
6287
|
DUCKDB_API static ColumnDefinition Deserialize(Deserializer &source);
|
|
6288
|
+
|
|
6289
|
+
//===--------------------------------------------------------------------===//
|
|
6290
|
+
// Generated Columns (VIRTUAL)
|
|
6291
|
+
//===--------------------------------------------------------------------===//
|
|
6292
|
+
|
|
6293
|
+
ParsedExpression &GeneratedExpressionMutable();
|
|
6294
|
+
const ParsedExpression &GeneratedExpression() const;
|
|
6295
|
+
void SetGeneratedExpression(unique_ptr<ParsedExpression> expression);
|
|
6296
|
+
void ChangeGeneratedExpressionType(const LogicalType &type);
|
|
6297
|
+
void GetListOfDependencies(vector<string> &dependencies) const;
|
|
6298
|
+
|
|
6299
|
+
private:
|
|
6300
|
+
private:
|
|
6301
|
+
//! The name of the entry
|
|
6302
|
+
string name;
|
|
6303
|
+
//! The type of the column
|
|
6304
|
+
LogicalType type;
|
|
6305
|
+
//! Compression Type used for this column
|
|
6306
|
+
duckdb::CompressionType compression_type = duckdb::CompressionType::COMPRESSION_AUTO;
|
|
6307
|
+
//! The index of the column in the storage of the table
|
|
6308
|
+
storage_t storage_oid;
|
|
6309
|
+
//! The index of the column in the table
|
|
6310
|
+
idx_t oid;
|
|
6311
|
+
//! The category of the column
|
|
6312
|
+
TableColumnType category = TableColumnType::STANDARD;
|
|
6313
|
+
//! Used by Generated Columns
|
|
6314
|
+
unique_ptr<ParsedExpression> generated_expression;
|
|
6366
6315
|
};
|
|
6367
6316
|
|
|
6368
6317
|
} // namespace duckdb
|
|
@@ -6390,14 +6339,19 @@ struct PragmaInfo;
|
|
|
6390
6339
|
struct FunctionData {
|
|
6391
6340
|
DUCKDB_API virtual ~FunctionData();
|
|
6392
6341
|
|
|
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);
|
|
6342
|
+
DUCKDB_API virtual unique_ptr<FunctionData> Copy() const = 0;
|
|
6343
|
+
DUCKDB_API virtual bool Equals(const FunctionData &other) const = 0;
|
|
6344
|
+
DUCKDB_API static bool Equals(const FunctionData *left, const FunctionData *right);
|
|
6396
6345
|
};
|
|
6397
6346
|
|
|
6398
6347
|
struct TableFunctionData : public FunctionData {
|
|
6399
6348
|
// used to pass on projections to table functions that support them. NB, can contain COLUMN_IDENTIFIER_ROW_ID
|
|
6400
6349
|
vector<idx_t> column_ids;
|
|
6350
|
+
|
|
6351
|
+
DUCKDB_API virtual ~TableFunctionData();
|
|
6352
|
+
|
|
6353
|
+
DUCKDB_API unique_ptr<FunctionData> Copy() const override;
|
|
6354
|
+
DUCKDB_API bool Equals(const FunctionData &other) const override;
|
|
6401
6355
|
};
|
|
6402
6356
|
|
|
6403
6357
|
struct FunctionParameters {
|
|
@@ -6427,11 +6381,14 @@ public:
|
|
|
6427
6381
|
//! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
|
|
6428
6382
|
//! returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6429
6383
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
|
|
6430
|
-
vector<LogicalType> &arguments, string &error);
|
|
6384
|
+
vector<LogicalType> &arguments, string &error, bool &cast_parameters);
|
|
6431
6385
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
|
|
6432
|
-
vector<unique_ptr<Expression>> &arguments, string &error
|
|
6386
|
+
vector<unique_ptr<Expression>> &arguments, string &error,
|
|
6387
|
+
bool &cast_parameters);
|
|
6433
6388
|
//! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
|
|
6434
6389
|
//! function, returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6390
|
+
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
6391
|
+
vector<LogicalType> &arguments, string &error, bool &cast_parameters);
|
|
6435
6392
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
6436
6393
|
vector<LogicalType> &arguments, string &error);
|
|
6437
6394
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
@@ -6477,10 +6434,6 @@ public:
|
|
|
6477
6434
|
public:
|
|
6478
6435
|
DUCKDB_API string ToString() override;
|
|
6479
6436
|
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
6437
|
};
|
|
6485
6438
|
|
|
6486
6439
|
class BaseScalarFunction : public SimpleFunction {
|
|
@@ -6502,7 +6455,8 @@ public:
|
|
|
6502
6455
|
DUCKDB_API hash_t Hash() const;
|
|
6503
6456
|
|
|
6504
6457
|
//! Cast a set of expressions to the arguments of this function
|
|
6505
|
-
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children
|
|
6458
|
+
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children,
|
|
6459
|
+
bool cast_parameter_expressions = true);
|
|
6506
6460
|
|
|
6507
6461
|
DUCKDB_API string ToString() override;
|
|
6508
6462
|
};
|
|
@@ -6574,6 +6528,7 @@ namespace duckdb {
|
|
|
6574
6528
|
class Expression;
|
|
6575
6529
|
class ExpressionExecutor;
|
|
6576
6530
|
struct ExpressionExecutorState;
|
|
6531
|
+
struct FunctionLocalState;
|
|
6577
6532
|
|
|
6578
6533
|
struct ExpressionState {
|
|
6579
6534
|
ExpressionState(const Expression &expr, ExpressionExecutorState &root);
|
|
@@ -6594,13 +6549,13 @@ public:
|
|
|
6594
6549
|
};
|
|
6595
6550
|
|
|
6596
6551
|
struct ExecuteFunctionState : public ExpressionState {
|
|
6597
|
-
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root)
|
|
6598
|
-
|
|
6552
|
+
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root);
|
|
6553
|
+
~ExecuteFunctionState();
|
|
6599
6554
|
|
|
6600
|
-
unique_ptr<
|
|
6555
|
+
unique_ptr<FunctionLocalState> local_state;
|
|
6601
6556
|
|
|
6602
6557
|
public:
|
|
6603
|
-
static
|
|
6558
|
+
static FunctionLocalState *GetFunctionState(ExpressionState &state) {
|
|
6604
6559
|
return ((ExecuteFunctionState &)state).local_state.get();
|
|
6605
6560
|
}
|
|
6606
6561
|
};
|
|
@@ -6651,6 +6606,151 @@ struct ExpressionExecutorState {
|
|
|
6651
6606
|
|
|
6652
6607
|
|
|
6653
6608
|
|
|
6609
|
+
//===----------------------------------------------------------------------===//
|
|
6610
|
+
// DuckDB
|
|
6611
|
+
//
|
|
6612
|
+
// duckdb/common/limits.hpp
|
|
6613
|
+
//
|
|
6614
|
+
//
|
|
6615
|
+
//===----------------------------------------------------------------------===//
|
|
6616
|
+
|
|
6617
|
+
|
|
6618
|
+
|
|
6619
|
+
|
|
6620
|
+
|
|
6621
|
+
namespace duckdb {
|
|
6622
|
+
|
|
6623
|
+
template <class T>
|
|
6624
|
+
struct NumericLimits {
|
|
6625
|
+
static T Minimum();
|
|
6626
|
+
static T Maximum();
|
|
6627
|
+
static bool IsSigned();
|
|
6628
|
+
static idx_t Digits();
|
|
6629
|
+
};
|
|
6630
|
+
|
|
6631
|
+
template <>
|
|
6632
|
+
struct NumericLimits<int8_t> {
|
|
6633
|
+
static int8_t Minimum();
|
|
6634
|
+
static int8_t Maximum();
|
|
6635
|
+
static bool IsSigned() {
|
|
6636
|
+
return true;
|
|
6637
|
+
}
|
|
6638
|
+
static idx_t Digits() {
|
|
6639
|
+
return 3;
|
|
6640
|
+
}
|
|
6641
|
+
};
|
|
6642
|
+
template <>
|
|
6643
|
+
struct NumericLimits<int16_t> {
|
|
6644
|
+
static int16_t Minimum();
|
|
6645
|
+
static int16_t Maximum();
|
|
6646
|
+
static bool IsSigned() {
|
|
6647
|
+
return true;
|
|
6648
|
+
}
|
|
6649
|
+
static idx_t Digits() {
|
|
6650
|
+
return 5;
|
|
6651
|
+
}
|
|
6652
|
+
};
|
|
6653
|
+
template <>
|
|
6654
|
+
struct NumericLimits<int32_t> {
|
|
6655
|
+
static int32_t Minimum();
|
|
6656
|
+
static int32_t Maximum();
|
|
6657
|
+
static bool IsSigned() {
|
|
6658
|
+
return true;
|
|
6659
|
+
}
|
|
6660
|
+
static idx_t Digits() {
|
|
6661
|
+
return 10;
|
|
6662
|
+
}
|
|
6663
|
+
};
|
|
6664
|
+
template <>
|
|
6665
|
+
struct NumericLimits<int64_t> {
|
|
6666
|
+
static int64_t Minimum();
|
|
6667
|
+
static int64_t Maximum();
|
|
6668
|
+
static bool IsSigned() {
|
|
6669
|
+
return true;
|
|
6670
|
+
}
|
|
6671
|
+
static idx_t Digits() {
|
|
6672
|
+
return 19;
|
|
6673
|
+
}
|
|
6674
|
+
};
|
|
6675
|
+
template <>
|
|
6676
|
+
struct NumericLimits<hugeint_t> {
|
|
6677
|
+
static hugeint_t Minimum();
|
|
6678
|
+
static hugeint_t Maximum();
|
|
6679
|
+
static bool IsSigned() {
|
|
6680
|
+
return true;
|
|
6681
|
+
}
|
|
6682
|
+
static idx_t Digits() {
|
|
6683
|
+
return 39;
|
|
6684
|
+
}
|
|
6685
|
+
};
|
|
6686
|
+
template <>
|
|
6687
|
+
struct NumericLimits<uint8_t> {
|
|
6688
|
+
static uint8_t Minimum();
|
|
6689
|
+
static uint8_t Maximum();
|
|
6690
|
+
static bool IsSigned() {
|
|
6691
|
+
return false;
|
|
6692
|
+
}
|
|
6693
|
+
static idx_t Digits() {
|
|
6694
|
+
return 3;
|
|
6695
|
+
}
|
|
6696
|
+
};
|
|
6697
|
+
template <>
|
|
6698
|
+
struct NumericLimits<uint16_t> {
|
|
6699
|
+
static uint16_t Minimum();
|
|
6700
|
+
static uint16_t Maximum();
|
|
6701
|
+
static bool IsSigned() {
|
|
6702
|
+
return false;
|
|
6703
|
+
}
|
|
6704
|
+
static idx_t Digits() {
|
|
6705
|
+
return 5;
|
|
6706
|
+
}
|
|
6707
|
+
};
|
|
6708
|
+
template <>
|
|
6709
|
+
struct NumericLimits<uint32_t> {
|
|
6710
|
+
static uint32_t Minimum();
|
|
6711
|
+
static uint32_t Maximum();
|
|
6712
|
+
static bool IsSigned() {
|
|
6713
|
+
return false;
|
|
6714
|
+
}
|
|
6715
|
+
static idx_t Digits() {
|
|
6716
|
+
return 10;
|
|
6717
|
+
}
|
|
6718
|
+
};
|
|
6719
|
+
template <>
|
|
6720
|
+
struct NumericLimits<uint64_t> {
|
|
6721
|
+
static uint64_t Minimum();
|
|
6722
|
+
static uint64_t Maximum();
|
|
6723
|
+
static bool IsSigned() {
|
|
6724
|
+
return false;
|
|
6725
|
+
}
|
|
6726
|
+
static idx_t Digits() {
|
|
6727
|
+
return 20;
|
|
6728
|
+
}
|
|
6729
|
+
};
|
|
6730
|
+
template <>
|
|
6731
|
+
struct NumericLimits<float> {
|
|
6732
|
+
static float Minimum();
|
|
6733
|
+
static float Maximum();
|
|
6734
|
+
static bool IsSigned() {
|
|
6735
|
+
return true;
|
|
6736
|
+
}
|
|
6737
|
+
static idx_t Digits() {
|
|
6738
|
+
return 127;
|
|
6739
|
+
}
|
|
6740
|
+
};
|
|
6741
|
+
template <>
|
|
6742
|
+
struct NumericLimits<double> {
|
|
6743
|
+
static double Minimum();
|
|
6744
|
+
static double Maximum();
|
|
6745
|
+
static bool IsSigned() {
|
|
6746
|
+
return true;
|
|
6747
|
+
}
|
|
6748
|
+
static idx_t Digits() {
|
|
6749
|
+
return 250;
|
|
6750
|
+
}
|
|
6751
|
+
};
|
|
6752
|
+
|
|
6753
|
+
} // namespace duckdb
|
|
6654
6754
|
|
|
6655
6755
|
|
|
6656
6756
|
|
|
@@ -7196,32 +7296,46 @@ class FieldWriter;
|
|
|
7196
7296
|
class FieldReader;
|
|
7197
7297
|
class Vector;
|
|
7198
7298
|
class ValidityStatistics;
|
|
7299
|
+
class DistinctStatistics;
|
|
7300
|
+
struct VectorData;
|
|
7301
|
+
|
|
7302
|
+
enum StatisticsType { LOCAL_STATS = 0, GLOBAL_STATS = 1 };
|
|
7199
7303
|
|
|
7200
7304
|
class BaseStatistics {
|
|
7201
7305
|
public:
|
|
7202
|
-
|
|
7306
|
+
BaseStatistics(LogicalType type, StatisticsType stats_type);
|
|
7203
7307
|
virtual ~BaseStatistics();
|
|
7204
7308
|
|
|
7205
7309
|
//! The type of the logical segment
|
|
7206
7310
|
LogicalType type;
|
|
7207
7311
|
//! The validity stats of the column (if any)
|
|
7208
7312
|
unique_ptr<BaseStatistics> validity_stats;
|
|
7313
|
+
//! The approximate count distinct stats of the column (if any)
|
|
7314
|
+
unique_ptr<BaseStatistics> distinct_stats;
|
|
7315
|
+
//! Whether these are 'global' stats, i.e., over a whole table, or just over a segment
|
|
7316
|
+
//! Some statistics are more expensive to keep, therefore we only keep them globally
|
|
7317
|
+
StatisticsType stats_type;
|
|
7209
7318
|
|
|
7210
7319
|
public:
|
|
7320
|
+
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type, StatisticsType stats_type);
|
|
7321
|
+
|
|
7211
7322
|
bool CanHaveNull() const;
|
|
7212
7323
|
bool CanHaveNoNull() const;
|
|
7213
7324
|
|
|
7325
|
+
void UpdateDistinctStatistics(Vector &v, idx_t count);
|
|
7326
|
+
|
|
7214
7327
|
virtual bool IsConstant() const {
|
|
7215
7328
|
return false;
|
|
7216
7329
|
}
|
|
7217
7330
|
|
|
7218
|
-
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type);
|
|
7219
|
-
|
|
7220
7331
|
virtual void Merge(const BaseStatistics &other);
|
|
7221
7332
|
|
|
7222
7333
|
virtual unique_ptr<BaseStatistics> Copy() const;
|
|
7223
|
-
void
|
|
7334
|
+
void CopyBase(const BaseStatistics &orig);
|
|
7335
|
+
|
|
7336
|
+
virtual void Serialize(Serializer &serializer) const;
|
|
7224
7337
|
virtual void Serialize(FieldWriter &writer) const;
|
|
7338
|
+
|
|
7225
7339
|
static unique_ptr<BaseStatistics> Deserialize(Deserializer &source, LogicalType type);
|
|
7226
7340
|
|
|
7227
7341
|
//! Verify that a vector does not violate the statistics
|
|
@@ -7229,12 +7343,20 @@ public:
|
|
|
7229
7343
|
void Verify(Vector &vector, idx_t count) const;
|
|
7230
7344
|
|
|
7231
7345
|
virtual string ToString() const;
|
|
7346
|
+
|
|
7347
|
+
protected:
|
|
7348
|
+
void InitializeBase();
|
|
7232
7349
|
};
|
|
7233
7350
|
|
|
7234
7351
|
} // namespace duckdb
|
|
7235
7352
|
|
|
7236
7353
|
|
|
7237
7354
|
namespace duckdb {
|
|
7355
|
+
|
|
7356
|
+
struct FunctionLocalState {
|
|
7357
|
+
DUCKDB_API virtual ~FunctionLocalState();
|
|
7358
|
+
};
|
|
7359
|
+
|
|
7238
7360
|
class BoundFunctionExpression;
|
|
7239
7361
|
class ScalarFunctionCatalogEntry;
|
|
7240
7362
|
|
|
@@ -7243,7 +7365,8 @@ typedef std::function<void(DataChunk &, ExpressionState &, Vector &)> scalar_fun
|
|
|
7243
7365
|
//! Binds the scalar function and creates the function data
|
|
7244
7366
|
typedef unique_ptr<FunctionData> (*bind_scalar_function_t)(ClientContext &context, ScalarFunction &bound_function,
|
|
7245
7367
|
vector<unique_ptr<Expression>> &arguments);
|
|
7246
|
-
typedef unique_ptr<
|
|
7368
|
+
typedef unique_ptr<FunctionLocalState> (*init_local_state_t)(const BoundFunctionExpression &expr,
|
|
7369
|
+
FunctionData *bind_data);
|
|
7247
7370
|
typedef unique_ptr<BaseStatistics> (*function_statistics_t)(ClientContext &context, BoundFunctionExpression &expr,
|
|
7248
7371
|
FunctionData *bind_data,
|
|
7249
7372
|
vector<unique_ptr<BaseStatistics>> &child_stats);
|
|
@@ -7285,10 +7408,9 @@ public:
|
|
|
7285
7408
|
vector<unique_ptr<Expression>> children,
|
|
7286
7409
|
string &error, bool is_operator = false);
|
|
7287
7410
|
|
|
7288
|
-
DUCKDB_API static unique_ptr<BoundFunctionExpression>
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
bool is_operator = false);
|
|
7411
|
+
DUCKDB_API static unique_ptr<BoundFunctionExpression>
|
|
7412
|
+
BindScalarFunction(ClientContext &context, ScalarFunction bound_function, vector<unique_ptr<Expression>> children,
|
|
7413
|
+
bool is_operator = false, bool cast_parameters = true);
|
|
7292
7414
|
|
|
7293
7415
|
DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
|
|
7294
7416
|
DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
|
|
@@ -7716,13 +7838,13 @@ public:
|
|
|
7716
7838
|
}
|
|
7717
7839
|
|
|
7718
7840
|
template <class STATE_TYPE, class OP>
|
|
7719
|
-
static void Combine(Vector &source, Vector &target, idx_t count) {
|
|
7841
|
+
static void Combine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
7720
7842
|
D_ASSERT(source.GetType().id() == LogicalTypeId::POINTER && target.GetType().id() == LogicalTypeId::POINTER);
|
|
7721
7843
|
auto sdata = FlatVector::GetData<const STATE_TYPE *>(source);
|
|
7722
7844
|
auto tdata = FlatVector::GetData<STATE_TYPE *>(target);
|
|
7723
7845
|
|
|
7724
7846
|
for (idx_t i = 0; i < count; i++) {
|
|
7725
|
-
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i]);
|
|
7847
|
+
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i], bind_data);
|
|
7726
7848
|
}
|
|
7727
7849
|
}
|
|
7728
7850
|
|
|
@@ -7749,13 +7871,13 @@ public:
|
|
|
7749
7871
|
}
|
|
7750
7872
|
|
|
7751
7873
|
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
|
7752
|
-
static void UnaryWindow(Vector &input, FunctionData *bind_data, data_ptr_t state,
|
|
7753
|
-
const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
|
|
7874
|
+
static void UnaryWindow(Vector &input, const ValidityMask &ifilter, FunctionData *bind_data, data_ptr_t state,
|
|
7875
|
+
const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
|
|
7754
7876
|
|
|
7755
7877
|
auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
|
|
7756
7878
|
const auto &ivalid = FlatVector::Validity(input);
|
|
7757
|
-
OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ivalid, bind_data, (STATE *)state, frame,
|
|
7758
|
-
result, rid, bias);
|
|
7879
|
+
OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ifilter, ivalid, bind_data, (STATE *)state, frame,
|
|
7880
|
+
prev, result, rid, bias);
|
|
7759
7881
|
}
|
|
7760
7882
|
|
|
7761
7883
|
template <class STATE_TYPE, class OP>
|
|
@@ -8271,8 +8393,9 @@ public:
|
|
|
8271
8393
|
mutex write_lock;
|
|
8272
8394
|
|
|
8273
8395
|
public:
|
|
8274
|
-
//! Get the
|
|
8396
|
+
//! Get the Catalog from the ClientContext
|
|
8275
8397
|
DUCKDB_API static Catalog &GetCatalog(ClientContext &context);
|
|
8398
|
+
//! Get the Catalog from the DatabaseInstance
|
|
8276
8399
|
DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db);
|
|
8277
8400
|
|
|
8278
8401
|
DUCKDB_API DependencyManager &GetDependencyManager() {
|
|
@@ -8351,6 +8474,9 @@ public:
|
|
|
8351
8474
|
//! Gets the "schema.name" entry without a specified type, if entry does not exist an exception is thrown
|
|
8352
8475
|
DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &schema, const string &name);
|
|
8353
8476
|
|
|
8477
|
+
//! Fetches a logical type from the catalog
|
|
8478
|
+
DUCKDB_API LogicalType GetType(ClientContext &context, const string &schema, const string &name);
|
|
8479
|
+
|
|
8354
8480
|
template <class T>
|
|
8355
8481
|
T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
|
|
8356
8482
|
QueryErrorContext error_context = QueryErrorContext());
|
|
@@ -8409,6 +8535,9 @@ DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &conte
|
|
|
8409
8535
|
template <>
|
|
8410
8536
|
DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
8411
8537
|
bool if_exists, QueryErrorContext error_context);
|
|
8538
|
+
template <>
|
|
8539
|
+
DUCKDB_API TypeCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
8540
|
+
bool if_exists, QueryErrorContext error_context);
|
|
8412
8541
|
|
|
8413
8542
|
} // namespace duckdb
|
|
8414
8543
|
|
|
@@ -8953,8 +9082,8 @@ typedef void (*aggregate_initialize_t)(data_ptr_t state);
|
|
|
8953
9082
|
//! The type used for updating hashed aggregate functions
|
|
8954
9083
|
typedef void (*aggregate_update_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, Vector &state,
|
|
8955
9084
|
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);
|
|
9085
|
+
//! The type used for combining hashed aggregate states
|
|
9086
|
+
typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count);
|
|
8958
9087
|
//! The type used for finalizing hashed aggregate function payloads
|
|
8959
9088
|
typedef void (*aggregate_finalize_t)(Vector &state, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset);
|
|
8960
9089
|
//! The type used for propagating statistics in aggregate functions (optional)
|
|
@@ -8974,9 +9103,9 @@ typedef void (*aggregate_simple_update_t)(Vector inputs[], FunctionData *bind_da
|
|
|
8974
9103
|
|
|
8975
9104
|
//! The type used for updating complex windowed aggregate functions (optional)
|
|
8976
9105
|
typedef std::pair<idx_t, idx_t> FrameBounds;
|
|
8977
|
-
typedef void (*aggregate_window_t)(Vector inputs[],
|
|
8978
|
-
|
|
8979
|
-
idx_t bias);
|
|
9106
|
+
typedef void (*aggregate_window_t)(Vector inputs[], const ValidityMask &filter_mask, FunctionData *bind_data,
|
|
9107
|
+
idx_t input_count, data_ptr_t state, const FrameBounds &frame,
|
|
9108
|
+
const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias);
|
|
8980
9109
|
|
|
8981
9110
|
class AggregateFunction : public BaseScalarFunction {
|
|
8982
9111
|
public:
|
|
@@ -9058,7 +9187,8 @@ public:
|
|
|
9058
9187
|
DUCKDB_API static unique_ptr<BoundAggregateExpression>
|
|
9059
9188
|
BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
|
|
9060
9189
|
vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
|
|
9061
|
-
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr
|
|
9190
|
+
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr,
|
|
9191
|
+
bool cast_parameters = true);
|
|
9062
9192
|
|
|
9063
9193
|
DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
|
|
9064
9194
|
vector<unique_ptr<Expression>> &children,
|
|
@@ -9142,11 +9272,12 @@ public:
|
|
|
9142
9272
|
}
|
|
9143
9273
|
|
|
9144
9274
|
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
|
9145
|
-
static void UnaryWindow(Vector inputs[],
|
|
9146
|
-
const FrameBounds &frame, const FrameBounds &prev,
|
|
9275
|
+
static void UnaryWindow(Vector inputs[], const ValidityMask &filter_mask, FunctionData *bind_data,
|
|
9276
|
+
idx_t input_count, data_ptr_t state, const FrameBounds &frame, const FrameBounds &prev,
|
|
9277
|
+
Vector &result, idx_t rid, idx_t bias) {
|
|
9147
9278
|
D_ASSERT(input_count == 1);
|
|
9148
|
-
AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], bind_data, state,
|
|
9149
|
-
result, rid, bias);
|
|
9279
|
+
AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], filter_mask, bind_data, state,
|
|
9280
|
+
frame, prev, result, rid, bias);
|
|
9150
9281
|
}
|
|
9151
9282
|
|
|
9152
9283
|
template <class STATE, class A_TYPE, class B_TYPE, class OP>
|
|
@@ -9164,8 +9295,8 @@ public:
|
|
|
9164
9295
|
}
|
|
9165
9296
|
|
|
9166
9297
|
template <class STATE, class OP>
|
|
9167
|
-
static void StateCombine(Vector &source, Vector &target, idx_t count) {
|
|
9168
|
-
AggregateExecutor::Combine<STATE, OP>(source, target, count);
|
|
9298
|
+
static void StateCombine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
9299
|
+
AggregateExecutor::Combine<STATE, OP>(source, target, bind_data, count);
|
|
9169
9300
|
}
|
|
9170
9301
|
|
|
9171
9302
|
template <class STATE, class RESULT_TYPE, class OP>
|
|
@@ -9623,11 +9754,8 @@ public:
|
|
|
9623
9754
|
//! Copy a single cell to a target vector
|
|
9624
9755
|
DUCKDB_API void CopyCell(idx_t column, idx_t index, Vector &target, idx_t target_offset);
|
|
9625
9756
|
|
|
9626
|
-
DUCKDB_API string ToString() const
|
|
9627
|
-
|
|
9628
|
-
: "ChunkCollection [ " + std::to_string(count) + " ]: \n" + chunks[0]->ToString();
|
|
9629
|
-
}
|
|
9630
|
-
DUCKDB_API void Print();
|
|
9757
|
+
DUCKDB_API string ToString() const;
|
|
9758
|
+
DUCKDB_API void Print() const;
|
|
9631
9759
|
|
|
9632
9760
|
//! Gets a reference to the chunk at the given index
|
|
9633
9761
|
DUCKDB_API DataChunk &GetChunkForRow(idx_t row_index) {
|
|
@@ -9748,7 +9876,32 @@ enum class StatementType : uint8_t {
|
|
|
9748
9876
|
};
|
|
9749
9877
|
|
|
9750
9878
|
string StatementTypeToString(StatementType type);
|
|
9751
|
-
|
|
9879
|
+
|
|
9880
|
+
enum class StatementReturnType : uint8_t {
|
|
9881
|
+
QUERY_RESULT, // the statement returns a query result (e.g. for display to the user)
|
|
9882
|
+
CHANGED_ROWS, // the statement returns a single row containing the number of changed rows (e.g. an insert stmt)
|
|
9883
|
+
NOTHING // the statement returns nothing
|
|
9884
|
+
};
|
|
9885
|
+
|
|
9886
|
+
//! A struct containing various properties of a SQL statement
|
|
9887
|
+
struct StatementProperties {
|
|
9888
|
+
StatementProperties()
|
|
9889
|
+
: read_only(true), requires_valid_transaction(true), allow_stream_result(false), bound_all_parameters(true),
|
|
9890
|
+
return_type(StatementReturnType::QUERY_RESULT) {
|
|
9891
|
+
}
|
|
9892
|
+
|
|
9893
|
+
//! Whether or not the statement is a read-only statement, or whether it can result in changes to the database
|
|
9894
|
+
bool read_only;
|
|
9895
|
+
//! Whether or not the statement requires a valid transaction. Almost all statements require this, with the
|
|
9896
|
+
//! exception of
|
|
9897
|
+
bool requires_valid_transaction;
|
|
9898
|
+
//! Whether or not the result can be streamed to the client
|
|
9899
|
+
bool allow_stream_result;
|
|
9900
|
+
//! Whether or not all parameters have successfully had their types determined
|
|
9901
|
+
bool bound_all_parameters;
|
|
9902
|
+
//! What type of data the statement returns
|
|
9903
|
+
StatementReturnType return_type;
|
|
9904
|
+
};
|
|
9752
9905
|
|
|
9753
9906
|
} // namespace duckdb
|
|
9754
9907
|
|
|
@@ -9763,11 +9916,9 @@ enum class QueryResultType : uint8_t { MATERIALIZED_RESULT, STREAM_RESULT, PENDI
|
|
|
9763
9916
|
|
|
9764
9917
|
class BaseQueryResult {
|
|
9765
9918
|
public:
|
|
9766
|
-
//! Creates a successful empty query result
|
|
9767
|
-
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type);
|
|
9768
9919
|
//! Creates a successful query result with the specified names and types
|
|
9769
|
-
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type,
|
|
9770
|
-
vector<string> names);
|
|
9920
|
+
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
9921
|
+
vector<LogicalType> types, vector<string> names);
|
|
9771
9922
|
//! Creates an unsuccessful query result with error condition
|
|
9772
9923
|
DUCKDB_API BaseQueryResult(QueryResultType type, string error);
|
|
9773
9924
|
DUCKDB_API virtual ~BaseQueryResult();
|
|
@@ -9776,6 +9927,8 @@ public:
|
|
|
9776
9927
|
QueryResultType type;
|
|
9777
9928
|
//! The type of the statement that created this result
|
|
9778
9929
|
StatementType statement_type;
|
|
9930
|
+
//! Properties of the statement
|
|
9931
|
+
StatementProperties properties;
|
|
9779
9932
|
//! The SQL types of the result
|
|
9780
9933
|
vector<LogicalType> types;
|
|
9781
9934
|
//! The names of the result
|
|
@@ -9796,11 +9949,9 @@ public:
|
|
|
9796
9949
|
//! incrementally fetch data from the database.
|
|
9797
9950
|
class QueryResult : public BaseQueryResult {
|
|
9798
9951
|
public:
|
|
9799
|
-
//! Creates a successful empty query result
|
|
9800
|
-
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type);
|
|
9801
9952
|
//! Creates a successful query result with the specified names and types
|
|
9802
|
-
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type,
|
|
9803
|
-
vector<string> names);
|
|
9953
|
+
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
9954
|
+
vector<LogicalType> types, vector<string> names);
|
|
9804
9955
|
//! Creates an unsuccessful query result with error condition
|
|
9805
9956
|
DUCKDB_API QueryResult(QueryResultType type, string error);
|
|
9806
9957
|
DUCKDB_API virtual ~QueryResult() override;
|
|
@@ -9836,7 +9987,10 @@ public:
|
|
|
9836
9987
|
}
|
|
9837
9988
|
}
|
|
9838
9989
|
|
|
9839
|
-
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names
|
|
9990
|
+
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names,
|
|
9991
|
+
string &config_timezone);
|
|
9992
|
+
|
|
9993
|
+
static string GetConfigTimezone(QueryResult &query_result);
|
|
9840
9994
|
|
|
9841
9995
|
private:
|
|
9842
9996
|
//! The current chunk used by the iterator
|
|
@@ -9914,17 +10068,23 @@ private:
|
|
|
9914
10068
|
|
|
9915
10069
|
namespace duckdb {
|
|
9916
10070
|
|
|
10071
|
+
class ClientContext;
|
|
10072
|
+
|
|
9917
10073
|
class MaterializedQueryResult : public QueryResult {
|
|
9918
10074
|
public:
|
|
9919
|
-
|
|
9920
|
-
DUCKDB_API explicit MaterializedQueryResult(StatementType statement_type);
|
|
10075
|
+
friend class ClientContext;
|
|
9921
10076
|
//! Creates a successful query result with the specified names and types
|
|
9922
|
-
DUCKDB_API MaterializedQueryResult(StatementType statement_type,
|
|
10077
|
+
DUCKDB_API MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
|
|
10078
|
+
vector<LogicalType> types, vector<string> names,
|
|
10079
|
+
const shared_ptr<ClientContext> &context);
|
|
9923
10080
|
//! Creates an unsuccessful query result with error condition
|
|
9924
10081
|
DUCKDB_API explicit MaterializedQueryResult(string error);
|
|
9925
10082
|
|
|
9926
10083
|
ChunkCollection collection;
|
|
9927
10084
|
|
|
10085
|
+
//! The client context this MaterializedQueryResult belongs to
|
|
10086
|
+
std::weak_ptr<ClientContext> context;
|
|
10087
|
+
|
|
9928
10088
|
public:
|
|
9929
10089
|
//! Fetches a DataChunk from the query result.
|
|
9930
10090
|
//! This will consume the result (i.e. the chunks are taken directly from the ChunkCollection).
|
|
@@ -10029,6 +10189,7 @@ enum class PhysicalOperatorType : uint8_t {
|
|
|
10029
10189
|
INVALID,
|
|
10030
10190
|
ORDER_BY,
|
|
10031
10191
|
LIMIT,
|
|
10192
|
+
STREAMING_LIMIT,
|
|
10032
10193
|
LIMIT_PERCENT,
|
|
10033
10194
|
TOP_N,
|
|
10034
10195
|
WINDOW,
|
|
@@ -10103,7 +10264,8 @@ enum class PhysicalOperatorType : uint8_t {
|
|
|
10103
10264
|
EXPORT,
|
|
10104
10265
|
SET,
|
|
10105
10266
|
LOAD,
|
|
10106
|
-
INOUT_FUNCTION
|
|
10267
|
+
INOUT_FUNCTION,
|
|
10268
|
+
RESULT_COLLECTOR
|
|
10107
10269
|
};
|
|
10108
10270
|
|
|
10109
10271
|
string PhysicalOperatorToString(PhysicalOperatorType type);
|
|
@@ -10182,8 +10344,10 @@ enum class SinkFinalizeType : uint8_t { READY, NO_OUTPUT_POSSIBLE };
|
|
|
10182
10344
|
|
|
10183
10345
|
namespace duckdb {
|
|
10184
10346
|
class Event;
|
|
10347
|
+
class Executor;
|
|
10185
10348
|
class PhysicalOperator;
|
|
10186
10349
|
class Pipeline;
|
|
10350
|
+
class PipelineBuildState;
|
|
10187
10351
|
|
|
10188
10352
|
// LCOV_EXCL_START
|
|
10189
10353
|
class OperatorState {
|
|
@@ -10215,6 +10379,13 @@ class LocalSinkState {
|
|
|
10215
10379
|
public:
|
|
10216
10380
|
virtual ~LocalSinkState() {
|
|
10217
10381
|
}
|
|
10382
|
+
|
|
10383
|
+
//! The current batch index
|
|
10384
|
+
//! This is only set in case RequiresBatchIndex() is true, and the source has support for it (SupportsBatchIndex())
|
|
10385
|
+
//! Otherwise this is left on INVALID_INDEX
|
|
10386
|
+
//! The batch index is a globally unique, increasing index that should be used to maintain insertion order
|
|
10387
|
+
//! //! in conjunction with parallelism
|
|
10388
|
+
idx_t batch_index = DConstants::INVALID_INDEX;
|
|
10218
10389
|
};
|
|
10219
10390
|
|
|
10220
10391
|
class GlobalSourceState {
|
|
@@ -10232,6 +10403,7 @@ public:
|
|
|
10232
10403
|
virtual ~LocalSourceState() {
|
|
10233
10404
|
}
|
|
10234
10405
|
};
|
|
10406
|
+
|
|
10235
10407
|
// LCOV_EXCL_STOP
|
|
10236
10408
|
|
|
10237
10409
|
//! PhysicalOperator is the base class of the physical operators present in the
|
|
@@ -10264,6 +10436,7 @@ public:
|
|
|
10264
10436
|
}
|
|
10265
10437
|
virtual string ToString() const;
|
|
10266
10438
|
void Print() const;
|
|
10439
|
+
virtual vector<PhysicalOperator *> GetChildren() const;
|
|
10267
10440
|
|
|
10268
10441
|
//! Return a vector of the types that will be returned by this operator
|
|
10269
10442
|
const vector<LogicalType> &GetTypes() const {
|
|
@@ -10274,6 +10447,14 @@ public:
|
|
|
10274
10447
|
return false;
|
|
10275
10448
|
}
|
|
10276
10449
|
|
|
10450
|
+
virtual void Verify();
|
|
10451
|
+
|
|
10452
|
+
//! Whether or not the operator depends on the order of the input chunks
|
|
10453
|
+
//! If this is set to true, we cannot do things like caching intermediate vectors
|
|
10454
|
+
virtual bool IsOrderDependent() const {
|
|
10455
|
+
return false;
|
|
10456
|
+
}
|
|
10457
|
+
|
|
10277
10458
|
public:
|
|
10278
10459
|
// Operator interface
|
|
10279
10460
|
virtual unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const;
|
|
@@ -10296,6 +10477,8 @@ public:
|
|
|
10296
10477
|
virtual unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const;
|
|
10297
10478
|
virtual void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
10298
10479
|
LocalSourceState &lstate) const;
|
|
10480
|
+
virtual idx_t GetBatchIndex(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
10481
|
+
LocalSourceState &lstate) const;
|
|
10299
10482
|
|
|
10300
10483
|
virtual bool IsSource() const {
|
|
10301
10484
|
return false;
|
|
@@ -10305,6 +10488,13 @@ public:
|
|
|
10305
10488
|
return false;
|
|
10306
10489
|
}
|
|
10307
10490
|
|
|
10491
|
+
virtual bool SupportsBatchIndex() const {
|
|
10492
|
+
return false;
|
|
10493
|
+
}
|
|
10494
|
+
|
|
10495
|
+
//! Returns the current progress percentage, or a negative value if progress bars are not supported
|
|
10496
|
+
virtual double GetProgress(ClientContext &context, GlobalSourceState &gstate) const;
|
|
10497
|
+
|
|
10308
10498
|
public:
|
|
10309
10499
|
// Sink interface
|
|
10310
10500
|
|
|
@@ -10333,9 +10523,19 @@ public:
|
|
|
10333
10523
|
return false;
|
|
10334
10524
|
}
|
|
10335
10525
|
|
|
10336
|
-
virtual bool
|
|
10526
|
+
virtual bool RequiresBatchIndex() const {
|
|
10337
10527
|
return false;
|
|
10338
10528
|
}
|
|
10529
|
+
|
|
10530
|
+
public:
|
|
10531
|
+
// Pipeline construction
|
|
10532
|
+
virtual vector<const PhysicalOperator *> GetSources() const;
|
|
10533
|
+
bool AllSourcesSupportBatchIndex() const;
|
|
10534
|
+
|
|
10535
|
+
void AddPipeline(Executor &executor, shared_ptr<Pipeline> current, PipelineBuildState &state);
|
|
10536
|
+
virtual void BuildPipelines(Executor &executor, Pipeline ¤t, PipelineBuildState &state);
|
|
10537
|
+
void BuildChildPipeline(Executor &executor, Pipeline ¤t, PipelineBuildState &state,
|
|
10538
|
+
PhysicalOperator *pipeline_child);
|
|
10339
10539
|
};
|
|
10340
10540
|
|
|
10341
10541
|
} // namespace duckdb
|
|
@@ -10352,26 +10552,35 @@ public:
|
|
|
10352
10552
|
|
|
10353
10553
|
|
|
10354
10554
|
|
|
10555
|
+
|
|
10556
|
+
|
|
10355
10557
|
#include <functional>
|
|
10356
10558
|
|
|
10357
10559
|
namespace duckdb {
|
|
10560
|
+
|
|
10358
10561
|
class BaseStatistics;
|
|
10359
10562
|
class LogicalGet;
|
|
10360
|
-
struct ParallelState;
|
|
10361
10563
|
class TableFilterSet;
|
|
10362
10564
|
|
|
10363
|
-
struct FunctionOperatorData {
|
|
10364
|
-
DUCKDB_API virtual ~FunctionOperatorData();
|
|
10365
|
-
};
|
|
10366
|
-
|
|
10367
10565
|
struct TableFunctionInfo {
|
|
10368
10566
|
DUCKDB_API virtual ~TableFunctionInfo();
|
|
10369
10567
|
};
|
|
10370
10568
|
|
|
10371
|
-
struct
|
|
10372
|
-
|
|
10569
|
+
struct GlobalTableFunctionState {
|
|
10570
|
+
public:
|
|
10571
|
+
// value returned from MaxThreads when as many threads as possible should be used
|
|
10572
|
+
constexpr static const int64_t MAX_THREADS = 999999999;
|
|
10573
|
+
|
|
10574
|
+
public:
|
|
10575
|
+
DUCKDB_API virtual ~GlobalTableFunctionState();
|
|
10576
|
+
|
|
10577
|
+
DUCKDB_API virtual idx_t MaxThreads() const {
|
|
10578
|
+
return 1;
|
|
10579
|
+
}
|
|
10580
|
+
};
|
|
10373
10581
|
|
|
10374
|
-
|
|
10582
|
+
struct LocalTableFunctionState {
|
|
10583
|
+
DUCKDB_API virtual ~LocalTableFunctionState();
|
|
10375
10584
|
};
|
|
10376
10585
|
|
|
10377
10586
|
struct TableFunctionBindInput {
|
|
@@ -10389,35 +10598,46 @@ struct TableFunctionBindInput {
|
|
|
10389
10598
|
TableFunctionInfo *info;
|
|
10390
10599
|
};
|
|
10391
10600
|
|
|
10601
|
+
struct TableFunctionInitInput {
|
|
10602
|
+
TableFunctionInitInput(const FunctionData *bind_data_p, const vector<column_t> &column_ids_p,
|
|
10603
|
+
TableFilterSet *filters_p)
|
|
10604
|
+
: bind_data(bind_data_p), column_ids(column_ids_p), filters(filters_p) {
|
|
10605
|
+
}
|
|
10606
|
+
|
|
10607
|
+
const FunctionData *bind_data;
|
|
10608
|
+
const vector<column_t> &column_ids;
|
|
10609
|
+
TableFilterSet *filters;
|
|
10610
|
+
};
|
|
10611
|
+
|
|
10612
|
+
struct TableFunctionInput {
|
|
10613
|
+
TableFunctionInput(const FunctionData *bind_data_p, LocalTableFunctionState *local_state_p,
|
|
10614
|
+
GlobalTableFunctionState *global_state_p)
|
|
10615
|
+
: bind_data(bind_data_p), local_state(local_state_p), global_state(global_state_p) {
|
|
10616
|
+
}
|
|
10617
|
+
|
|
10618
|
+
const FunctionData *bind_data;
|
|
10619
|
+
LocalTableFunctionState *local_state;
|
|
10620
|
+
GlobalTableFunctionState *global_state;
|
|
10621
|
+
};
|
|
10622
|
+
|
|
10392
10623
|
typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, TableFunctionBindInput &input,
|
|
10393
10624
|
vector<LogicalType> &return_types, vector<string> &names);
|
|
10394
|
-
typedef unique_ptr<
|
|
10395
|
-
|
|
10396
|
-
|
|
10625
|
+
typedef unique_ptr<GlobalTableFunctionState> (*table_function_init_global_t)(ClientContext &context,
|
|
10626
|
+
TableFunctionInitInput &input);
|
|
10627
|
+
typedef unique_ptr<LocalTableFunctionState> (*table_function_init_local_t)(ClientContext &context,
|
|
10628
|
+
TableFunctionInitInput &input,
|
|
10629
|
+
GlobalTableFunctionState *global_state);
|
|
10397
10630
|
typedef unique_ptr<BaseStatistics> (*table_statistics_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10398
10631
|
column_t column_index);
|
|
10399
|
-
typedef void (*table_function_t)(ClientContext &context,
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
typedef
|
|
10407
|
-
|
|
10408
|
-
typedef idx_t (*table_function_max_threads_t)(ClientContext &context, const FunctionData *bind_data);
|
|
10409
|
-
typedef unique_ptr<ParallelState> (*table_function_init_parallel_state_t)(ClientContext &context,
|
|
10410
|
-
const FunctionData *bind_data,
|
|
10411
|
-
const vector<column_t> &column_ids,
|
|
10412
|
-
TableFilterCollection *filters);
|
|
10413
|
-
typedef unique_ptr<FunctionOperatorData> (*table_function_init_parallel_t)(ClientContext &context,
|
|
10414
|
-
const FunctionData *bind_data,
|
|
10415
|
-
ParallelState *state,
|
|
10416
|
-
const vector<column_t> &column_ids,
|
|
10417
|
-
TableFilterCollection *filters);
|
|
10418
|
-
typedef bool (*table_function_parallel_state_next_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10419
|
-
FunctionOperatorData *state, ParallelState *parallel_state);
|
|
10420
|
-
typedef double (*table_function_progress_t)(ClientContext &context, const FunctionData *bind_data);
|
|
10632
|
+
typedef void (*table_function_t)(ClientContext &context, TableFunctionInput &data, DataChunk &output);
|
|
10633
|
+
|
|
10634
|
+
typedef OperatorResultType (*table_in_out_function_t)(ClientContext &context, TableFunctionInput &data,
|
|
10635
|
+
DataChunk &input, DataChunk &output);
|
|
10636
|
+
typedef idx_t (*table_function_get_batch_index_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10637
|
+
LocalTableFunctionState *local_state,
|
|
10638
|
+
GlobalTableFunctionState *global_state);
|
|
10639
|
+
typedef double (*table_function_progress_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10640
|
+
const GlobalTableFunctionState *global_state);
|
|
10421
10641
|
typedef void (*table_function_dependency_t)(unordered_set<CatalogEntry *> &dependencies, const FunctionData *bind_data);
|
|
10422
10642
|
typedef unique_ptr<NodeStatistics> (*table_function_cardinality_t)(ClientContext &context,
|
|
10423
10643
|
const FunctionData *bind_data);
|
|
@@ -10430,46 +10650,33 @@ class TableFunction : public SimpleNamedParameterFunction {
|
|
|
10430
10650
|
public:
|
|
10431
10651
|
DUCKDB_API
|
|
10432
10652
|
TableFunction(string name, vector<LogicalType> arguments, table_function_t function,
|
|
10433
|
-
table_function_bind_t bind = nullptr,
|
|
10434
|
-
|
|
10435
|
-
table_function_dependency_t dependency = nullptr, table_function_cardinality_t cardinality = nullptr,
|
|
10436
|
-
table_function_pushdown_complex_filter_t pushdown_complex_filter = nullptr,
|
|
10437
|
-
table_function_to_string_t to_string = nullptr, table_function_max_threads_t max_threads = nullptr,
|
|
10438
|
-
table_function_init_parallel_state_t init_parallel_state = nullptr,
|
|
10439
|
-
table_function_parallel_t parallel_function = nullptr,
|
|
10440
|
-
table_function_init_parallel_t parallel_init = nullptr,
|
|
10441
|
-
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);
|
|
10653
|
+
table_function_bind_t bind = nullptr, table_function_init_global_t init_global = nullptr,
|
|
10654
|
+
table_function_init_local_t init_local = nullptr);
|
|
10443
10655
|
DUCKDB_API
|
|
10444
10656
|
TableFunction(const vector<LogicalType> &arguments, table_function_t function, table_function_bind_t bind = nullptr,
|
|
10445
|
-
|
|
10446
|
-
table_function_cleanup_t cleanup = nullptr, table_function_dependency_t dependency = nullptr,
|
|
10447
|
-
table_function_cardinality_t cardinality = nullptr,
|
|
10448
|
-
table_function_pushdown_complex_filter_t pushdown_complex_filter = nullptr,
|
|
10449
|
-
table_function_to_string_t to_string = nullptr, table_function_max_threads_t max_threads = nullptr,
|
|
10450
|
-
table_function_init_parallel_state_t init_parallel_state = nullptr,
|
|
10451
|
-
table_function_parallel_t parallel_function = nullptr,
|
|
10452
|
-
table_function_init_parallel_t parallel_init = nullptr,
|
|
10453
|
-
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);
|
|
10657
|
+
table_function_init_global_t init_global = nullptr, table_function_init_local_t init_local = nullptr);
|
|
10455
10658
|
DUCKDB_API TableFunction();
|
|
10456
10659
|
|
|
10457
10660
|
//! Bind function
|
|
10458
10661
|
//! This function is used for determining the return type of a table producing function and returning bind data
|
|
10459
10662
|
//! The returned FunctionData object should be constant and should not be changed during execution.
|
|
10460
10663
|
table_function_bind_t bind;
|
|
10461
|
-
//! (Optional) init function
|
|
10462
|
-
//! Initialize the operator state of the function.
|
|
10463
|
-
//! table function
|
|
10464
|
-
|
|
10664
|
+
//! (Optional) global init function
|
|
10665
|
+
//! Initialize the global operator state of the function.
|
|
10666
|
+
//! The global operator state is used to keep track of the progress in the table function and is shared between
|
|
10667
|
+
//! all threads working on the table function.
|
|
10668
|
+
table_function_init_global_t init_global;
|
|
10669
|
+
//! (Optional) local init function
|
|
10670
|
+
//! Initialize the local operator state of the function.
|
|
10671
|
+
//! The local operator state is used to keep track of the progress in the table function and is thread-local.
|
|
10672
|
+
table_function_init_local_t init_local;
|
|
10465
10673
|
//! The main function
|
|
10466
10674
|
table_function_t function;
|
|
10675
|
+
//! The table in-out function (if this is an in-out function)
|
|
10676
|
+
table_in_out_function_t in_out_function;
|
|
10467
10677
|
//! (Optional) statistics function
|
|
10468
10678
|
//! Returns the statistics of a specified column
|
|
10469
10679
|
table_statistics_t statistics;
|
|
10470
|
-
//! (Optional) cleanup function
|
|
10471
|
-
//! The final cleanup function, called after all data is exhausted from the main function
|
|
10472
|
-
table_function_cleanup_t cleanup;
|
|
10473
10680
|
//! (Optional) dependency function
|
|
10474
10681
|
//! Sets up which catalog entries this table function depend on
|
|
10475
10682
|
table_function_dependency_t dependency;
|
|
@@ -10481,19 +10688,10 @@ public:
|
|
|
10481
10688
|
table_function_pushdown_complex_filter_t pushdown_complex_filter;
|
|
10482
10689
|
//! (Optional) function for rendering the operator to a string in profiling output
|
|
10483
10690
|
table_function_to_string_t to_string;
|
|
10484
|
-
//! (Optional) function that returns the maximum amount of threads that can work on this task
|
|
10485
|
-
table_function_max_threads_t max_threads;
|
|
10486
|
-
//! (Optional) initialize the parallel scan state, called once in total.
|
|
10487
|
-
table_function_init_parallel_state_t init_parallel_state;
|
|
10488
|
-
//! (Optional) Parallel version of the main function
|
|
10489
|
-
table_function_parallel_t parallel_function;
|
|
10490
|
-
//! (Optional) initialize the parallel scan given the parallel state. Called once per task. Return nullptr if there
|
|
10491
|
-
//! is nothing left to scan.
|
|
10492
|
-
table_function_init_parallel_t parallel_init;
|
|
10493
|
-
//! (Optional) return the next chunk to process in the parallel scan, or return nullptr if there is none
|
|
10494
|
-
table_function_parallel_state_next_t parallel_state_next;
|
|
10495
10691
|
//! (Optional) return how much of the table we have scanned up to this point (% of the data)
|
|
10496
10692
|
table_function_progress_t table_scan_progress;
|
|
10693
|
+
//! (Optional) returns the current batch index of the current scan operator
|
|
10694
|
+
table_function_get_batch_index_t get_batch_index;
|
|
10497
10695
|
//! Whether or not the table function supports projection pushdown. If not supported a projection will be added
|
|
10498
10696
|
//! that filters out unused columns.
|
|
10499
10697
|
bool projection_pushdown;
|
|
@@ -10506,25 +10704,6 @@ public:
|
|
|
10506
10704
|
|
|
10507
10705
|
} // namespace duckdb
|
|
10508
10706
|
|
|
10509
|
-
//===----------------------------------------------------------------------===//
|
|
10510
|
-
// DuckDB
|
|
10511
|
-
//
|
|
10512
|
-
// duckdb/parallel/parallel_state.hpp
|
|
10513
|
-
//
|
|
10514
|
-
//
|
|
10515
|
-
//===----------------------------------------------------------------------===//
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
namespace duckdb {
|
|
10520
|
-
|
|
10521
|
-
struct ParallelState {
|
|
10522
|
-
virtual ~ParallelState() {
|
|
10523
|
-
}
|
|
10524
|
-
};
|
|
10525
|
-
|
|
10526
|
-
} // namespace duckdb
|
|
10527
|
-
|
|
10528
10707
|
//===----------------------------------------------------------------------===//
|
|
10529
10708
|
// DuckDB
|
|
10530
10709
|
//
|
|
@@ -10611,11 +10790,11 @@ struct ProducerToken {
|
|
|
10611
10790
|
|
|
10612
10791
|
//! The TaskScheduler is responsible for managing tasks and threads
|
|
10613
10792
|
class TaskScheduler {
|
|
10614
|
-
// timeout for semaphore wait, default
|
|
10615
|
-
constexpr static int64_t TASK_TIMEOUT_USECS =
|
|
10793
|
+
// timeout for semaphore wait, default 5ms
|
|
10794
|
+
constexpr static int64_t TASK_TIMEOUT_USECS = 5000;
|
|
10616
10795
|
|
|
10617
10796
|
public:
|
|
10618
|
-
TaskScheduler();
|
|
10797
|
+
TaskScheduler(DatabaseInstance &db);
|
|
10619
10798
|
~TaskScheduler();
|
|
10620
10799
|
|
|
10621
10800
|
static TaskScheduler &GetScheduler(ClientContext &context);
|
|
@@ -10628,6 +10807,8 @@ public:
|
|
|
10628
10807
|
bool GetTaskFromProducer(ProducerToken &token, unique_ptr<Task> &task);
|
|
10629
10808
|
//! Run tasks forever until "marker" is set to false, "marker" must remain valid until the thread is joined
|
|
10630
10809
|
void ExecuteForever(atomic<bool> *marker);
|
|
10810
|
+
//! Run tasks until `max_tasks` have been completed, or until there are no more tasks available
|
|
10811
|
+
void ExecuteTasks(idx_t max_tasks);
|
|
10631
10812
|
|
|
10632
10813
|
//! Sets the amount of active threads executing tasks for the system; n-1 background threads will be launched.
|
|
10633
10814
|
//! The main thread will also be used for execution
|
|
@@ -10638,6 +10819,8 @@ public:
|
|
|
10638
10819
|
private:
|
|
10639
10820
|
void SetThreadsInternal(int32_t n);
|
|
10640
10821
|
|
|
10822
|
+
private:
|
|
10823
|
+
DatabaseInstance &db;
|
|
10641
10824
|
//! The task queue
|
|
10642
10825
|
unique_ptr<ConcurrentQueue> queue;
|
|
10643
10826
|
//! The active background threads of the task scheduler
|
|
@@ -10654,12 +10837,45 @@ namespace duckdb {
|
|
|
10654
10837
|
class Executor;
|
|
10655
10838
|
class Event;
|
|
10656
10839
|
|
|
10840
|
+
class PipelineBuildState {
|
|
10841
|
+
public:
|
|
10842
|
+
//! How much to increment batch indexes when multiple pipelines share the same source
|
|
10843
|
+
constexpr static idx_t BATCH_INCREMENT = 10000000000000;
|
|
10844
|
+
|
|
10845
|
+
public:
|
|
10846
|
+
//! The current recursive CTE node (if any)
|
|
10847
|
+
PhysicalOperator *recursive_cte = nullptr;
|
|
10848
|
+
|
|
10849
|
+
//! Duplicate eliminated join scan dependencies
|
|
10850
|
+
unordered_map<PhysicalOperator *, Pipeline *> delim_join_dependencies;
|
|
10851
|
+
|
|
10852
|
+
//! The number of pipelines that have each specific sink as their sink
|
|
10853
|
+
unordered_map<PhysicalOperator *, idx_t> sink_pipeline_count;
|
|
10854
|
+
|
|
10855
|
+
public:
|
|
10856
|
+
void SetPipelineSource(Pipeline &pipeline, PhysicalOperator *op);
|
|
10857
|
+
void SetPipelineSink(Pipeline &pipeline, PhysicalOperator *op);
|
|
10858
|
+
void SetPipelineOperators(Pipeline &pipeline, vector<PhysicalOperator *> operators);
|
|
10859
|
+
void AddPipelineOperator(Pipeline &pipeline, PhysicalOperator *op);
|
|
10860
|
+
void AddPipeline(Executor &executor, shared_ptr<Pipeline> pipeline);
|
|
10861
|
+
void AddChildPipeline(Executor &executor, Pipeline &pipeline);
|
|
10862
|
+
|
|
10863
|
+
unordered_map<Pipeline *, vector<shared_ptr<Pipeline>>> &GetUnionPipelines(Executor &executor);
|
|
10864
|
+
unordered_map<Pipeline *, vector<shared_ptr<Pipeline>>> &GetChildPipelines(Executor &executor);
|
|
10865
|
+
unordered_map<Pipeline *, vector<Pipeline *>> &GetChildDependencies(Executor &executor);
|
|
10866
|
+
|
|
10867
|
+
PhysicalOperator *GetPipelineSource(Pipeline &pipeline);
|
|
10868
|
+
PhysicalOperator *GetPipelineSink(Pipeline &pipeline);
|
|
10869
|
+
vector<PhysicalOperator *> GetPipelineOperators(Pipeline &pipeline);
|
|
10870
|
+
};
|
|
10871
|
+
|
|
10657
10872
|
//! The Pipeline class represents an execution pipeline
|
|
10658
10873
|
class Pipeline : public std::enable_shared_from_this<Pipeline> {
|
|
10659
10874
|
friend class Executor;
|
|
10660
10875
|
friend class PipelineExecutor;
|
|
10661
10876
|
friend class PipelineEvent;
|
|
10662
10877
|
friend class PipelineFinishEvent;
|
|
10878
|
+
friend class PipelineBuildState;
|
|
10663
10879
|
|
|
10664
10880
|
public:
|
|
10665
10881
|
explicit Pipeline(Executor &execution_context);
|
|
@@ -10683,7 +10899,7 @@ public:
|
|
|
10683
10899
|
void Print() const;
|
|
10684
10900
|
|
|
10685
10901
|
//! Returns query progress
|
|
10686
|
-
bool GetProgress(double ¤t_percentage);
|
|
10902
|
+
bool GetProgress(double ¤t_percentage, idx_t &estimated_cardinality);
|
|
10687
10903
|
|
|
10688
10904
|
//! Returns a list of all operators (including source and sink) involved in this pipeline
|
|
10689
10905
|
vector<PhysicalOperator *> GetOperators() const;
|
|
@@ -10692,6 +10908,9 @@ public:
|
|
|
10692
10908
|
return sink;
|
|
10693
10909
|
}
|
|
10694
10910
|
|
|
10911
|
+
//! Returns whether any of the operators in the pipeline care about preserving insertion order
|
|
10912
|
+
bool IsOrderDependent() const;
|
|
10913
|
+
|
|
10695
10914
|
private:
|
|
10696
10915
|
//! Whether or not the pipeline has been readied
|
|
10697
10916
|
bool ready;
|
|
@@ -10710,8 +10929,10 @@ private:
|
|
|
10710
10929
|
//! The dependencies of this pipeline
|
|
10711
10930
|
vector<weak_ptr<Pipeline>> dependencies;
|
|
10712
10931
|
|
|
10932
|
+
//! The base batch index of this pipeline
|
|
10933
|
+
idx_t base_batch_index = 0;
|
|
10934
|
+
|
|
10713
10935
|
private:
|
|
10714
|
-
bool GetProgressInternal(ClientContext &context, PhysicalOperator *op, double ¤t_percentage);
|
|
10715
10936
|
void ScheduleSequentialTask(shared_ptr<Event> &event);
|
|
10716
10937
|
bool LaunchScanTasks(shared_ptr<Event> &event, idx_t max_threads);
|
|
10717
10938
|
|
|
@@ -10758,6 +10979,7 @@ using event_map_t = unordered_map<const Pipeline *, PipelineEventStack>;
|
|
|
10758
10979
|
class Executor {
|
|
10759
10980
|
friend class Pipeline;
|
|
10760
10981
|
friend class PipelineTask;
|
|
10982
|
+
friend class PipelineBuildState;
|
|
10761
10983
|
|
|
10762
10984
|
public:
|
|
10763
10985
|
explicit Executor(ClientContext &context);
|
|
@@ -10769,7 +10991,7 @@ public:
|
|
|
10769
10991
|
static Executor &Get(ClientContext &context);
|
|
10770
10992
|
|
|
10771
10993
|
void Initialize(PhysicalOperator *physical_plan);
|
|
10772
|
-
void
|
|
10994
|
+
void Initialize(unique_ptr<PhysicalOperator> physical_plan);
|
|
10773
10995
|
|
|
10774
10996
|
void CancelTasks();
|
|
10775
10997
|
PendingExecutionResult ExecuteTask();
|
|
@@ -10807,7 +11029,14 @@ public:
|
|
|
10807
11029
|
|
|
10808
11030
|
void ReschedulePipelines(const vector<shared_ptr<Pipeline>> &pipelines, vector<shared_ptr<Event>> &events);
|
|
10809
11031
|
|
|
11032
|
+
//! Whether or not the root of the pipeline is a result collector object
|
|
11033
|
+
bool HasResultCollector();
|
|
11034
|
+
//! Returns the query result - can only be used if `HasResultCollector` returns true
|
|
11035
|
+
unique_ptr<QueryResult> GetResult();
|
|
11036
|
+
|
|
10810
11037
|
private:
|
|
11038
|
+
void InitializeInternal(PhysicalOperator *physical_plan);
|
|
11039
|
+
|
|
10811
11040
|
void ScheduleEvents();
|
|
10812
11041
|
void ScheduleEventsInternal(const vector<shared_ptr<Pipeline>> &pipelines,
|
|
10813
11042
|
unordered_map<Pipeline *, vector<shared_ptr<Pipeline>>> &child_pipelines,
|
|
@@ -10830,6 +11059,7 @@ private:
|
|
|
10830
11059
|
|
|
10831
11060
|
private:
|
|
10832
11061
|
PhysicalOperator *physical_plan;
|
|
11062
|
+
unique_ptr<PhysicalOperator> owned_plan;
|
|
10833
11063
|
|
|
10834
11064
|
mutex executor_lock;
|
|
10835
11065
|
//! The pipelines of the current query
|
|
@@ -10865,12 +11095,6 @@ private:
|
|
|
10865
11095
|
//! Dependencies of child pipelines
|
|
10866
11096
|
unordered_map<Pipeline *, vector<Pipeline *>> child_dependencies;
|
|
10867
11097
|
|
|
10868
|
-
//! Duplicate eliminated join scan dependencies
|
|
10869
|
-
unordered_map<PhysicalOperator *, Pipeline *> delim_join_dependencies;
|
|
10870
|
-
|
|
10871
|
-
//! Active recursive CTE node (if any)
|
|
10872
|
-
PhysicalOperator *recursive_cte;
|
|
10873
|
-
|
|
10874
11098
|
//! The last pending execution result (if any)
|
|
10875
11099
|
PendingExecutionResult execution_result;
|
|
10876
11100
|
//! The current task in process (if any)
|
|
@@ -10889,7 +11113,7 @@ class PendingQueryResult : public BaseQueryResult {
|
|
|
10889
11113
|
|
|
10890
11114
|
public:
|
|
10891
11115
|
DUCKDB_API PendingQueryResult(shared_ptr<ClientContext> context, PreparedStatementData &statement,
|
|
10892
|
-
vector<LogicalType> types);
|
|
11116
|
+
vector<LogicalType> types, bool allow_stream_result);
|
|
10893
11117
|
DUCKDB_API explicit PendingQueryResult(string error_message);
|
|
10894
11118
|
DUCKDB_API ~PendingQueryResult();
|
|
10895
11119
|
|
|
@@ -10903,18 +11127,19 @@ public:
|
|
|
10903
11127
|
|
|
10904
11128
|
//! Returns the result of the query as an actual query result.
|
|
10905
11129
|
//! This returns (mostly) instantly if ExecuteTask has been called until RESULT_READY was returned.
|
|
10906
|
-
DUCKDB_API unique_ptr<QueryResult> Execute(
|
|
11130
|
+
DUCKDB_API unique_ptr<QueryResult> Execute();
|
|
10907
11131
|
|
|
10908
11132
|
DUCKDB_API void Close();
|
|
10909
11133
|
|
|
10910
11134
|
private:
|
|
10911
11135
|
shared_ptr<ClientContext> context;
|
|
11136
|
+
bool allow_stream_result;
|
|
10912
11137
|
|
|
10913
11138
|
private:
|
|
10914
11139
|
void CheckExecutableInternal(ClientContextLock &lock);
|
|
10915
11140
|
|
|
10916
11141
|
PendingExecutionResult ExecuteTaskInternal(ClientContextLock &lock);
|
|
10917
|
-
unique_ptr<QueryResult> ExecuteInternal(ClientContextLock &lock
|
|
11142
|
+
unique_ptr<QueryResult> ExecuteInternal(ClientContextLock &lock);
|
|
10918
11143
|
unique_ptr<ClientContextLock> LockContext();
|
|
10919
11144
|
};
|
|
10920
11145
|
|
|
@@ -10968,6 +11193,8 @@ public:
|
|
|
10968
11193
|
idx_t ColumnCount();
|
|
10969
11194
|
//! Returns the statement type of the underlying prepared statement object
|
|
10970
11195
|
StatementType GetStatementType();
|
|
11196
|
+
//! Returns the underlying statement properties
|
|
11197
|
+
StatementProperties GetStatementProperties();
|
|
10971
11198
|
//! Returns the result SQL types of the prepared statement
|
|
10972
11199
|
const vector<LogicalType> &GetTypes();
|
|
10973
11200
|
//! Returns the result names of the prepared statement
|
|
@@ -10988,7 +11215,7 @@ public:
|
|
|
10988
11215
|
}
|
|
10989
11216
|
|
|
10990
11217
|
//! Create a pending query result of the prepared statement with the given set of arguments
|
|
10991
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(vector<Value> &values);
|
|
11218
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(vector<Value> &values, bool allow_stream_result = true);
|
|
10992
11219
|
|
|
10993
11220
|
//! Execute the prepared statement with the given set of values
|
|
10994
11221
|
DUCKDB_API unique_ptr<QueryResult> Execute(vector<Value> &values, bool allow_stream_result = true);
|
|
@@ -11260,11 +11487,11 @@ class FieldReader;
|
|
|
11260
11487
|
// Constraint Types
|
|
11261
11488
|
//===--------------------------------------------------------------------===//
|
|
11262
11489
|
enum class ConstraintType : uint8_t {
|
|
11263
|
-
INVALID = 0,
|
|
11264
|
-
NOT_NULL = 1,
|
|
11265
|
-
CHECK = 2,
|
|
11266
|
-
UNIQUE = 3,
|
|
11267
|
-
FOREIGN_KEY = 4 // FOREIGN KEY constraint
|
|
11490
|
+
INVALID = 0, // invalid constraint type
|
|
11491
|
+
NOT_NULL = 1, // NOT NULL constraint
|
|
11492
|
+
CHECK = 2, // CHECK constraint
|
|
11493
|
+
UNIQUE = 3, // UNIQUE constraint
|
|
11494
|
+
FOREIGN_KEY = 4, // FOREIGN KEY constraint
|
|
11268
11495
|
};
|
|
11269
11496
|
|
|
11270
11497
|
enum class ForeignKeyType : uint8_t {
|
|
@@ -11280,7 +11507,7 @@ struct ForeignKeyInfo {
|
|
|
11280
11507
|
//! key table
|
|
11281
11508
|
string table;
|
|
11282
11509
|
//! The set of main key table's column's index
|
|
11283
|
-
vector<
|
|
11510
|
+
vector<storage_t> pk_keys;
|
|
11284
11511
|
//! The set of foreign key table's column's index
|
|
11285
11512
|
vector<idx_t> fk_keys;
|
|
11286
11513
|
};
|
|
@@ -11335,9 +11562,105 @@ public:
|
|
|
11335
11562
|
|
|
11336
11563
|
|
|
11337
11564
|
|
|
11565
|
+
//===----------------------------------------------------------------------===//
|
|
11566
|
+
// DuckDB
|
|
11567
|
+
//
|
|
11568
|
+
// duckdb/catalog/catalog_entry/column_dependency_manager.hpp
|
|
11569
|
+
//
|
|
11570
|
+
//
|
|
11571
|
+
//===----------------------------------------------------------------------===//
|
|
11572
|
+
|
|
11573
|
+
|
|
11574
|
+
|
|
11575
|
+
|
|
11576
|
+
|
|
11577
|
+
|
|
11578
|
+
//===----------------------------------------------------------------------===//
|
|
11579
|
+
// DuckDB
|
|
11580
|
+
//
|
|
11581
|
+
// duckdb/common/set.hpp
|
|
11582
|
+
//
|
|
11583
|
+
//
|
|
11584
|
+
//===----------------------------------------------------------------------===//
|
|
11585
|
+
|
|
11586
|
+
|
|
11587
|
+
|
|
11588
|
+
#include <set>
|
|
11589
|
+
|
|
11590
|
+
namespace duckdb {
|
|
11591
|
+
using std::set;
|
|
11592
|
+
}
|
|
11593
|
+
|
|
11594
|
+
//===----------------------------------------------------------------------===//
|
|
11595
|
+
// DuckDB
|
|
11596
|
+
//
|
|
11597
|
+
// duckdb/common/stack.hpp
|
|
11598
|
+
//
|
|
11599
|
+
//
|
|
11600
|
+
//===----------------------------------------------------------------------===//
|
|
11601
|
+
|
|
11602
|
+
|
|
11603
|
+
|
|
11604
|
+
#include <stack>
|
|
11605
|
+
|
|
11606
|
+
namespace duckdb {
|
|
11607
|
+
using std::stack;
|
|
11608
|
+
}
|
|
11609
|
+
|
|
11610
|
+
|
|
11611
|
+
namespace duckdb {
|
|
11612
|
+
|
|
11613
|
+
//! Dependency Manager local to a table, responsible for keeping track of generated column dependencies
|
|
11614
|
+
|
|
11615
|
+
class ColumnDependencyManager {
|
|
11616
|
+
public:
|
|
11617
|
+
DUCKDB_API ColumnDependencyManager();
|
|
11618
|
+
DUCKDB_API ~ColumnDependencyManager();
|
|
11619
|
+
DUCKDB_API ColumnDependencyManager(ColumnDependencyManager &&other) = default;
|
|
11620
|
+
DUCKDB_API ColumnDependencyManager(const ColumnDependencyManager &other) = delete;
|
|
11621
|
+
|
|
11622
|
+
public:
|
|
11623
|
+
//! Get the bind order that ensures dependencies are resolved before dependents are
|
|
11624
|
+
stack<column_t> GetBindOrder(const vector<ColumnDefinition> &columns);
|
|
11625
|
+
|
|
11626
|
+
//! Adds a connection between the dependent and its dependencies
|
|
11627
|
+
void AddGeneratedColumn(column_t index, const vector<column_t> &indices, bool root = true);
|
|
11628
|
+
//! Add a generated column from a column definition
|
|
11629
|
+
void AddGeneratedColumn(const ColumnDefinition &column, const case_insensitive_map_t<column_t> &name_map);
|
|
11630
|
+
|
|
11631
|
+
//! Removes the column(s) and outputs the new column indices
|
|
11632
|
+
vector<column_t> RemoveColumn(column_t index, column_t column_amount);
|
|
11633
|
+
|
|
11634
|
+
bool IsDependencyOf(column_t dependent, column_t dependency) const;
|
|
11635
|
+
bool HasDependencies(column_t index) const;
|
|
11636
|
+
const unordered_set<column_t> &GetDependencies(column_t index) const;
|
|
11637
|
+
|
|
11638
|
+
bool HasDependents(column_t index) const;
|
|
11639
|
+
const unordered_set<column_t> &GetDependents(column_t index) const;
|
|
11640
|
+
|
|
11641
|
+
private:
|
|
11642
|
+
void RemoveStandardColumn(column_t index);
|
|
11643
|
+
void RemoveGeneratedColumn(column_t index);
|
|
11644
|
+
|
|
11645
|
+
void AdjustSingle(column_t idx, idx_t offset);
|
|
11646
|
+
// Clean up the gaps created by a Remove operation
|
|
11647
|
+
vector<column_t> CleanupInternals(column_t column_amount);
|
|
11648
|
+
|
|
11649
|
+
private:
|
|
11650
|
+
//! A map of column dependency to generated column(s)
|
|
11651
|
+
unordered_map<column_t, unordered_set<column_t>> dependencies_map;
|
|
11652
|
+
//! A map of generated column name to (potentially generated)column dependencies
|
|
11653
|
+
unordered_map<column_t, unordered_set<column_t>> dependents_map;
|
|
11654
|
+
//! For resolve-order purposes, keep track of the 'direct' (not inherited) dependencies of a generated column
|
|
11655
|
+
unordered_map<column_t, unordered_set<column_t>> direct_dependencies;
|
|
11656
|
+
set<column_t> deleted_columns;
|
|
11657
|
+
};
|
|
11658
|
+
|
|
11659
|
+
} // namespace duckdb
|
|
11660
|
+
|
|
11661
|
+
|
|
11338
11662
|
namespace duckdb {
|
|
11339
11663
|
|
|
11340
|
-
class ColumnStatistics;
|
|
11341
11664
|
class DataTable;
|
|
11342
11665
|
struct CreateTableInfo;
|
|
11343
11666
|
struct BoundCreateTableInfo;
|
|
@@ -11364,13 +11687,16 @@ public:
|
|
|
11364
11687
|
vector<unique_ptr<Constraint>> constraints;
|
|
11365
11688
|
//! A list of constraints that are part of this table
|
|
11366
11689
|
vector<unique_ptr<BoundConstraint>> bound_constraints;
|
|
11690
|
+
ColumnDependencyManager column_dependency_manager;
|
|
11367
11691
|
//! A map of column name to column index
|
|
11368
11692
|
case_insensitive_map_t<column_t> name_map;
|
|
11369
11693
|
|
|
11370
11694
|
public:
|
|
11695
|
+
//! For debugging purposes, count how many columns are STANDARD
|
|
11696
|
+
idx_t StandardColumnCount() const;
|
|
11371
11697
|
unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info) override;
|
|
11372
11698
|
//! Returns whether or not a column with the given name exists
|
|
11373
|
-
bool ColumnExists(const string &name);
|
|
11699
|
+
DUCKDB_API bool ColumnExists(const string &name);
|
|
11374
11700
|
//! Returns a reference to the column of the specified name. Throws an
|
|
11375
11701
|
//! exception if the column does not exist.
|
|
11376
11702
|
ColumnDefinition &GetColumn(const string &name);
|
|
@@ -11394,9 +11720,10 @@ public:
|
|
|
11394
11720
|
//! If the column does not exist:
|
|
11395
11721
|
//! If if_exists is true, returns DConstants::INVALID_INDEX
|
|
11396
11722
|
//! If if_exists is false, throws an exception
|
|
11397
|
-
|
|
11723
|
+
column_t GetColumnIndex(string &name, bool if_exists = false);
|
|
11398
11724
|
|
|
11399
11725
|
private:
|
|
11726
|
+
const string &GetColumnName(column_t index);
|
|
11400
11727
|
unique_ptr<CatalogEntry> RenameColumn(ClientContext &context, RenameColumnInfo &info);
|
|
11401
11728
|
unique_ptr<CatalogEntry> AddColumn(ClientContext &context, AddColumnInfo &info);
|
|
11402
11729
|
unique_ptr<CatalogEntry> RemoveColumn(ClientContext &context, RemoveColumnInfo &info);
|
|
@@ -11564,6 +11891,7 @@ public:
|
|
|
11564
11891
|
|
|
11565
11892
|
|
|
11566
11893
|
|
|
11894
|
+
|
|
11567
11895
|
namespace duckdb {
|
|
11568
11896
|
|
|
11569
11897
|
enum class AlterType : uint8_t {
|
|
@@ -11626,7 +11954,7 @@ enum class AlterTableType : uint8_t {
|
|
|
11626
11954
|
REMOVE_COLUMN = 4,
|
|
11627
11955
|
ALTER_COLUMN_TYPE = 5,
|
|
11628
11956
|
SET_DEFAULT = 6,
|
|
11629
|
-
FOREIGN_KEY_CONSTRAINT = 7
|
|
11957
|
+
FOREIGN_KEY_CONSTRAINT = 7,
|
|
11630
11958
|
};
|
|
11631
11959
|
|
|
11632
11960
|
struct AlterTableInfo : public AlterInfo {
|
|
@@ -11696,13 +12024,15 @@ public:
|
|
|
11696
12024
|
// RemoveColumnInfo
|
|
11697
12025
|
//===--------------------------------------------------------------------===//
|
|
11698
12026
|
struct RemoveColumnInfo : public AlterTableInfo {
|
|
11699
|
-
RemoveColumnInfo(string schema, string table, string removed_column, bool if_exists);
|
|
12027
|
+
RemoveColumnInfo(string schema, string table, string removed_column, bool if_exists, bool cascade);
|
|
11700
12028
|
~RemoveColumnInfo() override;
|
|
11701
12029
|
|
|
11702
12030
|
//! The column to remove
|
|
11703
12031
|
string removed_column;
|
|
11704
12032
|
//! Whether or not an error should be thrown if the column does not exist
|
|
11705
12033
|
bool if_exists;
|
|
12034
|
+
//! Whether or not the column should be removed if a dependency conflict arises (used by GENERATED columns)
|
|
12035
|
+
bool cascade;
|
|
11706
12036
|
|
|
11707
12037
|
public:
|
|
11708
12038
|
unique_ptr<AlterInfo> Copy() const override;
|
|
@@ -12311,7 +12641,8 @@ public:
|
|
|
12311
12641
|
}
|
|
12312
12642
|
|
|
12313
12643
|
//! Cast an expression to the specified SQL type if required
|
|
12314
|
-
static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type
|
|
12644
|
+
static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type,
|
|
12645
|
+
bool try_cast = false);
|
|
12315
12646
|
//! Returns true if a cast is invertible (i.e. CAST(s -> t -> s) = s for all values of s). This is not true for e.g.
|
|
12316
12647
|
//! boolean casts, because that can be e.g. -1 -> TRUE -> 1. This is necessary to prevent some optimizer bugs.
|
|
12317
12648
|
static bool CastIsInvertible(const LogicalType &source_type, const LogicalType &target_type);
|
|
@@ -12632,10 +12963,10 @@ namespace duckdb {
|
|
|
12632
12963
|
class BoundReferenceExpression : public Expression {
|
|
12633
12964
|
public:
|
|
12634
12965
|
BoundReferenceExpression(string alias, LogicalType type, idx_t index);
|
|
12635
|
-
BoundReferenceExpression(LogicalType type,
|
|
12966
|
+
BoundReferenceExpression(LogicalType type, storage_t index);
|
|
12636
12967
|
|
|
12637
12968
|
//! Index used to access data in the chunks
|
|
12638
|
-
|
|
12969
|
+
storage_t index;
|
|
12639
12970
|
|
|
12640
12971
|
public:
|
|
12641
12972
|
bool IsScalar() const override {
|
|
@@ -13124,6 +13455,7 @@ public:
|
|
|
13124
13455
|
string Bind(unique_ptr<ParsedExpression> *expr, idx_t depth, bool root_expression = false);
|
|
13125
13456
|
|
|
13126
13457
|
unique_ptr<ParsedExpression> CreateStructExtract(unique_ptr<ParsedExpression> base, string field_name);
|
|
13458
|
+
unique_ptr<ParsedExpression> CreateStructPack(ColumnRefExpression &colref);
|
|
13127
13459
|
BindResult BindQualifiedColumnName(ColumnRefExpression &colref, const string &table_name);
|
|
13128
13460
|
|
|
13129
13461
|
unique_ptr<ParsedExpression> QualifyColumnName(const string &column_name, string &error_message);
|
|
@@ -13147,9 +13479,6 @@ public:
|
|
|
13147
13479
|
static bool ContainsType(const LogicalType &type, LogicalTypeId target);
|
|
13148
13480
|
static LogicalType ExchangeType(const LogicalType &type, LogicalTypeId target, LogicalType new_type);
|
|
13149
13481
|
|
|
13150
|
-
static void ResolveParameterType(LogicalType &type);
|
|
13151
|
-
static void ResolveParameterType(unique_ptr<Expression> &expr);
|
|
13152
|
-
|
|
13153
13482
|
//! Bind the given expresion. Unlike Bind(), this does *not* mute the given ParsedExpression.
|
|
13154
13483
|
//! Exposed to be used from sub-binders that aren't subclasses of ExpressionBinder.
|
|
13155
13484
|
virtual BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
|
|
@@ -13171,7 +13500,6 @@ protected:
|
|
|
13171
13500
|
BindResult BindExpression(OperatorExpression &expr, idx_t depth);
|
|
13172
13501
|
BindResult BindExpression(ParameterExpression &expr, idx_t depth);
|
|
13173
13502
|
BindResult BindExpression(PositionalReferenceExpression &ref, idx_t depth);
|
|
13174
|
-
BindResult BindExpression(StarExpression &expr, idx_t depth);
|
|
13175
13503
|
BindResult BindExpression(SubqueryExpression &expr, idx_t depth);
|
|
13176
13504
|
|
|
13177
13505
|
protected:
|
|
@@ -13209,6 +13537,7 @@ protected:
|
|
|
13209
13537
|
|
|
13210
13538
|
|
|
13211
13539
|
|
|
13540
|
+
|
|
13212
13541
|
namespace duckdb {
|
|
13213
13542
|
class BindContext;
|
|
13214
13543
|
class BoundQueryNode;
|
|
@@ -13218,12 +13547,18 @@ class LogicalGet;
|
|
|
13218
13547
|
class TableCatalogEntry;
|
|
13219
13548
|
class TableFunctionCatalogEntry;
|
|
13220
13549
|
class BoundTableFunction;
|
|
13550
|
+
class StandardEntry;
|
|
13551
|
+
|
|
13552
|
+
enum class BindingType { BASE, TABLE, MACRO, CATALOG_ENTRY };
|
|
13221
13553
|
|
|
13222
13554
|
//! A Binding represents a binding to a table, table-producing function or subquery with a specified table index.
|
|
13223
13555
|
struct Binding {
|
|
13224
|
-
Binding(const string &alias, vector<LogicalType> types, vector<string> names,
|
|
13556
|
+
Binding(BindingType binding_type, const string &alias, vector<LogicalType> types, vector<string> names,
|
|
13557
|
+
idx_t index);
|
|
13225
13558
|
virtual ~Binding() = default;
|
|
13226
13559
|
|
|
13560
|
+
//! The type of Binding
|
|
13561
|
+
BindingType binding_type;
|
|
13227
13562
|
//! The alias of the binding
|
|
13228
13563
|
string alias;
|
|
13229
13564
|
//! The table index of the binding
|
|
@@ -13240,7 +13575,17 @@ public:
|
|
|
13240
13575
|
bool HasMatchingBinding(const string &column_name);
|
|
13241
13576
|
virtual string ColumnNotFoundError(const string &column_name) const;
|
|
13242
13577
|
virtual BindResult Bind(ColumnRefExpression &colref, idx_t depth);
|
|
13243
|
-
virtual
|
|
13578
|
+
virtual StandardEntry *GetStandardEntry();
|
|
13579
|
+
};
|
|
13580
|
+
|
|
13581
|
+
struct EntryBinding : public Binding {
|
|
13582
|
+
public:
|
|
13583
|
+
EntryBinding(const string &alias, vector<LogicalType> types, vector<string> names, idx_t index,
|
|
13584
|
+
StandardEntry &entry);
|
|
13585
|
+
StandardEntry &entry;
|
|
13586
|
+
|
|
13587
|
+
public:
|
|
13588
|
+
StandardEntry *GetStandardEntry() override;
|
|
13244
13589
|
};
|
|
13245
13590
|
|
|
13246
13591
|
//! TableBinding is exactly like the Binding, except it keeps track of which columns were bound in the linked LogicalGet
|
|
@@ -13253,8 +13598,9 @@ struct TableBinding : public Binding {
|
|
|
13253
13598
|
LogicalGet &get;
|
|
13254
13599
|
|
|
13255
13600
|
public:
|
|
13601
|
+
unique_ptr<ParsedExpression> ExpandGeneratedColumn(const string &column_name);
|
|
13256
13602
|
BindResult Bind(ColumnRefExpression &colref, idx_t depth) override;
|
|
13257
|
-
|
|
13603
|
+
StandardEntry *GetStandardEntry() override;
|
|
13258
13604
|
string ColumnNotFoundError(const string &column_name) const override;
|
|
13259
13605
|
};
|
|
13260
13606
|
|
|
@@ -13318,6 +13664,8 @@ public:
|
|
|
13318
13664
|
string BindColumn(PositionalReferenceExpression &ref, string &table_name, string &column_name);
|
|
13319
13665
|
BindResult BindColumn(PositionalReferenceExpression &ref, idx_t depth);
|
|
13320
13666
|
|
|
13667
|
+
unique_ptr<ParsedExpression> ExpandGeneratedColumn(const string &table_name, const string &column_name);
|
|
13668
|
+
|
|
13321
13669
|
unique_ptr<ParsedExpression> CreateColumnReference(const string &table_name, const string &column_name);
|
|
13322
13670
|
unique_ptr<ParsedExpression> CreateColumnReference(const string &schema_name, const string &table_name,
|
|
13323
13671
|
const string &column_name);
|
|
@@ -13342,10 +13690,15 @@ public:
|
|
|
13342
13690
|
//! Adds a call to a table function with the given alias to the BindContext.
|
|
13343
13691
|
void AddTableFunction(idx_t index, const string &alias, const vector<string> &names,
|
|
13344
13692
|
const vector<LogicalType> &types, LogicalGet &get);
|
|
13693
|
+
//! Adds a table view with a given alias to the BindContext.
|
|
13694
|
+
void AddView(idx_t index, const string &alias, SubqueryRef &ref, BoundQueryNode &subquery, ViewCatalogEntry *view);
|
|
13345
13695
|
//! Adds a subquery with a given alias to the BindContext.
|
|
13346
13696
|
void AddSubquery(idx_t index, const string &alias, SubqueryRef &ref, BoundQueryNode &subquery);
|
|
13347
13697
|
//! Adds a subquery with a given alias to the BindContext.
|
|
13348
13698
|
void AddSubquery(idx_t index, const string &alias, TableFunctionRef &ref, BoundQueryNode &subquery);
|
|
13699
|
+
//! Adds a binding to a catalog entry with a given alias to the BindContext.
|
|
13700
|
+
void AddEntryBinding(idx_t index, const string &alias, const vector<string> &names,
|
|
13701
|
+
const vector<LogicalType> &types, StandardEntry *entry);
|
|
13349
13702
|
//! Adds a base table with the given alias to the BindContext.
|
|
13350
13703
|
void AddGenericBinding(idx_t index, const string &alias, const vector<string> &names,
|
|
13351
13704
|
const vector<LogicalType> &types);
|
|
@@ -13421,7 +13774,6 @@ private:
|
|
|
13421
13774
|
|
|
13422
13775
|
|
|
13423
13776
|
|
|
13424
|
-
//#include "duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp"
|
|
13425
13777
|
|
|
13426
13778
|
namespace duckdb {
|
|
13427
13779
|
class BoundResultModifier;
|
|
@@ -13483,12 +13835,10 @@ public:
|
|
|
13483
13835
|
vector<CorrelatedColumnInfo> correlated_columns;
|
|
13484
13836
|
//! The set of parameter expressions bound by this binder
|
|
13485
13837
|
vector<BoundParameterExpression *> *parameters;
|
|
13486
|
-
//!
|
|
13487
|
-
|
|
13488
|
-
//!
|
|
13489
|
-
|
|
13490
|
-
//! Whether or not the statement can be streamed to the client
|
|
13491
|
-
bool allow_stream_result;
|
|
13838
|
+
//! The types of the prepared statement parameters, if any
|
|
13839
|
+
vector<LogicalType> *parameter_types;
|
|
13840
|
+
//! Statement properties
|
|
13841
|
+
StatementProperties properties;
|
|
13492
13842
|
//! The alias for the currently processing subquery, if it exists
|
|
13493
13843
|
string alias;
|
|
13494
13844
|
//! Macro parameter bindings (if any)
|
|
@@ -13588,6 +13938,8 @@ private:
|
|
|
13588
13938
|
unordered_set<ViewCatalogEntry *> bound_views;
|
|
13589
13939
|
|
|
13590
13940
|
private:
|
|
13941
|
+
//! Bind the expressions of generated columns to check for errors
|
|
13942
|
+
void BindGeneratedColumns(BoundCreateTableInfo &info);
|
|
13591
13943
|
//! Bind the default values of the columns of a table
|
|
13592
13944
|
void BindDefaultValues(vector<ColumnDefinition> &columns, vector<unique_ptr<Expression>> &bound_defaults);
|
|
13593
13945
|
//! Bind a limit value (LIMIT or OFFSET)
|
|
@@ -13641,9 +13993,12 @@ private:
|
|
|
13641
13993
|
unique_ptr<BoundTableRef> Bind(EmptyTableRef &ref);
|
|
13642
13994
|
unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
|
|
13643
13995
|
|
|
13644
|
-
bool
|
|
13645
|
-
|
|
13646
|
-
|
|
13996
|
+
bool BindTableFunctionParameters(TableFunctionCatalogEntry &table_function,
|
|
13997
|
+
vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
|
|
13998
|
+
vector<Value> ¶meters, named_parameter_map_t &named_parameters,
|
|
13999
|
+
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
14000
|
+
bool BindTableInTableOutFunction(vector<unique_ptr<ParsedExpression>> &expressions,
|
|
14001
|
+
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
13647
14002
|
|
|
13648
14003
|
unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
|
|
13649
14004
|
unique_ptr<LogicalOperator> CreatePlan(BoundCrossProductRef &ref);
|
|
@@ -13781,6 +14136,7 @@ public:
|
|
|
13781
14136
|
|
|
13782
14137
|
|
|
13783
14138
|
namespace duckdb {
|
|
14139
|
+
|
|
13784
14140
|
//! SQLStatement is the base class of any type of SQL statement.
|
|
13785
14141
|
class SQLStatement {
|
|
13786
14142
|
public:
|
|
@@ -13803,6 +14159,9 @@ protected:
|
|
|
13803
14159
|
SQLStatement(const SQLStatement &other) = default;
|
|
13804
14160
|
|
|
13805
14161
|
public:
|
|
14162
|
+
virtual string ToString() const {
|
|
14163
|
+
throw InternalException("ToString not supported for this type of SQLStatement");
|
|
14164
|
+
}
|
|
13806
14165
|
//! Create a copy of this SelectStatement
|
|
13807
14166
|
virtual unique_ptr<SQLStatement> Copy() const = 0;
|
|
13808
14167
|
};
|
|
@@ -13907,7 +14266,9 @@ public:
|
|
|
13907
14266
|
|
|
13908
14267
|
public:
|
|
13909
14268
|
//! Convert the object to a string
|
|
13910
|
-
virtual string ToString() const;
|
|
14269
|
+
virtual string ToString() const = 0;
|
|
14270
|
+
string BaseToString(string result) const;
|
|
14271
|
+
string BaseToString(string result, const vector<string> &column_name_alias) const;
|
|
13911
14272
|
void Print();
|
|
13912
14273
|
|
|
13913
14274
|
virtual bool Equals(const TableRef *other) const;
|
|
@@ -13944,6 +14305,8 @@ protected:
|
|
|
13944
14305
|
SelectStatement(const SelectStatement &other);
|
|
13945
14306
|
|
|
13946
14307
|
public:
|
|
14308
|
+
//! Convert the SELECT statement to a string
|
|
14309
|
+
string ToString() const override;
|
|
13947
14310
|
//! Create a copy of this SelectStatement
|
|
13948
14311
|
unique_ptr<SQLStatement> Copy() const override;
|
|
13949
14312
|
//! Serializes a SelectStatement to a stand-alone binary blob
|
|
@@ -13995,6 +14358,9 @@ public:
|
|
|
13995
14358
|
virtual const vector<unique_ptr<ParsedExpression>> &GetSelectList() const = 0;
|
|
13996
14359
|
|
|
13997
14360
|
public:
|
|
14361
|
+
//! Convert the query node to a string
|
|
14362
|
+
virtual string ToString() const = 0;
|
|
14363
|
+
|
|
13998
14364
|
virtual bool Equals(const QueryNode *other) const;
|
|
13999
14365
|
|
|
14000
14366
|
//! Create a copy of this QueryNode
|
|
@@ -14006,6 +14372,9 @@ public:
|
|
|
14006
14372
|
//! Deserializes a blob back into a QueryNode
|
|
14007
14373
|
DUCKDB_API static unique_ptr<QueryNode> Deserialize(Deserializer &source);
|
|
14008
14374
|
|
|
14375
|
+
string CTEToString() const;
|
|
14376
|
+
string ResultModifiersToString() const;
|
|
14377
|
+
|
|
14009
14378
|
protected:
|
|
14010
14379
|
//! Copy base QueryNode properties from another expression to this one,
|
|
14011
14380
|
//! used in Copy method
|
|
@@ -14169,12 +14538,14 @@ public:
|
|
|
14169
14538
|
string schema;
|
|
14170
14539
|
//! Name of the aggregate function
|
|
14171
14540
|
string function_name;
|
|
14172
|
-
//! The child expression of the main window
|
|
14541
|
+
//! The child expression of the main window function
|
|
14173
14542
|
vector<unique_ptr<ParsedExpression>> children;
|
|
14174
14543
|
//! The set of expressions to partition by
|
|
14175
14544
|
vector<unique_ptr<ParsedExpression>> partitions;
|
|
14176
14545
|
//! The set of ordering clauses
|
|
14177
14546
|
vector<OrderByNode> orders;
|
|
14547
|
+
//! Expression representing a filter, only used for aggregates
|
|
14548
|
+
unique_ptr<ParsedExpression> filter_expr;
|
|
14178
14549
|
//! True to ignore NULL values
|
|
14179
14550
|
bool ignore_nulls;
|
|
14180
14551
|
//! The window boundaries
|
|
@@ -14223,8 +14594,13 @@ public:
|
|
|
14223
14594
|
if (entry.ignore_nulls) {
|
|
14224
14595
|
result += " IGNORE NULLS";
|
|
14225
14596
|
}
|
|
14597
|
+
// FILTER
|
|
14598
|
+
if (entry.filter_expr) {
|
|
14599
|
+
result += ") FILTER (WHERE " + entry.filter_expr->ToString();
|
|
14600
|
+
}
|
|
14601
|
+
|
|
14226
14602
|
// Over clause
|
|
14227
|
-
result += ") OVER(";
|
|
14603
|
+
result += ") OVER (";
|
|
14228
14604
|
string sep;
|
|
14229
14605
|
|
|
14230
14606
|
// Partitions
|
|
@@ -14343,7 +14719,7 @@ public:
|
|
|
14343
14719
|
unique_ptr<AggregateFunction> aggregate;
|
|
14344
14720
|
//! The bound function info
|
|
14345
14721
|
unique_ptr<FunctionData> bind_info;
|
|
14346
|
-
//! The child expressions of the main window
|
|
14722
|
+
//! The child expressions of the main window function
|
|
14347
14723
|
vector<unique_ptr<Expression>> children;
|
|
14348
14724
|
//! The set of expressions to partition by
|
|
14349
14725
|
vector<unique_ptr<Expression>> partitions;
|
|
@@ -14351,6 +14727,8 @@ public:
|
|
|
14351
14727
|
vector<unique_ptr<BaseStatistics>> partitions_stats;
|
|
14352
14728
|
//! The set of ordering clauses
|
|
14353
14729
|
vector<BoundOrderByNode> orders;
|
|
14730
|
+
//! Expression representing a filter, only used for aggregates
|
|
14731
|
+
unique_ptr<Expression> filter_expr;
|
|
14354
14732
|
//! True to ignore NULL values
|
|
14355
14733
|
bool ignore_nulls;
|
|
14356
14734
|
//! The window boundaries
|
|
@@ -14434,11 +14812,11 @@ typedef unordered_map<block_id_t, unique_ptr<BufferHandle>> buffer_handle_set_t;
|
|
|
14434
14812
|
|
|
14435
14813
|
struct ColumnScanState {
|
|
14436
14814
|
//! The column segment that is currently being scanned
|
|
14437
|
-
ColumnSegment *current;
|
|
14815
|
+
ColumnSegment *current = nullptr;
|
|
14438
14816
|
//! The current row index of the scan
|
|
14439
|
-
idx_t row_index;
|
|
14817
|
+
idx_t row_index = 0;
|
|
14440
14818
|
//! The internal row index (i.e. the position of the SegmentScanState)
|
|
14441
|
-
idx_t internal_index;
|
|
14819
|
+
idx_t internal_index = 0;
|
|
14442
14820
|
//! Segment scan state
|
|
14443
14821
|
unique_ptr<SegmentScanState> scan_state;
|
|
14444
14822
|
//! Child states of the vector
|
|
@@ -14472,10 +14850,10 @@ struct LocalScanState {
|
|
|
14472
14850
|
return storage.get();
|
|
14473
14851
|
}
|
|
14474
14852
|
|
|
14475
|
-
idx_t chunk_index;
|
|
14476
|
-
idx_t max_index;
|
|
14477
|
-
idx_t last_chunk_count;
|
|
14478
|
-
TableFilterSet *table_filters;
|
|
14853
|
+
idx_t chunk_index = 0;
|
|
14854
|
+
idx_t max_index = 0;
|
|
14855
|
+
idx_t last_chunk_count = 0;
|
|
14856
|
+
TableFilterSet *table_filters = nullptr;
|
|
14479
14857
|
|
|
14480
14858
|
private:
|
|
14481
14859
|
shared_ptr<LocalTableStorage> storage;
|
|
@@ -14489,17 +14867,13 @@ public:
|
|
|
14489
14867
|
//! The parent scan state
|
|
14490
14868
|
TableScanState &parent;
|
|
14491
14869
|
//! The current row_group we are scanning
|
|
14492
|
-
RowGroup *row_group;
|
|
14870
|
+
RowGroup *row_group = nullptr;
|
|
14493
14871
|
//! The vector index within the row_group
|
|
14494
|
-
idx_t vector_index;
|
|
14872
|
+
idx_t vector_index = 0;
|
|
14495
14873
|
//! The maximum row index of this row_group scan
|
|
14496
|
-
idx_t max_row;
|
|
14874
|
+
idx_t max_row = 0;
|
|
14497
14875
|
//! Child column scans
|
|
14498
14876
|
unique_ptr<ColumnScanState[]> column_scans;
|
|
14499
|
-
|
|
14500
|
-
public:
|
|
14501
|
-
//! Move to the next vector, skipping past the current one
|
|
14502
|
-
void NextVector();
|
|
14503
14877
|
};
|
|
14504
14878
|
|
|
14505
14879
|
class TableScanState {
|
|
@@ -14509,7 +14883,7 @@ public:
|
|
|
14509
14883
|
//! The row_group scan state
|
|
14510
14884
|
RowGroupScanState row_group_scan_state;
|
|
14511
14885
|
//! The total maximum row index
|
|
14512
|
-
idx_t max_row;
|
|
14886
|
+
idx_t max_row = 0;
|
|
14513
14887
|
//! The column identifiers of the scan
|
|
14514
14888
|
vector<column_t> column_ids;
|
|
14515
14889
|
//! The table filters (if any)
|
|
@@ -14518,10 +14892,6 @@ public:
|
|
|
14518
14892
|
unique_ptr<AdaptiveFilter> adaptive_filter;
|
|
14519
14893
|
//! Transaction-local scan state
|
|
14520
14894
|
LocalScanState local_state;
|
|
14521
|
-
|
|
14522
|
-
public:
|
|
14523
|
-
//! Move to the next vector
|
|
14524
|
-
void NextVector();
|
|
14525
14895
|
};
|
|
14526
14896
|
|
|
14527
14897
|
class CreateIndexScanState : public TableScanState {
|
|
@@ -14803,8 +15173,8 @@ private:
|
|
|
14803
15173
|
void AdjustTableDependencies(CatalogEntry *entry);
|
|
14804
15174
|
//! Adjust one dependency
|
|
14805
15175
|
void AdjustDependency(CatalogEntry *entry, TableCatalogEntry *table, ColumnDefinition &column, bool remove);
|
|
14806
|
-
//! Adjust
|
|
14807
|
-
void
|
|
15176
|
+
//! Adjust User dependency
|
|
15177
|
+
void AdjustUserDependency(CatalogEntry *entry, ColumnDefinition &column, bool remove);
|
|
14808
15178
|
//! Given a root entry, gets the entry valid for this transaction
|
|
14809
15179
|
CatalogEntry *GetEntryForTransaction(ClientContext &context, CatalogEntry *current);
|
|
14810
15180
|
CatalogEntry *GetCommittedEntry(CatalogEntry *current);
|
|
@@ -14818,6 +15188,11 @@ private:
|
|
|
14818
15188
|
void DeleteMapping(ClientContext &context, const string &name);
|
|
14819
15189
|
void DropEntryDependencies(ClientContext &context, idx_t entry_index, CatalogEntry &entry, bool cascade);
|
|
14820
15190
|
|
|
15191
|
+
//! Create all default entries
|
|
15192
|
+
void CreateDefaultEntries(ClientContext &context, unique_lock<mutex> &lock);
|
|
15193
|
+
//! Attempt to create a default entry with the specified name. Returns the entry if successful, nullptr otherwise.
|
|
15194
|
+
CatalogEntry *CreateDefaultEntry(ClientContext &context, const string &name, unique_lock<mutex> &lock);
|
|
15195
|
+
|
|
14821
15196
|
private:
|
|
14822
15197
|
Catalog &catalog;
|
|
14823
15198
|
//! The catalog lock is used to make changes to the data
|
|
@@ -16410,6 +16785,15 @@ Sets the init function of the table function
|
|
|
16410
16785
|
*/
|
|
16411
16786
|
DUCKDB_API void duckdb_table_function_set_init(duckdb_table_function table_function, duckdb_table_function_init_t init);
|
|
16412
16787
|
|
|
16788
|
+
/*!
|
|
16789
|
+
Sets the thread-local init function of the table function
|
|
16790
|
+
|
|
16791
|
+
* table_function: The table function
|
|
16792
|
+
* init: The init function
|
|
16793
|
+
*/
|
|
16794
|
+
DUCKDB_API void duckdb_table_function_set_local_init(duckdb_table_function table_function,
|
|
16795
|
+
duckdb_table_function_init_t init);
|
|
16796
|
+
|
|
16413
16797
|
/*!
|
|
16414
16798
|
Sets the main function of the table function
|
|
16415
16799
|
|
|
@@ -16553,6 +16937,14 @@ This function must be used if projection pushdown is enabled to figure out which
|
|
|
16553
16937
|
*/
|
|
16554
16938
|
DUCKDB_API idx_t duckdb_init_get_column_index(duckdb_init_info info, idx_t column_index);
|
|
16555
16939
|
|
|
16940
|
+
/*!
|
|
16941
|
+
Sets how many threads can process this table function in parallel (default: 1)
|
|
16942
|
+
|
|
16943
|
+
* info: The info object
|
|
16944
|
+
* max_threads: The maximum amount of threads that can process this table function
|
|
16945
|
+
*/
|
|
16946
|
+
DUCKDB_API void duckdb_init_set_max_threads(duckdb_init_info info, idx_t max_threads);
|
|
16947
|
+
|
|
16556
16948
|
/*!
|
|
16557
16949
|
Report that an error has occurred while calling init.
|
|
16558
16950
|
|
|
@@ -16584,13 +16976,21 @@ For tracking state, use the init data instead.
|
|
|
16584
16976
|
DUCKDB_API void *duckdb_function_get_bind_data(duckdb_function_info info);
|
|
16585
16977
|
|
|
16586
16978
|
/*!
|
|
16587
|
-
Gets the init data set by `
|
|
16979
|
+
Gets the init data set by `duckdb_init_set_init_data` during the init.
|
|
16588
16980
|
|
|
16589
16981
|
* info: The info object
|
|
16590
16982
|
* returns: The init data object
|
|
16591
16983
|
*/
|
|
16592
16984
|
DUCKDB_API void *duckdb_function_get_init_data(duckdb_function_info info);
|
|
16593
16985
|
|
|
16986
|
+
/*!
|
|
16987
|
+
Gets the thread-local init data set by `duckdb_init_set_init_data` during the local_init.
|
|
16988
|
+
|
|
16989
|
+
* info: The info object
|
|
16990
|
+
* returns: The init data object
|
|
16991
|
+
*/
|
|
16992
|
+
DUCKDB_API void *duckdb_function_get_local_init_data(duckdb_function_info info);
|
|
16993
|
+
|
|
16594
16994
|
/*!
|
|
16595
16995
|
Report that an error has occurred while executing the function.
|
|
16596
16996
|
|
|
@@ -16896,6 +17296,19 @@ Closes the result and de-allocates all memory allocated for the arrow result.
|
|
|
16896
17296
|
*/
|
|
16897
17297
|
DUCKDB_API void duckdb_destroy_arrow(duckdb_arrow *result);
|
|
16898
17298
|
|
|
17299
|
+
//===--------------------------------------------------------------------===//
|
|
17300
|
+
// Threading Information
|
|
17301
|
+
//===--------------------------------------------------------------------===//
|
|
17302
|
+
/*!
|
|
17303
|
+
Execute DuckDB tasks on this thread.
|
|
17304
|
+
|
|
17305
|
+
Will return after `max_tasks` have been executed, or if there are no more tasks present.
|
|
17306
|
+
|
|
17307
|
+
* database: The database object to execute tasks for
|
|
17308
|
+
* max_tasks: The maximum amount of tasks to execute
|
|
17309
|
+
*/
|
|
17310
|
+
DUCKDB_API void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks);
|
|
17311
|
+
|
|
16899
17312
|
#ifdef __cplusplus
|
|
16900
17313
|
}
|
|
16901
17314
|
#endif
|
|
@@ -16958,7 +17371,7 @@ namespace duckdb {
|
|
|
16958
17371
|
|
|
16959
17372
|
class ProgressBar {
|
|
16960
17373
|
public:
|
|
16961
|
-
explicit ProgressBar(Executor &executor, idx_t show_progress_after);
|
|
17374
|
+
explicit ProgressBar(Executor &executor, idx_t show_progress_after, bool print_progress);
|
|
16962
17375
|
|
|
16963
17376
|
//! Starts the thread
|
|
16964
17377
|
void Start();
|
|
@@ -16980,6 +17393,8 @@ private:
|
|
|
16980
17393
|
idx_t show_progress_after;
|
|
16981
17394
|
//! The current progress percentage
|
|
16982
17395
|
double current_percentage;
|
|
17396
|
+
//! Whether or not we print the progress bar
|
|
17397
|
+
bool print_progress;
|
|
16983
17398
|
//! Whether or not profiling is supported for the current query
|
|
16984
17399
|
bool supported = true;
|
|
16985
17400
|
};
|
|
@@ -17014,8 +17429,8 @@ class StreamQueryResult : public QueryResult {
|
|
|
17014
17429
|
public:
|
|
17015
17430
|
//! Create a successful StreamQueryResult. StreamQueryResults should always be successful initially (it makes no
|
|
17016
17431
|
//! sense to stream an error).
|
|
17017
|
-
DUCKDB_API StreamQueryResult(StatementType statement_type,
|
|
17018
|
-
vector<LogicalType> types, vector<string> names);
|
|
17432
|
+
DUCKDB_API StreamQueryResult(StatementType statement_type, StatementProperties properties,
|
|
17433
|
+
shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names);
|
|
17019
17434
|
DUCKDB_API ~StreamQueryResult() override;
|
|
17020
17435
|
|
|
17021
17436
|
public:
|
|
@@ -17031,7 +17446,6 @@ public:
|
|
|
17031
17446
|
//! Closes the StreamQueryResult
|
|
17032
17447
|
DUCKDB_API void Close();
|
|
17033
17448
|
|
|
17034
|
-
private:
|
|
17035
17449
|
//! The client context this StreamQueryResult belongs to
|
|
17036
17450
|
shared_ptr<ClientContext> context;
|
|
17037
17451
|
|
|
@@ -17128,7 +17542,6 @@ private:
|
|
|
17128
17542
|
} // namespace duckdb
|
|
17129
17543
|
|
|
17130
17544
|
|
|
17131
|
-
#include <random>
|
|
17132
17545
|
|
|
17133
17546
|
//===----------------------------------------------------------------------===//
|
|
17134
17547
|
// DuckDB
|
|
@@ -17165,6 +17578,11 @@ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_O
|
|
|
17165
17578
|
|
|
17166
17579
|
namespace duckdb {
|
|
17167
17580
|
class ClientContext;
|
|
17581
|
+
class PhysicalResultCollector;
|
|
17582
|
+
class PreparedStatementData;
|
|
17583
|
+
|
|
17584
|
+
typedef std::function<unique_ptr<PhysicalResultCollector>(ClientContext &context, PreparedStatementData &data)>
|
|
17585
|
+
get_result_collector_t;
|
|
17168
17586
|
|
|
17169
17587
|
struct ClientConfig {
|
|
17170
17588
|
//! If the query profiler is enabled or not.
|
|
@@ -17187,6 +17605,8 @@ struct ClientConfig {
|
|
|
17187
17605
|
//! Preserve identifier case while parsing.
|
|
17188
17606
|
//! If false, all unquoted identifiers are lower-cased (e.g. "MyTable" -> "mytable").
|
|
17189
17607
|
bool preserve_identifier_case = true;
|
|
17608
|
+
//! The maximum expression depth limit in the parser
|
|
17609
|
+
idx_t max_expression_depth = 1000;
|
|
17190
17610
|
|
|
17191
17611
|
// Whether or not aggressive query verification is enabled
|
|
17192
17612
|
bool query_verification_enabled = false;
|
|
@@ -17198,6 +17618,8 @@ struct ClientConfig {
|
|
|
17198
17618
|
bool force_index_join = false;
|
|
17199
17619
|
//! Force out-of-core computation for operators that support it, used for testing
|
|
17200
17620
|
bool force_external = false;
|
|
17621
|
+
//! Force disable cross product generation when hyper graph isn't connected, used for testing
|
|
17622
|
+
bool force_no_cross_product = false;
|
|
17201
17623
|
//! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
|
|
17202
17624
|
//! elements)
|
|
17203
17625
|
idx_t perfect_ht_threshold = 12;
|
|
@@ -17208,8 +17630,14 @@ struct ClientConfig {
|
|
|
17208
17630
|
//! Generic options
|
|
17209
17631
|
case_insensitive_map_t<Value> set_variables;
|
|
17210
17632
|
|
|
17633
|
+
//! Function that is used to create the result collector for a materialized result
|
|
17634
|
+
//! Defaults to PhysicalMaterializedCollector
|
|
17635
|
+
get_result_collector_t result_collector = nullptr;
|
|
17636
|
+
|
|
17211
17637
|
public:
|
|
17212
17638
|
static ClientConfig &GetConfig(ClientContext &context);
|
|
17639
|
+
|
|
17640
|
+
static string ExtractTimezoneFromConfig(ClientConfig &config);
|
|
17213
17641
|
};
|
|
17214
17642
|
|
|
17215
17643
|
} // namespace duckdb
|
|
@@ -17248,12 +17676,19 @@ class PreparedStatementData;
|
|
|
17248
17676
|
class Relation;
|
|
17249
17677
|
class BufferedFileWriter;
|
|
17250
17678
|
class QueryProfiler;
|
|
17251
|
-
class QueryProfilerHistory;
|
|
17252
17679
|
class ClientContextLock;
|
|
17253
17680
|
struct CreateScalarFunctionInfo;
|
|
17254
17681
|
class ScalarFunctionCatalogEntry;
|
|
17255
17682
|
struct ActiveQueryContext;
|
|
17256
17683
|
struct ParserOptions;
|
|
17684
|
+
struct ClientData;
|
|
17685
|
+
|
|
17686
|
+
struct PendingQueryParameters {
|
|
17687
|
+
//! Prepared statement parameters (if any)
|
|
17688
|
+
vector<Value> *parameters = nullptr;
|
|
17689
|
+
//! Whether or not a stream result should be allowed
|
|
17690
|
+
bool allow_stream_result = false;
|
|
17691
|
+
};
|
|
17257
17692
|
|
|
17258
17693
|
//! The ClientContext holds information relevant to the current client session
|
|
17259
17694
|
//! during execution
|
|
@@ -17266,10 +17701,6 @@ public:
|
|
|
17266
17701
|
DUCKDB_API explicit ClientContext(shared_ptr<DatabaseInstance> db);
|
|
17267
17702
|
DUCKDB_API ~ClientContext();
|
|
17268
17703
|
|
|
17269
|
-
//! Query profiler
|
|
17270
|
-
shared_ptr<QueryProfiler> profiler;
|
|
17271
|
-
//! QueryProfiler History
|
|
17272
|
-
unique_ptr<QueryProfilerHistory> query_profiler_history;
|
|
17273
17704
|
//! The database that this client is connected to
|
|
17274
17705
|
shared_ptr<DatabaseInstance> db;
|
|
17275
17706
|
//! Data for the currently running transaction
|
|
@@ -17279,20 +17710,10 @@ public:
|
|
|
17279
17710
|
//! External Objects (e.g., Python objects) that views depend of
|
|
17280
17711
|
unordered_map<string, vector<shared_ptr<ExternalDependency>>> external_dependencies;
|
|
17281
17712
|
|
|
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
17713
|
//! The client configuration
|
|
17295
17714
|
ClientConfig config;
|
|
17715
|
+
//! The set of client-specific data
|
|
17716
|
+
unique_ptr<ClientData> client_data;
|
|
17296
17717
|
|
|
17297
17718
|
public:
|
|
17298
17719
|
DUCKDB_API Transaction &ActiveTransaction() {
|
|
@@ -17314,9 +17735,10 @@ public:
|
|
|
17314
17735
|
|
|
17315
17736
|
//! Issues a query to the database and returns a Pending Query Result. Note that "query" may only contain
|
|
17316
17737
|
//! a single statement.
|
|
17317
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query);
|
|
17738
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query, bool allow_stream_result);
|
|
17318
17739
|
//! Issues a query to the database and returns a Pending Query Result
|
|
17319
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement
|
|
17740
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement,
|
|
17741
|
+
bool allow_stream_result);
|
|
17320
17742
|
|
|
17321
17743
|
//! Destroy the client context
|
|
17322
17744
|
DUCKDB_API void Destroy();
|
|
@@ -17341,13 +17763,15 @@ public:
|
|
|
17341
17763
|
//! It is possible that the prepared statement will be re-bound. This will generally happen if the catalog is
|
|
17342
17764
|
//! modified in between the prepared statement being bound and the prepared statement being run.
|
|
17343
17765
|
DUCKDB_API unique_ptr<PendingQueryResult>
|
|
17344
|
-
PendingQuery(const string &query, shared_ptr<PreparedStatementData> &prepared,
|
|
17766
|
+
PendingQuery(const string &query, shared_ptr<PreparedStatementData> &prepared, PendingQueryParameters parameters);
|
|
17345
17767
|
|
|
17346
17768
|
//! Execute a prepared statement with the given name and set of parameters
|
|
17347
17769
|
//! It is possible that the prepared statement will be re-bound. This will generally happen if the catalog is
|
|
17348
17770
|
//! modified in between the prepared statement being bound and the prepared statement being run.
|
|
17349
17771
|
DUCKDB_API unique_ptr<QueryResult> Execute(const string &query, shared_ptr<PreparedStatementData> &prepared,
|
|
17350
17772
|
vector<Value> &values, bool allow_stream_result = true);
|
|
17773
|
+
DUCKDB_API unique_ptr<QueryResult> Execute(const string &query, shared_ptr<PreparedStatementData> &prepared,
|
|
17774
|
+
PendingQueryParameters parameters);
|
|
17351
17775
|
|
|
17352
17776
|
//! Gets current percentage of the query's progress, returns 0 in case the progress bar is disabled.
|
|
17353
17777
|
DUCKDB_API double GetProgress();
|
|
@@ -17396,9 +17820,8 @@ private:
|
|
|
17396
17820
|
string &error);
|
|
17397
17821
|
//! Issues a query to the database and returns a Pending Query Result
|
|
17398
17822
|
unique_ptr<PendingQueryResult> PendingQueryInternal(ClientContextLock &lock, unique_ptr<SQLStatement> statement,
|
|
17399
|
-
bool verify = true);
|
|
17400
|
-
unique_ptr<QueryResult> ExecutePendingQueryInternal(ClientContextLock &lock, PendingQueryResult &query
|
|
17401
|
-
bool allow_stream_result);
|
|
17823
|
+
PendingQueryParameters parameters, bool verify = true);
|
|
17824
|
+
unique_ptr<QueryResult> ExecutePendingQueryInternal(ClientContextLock &lock, PendingQueryResult &query);
|
|
17402
17825
|
|
|
17403
17826
|
//! Parse statements from a query
|
|
17404
17827
|
vector<unique_ptr<SQLStatement>> ParseStatementsInternal(ClientContextLock &lock, const string &query);
|
|
@@ -17410,28 +17833,28 @@ private:
|
|
|
17410
17833
|
//! Internal clean up, does not lock. Caller must hold the context_lock.
|
|
17411
17834
|
void CleanupInternal(ClientContextLock &lock, BaseQueryResult *result = nullptr,
|
|
17412
17835
|
bool invalidate_transaction = false);
|
|
17413
|
-
string FinalizeQuery(ClientContextLock &lock, bool success);
|
|
17414
17836
|
unique_ptr<PendingQueryResult> PendingStatementOrPreparedStatement(ClientContextLock &lock, const string &query,
|
|
17415
17837
|
unique_ptr<SQLStatement> statement,
|
|
17416
17838
|
shared_ptr<PreparedStatementData> &prepared,
|
|
17417
|
-
|
|
17839
|
+
PendingQueryParameters parameters);
|
|
17418
17840
|
unique_ptr<PendingQueryResult> PendingPreparedStatement(ClientContextLock &lock,
|
|
17419
17841
|
shared_ptr<PreparedStatementData> statement_p,
|
|
17420
|
-
|
|
17842
|
+
PendingQueryParameters parameters);
|
|
17421
17843
|
|
|
17422
17844
|
//! Internally prepare a SQL statement. Caller must hold the context_lock.
|
|
17423
17845
|
shared_ptr<PreparedStatementData> CreatePreparedStatement(ClientContextLock &lock, const string &query,
|
|
17424
|
-
unique_ptr<SQLStatement> statement
|
|
17846
|
+
unique_ptr<SQLStatement> statement,
|
|
17847
|
+
vector<Value> *values = nullptr);
|
|
17425
17848
|
unique_ptr<PendingQueryResult> PendingStatementInternal(ClientContextLock &lock, const string &query,
|
|
17426
|
-
unique_ptr<SQLStatement> statement
|
|
17849
|
+
unique_ptr<SQLStatement> statement,
|
|
17850
|
+
PendingQueryParameters parameters);
|
|
17427
17851
|
unique_ptr<QueryResult> RunStatementInternal(ClientContextLock &lock, const string &query,
|
|
17428
17852
|
unique_ptr<SQLStatement> statement, bool allow_stream_result,
|
|
17429
17853
|
bool verify = true);
|
|
17430
17854
|
unique_ptr<PreparedStatement> PrepareInternal(ClientContextLock &lock, unique_ptr<SQLStatement> statement);
|
|
17431
17855
|
void LogQueryInternal(ClientContextLock &lock, const string &query);
|
|
17432
17856
|
|
|
17433
|
-
unique_ptr<QueryResult> FetchResultInternal(ClientContextLock &lock, PendingQueryResult &pending
|
|
17434
|
-
bool allow_stream_result);
|
|
17857
|
+
unique_ptr<QueryResult> FetchResultInternal(ClientContextLock &lock, PendingQueryResult &pending);
|
|
17435
17858
|
unique_ptr<DataChunk> FetchInternal(ClientContextLock &lock, Executor &executor, BaseQueryResult &result);
|
|
17436
17859
|
|
|
17437
17860
|
unique_ptr<ClientContextLock> LockContext();
|
|
@@ -17444,14 +17867,13 @@ private:
|
|
|
17444
17867
|
|
|
17445
17868
|
PendingExecutionResult ExecuteTaskInternal(ClientContextLock &lock, PendingQueryResult &result);
|
|
17446
17869
|
|
|
17447
|
-
unique_ptr<PendingQueryResult>
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
shared_ptr<PreparedStatementData> &prepared, vector<Value> *values);
|
|
17870
|
+
unique_ptr<PendingQueryResult> PendingStatementOrPreparedStatementInternal(
|
|
17871
|
+
ClientContextLock &lock, const string &query, unique_ptr<SQLStatement> statement,
|
|
17872
|
+
shared_ptr<PreparedStatementData> &prepared, PendingQueryParameters parameters);
|
|
17451
17873
|
|
|
17452
17874
|
unique_ptr<PendingQueryResult> PendingQueryPreparedInternal(ClientContextLock &lock, const string &query,
|
|
17453
17875
|
shared_ptr<PreparedStatementData> &prepared,
|
|
17454
|
-
|
|
17876
|
+
PendingQueryParameters parameters);
|
|
17455
17877
|
|
|
17456
17878
|
private:
|
|
17457
17879
|
//! Lock on using the ClientContext in parallel
|
|
@@ -17695,9 +18117,10 @@ public:
|
|
|
17695
18117
|
|
|
17696
18118
|
//! Issues a query to the database and returns a Pending Query Result. Note that "query" may only contain
|
|
17697
18119
|
//! a single statement.
|
|
17698
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query);
|
|
18120
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query, bool allow_stream_result = false);
|
|
17699
18121
|
//! Issues a query to the database and returns a Pending Query Result
|
|
17700
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement
|
|
18122
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement,
|
|
18123
|
+
bool allow_stream_result = false);
|
|
17701
18124
|
|
|
17702
18125
|
//! Prepare the specified query, returning a prepared statement object
|
|
17703
18126
|
DUCKDB_API unique_ptr<PreparedStatement> Prepare(const string &query);
|
|
@@ -17988,21 +18411,6 @@ struct ReplacementScan {
|
|
|
17988
18411
|
|
|
17989
18412
|
} // namespace duckdb
|
|
17990
18413
|
|
|
17991
|
-
//===----------------------------------------------------------------------===//
|
|
17992
|
-
// DuckDB
|
|
17993
|
-
//
|
|
17994
|
-
// duckdb/common/set.hpp
|
|
17995
|
-
//
|
|
17996
|
-
//
|
|
17997
|
-
//===----------------------------------------------------------------------===//
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
#include <set>
|
|
18002
|
-
|
|
18003
|
-
namespace duckdb {
|
|
18004
|
-
using std::set;
|
|
18005
|
-
}
|
|
18006
18414
|
|
|
18007
18415
|
|
|
18008
18416
|
//===----------------------------------------------------------------------===//
|
|
@@ -18158,6 +18566,8 @@ public:
|
|
|
18158
18566
|
idx_t maximum_memory = (idx_t)-1;
|
|
18159
18567
|
//! The maximum amount of CPU threads used by the database system. Default: all available.
|
|
18160
18568
|
idx_t maximum_threads = (idx_t)-1;
|
|
18569
|
+
//! The number of external threads that work on DuckDB tasks. Default: none.
|
|
18570
|
+
idx_t external_threads = 0;
|
|
18161
18571
|
//! Whether or not to create and use a temporary directory to store intermediates that do not fit in memory
|
|
18162
18572
|
bool use_temporary_directory = true;
|
|
18163
18573
|
//! Directory to store temporary structures that do not fit in memory
|
|
@@ -18191,6 +18601,8 @@ public:
|
|
|
18191
18601
|
bool debug_many_free_list_blocks = false;
|
|
18192
18602
|
//! Debug setting for window aggregation mode: (window, combine, separate)
|
|
18193
18603
|
WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
|
|
18604
|
+
//! Whether or not preserving insertion order should be preserved
|
|
18605
|
+
bool preserve_insertion_order = true;
|
|
18194
18606
|
|
|
18195
18607
|
//! Extra parameters that can be SET for loaded extensions
|
|
18196
18608
|
case_insensitive_map_t<ExtensionOption> extension_parameters;
|
|
@@ -18427,14 +18839,14 @@ public:
|
|
|
18427
18839
|
static const int8_t MONTH_PER_DAY_OF_YEAR[365];
|
|
18428
18840
|
static const int8_t LEAP_MONTH_PER_DAY_OF_YEAR[366];
|
|
18429
18841
|
|
|
18430
|
-
// min date is 5877642-06-
|
|
18842
|
+
// min date is 5877642-06-25 (BC) (-2^31+2)
|
|
18431
18843
|
constexpr static const int32_t DATE_MIN_YEAR = -5877641;
|
|
18432
18844
|
constexpr static const int32_t DATE_MIN_MONTH = 6;
|
|
18433
|
-
constexpr static const int32_t DATE_MIN_DAY =
|
|
18434
|
-
// max date is 5881580-07-
|
|
18845
|
+
constexpr static const int32_t DATE_MIN_DAY = 25;
|
|
18846
|
+
// max date is 5881580-07-10 (2^31-2)
|
|
18435
18847
|
constexpr static const int32_t DATE_MAX_YEAR = 5881580;
|
|
18436
18848
|
constexpr static const int32_t DATE_MAX_MONTH = 7;
|
|
18437
|
-
constexpr static const int32_t DATE_MAX_DAY =
|
|
18849
|
+
constexpr static const int32_t DATE_MAX_DAY = 10;
|
|
18438
18850
|
constexpr static const int32_t EPOCH_YEAR = 1970;
|
|
18439
18851
|
|
|
18440
18852
|
constexpr static const int32_t YEAR_INTERVAL = 400;
|
|
@@ -18467,6 +18879,11 @@ public:
|
|
|
18467
18879
|
//! date
|
|
18468
18880
|
DUCKDB_API static bool IsValid(int32_t year, int32_t month, int32_t day);
|
|
18469
18881
|
|
|
18882
|
+
//! Returns true if the specified date is finite
|
|
18883
|
+
static inline bool IsFinite(date_t date) {
|
|
18884
|
+
return date != date_t::infinity() && date != date_t::ninfinity();
|
|
18885
|
+
}
|
|
18886
|
+
|
|
18470
18887
|
//! The max number of days in a month of a given year
|
|
18471
18888
|
DUCKDB_API static int32_t MonthDays(int32_t year, int32_t month);
|
|
18472
18889
|
|
|
@@ -18667,15 +19084,6 @@ public:
|
|
|
18667
19084
|
|
|
18668
19085
|
namespace duckdb {
|
|
18669
19086
|
|
|
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
19087
|
//! The Timestamp class is a static class that holds helper functions for the Timestamp
|
|
18680
19088
|
//! type.
|
|
18681
19089
|
class Timestamp {
|
|
@@ -18700,6 +19108,11 @@ public:
|
|
|
18700
19108
|
DUCKDB_API static timestamp_t FromDatetime(date_t date, dtime_t time);
|
|
18701
19109
|
DUCKDB_API static bool TryFromDatetime(date_t date, dtime_t time, timestamp_t &result);
|
|
18702
19110
|
|
|
19111
|
+
//! Is the timestamp finite or infinite?
|
|
19112
|
+
static inline bool IsFinite(timestamp_t timestamp) {
|
|
19113
|
+
return timestamp != timestamp_t::infinity() && timestamp != timestamp_t::ninfinity();
|
|
19114
|
+
}
|
|
19115
|
+
|
|
18703
19116
|
//! Extract the date and time from a given timestamp object
|
|
18704
19117
|
DUCKDB_API static void Convert(timestamp_t date, date_t &out_date, dtime_t &out_time);
|
|
18705
19118
|
//! Returns current timestamp
|
|
@@ -19350,6 +19763,7 @@ public:
|
|
|
19350
19763
|
|
|
19351
19764
|
|
|
19352
19765
|
|
|
19766
|
+
|
|
19353
19767
|
namespace duckdb {
|
|
19354
19768
|
|
|
19355
19769
|
struct CreateTableInfo : public CreateInfo {
|
|
@@ -19973,11 +20387,14 @@ public:
|
|
|
19973
20387
|
|
|
19974
20388
|
|
|
19975
20389
|
|
|
20390
|
+
|
|
20391
|
+
|
|
19976
20392
|
namespace duckdb {
|
|
19977
20393
|
class CatalogEntry;
|
|
19978
20394
|
|
|
19979
20395
|
struct BoundCreateTableInfo {
|
|
19980
|
-
explicit BoundCreateTableInfo(unique_ptr<CreateInfo>
|
|
20396
|
+
explicit BoundCreateTableInfo(unique_ptr<CreateInfo> base_p) : base(move(base_p)) {
|
|
20397
|
+
D_ASSERT(base);
|
|
19981
20398
|
}
|
|
19982
20399
|
|
|
19983
20400
|
//! The schema to create the table in
|
|
@@ -19986,6 +20403,8 @@ struct BoundCreateTableInfo {
|
|
|
19986
20403
|
unique_ptr<CreateInfo> base;
|
|
19987
20404
|
//! The map of column names -> column index, used during binding
|
|
19988
20405
|
case_insensitive_map_t<column_t> name_map;
|
|
20406
|
+
//! Column dependency manager of the table
|
|
20407
|
+
ColumnDependencyManager column_dependency_manager;
|
|
19989
20408
|
//! List of constraints on the table
|
|
19990
20409
|
vector<unique_ptr<Constraint>> constraints;
|
|
19991
20410
|
//! List of bound constraints on the table
|
|
@@ -20000,6 +20419,7 @@ struct BoundCreateTableInfo {
|
|
|
20000
20419
|
unique_ptr<LogicalOperator> query;
|
|
20001
20420
|
|
|
20002
20421
|
CreateTableInfo &Base() {
|
|
20422
|
+
D_ASSERT(base);
|
|
20003
20423
|
return (CreateTableInfo &)*base;
|
|
20004
20424
|
}
|
|
20005
20425
|
};
|
|
@@ -20973,6 +21393,32 @@ private:
|
|
|
20973
21393
|
|
|
20974
21394
|
|
|
20975
21395
|
|
|
21396
|
+
//===----------------------------------------------------------------------===//
|
|
21397
|
+
// DuckDB
|
|
21398
|
+
//
|
|
21399
|
+
// duckdb/storage/statistics/column_statistics.hpp
|
|
21400
|
+
//
|
|
21401
|
+
//
|
|
21402
|
+
//===----------------------------------------------------------------------===//
|
|
21403
|
+
|
|
21404
|
+
|
|
21405
|
+
|
|
21406
|
+
|
|
21407
|
+
|
|
21408
|
+
namespace duckdb {
|
|
21409
|
+
|
|
21410
|
+
class ColumnStatistics {
|
|
21411
|
+
public:
|
|
21412
|
+
explicit ColumnStatistics(unique_ptr<BaseStatistics> stats_p);
|
|
21413
|
+
|
|
21414
|
+
unique_ptr<BaseStatistics> stats;
|
|
21415
|
+
|
|
21416
|
+
public:
|
|
21417
|
+
static shared_ptr<ColumnStatistics> CreateEmptyStats(const LogicalType &type);
|
|
21418
|
+
};
|
|
21419
|
+
|
|
21420
|
+
} // namespace duckdb
|
|
21421
|
+
|
|
20976
21422
|
|
|
20977
21423
|
|
|
20978
21424
|
|
|
@@ -21207,7 +21653,7 @@ private:
|
|
|
21207
21653
|
//! The segment trees holding the various row_groups of the table
|
|
21208
21654
|
shared_ptr<SegmentTree> row_groups;
|
|
21209
21655
|
//! Column statistics
|
|
21210
|
-
vector<
|
|
21656
|
+
vector<shared_ptr<ColumnStatistics>> column_stats;
|
|
21211
21657
|
//! The statistics lock
|
|
21212
21658
|
mutex stats_lock;
|
|
21213
21659
|
//! Whether or not the data table is the root DataTable for this table; the root DataTable is the newest version
|
|
@@ -21373,6 +21819,7 @@ namespace duckdb {
|
|
|
21373
21819
|
|
|
21374
21820
|
struct ParserOptions {
|
|
21375
21821
|
bool preserve_identifier_case = true;
|
|
21822
|
+
idx_t max_expression_depth = 1000;
|
|
21376
21823
|
};
|
|
21377
21824
|
|
|
21378
21825
|
//! The parser is responsible for parsing the query and converting it into a set
|
|
@@ -21616,7 +22063,7 @@ class Vector;
|
|
|
21616
22063
|
|
|
21617
22064
|
class ValidityStatistics : public BaseStatistics {
|
|
21618
22065
|
public:
|
|
21619
|
-
ValidityStatistics(bool has_null = false, bool has_no_null = true);
|
|
22066
|
+
explicit ValidityStatistics(bool has_null = false, bool has_no_null = true);
|
|
21620
22067
|
|
|
21621
22068
|
//! Whether or not the segment can contain NULL values
|
|
21622
22069
|
bool has_null;
|
|
@@ -21629,8 +22076,10 @@ public:
|
|
|
21629
22076
|
bool IsConstant() const override;
|
|
21630
22077
|
|
|
21631
22078
|
unique_ptr<BaseStatistics> Copy() const override;
|
|
22079
|
+
|
|
21632
22080
|
void Serialize(FieldWriter &writer) const override;
|
|
21633
|
-
static unique_ptr<
|
|
22081
|
+
static unique_ptr<ValidityStatistics> Deserialize(FieldReader &reader);
|
|
22082
|
+
|
|
21634
22083
|
void Verify(Vector &vector, const SelectionVector &sel, idx_t count) const override;
|
|
21635
22084
|
|
|
21636
22085
|
static unique_ptr<BaseStatistics> Combine(const unique_ptr<BaseStatistics> &lstats,
|
|
@@ -21649,7 +22098,7 @@ public:
|
|
|
21649
22098
|
constexpr static uint32_t MAX_STRING_MINMAX_SIZE = 8;
|
|
21650
22099
|
|
|
21651
22100
|
public:
|
|
21652
|
-
explicit StringStatistics(LogicalType type);
|
|
22101
|
+
explicit StringStatistics(LogicalType type, StatisticsType stats_type);
|
|
21653
22102
|
|
|
21654
22103
|
//! The minimum value of the segment, potentially truncated
|
|
21655
22104
|
data_t min[MAX_STRING_MINMAX_SIZE];
|
|
@@ -21743,8 +22192,8 @@ namespace duckdb {
|
|
|
21743
22192
|
|
|
21744
22193
|
class NumericStatistics : public BaseStatistics {
|
|
21745
22194
|
public:
|
|
21746
|
-
explicit NumericStatistics(LogicalType type);
|
|
21747
|
-
NumericStatistics(LogicalType type, Value min, Value max);
|
|
22195
|
+
explicit NumericStatistics(LogicalType type, StatisticsType stats_type);
|
|
22196
|
+
NumericStatistics(LogicalType type, Value min, Value max, StatisticsType stats_type);
|
|
21748
22197
|
|
|
21749
22198
|
//! The minimum value of the segment
|
|
21750
22199
|
Value min;
|
|
@@ -22048,10 +22497,25 @@ protected:
|
|
|
22048
22497
|
|
|
22049
22498
|
|
|
22050
22499
|
|
|
22500
|
+
//===----------------------------------------------------------------------===//
|
|
22501
|
+
// DuckDB
|
|
22502
|
+
//
|
|
22503
|
+
// duckdb/common/queue.hpp
|
|
22504
|
+
//
|
|
22505
|
+
//
|
|
22506
|
+
//===----------------------------------------------------------------------===//
|
|
22507
|
+
|
|
22508
|
+
|
|
22051
22509
|
|
|
22052
|
-
#include <sstream>
|
|
22053
22510
|
#include <queue>
|
|
22054
22511
|
|
|
22512
|
+
namespace duckdb {
|
|
22513
|
+
using std::queue;
|
|
22514
|
+
}
|
|
22515
|
+
|
|
22516
|
+
|
|
22517
|
+
#include <sstream>
|
|
22518
|
+
|
|
22055
22519
|
namespace duckdb {
|
|
22056
22520
|
struct CopyInfo;
|
|
22057
22521
|
struct CSVFileHandle;
|
|
@@ -22088,13 +22552,10 @@ struct TextSearchShiftArray {
|
|
|
22088
22552
|
};
|
|
22089
22553
|
|
|
22090
22554
|
struct BufferedCSVReaderOptions {
|
|
22091
|
-
|
|
22092
|
-
|
|
22093
|
-
|
|
22094
|
-
|
|
22095
|
-
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
|
22096
|
-
//! Whether or not to automatically detect dialect and datatypes
|
|
22097
|
-
bool auto_detect = false;
|
|
22555
|
+
//===--------------------------------------------------------------------===//
|
|
22556
|
+
// CommonCSVOptions
|
|
22557
|
+
//===--------------------------------------------------------------------===//
|
|
22558
|
+
|
|
22098
22559
|
//! Whether or not a delimiter was defined by the user
|
|
22099
22560
|
bool has_delimiter = false;
|
|
22100
22561
|
//! Delimiter to separate columns within each line
|
|
@@ -22113,33 +22574,67 @@ struct BufferedCSVReaderOptions {
|
|
|
22113
22574
|
bool header = false;
|
|
22114
22575
|
//! Whether or not we should ignore InvalidInput errors
|
|
22115
22576
|
bool ignore_errors = false;
|
|
22116
|
-
//! Whether or not header names shall be normalized
|
|
22117
|
-
bool normalize_names = false;
|
|
22118
|
-
//! How many leading rows to skip
|
|
22119
|
-
idx_t skip_rows = 0;
|
|
22120
22577
|
//! Expected number of columns
|
|
22121
22578
|
idx_t num_cols = 0;
|
|
22579
|
+
//! Number of samples to buffer
|
|
22580
|
+
idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
|
|
22122
22581
|
//! Specifies the string that represents a null value
|
|
22123
22582
|
string null_str;
|
|
22583
|
+
//! Whether file is compressed or not, and if so which compression type
|
|
22584
|
+
//! AUTO_DETECT (default; infer from file extension)
|
|
22585
|
+
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
|
22586
|
+
|
|
22587
|
+
//===--------------------------------------------------------------------===//
|
|
22588
|
+
// ReadCSVOptions
|
|
22589
|
+
//===--------------------------------------------------------------------===//
|
|
22590
|
+
|
|
22591
|
+
//! How many leading rows to skip
|
|
22592
|
+
idx_t skip_rows = 0;
|
|
22593
|
+
//! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
|
|
22594
|
+
//! note that this is the guaranteed line length that will succeed, longer lines may be accepted if slightly above
|
|
22595
|
+
idx_t maximum_line_size = 2097152;
|
|
22596
|
+
//! Whether or not header names shall be normalized
|
|
22597
|
+
bool normalize_names = false;
|
|
22124
22598
|
//! True, if column with that index must skip null check
|
|
22125
22599
|
vector<bool> force_not_null;
|
|
22600
|
+
//! Consider all columns to be of type varchar
|
|
22601
|
+
bool all_varchar = false;
|
|
22126
22602
|
//! Size of sample chunk used for dialect and type detection
|
|
22127
22603
|
idx_t sample_chunk_size = STANDARD_VECTOR_SIZE;
|
|
22128
22604
|
//! Number of sample chunks used for type detection
|
|
22129
22605
|
idx_t sample_chunks = 10;
|
|
22130
|
-
//!
|
|
22131
|
-
|
|
22132
|
-
//!
|
|
22133
|
-
|
|
22134
|
-
//!
|
|
22135
|
-
|
|
22606
|
+
//! Whether or not to automatically detect dialect and datatypes
|
|
22607
|
+
bool auto_detect = false;
|
|
22608
|
+
//! The file path of the CSV file to read
|
|
22609
|
+
string file_path;
|
|
22610
|
+
//! Whether or not to include a file name column
|
|
22611
|
+
bool include_file_name = false;
|
|
22136
22612
|
|
|
22137
|
-
|
|
22138
|
-
|
|
22613
|
+
//===--------------------------------------------------------------------===//
|
|
22614
|
+
// WriteCSVOptions
|
|
22615
|
+
//===--------------------------------------------------------------------===//
|
|
22616
|
+
|
|
22617
|
+
//! The column names of the columns to write
|
|
22618
|
+
vector<string> names;
|
|
22619
|
+
//! True, if column with that index must be quoted
|
|
22620
|
+
vector<bool> force_quote;
|
|
22621
|
+
|
|
22622
|
+
//! The date format to use (if any is specified)
|
|
22623
|
+
std::map<LogicalTypeId, StrpTimeFormat> date_format = {{LogicalTypeId::DATE, {}}, {LogicalTypeId::TIMESTAMP, {}}};
|
|
22139
22624
|
//! Whether or not a type format is specified
|
|
22140
22625
|
std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
|
|
22141
22626
|
|
|
22142
22627
|
void SetDelimiter(const string &delimiter);
|
|
22628
|
+
//! Set an option that is supported by both reading and writing functions, called by
|
|
22629
|
+
//! the SetReadOption and SetWriteOption methods
|
|
22630
|
+
bool SetBaseOption(const string &loption, const Value &value);
|
|
22631
|
+
|
|
22632
|
+
//! loption - lowercase string
|
|
22633
|
+
//! set - argument(s) to the option
|
|
22634
|
+
//! expected_names - names expected if the option is "columns"
|
|
22635
|
+
void SetReadOption(const string &loption, const Value &value, vector<string> &expected_names);
|
|
22636
|
+
|
|
22637
|
+
void SetWriteOption(const string &loption, const Value &value);
|
|
22143
22638
|
|
|
22144
22639
|
std::string ToString() const;
|
|
22145
22640
|
};
|
|
@@ -22150,6 +22645,8 @@ enum class ParserMode : uint8_t { PARSING = 0, SNIFFING_DIALECT = 1, SNIFFING_DA
|
|
|
22150
22645
|
class BufferedCSVReader {
|
|
22151
22646
|
//! Initial buffer read size; can be extended for long lines
|
|
22152
22647
|
static constexpr idx_t INITIAL_BUFFER_SIZE = 16384;
|
|
22648
|
+
//! Larger buffer size for non disk files
|
|
22649
|
+
static constexpr idx_t INITIAL_BUFFER_SIZE_LARGE = 10000000; // 10MB
|
|
22153
22650
|
ParserMode mode;
|
|
22154
22651
|
|
|
22155
22652
|
public:
|
|
@@ -22419,7 +22916,7 @@ private:
|
|
|
22419
22916
|
//===----------------------------------------------------------------------===//
|
|
22420
22917
|
// DuckDB
|
|
22421
22918
|
//
|
|
22422
|
-
// duckdb/parser/expression/
|
|
22919
|
+
// duckdb/parser/expression/comparison_expression.hpp
|
|
22423
22920
|
//
|
|
22424
22921
|
//
|
|
22425
22922
|
//===----------------------------------------------------------------------===//
|
|
@@ -22428,72 +22925,38 @@ private:
|
|
|
22428
22925
|
|
|
22429
22926
|
|
|
22430
22927
|
|
|
22431
|
-
|
|
22432
22928
|
namespace duckdb {
|
|
22433
|
-
|
|
22434
|
-
//!
|
|
22435
|
-
|
|
22436
|
-
//! 2. An OperatorExpression with the "->" operator
|
|
22437
|
-
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
22438
|
-
class LambdaExpression : public ParsedExpression {
|
|
22929
|
+
//! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
|
|
22930
|
+
//! and has two children.
|
|
22931
|
+
class ComparisonExpression : public ParsedExpression {
|
|
22439
22932
|
public:
|
|
22440
|
-
|
|
22933
|
+
DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
22934
|
+
unique_ptr<ParsedExpression> right);
|
|
22441
22935
|
|
|
22442
|
-
unique_ptr<ParsedExpression>
|
|
22443
|
-
unique_ptr<ParsedExpression>
|
|
22936
|
+
unique_ptr<ParsedExpression> left;
|
|
22937
|
+
unique_ptr<ParsedExpression> right;
|
|
22444
22938
|
|
|
22445
22939
|
public:
|
|
22446
22940
|
string ToString() const override;
|
|
22447
22941
|
|
|
22448
|
-
static bool Equals(const
|
|
22449
|
-
hash_t Hash() const override;
|
|
22942
|
+
static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
|
|
22450
22943
|
|
|
22451
22944
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22452
22945
|
|
|
22453
22946
|
void Serialize(FieldWriter &writer) const override;
|
|
22454
22947
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22455
|
-
};
|
|
22456
|
-
|
|
22457
|
-
} // namespace duckdb
|
|
22458
|
-
//===----------------------------------------------------------------------===//
|
|
22459
|
-
// DuckDB
|
|
22460
|
-
//
|
|
22461
|
-
// duckdb/parser/expression/collate_expression.hpp
|
|
22462
|
-
//
|
|
22463
|
-
//
|
|
22464
|
-
//===----------------------------------------------------------------------===//
|
|
22465
|
-
|
|
22466
|
-
|
|
22467
|
-
|
|
22468
|
-
|
|
22469
|
-
|
|
22470
|
-
namespace duckdb {
|
|
22471
|
-
|
|
22472
|
-
//! CollateExpression represents a COLLATE statement
|
|
22473
|
-
class CollateExpression : public ParsedExpression {
|
|
22474
|
-
public:
|
|
22475
|
-
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
22476
|
-
|
|
22477
|
-
//! The child of the cast expression
|
|
22478
|
-
unique_ptr<ParsedExpression> child;
|
|
22479
|
-
//! The collation clause
|
|
22480
|
-
string collation;
|
|
22481
22948
|
|
|
22482
22949
|
public:
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
22488
|
-
|
|
22489
|
-
void Serialize(FieldWriter &writer) const override;
|
|
22490
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22950
|
+
template <class T, class BASE>
|
|
22951
|
+
static string ToString(const T &entry) {
|
|
22952
|
+
return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
|
|
22953
|
+
}
|
|
22491
22954
|
};
|
|
22492
22955
|
} // namespace duckdb
|
|
22493
22956
|
//===----------------------------------------------------------------------===//
|
|
22494
22957
|
// DuckDB
|
|
22495
22958
|
//
|
|
22496
|
-
// duckdb/parser/expression/
|
|
22959
|
+
// duckdb/parser/expression/default_expression.hpp
|
|
22497
22960
|
//
|
|
22498
22961
|
//
|
|
22499
22962
|
//===----------------------------------------------------------------------===//
|
|
@@ -22503,35 +22966,24 @@ public:
|
|
|
22503
22966
|
|
|
22504
22967
|
|
|
22505
22968
|
namespace duckdb {
|
|
22506
|
-
|
|
22507
|
-
class
|
|
22969
|
+
//! Represents the default value of a column
|
|
22970
|
+
class DefaultExpression : public ParsedExpression {
|
|
22508
22971
|
public:
|
|
22509
|
-
|
|
22510
|
-
unique_ptr<ParsedExpression> upper);
|
|
22511
|
-
|
|
22512
|
-
unique_ptr<ParsedExpression> input;
|
|
22513
|
-
unique_ptr<ParsedExpression> lower;
|
|
22514
|
-
unique_ptr<ParsedExpression> upper;
|
|
22972
|
+
DefaultExpression();
|
|
22515
22973
|
|
|
22516
22974
|
public:
|
|
22517
|
-
|
|
22975
|
+
bool IsScalar() const override {
|
|
22976
|
+
return false;
|
|
22977
|
+
}
|
|
22518
22978
|
|
|
22519
|
-
|
|
22979
|
+
string ToString() const override;
|
|
22520
22980
|
|
|
22521
22981
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22522
22982
|
|
|
22523
22983
|
void Serialize(FieldWriter &writer) const override;
|
|
22524
22984
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22525
|
-
|
|
22526
|
-
public:
|
|
22527
|
-
template <class T, class BASE>
|
|
22528
|
-
static string ToString(const T &entry) {
|
|
22529
|
-
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
22530
|
-
}
|
|
22531
22985
|
};
|
|
22532
22986
|
} // namespace duckdb
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
22987
|
//===----------------------------------------------------------------------===//
|
|
22536
22988
|
// DuckDB
|
|
22537
22989
|
//
|
|
@@ -22584,11 +23036,10 @@ public:
|
|
|
22584
23036
|
}
|
|
22585
23037
|
};
|
|
22586
23038
|
} // namespace duckdb
|
|
22587
|
-
|
|
22588
23039
|
//===----------------------------------------------------------------------===//
|
|
22589
23040
|
// DuckDB
|
|
22590
23041
|
//
|
|
22591
|
-
// duckdb/parser/expression/
|
|
23042
|
+
// duckdb/parser/expression/positional_reference_expression.hpp
|
|
22592
23043
|
//
|
|
22593
23044
|
//
|
|
22594
23045
|
//===----------------------------------------------------------------------===//
|
|
@@ -22597,46 +23048,32 @@ public:
|
|
|
22597
23048
|
|
|
22598
23049
|
|
|
22599
23050
|
|
|
22600
|
-
|
|
22601
23051
|
namespace duckdb {
|
|
22602
|
-
|
|
22603
|
-
//! CastExpression represents a type cast from one SQL type to another SQL type
|
|
22604
|
-
class CastExpression : public ParsedExpression {
|
|
23052
|
+
class PositionalReferenceExpression : public ParsedExpression {
|
|
22605
23053
|
public:
|
|
22606
|
-
DUCKDB_API
|
|
23054
|
+
DUCKDB_API PositionalReferenceExpression(idx_t index);
|
|
22607
23055
|
|
|
22608
|
-
|
|
22609
|
-
unique_ptr<ParsedExpression> child;
|
|
22610
|
-
//! The type to cast to
|
|
22611
|
-
LogicalType cast_type;
|
|
22612
|
-
//! Whether or not this is a try_cast expression
|
|
22613
|
-
bool try_cast;
|
|
23056
|
+
idx_t index;
|
|
22614
23057
|
|
|
22615
23058
|
public:
|
|
22616
|
-
|
|
23059
|
+
bool IsScalar() const override {
|
|
23060
|
+
return false;
|
|
23061
|
+
}
|
|
22617
23062
|
|
|
22618
|
-
|
|
23063
|
+
string ToString() const override;
|
|
22619
23064
|
|
|
23065
|
+
static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
|
|
22620
23066
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23067
|
+
hash_t Hash() const override;
|
|
22621
23068
|
|
|
22622
23069
|
void Serialize(FieldWriter &writer) const override;
|
|
22623
23070
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22624
|
-
|
|
22625
|
-
public:
|
|
22626
|
-
template <class T, class BASE>
|
|
22627
|
-
static string ToString(const T &entry) {
|
|
22628
|
-
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
22629
|
-
entry.cast_type.ToString() + ")";
|
|
22630
|
-
}
|
|
22631
23071
|
};
|
|
22632
23072
|
} // namespace duckdb
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
23073
|
//===----------------------------------------------------------------------===//
|
|
22637
23074
|
// DuckDB
|
|
22638
23075
|
//
|
|
22639
|
-
// duckdb/parser/expression/
|
|
23076
|
+
// duckdb/parser/expression/conjunction_expression.hpp
|
|
22640
23077
|
//
|
|
22641
23078
|
//
|
|
22642
23079
|
//===----------------------------------------------------------------------===//
|
|
@@ -22645,21 +23082,25 @@ public:
|
|
|
22645
23082
|
|
|
22646
23083
|
|
|
22647
23084
|
|
|
23085
|
+
|
|
22648
23086
|
namespace duckdb {
|
|
22649
|
-
|
|
22650
|
-
//!
|
|
22651
|
-
class
|
|
23087
|
+
|
|
23088
|
+
//! Represents a conjunction (AND/OR)
|
|
23089
|
+
class ConjunctionExpression : public ParsedExpression {
|
|
22652
23090
|
public:
|
|
22653
|
-
DUCKDB_API
|
|
22654
|
-
|
|
23091
|
+
DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
|
|
23092
|
+
DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23093
|
+
DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
23094
|
+
unique_ptr<ParsedExpression> right);
|
|
22655
23095
|
|
|
22656
|
-
unique_ptr<ParsedExpression
|
|
22657
|
-
unique_ptr<ParsedExpression> right;
|
|
23096
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
22658
23097
|
|
|
22659
23098
|
public:
|
|
23099
|
+
void AddExpression(unique_ptr<ParsedExpression> expr);
|
|
23100
|
+
|
|
22660
23101
|
string ToString() const override;
|
|
22661
23102
|
|
|
22662
|
-
static bool Equals(const
|
|
23103
|
+
static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
|
|
22663
23104
|
|
|
22664
23105
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22665
23106
|
|
|
@@ -22669,15 +23110,18 @@ public:
|
|
|
22669
23110
|
public:
|
|
22670
23111
|
template <class T, class BASE>
|
|
22671
23112
|
static string ToString(const T &entry) {
|
|
22672
|
-
|
|
23113
|
+
string result = "(" + entry.children[0]->ToString();
|
|
23114
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
23115
|
+
result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
|
|
23116
|
+
}
|
|
23117
|
+
return result + ")";
|
|
22673
23118
|
}
|
|
22674
23119
|
};
|
|
22675
23120
|
} // namespace duckdb
|
|
22676
|
-
|
|
22677
23121
|
//===----------------------------------------------------------------------===//
|
|
22678
23122
|
// DuckDB
|
|
22679
23123
|
//
|
|
22680
|
-
// duckdb/parser/expression/
|
|
23124
|
+
// duckdb/parser/expression/subquery_expression.hpp
|
|
22681
23125
|
//
|
|
22682
23126
|
//
|
|
22683
23127
|
//===----------------------------------------------------------------------===//
|
|
@@ -22687,46 +23131,46 @@ public:
|
|
|
22687
23131
|
|
|
22688
23132
|
|
|
22689
23133
|
|
|
23134
|
+
|
|
22690
23135
|
namespace duckdb {
|
|
22691
23136
|
|
|
22692
|
-
//! Represents a
|
|
22693
|
-
class
|
|
23137
|
+
//! Represents a subquery
|
|
23138
|
+
class SubqueryExpression : public ParsedExpression {
|
|
22694
23139
|
public:
|
|
22695
|
-
|
|
22696
|
-
DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
22697
|
-
DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
22698
|
-
unique_ptr<ParsedExpression> right);
|
|
23140
|
+
SubqueryExpression();
|
|
22699
23141
|
|
|
22700
|
-
|
|
23142
|
+
//! The actual subquery
|
|
23143
|
+
unique_ptr<SelectStatement> subquery;
|
|
23144
|
+
//! The subquery type
|
|
23145
|
+
SubqueryType subquery_type;
|
|
23146
|
+
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
23147
|
+
//! subquery)
|
|
23148
|
+
unique_ptr<ParsedExpression> child;
|
|
23149
|
+
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
23150
|
+
ExpressionType comparison_type;
|
|
22701
23151
|
|
|
22702
23152
|
public:
|
|
22703
|
-
|
|
23153
|
+
bool HasSubquery() const override {
|
|
23154
|
+
return true;
|
|
23155
|
+
}
|
|
23156
|
+
bool IsScalar() const override {
|
|
23157
|
+
return false;
|
|
23158
|
+
}
|
|
22704
23159
|
|
|
22705
23160
|
string ToString() const override;
|
|
22706
23161
|
|
|
22707
|
-
static bool Equals(const
|
|
23162
|
+
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
22708
23163
|
|
|
22709
23164
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22710
23165
|
|
|
22711
23166
|
void Serialize(FieldWriter &writer) const override;
|
|
22712
23167
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22713
|
-
|
|
22714
|
-
public:
|
|
22715
|
-
template <class T, class BASE>
|
|
22716
|
-
static string ToString(const T &entry) {
|
|
22717
|
-
string result = entry.children[0]->ToString();
|
|
22718
|
-
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22719
|
-
result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
|
|
22720
|
-
}
|
|
22721
|
-
return result;
|
|
22722
|
-
}
|
|
22723
23168
|
};
|
|
22724
23169
|
} // namespace duckdb
|
|
22725
|
-
|
|
22726
23170
|
//===----------------------------------------------------------------------===//
|
|
22727
23171
|
// DuckDB
|
|
22728
23172
|
//
|
|
22729
|
-
// duckdb/parser/expression/
|
|
23173
|
+
// duckdb/parser/expression/cast_expression.hpp
|
|
22730
23174
|
//
|
|
22731
23175
|
//
|
|
22732
23176
|
//===----------------------------------------------------------------------===//
|
|
@@ -22738,32 +23182,40 @@ public:
|
|
|
22738
23182
|
|
|
22739
23183
|
namespace duckdb {
|
|
22740
23184
|
|
|
22741
|
-
//!
|
|
22742
|
-
class
|
|
23185
|
+
//! CastExpression represents a type cast from one SQL type to another SQL type
|
|
23186
|
+
class CastExpression : public ParsedExpression {
|
|
22743
23187
|
public:
|
|
22744
|
-
DUCKDB_API
|
|
23188
|
+
DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
|
|
22745
23189
|
|
|
22746
|
-
//! The
|
|
22747
|
-
|
|
23190
|
+
//! The child of the cast expression
|
|
23191
|
+
unique_ptr<ParsedExpression> child;
|
|
23192
|
+
//! The type to cast to
|
|
23193
|
+
LogicalType cast_type;
|
|
23194
|
+
//! Whether or not this is a try_cast expression
|
|
23195
|
+
bool try_cast;
|
|
22748
23196
|
|
|
22749
23197
|
public:
|
|
22750
23198
|
string ToString() const override;
|
|
22751
23199
|
|
|
22752
|
-
static bool Equals(const
|
|
22753
|
-
hash_t Hash() const override;
|
|
23200
|
+
static bool Equals(const CastExpression *a, const CastExpression *b);
|
|
22754
23201
|
|
|
22755
23202
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22756
23203
|
|
|
22757
23204
|
void Serialize(FieldWriter &writer) const override;
|
|
22758
23205
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22759
|
-
};
|
|
22760
23206
|
|
|
23207
|
+
public:
|
|
23208
|
+
template <class T, class BASE>
|
|
23209
|
+
static string ToString(const T &entry) {
|
|
23210
|
+
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
23211
|
+
entry.cast_type.ToString() + ")";
|
|
23212
|
+
}
|
|
23213
|
+
};
|
|
22761
23214
|
} // namespace duckdb
|
|
22762
|
-
|
|
22763
23215
|
//===----------------------------------------------------------------------===//
|
|
22764
23216
|
// DuckDB
|
|
22765
23217
|
//
|
|
22766
|
-
// duckdb/parser/expression/
|
|
23218
|
+
// duckdb/parser/expression/lambda_expression.hpp
|
|
22767
23219
|
//
|
|
22768
23220
|
//
|
|
22769
23221
|
//===----------------------------------------------------------------------===//
|
|
@@ -22772,26 +23224,33 @@ public:
|
|
|
22772
23224
|
|
|
22773
23225
|
|
|
22774
23226
|
|
|
23227
|
+
|
|
22775
23228
|
namespace duckdb {
|
|
22776
|
-
//! Represents the default value of a column
|
|
22777
|
-
class DefaultExpression : public ParsedExpression {
|
|
22778
|
-
public:
|
|
22779
|
-
DefaultExpression();
|
|
22780
23229
|
|
|
23230
|
+
//! LambdaExpression represents either:
|
|
23231
|
+
//! 1. A lambda operator that can be used for e.g. mapping an expression to a list
|
|
23232
|
+
//! 2. An OperatorExpression with the "->" operator
|
|
23233
|
+
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
23234
|
+
class LambdaExpression : public ParsedExpression {
|
|
22781
23235
|
public:
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
23236
|
+
LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
|
|
23237
|
+
|
|
23238
|
+
unique_ptr<ParsedExpression> lhs;
|
|
23239
|
+
unique_ptr<ParsedExpression> rhs;
|
|
22785
23240
|
|
|
23241
|
+
public:
|
|
22786
23242
|
string ToString() const override;
|
|
22787
23243
|
|
|
23244
|
+
static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
|
|
23245
|
+
hash_t Hash() const override;
|
|
23246
|
+
|
|
22788
23247
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22789
23248
|
|
|
22790
23249
|
void Serialize(FieldWriter &writer) const override;
|
|
22791
23250
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22792
23251
|
};
|
|
22793
|
-
} // namespace duckdb
|
|
22794
23252
|
|
|
23253
|
+
} // namespace duckdb
|
|
22795
23254
|
//===----------------------------------------------------------------------===//
|
|
22796
23255
|
// DuckDB
|
|
22797
23256
|
//
|
|
@@ -22854,7 +23313,7 @@ public:
|
|
|
22854
23313
|
template <class T, class BASE>
|
|
22855
23314
|
static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
|
|
22856
23315
|
bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
|
|
22857
|
-
bool export_state = false) {
|
|
23316
|
+
bool export_state = false, bool add_alias = false) {
|
|
22858
23317
|
if (is_operator) {
|
|
22859
23318
|
// built-in operator
|
|
22860
23319
|
D_ASSERT(!distinct);
|
|
@@ -22876,8 +23335,11 @@ public:
|
|
|
22876
23335
|
if (distinct) {
|
|
22877
23336
|
result += "DISTINCT ";
|
|
22878
23337
|
}
|
|
22879
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22880
|
-
|
|
23338
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
|
|
23339
|
+
return child->alias.empty() || !add_alias
|
|
23340
|
+
? child->ToString()
|
|
23341
|
+
: KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
|
|
23342
|
+
});
|
|
22881
23343
|
// ordered aggregate
|
|
22882
23344
|
if (order_bys && !order_bys->orders.empty()) {
|
|
22883
23345
|
if (entry.children.empty()) {
|
|
@@ -22906,12 +23368,10 @@ public:
|
|
|
22906
23368
|
}
|
|
22907
23369
|
};
|
|
22908
23370
|
} // namespace duckdb
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
23371
|
//===----------------------------------------------------------------------===//
|
|
22912
23372
|
// DuckDB
|
|
22913
23373
|
//
|
|
22914
|
-
// duckdb/parser/expression/
|
|
23374
|
+
// duckdb/parser/expression/star_expression.hpp
|
|
22915
23375
|
//
|
|
22916
23376
|
//
|
|
22917
23377
|
//===----------------------------------------------------------------------===//
|
|
@@ -22921,94 +23381,31 @@ public:
|
|
|
22921
23381
|
|
|
22922
23382
|
|
|
22923
23383
|
|
|
22924
|
-
|
|
22925
|
-
|
|
22926
23384
|
namespace duckdb {
|
|
22927
|
-
|
|
22928
|
-
|
|
23385
|
+
|
|
23386
|
+
//! Represents a * expression in the SELECT clause
|
|
23387
|
+
class StarExpression : public ParsedExpression {
|
|
22929
23388
|
public:
|
|
22930
|
-
|
|
22931
|
-
unique_ptr<ParsedExpression> right = nullptr);
|
|
22932
|
-
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23389
|
+
StarExpression(string relation_name = string());
|
|
22933
23390
|
|
|
22934
|
-
|
|
23391
|
+
//! The relation name in case of tbl.*, or empty if this is a normal *
|
|
23392
|
+
string relation_name;
|
|
23393
|
+
//! List of columns to exclude from the STAR expression
|
|
23394
|
+
case_insensitive_set_t exclude_list;
|
|
23395
|
+
//! List of columns to replace with another expression
|
|
23396
|
+
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
22935
23397
|
|
|
22936
23398
|
public:
|
|
22937
23399
|
string ToString() const override;
|
|
22938
23400
|
|
|
22939
|
-
static bool Equals(const
|
|
23401
|
+
static bool Equals(const StarExpression *a, const StarExpression *b);
|
|
22940
23402
|
|
|
22941
23403
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22942
23404
|
|
|
22943
23405
|
void Serialize(FieldWriter &writer) const override;
|
|
22944
23406
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22945
|
-
|
|
22946
|
-
public:
|
|
22947
|
-
template <class T, class BASE>
|
|
22948
|
-
static string ToString(const T &entry) {
|
|
22949
|
-
auto op = ExpressionTypeToOperator(entry.type);
|
|
22950
|
-
if (!op.empty()) {
|
|
22951
|
-
// use the operator string to represent the operator
|
|
22952
|
-
D_ASSERT(entry.children.size() == 2);
|
|
22953
|
-
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
22954
|
-
}
|
|
22955
|
-
switch (entry.type) {
|
|
22956
|
-
case ExpressionType::COMPARE_IN:
|
|
22957
|
-
case ExpressionType::COMPARE_NOT_IN: {
|
|
22958
|
-
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
22959
|
-
string in_child = entry.children[0]->ToString();
|
|
22960
|
-
string child_list = "(";
|
|
22961
|
-
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22962
|
-
if (i > 1) {
|
|
22963
|
-
child_list += ", ";
|
|
22964
|
-
}
|
|
22965
|
-
child_list += entry.children[i]->ToString();
|
|
22966
|
-
}
|
|
22967
|
-
child_list += ")";
|
|
22968
|
-
return "(" + in_child + op_type + child_list + ")";
|
|
22969
|
-
}
|
|
22970
|
-
case ExpressionType::OPERATOR_NOT:
|
|
22971
|
-
case ExpressionType::GROUPING_FUNCTION:
|
|
22972
|
-
case ExpressionType::OPERATOR_COALESCE: {
|
|
22973
|
-
string result = ExpressionTypeToString(entry.type);
|
|
22974
|
-
result += "(";
|
|
22975
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22976
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22977
|
-
result += ")";
|
|
22978
|
-
return result;
|
|
22979
|
-
}
|
|
22980
|
-
case ExpressionType::OPERATOR_IS_NULL:
|
|
22981
|
-
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
22982
|
-
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
22983
|
-
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
22984
|
-
case ExpressionType::ARRAY_EXTRACT:
|
|
22985
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
22986
|
-
case ExpressionType::ARRAY_SLICE:
|
|
22987
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
22988
|
-
entry.children[2]->ToString() + "]";
|
|
22989
|
-
case ExpressionType::STRUCT_EXTRACT: {
|
|
22990
|
-
D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
|
|
22991
|
-
auto child_string = entry.children[1]->ToString();
|
|
22992
|
-
D_ASSERT(child_string.size() >= 3);
|
|
22993
|
-
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
22994
|
-
return "(" + entry.children[0]->ToString() + ")." +
|
|
22995
|
-
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
22996
|
-
}
|
|
22997
|
-
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
22998
|
-
string result = "ARRAY[";
|
|
22999
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
23000
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
23001
|
-
result += "]";
|
|
23002
|
-
return result;
|
|
23003
|
-
}
|
|
23004
|
-
default:
|
|
23005
|
-
throw InternalException("Unrecognized operator type");
|
|
23006
|
-
}
|
|
23007
|
-
}
|
|
23008
23407
|
};
|
|
23009
|
-
|
|
23010
23408
|
} // namespace duckdb
|
|
23011
|
-
|
|
23012
23409
|
//===----------------------------------------------------------------------===//
|
|
23013
23410
|
// DuckDB
|
|
23014
23411
|
//
|
|
@@ -23045,11 +23442,10 @@ public:
|
|
|
23045
23442
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23046
23443
|
};
|
|
23047
23444
|
} // namespace duckdb
|
|
23048
|
-
|
|
23049
23445
|
//===----------------------------------------------------------------------===//
|
|
23050
23446
|
// DuckDB
|
|
23051
23447
|
//
|
|
23052
|
-
// duckdb/parser/expression/
|
|
23448
|
+
// duckdb/parser/expression/between_expression.hpp
|
|
23053
23449
|
//
|
|
23054
23450
|
//
|
|
23055
23451
|
//===----------------------------------------------------------------------===//
|
|
@@ -23059,32 +23455,41 @@ public:
|
|
|
23059
23455
|
|
|
23060
23456
|
|
|
23061
23457
|
namespace duckdb {
|
|
23062
|
-
|
|
23458
|
+
|
|
23459
|
+
class BetweenExpression : public ParsedExpression {
|
|
23063
23460
|
public:
|
|
23064
|
-
DUCKDB_API
|
|
23461
|
+
DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
|
|
23462
|
+
unique_ptr<ParsedExpression> upper);
|
|
23065
23463
|
|
|
23066
|
-
|
|
23464
|
+
unique_ptr<ParsedExpression> input;
|
|
23465
|
+
unique_ptr<ParsedExpression> lower;
|
|
23466
|
+
unique_ptr<ParsedExpression> upper;
|
|
23067
23467
|
|
|
23068
23468
|
public:
|
|
23069
|
-
bool IsScalar() const override {
|
|
23070
|
-
return false;
|
|
23071
|
-
}
|
|
23072
|
-
|
|
23073
23469
|
string ToString() const override;
|
|
23074
23470
|
|
|
23075
|
-
static bool Equals(const
|
|
23471
|
+
static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
|
|
23472
|
+
|
|
23076
23473
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23077
|
-
hash_t Hash() const override;
|
|
23078
23474
|
|
|
23079
23475
|
void Serialize(FieldWriter &writer) const override;
|
|
23080
23476
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23477
|
+
|
|
23478
|
+
public:
|
|
23479
|
+
template <class T, class BASE>
|
|
23480
|
+
static string ToString(const T &entry) {
|
|
23481
|
+
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
23482
|
+
}
|
|
23081
23483
|
};
|
|
23082
23484
|
} // namespace duckdb
|
|
23083
23485
|
|
|
23486
|
+
|
|
23487
|
+
|
|
23488
|
+
|
|
23084
23489
|
//===----------------------------------------------------------------------===//
|
|
23085
23490
|
// DuckDB
|
|
23086
23491
|
//
|
|
23087
|
-
// duckdb/parser/expression/
|
|
23492
|
+
// duckdb/parser/expression/collate_expression.hpp
|
|
23088
23493
|
//
|
|
23089
23494
|
//
|
|
23090
23495
|
//===----------------------------------------------------------------------===//
|
|
@@ -23093,25 +23498,22 @@ public:
|
|
|
23093
23498
|
|
|
23094
23499
|
|
|
23095
23500
|
|
|
23096
|
-
|
|
23097
23501
|
namespace duckdb {
|
|
23098
23502
|
|
|
23099
|
-
//!
|
|
23100
|
-
class
|
|
23503
|
+
//! CollateExpression represents a COLLATE statement
|
|
23504
|
+
class CollateExpression : public ParsedExpression {
|
|
23101
23505
|
public:
|
|
23102
|
-
|
|
23506
|
+
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
23103
23507
|
|
|
23104
|
-
//! The
|
|
23105
|
-
|
|
23106
|
-
//!
|
|
23107
|
-
|
|
23108
|
-
//! List of columns to replace with another expression
|
|
23109
|
-
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
23508
|
+
//! The child of the cast expression
|
|
23509
|
+
unique_ptr<ParsedExpression> child;
|
|
23510
|
+
//! The collation clause
|
|
23511
|
+
string collation;
|
|
23110
23512
|
|
|
23111
23513
|
public:
|
|
23112
23514
|
string ToString() const override;
|
|
23113
23515
|
|
|
23114
|
-
static bool Equals(const
|
|
23516
|
+
static bool Equals(const CollateExpression *a, const CollateExpression *b);
|
|
23115
23517
|
|
|
23116
23518
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23117
23519
|
|
|
@@ -23120,10 +23522,13 @@ public:
|
|
|
23120
23522
|
};
|
|
23121
23523
|
} // namespace duckdb
|
|
23122
23524
|
|
|
23525
|
+
|
|
23526
|
+
|
|
23527
|
+
|
|
23123
23528
|
//===----------------------------------------------------------------------===//
|
|
23124
23529
|
// DuckDB
|
|
23125
23530
|
//
|
|
23126
|
-
// duckdb/parser/expression/
|
|
23531
|
+
// duckdb/parser/expression/constant_expression.hpp
|
|
23127
23532
|
//
|
|
23128
23533
|
//
|
|
23129
23534
|
//===----------------------------------------------------------------------===//
|
|
@@ -23133,90 +23538,37 @@ public:
|
|
|
23133
23538
|
|
|
23134
23539
|
|
|
23135
23540
|
|
|
23136
|
-
|
|
23137
23541
|
namespace duckdb {
|
|
23138
23542
|
|
|
23139
|
-
//!
|
|
23140
|
-
class
|
|
23543
|
+
//! ConstantExpression represents a constant value in the query
|
|
23544
|
+
class ConstantExpression : public ParsedExpression {
|
|
23141
23545
|
public:
|
|
23142
|
-
|
|
23546
|
+
DUCKDB_API explicit ConstantExpression(Value val);
|
|
23143
23547
|
|
|
23144
|
-
//! The
|
|
23145
|
-
|
|
23146
|
-
//! The subquery type
|
|
23147
|
-
SubqueryType subquery_type;
|
|
23148
|
-
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
23149
|
-
//! subquery)
|
|
23150
|
-
unique_ptr<ParsedExpression> child;
|
|
23151
|
-
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
23152
|
-
ExpressionType comparison_type;
|
|
23548
|
+
//! The constant value referenced
|
|
23549
|
+
Value value;
|
|
23153
23550
|
|
|
23154
23551
|
public:
|
|
23155
|
-
bool HasSubquery() const override {
|
|
23156
|
-
return true;
|
|
23157
|
-
}
|
|
23158
|
-
bool IsScalar() const override {
|
|
23159
|
-
return false;
|
|
23160
|
-
}
|
|
23161
|
-
|
|
23162
23552
|
string ToString() const override;
|
|
23163
23553
|
|
|
23164
|
-
static bool Equals(const
|
|
23554
|
+
static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
|
|
23555
|
+
hash_t Hash() const override;
|
|
23165
23556
|
|
|
23166
23557
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23167
23558
|
|
|
23168
23559
|
void Serialize(FieldWriter &writer) const override;
|
|
23169
23560
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23170
23561
|
};
|
|
23171
|
-
} // namespace duckdb
|
|
23172
|
-
|
|
23173
|
-
|
|
23174
|
-
//===----------------------------------------------------------------------===//
|
|
23175
|
-
// DuckDB
|
|
23176
|
-
//
|
|
23177
|
-
// duckdb/parser/parsed_data/create_collation_info.hpp
|
|
23178
|
-
//
|
|
23179
|
-
//
|
|
23180
|
-
//===----------------------------------------------------------------------===//
|
|
23181
|
-
|
|
23182
23562
|
|
|
23563
|
+
} // namespace duckdb
|
|
23183
23564
|
|
|
23184
23565
|
|
|
23185
23566
|
|
|
23186
23567
|
|
|
23187
|
-
namespace duckdb {
|
|
23188
|
-
|
|
23189
|
-
struct CreateCollationInfo : public CreateInfo {
|
|
23190
|
-
CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
|
|
23191
|
-
: CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
|
|
23192
|
-
not_required_for_equality(not_required_for_equality_p) {
|
|
23193
|
-
this->name = move(name_p);
|
|
23194
|
-
}
|
|
23195
|
-
|
|
23196
|
-
//! The name of the collation
|
|
23197
|
-
string name;
|
|
23198
|
-
//! The collation function to push in case collation is required
|
|
23199
|
-
ScalarFunction function;
|
|
23200
|
-
//! Whether or not the collation can be combined with other collations.
|
|
23201
|
-
bool combinable;
|
|
23202
|
-
//! Whether or not the collation is required for equality comparisons or not. For many collations a binary
|
|
23203
|
-
//! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
|
|
23204
|
-
//! speeds up processing.
|
|
23205
|
-
bool not_required_for_equality;
|
|
23206
|
-
|
|
23207
|
-
public:
|
|
23208
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
23209
|
-
auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
|
|
23210
|
-
CopyProperties(*result);
|
|
23211
|
-
return move(result);
|
|
23212
|
-
}
|
|
23213
|
-
};
|
|
23214
|
-
|
|
23215
|
-
} // namespace duckdb
|
|
23216
23568
|
//===----------------------------------------------------------------------===//
|
|
23217
23569
|
// DuckDB
|
|
23218
23570
|
//
|
|
23219
|
-
// duckdb/parser/
|
|
23571
|
+
// duckdb/parser/expression/operator_expression.hpp
|
|
23220
23572
|
//
|
|
23221
23573
|
//
|
|
23222
23574
|
//===----------------------------------------------------------------------===//
|
|
@@ -23225,61 +23577,104 @@ public:
|
|
|
23225
23577
|
|
|
23226
23578
|
|
|
23227
23579
|
|
|
23228
|
-
namespace duckdb {
|
|
23229
|
-
|
|
23230
|
-
struct CreateSchemaInfo : public CreateInfo {
|
|
23231
|
-
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
23232
|
-
}
|
|
23233
|
-
|
|
23234
|
-
public:
|
|
23235
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
23236
|
-
auto result = make_unique<CreateSchemaInfo>();
|
|
23237
|
-
CopyProperties(*result);
|
|
23238
|
-
return move(result);
|
|
23239
|
-
}
|
|
23240
|
-
};
|
|
23241
23580
|
|
|
23242
|
-
} // namespace duckdb
|
|
23243
|
-
//===----------------------------------------------------------------------===//
|
|
23244
|
-
// DuckDB
|
|
23245
|
-
//
|
|
23246
|
-
// duckdb/parser/parsed_data/show_select_info.hpp
|
|
23247
|
-
//
|
|
23248
|
-
//
|
|
23249
|
-
//===----------------------------------------------------------------------===//
|
|
23250
23581
|
|
|
23251
23582
|
|
|
23583
|
+
namespace duckdb {
|
|
23584
|
+
//! Represents a built-in operator expression
|
|
23585
|
+
class OperatorExpression : public ParsedExpression {
|
|
23586
|
+
public:
|
|
23587
|
+
DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
|
|
23588
|
+
unique_ptr<ParsedExpression> right = nullptr);
|
|
23589
|
+
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23252
23590
|
|
|
23591
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
23253
23592
|
|
|
23593
|
+
public:
|
|
23594
|
+
string ToString() const override;
|
|
23254
23595
|
|
|
23596
|
+
static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
|
|
23255
23597
|
|
|
23256
|
-
|
|
23598
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23257
23599
|
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
vector<LogicalType> types;
|
|
23261
|
-
//! The QueryNode of select query
|
|
23262
|
-
unique_ptr<QueryNode> query;
|
|
23263
|
-
//! Aliases of projected columns
|
|
23264
|
-
vector<string> aliases;
|
|
23265
|
-
//! Whether or not we are requesting a summary or a describe
|
|
23266
|
-
bool is_summary;
|
|
23600
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23601
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23267
23602
|
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23603
|
+
public:
|
|
23604
|
+
template <class T, class BASE>
|
|
23605
|
+
static string ToString(const T &entry) {
|
|
23606
|
+
auto op = ExpressionTypeToOperator(entry.type);
|
|
23607
|
+
if (!op.empty()) {
|
|
23608
|
+
// use the operator string to represent the operator
|
|
23609
|
+
D_ASSERT(entry.children.size() == 2);
|
|
23610
|
+
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
23611
|
+
}
|
|
23612
|
+
switch (entry.type) {
|
|
23613
|
+
case ExpressionType::COMPARE_IN:
|
|
23614
|
+
case ExpressionType::COMPARE_NOT_IN: {
|
|
23615
|
+
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
23616
|
+
string in_child = entry.children[0]->ToString();
|
|
23617
|
+
string child_list = "(";
|
|
23618
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
23619
|
+
if (i > 1) {
|
|
23620
|
+
child_list += ", ";
|
|
23621
|
+
}
|
|
23622
|
+
child_list += entry.children[i]->ToString();
|
|
23623
|
+
}
|
|
23624
|
+
child_list += ")";
|
|
23625
|
+
return "(" + in_child + op_type + child_list + ")";
|
|
23626
|
+
}
|
|
23627
|
+
case ExpressionType::OPERATOR_NOT:
|
|
23628
|
+
case ExpressionType::GROUPING_FUNCTION:
|
|
23629
|
+
case ExpressionType::OPERATOR_COALESCE: {
|
|
23630
|
+
string result = ExpressionTypeToString(entry.type);
|
|
23631
|
+
result += "(";
|
|
23632
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
23633
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
23634
|
+
result += ")";
|
|
23635
|
+
return result;
|
|
23636
|
+
}
|
|
23637
|
+
case ExpressionType::OPERATOR_IS_NULL:
|
|
23638
|
+
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
23639
|
+
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
23640
|
+
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
23641
|
+
case ExpressionType::ARRAY_EXTRACT:
|
|
23642
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
23643
|
+
case ExpressionType::ARRAY_SLICE:
|
|
23644
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
23645
|
+
entry.children[2]->ToString() + "]";
|
|
23646
|
+
case ExpressionType::STRUCT_EXTRACT: {
|
|
23647
|
+
D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
|
|
23648
|
+
auto child_string = entry.children[1]->ToString();
|
|
23649
|
+
D_ASSERT(child_string.size() >= 3);
|
|
23650
|
+
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
23651
|
+
return "(" + entry.children[0]->ToString() + ")." +
|
|
23652
|
+
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
23653
|
+
}
|
|
23654
|
+
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
23655
|
+
string result = "(ARRAY[";
|
|
23656
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
23657
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
23658
|
+
result += "])";
|
|
23659
|
+
return result;
|
|
23660
|
+
}
|
|
23661
|
+
default:
|
|
23662
|
+
throw InternalException("Unrecognized operator type");
|
|
23663
|
+
}
|
|
23275
23664
|
}
|
|
23276
23665
|
};
|
|
23277
23666
|
|
|
23278
23667
|
} // namespace duckdb
|
|
23668
|
+
|
|
23669
|
+
|
|
23670
|
+
|
|
23671
|
+
|
|
23672
|
+
|
|
23673
|
+
|
|
23279
23674
|
//===----------------------------------------------------------------------===//
|
|
23280
23675
|
// DuckDB
|
|
23281
23676
|
//
|
|
23282
|
-
// duckdb/parser/parsed_data/
|
|
23677
|
+
// duckdb/parser/parsed_data/create_view_info.hpp
|
|
23283
23678
|
//
|
|
23284
23679
|
//
|
|
23285
23680
|
//===----------------------------------------------------------------------===//
|
|
@@ -23288,17 +23683,41 @@ struct ShowSelectInfo : public ParseInfo {
|
|
|
23288
23683
|
|
|
23289
23684
|
|
|
23290
23685
|
|
|
23686
|
+
|
|
23291
23687
|
namespace duckdb {
|
|
23292
23688
|
|
|
23293
|
-
struct
|
|
23294
|
-
|
|
23689
|
+
struct CreateViewInfo : public CreateInfo {
|
|
23690
|
+
CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
|
|
23691
|
+
}
|
|
23692
|
+
CreateViewInfo(string schema, string view_name)
|
|
23693
|
+
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
23694
|
+
}
|
|
23695
|
+
|
|
23696
|
+
//! Table name to insert to
|
|
23697
|
+
string view_name;
|
|
23698
|
+
//! Aliases of the view
|
|
23699
|
+
vector<string> aliases;
|
|
23700
|
+
//! Return types
|
|
23701
|
+
vector<LogicalType> types;
|
|
23702
|
+
//! The SelectStatement of the view
|
|
23703
|
+
unique_ptr<SelectStatement> query;
|
|
23704
|
+
|
|
23705
|
+
public:
|
|
23706
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23707
|
+
auto result = make_unique<CreateViewInfo>(schema, view_name);
|
|
23708
|
+
CopyProperties(*result);
|
|
23709
|
+
result->aliases = aliases;
|
|
23710
|
+
result->types = types;
|
|
23711
|
+
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23712
|
+
return move(result);
|
|
23713
|
+
}
|
|
23295
23714
|
};
|
|
23296
23715
|
|
|
23297
23716
|
} // namespace duckdb
|
|
23298
23717
|
//===----------------------------------------------------------------------===//
|
|
23299
23718
|
// DuckDB
|
|
23300
23719
|
//
|
|
23301
|
-
// duckdb/parser/parsed_data/
|
|
23720
|
+
// duckdb/parser/parsed_data/transaction_info.hpp
|
|
23302
23721
|
//
|
|
23303
23722
|
//
|
|
23304
23723
|
//===----------------------------------------------------------------------===//
|
|
@@ -23307,11 +23726,23 @@ struct VacuumInfo : public ParseInfo {
|
|
|
23307
23726
|
|
|
23308
23727
|
|
|
23309
23728
|
|
|
23729
|
+
namespace duckdb {
|
|
23730
|
+
|
|
23731
|
+
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
23732
|
+
|
|
23733
|
+
struct TransactionInfo : public ParseInfo {
|
|
23734
|
+
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23735
|
+
}
|
|
23736
|
+
|
|
23737
|
+
//! The type of transaction statement
|
|
23738
|
+
TransactionType type;
|
|
23739
|
+
};
|
|
23310
23740
|
|
|
23741
|
+
} // namespace duckdb
|
|
23311
23742
|
//===----------------------------------------------------------------------===//
|
|
23312
23743
|
// DuckDB
|
|
23313
23744
|
//
|
|
23314
|
-
// duckdb/parser/
|
|
23745
|
+
// duckdb/parser/parsed_data/create_pragma_function_info.hpp
|
|
23315
23746
|
//
|
|
23316
23747
|
//
|
|
23317
23748
|
//===----------------------------------------------------------------------===//
|
|
@@ -23322,62 +23753,54 @@ struct VacuumInfo : public ParseInfo {
|
|
|
23322
23753
|
|
|
23323
23754
|
|
|
23324
23755
|
namespace duckdb {
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23756
|
+
|
|
23757
|
+
struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
|
|
23758
|
+
explicit CreatePragmaFunctionInfo(PragmaFunction function)
|
|
23759
|
+
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
|
|
23760
|
+
functions.push_back(move(function));
|
|
23761
|
+
this->name = function.name;
|
|
23762
|
+
}
|
|
23763
|
+
CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
|
|
23764
|
+
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
|
|
23765
|
+
this->name = name;
|
|
23766
|
+
for (auto &function : functions) {
|
|
23767
|
+
function.name = name;
|
|
23768
|
+
}
|
|
23329
23769
|
}
|
|
23330
23770
|
|
|
23331
|
-
|
|
23332
|
-
string schema_name;
|
|
23333
|
-
//! Table name
|
|
23334
|
-
string table_name;
|
|
23335
|
-
//! Aliases for the column names
|
|
23336
|
-
vector<string> column_name_alias;
|
|
23771
|
+
vector<PragmaFunction> functions;
|
|
23337
23772
|
|
|
23338
23773
|
public:
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
//! Serializes a blob into a BaseTableRef
|
|
23345
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
23346
|
-
//! Deserializes a blob back into a BaseTableRef
|
|
23347
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23774
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23775
|
+
auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
|
|
23776
|
+
CopyProperties(*result);
|
|
23777
|
+
return move(result);
|
|
23778
|
+
}
|
|
23348
23779
|
};
|
|
23780
|
+
|
|
23349
23781
|
} // namespace duckdb
|
|
23782
|
+
//===----------------------------------------------------------------------===//
|
|
23783
|
+
// DuckDB
|
|
23784
|
+
//
|
|
23785
|
+
// duckdb/parser/parsed_data/create_schema_info.hpp
|
|
23786
|
+
//
|
|
23787
|
+
//
|
|
23788
|
+
//===----------------------------------------------------------------------===//
|
|
23789
|
+
|
|
23790
|
+
|
|
23350
23791
|
|
|
23351
23792
|
|
|
23352
23793
|
|
|
23353
23794
|
namespace duckdb {
|
|
23354
23795
|
|
|
23355
|
-
struct
|
|
23356
|
-
|
|
23796
|
+
struct CreateSchemaInfo : public CreateInfo {
|
|
23797
|
+
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
23357
23798
|
}
|
|
23358
23799
|
|
|
23359
|
-
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
23360
|
-
IndexType index_type;
|
|
23361
|
-
//! Name of the Index
|
|
23362
|
-
string index_name;
|
|
23363
|
-
//! If it is an unique index
|
|
23364
|
-
bool unique = false;
|
|
23365
|
-
//! The table to create the index on
|
|
23366
|
-
unique_ptr<BaseTableRef> table;
|
|
23367
|
-
//! Set of expressions to index by
|
|
23368
|
-
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23369
|
-
|
|
23370
23800
|
public:
|
|
23371
23801
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23372
|
-
auto result = make_unique<
|
|
23802
|
+
auto result = make_unique<CreateSchemaInfo>();
|
|
23373
23803
|
CopyProperties(*result);
|
|
23374
|
-
result->index_type = index_type;
|
|
23375
|
-
result->index_name = index_name;
|
|
23376
|
-
result->unique = unique;
|
|
23377
|
-
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
23378
|
-
for (auto &expr : expressions) {
|
|
23379
|
-
result->expressions.push_back(expr->Copy());
|
|
23380
|
-
}
|
|
23381
23804
|
return move(result);
|
|
23382
23805
|
}
|
|
23383
23806
|
};
|
|
@@ -23386,7 +23809,7 @@ public:
|
|
|
23386
23809
|
//===----------------------------------------------------------------------===//
|
|
23387
23810
|
// DuckDB
|
|
23388
23811
|
//
|
|
23389
|
-
// duckdb/parser/parsed_data/
|
|
23812
|
+
// duckdb/parser/parsed_data/create_macro_info.hpp
|
|
23390
23813
|
//
|
|
23391
23814
|
//
|
|
23392
23815
|
//===----------------------------------------------------------------------===//
|
|
@@ -23394,29 +23817,17 @@ public:
|
|
|
23394
23817
|
|
|
23395
23818
|
|
|
23396
23819
|
|
|
23397
|
-
|
|
23398
|
-
namespace duckdb {
|
|
23399
|
-
|
|
23400
|
-
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
23401
|
-
|
|
23402
|
-
struct TransactionInfo : public ParseInfo {
|
|
23403
|
-
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23404
|
-
}
|
|
23405
|
-
|
|
23406
|
-
//! The type of transaction statement
|
|
23407
|
-
TransactionType type;
|
|
23408
|
-
};
|
|
23409
|
-
|
|
23410
|
-
} // namespace duckdb
|
|
23411
23820
|
//===----------------------------------------------------------------------===//
|
|
23412
23821
|
// DuckDB
|
|
23413
23822
|
//
|
|
23414
|
-
// duckdb/
|
|
23823
|
+
// duckdb/function/macro_function.hpp
|
|
23415
23824
|
//
|
|
23416
23825
|
//
|
|
23417
23826
|
//===----------------------------------------------------------------------===//
|
|
23418
23827
|
|
|
23419
23828
|
|
|
23829
|
+
//! The SelectStatement of the view
|
|
23830
|
+
|
|
23420
23831
|
|
|
23421
23832
|
|
|
23422
23833
|
|
|
@@ -23425,22 +23836,55 @@ struct TransactionInfo : public ParseInfo {
|
|
|
23425
23836
|
|
|
23426
23837
|
namespace duckdb {
|
|
23427
23838
|
|
|
23428
|
-
|
|
23839
|
+
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
23429
23840
|
|
|
23430
|
-
|
|
23841
|
+
class MacroFunction {
|
|
23842
|
+
public:
|
|
23843
|
+
// explicit MacroFunction(unique_ptr<ParsedExpression> expression);
|
|
23844
|
+
MacroFunction(MacroType type);
|
|
23845
|
+
|
|
23846
|
+
// MacroFunction(void);
|
|
23847
|
+
// The type
|
|
23848
|
+
MacroType type;
|
|
23849
|
+
//! The positional parameters
|
|
23850
|
+
vector<unique_ptr<ParsedExpression>> parameters;
|
|
23851
|
+
//! The default parameters and their associated values
|
|
23852
|
+
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
23853
|
+
|
|
23854
|
+
public:
|
|
23855
|
+
virtual ~MacroFunction() {
|
|
23431
23856
|
}
|
|
23432
23857
|
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
|
|
23858
|
+
void CopyProperties(MacroFunction &other);
|
|
23859
|
+
|
|
23860
|
+
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
23861
|
+
|
|
23862
|
+
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
23863
|
+
FunctionExpression &function_expr,
|
|
23864
|
+
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
23865
|
+
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
23866
|
+
};
|
|
23867
|
+
|
|
23868
|
+
} // namespace duckdb
|
|
23869
|
+
|
|
23870
|
+
|
|
23871
|
+
namespace duckdb {
|
|
23872
|
+
|
|
23873
|
+
struct CreateMacroInfo : public CreateFunctionInfo {
|
|
23874
|
+
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
23875
|
+
}
|
|
23876
|
+
|
|
23877
|
+
CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
|
|
23878
|
+
}
|
|
23879
|
+
|
|
23880
|
+
unique_ptr<MacroFunction> function;
|
|
23437
23881
|
|
|
23438
23882
|
public:
|
|
23439
23883
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23440
|
-
auto result = make_unique<
|
|
23441
|
-
|
|
23884
|
+
auto result = make_unique<CreateMacroInfo>();
|
|
23885
|
+
result->function = function->Copy();
|
|
23442
23886
|
result->name = name;
|
|
23443
|
-
result
|
|
23887
|
+
CopyProperties(*result);
|
|
23444
23888
|
return move(result);
|
|
23445
23889
|
}
|
|
23446
23890
|
};
|
|
@@ -23449,7 +23893,7 @@ public:
|
|
|
23449
23893
|
//===----------------------------------------------------------------------===//
|
|
23450
23894
|
// DuckDB
|
|
23451
23895
|
//
|
|
23452
|
-
// duckdb/parser/parsed_data/
|
|
23896
|
+
// duckdb/parser/parsed_data/create_aggregate_function_info.hpp
|
|
23453
23897
|
//
|
|
23454
23898
|
//
|
|
23455
23899
|
//===----------------------------------------------------------------------===//
|
|
@@ -23461,29 +23905,27 @@ public:
|
|
|
23461
23905
|
|
|
23462
23906
|
namespace duckdb {
|
|
23463
23907
|
|
|
23464
|
-
struct
|
|
23465
|
-
|
|
23908
|
+
struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
|
|
23909
|
+
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
23910
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
23911
|
+
this->name = function.name;
|
|
23912
|
+
functions.AddFunction(move(function));
|
|
23466
23913
|
}
|
|
23467
|
-
|
|
23468
|
-
|
|
23914
|
+
|
|
23915
|
+
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
23916
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
23917
|
+
this->name = functions.name;
|
|
23918
|
+
for (auto &func : functions.functions) {
|
|
23919
|
+
func.name = functions.name;
|
|
23920
|
+
}
|
|
23469
23921
|
}
|
|
23470
23922
|
|
|
23471
|
-
|
|
23472
|
-
string view_name;
|
|
23473
|
-
//! Aliases of the view
|
|
23474
|
-
vector<string> aliases;
|
|
23475
|
-
//! Return types
|
|
23476
|
-
vector<LogicalType> types;
|
|
23477
|
-
//! The SelectStatement of the view
|
|
23478
|
-
unique_ptr<SelectStatement> query;
|
|
23923
|
+
AggregateFunctionSet functions;
|
|
23479
23924
|
|
|
23480
23925
|
public:
|
|
23481
23926
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23482
|
-
auto result = make_unique<
|
|
23927
|
+
auto result = make_unique<CreateAggregateFunctionInfo>(functions);
|
|
23483
23928
|
CopyProperties(*result);
|
|
23484
|
-
result->aliases = aliases;
|
|
23485
|
-
result->types = types;
|
|
23486
|
-
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23487
23929
|
return move(result);
|
|
23488
23930
|
}
|
|
23489
23931
|
};
|
|
@@ -23492,7 +23934,7 @@ public:
|
|
|
23492
23934
|
//===----------------------------------------------------------------------===//
|
|
23493
23935
|
// DuckDB
|
|
23494
23936
|
//
|
|
23495
|
-
// duckdb/parser/parsed_data/
|
|
23937
|
+
// duckdb/parser/parsed_data/show_select_info.hpp
|
|
23496
23938
|
//
|
|
23497
23939
|
//
|
|
23498
23940
|
//===----------------------------------------------------------------------===//
|
|
@@ -23500,74 +23942,194 @@ public:
|
|
|
23500
23942
|
|
|
23501
23943
|
|
|
23502
23944
|
|
|
23945
|
+
|
|
23946
|
+
|
|
23947
|
+
namespace duckdb {
|
|
23948
|
+
|
|
23949
|
+
struct ShowSelectInfo : public ParseInfo {
|
|
23950
|
+
//! Types of projected columns
|
|
23951
|
+
vector<LogicalType> types;
|
|
23952
|
+
//! The QueryNode of select query
|
|
23953
|
+
unique_ptr<QueryNode> query;
|
|
23954
|
+
//! Aliases of projected columns
|
|
23955
|
+
vector<string> aliases;
|
|
23956
|
+
//! Whether or not we are requesting a summary or a describe
|
|
23957
|
+
bool is_summary;
|
|
23958
|
+
|
|
23959
|
+
unique_ptr<ShowSelectInfo> Copy() {
|
|
23960
|
+
auto result = make_unique<ShowSelectInfo>();
|
|
23961
|
+
result->types = types;
|
|
23962
|
+
result->query = query->Copy();
|
|
23963
|
+
result->aliases = aliases;
|
|
23964
|
+
result->is_summary = is_summary;
|
|
23965
|
+
return result;
|
|
23966
|
+
}
|
|
23967
|
+
};
|
|
23968
|
+
|
|
23969
|
+
} // namespace duckdb
|
|
23503
23970
|
//===----------------------------------------------------------------------===//
|
|
23504
23971
|
// DuckDB
|
|
23505
23972
|
//
|
|
23506
|
-
// duckdb/
|
|
23973
|
+
// duckdb/parser/parsed_data/export_table_data.hpp
|
|
23507
23974
|
//
|
|
23508
23975
|
//
|
|
23509
23976
|
//===----------------------------------------------------------------------===//
|
|
23510
23977
|
|
|
23511
23978
|
|
|
23512
|
-
//! The SelectStatement of the view
|
|
23513
23979
|
|
|
23514
23980
|
|
|
23515
23981
|
|
|
23516
23982
|
|
|
23983
|
+
namespace duckdb {
|
|
23984
|
+
|
|
23985
|
+
struct ExportedTableData {
|
|
23986
|
+
//! Name of the exported table
|
|
23987
|
+
string table_name;
|
|
23988
|
+
|
|
23989
|
+
//! Name of the schema
|
|
23990
|
+
string schema_name;
|
|
23991
|
+
|
|
23992
|
+
//! Path to be exported
|
|
23993
|
+
string file_path;
|
|
23994
|
+
};
|
|
23995
|
+
|
|
23996
|
+
struct ExportedTableInfo {
|
|
23997
|
+
TableCatalogEntry *entry;
|
|
23998
|
+
ExportedTableData table_data;
|
|
23999
|
+
};
|
|
24000
|
+
|
|
24001
|
+
struct BoundExportData : public ParseInfo {
|
|
24002
|
+
std::vector<ExportedTableInfo> data;
|
|
24003
|
+
};
|
|
24004
|
+
|
|
24005
|
+
} // namespace duckdb
|
|
24006
|
+
//===----------------------------------------------------------------------===//
|
|
24007
|
+
// DuckDB
|
|
24008
|
+
//
|
|
24009
|
+
// duckdb/parser/parsed_data/drop_info.hpp
|
|
24010
|
+
//
|
|
24011
|
+
//
|
|
24012
|
+
//===----------------------------------------------------------------------===//
|
|
24013
|
+
|
|
24014
|
+
|
|
24015
|
+
|
|
23517
24016
|
|
|
23518
24017
|
|
|
23519
24018
|
|
|
23520
24019
|
namespace duckdb {
|
|
23521
24020
|
|
|
23522
|
-
|
|
24021
|
+
struct DropInfo : public ParseInfo {
|
|
24022
|
+
DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
|
|
24023
|
+
}
|
|
24024
|
+
|
|
24025
|
+
//! The catalog type to drop
|
|
24026
|
+
CatalogType type;
|
|
24027
|
+
//! Schema name to drop from, if any
|
|
24028
|
+
string schema;
|
|
24029
|
+
//! Element name to drop
|
|
24030
|
+
string name;
|
|
24031
|
+
//! Ignore if the entry does not exist instead of failing
|
|
24032
|
+
bool if_exists = false;
|
|
24033
|
+
//! Cascade drop (drop all dependents instead of throwing an error if there
|
|
24034
|
+
//! are any)
|
|
24035
|
+
bool cascade = false;
|
|
23523
24036
|
|
|
23524
|
-
class MacroFunction {
|
|
23525
24037
|
public:
|
|
23526
|
-
|
|
23527
|
-
|
|
24038
|
+
unique_ptr<DropInfo> Copy() const {
|
|
24039
|
+
auto result = make_unique<DropInfo>();
|
|
24040
|
+
result->type = type;
|
|
24041
|
+
result->schema = schema;
|
|
24042
|
+
result->name = name;
|
|
24043
|
+
result->if_exists = if_exists;
|
|
24044
|
+
result->cascade = cascade;
|
|
24045
|
+
return result;
|
|
24046
|
+
}
|
|
24047
|
+
};
|
|
23528
24048
|
|
|
23529
|
-
|
|
23530
|
-
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
|
|
23534
|
-
|
|
23535
|
-
|
|
24049
|
+
} // namespace duckdb
|
|
24050
|
+
//===----------------------------------------------------------------------===//
|
|
24051
|
+
// DuckDB
|
|
24052
|
+
//
|
|
24053
|
+
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
24054
|
+
//
|
|
24055
|
+
//
|
|
24056
|
+
//===----------------------------------------------------------------------===//
|
|
24057
|
+
|
|
24058
|
+
|
|
24059
|
+
|
|
24060
|
+
|
|
24061
|
+
|
|
24062
|
+
|
|
24063
|
+
//===----------------------------------------------------------------------===//
|
|
24064
|
+
// DuckDB
|
|
24065
|
+
//
|
|
24066
|
+
// duckdb/parser/tableref/basetableref.hpp
|
|
24067
|
+
//
|
|
24068
|
+
//
|
|
24069
|
+
//===----------------------------------------------------------------------===//
|
|
23536
24070
|
|
|
24071
|
+
|
|
24072
|
+
|
|
24073
|
+
|
|
24074
|
+
|
|
24075
|
+
|
|
24076
|
+
namespace duckdb {
|
|
24077
|
+
//! Represents a TableReference to a base table in the schema
|
|
24078
|
+
class BaseTableRef : public TableRef {
|
|
23537
24079
|
public:
|
|
23538
|
-
|
|
24080
|
+
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
23539
24081
|
}
|
|
23540
24082
|
|
|
23541
|
-
|
|
24083
|
+
//! Schema name
|
|
24084
|
+
string schema_name;
|
|
24085
|
+
//! Table name
|
|
24086
|
+
string table_name;
|
|
24087
|
+
//! Aliases for the column names
|
|
24088
|
+
vector<string> column_name_alias;
|
|
23542
24089
|
|
|
23543
|
-
|
|
24090
|
+
public:
|
|
24091
|
+
string ToString() const override;
|
|
24092
|
+
bool Equals(const TableRef *other_p) const override;
|
|
23544
24093
|
|
|
23545
|
-
|
|
23546
|
-
FunctionExpression &function_expr,
|
|
23547
|
-
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
23548
|
-
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
23549
|
-
};
|
|
24094
|
+
unique_ptr<TableRef> Copy() override;
|
|
23550
24095
|
|
|
24096
|
+
//! Serializes a blob into a BaseTableRef
|
|
24097
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
24098
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
24099
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24100
|
+
};
|
|
23551
24101
|
} // namespace duckdb
|
|
23552
24102
|
|
|
23553
24103
|
|
|
23554
|
-
namespace duckdb {
|
|
23555
24104
|
|
|
23556
|
-
|
|
23557
|
-
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
23558
|
-
}
|
|
24105
|
+
namespace duckdb {
|
|
23559
24106
|
|
|
23560
|
-
|
|
24107
|
+
struct CreateIndexInfo : public CreateInfo {
|
|
24108
|
+
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
23561
24109
|
}
|
|
23562
24110
|
|
|
23563
|
-
|
|
24111
|
+
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
24112
|
+
IndexType index_type;
|
|
24113
|
+
//! Name of the Index
|
|
24114
|
+
string index_name;
|
|
24115
|
+
//! If it is an unique index
|
|
24116
|
+
bool unique = false;
|
|
24117
|
+
//! The table to create the index on
|
|
24118
|
+
unique_ptr<BaseTableRef> table;
|
|
24119
|
+
//! Set of expressions to index by
|
|
24120
|
+
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23564
24121
|
|
|
23565
24122
|
public:
|
|
23566
24123
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23567
|
-
auto result = make_unique<
|
|
23568
|
-
result->function = function->Copy();
|
|
23569
|
-
result->name = name;
|
|
24124
|
+
auto result = make_unique<CreateIndexInfo>();
|
|
23570
24125
|
CopyProperties(*result);
|
|
24126
|
+
result->index_type = index_type;
|
|
24127
|
+
result->index_name = index_name;
|
|
24128
|
+
result->unique = unique;
|
|
24129
|
+
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
24130
|
+
for (auto &expr : expressions) {
|
|
24131
|
+
result->expressions.push_back(expr->Copy());
|
|
24132
|
+
}
|
|
23571
24133
|
return move(result);
|
|
23572
24134
|
}
|
|
23573
24135
|
};
|
|
@@ -23576,7 +24138,7 @@ public:
|
|
|
23576
24138
|
//===----------------------------------------------------------------------===//
|
|
23577
24139
|
// DuckDB
|
|
23578
24140
|
//
|
|
23579
|
-
// duckdb/parser/parsed_data/
|
|
24141
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23580
24142
|
//
|
|
23581
24143
|
//
|
|
23582
24144
|
//===----------------------------------------------------------------------===//
|
|
@@ -23585,34 +24147,17 @@ public:
|
|
|
23585
24147
|
|
|
23586
24148
|
|
|
23587
24149
|
|
|
23588
|
-
|
|
23589
24150
|
namespace duckdb {
|
|
23590
24151
|
|
|
23591
|
-
struct
|
|
23592
|
-
|
|
23593
|
-
string table_name;
|
|
23594
|
-
|
|
23595
|
-
//! Name of the schema
|
|
23596
|
-
string schema_name;
|
|
23597
|
-
|
|
23598
|
-
//! Path to be exported
|
|
23599
|
-
string file_path;
|
|
23600
|
-
};
|
|
23601
|
-
|
|
23602
|
-
struct ExportedTableInfo {
|
|
23603
|
-
TableCatalogEntry *entry;
|
|
23604
|
-
ExportedTableData table_data;
|
|
23605
|
-
};
|
|
23606
|
-
|
|
23607
|
-
struct BoundExportData : public ParseInfo {
|
|
23608
|
-
std::vector<ExportedTableInfo> data;
|
|
24152
|
+
struct VacuumInfo : public ParseInfo {
|
|
24153
|
+
// nothing for now
|
|
23609
24154
|
};
|
|
23610
24155
|
|
|
23611
24156
|
} // namespace duckdb
|
|
23612
24157
|
//===----------------------------------------------------------------------===//
|
|
23613
24158
|
// DuckDB
|
|
23614
24159
|
//
|
|
23615
|
-
// duckdb/parser/parsed_data/
|
|
24160
|
+
// duckdb/parser/parsed_data/create_collation_info.hpp
|
|
23616
24161
|
//
|
|
23617
24162
|
//
|
|
23618
24163
|
//===----------------------------------------------------------------------===//
|
|
@@ -23621,20 +24166,32 @@ struct BoundExportData : public ParseInfo {
|
|
|
23621
24166
|
|
|
23622
24167
|
|
|
23623
24168
|
|
|
24169
|
+
|
|
23624
24170
|
namespace duckdb {
|
|
23625
24171
|
|
|
23626
|
-
|
|
24172
|
+
struct CreateCollationInfo : public CreateInfo {
|
|
24173
|
+
CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
|
|
24174
|
+
: CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
|
|
24175
|
+
not_required_for_equality(not_required_for_equality_p) {
|
|
24176
|
+
this->name = move(name_p);
|
|
24177
|
+
}
|
|
23627
24178
|
|
|
23628
|
-
|
|
23629
|
-
|
|
23630
|
-
|
|
24179
|
+
//! The name of the collation
|
|
24180
|
+
string name;
|
|
24181
|
+
//! The collation function to push in case collation is required
|
|
24182
|
+
ScalarFunction function;
|
|
24183
|
+
//! Whether or not the collation can be combined with other collations.
|
|
24184
|
+
bool combinable;
|
|
24185
|
+
//! Whether or not the collation is required for equality comparisons or not. For many collations a binary
|
|
24186
|
+
//! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
|
|
24187
|
+
//! speeds up processing.
|
|
24188
|
+
bool not_required_for_equality;
|
|
23631
24189
|
|
|
23632
24190
|
public:
|
|
23633
|
-
unique_ptr<
|
|
23634
|
-
auto result = make_unique<
|
|
23635
|
-
result
|
|
23636
|
-
result
|
|
23637
|
-
return result;
|
|
24191
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
24192
|
+
auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
|
|
24193
|
+
CopyProperties(*result);
|
|
24194
|
+
return move(result);
|
|
23638
24195
|
}
|
|
23639
24196
|
};
|
|
23640
24197
|
|
|
@@ -23642,7 +24199,7 @@ public:
|
|
|
23642
24199
|
//===----------------------------------------------------------------------===//
|
|
23643
24200
|
// DuckDB
|
|
23644
24201
|
//
|
|
23645
|
-
// duckdb/parser/parsed_data/
|
|
24202
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23646
24203
|
//
|
|
23647
24204
|
//
|
|
23648
24205
|
//===----------------------------------------------------------------------===//
|
|
@@ -23651,31 +24208,20 @@ public:
|
|
|
23651
24208
|
|
|
23652
24209
|
|
|
23653
24210
|
|
|
23654
|
-
|
|
23655
24211
|
namespace duckdb {
|
|
23656
24212
|
|
|
23657
|
-
|
|
23658
|
-
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
23659
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
23660
|
-
this->name = function.name;
|
|
23661
|
-
functions.AddFunction(move(function));
|
|
23662
|
-
}
|
|
23663
|
-
|
|
23664
|
-
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
23665
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
23666
|
-
this->name = functions.name;
|
|
23667
|
-
for (auto &func : functions.functions) {
|
|
23668
|
-
func.name = functions.name;
|
|
23669
|
-
}
|
|
23670
|
-
}
|
|
24213
|
+
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
23671
24214
|
|
|
23672
|
-
|
|
24215
|
+
struct LoadInfo : public ParseInfo {
|
|
24216
|
+
std::string filename;
|
|
24217
|
+
LoadType load_type;
|
|
23673
24218
|
|
|
23674
24219
|
public:
|
|
23675
|
-
unique_ptr<
|
|
23676
|
-
auto result = make_unique<
|
|
23677
|
-
|
|
23678
|
-
|
|
24220
|
+
unique_ptr<LoadInfo> Copy() const {
|
|
24221
|
+
auto result = make_unique<LoadInfo>();
|
|
24222
|
+
result->filename = filename;
|
|
24223
|
+
result->load_type = load_type;
|
|
24224
|
+
return result;
|
|
23679
24225
|
}
|
|
23680
24226
|
};
|
|
23681
24227
|
|
|
@@ -23683,7 +24229,7 @@ public:
|
|
|
23683
24229
|
//===----------------------------------------------------------------------===//
|
|
23684
24230
|
// DuckDB
|
|
23685
24231
|
//
|
|
23686
|
-
// duckdb/parser/parsed_data/
|
|
24232
|
+
// duckdb/parser/parsed_data/create_type_info.hpp
|
|
23687
24233
|
//
|
|
23688
24234
|
//
|
|
23689
24235
|
//===----------------------------------------------------------------------===//
|
|
@@ -23693,33 +24239,27 @@ public:
|
|
|
23693
24239
|
|
|
23694
24240
|
|
|
23695
24241
|
|
|
24242
|
+
|
|
24243
|
+
|
|
23696
24244
|
namespace duckdb {
|
|
23697
24245
|
|
|
23698
|
-
struct
|
|
23699
|
-
|
|
24246
|
+
struct CreateTypeInfo : public CreateInfo {
|
|
24247
|
+
|
|
24248
|
+
CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
|
|
23700
24249
|
}
|
|
23701
24250
|
|
|
23702
|
-
//!
|
|
23703
|
-
CatalogType type;
|
|
23704
|
-
//! Schema name to drop from, if any
|
|
23705
|
-
string schema;
|
|
23706
|
-
//! Element name to drop
|
|
24251
|
+
//! Name of the Type
|
|
23707
24252
|
string name;
|
|
23708
|
-
//!
|
|
23709
|
-
|
|
23710
|
-
//! Cascade drop (drop all dependents instead of throwing an error if there
|
|
23711
|
-
//! are any)
|
|
23712
|
-
bool cascade = false;
|
|
24253
|
+
//! Logical Type
|
|
24254
|
+
LogicalType type;
|
|
23713
24255
|
|
|
23714
24256
|
public:
|
|
23715
|
-
unique_ptr<
|
|
23716
|
-
auto result = make_unique<
|
|
23717
|
-
result
|
|
23718
|
-
result->schema = schema;
|
|
24257
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
24258
|
+
auto result = make_unique<CreateTypeInfo>();
|
|
24259
|
+
CopyProperties(*result);
|
|
23719
24260
|
result->name = name;
|
|
23720
|
-
result->
|
|
23721
|
-
result
|
|
23722
|
-
return result;
|
|
24261
|
+
result->type = type;
|
|
24262
|
+
return move(result);
|
|
23723
24263
|
}
|
|
23724
24264
|
};
|
|
23725
24265
|
|
|
@@ -23727,7 +24267,7 @@ public:
|
|
|
23727
24267
|
//===----------------------------------------------------------------------===//
|
|
23728
24268
|
// DuckDB
|
|
23729
24269
|
//
|
|
23730
|
-
// duckdb/parser/
|
|
24270
|
+
// duckdb/parser/tableref/subqueryref.hpp
|
|
23731
24271
|
//
|
|
23732
24272
|
//
|
|
23733
24273
|
//===----------------------------------------------------------------------===//
|
|
@@ -23738,31 +24278,27 @@ public:
|
|
|
23738
24278
|
|
|
23739
24279
|
|
|
23740
24280
|
namespace duckdb {
|
|
24281
|
+
//! Represents a subquery
|
|
24282
|
+
class SubqueryRef : public TableRef {
|
|
24283
|
+
public:
|
|
24284
|
+
explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
23741
24285
|
|
|
23742
|
-
|
|
23743
|
-
|
|
23744
|
-
|
|
23745
|
-
|
|
23746
|
-
this->name = function.name;
|
|
23747
|
-
}
|
|
23748
|
-
CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
|
|
23749
|
-
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
|
|
23750
|
-
this->name = name;
|
|
23751
|
-
for (auto &function : functions) {
|
|
23752
|
-
function.name = name;
|
|
23753
|
-
}
|
|
23754
|
-
}
|
|
23755
|
-
|
|
23756
|
-
vector<PragmaFunction> functions;
|
|
24286
|
+
//! The subquery
|
|
24287
|
+
unique_ptr<SelectStatement> subquery;
|
|
24288
|
+
//! Aliases for the column names
|
|
24289
|
+
vector<string> column_name_alias;
|
|
23757
24290
|
|
|
23758
24291
|
public:
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
}
|
|
23764
|
-
};
|
|
24292
|
+
string ToString() const override;
|
|
24293
|
+
bool Equals(const TableRef *other_p) const override;
|
|
24294
|
+
|
|
24295
|
+
unique_ptr<TableRef> Copy() override;
|
|
23765
24296
|
|
|
24297
|
+
//! Serializes a blob into a SubqueryRef
|
|
24298
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
24299
|
+
//! Deserializes a blob back into a SubqueryRef
|
|
24300
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24301
|
+
};
|
|
23766
24302
|
} // namespace duckdb
|
|
23767
24303
|
//===----------------------------------------------------------------------===//
|
|
23768
24304
|
// DuckDB
|
|
@@ -23794,6 +24330,7 @@ public:
|
|
|
23794
24330
|
vector<string> expected_names;
|
|
23795
24331
|
|
|
23796
24332
|
public:
|
|
24333
|
+
string ToString() const override;
|
|
23797
24334
|
bool Equals(const TableRef *other_p) const override;
|
|
23798
24335
|
|
|
23799
24336
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23830,6 +24367,7 @@ public:
|
|
|
23830
24367
|
unique_ptr<TableRef> right;
|
|
23831
24368
|
|
|
23832
24369
|
public:
|
|
24370
|
+
string ToString() const override;
|
|
23833
24371
|
bool Equals(const TableRef *other_p) const override;
|
|
23834
24372
|
|
|
23835
24373
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23861,6 +24399,7 @@ public:
|
|
|
23861
24399
|
}
|
|
23862
24400
|
|
|
23863
24401
|
public:
|
|
24402
|
+
string ToString() const override;
|
|
23864
24403
|
bool Equals(const TableRef *other_p) const override;
|
|
23865
24404
|
|
|
23866
24405
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23910,6 +24449,7 @@ public:
|
|
|
23910
24449
|
vector<string> using_columns;
|
|
23911
24450
|
|
|
23912
24451
|
public:
|
|
24452
|
+
string ToString() const override;
|
|
23913
24453
|
bool Equals(const TableRef *other_p) const override;
|
|
23914
24454
|
|
|
23915
24455
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23921,41 +24461,6 @@ public:
|
|
|
23921
24461
|
};
|
|
23922
24462
|
} // namespace duckdb
|
|
23923
24463
|
|
|
23924
|
-
//===----------------------------------------------------------------------===//
|
|
23925
|
-
// DuckDB
|
|
23926
|
-
//
|
|
23927
|
-
// duckdb/parser/tableref/subqueryref.hpp
|
|
23928
|
-
//
|
|
23929
|
-
//
|
|
23930
|
-
//===----------------------------------------------------------------------===//
|
|
23931
|
-
|
|
23932
|
-
|
|
23933
|
-
|
|
23934
|
-
|
|
23935
|
-
|
|
23936
|
-
|
|
23937
|
-
namespace duckdb {
|
|
23938
|
-
//! Represents a subquery
|
|
23939
|
-
class SubqueryRef : public TableRef {
|
|
23940
|
-
public:
|
|
23941
|
-
explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
23942
|
-
|
|
23943
|
-
//! The subquery
|
|
23944
|
-
unique_ptr<SelectStatement> subquery;
|
|
23945
|
-
//! Aliases for the column names
|
|
23946
|
-
vector<string> column_name_alias;
|
|
23947
|
-
|
|
23948
|
-
public:
|
|
23949
|
-
bool Equals(const TableRef *other_p) const override;
|
|
23950
|
-
|
|
23951
|
-
unique_ptr<TableRef> Copy() override;
|
|
23952
|
-
|
|
23953
|
-
//! Serializes a blob into a SubqueryRef
|
|
23954
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
23955
|
-
//! Deserializes a blob back into a SubqueryRef
|
|
23956
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23957
|
-
};
|
|
23958
|
-
} // namespace duckdb
|
|
23959
24464
|
|
|
23960
24465
|
//===----------------------------------------------------------------------===//
|
|
23961
24466
|
// DuckDB
|
|
@@ -23976,8 +24481,7 @@ namespace duckdb {
|
|
|
23976
24481
|
//! Represents a Table producing function
|
|
23977
24482
|
class TableFunctionRef : public TableRef {
|
|
23978
24483
|
public:
|
|
23979
|
-
TableFunctionRef()
|
|
23980
|
-
}
|
|
24484
|
+
DUCKDB_API TableFunctionRef();
|
|
23981
24485
|
|
|
23982
24486
|
unique_ptr<ParsedExpression> function;
|
|
23983
24487
|
vector<string> column_name_alias;
|