duckdb 0.3.5-dev8.0 → 0.3.5-dev960.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 +34820 -25369
- package/src/duckdb.hpp +1638 -1149
- package/src/parquet-amalgamation.cpp +36549 -36589
- 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 "1c814b890"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.5-dev960"
|
|
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 {
|
|
@@ -2789,7 +2805,7 @@ public:
|
|
|
2789
2805
|
DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
|
|
2790
2806
|
//! Create an empty list with the specified child-type
|
|
2791
2807
|
DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
|
|
2792
|
-
//!
|
|
2808
|
+
//! Create a map value from a (key, value) pair
|
|
2793
2809
|
DUCKDB_API static Value MAP(Value key, Value value);
|
|
2794
2810
|
|
|
2795
2811
|
//! Create a blob Value from a data pointer and a length: no bytes are interpreted
|
|
@@ -2882,6 +2898,8 @@ public:
|
|
|
2882
2898
|
//! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
|
|
2883
2899
|
//! function, NULL values are equivalent and floating point values that are close are equivalent.
|
|
2884
2900
|
DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
|
|
2901
|
+
//! Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.
|
|
2902
|
+
DUCKDB_API static bool NotDistinctFrom(const Value &lvalue, const Value &rvalue);
|
|
2885
2903
|
|
|
2886
2904
|
friend std::ostream &operator<<(std::ostream &out, const Value &val) {
|
|
2887
2905
|
out << val.ToString();
|
|
@@ -3094,6 +3112,8 @@ template <>
|
|
|
3094
3112
|
DUCKDB_API timestamp_t Value::GetValue() const;
|
|
3095
3113
|
template <>
|
|
3096
3114
|
DUCKDB_API interval_t Value::GetValue() const;
|
|
3115
|
+
template <>
|
|
3116
|
+
DUCKDB_API Value Value::GetValue() const;
|
|
3097
3117
|
|
|
3098
3118
|
template <>
|
|
3099
3119
|
DUCKDB_API bool Value::GetValueUnsafe() const;
|
|
@@ -3172,6 +3192,10 @@ template <>
|
|
|
3172
3192
|
DUCKDB_API bool Value::IsFinite(float input);
|
|
3173
3193
|
template <>
|
|
3174
3194
|
DUCKDB_API bool Value::IsFinite(double input);
|
|
3195
|
+
template <>
|
|
3196
|
+
DUCKDB_API bool Value::IsFinite(date_t input);
|
|
3197
|
+
template <>
|
|
3198
|
+
DUCKDB_API bool Value::IsFinite(timestamp_t input);
|
|
3175
3199
|
|
|
3176
3200
|
} // namespace duckdb
|
|
3177
3201
|
|
|
@@ -3852,7 +3876,6 @@ struct FlatVector {
|
|
|
3852
3876
|
D_ASSERT(vector.GetVectorType() == VectorType::FLAT_VECTOR);
|
|
3853
3877
|
return !vector.validity.RowIsValid(idx);
|
|
3854
3878
|
}
|
|
3855
|
-
DUCKDB_API static const SelectionVector *IncrementalSelectionVector(idx_t count, SelectionVector &owned_sel);
|
|
3856
3879
|
DUCKDB_API static const SelectionVector *IncrementalSelectionVector();
|
|
3857
3880
|
};
|
|
3858
3881
|
|
|
@@ -3974,6 +3997,9 @@ struct SequenceVector {
|
|
|
3974
3997
|
extern "C" {
|
|
3975
3998
|
#endif
|
|
3976
3999
|
|
|
4000
|
+
#ifndef ARROW_C_DATA_INTERFACE
|
|
4001
|
+
#define ARROW_C_DATA_INTERFACE
|
|
4002
|
+
|
|
3977
4003
|
#define ARROW_FLAG_DICTIONARY_ORDERED 1
|
|
3978
4004
|
#define ARROW_FLAG_NULLABLE 2
|
|
3979
4005
|
#define ARROW_FLAG_MAP_KEYS_SORTED 4
|
|
@@ -4010,7 +4036,10 @@ struct ArrowArray {
|
|
|
4010
4036
|
// Opaque producer-specific data
|
|
4011
4037
|
void *private_data;
|
|
4012
4038
|
};
|
|
4039
|
+
#endif
|
|
4013
4040
|
|
|
4041
|
+
#ifndef ARROW_C_STREAM_INTERFACE
|
|
4042
|
+
#define ARROW_C_STREAM_INTERFACE
|
|
4014
4043
|
// EXPERIMENTAL
|
|
4015
4044
|
struct ArrowArrayStream {
|
|
4016
4045
|
// Callback to get the stream type
|
|
@@ -4035,6 +4064,7 @@ struct ArrowArrayStream {
|
|
|
4035
4064
|
// Opaque producer-specific data
|
|
4036
4065
|
void *private_data;
|
|
4037
4066
|
};
|
|
4067
|
+
#endif
|
|
4038
4068
|
|
|
4039
4069
|
#ifdef __cplusplus
|
|
4040
4070
|
}
|
|
@@ -4867,9 +4897,8 @@ public:
|
|
|
4867
4897
|
template <class LEFT_TYPE, class RIGHT_TYPE, class OP>
|
|
4868
4898
|
static idx_t Select(Vector &left, Vector &right, const SelectionVector *sel, idx_t count, SelectionVector *true_sel,
|
|
4869
4899
|
SelectionVector *false_sel) {
|
|
4870
|
-
SelectionVector owned_sel;
|
|
4871
4900
|
if (!sel) {
|
|
4872
|
-
sel = FlatVector::IncrementalSelectionVector(
|
|
4901
|
+
sel = FlatVector::IncrementalSelectionVector();
|
|
4873
4902
|
}
|
|
4874
4903
|
if (left.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
4875
4904
|
right.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
@@ -4909,9 +4938,23 @@ public:
|
|
|
4909
4938
|
|
|
4910
4939
|
namespace duckdb {
|
|
4911
4940
|
|
|
4941
|
+
struct TernaryLambdaWrapper {
|
|
4942
|
+
template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
|
|
4943
|
+
static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
|
|
4944
|
+
return fun(a, b, c);
|
|
4945
|
+
}
|
|
4946
|
+
};
|
|
4947
|
+
|
|
4948
|
+
struct TernaryLambdaWrapperWithNulls {
|
|
4949
|
+
template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
|
|
4950
|
+
static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
|
|
4951
|
+
return fun(a, b, c, mask, idx);
|
|
4952
|
+
}
|
|
4953
|
+
};
|
|
4954
|
+
|
|
4912
4955
|
struct TernaryExecutor {
|
|
4913
4956
|
private:
|
|
4914
|
-
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class FUN>
|
|
4957
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
|
|
4915
4958
|
static inline void ExecuteLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
|
|
4916
4959
|
RESULT_TYPE *__restrict result_data, idx_t count, const SelectionVector &asel,
|
|
4917
4960
|
const SelectionVector &bsel, const SelectionVector &csel, ValidityMask &avalidity,
|
|
@@ -4923,7 +4966,8 @@ private:
|
|
|
4923
4966
|
auto bidx = bsel.get_index(i);
|
|
4924
4967
|
auto cidx = csel.get_index(i);
|
|
4925
4968
|
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx) && cvalidity.RowIsValid(cidx)) {
|
|
4926
|
-
result_data[i] =
|
|
4969
|
+
result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
4970
|
+
fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
|
|
4927
4971
|
} else {
|
|
4928
4972
|
result_validity.SetInvalid(i);
|
|
4929
4973
|
}
|
|
@@ -4933,15 +4977,15 @@ private:
|
|
|
4933
4977
|
auto aidx = asel.get_index(i);
|
|
4934
4978
|
auto bidx = bsel.get_index(i);
|
|
4935
4979
|
auto cidx = csel.get_index(i);
|
|
4936
|
-
result_data[i] =
|
|
4980
|
+
result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
4981
|
+
fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
|
|
4937
4982
|
}
|
|
4938
4983
|
}
|
|
4939
4984
|
}
|
|
4940
4985
|
|
|
4941
4986
|
public:
|
|
4942
|
-
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
4943
|
-
|
|
4944
|
-
static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
4987
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
|
|
4988
|
+
static void ExecuteGeneric(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
4945
4989
|
if (a.GetVectorType() == VectorType::CONSTANT_VECTOR && b.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
4946
4990
|
c.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
4947
4991
|
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
@@ -4952,7 +4996,9 @@ public:
|
|
|
4952
4996
|
auto bdata = ConstantVector::GetData<B_TYPE>(b);
|
|
4953
4997
|
auto cdata = ConstantVector::GetData<C_TYPE>(c);
|
|
4954
4998
|
auto result_data = ConstantVector::GetData<RESULT_TYPE>(result);
|
|
4955
|
-
|
|
4999
|
+
auto &result_validity = ConstantVector::Validity(result);
|
|
5000
|
+
result_data[0] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
5001
|
+
fun, adata[0], bdata[0], cdata[0], result_validity, 0);
|
|
4956
5002
|
}
|
|
4957
5003
|
} else {
|
|
4958
5004
|
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
@@ -4962,13 +5008,26 @@ public:
|
|
|
4962
5008
|
b.Orrify(count, bdata);
|
|
4963
5009
|
c.Orrify(count, cdata);
|
|
4964
5010
|
|
|
4965
|
-
ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
|
|
5011
|
+
ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, OPWRAPPER>(
|
|
4966
5012
|
(A_TYPE *)adata.data, (B_TYPE *)bdata.data, (C_TYPE *)cdata.data,
|
|
4967
5013
|
FlatVector::GetData<RESULT_TYPE>(result), count, *adata.sel, *bdata.sel, *cdata.sel, adata.validity,
|
|
4968
5014
|
bdata.validity, cdata.validity, FlatVector::Validity(result), fun);
|
|
4969
5015
|
}
|
|
4970
5016
|
}
|
|
4971
5017
|
|
|
5018
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
5019
|
+
class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE)>>
|
|
5020
|
+
static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
5021
|
+
ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapper, FUN>(a, b, c, result, count, fun);
|
|
5022
|
+
}
|
|
5023
|
+
|
|
5024
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
5025
|
+
class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE, ValidityMask &, idx_t)>>
|
|
5026
|
+
static void ExecuteWithNulls(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
|
|
5027
|
+
ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapperWithNulls, FUN>(a, b, c, result, count,
|
|
5028
|
+
fun);
|
|
5029
|
+
}
|
|
5030
|
+
|
|
4972
5031
|
private:
|
|
4973
5032
|
template <class A_TYPE, class B_TYPE, class C_TYPE, class OP, bool NO_NULL, bool HAS_TRUE_SEL, bool HAS_FALSE_SEL>
|
|
4974
5033
|
static inline idx_t SelectLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
|
|
@@ -5038,9 +5097,8 @@ public:
|
|
|
5038
5097
|
template <class A_TYPE, class B_TYPE, class C_TYPE, class OP>
|
|
5039
5098
|
static idx_t Select(Vector &a, Vector &b, Vector &c, const SelectionVector *sel, idx_t count,
|
|
5040
5099
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
5041
|
-
SelectionVector owned_sel;
|
|
5042
5100
|
if (!sel) {
|
|
5043
|
-
sel = FlatVector::IncrementalSelectionVector(
|
|
5101
|
+
sel = FlatVector::IncrementalSelectionVector();
|
|
5044
5102
|
}
|
|
5045
5103
|
VectorData adata, bdata, cdata;
|
|
5046
5104
|
a.Orrify(count, adata);
|
|
@@ -5315,195 +5373,6 @@ using std::chrono::system_clock;
|
|
|
5315
5373
|
using std::chrono::time_point;
|
|
5316
5374
|
} // namespace duckdb
|
|
5317
5375
|
|
|
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
5376
|
|
|
5508
5377
|
namespace duckdb {
|
|
5509
5378
|
|
|
@@ -5561,7 +5430,6 @@ private:
|
|
|
5561
5430
|
|
|
5562
5431
|
} // namespace duckdb
|
|
5563
5432
|
|
|
5564
|
-
|
|
5565
5433
|
//===----------------------------------------------------------------------===//
|
|
5566
5434
|
// DuckDB
|
|
5567
5435
|
//
|
|
@@ -6074,7 +5942,7 @@ public:
|
|
|
6074
5942
|
//! Convert the Expression to a String
|
|
6075
5943
|
virtual string ToString() const = 0;
|
|
6076
5944
|
//! Print the expression to stdout
|
|
6077
|
-
void Print();
|
|
5945
|
+
void Print() const;
|
|
6078
5946
|
|
|
6079
5947
|
//! Creates a hash value of this expression. It is important that if two expressions are identical (i.e.
|
|
6080
5948
|
//! Expression::Equals() returns true), that their hash value is identical as well.
|
|
@@ -6137,7 +6005,7 @@ public:
|
|
|
6137
6005
|
static bool RequiresQuotes(const string &text);
|
|
6138
6006
|
|
|
6139
6007
|
//! Writes a string that is optionally quoted + escaped so it can be used as an identifier
|
|
6140
|
-
static string WriteOptionallyQuoted(const string &text);
|
|
6008
|
+
static string WriteOptionallyQuoted(const string &text, char quote = '"');
|
|
6141
6009
|
};
|
|
6142
6010
|
|
|
6143
6011
|
} // namespace duckdb
|
|
@@ -6338,31 +6206,104 @@ string CompressionTypeToString(CompressionType type);
|
|
|
6338
6206
|
|
|
6339
6207
|
} // namespace duckdb
|
|
6340
6208
|
|
|
6209
|
+
//===----------------------------------------------------------------------===//
|
|
6210
|
+
// DuckDB
|
|
6211
|
+
//
|
|
6212
|
+
// duckdb/catalog/catalog_entry/table_column_type.hpp
|
|
6213
|
+
//
|
|
6214
|
+
//
|
|
6215
|
+
//===----------------------------------------------------------------------===//
|
|
6216
|
+
|
|
6217
|
+
|
|
6218
|
+
|
|
6219
|
+
|
|
6220
|
+
|
|
6221
|
+
namespace duckdb {
|
|
6222
|
+
|
|
6223
|
+
enum class TableColumnType : uint8_t { STANDARD = 0, GENERATED = 1 };
|
|
6224
|
+
|
|
6225
|
+
} // namespace duckdb
|
|
6226
|
+
|
|
6227
|
+
|
|
6341
6228
|
|
|
6342
6229
|
namespace duckdb {
|
|
6343
6230
|
|
|
6231
|
+
struct RenameColumnInfo;
|
|
6232
|
+
struct RenameTableInfo;
|
|
6233
|
+
|
|
6234
|
+
class ColumnDefinition;
|
|
6235
|
+
|
|
6344
6236
|
//! A column of a table.
|
|
6345
6237
|
class ColumnDefinition {
|
|
6346
6238
|
public:
|
|
6347
6239
|
DUCKDB_API ColumnDefinition(string name, LogicalType type);
|
|
6348
|
-
DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression>
|
|
6240
|
+
DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression> expression,
|
|
6241
|
+
TableColumnType category);
|
|
6349
6242
|
|
|
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
6243
|
//! The default value of the column (if any)
|
|
6357
6244
|
unique_ptr<ParsedExpression> default_value;
|
|
6358
|
-
//! Compression Type used for this column
|
|
6359
|
-
CompressionType compression_type = CompressionType::COMPRESSION_AUTO;
|
|
6360
6245
|
|
|
6361
6246
|
public:
|
|
6247
|
+
//! default_value
|
|
6248
|
+
const unique_ptr<ParsedExpression> &DefaultValue() const;
|
|
6249
|
+
void SetDefaultValue(unique_ptr<ParsedExpression> default_value);
|
|
6250
|
+
|
|
6251
|
+
//! type
|
|
6252
|
+
DUCKDB_API const LogicalType &Type() const;
|
|
6253
|
+
LogicalType &TypeMutable();
|
|
6254
|
+
void SetType(const LogicalType &type);
|
|
6255
|
+
|
|
6256
|
+
//! name
|
|
6257
|
+
DUCKDB_API const string &Name() const;
|
|
6258
|
+
void SetName(const string &name);
|
|
6259
|
+
|
|
6260
|
+
//! compression_type
|
|
6261
|
+
const duckdb::CompressionType &CompressionType() const;
|
|
6262
|
+
void SetCompressionType(duckdb::CompressionType compression_type);
|
|
6263
|
+
|
|
6264
|
+
//! storage_oid
|
|
6265
|
+
const storage_t &StorageOid() const;
|
|
6266
|
+
void SetStorageOid(storage_t storage_oid);
|
|
6267
|
+
|
|
6268
|
+
//! oid
|
|
6269
|
+
const column_t &Oid() const;
|
|
6270
|
+
void SetOid(column_t oid);
|
|
6271
|
+
|
|
6272
|
+
//! category
|
|
6273
|
+
const TableColumnType &Category() const;
|
|
6274
|
+
//! Whether this column is a Generated Column
|
|
6275
|
+
bool Generated() const;
|
|
6362
6276
|
DUCKDB_API ColumnDefinition Copy() const;
|
|
6363
6277
|
|
|
6364
6278
|
DUCKDB_API void Serialize(Serializer &serializer) const;
|
|
6365
6279
|
DUCKDB_API static ColumnDefinition Deserialize(Deserializer &source);
|
|
6280
|
+
|
|
6281
|
+
//===--------------------------------------------------------------------===//
|
|
6282
|
+
// Generated Columns (VIRTUAL)
|
|
6283
|
+
//===--------------------------------------------------------------------===//
|
|
6284
|
+
|
|
6285
|
+
ParsedExpression &GeneratedExpressionMutable();
|
|
6286
|
+
const ParsedExpression &GeneratedExpression() const;
|
|
6287
|
+
void SetGeneratedExpression(unique_ptr<ParsedExpression> expression);
|
|
6288
|
+
void ChangeGeneratedExpressionType(const LogicalType &type);
|
|
6289
|
+
void GetListOfDependencies(vector<string> &dependencies) const;
|
|
6290
|
+
|
|
6291
|
+
private:
|
|
6292
|
+
private:
|
|
6293
|
+
//! The name of the entry
|
|
6294
|
+
string name;
|
|
6295
|
+
//! The type of the column
|
|
6296
|
+
LogicalType type;
|
|
6297
|
+
//! Compression Type used for this column
|
|
6298
|
+
duckdb::CompressionType compression_type = duckdb::CompressionType::COMPRESSION_AUTO;
|
|
6299
|
+
//! The index of the column in the storage of the table
|
|
6300
|
+
storage_t storage_oid;
|
|
6301
|
+
//! The index of the column in the table
|
|
6302
|
+
idx_t oid;
|
|
6303
|
+
//! The category of the column
|
|
6304
|
+
TableColumnType category = TableColumnType::STANDARD;
|
|
6305
|
+
//! Used by Generated Columns
|
|
6306
|
+
unique_ptr<ParsedExpression> generated_expression;
|
|
6366
6307
|
};
|
|
6367
6308
|
|
|
6368
6309
|
} // namespace duckdb
|
|
@@ -6390,14 +6331,19 @@ struct PragmaInfo;
|
|
|
6390
6331
|
struct FunctionData {
|
|
6391
6332
|
DUCKDB_API virtual ~FunctionData();
|
|
6392
6333
|
|
|
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);
|
|
6334
|
+
DUCKDB_API virtual unique_ptr<FunctionData> Copy() const = 0;
|
|
6335
|
+
DUCKDB_API virtual bool Equals(const FunctionData &other) const = 0;
|
|
6336
|
+
DUCKDB_API static bool Equals(const FunctionData *left, const FunctionData *right);
|
|
6396
6337
|
};
|
|
6397
6338
|
|
|
6398
6339
|
struct TableFunctionData : public FunctionData {
|
|
6399
6340
|
// used to pass on projections to table functions that support them. NB, can contain COLUMN_IDENTIFIER_ROW_ID
|
|
6400
6341
|
vector<idx_t> column_ids;
|
|
6342
|
+
|
|
6343
|
+
DUCKDB_API virtual ~TableFunctionData();
|
|
6344
|
+
|
|
6345
|
+
DUCKDB_API unique_ptr<FunctionData> Copy() const override;
|
|
6346
|
+
DUCKDB_API bool Equals(const FunctionData &other) const override;
|
|
6401
6347
|
};
|
|
6402
6348
|
|
|
6403
6349
|
struct FunctionParameters {
|
|
@@ -6427,11 +6373,14 @@ public:
|
|
|
6427
6373
|
//! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
|
|
6428
6374
|
//! returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6429
6375
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
|
|
6430
|
-
vector<LogicalType> &arguments, string &error);
|
|
6376
|
+
vector<LogicalType> &arguments, string &error, bool &cast_parameters);
|
|
6431
6377
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
|
|
6432
|
-
vector<unique_ptr<Expression>> &arguments, string &error
|
|
6378
|
+
vector<unique_ptr<Expression>> &arguments, string &error,
|
|
6379
|
+
bool &cast_parameters);
|
|
6433
6380
|
//! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
|
|
6434
6381
|
//! function, returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6382
|
+
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
6383
|
+
vector<LogicalType> &arguments, string &error, bool &cast_parameters);
|
|
6435
6384
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
6436
6385
|
vector<LogicalType> &arguments, string &error);
|
|
6437
6386
|
DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
|
|
@@ -6477,10 +6426,6 @@ public:
|
|
|
6477
6426
|
public:
|
|
6478
6427
|
DUCKDB_API string ToString() override;
|
|
6479
6428
|
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
6429
|
};
|
|
6485
6430
|
|
|
6486
6431
|
class BaseScalarFunction : public SimpleFunction {
|
|
@@ -6502,7 +6447,8 @@ public:
|
|
|
6502
6447
|
DUCKDB_API hash_t Hash() const;
|
|
6503
6448
|
|
|
6504
6449
|
//! Cast a set of expressions to the arguments of this function
|
|
6505
|
-
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children
|
|
6450
|
+
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children,
|
|
6451
|
+
bool cast_parameter_expressions = true);
|
|
6506
6452
|
|
|
6507
6453
|
DUCKDB_API string ToString() override;
|
|
6508
6454
|
};
|
|
@@ -6574,6 +6520,7 @@ namespace duckdb {
|
|
|
6574
6520
|
class Expression;
|
|
6575
6521
|
class ExpressionExecutor;
|
|
6576
6522
|
struct ExpressionExecutorState;
|
|
6523
|
+
struct FunctionLocalState;
|
|
6577
6524
|
|
|
6578
6525
|
struct ExpressionState {
|
|
6579
6526
|
ExpressionState(const Expression &expr, ExpressionExecutorState &root);
|
|
@@ -6594,13 +6541,13 @@ public:
|
|
|
6594
6541
|
};
|
|
6595
6542
|
|
|
6596
6543
|
struct ExecuteFunctionState : public ExpressionState {
|
|
6597
|
-
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root)
|
|
6598
|
-
|
|
6544
|
+
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root);
|
|
6545
|
+
~ExecuteFunctionState();
|
|
6599
6546
|
|
|
6600
|
-
unique_ptr<
|
|
6547
|
+
unique_ptr<FunctionLocalState> local_state;
|
|
6601
6548
|
|
|
6602
6549
|
public:
|
|
6603
|
-
static
|
|
6550
|
+
static FunctionLocalState *GetFunctionState(ExpressionState &state) {
|
|
6604
6551
|
return ((ExecuteFunctionState &)state).local_state.get();
|
|
6605
6552
|
}
|
|
6606
6553
|
};
|
|
@@ -6651,7 +6598,152 @@ struct ExpressionExecutorState {
|
|
|
6651
6598
|
|
|
6652
6599
|
|
|
6653
6600
|
|
|
6654
|
-
|
|
6601
|
+
//===----------------------------------------------------------------------===//
|
|
6602
|
+
// DuckDB
|
|
6603
|
+
//
|
|
6604
|
+
// duckdb/common/limits.hpp
|
|
6605
|
+
//
|
|
6606
|
+
//
|
|
6607
|
+
//===----------------------------------------------------------------------===//
|
|
6608
|
+
|
|
6609
|
+
|
|
6610
|
+
|
|
6611
|
+
|
|
6612
|
+
|
|
6613
|
+
namespace duckdb {
|
|
6614
|
+
|
|
6615
|
+
template <class T>
|
|
6616
|
+
struct NumericLimits {
|
|
6617
|
+
static T Minimum();
|
|
6618
|
+
static T Maximum();
|
|
6619
|
+
static bool IsSigned();
|
|
6620
|
+
static idx_t Digits();
|
|
6621
|
+
};
|
|
6622
|
+
|
|
6623
|
+
template <>
|
|
6624
|
+
struct NumericLimits<int8_t> {
|
|
6625
|
+
static int8_t Minimum();
|
|
6626
|
+
static int8_t Maximum();
|
|
6627
|
+
static bool IsSigned() {
|
|
6628
|
+
return true;
|
|
6629
|
+
}
|
|
6630
|
+
static idx_t Digits() {
|
|
6631
|
+
return 3;
|
|
6632
|
+
}
|
|
6633
|
+
};
|
|
6634
|
+
template <>
|
|
6635
|
+
struct NumericLimits<int16_t> {
|
|
6636
|
+
static int16_t Minimum();
|
|
6637
|
+
static int16_t Maximum();
|
|
6638
|
+
static bool IsSigned() {
|
|
6639
|
+
return true;
|
|
6640
|
+
}
|
|
6641
|
+
static idx_t Digits() {
|
|
6642
|
+
return 5;
|
|
6643
|
+
}
|
|
6644
|
+
};
|
|
6645
|
+
template <>
|
|
6646
|
+
struct NumericLimits<int32_t> {
|
|
6647
|
+
static int32_t Minimum();
|
|
6648
|
+
static int32_t Maximum();
|
|
6649
|
+
static bool IsSigned() {
|
|
6650
|
+
return true;
|
|
6651
|
+
}
|
|
6652
|
+
static idx_t Digits() {
|
|
6653
|
+
return 10;
|
|
6654
|
+
}
|
|
6655
|
+
};
|
|
6656
|
+
template <>
|
|
6657
|
+
struct NumericLimits<int64_t> {
|
|
6658
|
+
static int64_t Minimum();
|
|
6659
|
+
static int64_t Maximum();
|
|
6660
|
+
static bool IsSigned() {
|
|
6661
|
+
return true;
|
|
6662
|
+
}
|
|
6663
|
+
static idx_t Digits() {
|
|
6664
|
+
return 19;
|
|
6665
|
+
}
|
|
6666
|
+
};
|
|
6667
|
+
template <>
|
|
6668
|
+
struct NumericLimits<hugeint_t> {
|
|
6669
|
+
static hugeint_t Minimum();
|
|
6670
|
+
static hugeint_t Maximum();
|
|
6671
|
+
static bool IsSigned() {
|
|
6672
|
+
return true;
|
|
6673
|
+
}
|
|
6674
|
+
static idx_t Digits() {
|
|
6675
|
+
return 39;
|
|
6676
|
+
}
|
|
6677
|
+
};
|
|
6678
|
+
template <>
|
|
6679
|
+
struct NumericLimits<uint8_t> {
|
|
6680
|
+
static uint8_t Minimum();
|
|
6681
|
+
static uint8_t Maximum();
|
|
6682
|
+
static bool IsSigned() {
|
|
6683
|
+
return false;
|
|
6684
|
+
}
|
|
6685
|
+
static idx_t Digits() {
|
|
6686
|
+
return 3;
|
|
6687
|
+
}
|
|
6688
|
+
};
|
|
6689
|
+
template <>
|
|
6690
|
+
struct NumericLimits<uint16_t> {
|
|
6691
|
+
static uint16_t Minimum();
|
|
6692
|
+
static uint16_t Maximum();
|
|
6693
|
+
static bool IsSigned() {
|
|
6694
|
+
return false;
|
|
6695
|
+
}
|
|
6696
|
+
static idx_t Digits() {
|
|
6697
|
+
return 5;
|
|
6698
|
+
}
|
|
6699
|
+
};
|
|
6700
|
+
template <>
|
|
6701
|
+
struct NumericLimits<uint32_t> {
|
|
6702
|
+
static uint32_t Minimum();
|
|
6703
|
+
static uint32_t Maximum();
|
|
6704
|
+
static bool IsSigned() {
|
|
6705
|
+
return false;
|
|
6706
|
+
}
|
|
6707
|
+
static idx_t Digits() {
|
|
6708
|
+
return 10;
|
|
6709
|
+
}
|
|
6710
|
+
};
|
|
6711
|
+
template <>
|
|
6712
|
+
struct NumericLimits<uint64_t> {
|
|
6713
|
+
static uint64_t Minimum();
|
|
6714
|
+
static uint64_t Maximum();
|
|
6715
|
+
static bool IsSigned() {
|
|
6716
|
+
return false;
|
|
6717
|
+
}
|
|
6718
|
+
static idx_t Digits() {
|
|
6719
|
+
return 20;
|
|
6720
|
+
}
|
|
6721
|
+
};
|
|
6722
|
+
template <>
|
|
6723
|
+
struct NumericLimits<float> {
|
|
6724
|
+
static float Minimum();
|
|
6725
|
+
static float Maximum();
|
|
6726
|
+
static bool IsSigned() {
|
|
6727
|
+
return true;
|
|
6728
|
+
}
|
|
6729
|
+
static idx_t Digits() {
|
|
6730
|
+
return 127;
|
|
6731
|
+
}
|
|
6732
|
+
};
|
|
6733
|
+
template <>
|
|
6734
|
+
struct NumericLimits<double> {
|
|
6735
|
+
static double Minimum();
|
|
6736
|
+
static double Maximum();
|
|
6737
|
+
static bool IsSigned() {
|
|
6738
|
+
return true;
|
|
6739
|
+
}
|
|
6740
|
+
static idx_t Digits() {
|
|
6741
|
+
return 250;
|
|
6742
|
+
}
|
|
6743
|
+
};
|
|
6744
|
+
|
|
6745
|
+
} // namespace duckdb
|
|
6746
|
+
|
|
6655
6747
|
|
|
6656
6748
|
|
|
6657
6749
|
namespace duckdb {
|
|
@@ -7196,32 +7288,46 @@ class FieldWriter;
|
|
|
7196
7288
|
class FieldReader;
|
|
7197
7289
|
class Vector;
|
|
7198
7290
|
class ValidityStatistics;
|
|
7291
|
+
class DistinctStatistics;
|
|
7292
|
+
struct VectorData;
|
|
7293
|
+
|
|
7294
|
+
enum StatisticsType { LOCAL_STATS = 0, GLOBAL_STATS = 1 };
|
|
7199
7295
|
|
|
7200
7296
|
class BaseStatistics {
|
|
7201
7297
|
public:
|
|
7202
|
-
|
|
7298
|
+
BaseStatistics(LogicalType type, StatisticsType stats_type);
|
|
7203
7299
|
virtual ~BaseStatistics();
|
|
7204
7300
|
|
|
7205
7301
|
//! The type of the logical segment
|
|
7206
7302
|
LogicalType type;
|
|
7207
7303
|
//! The validity stats of the column (if any)
|
|
7208
7304
|
unique_ptr<BaseStatistics> validity_stats;
|
|
7305
|
+
//! The approximate count distinct stats of the column (if any)
|
|
7306
|
+
unique_ptr<BaseStatistics> distinct_stats;
|
|
7307
|
+
//! Whether these are 'global' stats, i.e., over a whole table, or just over a segment
|
|
7308
|
+
//! Some statistics are more expensive to keep, therefore we only keep them globally
|
|
7309
|
+
StatisticsType stats_type;
|
|
7209
7310
|
|
|
7210
7311
|
public:
|
|
7312
|
+
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type, StatisticsType stats_type);
|
|
7313
|
+
|
|
7211
7314
|
bool CanHaveNull() const;
|
|
7212
7315
|
bool CanHaveNoNull() const;
|
|
7213
7316
|
|
|
7317
|
+
void UpdateDistinctStatistics(Vector &v, idx_t count);
|
|
7318
|
+
|
|
7214
7319
|
virtual bool IsConstant() const {
|
|
7215
7320
|
return false;
|
|
7216
7321
|
}
|
|
7217
7322
|
|
|
7218
|
-
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type);
|
|
7219
|
-
|
|
7220
7323
|
virtual void Merge(const BaseStatistics &other);
|
|
7221
7324
|
|
|
7222
7325
|
virtual unique_ptr<BaseStatistics> Copy() const;
|
|
7223
|
-
void
|
|
7326
|
+
void CopyBase(const BaseStatistics &orig);
|
|
7327
|
+
|
|
7328
|
+
virtual void Serialize(Serializer &serializer) const;
|
|
7224
7329
|
virtual void Serialize(FieldWriter &writer) const;
|
|
7330
|
+
|
|
7225
7331
|
static unique_ptr<BaseStatistics> Deserialize(Deserializer &source, LogicalType type);
|
|
7226
7332
|
|
|
7227
7333
|
//! Verify that a vector does not violate the statistics
|
|
@@ -7229,12 +7335,20 @@ public:
|
|
|
7229
7335
|
void Verify(Vector &vector, idx_t count) const;
|
|
7230
7336
|
|
|
7231
7337
|
virtual string ToString() const;
|
|
7338
|
+
|
|
7339
|
+
protected:
|
|
7340
|
+
void InitializeBase();
|
|
7232
7341
|
};
|
|
7233
7342
|
|
|
7234
7343
|
} // namespace duckdb
|
|
7235
7344
|
|
|
7236
7345
|
|
|
7237
7346
|
namespace duckdb {
|
|
7347
|
+
|
|
7348
|
+
struct FunctionLocalState {
|
|
7349
|
+
DUCKDB_API virtual ~FunctionLocalState();
|
|
7350
|
+
};
|
|
7351
|
+
|
|
7238
7352
|
class BoundFunctionExpression;
|
|
7239
7353
|
class ScalarFunctionCatalogEntry;
|
|
7240
7354
|
|
|
@@ -7243,7 +7357,8 @@ typedef std::function<void(DataChunk &, ExpressionState &, Vector &)> scalar_fun
|
|
|
7243
7357
|
//! Binds the scalar function and creates the function data
|
|
7244
7358
|
typedef unique_ptr<FunctionData> (*bind_scalar_function_t)(ClientContext &context, ScalarFunction &bound_function,
|
|
7245
7359
|
vector<unique_ptr<Expression>> &arguments);
|
|
7246
|
-
typedef unique_ptr<
|
|
7360
|
+
typedef unique_ptr<FunctionLocalState> (*init_local_state_t)(const BoundFunctionExpression &expr,
|
|
7361
|
+
FunctionData *bind_data);
|
|
7247
7362
|
typedef unique_ptr<BaseStatistics> (*function_statistics_t)(ClientContext &context, BoundFunctionExpression &expr,
|
|
7248
7363
|
FunctionData *bind_data,
|
|
7249
7364
|
vector<unique_ptr<BaseStatistics>> &child_stats);
|
|
@@ -7285,10 +7400,9 @@ public:
|
|
|
7285
7400
|
vector<unique_ptr<Expression>> children,
|
|
7286
7401
|
string &error, bool is_operator = false);
|
|
7287
7402
|
|
|
7288
|
-
DUCKDB_API static unique_ptr<BoundFunctionExpression>
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
bool is_operator = false);
|
|
7403
|
+
DUCKDB_API static unique_ptr<BoundFunctionExpression>
|
|
7404
|
+
BindScalarFunction(ClientContext &context, ScalarFunction bound_function, vector<unique_ptr<Expression>> children,
|
|
7405
|
+
bool is_operator = false, bool cast_parameters = true);
|
|
7292
7406
|
|
|
7293
7407
|
DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
|
|
7294
7408
|
DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
|
|
@@ -7716,13 +7830,13 @@ public:
|
|
|
7716
7830
|
}
|
|
7717
7831
|
|
|
7718
7832
|
template <class STATE_TYPE, class OP>
|
|
7719
|
-
static void Combine(Vector &source, Vector &target, idx_t count) {
|
|
7833
|
+
static void Combine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
7720
7834
|
D_ASSERT(source.GetType().id() == LogicalTypeId::POINTER && target.GetType().id() == LogicalTypeId::POINTER);
|
|
7721
7835
|
auto sdata = FlatVector::GetData<const STATE_TYPE *>(source);
|
|
7722
7836
|
auto tdata = FlatVector::GetData<STATE_TYPE *>(target);
|
|
7723
7837
|
|
|
7724
7838
|
for (idx_t i = 0; i < count; i++) {
|
|
7725
|
-
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i]);
|
|
7839
|
+
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i], bind_data);
|
|
7726
7840
|
}
|
|
7727
7841
|
}
|
|
7728
7842
|
|
|
@@ -7749,13 +7863,13 @@ public:
|
|
|
7749
7863
|
}
|
|
7750
7864
|
|
|
7751
7865
|
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) {
|
|
7866
|
+
static void UnaryWindow(Vector &input, const ValidityMask &ifilter, FunctionData *bind_data, data_ptr_t state,
|
|
7867
|
+
const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
|
|
7754
7868
|
|
|
7755
7869
|
auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
|
|
7756
7870
|
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);
|
|
7871
|
+
OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ifilter, ivalid, bind_data, (STATE *)state, frame,
|
|
7872
|
+
prev, result, rid, bias);
|
|
7759
7873
|
}
|
|
7760
7874
|
|
|
7761
7875
|
template <class STATE_TYPE, class OP>
|
|
@@ -8271,8 +8385,9 @@ public:
|
|
|
8271
8385
|
mutex write_lock;
|
|
8272
8386
|
|
|
8273
8387
|
public:
|
|
8274
|
-
//! Get the
|
|
8388
|
+
//! Get the Catalog from the ClientContext
|
|
8275
8389
|
DUCKDB_API static Catalog &GetCatalog(ClientContext &context);
|
|
8390
|
+
//! Get the Catalog from the DatabaseInstance
|
|
8276
8391
|
DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db);
|
|
8277
8392
|
|
|
8278
8393
|
DUCKDB_API DependencyManager &GetDependencyManager() {
|
|
@@ -8351,6 +8466,9 @@ public:
|
|
|
8351
8466
|
//! Gets the "schema.name" entry without a specified type, if entry does not exist an exception is thrown
|
|
8352
8467
|
DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &schema, const string &name);
|
|
8353
8468
|
|
|
8469
|
+
//! Fetches a logical type from the catalog
|
|
8470
|
+
DUCKDB_API LogicalType GetType(ClientContext &context, const string &schema, const string &name);
|
|
8471
|
+
|
|
8354
8472
|
template <class T>
|
|
8355
8473
|
T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
|
|
8356
8474
|
QueryErrorContext error_context = QueryErrorContext());
|
|
@@ -8409,6 +8527,9 @@ DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &conte
|
|
|
8409
8527
|
template <>
|
|
8410
8528
|
DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
8411
8529
|
bool if_exists, QueryErrorContext error_context);
|
|
8530
|
+
template <>
|
|
8531
|
+
DUCKDB_API TypeCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
8532
|
+
bool if_exists, QueryErrorContext error_context);
|
|
8412
8533
|
|
|
8413
8534
|
} // namespace duckdb
|
|
8414
8535
|
|
|
@@ -8953,8 +9074,8 @@ typedef void (*aggregate_initialize_t)(data_ptr_t state);
|
|
|
8953
9074
|
//! The type used for updating hashed aggregate functions
|
|
8954
9075
|
typedef void (*aggregate_update_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, Vector &state,
|
|
8955
9076
|
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);
|
|
9077
|
+
//! The type used for combining hashed aggregate states
|
|
9078
|
+
typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count);
|
|
8958
9079
|
//! The type used for finalizing hashed aggregate function payloads
|
|
8959
9080
|
typedef void (*aggregate_finalize_t)(Vector &state, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset);
|
|
8960
9081
|
//! The type used for propagating statistics in aggregate functions (optional)
|
|
@@ -8974,9 +9095,9 @@ typedef void (*aggregate_simple_update_t)(Vector inputs[], FunctionData *bind_da
|
|
|
8974
9095
|
|
|
8975
9096
|
//! The type used for updating complex windowed aggregate functions (optional)
|
|
8976
9097
|
typedef std::pair<idx_t, idx_t> FrameBounds;
|
|
8977
|
-
typedef void (*aggregate_window_t)(Vector inputs[],
|
|
8978
|
-
|
|
8979
|
-
idx_t bias);
|
|
9098
|
+
typedef void (*aggregate_window_t)(Vector inputs[], const ValidityMask &filter_mask, FunctionData *bind_data,
|
|
9099
|
+
idx_t input_count, data_ptr_t state, const FrameBounds &frame,
|
|
9100
|
+
const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias);
|
|
8980
9101
|
|
|
8981
9102
|
class AggregateFunction : public BaseScalarFunction {
|
|
8982
9103
|
public:
|
|
@@ -9058,7 +9179,8 @@ public:
|
|
|
9058
9179
|
DUCKDB_API static unique_ptr<BoundAggregateExpression>
|
|
9059
9180
|
BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
|
|
9060
9181
|
vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
|
|
9061
|
-
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr
|
|
9182
|
+
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr,
|
|
9183
|
+
bool cast_parameters = true);
|
|
9062
9184
|
|
|
9063
9185
|
DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
|
|
9064
9186
|
vector<unique_ptr<Expression>> &children,
|
|
@@ -9142,11 +9264,12 @@ public:
|
|
|
9142
9264
|
}
|
|
9143
9265
|
|
|
9144
9266
|
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
|
9145
|
-
static void UnaryWindow(Vector inputs[],
|
|
9146
|
-
const FrameBounds &frame, const FrameBounds &prev,
|
|
9267
|
+
static void UnaryWindow(Vector inputs[], const ValidityMask &filter_mask, FunctionData *bind_data,
|
|
9268
|
+
idx_t input_count, data_ptr_t state, const FrameBounds &frame, const FrameBounds &prev,
|
|
9269
|
+
Vector &result, idx_t rid, idx_t bias) {
|
|
9147
9270
|
D_ASSERT(input_count == 1);
|
|
9148
|
-
AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], bind_data, state,
|
|
9149
|
-
result, rid, bias);
|
|
9271
|
+
AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], filter_mask, bind_data, state,
|
|
9272
|
+
frame, prev, result, rid, bias);
|
|
9150
9273
|
}
|
|
9151
9274
|
|
|
9152
9275
|
template <class STATE, class A_TYPE, class B_TYPE, class OP>
|
|
@@ -9164,8 +9287,8 @@ public:
|
|
|
9164
9287
|
}
|
|
9165
9288
|
|
|
9166
9289
|
template <class STATE, class OP>
|
|
9167
|
-
static void StateCombine(Vector &source, Vector &target, idx_t count) {
|
|
9168
|
-
AggregateExecutor::Combine<STATE, OP>(source, target, count);
|
|
9290
|
+
static void StateCombine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
9291
|
+
AggregateExecutor::Combine<STATE, OP>(source, target, bind_data, count);
|
|
9169
9292
|
}
|
|
9170
9293
|
|
|
9171
9294
|
template <class STATE, class RESULT_TYPE, class OP>
|
|
@@ -9623,11 +9746,8 @@ public:
|
|
|
9623
9746
|
//! Copy a single cell to a target vector
|
|
9624
9747
|
DUCKDB_API void CopyCell(idx_t column, idx_t index, Vector &target, idx_t target_offset);
|
|
9625
9748
|
|
|
9626
|
-
DUCKDB_API string ToString() const
|
|
9627
|
-
|
|
9628
|
-
: "ChunkCollection [ " + std::to_string(count) + " ]: \n" + chunks[0]->ToString();
|
|
9629
|
-
}
|
|
9630
|
-
DUCKDB_API void Print();
|
|
9749
|
+
DUCKDB_API string ToString() const;
|
|
9750
|
+
DUCKDB_API void Print() const;
|
|
9631
9751
|
|
|
9632
9752
|
//! Gets a reference to the chunk at the given index
|
|
9633
9753
|
DUCKDB_API DataChunk &GetChunkForRow(idx_t row_index) {
|
|
@@ -9748,7 +9868,32 @@ enum class StatementType : uint8_t {
|
|
|
9748
9868
|
};
|
|
9749
9869
|
|
|
9750
9870
|
string StatementTypeToString(StatementType type);
|
|
9751
|
-
|
|
9871
|
+
|
|
9872
|
+
enum class StatementReturnType : uint8_t {
|
|
9873
|
+
QUERY_RESULT, // the statement returns a query result (e.g. for display to the user)
|
|
9874
|
+
CHANGED_ROWS, // the statement returns a single row containing the number of changed rows (e.g. an insert stmt)
|
|
9875
|
+
NOTHING // the statement returns nothing
|
|
9876
|
+
};
|
|
9877
|
+
|
|
9878
|
+
//! A struct containing various properties of a SQL statement
|
|
9879
|
+
struct StatementProperties {
|
|
9880
|
+
StatementProperties()
|
|
9881
|
+
: read_only(true), requires_valid_transaction(true), allow_stream_result(false), bound_all_parameters(true),
|
|
9882
|
+
return_type(StatementReturnType::QUERY_RESULT) {
|
|
9883
|
+
}
|
|
9884
|
+
|
|
9885
|
+
//! Whether or not the statement is a read-only statement, or whether it can result in changes to the database
|
|
9886
|
+
bool read_only;
|
|
9887
|
+
//! Whether or not the statement requires a valid transaction. Almost all statements require this, with the
|
|
9888
|
+
//! exception of
|
|
9889
|
+
bool requires_valid_transaction;
|
|
9890
|
+
//! Whether or not the result can be streamed to the client
|
|
9891
|
+
bool allow_stream_result;
|
|
9892
|
+
//! Whether or not all parameters have successfully had their types determined
|
|
9893
|
+
bool bound_all_parameters;
|
|
9894
|
+
//! What type of data the statement returns
|
|
9895
|
+
StatementReturnType return_type;
|
|
9896
|
+
};
|
|
9752
9897
|
|
|
9753
9898
|
} // namespace duckdb
|
|
9754
9899
|
|
|
@@ -9763,11 +9908,9 @@ enum class QueryResultType : uint8_t { MATERIALIZED_RESULT, STREAM_RESULT, PENDI
|
|
|
9763
9908
|
|
|
9764
9909
|
class BaseQueryResult {
|
|
9765
9910
|
public:
|
|
9766
|
-
//! Creates a successful empty query result
|
|
9767
|
-
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type);
|
|
9768
9911
|
//! Creates a successful query result with the specified names and types
|
|
9769
|
-
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type,
|
|
9770
|
-
vector<string> names);
|
|
9912
|
+
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
9913
|
+
vector<LogicalType> types, vector<string> names);
|
|
9771
9914
|
//! Creates an unsuccessful query result with error condition
|
|
9772
9915
|
DUCKDB_API BaseQueryResult(QueryResultType type, string error);
|
|
9773
9916
|
DUCKDB_API virtual ~BaseQueryResult();
|
|
@@ -9776,6 +9919,8 @@ public:
|
|
|
9776
9919
|
QueryResultType type;
|
|
9777
9920
|
//! The type of the statement that created this result
|
|
9778
9921
|
StatementType statement_type;
|
|
9922
|
+
//! Properties of the statement
|
|
9923
|
+
StatementProperties properties;
|
|
9779
9924
|
//! The SQL types of the result
|
|
9780
9925
|
vector<LogicalType> types;
|
|
9781
9926
|
//! The names of the result
|
|
@@ -9796,11 +9941,9 @@ public:
|
|
|
9796
9941
|
//! incrementally fetch data from the database.
|
|
9797
9942
|
class QueryResult : public BaseQueryResult {
|
|
9798
9943
|
public:
|
|
9799
|
-
//! Creates a successful empty query result
|
|
9800
|
-
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type);
|
|
9801
9944
|
//! Creates a successful query result with the specified names and types
|
|
9802
|
-
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type,
|
|
9803
|
-
vector<string> names);
|
|
9945
|
+
DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
|
|
9946
|
+
vector<LogicalType> types, vector<string> names);
|
|
9804
9947
|
//! Creates an unsuccessful query result with error condition
|
|
9805
9948
|
DUCKDB_API QueryResult(QueryResultType type, string error);
|
|
9806
9949
|
DUCKDB_API virtual ~QueryResult() override;
|
|
@@ -9836,7 +9979,10 @@ public:
|
|
|
9836
9979
|
}
|
|
9837
9980
|
}
|
|
9838
9981
|
|
|
9839
|
-
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names
|
|
9982
|
+
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names,
|
|
9983
|
+
string &config_timezone);
|
|
9984
|
+
|
|
9985
|
+
static string GetConfigTimezone(QueryResult &query_result);
|
|
9840
9986
|
|
|
9841
9987
|
private:
|
|
9842
9988
|
//! The current chunk used by the iterator
|
|
@@ -9914,17 +10060,23 @@ private:
|
|
|
9914
10060
|
|
|
9915
10061
|
namespace duckdb {
|
|
9916
10062
|
|
|
10063
|
+
class ClientContext;
|
|
10064
|
+
|
|
9917
10065
|
class MaterializedQueryResult : public QueryResult {
|
|
9918
10066
|
public:
|
|
9919
|
-
|
|
9920
|
-
DUCKDB_API explicit MaterializedQueryResult(StatementType statement_type);
|
|
10067
|
+
friend class ClientContext;
|
|
9921
10068
|
//! Creates a successful query result with the specified names and types
|
|
9922
|
-
DUCKDB_API MaterializedQueryResult(StatementType statement_type,
|
|
10069
|
+
DUCKDB_API MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
|
|
10070
|
+
vector<LogicalType> types, vector<string> names,
|
|
10071
|
+
const shared_ptr<ClientContext> &context);
|
|
9923
10072
|
//! Creates an unsuccessful query result with error condition
|
|
9924
10073
|
DUCKDB_API explicit MaterializedQueryResult(string error);
|
|
9925
10074
|
|
|
9926
10075
|
ChunkCollection collection;
|
|
9927
10076
|
|
|
10077
|
+
//! The client context this MaterializedQueryResult belongs to
|
|
10078
|
+
std::weak_ptr<ClientContext> context;
|
|
10079
|
+
|
|
9928
10080
|
public:
|
|
9929
10081
|
//! Fetches a DataChunk from the query result.
|
|
9930
10082
|
//! This will consume the result (i.e. the chunks are taken directly from the ChunkCollection).
|
|
@@ -10029,6 +10181,7 @@ enum class PhysicalOperatorType : uint8_t {
|
|
|
10029
10181
|
INVALID,
|
|
10030
10182
|
ORDER_BY,
|
|
10031
10183
|
LIMIT,
|
|
10184
|
+
STREAMING_LIMIT,
|
|
10032
10185
|
LIMIT_PERCENT,
|
|
10033
10186
|
TOP_N,
|
|
10034
10187
|
WINDOW,
|
|
@@ -10103,7 +10256,8 @@ enum class PhysicalOperatorType : uint8_t {
|
|
|
10103
10256
|
EXPORT,
|
|
10104
10257
|
SET,
|
|
10105
10258
|
LOAD,
|
|
10106
|
-
INOUT_FUNCTION
|
|
10259
|
+
INOUT_FUNCTION,
|
|
10260
|
+
RESULT_COLLECTOR
|
|
10107
10261
|
};
|
|
10108
10262
|
|
|
10109
10263
|
string PhysicalOperatorToString(PhysicalOperatorType type);
|
|
@@ -10182,8 +10336,10 @@ enum class SinkFinalizeType : uint8_t { READY, NO_OUTPUT_POSSIBLE };
|
|
|
10182
10336
|
|
|
10183
10337
|
namespace duckdb {
|
|
10184
10338
|
class Event;
|
|
10339
|
+
class Executor;
|
|
10185
10340
|
class PhysicalOperator;
|
|
10186
10341
|
class Pipeline;
|
|
10342
|
+
class PipelineBuildState;
|
|
10187
10343
|
|
|
10188
10344
|
// LCOV_EXCL_START
|
|
10189
10345
|
class OperatorState {
|
|
@@ -10215,6 +10371,13 @@ class LocalSinkState {
|
|
|
10215
10371
|
public:
|
|
10216
10372
|
virtual ~LocalSinkState() {
|
|
10217
10373
|
}
|
|
10374
|
+
|
|
10375
|
+
//! The current batch index
|
|
10376
|
+
//! This is only set in case RequiresBatchIndex() is true, and the source has support for it (SupportsBatchIndex())
|
|
10377
|
+
//! Otherwise this is left on INVALID_INDEX
|
|
10378
|
+
//! The batch index is a globally unique, increasing index that should be used to maintain insertion order
|
|
10379
|
+
//! //! in conjunction with parallelism
|
|
10380
|
+
idx_t batch_index = DConstants::INVALID_INDEX;
|
|
10218
10381
|
};
|
|
10219
10382
|
|
|
10220
10383
|
class GlobalSourceState {
|
|
@@ -10232,6 +10395,7 @@ public:
|
|
|
10232
10395
|
virtual ~LocalSourceState() {
|
|
10233
10396
|
}
|
|
10234
10397
|
};
|
|
10398
|
+
|
|
10235
10399
|
// LCOV_EXCL_STOP
|
|
10236
10400
|
|
|
10237
10401
|
//! PhysicalOperator is the base class of the physical operators present in the
|
|
@@ -10264,6 +10428,7 @@ public:
|
|
|
10264
10428
|
}
|
|
10265
10429
|
virtual string ToString() const;
|
|
10266
10430
|
void Print() const;
|
|
10431
|
+
virtual vector<PhysicalOperator *> GetChildren() const;
|
|
10267
10432
|
|
|
10268
10433
|
//! Return a vector of the types that will be returned by this operator
|
|
10269
10434
|
const vector<LogicalType> &GetTypes() const {
|
|
@@ -10274,6 +10439,14 @@ public:
|
|
|
10274
10439
|
return false;
|
|
10275
10440
|
}
|
|
10276
10441
|
|
|
10442
|
+
virtual void Verify();
|
|
10443
|
+
|
|
10444
|
+
//! Whether or not the operator depends on the order of the input chunks
|
|
10445
|
+
//! If this is set to true, we cannot do things like caching intermediate vectors
|
|
10446
|
+
virtual bool IsOrderDependent() const {
|
|
10447
|
+
return false;
|
|
10448
|
+
}
|
|
10449
|
+
|
|
10277
10450
|
public:
|
|
10278
10451
|
// Operator interface
|
|
10279
10452
|
virtual unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const;
|
|
@@ -10296,6 +10469,8 @@ public:
|
|
|
10296
10469
|
virtual unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const;
|
|
10297
10470
|
virtual void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
10298
10471
|
LocalSourceState &lstate) const;
|
|
10472
|
+
virtual idx_t GetBatchIndex(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
10473
|
+
LocalSourceState &lstate) const;
|
|
10299
10474
|
|
|
10300
10475
|
virtual bool IsSource() const {
|
|
10301
10476
|
return false;
|
|
@@ -10305,6 +10480,13 @@ public:
|
|
|
10305
10480
|
return false;
|
|
10306
10481
|
}
|
|
10307
10482
|
|
|
10483
|
+
virtual bool SupportsBatchIndex() const {
|
|
10484
|
+
return false;
|
|
10485
|
+
}
|
|
10486
|
+
|
|
10487
|
+
//! Returns the current progress percentage, or a negative value if progress bars are not supported
|
|
10488
|
+
virtual double GetProgress(ClientContext &context, GlobalSourceState &gstate) const;
|
|
10489
|
+
|
|
10308
10490
|
public:
|
|
10309
10491
|
// Sink interface
|
|
10310
10492
|
|
|
@@ -10333,9 +10515,19 @@ public:
|
|
|
10333
10515
|
return false;
|
|
10334
10516
|
}
|
|
10335
10517
|
|
|
10336
|
-
virtual bool
|
|
10518
|
+
virtual bool RequiresBatchIndex() const {
|
|
10337
10519
|
return false;
|
|
10338
10520
|
}
|
|
10521
|
+
|
|
10522
|
+
public:
|
|
10523
|
+
// Pipeline construction
|
|
10524
|
+
virtual vector<const PhysicalOperator *> GetSources() const;
|
|
10525
|
+
bool AllSourcesSupportBatchIndex() const;
|
|
10526
|
+
|
|
10527
|
+
void AddPipeline(Executor &executor, shared_ptr<Pipeline> current, PipelineBuildState &state);
|
|
10528
|
+
virtual void BuildPipelines(Executor &executor, Pipeline ¤t, PipelineBuildState &state);
|
|
10529
|
+
void BuildChildPipeline(Executor &executor, Pipeline ¤t, PipelineBuildState &state,
|
|
10530
|
+
PhysicalOperator *pipeline_child);
|
|
10339
10531
|
};
|
|
10340
10532
|
|
|
10341
10533
|
} // namespace duckdb
|
|
@@ -10352,26 +10544,35 @@ public:
|
|
|
10352
10544
|
|
|
10353
10545
|
|
|
10354
10546
|
|
|
10547
|
+
|
|
10548
|
+
|
|
10355
10549
|
#include <functional>
|
|
10356
10550
|
|
|
10357
10551
|
namespace duckdb {
|
|
10552
|
+
|
|
10358
10553
|
class BaseStatistics;
|
|
10359
10554
|
class LogicalGet;
|
|
10360
|
-
struct ParallelState;
|
|
10361
10555
|
class TableFilterSet;
|
|
10362
10556
|
|
|
10363
|
-
struct FunctionOperatorData {
|
|
10364
|
-
DUCKDB_API virtual ~FunctionOperatorData();
|
|
10365
|
-
};
|
|
10366
|
-
|
|
10367
10557
|
struct TableFunctionInfo {
|
|
10368
10558
|
DUCKDB_API virtual ~TableFunctionInfo();
|
|
10369
10559
|
};
|
|
10370
10560
|
|
|
10371
|
-
struct
|
|
10372
|
-
|
|
10561
|
+
struct GlobalTableFunctionState {
|
|
10562
|
+
public:
|
|
10563
|
+
// value returned from MaxThreads when as many threads as possible should be used
|
|
10564
|
+
constexpr static const int64_t MAX_THREADS = 999999999;
|
|
10565
|
+
|
|
10566
|
+
public:
|
|
10567
|
+
DUCKDB_API virtual ~GlobalTableFunctionState();
|
|
10568
|
+
|
|
10569
|
+
DUCKDB_API virtual idx_t MaxThreads() const {
|
|
10570
|
+
return 1;
|
|
10571
|
+
}
|
|
10572
|
+
};
|
|
10373
10573
|
|
|
10374
|
-
|
|
10574
|
+
struct LocalTableFunctionState {
|
|
10575
|
+
DUCKDB_API virtual ~LocalTableFunctionState();
|
|
10375
10576
|
};
|
|
10376
10577
|
|
|
10377
10578
|
struct TableFunctionBindInput {
|
|
@@ -10389,35 +10590,46 @@ struct TableFunctionBindInput {
|
|
|
10389
10590
|
TableFunctionInfo *info;
|
|
10390
10591
|
};
|
|
10391
10592
|
|
|
10593
|
+
struct TableFunctionInitInput {
|
|
10594
|
+
TableFunctionInitInput(const FunctionData *bind_data_p, const vector<column_t> &column_ids_p,
|
|
10595
|
+
TableFilterSet *filters_p)
|
|
10596
|
+
: bind_data(bind_data_p), column_ids(column_ids_p), filters(filters_p) {
|
|
10597
|
+
}
|
|
10598
|
+
|
|
10599
|
+
const FunctionData *bind_data;
|
|
10600
|
+
const vector<column_t> &column_ids;
|
|
10601
|
+
TableFilterSet *filters;
|
|
10602
|
+
};
|
|
10603
|
+
|
|
10604
|
+
struct TableFunctionInput {
|
|
10605
|
+
TableFunctionInput(const FunctionData *bind_data_p, LocalTableFunctionState *local_state_p,
|
|
10606
|
+
GlobalTableFunctionState *global_state_p)
|
|
10607
|
+
: bind_data(bind_data_p), local_state(local_state_p), global_state(global_state_p) {
|
|
10608
|
+
}
|
|
10609
|
+
|
|
10610
|
+
const FunctionData *bind_data;
|
|
10611
|
+
LocalTableFunctionState *local_state;
|
|
10612
|
+
GlobalTableFunctionState *global_state;
|
|
10613
|
+
};
|
|
10614
|
+
|
|
10392
10615
|
typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, TableFunctionBindInput &input,
|
|
10393
10616
|
vector<LogicalType> &return_types, vector<string> &names);
|
|
10394
|
-
typedef unique_ptr<
|
|
10395
|
-
|
|
10396
|
-
|
|
10617
|
+
typedef unique_ptr<GlobalTableFunctionState> (*table_function_init_global_t)(ClientContext &context,
|
|
10618
|
+
TableFunctionInitInput &input);
|
|
10619
|
+
typedef unique_ptr<LocalTableFunctionState> (*table_function_init_local_t)(ClientContext &context,
|
|
10620
|
+
TableFunctionInitInput &input,
|
|
10621
|
+
GlobalTableFunctionState *global_state);
|
|
10397
10622
|
typedef unique_ptr<BaseStatistics> (*table_statistics_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10398
10623
|
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);
|
|
10624
|
+
typedef void (*table_function_t)(ClientContext &context, TableFunctionInput &data, DataChunk &output);
|
|
10625
|
+
|
|
10626
|
+
typedef OperatorResultType (*table_in_out_function_t)(ClientContext &context, TableFunctionInput &data,
|
|
10627
|
+
DataChunk &input, DataChunk &output);
|
|
10628
|
+
typedef idx_t (*table_function_get_batch_index_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10629
|
+
LocalTableFunctionState *local_state,
|
|
10630
|
+
GlobalTableFunctionState *global_state);
|
|
10631
|
+
typedef double (*table_function_progress_t)(ClientContext &context, const FunctionData *bind_data,
|
|
10632
|
+
const GlobalTableFunctionState *global_state);
|
|
10421
10633
|
typedef void (*table_function_dependency_t)(unordered_set<CatalogEntry *> &dependencies, const FunctionData *bind_data);
|
|
10422
10634
|
typedef unique_ptr<NodeStatistics> (*table_function_cardinality_t)(ClientContext &context,
|
|
10423
10635
|
const FunctionData *bind_data);
|
|
@@ -10430,46 +10642,33 @@ class TableFunction : public SimpleNamedParameterFunction {
|
|
|
10430
10642
|
public:
|
|
10431
10643
|
DUCKDB_API
|
|
10432
10644
|
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);
|
|
10645
|
+
table_function_bind_t bind = nullptr, table_function_init_global_t init_global = nullptr,
|
|
10646
|
+
table_function_init_local_t init_local = nullptr);
|
|
10443
10647
|
DUCKDB_API
|
|
10444
10648
|
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);
|
|
10649
|
+
table_function_init_global_t init_global = nullptr, table_function_init_local_t init_local = nullptr);
|
|
10455
10650
|
DUCKDB_API TableFunction();
|
|
10456
10651
|
|
|
10457
10652
|
//! Bind function
|
|
10458
10653
|
//! This function is used for determining the return type of a table producing function and returning bind data
|
|
10459
10654
|
//! The returned FunctionData object should be constant and should not be changed during execution.
|
|
10460
10655
|
table_function_bind_t bind;
|
|
10461
|
-
//! (Optional) init function
|
|
10462
|
-
//! Initialize the operator state of the function.
|
|
10463
|
-
//! table function
|
|
10464
|
-
|
|
10656
|
+
//! (Optional) global init function
|
|
10657
|
+
//! Initialize the global operator state of the function.
|
|
10658
|
+
//! The global operator state is used to keep track of the progress in the table function and is shared between
|
|
10659
|
+
//! all threads working on the table function.
|
|
10660
|
+
table_function_init_global_t init_global;
|
|
10661
|
+
//! (Optional) local init function
|
|
10662
|
+
//! Initialize the local operator state of the function.
|
|
10663
|
+
//! The local operator state is used to keep track of the progress in the table function and is thread-local.
|
|
10664
|
+
table_function_init_local_t init_local;
|
|
10465
10665
|
//! The main function
|
|
10466
10666
|
table_function_t function;
|
|
10667
|
+
//! The table in-out function (if this is an in-out function)
|
|
10668
|
+
table_in_out_function_t in_out_function;
|
|
10467
10669
|
//! (Optional) statistics function
|
|
10468
10670
|
//! Returns the statistics of a specified column
|
|
10469
10671
|
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
10672
|
//! (Optional) dependency function
|
|
10474
10673
|
//! Sets up which catalog entries this table function depend on
|
|
10475
10674
|
table_function_dependency_t dependency;
|
|
@@ -10481,19 +10680,10 @@ public:
|
|
|
10481
10680
|
table_function_pushdown_complex_filter_t pushdown_complex_filter;
|
|
10482
10681
|
//! (Optional) function for rendering the operator to a string in profiling output
|
|
10483
10682
|
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
10683
|
//! (Optional) return how much of the table we have scanned up to this point (% of the data)
|
|
10496
10684
|
table_function_progress_t table_scan_progress;
|
|
10685
|
+
//! (Optional) returns the current batch index of the current scan operator
|
|
10686
|
+
table_function_get_batch_index_t get_batch_index;
|
|
10497
10687
|
//! Whether or not the table function supports projection pushdown. If not supported a projection will be added
|
|
10498
10688
|
//! that filters out unused columns.
|
|
10499
10689
|
bool projection_pushdown;
|
|
@@ -10506,25 +10696,6 @@ public:
|
|
|
10506
10696
|
|
|
10507
10697
|
} // namespace duckdb
|
|
10508
10698
|
|
|
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
10699
|
//===----------------------------------------------------------------------===//
|
|
10529
10700
|
// DuckDB
|
|
10530
10701
|
//
|
|
@@ -10611,11 +10782,11 @@ struct ProducerToken {
|
|
|
10611
10782
|
|
|
10612
10783
|
//! The TaskScheduler is responsible for managing tasks and threads
|
|
10613
10784
|
class TaskScheduler {
|
|
10614
|
-
// timeout for semaphore wait, default
|
|
10615
|
-
constexpr static int64_t TASK_TIMEOUT_USECS =
|
|
10785
|
+
// timeout for semaphore wait, default 5ms
|
|
10786
|
+
constexpr static int64_t TASK_TIMEOUT_USECS = 5000;
|
|
10616
10787
|
|
|
10617
10788
|
public:
|
|
10618
|
-
TaskScheduler();
|
|
10789
|
+
TaskScheduler(DatabaseInstance &db);
|
|
10619
10790
|
~TaskScheduler();
|
|
10620
10791
|
|
|
10621
10792
|
static TaskScheduler &GetScheduler(ClientContext &context);
|
|
@@ -10628,6 +10799,8 @@ public:
|
|
|
10628
10799
|
bool GetTaskFromProducer(ProducerToken &token, unique_ptr<Task> &task);
|
|
10629
10800
|
//! Run tasks forever until "marker" is set to false, "marker" must remain valid until the thread is joined
|
|
10630
10801
|
void ExecuteForever(atomic<bool> *marker);
|
|
10802
|
+
//! Run tasks until `max_tasks` have been completed, or until there are no more tasks available
|
|
10803
|
+
void ExecuteTasks(idx_t max_tasks);
|
|
10631
10804
|
|
|
10632
10805
|
//! Sets the amount of active threads executing tasks for the system; n-1 background threads will be launched.
|
|
10633
10806
|
//! The main thread will also be used for execution
|
|
@@ -10638,6 +10811,8 @@ public:
|
|
|
10638
10811
|
private:
|
|
10639
10812
|
void SetThreadsInternal(int32_t n);
|
|
10640
10813
|
|
|
10814
|
+
private:
|
|
10815
|
+
DatabaseInstance &db;
|
|
10641
10816
|
//! The task queue
|
|
10642
10817
|
unique_ptr<ConcurrentQueue> queue;
|
|
10643
10818
|
//! The active background threads of the task scheduler
|
|
@@ -10654,12 +10829,45 @@ namespace duckdb {
|
|
|
10654
10829
|
class Executor;
|
|
10655
10830
|
class Event;
|
|
10656
10831
|
|
|
10832
|
+
class PipelineBuildState {
|
|
10833
|
+
public:
|
|
10834
|
+
//! How much to increment batch indexes when multiple pipelines share the same source
|
|
10835
|
+
constexpr static idx_t BATCH_INCREMENT = 10000000000000;
|
|
10836
|
+
|
|
10837
|
+
public:
|
|
10838
|
+
//! The current recursive CTE node (if any)
|
|
10839
|
+
PhysicalOperator *recursive_cte = nullptr;
|
|
10840
|
+
|
|
10841
|
+
//! Duplicate eliminated join scan dependencies
|
|
10842
|
+
unordered_map<PhysicalOperator *, Pipeline *> delim_join_dependencies;
|
|
10843
|
+
|
|
10844
|
+
//! The number of pipelines that have each specific sink as their sink
|
|
10845
|
+
unordered_map<PhysicalOperator *, idx_t> sink_pipeline_count;
|
|
10846
|
+
|
|
10847
|
+
public:
|
|
10848
|
+
void SetPipelineSource(Pipeline &pipeline, PhysicalOperator *op);
|
|
10849
|
+
void SetPipelineSink(Pipeline &pipeline, PhysicalOperator *op);
|
|
10850
|
+
void SetPipelineOperators(Pipeline &pipeline, vector<PhysicalOperator *> operators);
|
|
10851
|
+
void AddPipelineOperator(Pipeline &pipeline, PhysicalOperator *op);
|
|
10852
|
+
void AddPipeline(Executor &executor, shared_ptr<Pipeline> pipeline);
|
|
10853
|
+
void AddChildPipeline(Executor &executor, Pipeline &pipeline);
|
|
10854
|
+
|
|
10855
|
+
unordered_map<Pipeline *, vector<shared_ptr<Pipeline>>> &GetUnionPipelines(Executor &executor);
|
|
10856
|
+
unordered_map<Pipeline *, vector<shared_ptr<Pipeline>>> &GetChildPipelines(Executor &executor);
|
|
10857
|
+
unordered_map<Pipeline *, vector<Pipeline *>> &GetChildDependencies(Executor &executor);
|
|
10858
|
+
|
|
10859
|
+
PhysicalOperator *GetPipelineSource(Pipeline &pipeline);
|
|
10860
|
+
PhysicalOperator *GetPipelineSink(Pipeline &pipeline);
|
|
10861
|
+
vector<PhysicalOperator *> GetPipelineOperators(Pipeline &pipeline);
|
|
10862
|
+
};
|
|
10863
|
+
|
|
10657
10864
|
//! The Pipeline class represents an execution pipeline
|
|
10658
10865
|
class Pipeline : public std::enable_shared_from_this<Pipeline> {
|
|
10659
10866
|
friend class Executor;
|
|
10660
10867
|
friend class PipelineExecutor;
|
|
10661
10868
|
friend class PipelineEvent;
|
|
10662
10869
|
friend class PipelineFinishEvent;
|
|
10870
|
+
friend class PipelineBuildState;
|
|
10663
10871
|
|
|
10664
10872
|
public:
|
|
10665
10873
|
explicit Pipeline(Executor &execution_context);
|
|
@@ -10683,7 +10891,7 @@ public:
|
|
|
10683
10891
|
void Print() const;
|
|
10684
10892
|
|
|
10685
10893
|
//! Returns query progress
|
|
10686
|
-
bool GetProgress(double ¤t_percentage);
|
|
10894
|
+
bool GetProgress(double ¤t_percentage, idx_t &estimated_cardinality);
|
|
10687
10895
|
|
|
10688
10896
|
//! Returns a list of all operators (including source and sink) involved in this pipeline
|
|
10689
10897
|
vector<PhysicalOperator *> GetOperators() const;
|
|
@@ -10692,6 +10900,9 @@ public:
|
|
|
10692
10900
|
return sink;
|
|
10693
10901
|
}
|
|
10694
10902
|
|
|
10903
|
+
//! Returns whether any of the operators in the pipeline care about preserving insertion order
|
|
10904
|
+
bool IsOrderDependent() const;
|
|
10905
|
+
|
|
10695
10906
|
private:
|
|
10696
10907
|
//! Whether or not the pipeline has been readied
|
|
10697
10908
|
bool ready;
|
|
@@ -10710,8 +10921,10 @@ private:
|
|
|
10710
10921
|
//! The dependencies of this pipeline
|
|
10711
10922
|
vector<weak_ptr<Pipeline>> dependencies;
|
|
10712
10923
|
|
|
10924
|
+
//! The base batch index of this pipeline
|
|
10925
|
+
idx_t base_batch_index = 0;
|
|
10926
|
+
|
|
10713
10927
|
private:
|
|
10714
|
-
bool GetProgressInternal(ClientContext &context, PhysicalOperator *op, double ¤t_percentage);
|
|
10715
10928
|
void ScheduleSequentialTask(shared_ptr<Event> &event);
|
|
10716
10929
|
bool LaunchScanTasks(shared_ptr<Event> &event, idx_t max_threads);
|
|
10717
10930
|
|
|
@@ -10758,6 +10971,7 @@ using event_map_t = unordered_map<const Pipeline *, PipelineEventStack>;
|
|
|
10758
10971
|
class Executor {
|
|
10759
10972
|
friend class Pipeline;
|
|
10760
10973
|
friend class PipelineTask;
|
|
10974
|
+
friend class PipelineBuildState;
|
|
10761
10975
|
|
|
10762
10976
|
public:
|
|
10763
10977
|
explicit Executor(ClientContext &context);
|
|
@@ -10769,7 +10983,7 @@ public:
|
|
|
10769
10983
|
static Executor &Get(ClientContext &context);
|
|
10770
10984
|
|
|
10771
10985
|
void Initialize(PhysicalOperator *physical_plan);
|
|
10772
|
-
void
|
|
10986
|
+
void Initialize(unique_ptr<PhysicalOperator> physical_plan);
|
|
10773
10987
|
|
|
10774
10988
|
void CancelTasks();
|
|
10775
10989
|
PendingExecutionResult ExecuteTask();
|
|
@@ -10807,7 +11021,14 @@ public:
|
|
|
10807
11021
|
|
|
10808
11022
|
void ReschedulePipelines(const vector<shared_ptr<Pipeline>> &pipelines, vector<shared_ptr<Event>> &events);
|
|
10809
11023
|
|
|
11024
|
+
//! Whether or not the root of the pipeline is a result collector object
|
|
11025
|
+
bool HasResultCollector();
|
|
11026
|
+
//! Returns the query result - can only be used if `HasResultCollector` returns true
|
|
11027
|
+
unique_ptr<QueryResult> GetResult();
|
|
11028
|
+
|
|
10810
11029
|
private:
|
|
11030
|
+
void InitializeInternal(PhysicalOperator *physical_plan);
|
|
11031
|
+
|
|
10811
11032
|
void ScheduleEvents();
|
|
10812
11033
|
void ScheduleEventsInternal(const vector<shared_ptr<Pipeline>> &pipelines,
|
|
10813
11034
|
unordered_map<Pipeline *, vector<shared_ptr<Pipeline>>> &child_pipelines,
|
|
@@ -10830,6 +11051,7 @@ private:
|
|
|
10830
11051
|
|
|
10831
11052
|
private:
|
|
10832
11053
|
PhysicalOperator *physical_plan;
|
|
11054
|
+
unique_ptr<PhysicalOperator> owned_plan;
|
|
10833
11055
|
|
|
10834
11056
|
mutex executor_lock;
|
|
10835
11057
|
//! The pipelines of the current query
|
|
@@ -10865,12 +11087,6 @@ private:
|
|
|
10865
11087
|
//! Dependencies of child pipelines
|
|
10866
11088
|
unordered_map<Pipeline *, vector<Pipeline *>> child_dependencies;
|
|
10867
11089
|
|
|
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
11090
|
//! The last pending execution result (if any)
|
|
10875
11091
|
PendingExecutionResult execution_result;
|
|
10876
11092
|
//! The current task in process (if any)
|
|
@@ -10889,7 +11105,7 @@ class PendingQueryResult : public BaseQueryResult {
|
|
|
10889
11105
|
|
|
10890
11106
|
public:
|
|
10891
11107
|
DUCKDB_API PendingQueryResult(shared_ptr<ClientContext> context, PreparedStatementData &statement,
|
|
10892
|
-
vector<LogicalType> types);
|
|
11108
|
+
vector<LogicalType> types, bool allow_stream_result);
|
|
10893
11109
|
DUCKDB_API explicit PendingQueryResult(string error_message);
|
|
10894
11110
|
DUCKDB_API ~PendingQueryResult();
|
|
10895
11111
|
|
|
@@ -10903,18 +11119,19 @@ public:
|
|
|
10903
11119
|
|
|
10904
11120
|
//! Returns the result of the query as an actual query result.
|
|
10905
11121
|
//! This returns (mostly) instantly if ExecuteTask has been called until RESULT_READY was returned.
|
|
10906
|
-
DUCKDB_API unique_ptr<QueryResult> Execute(
|
|
11122
|
+
DUCKDB_API unique_ptr<QueryResult> Execute();
|
|
10907
11123
|
|
|
10908
11124
|
DUCKDB_API void Close();
|
|
10909
11125
|
|
|
10910
11126
|
private:
|
|
10911
11127
|
shared_ptr<ClientContext> context;
|
|
11128
|
+
bool allow_stream_result;
|
|
10912
11129
|
|
|
10913
11130
|
private:
|
|
10914
11131
|
void CheckExecutableInternal(ClientContextLock &lock);
|
|
10915
11132
|
|
|
10916
11133
|
PendingExecutionResult ExecuteTaskInternal(ClientContextLock &lock);
|
|
10917
|
-
unique_ptr<QueryResult> ExecuteInternal(ClientContextLock &lock
|
|
11134
|
+
unique_ptr<QueryResult> ExecuteInternal(ClientContextLock &lock);
|
|
10918
11135
|
unique_ptr<ClientContextLock> LockContext();
|
|
10919
11136
|
};
|
|
10920
11137
|
|
|
@@ -10968,6 +11185,8 @@ public:
|
|
|
10968
11185
|
idx_t ColumnCount();
|
|
10969
11186
|
//! Returns the statement type of the underlying prepared statement object
|
|
10970
11187
|
StatementType GetStatementType();
|
|
11188
|
+
//! Returns the underlying statement properties
|
|
11189
|
+
StatementProperties GetStatementProperties();
|
|
10971
11190
|
//! Returns the result SQL types of the prepared statement
|
|
10972
11191
|
const vector<LogicalType> &GetTypes();
|
|
10973
11192
|
//! Returns the result names of the prepared statement
|
|
@@ -10988,7 +11207,7 @@ public:
|
|
|
10988
11207
|
}
|
|
10989
11208
|
|
|
10990
11209
|
//! 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);
|
|
11210
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(vector<Value> &values, bool allow_stream_result = true);
|
|
10992
11211
|
|
|
10993
11212
|
//! Execute the prepared statement with the given set of values
|
|
10994
11213
|
DUCKDB_API unique_ptr<QueryResult> Execute(vector<Value> &values, bool allow_stream_result = true);
|
|
@@ -11260,11 +11479,11 @@ class FieldReader;
|
|
|
11260
11479
|
// Constraint Types
|
|
11261
11480
|
//===--------------------------------------------------------------------===//
|
|
11262
11481
|
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
|
|
11482
|
+
INVALID = 0, // invalid constraint type
|
|
11483
|
+
NOT_NULL = 1, // NOT NULL constraint
|
|
11484
|
+
CHECK = 2, // CHECK constraint
|
|
11485
|
+
UNIQUE = 3, // UNIQUE constraint
|
|
11486
|
+
FOREIGN_KEY = 4, // FOREIGN KEY constraint
|
|
11268
11487
|
};
|
|
11269
11488
|
|
|
11270
11489
|
enum class ForeignKeyType : uint8_t {
|
|
@@ -11280,7 +11499,7 @@ struct ForeignKeyInfo {
|
|
|
11280
11499
|
//! key table
|
|
11281
11500
|
string table;
|
|
11282
11501
|
//! The set of main key table's column's index
|
|
11283
|
-
vector<
|
|
11502
|
+
vector<storage_t> pk_keys;
|
|
11284
11503
|
//! The set of foreign key table's column's index
|
|
11285
11504
|
vector<idx_t> fk_keys;
|
|
11286
11505
|
};
|
|
@@ -11335,6 +11554,103 @@ public:
|
|
|
11335
11554
|
|
|
11336
11555
|
|
|
11337
11556
|
|
|
11557
|
+
//===----------------------------------------------------------------------===//
|
|
11558
|
+
// DuckDB
|
|
11559
|
+
//
|
|
11560
|
+
// duckdb/catalog/catalog_entry/column_dependency_manager.hpp
|
|
11561
|
+
//
|
|
11562
|
+
//
|
|
11563
|
+
//===----------------------------------------------------------------------===//
|
|
11564
|
+
|
|
11565
|
+
|
|
11566
|
+
|
|
11567
|
+
|
|
11568
|
+
|
|
11569
|
+
|
|
11570
|
+
//===----------------------------------------------------------------------===//
|
|
11571
|
+
// DuckDB
|
|
11572
|
+
//
|
|
11573
|
+
// duckdb/common/set.hpp
|
|
11574
|
+
//
|
|
11575
|
+
//
|
|
11576
|
+
//===----------------------------------------------------------------------===//
|
|
11577
|
+
|
|
11578
|
+
|
|
11579
|
+
|
|
11580
|
+
#include <set>
|
|
11581
|
+
|
|
11582
|
+
namespace duckdb {
|
|
11583
|
+
using std::set;
|
|
11584
|
+
}
|
|
11585
|
+
|
|
11586
|
+
//===----------------------------------------------------------------------===//
|
|
11587
|
+
// DuckDB
|
|
11588
|
+
//
|
|
11589
|
+
// duckdb/common/stack.hpp
|
|
11590
|
+
//
|
|
11591
|
+
//
|
|
11592
|
+
//===----------------------------------------------------------------------===//
|
|
11593
|
+
|
|
11594
|
+
|
|
11595
|
+
|
|
11596
|
+
#include <stack>
|
|
11597
|
+
|
|
11598
|
+
namespace duckdb {
|
|
11599
|
+
using std::stack;
|
|
11600
|
+
}
|
|
11601
|
+
|
|
11602
|
+
|
|
11603
|
+
namespace duckdb {
|
|
11604
|
+
|
|
11605
|
+
//! Dependency Manager local to a table, responsible for keeping track of generated column dependencies
|
|
11606
|
+
|
|
11607
|
+
class ColumnDependencyManager {
|
|
11608
|
+
public:
|
|
11609
|
+
DUCKDB_API ColumnDependencyManager();
|
|
11610
|
+
DUCKDB_API ~ColumnDependencyManager();
|
|
11611
|
+
DUCKDB_API ColumnDependencyManager(ColumnDependencyManager &&other) = default;
|
|
11612
|
+
DUCKDB_API ColumnDependencyManager(const ColumnDependencyManager &other) = delete;
|
|
11613
|
+
|
|
11614
|
+
public:
|
|
11615
|
+
//! Get the bind order that ensures dependencies are resolved before dependents are
|
|
11616
|
+
stack<column_t> GetBindOrder(const vector<ColumnDefinition> &columns);
|
|
11617
|
+
|
|
11618
|
+
//! Adds a connection between the dependent and its dependencies
|
|
11619
|
+
void AddGeneratedColumn(column_t index, const vector<column_t> &indices, bool root = true);
|
|
11620
|
+
//! Add a generated column from a column definition
|
|
11621
|
+
void AddGeneratedColumn(const ColumnDefinition &column, const case_insensitive_map_t<column_t> &name_map);
|
|
11622
|
+
|
|
11623
|
+
//! Removes the column(s) and outputs the new column indices
|
|
11624
|
+
vector<column_t> RemoveColumn(column_t index, column_t column_amount);
|
|
11625
|
+
|
|
11626
|
+
bool IsDependencyOf(column_t dependent, column_t dependency) const;
|
|
11627
|
+
bool HasDependencies(column_t index) const;
|
|
11628
|
+
const unordered_set<column_t> &GetDependencies(column_t index) const;
|
|
11629
|
+
|
|
11630
|
+
bool HasDependents(column_t index) const;
|
|
11631
|
+
const unordered_set<column_t> &GetDependents(column_t index) const;
|
|
11632
|
+
|
|
11633
|
+
private:
|
|
11634
|
+
void RemoveStandardColumn(column_t index);
|
|
11635
|
+
void RemoveGeneratedColumn(column_t index);
|
|
11636
|
+
|
|
11637
|
+
void AdjustSingle(column_t idx, idx_t offset);
|
|
11638
|
+
// Clean up the gaps created by a Remove operation
|
|
11639
|
+
vector<column_t> CleanupInternals(column_t column_amount);
|
|
11640
|
+
|
|
11641
|
+
private:
|
|
11642
|
+
//! A map of column dependency to generated column(s)
|
|
11643
|
+
unordered_map<column_t, unordered_set<column_t>> dependencies_map;
|
|
11644
|
+
//! A map of generated column name to (potentially generated)column dependencies
|
|
11645
|
+
unordered_map<column_t, unordered_set<column_t>> dependents_map;
|
|
11646
|
+
//! For resolve-order purposes, keep track of the 'direct' (not inherited) dependencies of a generated column
|
|
11647
|
+
unordered_map<column_t, unordered_set<column_t>> direct_dependencies;
|
|
11648
|
+
set<column_t> deleted_columns;
|
|
11649
|
+
};
|
|
11650
|
+
|
|
11651
|
+
} // namespace duckdb
|
|
11652
|
+
|
|
11653
|
+
|
|
11338
11654
|
namespace duckdb {
|
|
11339
11655
|
|
|
11340
11656
|
class ColumnStatistics;
|
|
@@ -11364,13 +11680,16 @@ public:
|
|
|
11364
11680
|
vector<unique_ptr<Constraint>> constraints;
|
|
11365
11681
|
//! A list of constraints that are part of this table
|
|
11366
11682
|
vector<unique_ptr<BoundConstraint>> bound_constraints;
|
|
11683
|
+
ColumnDependencyManager column_dependency_manager;
|
|
11367
11684
|
//! A map of column name to column index
|
|
11368
11685
|
case_insensitive_map_t<column_t> name_map;
|
|
11369
11686
|
|
|
11370
11687
|
public:
|
|
11688
|
+
//! For debugging purposes, count how many columns are STANDARD
|
|
11689
|
+
idx_t StandardColumnCount() const;
|
|
11371
11690
|
unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info) override;
|
|
11372
11691
|
//! Returns whether or not a column with the given name exists
|
|
11373
|
-
bool ColumnExists(const string &name);
|
|
11692
|
+
DUCKDB_API bool ColumnExists(const string &name);
|
|
11374
11693
|
//! Returns a reference to the column of the specified name. Throws an
|
|
11375
11694
|
//! exception if the column does not exist.
|
|
11376
11695
|
ColumnDefinition &GetColumn(const string &name);
|
|
@@ -11394,9 +11713,10 @@ public:
|
|
|
11394
11713
|
//! If the column does not exist:
|
|
11395
11714
|
//! If if_exists is true, returns DConstants::INVALID_INDEX
|
|
11396
11715
|
//! If if_exists is false, throws an exception
|
|
11397
|
-
|
|
11716
|
+
column_t GetColumnIndex(string &name, bool if_exists = false);
|
|
11398
11717
|
|
|
11399
11718
|
private:
|
|
11719
|
+
const string &GetColumnName(column_t index);
|
|
11400
11720
|
unique_ptr<CatalogEntry> RenameColumn(ClientContext &context, RenameColumnInfo &info);
|
|
11401
11721
|
unique_ptr<CatalogEntry> AddColumn(ClientContext &context, AddColumnInfo &info);
|
|
11402
11722
|
unique_ptr<CatalogEntry> RemoveColumn(ClientContext &context, RemoveColumnInfo &info);
|
|
@@ -11564,6 +11884,7 @@ public:
|
|
|
11564
11884
|
|
|
11565
11885
|
|
|
11566
11886
|
|
|
11887
|
+
|
|
11567
11888
|
namespace duckdb {
|
|
11568
11889
|
|
|
11569
11890
|
enum class AlterType : uint8_t {
|
|
@@ -11626,7 +11947,7 @@ enum class AlterTableType : uint8_t {
|
|
|
11626
11947
|
REMOVE_COLUMN = 4,
|
|
11627
11948
|
ALTER_COLUMN_TYPE = 5,
|
|
11628
11949
|
SET_DEFAULT = 6,
|
|
11629
|
-
FOREIGN_KEY_CONSTRAINT = 7
|
|
11950
|
+
FOREIGN_KEY_CONSTRAINT = 7,
|
|
11630
11951
|
};
|
|
11631
11952
|
|
|
11632
11953
|
struct AlterTableInfo : public AlterInfo {
|
|
@@ -11696,13 +12017,15 @@ public:
|
|
|
11696
12017
|
// RemoveColumnInfo
|
|
11697
12018
|
//===--------------------------------------------------------------------===//
|
|
11698
12019
|
struct RemoveColumnInfo : public AlterTableInfo {
|
|
11699
|
-
RemoveColumnInfo(string schema, string table, string removed_column, bool if_exists);
|
|
12020
|
+
RemoveColumnInfo(string schema, string table, string removed_column, bool if_exists, bool cascade);
|
|
11700
12021
|
~RemoveColumnInfo() override;
|
|
11701
12022
|
|
|
11702
12023
|
//! The column to remove
|
|
11703
12024
|
string removed_column;
|
|
11704
12025
|
//! Whether or not an error should be thrown if the column does not exist
|
|
11705
12026
|
bool if_exists;
|
|
12027
|
+
//! Whether or not the column should be removed if a dependency conflict arises (used by GENERATED columns)
|
|
12028
|
+
bool cascade;
|
|
11706
12029
|
|
|
11707
12030
|
public:
|
|
11708
12031
|
unique_ptr<AlterInfo> Copy() const override;
|
|
@@ -12311,7 +12634,8 @@ public:
|
|
|
12311
12634
|
}
|
|
12312
12635
|
|
|
12313
12636
|
//! Cast an expression to the specified SQL type if required
|
|
12314
|
-
static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type
|
|
12637
|
+
static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type,
|
|
12638
|
+
bool try_cast = false);
|
|
12315
12639
|
//! 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
12640
|
//! boolean casts, because that can be e.g. -1 -> TRUE -> 1. This is necessary to prevent some optimizer bugs.
|
|
12317
12641
|
static bool CastIsInvertible(const LogicalType &source_type, const LogicalType &target_type);
|
|
@@ -12632,10 +12956,10 @@ namespace duckdb {
|
|
|
12632
12956
|
class BoundReferenceExpression : public Expression {
|
|
12633
12957
|
public:
|
|
12634
12958
|
BoundReferenceExpression(string alias, LogicalType type, idx_t index);
|
|
12635
|
-
BoundReferenceExpression(LogicalType type,
|
|
12959
|
+
BoundReferenceExpression(LogicalType type, storage_t index);
|
|
12636
12960
|
|
|
12637
12961
|
//! Index used to access data in the chunks
|
|
12638
|
-
|
|
12962
|
+
storage_t index;
|
|
12639
12963
|
|
|
12640
12964
|
public:
|
|
12641
12965
|
bool IsScalar() const override {
|
|
@@ -13124,6 +13448,7 @@ public:
|
|
|
13124
13448
|
string Bind(unique_ptr<ParsedExpression> *expr, idx_t depth, bool root_expression = false);
|
|
13125
13449
|
|
|
13126
13450
|
unique_ptr<ParsedExpression> CreateStructExtract(unique_ptr<ParsedExpression> base, string field_name);
|
|
13451
|
+
unique_ptr<ParsedExpression> CreateStructPack(ColumnRefExpression &colref);
|
|
13127
13452
|
BindResult BindQualifiedColumnName(ColumnRefExpression &colref, const string &table_name);
|
|
13128
13453
|
|
|
13129
13454
|
unique_ptr<ParsedExpression> QualifyColumnName(const string &column_name, string &error_message);
|
|
@@ -13147,9 +13472,6 @@ public:
|
|
|
13147
13472
|
static bool ContainsType(const LogicalType &type, LogicalTypeId target);
|
|
13148
13473
|
static LogicalType ExchangeType(const LogicalType &type, LogicalTypeId target, LogicalType new_type);
|
|
13149
13474
|
|
|
13150
|
-
static void ResolveParameterType(LogicalType &type);
|
|
13151
|
-
static void ResolveParameterType(unique_ptr<Expression> &expr);
|
|
13152
|
-
|
|
13153
13475
|
//! Bind the given expresion. Unlike Bind(), this does *not* mute the given ParsedExpression.
|
|
13154
13476
|
//! Exposed to be used from sub-binders that aren't subclasses of ExpressionBinder.
|
|
13155
13477
|
virtual BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
|
|
@@ -13171,7 +13493,6 @@ protected:
|
|
|
13171
13493
|
BindResult BindExpression(OperatorExpression &expr, idx_t depth);
|
|
13172
13494
|
BindResult BindExpression(ParameterExpression &expr, idx_t depth);
|
|
13173
13495
|
BindResult BindExpression(PositionalReferenceExpression &ref, idx_t depth);
|
|
13174
|
-
BindResult BindExpression(StarExpression &expr, idx_t depth);
|
|
13175
13496
|
BindResult BindExpression(SubqueryExpression &expr, idx_t depth);
|
|
13176
13497
|
|
|
13177
13498
|
protected:
|
|
@@ -13209,6 +13530,7 @@ protected:
|
|
|
13209
13530
|
|
|
13210
13531
|
|
|
13211
13532
|
|
|
13533
|
+
|
|
13212
13534
|
namespace duckdb {
|
|
13213
13535
|
class BindContext;
|
|
13214
13536
|
class BoundQueryNode;
|
|
@@ -13219,11 +13541,16 @@ class TableCatalogEntry;
|
|
|
13219
13541
|
class TableFunctionCatalogEntry;
|
|
13220
13542
|
class BoundTableFunction;
|
|
13221
13543
|
|
|
13544
|
+
enum class BindingType { BASE, TABLE, MACRO };
|
|
13545
|
+
|
|
13222
13546
|
//! A Binding represents a binding to a table, table-producing function or subquery with a specified table index.
|
|
13223
13547
|
struct Binding {
|
|
13224
|
-
Binding(const string &alias, vector<LogicalType> types, vector<string> names,
|
|
13548
|
+
Binding(BindingType binding_type, const string &alias, vector<LogicalType> types, vector<string> names,
|
|
13549
|
+
idx_t index);
|
|
13225
13550
|
virtual ~Binding() = default;
|
|
13226
13551
|
|
|
13552
|
+
//! The type of Binding
|
|
13553
|
+
BindingType binding_type;
|
|
13227
13554
|
//! The alias of the binding
|
|
13228
13555
|
string alias;
|
|
13229
13556
|
//! The table index of the binding
|
|
@@ -13253,6 +13580,7 @@ struct TableBinding : public Binding {
|
|
|
13253
13580
|
LogicalGet &get;
|
|
13254
13581
|
|
|
13255
13582
|
public:
|
|
13583
|
+
unique_ptr<ParsedExpression> ExpandGeneratedColumn(const string &column_name);
|
|
13256
13584
|
BindResult Bind(ColumnRefExpression &colref, idx_t depth) override;
|
|
13257
13585
|
TableCatalogEntry *GetTableEntry() override;
|
|
13258
13586
|
string ColumnNotFoundError(const string &column_name) const override;
|
|
@@ -13318,6 +13646,8 @@ public:
|
|
|
13318
13646
|
string BindColumn(PositionalReferenceExpression &ref, string &table_name, string &column_name);
|
|
13319
13647
|
BindResult BindColumn(PositionalReferenceExpression &ref, idx_t depth);
|
|
13320
13648
|
|
|
13649
|
+
unique_ptr<ParsedExpression> ExpandGeneratedColumn(const string &table_name, const string &column_name);
|
|
13650
|
+
|
|
13321
13651
|
unique_ptr<ParsedExpression> CreateColumnReference(const string &table_name, const string &column_name);
|
|
13322
13652
|
unique_ptr<ParsedExpression> CreateColumnReference(const string &schema_name, const string &table_name,
|
|
13323
13653
|
const string &column_name);
|
|
@@ -13421,7 +13751,6 @@ private:
|
|
|
13421
13751
|
|
|
13422
13752
|
|
|
13423
13753
|
|
|
13424
|
-
//#include "duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp"
|
|
13425
13754
|
|
|
13426
13755
|
namespace duckdb {
|
|
13427
13756
|
class BoundResultModifier;
|
|
@@ -13483,12 +13812,10 @@ public:
|
|
|
13483
13812
|
vector<CorrelatedColumnInfo> correlated_columns;
|
|
13484
13813
|
//! The set of parameter expressions bound by this binder
|
|
13485
13814
|
vector<BoundParameterExpression *> *parameters;
|
|
13486
|
-
//!
|
|
13487
|
-
|
|
13488
|
-
//!
|
|
13489
|
-
|
|
13490
|
-
//! Whether or not the statement can be streamed to the client
|
|
13491
|
-
bool allow_stream_result;
|
|
13815
|
+
//! The types of the prepared statement parameters, if any
|
|
13816
|
+
vector<LogicalType> *parameter_types;
|
|
13817
|
+
//! Statement properties
|
|
13818
|
+
StatementProperties properties;
|
|
13492
13819
|
//! The alias for the currently processing subquery, if it exists
|
|
13493
13820
|
string alias;
|
|
13494
13821
|
//! Macro parameter bindings (if any)
|
|
@@ -13588,6 +13915,8 @@ private:
|
|
|
13588
13915
|
unordered_set<ViewCatalogEntry *> bound_views;
|
|
13589
13916
|
|
|
13590
13917
|
private:
|
|
13918
|
+
//! Bind the expressions of generated columns to check for errors
|
|
13919
|
+
void BindGeneratedColumns(BoundCreateTableInfo &info);
|
|
13591
13920
|
//! Bind the default values of the columns of a table
|
|
13592
13921
|
void BindDefaultValues(vector<ColumnDefinition> &columns, vector<unique_ptr<Expression>> &bound_defaults);
|
|
13593
13922
|
//! Bind a limit value (LIMIT or OFFSET)
|
|
@@ -13641,9 +13970,12 @@ private:
|
|
|
13641
13970
|
unique_ptr<BoundTableRef> Bind(EmptyTableRef &ref);
|
|
13642
13971
|
unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
|
|
13643
13972
|
|
|
13644
|
-
bool
|
|
13645
|
-
|
|
13646
|
-
|
|
13973
|
+
bool BindTableFunctionParameters(TableFunctionCatalogEntry &table_function,
|
|
13974
|
+
vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
|
|
13975
|
+
vector<Value> ¶meters, named_parameter_map_t &named_parameters,
|
|
13976
|
+
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
13977
|
+
bool BindTableInTableOutFunction(vector<unique_ptr<ParsedExpression>> &expressions,
|
|
13978
|
+
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
13647
13979
|
|
|
13648
13980
|
unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
|
|
13649
13981
|
unique_ptr<LogicalOperator> CreatePlan(BoundCrossProductRef &ref);
|
|
@@ -13781,6 +14113,7 @@ public:
|
|
|
13781
14113
|
|
|
13782
14114
|
|
|
13783
14115
|
namespace duckdb {
|
|
14116
|
+
|
|
13784
14117
|
//! SQLStatement is the base class of any type of SQL statement.
|
|
13785
14118
|
class SQLStatement {
|
|
13786
14119
|
public:
|
|
@@ -13803,6 +14136,9 @@ protected:
|
|
|
13803
14136
|
SQLStatement(const SQLStatement &other) = default;
|
|
13804
14137
|
|
|
13805
14138
|
public:
|
|
14139
|
+
virtual string ToString() const {
|
|
14140
|
+
throw InternalException("ToString not supported for this type of SQLStatement");
|
|
14141
|
+
}
|
|
13806
14142
|
//! Create a copy of this SelectStatement
|
|
13807
14143
|
virtual unique_ptr<SQLStatement> Copy() const = 0;
|
|
13808
14144
|
};
|
|
@@ -13907,7 +14243,9 @@ public:
|
|
|
13907
14243
|
|
|
13908
14244
|
public:
|
|
13909
14245
|
//! Convert the object to a string
|
|
13910
|
-
virtual string ToString() const;
|
|
14246
|
+
virtual string ToString() const = 0;
|
|
14247
|
+
string BaseToString(string result) const;
|
|
14248
|
+
string BaseToString(string result, const vector<string> &column_name_alias) const;
|
|
13911
14249
|
void Print();
|
|
13912
14250
|
|
|
13913
14251
|
virtual bool Equals(const TableRef *other) const;
|
|
@@ -13944,6 +14282,8 @@ protected:
|
|
|
13944
14282
|
SelectStatement(const SelectStatement &other);
|
|
13945
14283
|
|
|
13946
14284
|
public:
|
|
14285
|
+
//! Convert the SELECT statement to a string
|
|
14286
|
+
string ToString() const override;
|
|
13947
14287
|
//! Create a copy of this SelectStatement
|
|
13948
14288
|
unique_ptr<SQLStatement> Copy() const override;
|
|
13949
14289
|
//! Serializes a SelectStatement to a stand-alone binary blob
|
|
@@ -13995,6 +14335,9 @@ public:
|
|
|
13995
14335
|
virtual const vector<unique_ptr<ParsedExpression>> &GetSelectList() const = 0;
|
|
13996
14336
|
|
|
13997
14337
|
public:
|
|
14338
|
+
//! Convert the query node to a string
|
|
14339
|
+
virtual string ToString() const = 0;
|
|
14340
|
+
|
|
13998
14341
|
virtual bool Equals(const QueryNode *other) const;
|
|
13999
14342
|
|
|
14000
14343
|
//! Create a copy of this QueryNode
|
|
@@ -14006,6 +14349,9 @@ public:
|
|
|
14006
14349
|
//! Deserializes a blob back into a QueryNode
|
|
14007
14350
|
DUCKDB_API static unique_ptr<QueryNode> Deserialize(Deserializer &source);
|
|
14008
14351
|
|
|
14352
|
+
string CTEToString() const;
|
|
14353
|
+
string ResultModifiersToString() const;
|
|
14354
|
+
|
|
14009
14355
|
protected:
|
|
14010
14356
|
//! Copy base QueryNode properties from another expression to this one,
|
|
14011
14357
|
//! used in Copy method
|
|
@@ -14169,12 +14515,14 @@ public:
|
|
|
14169
14515
|
string schema;
|
|
14170
14516
|
//! Name of the aggregate function
|
|
14171
14517
|
string function_name;
|
|
14172
|
-
//! The child expression of the main window
|
|
14518
|
+
//! The child expression of the main window function
|
|
14173
14519
|
vector<unique_ptr<ParsedExpression>> children;
|
|
14174
14520
|
//! The set of expressions to partition by
|
|
14175
14521
|
vector<unique_ptr<ParsedExpression>> partitions;
|
|
14176
14522
|
//! The set of ordering clauses
|
|
14177
14523
|
vector<OrderByNode> orders;
|
|
14524
|
+
//! Expression representing a filter, only used for aggregates
|
|
14525
|
+
unique_ptr<ParsedExpression> filter_expr;
|
|
14178
14526
|
//! True to ignore NULL values
|
|
14179
14527
|
bool ignore_nulls;
|
|
14180
14528
|
//! The window boundaries
|
|
@@ -14223,8 +14571,13 @@ public:
|
|
|
14223
14571
|
if (entry.ignore_nulls) {
|
|
14224
14572
|
result += " IGNORE NULLS";
|
|
14225
14573
|
}
|
|
14574
|
+
// FILTER
|
|
14575
|
+
if (entry.filter_expr) {
|
|
14576
|
+
result += ") FILTER (WHERE " + entry.filter_expr->ToString();
|
|
14577
|
+
}
|
|
14578
|
+
|
|
14226
14579
|
// Over clause
|
|
14227
|
-
result += ") OVER(";
|
|
14580
|
+
result += ") OVER (";
|
|
14228
14581
|
string sep;
|
|
14229
14582
|
|
|
14230
14583
|
// Partitions
|
|
@@ -14343,7 +14696,7 @@ public:
|
|
|
14343
14696
|
unique_ptr<AggregateFunction> aggregate;
|
|
14344
14697
|
//! The bound function info
|
|
14345
14698
|
unique_ptr<FunctionData> bind_info;
|
|
14346
|
-
//! The child expressions of the main window
|
|
14699
|
+
//! The child expressions of the main window function
|
|
14347
14700
|
vector<unique_ptr<Expression>> children;
|
|
14348
14701
|
//! The set of expressions to partition by
|
|
14349
14702
|
vector<unique_ptr<Expression>> partitions;
|
|
@@ -14351,6 +14704,8 @@ public:
|
|
|
14351
14704
|
vector<unique_ptr<BaseStatistics>> partitions_stats;
|
|
14352
14705
|
//! The set of ordering clauses
|
|
14353
14706
|
vector<BoundOrderByNode> orders;
|
|
14707
|
+
//! Expression representing a filter, only used for aggregates
|
|
14708
|
+
unique_ptr<Expression> filter_expr;
|
|
14354
14709
|
//! True to ignore NULL values
|
|
14355
14710
|
bool ignore_nulls;
|
|
14356
14711
|
//! The window boundaries
|
|
@@ -14434,11 +14789,11 @@ typedef unordered_map<block_id_t, unique_ptr<BufferHandle>> buffer_handle_set_t;
|
|
|
14434
14789
|
|
|
14435
14790
|
struct ColumnScanState {
|
|
14436
14791
|
//! The column segment that is currently being scanned
|
|
14437
|
-
ColumnSegment *current;
|
|
14792
|
+
ColumnSegment *current = nullptr;
|
|
14438
14793
|
//! The current row index of the scan
|
|
14439
|
-
idx_t row_index;
|
|
14794
|
+
idx_t row_index = 0;
|
|
14440
14795
|
//! The internal row index (i.e. the position of the SegmentScanState)
|
|
14441
|
-
idx_t internal_index;
|
|
14796
|
+
idx_t internal_index = 0;
|
|
14442
14797
|
//! Segment scan state
|
|
14443
14798
|
unique_ptr<SegmentScanState> scan_state;
|
|
14444
14799
|
//! Child states of the vector
|
|
@@ -14472,10 +14827,10 @@ struct LocalScanState {
|
|
|
14472
14827
|
return storage.get();
|
|
14473
14828
|
}
|
|
14474
14829
|
|
|
14475
|
-
idx_t chunk_index;
|
|
14476
|
-
idx_t max_index;
|
|
14477
|
-
idx_t last_chunk_count;
|
|
14478
|
-
TableFilterSet *table_filters;
|
|
14830
|
+
idx_t chunk_index = 0;
|
|
14831
|
+
idx_t max_index = 0;
|
|
14832
|
+
idx_t last_chunk_count = 0;
|
|
14833
|
+
TableFilterSet *table_filters = nullptr;
|
|
14479
14834
|
|
|
14480
14835
|
private:
|
|
14481
14836
|
shared_ptr<LocalTableStorage> storage;
|
|
@@ -14489,17 +14844,13 @@ public:
|
|
|
14489
14844
|
//! The parent scan state
|
|
14490
14845
|
TableScanState &parent;
|
|
14491
14846
|
//! The current row_group we are scanning
|
|
14492
|
-
RowGroup *row_group;
|
|
14847
|
+
RowGroup *row_group = nullptr;
|
|
14493
14848
|
//! The vector index within the row_group
|
|
14494
|
-
idx_t vector_index;
|
|
14849
|
+
idx_t vector_index = 0;
|
|
14495
14850
|
//! The maximum row index of this row_group scan
|
|
14496
|
-
idx_t max_row;
|
|
14851
|
+
idx_t max_row = 0;
|
|
14497
14852
|
//! Child column scans
|
|
14498
14853
|
unique_ptr<ColumnScanState[]> column_scans;
|
|
14499
|
-
|
|
14500
|
-
public:
|
|
14501
|
-
//! Move to the next vector, skipping past the current one
|
|
14502
|
-
void NextVector();
|
|
14503
14854
|
};
|
|
14504
14855
|
|
|
14505
14856
|
class TableScanState {
|
|
@@ -14509,7 +14860,7 @@ public:
|
|
|
14509
14860
|
//! The row_group scan state
|
|
14510
14861
|
RowGroupScanState row_group_scan_state;
|
|
14511
14862
|
//! The total maximum row index
|
|
14512
|
-
idx_t max_row;
|
|
14863
|
+
idx_t max_row = 0;
|
|
14513
14864
|
//! The column identifiers of the scan
|
|
14514
14865
|
vector<column_t> column_ids;
|
|
14515
14866
|
//! The table filters (if any)
|
|
@@ -14518,10 +14869,6 @@ public:
|
|
|
14518
14869
|
unique_ptr<AdaptiveFilter> adaptive_filter;
|
|
14519
14870
|
//! Transaction-local scan state
|
|
14520
14871
|
LocalScanState local_state;
|
|
14521
|
-
|
|
14522
|
-
public:
|
|
14523
|
-
//! Move to the next vector
|
|
14524
|
-
void NextVector();
|
|
14525
14872
|
};
|
|
14526
14873
|
|
|
14527
14874
|
class CreateIndexScanState : public TableScanState {
|
|
@@ -14818,6 +15165,11 @@ private:
|
|
|
14818
15165
|
void DeleteMapping(ClientContext &context, const string &name);
|
|
14819
15166
|
void DropEntryDependencies(ClientContext &context, idx_t entry_index, CatalogEntry &entry, bool cascade);
|
|
14820
15167
|
|
|
15168
|
+
//! Create all default entries
|
|
15169
|
+
void CreateDefaultEntries(ClientContext &context, unique_lock<mutex> &lock);
|
|
15170
|
+
//! Attempt to create a default entry with the specified name. Returns the entry if successful, nullptr otherwise.
|
|
15171
|
+
CatalogEntry *CreateDefaultEntry(ClientContext &context, const string &name, unique_lock<mutex> &lock);
|
|
15172
|
+
|
|
14821
15173
|
private:
|
|
14822
15174
|
Catalog &catalog;
|
|
14823
15175
|
//! The catalog lock is used to make changes to the data
|
|
@@ -16410,6 +16762,15 @@ Sets the init function of the table function
|
|
|
16410
16762
|
*/
|
|
16411
16763
|
DUCKDB_API void duckdb_table_function_set_init(duckdb_table_function table_function, duckdb_table_function_init_t init);
|
|
16412
16764
|
|
|
16765
|
+
/*!
|
|
16766
|
+
Sets the thread-local init function of the table function
|
|
16767
|
+
|
|
16768
|
+
* table_function: The table function
|
|
16769
|
+
* init: The init function
|
|
16770
|
+
*/
|
|
16771
|
+
DUCKDB_API void duckdb_table_function_set_local_init(duckdb_table_function table_function,
|
|
16772
|
+
duckdb_table_function_init_t init);
|
|
16773
|
+
|
|
16413
16774
|
/*!
|
|
16414
16775
|
Sets the main function of the table function
|
|
16415
16776
|
|
|
@@ -16553,6 +16914,14 @@ This function must be used if projection pushdown is enabled to figure out which
|
|
|
16553
16914
|
*/
|
|
16554
16915
|
DUCKDB_API idx_t duckdb_init_get_column_index(duckdb_init_info info, idx_t column_index);
|
|
16555
16916
|
|
|
16917
|
+
/*!
|
|
16918
|
+
Sets how many threads can process this table function in parallel (default: 1)
|
|
16919
|
+
|
|
16920
|
+
* info: The info object
|
|
16921
|
+
* max_threads: The maximum amount of threads that can process this table function
|
|
16922
|
+
*/
|
|
16923
|
+
DUCKDB_API void duckdb_init_set_max_threads(duckdb_init_info info, idx_t max_threads);
|
|
16924
|
+
|
|
16556
16925
|
/*!
|
|
16557
16926
|
Report that an error has occurred while calling init.
|
|
16558
16927
|
|
|
@@ -16584,13 +16953,21 @@ For tracking state, use the init data instead.
|
|
|
16584
16953
|
DUCKDB_API void *duckdb_function_get_bind_data(duckdb_function_info info);
|
|
16585
16954
|
|
|
16586
16955
|
/*!
|
|
16587
|
-
Gets the init data set by `
|
|
16956
|
+
Gets the init data set by `duckdb_init_set_init_data` during the init.
|
|
16588
16957
|
|
|
16589
16958
|
* info: The info object
|
|
16590
16959
|
* returns: The init data object
|
|
16591
16960
|
*/
|
|
16592
16961
|
DUCKDB_API void *duckdb_function_get_init_data(duckdb_function_info info);
|
|
16593
16962
|
|
|
16963
|
+
/*!
|
|
16964
|
+
Gets the thread-local init data set by `duckdb_init_set_init_data` during the local_init.
|
|
16965
|
+
|
|
16966
|
+
* info: The info object
|
|
16967
|
+
* returns: The init data object
|
|
16968
|
+
*/
|
|
16969
|
+
DUCKDB_API void *duckdb_function_get_local_init_data(duckdb_function_info info);
|
|
16970
|
+
|
|
16594
16971
|
/*!
|
|
16595
16972
|
Report that an error has occurred while executing the function.
|
|
16596
16973
|
|
|
@@ -16896,6 +17273,19 @@ Closes the result and de-allocates all memory allocated for the arrow result.
|
|
|
16896
17273
|
*/
|
|
16897
17274
|
DUCKDB_API void duckdb_destroy_arrow(duckdb_arrow *result);
|
|
16898
17275
|
|
|
17276
|
+
//===--------------------------------------------------------------------===//
|
|
17277
|
+
// Threading Information
|
|
17278
|
+
//===--------------------------------------------------------------------===//
|
|
17279
|
+
/*!
|
|
17280
|
+
Execute DuckDB tasks on this thread.
|
|
17281
|
+
|
|
17282
|
+
Will return after `max_tasks` have been executed, or if there are no more tasks present.
|
|
17283
|
+
|
|
17284
|
+
* database: The database object to execute tasks for
|
|
17285
|
+
* max_tasks: The maximum amount of tasks to execute
|
|
17286
|
+
*/
|
|
17287
|
+
DUCKDB_API void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks);
|
|
17288
|
+
|
|
16899
17289
|
#ifdef __cplusplus
|
|
16900
17290
|
}
|
|
16901
17291
|
#endif
|
|
@@ -16958,7 +17348,7 @@ namespace duckdb {
|
|
|
16958
17348
|
|
|
16959
17349
|
class ProgressBar {
|
|
16960
17350
|
public:
|
|
16961
|
-
explicit ProgressBar(Executor &executor, idx_t show_progress_after);
|
|
17351
|
+
explicit ProgressBar(Executor &executor, idx_t show_progress_after, bool print_progress);
|
|
16962
17352
|
|
|
16963
17353
|
//! Starts the thread
|
|
16964
17354
|
void Start();
|
|
@@ -16980,6 +17370,8 @@ private:
|
|
|
16980
17370
|
idx_t show_progress_after;
|
|
16981
17371
|
//! The current progress percentage
|
|
16982
17372
|
double current_percentage;
|
|
17373
|
+
//! Whether or not we print the progress bar
|
|
17374
|
+
bool print_progress;
|
|
16983
17375
|
//! Whether or not profiling is supported for the current query
|
|
16984
17376
|
bool supported = true;
|
|
16985
17377
|
};
|
|
@@ -17014,8 +17406,8 @@ class StreamQueryResult : public QueryResult {
|
|
|
17014
17406
|
public:
|
|
17015
17407
|
//! Create a successful StreamQueryResult. StreamQueryResults should always be successful initially (it makes no
|
|
17016
17408
|
//! sense to stream an error).
|
|
17017
|
-
DUCKDB_API StreamQueryResult(StatementType statement_type,
|
|
17018
|
-
vector<LogicalType> types, vector<string> names);
|
|
17409
|
+
DUCKDB_API StreamQueryResult(StatementType statement_type, StatementProperties properties,
|
|
17410
|
+
shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names);
|
|
17019
17411
|
DUCKDB_API ~StreamQueryResult() override;
|
|
17020
17412
|
|
|
17021
17413
|
public:
|
|
@@ -17031,7 +17423,6 @@ public:
|
|
|
17031
17423
|
//! Closes the StreamQueryResult
|
|
17032
17424
|
DUCKDB_API void Close();
|
|
17033
17425
|
|
|
17034
|
-
private:
|
|
17035
17426
|
//! The client context this StreamQueryResult belongs to
|
|
17036
17427
|
shared_ptr<ClientContext> context;
|
|
17037
17428
|
|
|
@@ -17128,7 +17519,6 @@ private:
|
|
|
17128
17519
|
} // namespace duckdb
|
|
17129
17520
|
|
|
17130
17521
|
|
|
17131
|
-
#include <random>
|
|
17132
17522
|
|
|
17133
17523
|
//===----------------------------------------------------------------------===//
|
|
17134
17524
|
// DuckDB
|
|
@@ -17165,6 +17555,11 @@ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_O
|
|
|
17165
17555
|
|
|
17166
17556
|
namespace duckdb {
|
|
17167
17557
|
class ClientContext;
|
|
17558
|
+
class PhysicalResultCollector;
|
|
17559
|
+
class PreparedStatementData;
|
|
17560
|
+
|
|
17561
|
+
typedef std::function<unique_ptr<PhysicalResultCollector>(ClientContext &context, PreparedStatementData &data)>
|
|
17562
|
+
get_result_collector_t;
|
|
17168
17563
|
|
|
17169
17564
|
struct ClientConfig {
|
|
17170
17565
|
//! If the query profiler is enabled or not.
|
|
@@ -17187,6 +17582,8 @@ struct ClientConfig {
|
|
|
17187
17582
|
//! Preserve identifier case while parsing.
|
|
17188
17583
|
//! If false, all unquoted identifiers are lower-cased (e.g. "MyTable" -> "mytable").
|
|
17189
17584
|
bool preserve_identifier_case = true;
|
|
17585
|
+
//! The maximum expression depth limit in the parser
|
|
17586
|
+
idx_t max_expression_depth = 1000;
|
|
17190
17587
|
|
|
17191
17588
|
// Whether or not aggressive query verification is enabled
|
|
17192
17589
|
bool query_verification_enabled = false;
|
|
@@ -17198,6 +17595,8 @@ struct ClientConfig {
|
|
|
17198
17595
|
bool force_index_join = false;
|
|
17199
17596
|
//! Force out-of-core computation for operators that support it, used for testing
|
|
17200
17597
|
bool force_external = false;
|
|
17598
|
+
//! Force disable cross product generation when hyper graph isn't connected, used for testing
|
|
17599
|
+
bool force_no_cross_product = false;
|
|
17201
17600
|
//! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
|
|
17202
17601
|
//! elements)
|
|
17203
17602
|
idx_t perfect_ht_threshold = 12;
|
|
@@ -17208,12 +17607,39 @@ struct ClientConfig {
|
|
|
17208
17607
|
//! Generic options
|
|
17209
17608
|
case_insensitive_map_t<Value> set_variables;
|
|
17210
17609
|
|
|
17610
|
+
//! Function that is used to create the result collector for a materialized result
|
|
17611
|
+
//! Defaults to PhysicalMaterializedCollector
|
|
17612
|
+
get_result_collector_t result_collector = nullptr;
|
|
17613
|
+
|
|
17211
17614
|
public:
|
|
17212
17615
|
static ClientConfig &GetConfig(ClientContext &context);
|
|
17616
|
+
|
|
17617
|
+
static string ExtractTimezoneFromConfig(ClientConfig &config);
|
|
17213
17618
|
};
|
|
17214
17619
|
|
|
17215
17620
|
} // namespace duckdb
|
|
17216
17621
|
|
|
17622
|
+
//===----------------------------------------------------------------------===//
|
|
17623
|
+
// DuckDB
|
|
17624
|
+
//
|
|
17625
|
+
// duckdb/main/external_dependencies.hpp
|
|
17626
|
+
//
|
|
17627
|
+
//
|
|
17628
|
+
//===----------------------------------------------------------------------===//
|
|
17629
|
+
|
|
17630
|
+
|
|
17631
|
+
|
|
17632
|
+
namespace duckdb {
|
|
17633
|
+
|
|
17634
|
+
enum ExternalDependenciesType { PYTHON_DEPENDENCY };
|
|
17635
|
+
class ExternalDependency {
|
|
17636
|
+
public:
|
|
17637
|
+
explicit ExternalDependency(ExternalDependenciesType type_p) : type(type_p) {};
|
|
17638
|
+
virtual ~ExternalDependency() {};
|
|
17639
|
+
ExternalDependenciesType type;
|
|
17640
|
+
};
|
|
17641
|
+
|
|
17642
|
+
} // namespace duckdb
|
|
17217
17643
|
|
|
17218
17644
|
namespace duckdb {
|
|
17219
17645
|
class Appender;
|
|
@@ -17227,12 +17653,19 @@ class PreparedStatementData;
|
|
|
17227
17653
|
class Relation;
|
|
17228
17654
|
class BufferedFileWriter;
|
|
17229
17655
|
class QueryProfiler;
|
|
17230
|
-
class QueryProfilerHistory;
|
|
17231
17656
|
class ClientContextLock;
|
|
17232
17657
|
struct CreateScalarFunctionInfo;
|
|
17233
17658
|
class ScalarFunctionCatalogEntry;
|
|
17234
17659
|
struct ActiveQueryContext;
|
|
17235
17660
|
struct ParserOptions;
|
|
17661
|
+
struct ClientData;
|
|
17662
|
+
|
|
17663
|
+
struct PendingQueryParameters {
|
|
17664
|
+
//! Prepared statement parameters (if any)
|
|
17665
|
+
vector<Value> *parameters = nullptr;
|
|
17666
|
+
//! Whether or not a stream result should be allowed
|
|
17667
|
+
bool allow_stream_result = false;
|
|
17668
|
+
};
|
|
17236
17669
|
|
|
17237
17670
|
//! The ClientContext holds information relevant to the current client session
|
|
17238
17671
|
//! during execution
|
|
@@ -17245,31 +17678,19 @@ public:
|
|
|
17245
17678
|
DUCKDB_API explicit ClientContext(shared_ptr<DatabaseInstance> db);
|
|
17246
17679
|
DUCKDB_API ~ClientContext();
|
|
17247
17680
|
|
|
17248
|
-
//! Query profiler
|
|
17249
|
-
shared_ptr<QueryProfiler> profiler;
|
|
17250
|
-
//! QueryProfiler History
|
|
17251
|
-
unique_ptr<QueryProfilerHistory> query_profiler_history;
|
|
17252
17681
|
//! The database that this client is connected to
|
|
17253
17682
|
shared_ptr<DatabaseInstance> db;
|
|
17254
17683
|
//! Data for the currently running transaction
|
|
17255
17684
|
TransactionContext transaction;
|
|
17256
17685
|
//! Whether or not the query is interrupted
|
|
17257
17686
|
atomic<bool> interrupted;
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
|
|
17261
|
-
|
|
17262
|
-
//! The writer used to log queries (if logging is enabled)
|
|
17263
|
-
unique_ptr<BufferedFileWriter> log_query_writer;
|
|
17264
|
-
//! The random generator used by random(). Its seed value can be set by setseed().
|
|
17265
|
-
std::mt19937 random_engine;
|
|
17266
|
-
|
|
17267
|
-
const unique_ptr<CatalogSearchPath> catalog_search_path;
|
|
17268
|
-
|
|
17269
|
-
unique_ptr<FileOpener> file_opener;
|
|
17687
|
+
//! External Objects (e.g., Python objects) that views depend of
|
|
17688
|
+
unordered_map<string, vector<shared_ptr<ExternalDependency>>> external_dependencies;
|
|
17270
17689
|
|
|
17271
17690
|
//! The client configuration
|
|
17272
17691
|
ClientConfig config;
|
|
17692
|
+
//! The set of client-specific data
|
|
17693
|
+
unique_ptr<ClientData> client_data;
|
|
17273
17694
|
|
|
17274
17695
|
public:
|
|
17275
17696
|
DUCKDB_API Transaction &ActiveTransaction() {
|
|
@@ -17291,9 +17712,10 @@ public:
|
|
|
17291
17712
|
|
|
17292
17713
|
//! Issues a query to the database and returns a Pending Query Result. Note that "query" may only contain
|
|
17293
17714
|
//! a single statement.
|
|
17294
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query);
|
|
17715
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query, bool allow_stream_result);
|
|
17295
17716
|
//! Issues a query to the database and returns a Pending Query Result
|
|
17296
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement
|
|
17717
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement,
|
|
17718
|
+
bool allow_stream_result);
|
|
17297
17719
|
|
|
17298
17720
|
//! Destroy the client context
|
|
17299
17721
|
DUCKDB_API void Destroy();
|
|
@@ -17318,13 +17740,15 @@ public:
|
|
|
17318
17740
|
//! It is possible that the prepared statement will be re-bound. This will generally happen if the catalog is
|
|
17319
17741
|
//! modified in between the prepared statement being bound and the prepared statement being run.
|
|
17320
17742
|
DUCKDB_API unique_ptr<PendingQueryResult>
|
|
17321
|
-
PendingQuery(const string &query, shared_ptr<PreparedStatementData> &prepared,
|
|
17743
|
+
PendingQuery(const string &query, shared_ptr<PreparedStatementData> &prepared, PendingQueryParameters parameters);
|
|
17322
17744
|
|
|
17323
17745
|
//! Execute a prepared statement with the given name and set of parameters
|
|
17324
17746
|
//! It is possible that the prepared statement will be re-bound. This will generally happen if the catalog is
|
|
17325
17747
|
//! modified in between the prepared statement being bound and the prepared statement being run.
|
|
17326
17748
|
DUCKDB_API unique_ptr<QueryResult> Execute(const string &query, shared_ptr<PreparedStatementData> &prepared,
|
|
17327
17749
|
vector<Value> &values, bool allow_stream_result = true);
|
|
17750
|
+
DUCKDB_API unique_ptr<QueryResult> Execute(const string &query, shared_ptr<PreparedStatementData> &prepared,
|
|
17751
|
+
PendingQueryParameters parameters);
|
|
17328
17752
|
|
|
17329
17753
|
//! Gets current percentage of the query's progress, returns 0 in case the progress bar is disabled.
|
|
17330
17754
|
DUCKDB_API double GetProgress();
|
|
@@ -17373,9 +17797,8 @@ private:
|
|
|
17373
17797
|
string &error);
|
|
17374
17798
|
//! Issues a query to the database and returns a Pending Query Result
|
|
17375
17799
|
unique_ptr<PendingQueryResult> PendingQueryInternal(ClientContextLock &lock, unique_ptr<SQLStatement> statement,
|
|
17376
|
-
bool verify = true);
|
|
17377
|
-
unique_ptr<QueryResult> ExecutePendingQueryInternal(ClientContextLock &lock, PendingQueryResult &query
|
|
17378
|
-
bool allow_stream_result);
|
|
17800
|
+
PendingQueryParameters parameters, bool verify = true);
|
|
17801
|
+
unique_ptr<QueryResult> ExecutePendingQueryInternal(ClientContextLock &lock, PendingQueryResult &query);
|
|
17379
17802
|
|
|
17380
17803
|
//! Parse statements from a query
|
|
17381
17804
|
vector<unique_ptr<SQLStatement>> ParseStatementsInternal(ClientContextLock &lock, const string &query);
|
|
@@ -17387,28 +17810,28 @@ private:
|
|
|
17387
17810
|
//! Internal clean up, does not lock. Caller must hold the context_lock.
|
|
17388
17811
|
void CleanupInternal(ClientContextLock &lock, BaseQueryResult *result = nullptr,
|
|
17389
17812
|
bool invalidate_transaction = false);
|
|
17390
|
-
string FinalizeQuery(ClientContextLock &lock, bool success);
|
|
17391
17813
|
unique_ptr<PendingQueryResult> PendingStatementOrPreparedStatement(ClientContextLock &lock, const string &query,
|
|
17392
17814
|
unique_ptr<SQLStatement> statement,
|
|
17393
17815
|
shared_ptr<PreparedStatementData> &prepared,
|
|
17394
|
-
|
|
17816
|
+
PendingQueryParameters parameters);
|
|
17395
17817
|
unique_ptr<PendingQueryResult> PendingPreparedStatement(ClientContextLock &lock,
|
|
17396
17818
|
shared_ptr<PreparedStatementData> statement_p,
|
|
17397
|
-
|
|
17819
|
+
PendingQueryParameters parameters);
|
|
17398
17820
|
|
|
17399
17821
|
//! Internally prepare a SQL statement. Caller must hold the context_lock.
|
|
17400
17822
|
shared_ptr<PreparedStatementData> CreatePreparedStatement(ClientContextLock &lock, const string &query,
|
|
17401
|
-
unique_ptr<SQLStatement> statement
|
|
17823
|
+
unique_ptr<SQLStatement> statement,
|
|
17824
|
+
vector<Value> *values = nullptr);
|
|
17402
17825
|
unique_ptr<PendingQueryResult> PendingStatementInternal(ClientContextLock &lock, const string &query,
|
|
17403
|
-
unique_ptr<SQLStatement> statement
|
|
17826
|
+
unique_ptr<SQLStatement> statement,
|
|
17827
|
+
PendingQueryParameters parameters);
|
|
17404
17828
|
unique_ptr<QueryResult> RunStatementInternal(ClientContextLock &lock, const string &query,
|
|
17405
17829
|
unique_ptr<SQLStatement> statement, bool allow_stream_result,
|
|
17406
17830
|
bool verify = true);
|
|
17407
17831
|
unique_ptr<PreparedStatement> PrepareInternal(ClientContextLock &lock, unique_ptr<SQLStatement> statement);
|
|
17408
17832
|
void LogQueryInternal(ClientContextLock &lock, const string &query);
|
|
17409
17833
|
|
|
17410
|
-
unique_ptr<QueryResult> FetchResultInternal(ClientContextLock &lock, PendingQueryResult &pending
|
|
17411
|
-
bool allow_stream_result);
|
|
17834
|
+
unique_ptr<QueryResult> FetchResultInternal(ClientContextLock &lock, PendingQueryResult &pending);
|
|
17412
17835
|
unique_ptr<DataChunk> FetchInternal(ClientContextLock &lock, Executor &executor, BaseQueryResult &result);
|
|
17413
17836
|
|
|
17414
17837
|
unique_ptr<ClientContextLock> LockContext();
|
|
@@ -17421,14 +17844,13 @@ private:
|
|
|
17421
17844
|
|
|
17422
17845
|
PendingExecutionResult ExecuteTaskInternal(ClientContextLock &lock, PendingQueryResult &result);
|
|
17423
17846
|
|
|
17424
|
-
unique_ptr<PendingQueryResult>
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
shared_ptr<PreparedStatementData> &prepared, vector<Value> *values);
|
|
17847
|
+
unique_ptr<PendingQueryResult> PendingStatementOrPreparedStatementInternal(
|
|
17848
|
+
ClientContextLock &lock, const string &query, unique_ptr<SQLStatement> statement,
|
|
17849
|
+
shared_ptr<PreparedStatementData> &prepared, PendingQueryParameters parameters);
|
|
17428
17850
|
|
|
17429
17851
|
unique_ptr<PendingQueryResult> PendingQueryPreparedInternal(ClientContextLock &lock, const string &query,
|
|
17430
17852
|
shared_ptr<PreparedStatementData> &prepared,
|
|
17431
|
-
|
|
17853
|
+
PendingQueryParameters parameters);
|
|
17432
17854
|
|
|
17433
17855
|
private:
|
|
17434
17856
|
//! Lock on using the ClientContext in parallel
|
|
@@ -17472,6 +17894,7 @@ private:
|
|
|
17472
17894
|
} // namespace duckdb
|
|
17473
17895
|
|
|
17474
17896
|
|
|
17897
|
+
|
|
17475
17898
|
#include <memory>
|
|
17476
17899
|
|
|
17477
17900
|
namespace duckdb {
|
|
@@ -17483,8 +17906,6 @@ class LogicalOperator;
|
|
|
17483
17906
|
class QueryNode;
|
|
17484
17907
|
class TableRef;
|
|
17485
17908
|
|
|
17486
|
-
class ExtraDependencies {};
|
|
17487
|
-
|
|
17488
17909
|
class Relation : public std::enable_shared_from_this<Relation> {
|
|
17489
17910
|
public:
|
|
17490
17911
|
DUCKDB_API Relation(const std::shared_ptr<ClientContext> &context, RelationType type)
|
|
@@ -17499,7 +17920,7 @@ public:
|
|
|
17499
17920
|
|
|
17500
17921
|
RelationType type;
|
|
17501
17922
|
|
|
17502
|
-
|
|
17923
|
+
shared_ptr<ExternalDependency> extra_dependencies;
|
|
17503
17924
|
|
|
17504
17925
|
public:
|
|
17505
17926
|
DUCKDB_API virtual const vector<ColumnDefinition> &Columns() = 0;
|
|
@@ -17599,6 +18020,7 @@ public:
|
|
|
17599
18020
|
DUCKDB_API virtual Relation *ChildRelation() {
|
|
17600
18021
|
return nullptr;
|
|
17601
18022
|
}
|
|
18023
|
+
DUCKDB_API vector<shared_ptr<ExternalDependency>> GetAllDependencies();
|
|
17602
18024
|
|
|
17603
18025
|
protected:
|
|
17604
18026
|
DUCKDB_API string RenderWhitespace(idx_t depth);
|
|
@@ -17672,9 +18094,10 @@ public:
|
|
|
17672
18094
|
|
|
17673
18095
|
//! Issues a query to the database and returns a Pending Query Result. Note that "query" may only contain
|
|
17674
18096
|
//! a single statement.
|
|
17675
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query);
|
|
18097
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(const string &query, bool allow_stream_result = false);
|
|
17676
18098
|
//! Issues a query to the database and returns a Pending Query Result
|
|
17677
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement
|
|
18099
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(unique_ptr<SQLStatement> statement,
|
|
18100
|
+
bool allow_stream_result = false);
|
|
17678
18101
|
|
|
17679
18102
|
//! Prepare the specified query, returning a prepared statement object
|
|
17680
18103
|
DUCKDB_API unique_ptr<PreparedStatement> Prepare(const string &query);
|
|
@@ -17965,21 +18388,6 @@ struct ReplacementScan {
|
|
|
17965
18388
|
|
|
17966
18389
|
} // namespace duckdb
|
|
17967
18390
|
|
|
17968
|
-
//===----------------------------------------------------------------------===//
|
|
17969
|
-
// DuckDB
|
|
17970
|
-
//
|
|
17971
|
-
// duckdb/common/set.hpp
|
|
17972
|
-
//
|
|
17973
|
-
//
|
|
17974
|
-
//===----------------------------------------------------------------------===//
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
17978
|
-
#include <set>
|
|
17979
|
-
|
|
17980
|
-
namespace duckdb {
|
|
17981
|
-
using std::set;
|
|
17982
|
-
}
|
|
17983
18391
|
|
|
17984
18392
|
|
|
17985
18393
|
//===----------------------------------------------------------------------===//
|
|
@@ -18135,6 +18543,8 @@ public:
|
|
|
18135
18543
|
idx_t maximum_memory = (idx_t)-1;
|
|
18136
18544
|
//! The maximum amount of CPU threads used by the database system. Default: all available.
|
|
18137
18545
|
idx_t maximum_threads = (idx_t)-1;
|
|
18546
|
+
//! The number of external threads that work on DuckDB tasks. Default: none.
|
|
18547
|
+
idx_t external_threads = 0;
|
|
18138
18548
|
//! Whether or not to create and use a temporary directory to store intermediates that do not fit in memory
|
|
18139
18549
|
bool use_temporary_directory = true;
|
|
18140
18550
|
//! Directory to store temporary structures that do not fit in memory
|
|
@@ -18168,6 +18578,8 @@ public:
|
|
|
18168
18578
|
bool debug_many_free_list_blocks = false;
|
|
18169
18579
|
//! Debug setting for window aggregation mode: (window, combine, separate)
|
|
18170
18580
|
WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
|
|
18581
|
+
//! Whether or not preserving insertion order should be preserved
|
|
18582
|
+
bool preserve_insertion_order = true;
|
|
18171
18583
|
|
|
18172
18584
|
//! Extra parameters that can be SET for loaded extensions
|
|
18173
18585
|
case_insensitive_map_t<ExtensionOption> extension_parameters;
|
|
@@ -18404,14 +18816,14 @@ public:
|
|
|
18404
18816
|
static const int8_t MONTH_PER_DAY_OF_YEAR[365];
|
|
18405
18817
|
static const int8_t LEAP_MONTH_PER_DAY_OF_YEAR[366];
|
|
18406
18818
|
|
|
18407
|
-
// min date is 5877642-06-
|
|
18819
|
+
// min date is 5877642-06-25 (BC) (-2^31+2)
|
|
18408
18820
|
constexpr static const int32_t DATE_MIN_YEAR = -5877641;
|
|
18409
18821
|
constexpr static const int32_t DATE_MIN_MONTH = 6;
|
|
18410
|
-
constexpr static const int32_t DATE_MIN_DAY =
|
|
18411
|
-
// max date is 5881580-07-
|
|
18822
|
+
constexpr static const int32_t DATE_MIN_DAY = 25;
|
|
18823
|
+
// max date is 5881580-07-10 (2^31-2)
|
|
18412
18824
|
constexpr static const int32_t DATE_MAX_YEAR = 5881580;
|
|
18413
18825
|
constexpr static const int32_t DATE_MAX_MONTH = 7;
|
|
18414
|
-
constexpr static const int32_t DATE_MAX_DAY =
|
|
18826
|
+
constexpr static const int32_t DATE_MAX_DAY = 10;
|
|
18415
18827
|
constexpr static const int32_t EPOCH_YEAR = 1970;
|
|
18416
18828
|
|
|
18417
18829
|
constexpr static const int32_t YEAR_INTERVAL = 400;
|
|
@@ -18444,6 +18856,11 @@ public:
|
|
|
18444
18856
|
//! date
|
|
18445
18857
|
DUCKDB_API static bool IsValid(int32_t year, int32_t month, int32_t day);
|
|
18446
18858
|
|
|
18859
|
+
//! Returns true if the specified date is finite
|
|
18860
|
+
static inline bool IsFinite(date_t date) {
|
|
18861
|
+
return date != date_t::infinity() && date != date_t::ninfinity();
|
|
18862
|
+
}
|
|
18863
|
+
|
|
18447
18864
|
//! The max number of days in a month of a given year
|
|
18448
18865
|
DUCKDB_API static int32_t MonthDays(int32_t year, int32_t month);
|
|
18449
18866
|
|
|
@@ -18644,15 +19061,6 @@ public:
|
|
|
18644
19061
|
|
|
18645
19062
|
namespace duckdb {
|
|
18646
19063
|
|
|
18647
|
-
struct timestamp_struct {
|
|
18648
|
-
int32_t year;
|
|
18649
|
-
int8_t month;
|
|
18650
|
-
int8_t day;
|
|
18651
|
-
int8_t hour;
|
|
18652
|
-
int8_t min;
|
|
18653
|
-
int8_t sec;
|
|
18654
|
-
int16_t msec;
|
|
18655
|
-
};
|
|
18656
19064
|
//! The Timestamp class is a static class that holds helper functions for the Timestamp
|
|
18657
19065
|
//! type.
|
|
18658
19066
|
class Timestamp {
|
|
@@ -18677,6 +19085,11 @@ public:
|
|
|
18677
19085
|
DUCKDB_API static timestamp_t FromDatetime(date_t date, dtime_t time);
|
|
18678
19086
|
DUCKDB_API static bool TryFromDatetime(date_t date, dtime_t time, timestamp_t &result);
|
|
18679
19087
|
|
|
19088
|
+
//! Is the timestamp finite or infinite?
|
|
19089
|
+
static inline bool IsFinite(timestamp_t timestamp) {
|
|
19090
|
+
return timestamp != timestamp_t::infinity() && timestamp != timestamp_t::ninfinity();
|
|
19091
|
+
}
|
|
19092
|
+
|
|
18680
19093
|
//! Extract the date and time from a given timestamp object
|
|
18681
19094
|
DUCKDB_API static void Convert(timestamp_t date, date_t &out_date, dtime_t &out_time);
|
|
18682
19095
|
//! Returns current timestamp
|
|
@@ -19327,6 +19740,7 @@ public:
|
|
|
19327
19740
|
|
|
19328
19741
|
|
|
19329
19742
|
|
|
19743
|
+
|
|
19330
19744
|
namespace duckdb {
|
|
19331
19745
|
|
|
19332
19746
|
struct CreateTableInfo : public CreateInfo {
|
|
@@ -19950,11 +20364,14 @@ public:
|
|
|
19950
20364
|
|
|
19951
20365
|
|
|
19952
20366
|
|
|
20367
|
+
|
|
20368
|
+
|
|
19953
20369
|
namespace duckdb {
|
|
19954
20370
|
class CatalogEntry;
|
|
19955
20371
|
|
|
19956
20372
|
struct BoundCreateTableInfo {
|
|
19957
|
-
explicit BoundCreateTableInfo(unique_ptr<CreateInfo>
|
|
20373
|
+
explicit BoundCreateTableInfo(unique_ptr<CreateInfo> base_p) : base(move(base_p)) {
|
|
20374
|
+
D_ASSERT(base);
|
|
19958
20375
|
}
|
|
19959
20376
|
|
|
19960
20377
|
//! The schema to create the table in
|
|
@@ -19963,6 +20380,8 @@ struct BoundCreateTableInfo {
|
|
|
19963
20380
|
unique_ptr<CreateInfo> base;
|
|
19964
20381
|
//! The map of column names -> column index, used during binding
|
|
19965
20382
|
case_insensitive_map_t<column_t> name_map;
|
|
20383
|
+
//! Column dependency manager of the table
|
|
20384
|
+
ColumnDependencyManager column_dependency_manager;
|
|
19966
20385
|
//! List of constraints on the table
|
|
19967
20386
|
vector<unique_ptr<Constraint>> constraints;
|
|
19968
20387
|
//! List of bound constraints on the table
|
|
@@ -19977,6 +20396,7 @@ struct BoundCreateTableInfo {
|
|
|
19977
20396
|
unique_ptr<LogicalOperator> query;
|
|
19978
20397
|
|
|
19979
20398
|
CreateTableInfo &Base() {
|
|
20399
|
+
D_ASSERT(base);
|
|
19980
20400
|
return (CreateTableInfo &)*base;
|
|
19981
20401
|
}
|
|
19982
20402
|
};
|
|
@@ -21350,6 +21770,7 @@ namespace duckdb {
|
|
|
21350
21770
|
|
|
21351
21771
|
struct ParserOptions {
|
|
21352
21772
|
bool preserve_identifier_case = true;
|
|
21773
|
+
idx_t max_expression_depth = 1000;
|
|
21353
21774
|
};
|
|
21354
21775
|
|
|
21355
21776
|
//! The parser is responsible for parsing the query and converting it into a set
|
|
@@ -21593,7 +22014,7 @@ class Vector;
|
|
|
21593
22014
|
|
|
21594
22015
|
class ValidityStatistics : public BaseStatistics {
|
|
21595
22016
|
public:
|
|
21596
|
-
ValidityStatistics(bool has_null = false, bool has_no_null = true);
|
|
22017
|
+
explicit ValidityStatistics(bool has_null = false, bool has_no_null = true);
|
|
21597
22018
|
|
|
21598
22019
|
//! Whether or not the segment can contain NULL values
|
|
21599
22020
|
bool has_null;
|
|
@@ -21606,8 +22027,10 @@ public:
|
|
|
21606
22027
|
bool IsConstant() const override;
|
|
21607
22028
|
|
|
21608
22029
|
unique_ptr<BaseStatistics> Copy() const override;
|
|
22030
|
+
|
|
21609
22031
|
void Serialize(FieldWriter &writer) const override;
|
|
21610
|
-
static unique_ptr<
|
|
22032
|
+
static unique_ptr<ValidityStatistics> Deserialize(FieldReader &reader);
|
|
22033
|
+
|
|
21611
22034
|
void Verify(Vector &vector, const SelectionVector &sel, idx_t count) const override;
|
|
21612
22035
|
|
|
21613
22036
|
static unique_ptr<BaseStatistics> Combine(const unique_ptr<BaseStatistics> &lstats,
|
|
@@ -21626,7 +22049,7 @@ public:
|
|
|
21626
22049
|
constexpr static uint32_t MAX_STRING_MINMAX_SIZE = 8;
|
|
21627
22050
|
|
|
21628
22051
|
public:
|
|
21629
|
-
explicit StringStatistics(LogicalType type);
|
|
22052
|
+
explicit StringStatistics(LogicalType type, StatisticsType stats_type);
|
|
21630
22053
|
|
|
21631
22054
|
//! The minimum value of the segment, potentially truncated
|
|
21632
22055
|
data_t min[MAX_STRING_MINMAX_SIZE];
|
|
@@ -21720,8 +22143,8 @@ namespace duckdb {
|
|
|
21720
22143
|
|
|
21721
22144
|
class NumericStatistics : public BaseStatistics {
|
|
21722
22145
|
public:
|
|
21723
|
-
explicit NumericStatistics(LogicalType type);
|
|
21724
|
-
NumericStatistics(LogicalType type, Value min, Value max);
|
|
22146
|
+
explicit NumericStatistics(LogicalType type, StatisticsType stats_type);
|
|
22147
|
+
NumericStatistics(LogicalType type, Value min, Value max, StatisticsType stats_type);
|
|
21725
22148
|
|
|
21726
22149
|
//! The minimum value of the segment
|
|
21727
22150
|
Value min;
|
|
@@ -21882,6 +22305,8 @@ public:
|
|
|
21882
22305
|
|
|
21883
22306
|
|
|
21884
22307
|
|
|
22308
|
+
#include <algorithm>
|
|
22309
|
+
|
|
21885
22310
|
namespace duckdb {
|
|
21886
22311
|
|
|
21887
22312
|
enum class StrTimeSpecifier : uint8_t {
|
|
@@ -21929,7 +22354,11 @@ public:
|
|
|
21929
22354
|
virtual ~StrTimeFormat() {
|
|
21930
22355
|
}
|
|
21931
22356
|
|
|
21932
|
-
static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
|
|
22357
|
+
DUCKDB_API static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
|
|
22358
|
+
|
|
22359
|
+
inline bool HasFormatSpecifier(StrTimeSpecifier s) const {
|
|
22360
|
+
return std::find(specifiers.begin(), specifiers.end(), s) != specifiers.end();
|
|
22361
|
+
}
|
|
21933
22362
|
|
|
21934
22363
|
protected:
|
|
21935
22364
|
//! The format specifiers
|
|
@@ -21945,13 +22374,13 @@ protected:
|
|
|
21945
22374
|
|
|
21946
22375
|
protected:
|
|
21947
22376
|
void AddLiteral(string literal);
|
|
21948
|
-
virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
|
|
22377
|
+
DUCKDB_API virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
|
|
21949
22378
|
};
|
|
21950
22379
|
|
|
21951
22380
|
struct StrfTimeFormat : public StrTimeFormat {
|
|
21952
|
-
idx_t GetLength(date_t date, dtime_t time);
|
|
22381
|
+
DUCKDB_API idx_t GetLength(date_t date, dtime_t time, int32_t utc_offset, const char *tz_name);
|
|
21953
22382
|
|
|
21954
|
-
void FormatString(date_t date, int32_t data[
|
|
22383
|
+
DUCKDB_API void FormatString(date_t date, int32_t data[8], const char *tz_name, char *target);
|
|
21955
22384
|
void FormatString(date_t date, dtime_t time, char *target);
|
|
21956
22385
|
|
|
21957
22386
|
DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
|
|
@@ -21964,8 +22393,9 @@ protected:
|
|
|
21964
22393
|
vector<bool> is_date_specifier;
|
|
21965
22394
|
|
|
21966
22395
|
protected:
|
|
21967
|
-
void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
21968
|
-
static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time
|
|
22396
|
+
DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
22397
|
+
static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time, int32_t utc_offset,
|
|
22398
|
+
const char *tz_name);
|
|
21969
22399
|
char *WriteString(char *target, const string_t &str);
|
|
21970
22400
|
char *Write2(char *target, uint8_t value);
|
|
21971
22401
|
char *WritePadded2(char *target, uint32_t value);
|
|
@@ -21973,20 +22403,21 @@ protected:
|
|
|
21973
22403
|
char *WritePadded(char *target, uint32_t value, size_t padding);
|
|
21974
22404
|
bool IsDateSpecifier(StrTimeSpecifier specifier);
|
|
21975
22405
|
char *WriteDateSpecifier(StrTimeSpecifier specifier, date_t date, char *target);
|
|
21976
|
-
char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], char *target);
|
|
22406
|
+
char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], const char *tz_name, char *target);
|
|
21977
22407
|
};
|
|
21978
22408
|
|
|
21979
22409
|
struct StrpTimeFormat : public StrTimeFormat {
|
|
21980
22410
|
public:
|
|
21981
22411
|
//! Type-safe parsing argument
|
|
21982
22412
|
struct ParseResult {
|
|
21983
|
-
int32_t data[
|
|
22413
|
+
int32_t data[8]; // year, month, day, hour, min, sec, µs, offset
|
|
22414
|
+
string tz;
|
|
21984
22415
|
string error_message;
|
|
21985
22416
|
idx_t error_position = DConstants::INVALID_INDEX;
|
|
21986
22417
|
|
|
21987
22418
|
date_t ToDate();
|
|
21988
22419
|
timestamp_t ToTimestamp();
|
|
21989
|
-
string FormatError(string_t input, const string &format_specifier);
|
|
22420
|
+
DUCKDB_API string FormatError(string_t input, const string &format_specifier);
|
|
21990
22421
|
};
|
|
21991
22422
|
|
|
21992
22423
|
public:
|
|
@@ -21996,7 +22427,7 @@ public:
|
|
|
21996
22427
|
public:
|
|
21997
22428
|
DUCKDB_API static ParseResult Parse(const string &format, const string &text);
|
|
21998
22429
|
|
|
21999
|
-
bool Parse(string_t str, ParseResult &result);
|
|
22430
|
+
DUCKDB_API bool Parse(string_t str, ParseResult &result);
|
|
22000
22431
|
|
|
22001
22432
|
bool TryParseDate(string_t str, date_t &result, string &error_message);
|
|
22002
22433
|
bool TryParseTimestamp(string_t str, timestamp_t &result, string &error_message);
|
|
@@ -22006,7 +22437,7 @@ public:
|
|
|
22006
22437
|
|
|
22007
22438
|
protected:
|
|
22008
22439
|
static string FormatStrpTimeError(const string &input, idx_t position);
|
|
22009
|
-
void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
22440
|
+
DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
|
|
22010
22441
|
int NumericSpecifierWidth(StrTimeSpecifier specifier);
|
|
22011
22442
|
int32_t TryParseCollection(const char *data, idx_t &pos, idx_t size, const string_t collection[],
|
|
22012
22443
|
idx_t collection_count);
|
|
@@ -22017,9 +22448,24 @@ protected:
|
|
|
22017
22448
|
|
|
22018
22449
|
|
|
22019
22450
|
|
|
22451
|
+
//===----------------------------------------------------------------------===//
|
|
22452
|
+
// DuckDB
|
|
22453
|
+
//
|
|
22454
|
+
// duckdb/common/queue.hpp
|
|
22455
|
+
//
|
|
22456
|
+
//
|
|
22457
|
+
//===----------------------------------------------------------------------===//
|
|
22458
|
+
|
|
22459
|
+
|
|
22460
|
+
|
|
22461
|
+
#include <queue>
|
|
22462
|
+
|
|
22463
|
+
namespace duckdb {
|
|
22464
|
+
using std::queue;
|
|
22465
|
+
}
|
|
22466
|
+
|
|
22020
22467
|
|
|
22021
22468
|
#include <sstream>
|
|
22022
|
-
#include <queue>
|
|
22023
22469
|
|
|
22024
22470
|
namespace duckdb {
|
|
22025
22471
|
struct CopyInfo;
|
|
@@ -22057,13 +22503,10 @@ struct TextSearchShiftArray {
|
|
|
22057
22503
|
};
|
|
22058
22504
|
|
|
22059
22505
|
struct BufferedCSVReaderOptions {
|
|
22060
|
-
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
|
22065
|
-
//! Whether or not to automatically detect dialect and datatypes
|
|
22066
|
-
bool auto_detect = false;
|
|
22506
|
+
//===--------------------------------------------------------------------===//
|
|
22507
|
+
// CommonCSVOptions
|
|
22508
|
+
//===--------------------------------------------------------------------===//
|
|
22509
|
+
|
|
22067
22510
|
//! Whether or not a delimiter was defined by the user
|
|
22068
22511
|
bool has_delimiter = false;
|
|
22069
22512
|
//! Delimiter to separate columns within each line
|
|
@@ -22080,26 +22523,51 @@ struct BufferedCSVReaderOptions {
|
|
|
22080
22523
|
bool has_header = false;
|
|
22081
22524
|
//! Whether or not the file has a header line
|
|
22082
22525
|
bool header = false;
|
|
22083
|
-
//! Whether or not
|
|
22084
|
-
bool
|
|
22085
|
-
//! How many leading rows to skip
|
|
22086
|
-
idx_t skip_rows = 0;
|
|
22526
|
+
//! Whether or not we should ignore InvalidInput errors
|
|
22527
|
+
bool ignore_errors = false;
|
|
22087
22528
|
//! Expected number of columns
|
|
22088
22529
|
idx_t num_cols = 0;
|
|
22530
|
+
//! Number of samples to buffer
|
|
22531
|
+
idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
|
|
22089
22532
|
//! Specifies the string that represents a null value
|
|
22090
22533
|
string null_str;
|
|
22534
|
+
//! Whether file is compressed or not, and if so which compression type
|
|
22535
|
+
//! AUTO_DETECT (default; infer from file extension)
|
|
22536
|
+
FileCompressionType compression = FileCompressionType::AUTO_DETECT;
|
|
22537
|
+
|
|
22538
|
+
//===--------------------------------------------------------------------===//
|
|
22539
|
+
// ReadCSVOptions
|
|
22540
|
+
//===--------------------------------------------------------------------===//
|
|
22541
|
+
|
|
22542
|
+
//! How many leading rows to skip
|
|
22543
|
+
idx_t skip_rows = 0;
|
|
22544
|
+
//! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
|
|
22545
|
+
idx_t maximum_line_size = 2097152;
|
|
22546
|
+
//! Whether or not header names shall be normalized
|
|
22547
|
+
bool normalize_names = false;
|
|
22091
22548
|
//! True, if column with that index must skip null check
|
|
22092
22549
|
vector<bool> force_not_null;
|
|
22550
|
+
//! Consider all columns to be of type varchar
|
|
22551
|
+
bool all_varchar = false;
|
|
22093
22552
|
//! Size of sample chunk used for dialect and type detection
|
|
22094
22553
|
idx_t sample_chunk_size = STANDARD_VECTOR_SIZE;
|
|
22095
22554
|
//! Number of sample chunks used for type detection
|
|
22096
22555
|
idx_t sample_chunks = 10;
|
|
22097
|
-
//!
|
|
22098
|
-
|
|
22099
|
-
//!
|
|
22100
|
-
|
|
22101
|
-
//!
|
|
22102
|
-
|
|
22556
|
+
//! Whether or not to automatically detect dialect and datatypes
|
|
22557
|
+
bool auto_detect = false;
|
|
22558
|
+
//! The file path of the CSV file to read
|
|
22559
|
+
string file_path;
|
|
22560
|
+
//! Whether or not to include a file name column
|
|
22561
|
+
bool include_file_name = false;
|
|
22562
|
+
|
|
22563
|
+
//===--------------------------------------------------------------------===//
|
|
22564
|
+
// WriteCSVOptions
|
|
22565
|
+
//===--------------------------------------------------------------------===//
|
|
22566
|
+
|
|
22567
|
+
//! The column names of the columns to write
|
|
22568
|
+
vector<string> names;
|
|
22569
|
+
//! True, if column with that index must be quoted
|
|
22570
|
+
vector<bool> force_quote;
|
|
22103
22571
|
|
|
22104
22572
|
//! The date format to use (if any is specified)
|
|
22105
22573
|
std::map<LogicalTypeId, StrpTimeFormat> date_format = {{LogicalTypeId::DATE, {}}, {LogicalTypeId::TIMESTAMP, {}}};
|
|
@@ -22107,6 +22575,16 @@ struct BufferedCSVReaderOptions {
|
|
|
22107
22575
|
std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
|
|
22108
22576
|
|
|
22109
22577
|
void SetDelimiter(const string &delimiter);
|
|
22578
|
+
//! Set an option that is supported by both reading and writing functions, called by
|
|
22579
|
+
//! the SetReadOption and SetWriteOption methods
|
|
22580
|
+
bool SetBaseOption(const string &loption, const Value &value);
|
|
22581
|
+
|
|
22582
|
+
//! loption - lowercase string
|
|
22583
|
+
//! set - argument(s) to the option
|
|
22584
|
+
//! expected_names - names expected if the option is "columns"
|
|
22585
|
+
void SetReadOption(const string &loption, const Value &value, vector<string> &expected_names);
|
|
22586
|
+
|
|
22587
|
+
void SetWriteOption(const string &loption, const Value &value);
|
|
22110
22588
|
|
|
22111
22589
|
std::string ToString() const;
|
|
22112
22590
|
};
|
|
@@ -22232,6 +22710,10 @@ private:
|
|
|
22232
22710
|
const vector<LogicalType> &requested_types,
|
|
22233
22711
|
vector<vector<LogicalType>> &best_sql_types_candidates,
|
|
22234
22712
|
map<LogicalTypeId, vector<string>> &best_format_candidates);
|
|
22713
|
+
|
|
22714
|
+
private:
|
|
22715
|
+
//! Whether or not the current row's columns have overflown sql_types.size()
|
|
22716
|
+
bool error_column_overflow = false;
|
|
22235
22717
|
};
|
|
22236
22718
|
|
|
22237
22719
|
} // namespace duckdb
|
|
@@ -22382,7 +22864,7 @@ private:
|
|
|
22382
22864
|
//===----------------------------------------------------------------------===//
|
|
22383
22865
|
// DuckDB
|
|
22384
22866
|
//
|
|
22385
|
-
// duckdb/parser/expression/
|
|
22867
|
+
// duckdb/parser/expression/comparison_expression.hpp
|
|
22386
22868
|
//
|
|
22387
22869
|
//
|
|
22388
22870
|
//===----------------------------------------------------------------------===//
|
|
@@ -22391,72 +22873,38 @@ private:
|
|
|
22391
22873
|
|
|
22392
22874
|
|
|
22393
22875
|
|
|
22394
|
-
|
|
22395
22876
|
namespace duckdb {
|
|
22396
|
-
|
|
22397
|
-
//!
|
|
22398
|
-
|
|
22399
|
-
//! 2. An OperatorExpression with the "->" operator
|
|
22400
|
-
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
22401
|
-
class LambdaExpression : public ParsedExpression {
|
|
22877
|
+
//! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
|
|
22878
|
+
//! and has two children.
|
|
22879
|
+
class ComparisonExpression : public ParsedExpression {
|
|
22402
22880
|
public:
|
|
22403
|
-
|
|
22881
|
+
DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
22882
|
+
unique_ptr<ParsedExpression> right);
|
|
22404
22883
|
|
|
22405
|
-
unique_ptr<ParsedExpression>
|
|
22406
|
-
unique_ptr<ParsedExpression>
|
|
22884
|
+
unique_ptr<ParsedExpression> left;
|
|
22885
|
+
unique_ptr<ParsedExpression> right;
|
|
22407
22886
|
|
|
22408
22887
|
public:
|
|
22409
22888
|
string ToString() const override;
|
|
22410
22889
|
|
|
22411
|
-
static bool Equals(const
|
|
22412
|
-
hash_t Hash() const override;
|
|
22890
|
+
static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
|
|
22413
22891
|
|
|
22414
22892
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22415
22893
|
|
|
22416
22894
|
void Serialize(FieldWriter &writer) const override;
|
|
22417
22895
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22418
|
-
};
|
|
22419
|
-
|
|
22420
|
-
} // namespace duckdb
|
|
22421
|
-
//===----------------------------------------------------------------------===//
|
|
22422
|
-
// DuckDB
|
|
22423
|
-
//
|
|
22424
|
-
// duckdb/parser/expression/collate_expression.hpp
|
|
22425
|
-
//
|
|
22426
|
-
//
|
|
22427
|
-
//===----------------------------------------------------------------------===//
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22433
|
-
namespace duckdb {
|
|
22434
|
-
|
|
22435
|
-
//! CollateExpression represents a COLLATE statement
|
|
22436
|
-
class CollateExpression : public ParsedExpression {
|
|
22437
|
-
public:
|
|
22438
|
-
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
22439
|
-
|
|
22440
|
-
//! The child of the cast expression
|
|
22441
|
-
unique_ptr<ParsedExpression> child;
|
|
22442
|
-
//! The collation clause
|
|
22443
|
-
string collation;
|
|
22444
22896
|
|
|
22445
22897
|
public:
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
22451
|
-
|
|
22452
|
-
void Serialize(FieldWriter &writer) const override;
|
|
22453
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22898
|
+
template <class T, class BASE>
|
|
22899
|
+
static string ToString(const T &entry) {
|
|
22900
|
+
return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
|
|
22901
|
+
}
|
|
22454
22902
|
};
|
|
22455
22903
|
} // namespace duckdb
|
|
22456
22904
|
//===----------------------------------------------------------------------===//
|
|
22457
22905
|
// DuckDB
|
|
22458
22906
|
//
|
|
22459
|
-
// duckdb/parser/expression/
|
|
22907
|
+
// duckdb/parser/expression/default_expression.hpp
|
|
22460
22908
|
//
|
|
22461
22909
|
//
|
|
22462
22910
|
//===----------------------------------------------------------------------===//
|
|
@@ -22466,35 +22914,24 @@ public:
|
|
|
22466
22914
|
|
|
22467
22915
|
|
|
22468
22916
|
namespace duckdb {
|
|
22469
|
-
|
|
22470
|
-
class
|
|
22917
|
+
//! Represents the default value of a column
|
|
22918
|
+
class DefaultExpression : public ParsedExpression {
|
|
22471
22919
|
public:
|
|
22472
|
-
|
|
22473
|
-
unique_ptr<ParsedExpression> upper);
|
|
22474
|
-
|
|
22475
|
-
unique_ptr<ParsedExpression> input;
|
|
22476
|
-
unique_ptr<ParsedExpression> lower;
|
|
22477
|
-
unique_ptr<ParsedExpression> upper;
|
|
22920
|
+
DefaultExpression();
|
|
22478
22921
|
|
|
22479
22922
|
public:
|
|
22480
|
-
|
|
22923
|
+
bool IsScalar() const override {
|
|
22924
|
+
return false;
|
|
22925
|
+
}
|
|
22481
22926
|
|
|
22482
|
-
|
|
22927
|
+
string ToString() const override;
|
|
22483
22928
|
|
|
22484
22929
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22485
22930
|
|
|
22486
22931
|
void Serialize(FieldWriter &writer) const override;
|
|
22487
22932
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22488
|
-
|
|
22489
|
-
public:
|
|
22490
|
-
template <class T, class BASE>
|
|
22491
|
-
static string ToString(const T &entry) {
|
|
22492
|
-
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
22493
|
-
}
|
|
22494
22933
|
};
|
|
22495
22934
|
} // namespace duckdb
|
|
22496
|
-
|
|
22497
|
-
|
|
22498
22935
|
//===----------------------------------------------------------------------===//
|
|
22499
22936
|
// DuckDB
|
|
22500
22937
|
//
|
|
@@ -22547,11 +22984,10 @@ public:
|
|
|
22547
22984
|
}
|
|
22548
22985
|
};
|
|
22549
22986
|
} // namespace duckdb
|
|
22550
|
-
|
|
22551
22987
|
//===----------------------------------------------------------------------===//
|
|
22552
22988
|
// DuckDB
|
|
22553
22989
|
//
|
|
22554
|
-
// duckdb/parser/expression/
|
|
22990
|
+
// duckdb/parser/expression/positional_reference_expression.hpp
|
|
22555
22991
|
//
|
|
22556
22992
|
//
|
|
22557
22993
|
//===----------------------------------------------------------------------===//
|
|
@@ -22560,46 +22996,32 @@ public:
|
|
|
22560
22996
|
|
|
22561
22997
|
|
|
22562
22998
|
|
|
22563
|
-
|
|
22564
22999
|
namespace duckdb {
|
|
22565
|
-
|
|
22566
|
-
//! CastExpression represents a type cast from one SQL type to another SQL type
|
|
22567
|
-
class CastExpression : public ParsedExpression {
|
|
23000
|
+
class PositionalReferenceExpression : public ParsedExpression {
|
|
22568
23001
|
public:
|
|
22569
|
-
DUCKDB_API
|
|
23002
|
+
DUCKDB_API PositionalReferenceExpression(idx_t index);
|
|
22570
23003
|
|
|
22571
|
-
|
|
22572
|
-
unique_ptr<ParsedExpression> child;
|
|
22573
|
-
//! The type to cast to
|
|
22574
|
-
LogicalType cast_type;
|
|
22575
|
-
//! Whether or not this is a try_cast expression
|
|
22576
|
-
bool try_cast;
|
|
23004
|
+
idx_t index;
|
|
22577
23005
|
|
|
22578
23006
|
public:
|
|
22579
|
-
|
|
23007
|
+
bool IsScalar() const override {
|
|
23008
|
+
return false;
|
|
23009
|
+
}
|
|
22580
23010
|
|
|
22581
|
-
|
|
23011
|
+
string ToString() const override;
|
|
22582
23012
|
|
|
23013
|
+
static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
|
|
22583
23014
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23015
|
+
hash_t Hash() const override;
|
|
22584
23016
|
|
|
22585
23017
|
void Serialize(FieldWriter &writer) const override;
|
|
22586
23018
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22587
|
-
|
|
22588
|
-
public:
|
|
22589
|
-
template <class T, class BASE>
|
|
22590
|
-
static string ToString(const T &entry) {
|
|
22591
|
-
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
22592
|
-
entry.cast_type.ToString() + ")";
|
|
22593
|
-
}
|
|
22594
23019
|
};
|
|
22595
23020
|
} // namespace duckdb
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
23021
|
//===----------------------------------------------------------------------===//
|
|
22600
23022
|
// DuckDB
|
|
22601
23023
|
//
|
|
22602
|
-
// duckdb/parser/expression/
|
|
23024
|
+
// duckdb/parser/expression/conjunction_expression.hpp
|
|
22603
23025
|
//
|
|
22604
23026
|
//
|
|
22605
23027
|
//===----------------------------------------------------------------------===//
|
|
@@ -22608,21 +23030,25 @@ public:
|
|
|
22608
23030
|
|
|
22609
23031
|
|
|
22610
23032
|
|
|
23033
|
+
|
|
22611
23034
|
namespace duckdb {
|
|
22612
|
-
|
|
22613
|
-
//!
|
|
22614
|
-
class
|
|
23035
|
+
|
|
23036
|
+
//! Represents a conjunction (AND/OR)
|
|
23037
|
+
class ConjunctionExpression : public ParsedExpression {
|
|
22615
23038
|
public:
|
|
22616
|
-
DUCKDB_API
|
|
22617
|
-
|
|
23039
|
+
DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
|
|
23040
|
+
DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23041
|
+
DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
23042
|
+
unique_ptr<ParsedExpression> right);
|
|
22618
23043
|
|
|
22619
|
-
unique_ptr<ParsedExpression
|
|
22620
|
-
unique_ptr<ParsedExpression> right;
|
|
23044
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
22621
23045
|
|
|
22622
23046
|
public:
|
|
23047
|
+
void AddExpression(unique_ptr<ParsedExpression> expr);
|
|
23048
|
+
|
|
22623
23049
|
string ToString() const override;
|
|
22624
23050
|
|
|
22625
|
-
static bool Equals(const
|
|
23051
|
+
static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
|
|
22626
23052
|
|
|
22627
23053
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22628
23054
|
|
|
@@ -22632,15 +23058,18 @@ public:
|
|
|
22632
23058
|
public:
|
|
22633
23059
|
template <class T, class BASE>
|
|
22634
23060
|
static string ToString(const T &entry) {
|
|
22635
|
-
|
|
23061
|
+
string result = "(" + entry.children[0]->ToString();
|
|
23062
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
23063
|
+
result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
|
|
23064
|
+
}
|
|
23065
|
+
return result + ")";
|
|
22636
23066
|
}
|
|
22637
23067
|
};
|
|
22638
23068
|
} // namespace duckdb
|
|
22639
|
-
|
|
22640
23069
|
//===----------------------------------------------------------------------===//
|
|
22641
23070
|
// DuckDB
|
|
22642
23071
|
//
|
|
22643
|
-
// duckdb/parser/expression/
|
|
23072
|
+
// duckdb/parser/expression/subquery_expression.hpp
|
|
22644
23073
|
//
|
|
22645
23074
|
//
|
|
22646
23075
|
//===----------------------------------------------------------------------===//
|
|
@@ -22650,46 +23079,46 @@ public:
|
|
|
22650
23079
|
|
|
22651
23080
|
|
|
22652
23081
|
|
|
23082
|
+
|
|
22653
23083
|
namespace duckdb {
|
|
22654
23084
|
|
|
22655
|
-
//! Represents a
|
|
22656
|
-
class
|
|
23085
|
+
//! Represents a subquery
|
|
23086
|
+
class SubqueryExpression : public ParsedExpression {
|
|
22657
23087
|
public:
|
|
22658
|
-
|
|
22659
|
-
DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
22660
|
-
DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
22661
|
-
unique_ptr<ParsedExpression> right);
|
|
23088
|
+
SubqueryExpression();
|
|
22662
23089
|
|
|
22663
|
-
|
|
23090
|
+
//! The actual subquery
|
|
23091
|
+
unique_ptr<SelectStatement> subquery;
|
|
23092
|
+
//! The subquery type
|
|
23093
|
+
SubqueryType subquery_type;
|
|
23094
|
+
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
23095
|
+
//! subquery)
|
|
23096
|
+
unique_ptr<ParsedExpression> child;
|
|
23097
|
+
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
23098
|
+
ExpressionType comparison_type;
|
|
22664
23099
|
|
|
22665
23100
|
public:
|
|
22666
|
-
|
|
23101
|
+
bool HasSubquery() const override {
|
|
23102
|
+
return true;
|
|
23103
|
+
}
|
|
23104
|
+
bool IsScalar() const override {
|
|
23105
|
+
return false;
|
|
23106
|
+
}
|
|
22667
23107
|
|
|
22668
23108
|
string ToString() const override;
|
|
22669
23109
|
|
|
22670
|
-
static bool Equals(const
|
|
23110
|
+
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
22671
23111
|
|
|
22672
23112
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22673
23113
|
|
|
22674
23114
|
void Serialize(FieldWriter &writer) const override;
|
|
22675
23115
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22676
|
-
|
|
22677
|
-
public:
|
|
22678
|
-
template <class T, class BASE>
|
|
22679
|
-
static string ToString(const T &entry) {
|
|
22680
|
-
string result = entry.children[0]->ToString();
|
|
22681
|
-
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22682
|
-
result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
|
|
22683
|
-
}
|
|
22684
|
-
return result;
|
|
22685
|
-
}
|
|
22686
23116
|
};
|
|
22687
23117
|
} // namespace duckdb
|
|
22688
|
-
|
|
22689
23118
|
//===----------------------------------------------------------------------===//
|
|
22690
23119
|
// DuckDB
|
|
22691
23120
|
//
|
|
22692
|
-
// duckdb/parser/expression/
|
|
23121
|
+
// duckdb/parser/expression/cast_expression.hpp
|
|
22693
23122
|
//
|
|
22694
23123
|
//
|
|
22695
23124
|
//===----------------------------------------------------------------------===//
|
|
@@ -22701,32 +23130,40 @@ public:
|
|
|
22701
23130
|
|
|
22702
23131
|
namespace duckdb {
|
|
22703
23132
|
|
|
22704
|
-
//!
|
|
22705
|
-
class
|
|
23133
|
+
//! CastExpression represents a type cast from one SQL type to another SQL type
|
|
23134
|
+
class CastExpression : public ParsedExpression {
|
|
22706
23135
|
public:
|
|
22707
|
-
DUCKDB_API
|
|
23136
|
+
DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
|
|
22708
23137
|
|
|
22709
|
-
//! The
|
|
22710
|
-
|
|
23138
|
+
//! The child of the cast expression
|
|
23139
|
+
unique_ptr<ParsedExpression> child;
|
|
23140
|
+
//! The type to cast to
|
|
23141
|
+
LogicalType cast_type;
|
|
23142
|
+
//! Whether or not this is a try_cast expression
|
|
23143
|
+
bool try_cast;
|
|
22711
23144
|
|
|
22712
23145
|
public:
|
|
22713
23146
|
string ToString() const override;
|
|
22714
23147
|
|
|
22715
|
-
static bool Equals(const
|
|
22716
|
-
hash_t Hash() const override;
|
|
23148
|
+
static bool Equals(const CastExpression *a, const CastExpression *b);
|
|
22717
23149
|
|
|
22718
23150
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22719
23151
|
|
|
22720
23152
|
void Serialize(FieldWriter &writer) const override;
|
|
22721
23153
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22722
|
-
};
|
|
22723
23154
|
|
|
23155
|
+
public:
|
|
23156
|
+
template <class T, class BASE>
|
|
23157
|
+
static string ToString(const T &entry) {
|
|
23158
|
+
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
23159
|
+
entry.cast_type.ToString() + ")";
|
|
23160
|
+
}
|
|
23161
|
+
};
|
|
22724
23162
|
} // namespace duckdb
|
|
22725
|
-
|
|
22726
23163
|
//===----------------------------------------------------------------------===//
|
|
22727
23164
|
// DuckDB
|
|
22728
23165
|
//
|
|
22729
|
-
// duckdb/parser/expression/
|
|
23166
|
+
// duckdb/parser/expression/lambda_expression.hpp
|
|
22730
23167
|
//
|
|
22731
23168
|
//
|
|
22732
23169
|
//===----------------------------------------------------------------------===//
|
|
@@ -22735,26 +23172,33 @@ public:
|
|
|
22735
23172
|
|
|
22736
23173
|
|
|
22737
23174
|
|
|
23175
|
+
|
|
22738
23176
|
namespace duckdb {
|
|
22739
|
-
//! Represents the default value of a column
|
|
22740
|
-
class DefaultExpression : public ParsedExpression {
|
|
22741
|
-
public:
|
|
22742
|
-
DefaultExpression();
|
|
22743
23177
|
|
|
23178
|
+
//! LambdaExpression represents either:
|
|
23179
|
+
//! 1. A lambda operator that can be used for e.g. mapping an expression to a list
|
|
23180
|
+
//! 2. An OperatorExpression with the "->" operator
|
|
23181
|
+
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
23182
|
+
class LambdaExpression : public ParsedExpression {
|
|
22744
23183
|
public:
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
23184
|
+
LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
|
|
23185
|
+
|
|
23186
|
+
unique_ptr<ParsedExpression> lhs;
|
|
23187
|
+
unique_ptr<ParsedExpression> rhs;
|
|
22748
23188
|
|
|
23189
|
+
public:
|
|
22749
23190
|
string ToString() const override;
|
|
22750
23191
|
|
|
23192
|
+
static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
|
|
23193
|
+
hash_t Hash() const override;
|
|
23194
|
+
|
|
22751
23195
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22752
23196
|
|
|
22753
23197
|
void Serialize(FieldWriter &writer) const override;
|
|
22754
23198
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22755
23199
|
};
|
|
22756
|
-
} // namespace duckdb
|
|
22757
23200
|
|
|
23201
|
+
} // namespace duckdb
|
|
22758
23202
|
//===----------------------------------------------------------------------===//
|
|
22759
23203
|
// DuckDB
|
|
22760
23204
|
//
|
|
@@ -22817,7 +23261,7 @@ public:
|
|
|
22817
23261
|
template <class T, class BASE>
|
|
22818
23262
|
static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
|
|
22819
23263
|
bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
|
|
22820
|
-
bool export_state = false) {
|
|
23264
|
+
bool export_state = false, bool add_alias = false) {
|
|
22821
23265
|
if (is_operator) {
|
|
22822
23266
|
// built-in operator
|
|
22823
23267
|
D_ASSERT(!distinct);
|
|
@@ -22839,8 +23283,11 @@ public:
|
|
|
22839
23283
|
if (distinct) {
|
|
22840
23284
|
result += "DISTINCT ";
|
|
22841
23285
|
}
|
|
22842
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22843
|
-
|
|
23286
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
|
|
23287
|
+
return child->alias.empty() || !add_alias
|
|
23288
|
+
? child->ToString()
|
|
23289
|
+
: KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
|
|
23290
|
+
});
|
|
22844
23291
|
// ordered aggregate
|
|
22845
23292
|
if (order_bys && !order_bys->orders.empty()) {
|
|
22846
23293
|
if (entry.children.empty()) {
|
|
@@ -22869,12 +23316,10 @@ public:
|
|
|
22869
23316
|
}
|
|
22870
23317
|
};
|
|
22871
23318
|
} // namespace duckdb
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
23319
|
//===----------------------------------------------------------------------===//
|
|
22875
23320
|
// DuckDB
|
|
22876
23321
|
//
|
|
22877
|
-
// duckdb/parser/expression/
|
|
23322
|
+
// duckdb/parser/expression/star_expression.hpp
|
|
22878
23323
|
//
|
|
22879
23324
|
//
|
|
22880
23325
|
//===----------------------------------------------------------------------===//
|
|
@@ -22884,94 +23329,31 @@ public:
|
|
|
22884
23329
|
|
|
22885
23330
|
|
|
22886
23331
|
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
23332
|
namespace duckdb {
|
|
22890
|
-
|
|
22891
|
-
|
|
23333
|
+
|
|
23334
|
+
//! Represents a * expression in the SELECT clause
|
|
23335
|
+
class StarExpression : public ParsedExpression {
|
|
22892
23336
|
public:
|
|
22893
|
-
|
|
22894
|
-
unique_ptr<ParsedExpression> right = nullptr);
|
|
22895
|
-
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23337
|
+
StarExpression(string relation_name = string());
|
|
22896
23338
|
|
|
22897
|
-
|
|
23339
|
+
//! The relation name in case of tbl.*, or empty if this is a normal *
|
|
23340
|
+
string relation_name;
|
|
23341
|
+
//! List of columns to exclude from the STAR expression
|
|
23342
|
+
case_insensitive_set_t exclude_list;
|
|
23343
|
+
//! List of columns to replace with another expression
|
|
23344
|
+
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
22898
23345
|
|
|
22899
23346
|
public:
|
|
22900
23347
|
string ToString() const override;
|
|
22901
23348
|
|
|
22902
|
-
static bool Equals(const
|
|
23349
|
+
static bool Equals(const StarExpression *a, const StarExpression *b);
|
|
22903
23350
|
|
|
22904
23351
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
22905
23352
|
|
|
22906
23353
|
void Serialize(FieldWriter &writer) const override;
|
|
22907
23354
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22908
|
-
|
|
22909
|
-
public:
|
|
22910
|
-
template <class T, class BASE>
|
|
22911
|
-
static string ToString(const T &entry) {
|
|
22912
|
-
auto op = ExpressionTypeToOperator(entry.type);
|
|
22913
|
-
if (!op.empty()) {
|
|
22914
|
-
// use the operator string to represent the operator
|
|
22915
|
-
D_ASSERT(entry.children.size() == 2);
|
|
22916
|
-
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
22917
|
-
}
|
|
22918
|
-
switch (entry.type) {
|
|
22919
|
-
case ExpressionType::COMPARE_IN:
|
|
22920
|
-
case ExpressionType::COMPARE_NOT_IN: {
|
|
22921
|
-
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
22922
|
-
string in_child = entry.children[0]->ToString();
|
|
22923
|
-
string child_list = "(";
|
|
22924
|
-
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
22925
|
-
if (i > 1) {
|
|
22926
|
-
child_list += ", ";
|
|
22927
|
-
}
|
|
22928
|
-
child_list += entry.children[i]->ToString();
|
|
22929
|
-
}
|
|
22930
|
-
child_list += ")";
|
|
22931
|
-
return "(" + in_child + op_type + child_list + ")";
|
|
22932
|
-
}
|
|
22933
|
-
case ExpressionType::OPERATOR_NOT:
|
|
22934
|
-
case ExpressionType::GROUPING_FUNCTION:
|
|
22935
|
-
case ExpressionType::OPERATOR_COALESCE: {
|
|
22936
|
-
string result = ExpressionTypeToString(entry.type);
|
|
22937
|
-
result += "(";
|
|
22938
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22939
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22940
|
-
result += ")";
|
|
22941
|
-
return result;
|
|
22942
|
-
}
|
|
22943
|
-
case ExpressionType::OPERATOR_IS_NULL:
|
|
22944
|
-
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
22945
|
-
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
22946
|
-
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
22947
|
-
case ExpressionType::ARRAY_EXTRACT:
|
|
22948
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
22949
|
-
case ExpressionType::ARRAY_SLICE:
|
|
22950
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
22951
|
-
entry.children[2]->ToString() + "]";
|
|
22952
|
-
case ExpressionType::STRUCT_EXTRACT: {
|
|
22953
|
-
D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
|
|
22954
|
-
auto child_string = entry.children[1]->ToString();
|
|
22955
|
-
D_ASSERT(child_string.size() >= 3);
|
|
22956
|
-
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
22957
|
-
return "(" + entry.children[0]->ToString() + ")." +
|
|
22958
|
-
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
22959
|
-
}
|
|
22960
|
-
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
22961
|
-
string result = "ARRAY[";
|
|
22962
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
22963
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
22964
|
-
result += "]";
|
|
22965
|
-
return result;
|
|
22966
|
-
}
|
|
22967
|
-
default:
|
|
22968
|
-
throw InternalException("Unrecognized operator type");
|
|
22969
|
-
}
|
|
22970
|
-
}
|
|
22971
23355
|
};
|
|
22972
|
-
|
|
22973
23356
|
} // namespace duckdb
|
|
22974
|
-
|
|
22975
23357
|
//===----------------------------------------------------------------------===//
|
|
22976
23358
|
// DuckDB
|
|
22977
23359
|
//
|
|
@@ -23008,11 +23390,10 @@ public:
|
|
|
23008
23390
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23009
23391
|
};
|
|
23010
23392
|
} // namespace duckdb
|
|
23011
|
-
|
|
23012
23393
|
//===----------------------------------------------------------------------===//
|
|
23013
23394
|
// DuckDB
|
|
23014
23395
|
//
|
|
23015
|
-
// duckdb/parser/expression/
|
|
23396
|
+
// duckdb/parser/expression/between_expression.hpp
|
|
23016
23397
|
//
|
|
23017
23398
|
//
|
|
23018
23399
|
//===----------------------------------------------------------------------===//
|
|
@@ -23022,32 +23403,41 @@ public:
|
|
|
23022
23403
|
|
|
23023
23404
|
|
|
23024
23405
|
namespace duckdb {
|
|
23025
|
-
|
|
23406
|
+
|
|
23407
|
+
class BetweenExpression : public ParsedExpression {
|
|
23026
23408
|
public:
|
|
23027
|
-
DUCKDB_API
|
|
23409
|
+
DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
|
|
23410
|
+
unique_ptr<ParsedExpression> upper);
|
|
23028
23411
|
|
|
23029
|
-
|
|
23412
|
+
unique_ptr<ParsedExpression> input;
|
|
23413
|
+
unique_ptr<ParsedExpression> lower;
|
|
23414
|
+
unique_ptr<ParsedExpression> upper;
|
|
23030
23415
|
|
|
23031
23416
|
public:
|
|
23032
|
-
bool IsScalar() const override {
|
|
23033
|
-
return false;
|
|
23034
|
-
}
|
|
23035
|
-
|
|
23036
23417
|
string ToString() const override;
|
|
23037
23418
|
|
|
23038
|
-
static bool Equals(const
|
|
23419
|
+
static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
|
|
23420
|
+
|
|
23039
23421
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23040
|
-
hash_t Hash() const override;
|
|
23041
23422
|
|
|
23042
23423
|
void Serialize(FieldWriter &writer) const override;
|
|
23043
23424
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23425
|
+
|
|
23426
|
+
public:
|
|
23427
|
+
template <class T, class BASE>
|
|
23428
|
+
static string ToString(const T &entry) {
|
|
23429
|
+
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
23430
|
+
}
|
|
23044
23431
|
};
|
|
23045
23432
|
} // namespace duckdb
|
|
23046
23433
|
|
|
23434
|
+
|
|
23435
|
+
|
|
23436
|
+
|
|
23047
23437
|
//===----------------------------------------------------------------------===//
|
|
23048
23438
|
// DuckDB
|
|
23049
23439
|
//
|
|
23050
|
-
// duckdb/parser/expression/
|
|
23440
|
+
// duckdb/parser/expression/collate_expression.hpp
|
|
23051
23441
|
//
|
|
23052
23442
|
//
|
|
23053
23443
|
//===----------------------------------------------------------------------===//
|
|
@@ -23056,25 +23446,22 @@ public:
|
|
|
23056
23446
|
|
|
23057
23447
|
|
|
23058
23448
|
|
|
23059
|
-
|
|
23060
23449
|
namespace duckdb {
|
|
23061
23450
|
|
|
23062
|
-
//!
|
|
23063
|
-
class
|
|
23451
|
+
//! CollateExpression represents a COLLATE statement
|
|
23452
|
+
class CollateExpression : public ParsedExpression {
|
|
23064
23453
|
public:
|
|
23065
|
-
|
|
23454
|
+
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
23066
23455
|
|
|
23067
|
-
//! The
|
|
23068
|
-
|
|
23069
|
-
//!
|
|
23070
|
-
|
|
23071
|
-
//! List of columns to replace with another expression
|
|
23072
|
-
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
23456
|
+
//! The child of the cast expression
|
|
23457
|
+
unique_ptr<ParsedExpression> child;
|
|
23458
|
+
//! The collation clause
|
|
23459
|
+
string collation;
|
|
23073
23460
|
|
|
23074
23461
|
public:
|
|
23075
23462
|
string ToString() const override;
|
|
23076
23463
|
|
|
23077
|
-
static bool Equals(const
|
|
23464
|
+
static bool Equals(const CollateExpression *a, const CollateExpression *b);
|
|
23078
23465
|
|
|
23079
23466
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23080
23467
|
|
|
@@ -23083,10 +23470,13 @@ public:
|
|
|
23083
23470
|
};
|
|
23084
23471
|
} // namespace duckdb
|
|
23085
23472
|
|
|
23473
|
+
|
|
23474
|
+
|
|
23475
|
+
|
|
23086
23476
|
//===----------------------------------------------------------------------===//
|
|
23087
23477
|
// DuckDB
|
|
23088
23478
|
//
|
|
23089
|
-
// duckdb/parser/expression/
|
|
23479
|
+
// duckdb/parser/expression/constant_expression.hpp
|
|
23090
23480
|
//
|
|
23091
23481
|
//
|
|
23092
23482
|
//===----------------------------------------------------------------------===//
|
|
@@ -23096,90 +23486,37 @@ public:
|
|
|
23096
23486
|
|
|
23097
23487
|
|
|
23098
23488
|
|
|
23099
|
-
|
|
23100
23489
|
namespace duckdb {
|
|
23101
23490
|
|
|
23102
|
-
//!
|
|
23103
|
-
class
|
|
23491
|
+
//! ConstantExpression represents a constant value in the query
|
|
23492
|
+
class ConstantExpression : public ParsedExpression {
|
|
23104
23493
|
public:
|
|
23105
|
-
|
|
23494
|
+
DUCKDB_API explicit ConstantExpression(Value val);
|
|
23106
23495
|
|
|
23107
|
-
//! The
|
|
23108
|
-
|
|
23109
|
-
//! The subquery type
|
|
23110
|
-
SubqueryType subquery_type;
|
|
23111
|
-
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
23112
|
-
//! subquery)
|
|
23113
|
-
unique_ptr<ParsedExpression> child;
|
|
23114
|
-
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
23115
|
-
ExpressionType comparison_type;
|
|
23496
|
+
//! The constant value referenced
|
|
23497
|
+
Value value;
|
|
23116
23498
|
|
|
23117
23499
|
public:
|
|
23118
|
-
bool HasSubquery() const override {
|
|
23119
|
-
return true;
|
|
23120
|
-
}
|
|
23121
|
-
bool IsScalar() const override {
|
|
23122
|
-
return false;
|
|
23123
|
-
}
|
|
23124
|
-
|
|
23125
23500
|
string ToString() const override;
|
|
23126
23501
|
|
|
23127
|
-
static bool Equals(const
|
|
23502
|
+
static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
|
|
23503
|
+
hash_t Hash() const override;
|
|
23128
23504
|
|
|
23129
23505
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23130
23506
|
|
|
23131
23507
|
void Serialize(FieldWriter &writer) const override;
|
|
23132
23508
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23133
23509
|
};
|
|
23134
|
-
} // namespace duckdb
|
|
23135
|
-
|
|
23136
|
-
|
|
23137
|
-
//===----------------------------------------------------------------------===//
|
|
23138
|
-
// DuckDB
|
|
23139
|
-
//
|
|
23140
|
-
// duckdb/parser/parsed_data/create_collation_info.hpp
|
|
23141
|
-
//
|
|
23142
|
-
//
|
|
23143
|
-
//===----------------------------------------------------------------------===//
|
|
23144
|
-
|
|
23145
|
-
|
|
23146
|
-
|
|
23147
|
-
|
|
23148
23510
|
|
|
23511
|
+
} // namespace duckdb
|
|
23149
23512
|
|
|
23150
|
-
namespace duckdb {
|
|
23151
|
-
|
|
23152
|
-
struct CreateCollationInfo : public CreateInfo {
|
|
23153
|
-
CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
|
|
23154
|
-
: CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
|
|
23155
|
-
not_required_for_equality(not_required_for_equality_p) {
|
|
23156
|
-
this->name = move(name_p);
|
|
23157
|
-
}
|
|
23158
23513
|
|
|
23159
|
-
//! The name of the collation
|
|
23160
|
-
string name;
|
|
23161
|
-
//! The collation function to push in case collation is required
|
|
23162
|
-
ScalarFunction function;
|
|
23163
|
-
//! Whether or not the collation can be combined with other collations.
|
|
23164
|
-
bool combinable;
|
|
23165
|
-
//! Whether or not the collation is required for equality comparisons or not. For many collations a binary
|
|
23166
|
-
//! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
|
|
23167
|
-
//! speeds up processing.
|
|
23168
|
-
bool not_required_for_equality;
|
|
23169
23514
|
|
|
23170
|
-
public:
|
|
23171
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
23172
|
-
auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
|
|
23173
|
-
CopyProperties(*result);
|
|
23174
|
-
return move(result);
|
|
23175
|
-
}
|
|
23176
|
-
};
|
|
23177
23515
|
|
|
23178
|
-
} // namespace duckdb
|
|
23179
23516
|
//===----------------------------------------------------------------------===//
|
|
23180
23517
|
// DuckDB
|
|
23181
23518
|
//
|
|
23182
|
-
// duckdb/parser/
|
|
23519
|
+
// duckdb/parser/expression/operator_expression.hpp
|
|
23183
23520
|
//
|
|
23184
23521
|
//
|
|
23185
23522
|
//===----------------------------------------------------------------------===//
|
|
@@ -23188,80 +23525,104 @@ public:
|
|
|
23188
23525
|
|
|
23189
23526
|
|
|
23190
23527
|
|
|
23191
|
-
namespace duckdb {
|
|
23192
|
-
|
|
23193
|
-
struct CreateSchemaInfo : public CreateInfo {
|
|
23194
|
-
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
23195
|
-
}
|
|
23196
|
-
|
|
23197
|
-
public:
|
|
23198
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
23199
|
-
auto result = make_unique<CreateSchemaInfo>();
|
|
23200
|
-
CopyProperties(*result);
|
|
23201
|
-
return move(result);
|
|
23202
|
-
}
|
|
23203
|
-
};
|
|
23204
|
-
|
|
23205
|
-
} // namespace duckdb
|
|
23206
|
-
//===----------------------------------------------------------------------===//
|
|
23207
|
-
// DuckDB
|
|
23208
|
-
//
|
|
23209
|
-
// duckdb/parser/parsed_data/show_select_info.hpp
|
|
23210
|
-
//
|
|
23211
|
-
//
|
|
23212
|
-
//===----------------------------------------------------------------------===//
|
|
23213
23528
|
|
|
23214
23529
|
|
|
23215
23530
|
|
|
23531
|
+
namespace duckdb {
|
|
23532
|
+
//! Represents a built-in operator expression
|
|
23533
|
+
class OperatorExpression : public ParsedExpression {
|
|
23534
|
+
public:
|
|
23535
|
+
DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
|
|
23536
|
+
unique_ptr<ParsedExpression> right = nullptr);
|
|
23537
|
+
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
23216
23538
|
|
|
23539
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
23217
23540
|
|
|
23541
|
+
public:
|
|
23542
|
+
string ToString() const override;
|
|
23218
23543
|
|
|
23219
|
-
|
|
23544
|
+
static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
|
|
23220
23545
|
|
|
23221
|
-
|
|
23222
|
-
//! Types of projected columns
|
|
23223
|
-
vector<LogicalType> types;
|
|
23224
|
-
//! The QueryNode of select query
|
|
23225
|
-
unique_ptr<QueryNode> query;
|
|
23226
|
-
//! Aliases of projected columns
|
|
23227
|
-
vector<string> aliases;
|
|
23228
|
-
//! Whether or not we are requesting a summary or a describe
|
|
23229
|
-
bool is_summary;
|
|
23546
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23230
23547
|
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
result->types = types;
|
|
23234
|
-
result->query = query->Copy();
|
|
23235
|
-
result->aliases = aliases;
|
|
23236
|
-
result->is_summary = is_summary;
|
|
23237
|
-
return result;
|
|
23238
|
-
}
|
|
23239
|
-
};
|
|
23548
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23549
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23240
23550
|
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
//
|
|
23247
|
-
|
|
23248
|
-
|
|
23551
|
+
public:
|
|
23552
|
+
template <class T, class BASE>
|
|
23553
|
+
static string ToString(const T &entry) {
|
|
23554
|
+
auto op = ExpressionTypeToOperator(entry.type);
|
|
23555
|
+
if (!op.empty()) {
|
|
23556
|
+
// use the operator string to represent the operator
|
|
23557
|
+
D_ASSERT(entry.children.size() == 2);
|
|
23558
|
+
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
23559
|
+
}
|
|
23560
|
+
switch (entry.type) {
|
|
23561
|
+
case ExpressionType::COMPARE_IN:
|
|
23562
|
+
case ExpressionType::COMPARE_NOT_IN: {
|
|
23563
|
+
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
23564
|
+
string in_child = entry.children[0]->ToString();
|
|
23565
|
+
string child_list = "(";
|
|
23566
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
23567
|
+
if (i > 1) {
|
|
23568
|
+
child_list += ", ";
|
|
23569
|
+
}
|
|
23570
|
+
child_list += entry.children[i]->ToString();
|
|
23571
|
+
}
|
|
23572
|
+
child_list += ")";
|
|
23573
|
+
return "(" + in_child + op_type + child_list + ")";
|
|
23574
|
+
}
|
|
23575
|
+
case ExpressionType::OPERATOR_NOT:
|
|
23576
|
+
case ExpressionType::GROUPING_FUNCTION:
|
|
23577
|
+
case ExpressionType::OPERATOR_COALESCE: {
|
|
23578
|
+
string result = ExpressionTypeToString(entry.type);
|
|
23579
|
+
result += "(";
|
|
23580
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
23581
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
23582
|
+
result += ")";
|
|
23583
|
+
return result;
|
|
23584
|
+
}
|
|
23585
|
+
case ExpressionType::OPERATOR_IS_NULL:
|
|
23586
|
+
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
23587
|
+
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
23588
|
+
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
23589
|
+
case ExpressionType::ARRAY_EXTRACT:
|
|
23590
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
23591
|
+
case ExpressionType::ARRAY_SLICE:
|
|
23592
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
23593
|
+
entry.children[2]->ToString() + "]";
|
|
23594
|
+
case ExpressionType::STRUCT_EXTRACT: {
|
|
23595
|
+
D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
|
|
23596
|
+
auto child_string = entry.children[1]->ToString();
|
|
23597
|
+
D_ASSERT(child_string.size() >= 3);
|
|
23598
|
+
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
23599
|
+
return "(" + entry.children[0]->ToString() + ")." +
|
|
23600
|
+
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
23601
|
+
}
|
|
23602
|
+
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
23603
|
+
string result = "(ARRAY[";
|
|
23604
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
23605
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
23606
|
+
result += "])";
|
|
23607
|
+
return result;
|
|
23608
|
+
}
|
|
23609
|
+
default:
|
|
23610
|
+
throw InternalException("Unrecognized operator type");
|
|
23611
|
+
}
|
|
23612
|
+
}
|
|
23613
|
+
};
|
|
23249
23614
|
|
|
23615
|
+
} // namespace duckdb
|
|
23250
23616
|
|
|
23251
23617
|
|
|
23252
23618
|
|
|
23253
23619
|
|
|
23254
|
-
namespace duckdb {
|
|
23255
23620
|
|
|
23256
|
-
struct VacuumInfo : public ParseInfo {
|
|
23257
|
-
// nothing for now
|
|
23258
|
-
};
|
|
23259
23621
|
|
|
23260
|
-
} // namespace duckdb
|
|
23261
23622
|
//===----------------------------------------------------------------------===//
|
|
23262
23623
|
// DuckDB
|
|
23263
23624
|
//
|
|
23264
|
-
// duckdb/parser/parsed_data/
|
|
23625
|
+
// duckdb/parser/parsed_data/create_view_info.hpp
|
|
23265
23626
|
//
|
|
23266
23627
|
//
|
|
23267
23628
|
//===----------------------------------------------------------------------===//
|
|
@@ -23271,10 +23632,40 @@ struct VacuumInfo : public ParseInfo {
|
|
|
23271
23632
|
|
|
23272
23633
|
|
|
23273
23634
|
|
|
23635
|
+
namespace duckdb {
|
|
23636
|
+
|
|
23637
|
+
struct CreateViewInfo : public CreateInfo {
|
|
23638
|
+
CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
|
|
23639
|
+
}
|
|
23640
|
+
CreateViewInfo(string schema, string view_name)
|
|
23641
|
+
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
23642
|
+
}
|
|
23643
|
+
|
|
23644
|
+
//! Table name to insert to
|
|
23645
|
+
string view_name;
|
|
23646
|
+
//! Aliases of the view
|
|
23647
|
+
vector<string> aliases;
|
|
23648
|
+
//! Return types
|
|
23649
|
+
vector<LogicalType> types;
|
|
23650
|
+
//! The SelectStatement of the view
|
|
23651
|
+
unique_ptr<SelectStatement> query;
|
|
23652
|
+
|
|
23653
|
+
public:
|
|
23654
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23655
|
+
auto result = make_unique<CreateViewInfo>(schema, view_name);
|
|
23656
|
+
CopyProperties(*result);
|
|
23657
|
+
result->aliases = aliases;
|
|
23658
|
+
result->types = types;
|
|
23659
|
+
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23660
|
+
return move(result);
|
|
23661
|
+
}
|
|
23662
|
+
};
|
|
23663
|
+
|
|
23664
|
+
} // namespace duckdb
|
|
23274
23665
|
//===----------------------------------------------------------------------===//
|
|
23275
23666
|
// DuckDB
|
|
23276
23667
|
//
|
|
23277
|
-
// duckdb/parser/
|
|
23668
|
+
// duckdb/parser/parsed_data/transaction_info.hpp
|
|
23278
23669
|
//
|
|
23279
23670
|
//
|
|
23280
23671
|
//===----------------------------------------------------------------------===//
|
|
@@ -23283,64 +23674,54 @@ struct VacuumInfo : public ParseInfo {
|
|
|
23283
23674
|
|
|
23284
23675
|
|
|
23285
23676
|
|
|
23286
|
-
|
|
23287
23677
|
namespace duckdb {
|
|
23288
|
-
//! Represents a TableReference to a base table in the schema
|
|
23289
|
-
class BaseTableRef : public TableRef {
|
|
23290
|
-
public:
|
|
23291
|
-
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
23292
|
-
}
|
|
23293
|
-
|
|
23294
|
-
//! Schema name
|
|
23295
|
-
string schema_name;
|
|
23296
|
-
//! Table name
|
|
23297
|
-
string table_name;
|
|
23298
|
-
//! Aliases for the column names
|
|
23299
|
-
vector<string> column_name_alias;
|
|
23300
23678
|
|
|
23301
|
-
|
|
23302
|
-
string ToString() const override;
|
|
23303
|
-
bool Equals(const TableRef *other_p) const override;
|
|
23679
|
+
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
23304
23680
|
|
|
23305
|
-
|
|
23681
|
+
struct TransactionInfo : public ParseInfo {
|
|
23682
|
+
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23683
|
+
}
|
|
23306
23684
|
|
|
23307
|
-
//!
|
|
23308
|
-
|
|
23309
|
-
//! Deserializes a blob back into a BaseTableRef
|
|
23310
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23685
|
+
//! The type of transaction statement
|
|
23686
|
+
TransactionType type;
|
|
23311
23687
|
};
|
|
23688
|
+
|
|
23312
23689
|
} // namespace duckdb
|
|
23690
|
+
//===----------------------------------------------------------------------===//
|
|
23691
|
+
// DuckDB
|
|
23692
|
+
//
|
|
23693
|
+
// duckdb/parser/parsed_data/create_pragma_function_info.hpp
|
|
23694
|
+
//
|
|
23695
|
+
//
|
|
23696
|
+
//===----------------------------------------------------------------------===//
|
|
23697
|
+
|
|
23698
|
+
|
|
23699
|
+
|
|
23313
23700
|
|
|
23314
23701
|
|
|
23315
23702
|
|
|
23316
23703
|
namespace duckdb {
|
|
23317
23704
|
|
|
23318
|
-
struct
|
|
23319
|
-
|
|
23705
|
+
struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
|
|
23706
|
+
explicit CreatePragmaFunctionInfo(PragmaFunction function)
|
|
23707
|
+
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
|
|
23708
|
+
functions.push_back(move(function));
|
|
23709
|
+
this->name = function.name;
|
|
23710
|
+
}
|
|
23711
|
+
CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
|
|
23712
|
+
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
|
|
23713
|
+
this->name = name;
|
|
23714
|
+
for (auto &function : functions) {
|
|
23715
|
+
function.name = name;
|
|
23716
|
+
}
|
|
23320
23717
|
}
|
|
23321
23718
|
|
|
23322
|
-
|
|
23323
|
-
IndexType index_type;
|
|
23324
|
-
//! Name of the Index
|
|
23325
|
-
string index_name;
|
|
23326
|
-
//! If it is an unique index
|
|
23327
|
-
bool unique = false;
|
|
23328
|
-
//! The table to create the index on
|
|
23329
|
-
unique_ptr<BaseTableRef> table;
|
|
23330
|
-
//! Set of expressions to index by
|
|
23331
|
-
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23719
|
+
vector<PragmaFunction> functions;
|
|
23332
23720
|
|
|
23333
23721
|
public:
|
|
23334
23722
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23335
|
-
auto result = make_unique<
|
|
23723
|
+
auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
|
|
23336
23724
|
CopyProperties(*result);
|
|
23337
|
-
result->index_type = index_type;
|
|
23338
|
-
result->index_name = index_name;
|
|
23339
|
-
result->unique = unique;
|
|
23340
|
-
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
23341
|
-
for (auto &expr : expressions) {
|
|
23342
|
-
result->expressions.push_back(expr->Copy());
|
|
23343
|
-
}
|
|
23344
23725
|
return move(result);
|
|
23345
23726
|
}
|
|
23346
23727
|
};
|
|
@@ -23349,7 +23730,7 @@ public:
|
|
|
23349
23730
|
//===----------------------------------------------------------------------===//
|
|
23350
23731
|
// DuckDB
|
|
23351
23732
|
//
|
|
23352
|
-
// duckdb/parser/parsed_data/
|
|
23733
|
+
// duckdb/parser/parsed_data/create_schema_info.hpp
|
|
23353
23734
|
//
|
|
23354
23735
|
//
|
|
23355
23736
|
//===----------------------------------------------------------------------===//
|
|
@@ -23360,26 +23741,41 @@ public:
|
|
|
23360
23741
|
|
|
23361
23742
|
namespace duckdb {
|
|
23362
23743
|
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
struct TransactionInfo : public ParseInfo {
|
|
23366
|
-
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23744
|
+
struct CreateSchemaInfo : public CreateInfo {
|
|
23745
|
+
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
23367
23746
|
}
|
|
23368
23747
|
|
|
23369
|
-
|
|
23370
|
-
|
|
23748
|
+
public:
|
|
23749
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23750
|
+
auto result = make_unique<CreateSchemaInfo>();
|
|
23751
|
+
CopyProperties(*result);
|
|
23752
|
+
return move(result);
|
|
23753
|
+
}
|
|
23371
23754
|
};
|
|
23372
23755
|
|
|
23373
23756
|
} // namespace duckdb
|
|
23374
23757
|
//===----------------------------------------------------------------------===//
|
|
23375
23758
|
// DuckDB
|
|
23376
23759
|
//
|
|
23377
|
-
// duckdb/parser/parsed_data/
|
|
23760
|
+
// duckdb/parser/parsed_data/create_macro_info.hpp
|
|
23761
|
+
//
|
|
23762
|
+
//
|
|
23763
|
+
//===----------------------------------------------------------------------===//
|
|
23764
|
+
|
|
23765
|
+
|
|
23766
|
+
|
|
23767
|
+
|
|
23768
|
+
//===----------------------------------------------------------------------===//
|
|
23769
|
+
// DuckDB
|
|
23770
|
+
//
|
|
23771
|
+
// duckdb/function/macro_function.hpp
|
|
23378
23772
|
//
|
|
23379
23773
|
//
|
|
23380
23774
|
//===----------------------------------------------------------------------===//
|
|
23381
23775
|
|
|
23382
23776
|
|
|
23777
|
+
//! The SelectStatement of the view
|
|
23778
|
+
|
|
23383
23779
|
|
|
23384
23780
|
|
|
23385
23781
|
|
|
@@ -23388,22 +23784,55 @@ struct TransactionInfo : public ParseInfo {
|
|
|
23388
23784
|
|
|
23389
23785
|
namespace duckdb {
|
|
23390
23786
|
|
|
23391
|
-
|
|
23787
|
+
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
23392
23788
|
|
|
23393
|
-
|
|
23789
|
+
class MacroFunction {
|
|
23790
|
+
public:
|
|
23791
|
+
// explicit MacroFunction(unique_ptr<ParsedExpression> expression);
|
|
23792
|
+
MacroFunction(MacroType type);
|
|
23793
|
+
|
|
23794
|
+
// MacroFunction(void);
|
|
23795
|
+
// The type
|
|
23796
|
+
MacroType type;
|
|
23797
|
+
//! The positional parameters
|
|
23798
|
+
vector<unique_ptr<ParsedExpression>> parameters;
|
|
23799
|
+
//! The default parameters and their associated values
|
|
23800
|
+
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
23801
|
+
|
|
23802
|
+
public:
|
|
23803
|
+
virtual ~MacroFunction() {
|
|
23394
23804
|
}
|
|
23395
23805
|
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23806
|
+
void CopyProperties(MacroFunction &other);
|
|
23807
|
+
|
|
23808
|
+
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
23809
|
+
|
|
23810
|
+
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
23811
|
+
FunctionExpression &function_expr,
|
|
23812
|
+
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
23813
|
+
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
23814
|
+
};
|
|
23815
|
+
|
|
23816
|
+
} // namespace duckdb
|
|
23817
|
+
|
|
23818
|
+
|
|
23819
|
+
namespace duckdb {
|
|
23820
|
+
|
|
23821
|
+
struct CreateMacroInfo : public CreateFunctionInfo {
|
|
23822
|
+
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
23823
|
+
}
|
|
23824
|
+
|
|
23825
|
+
CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
|
|
23826
|
+
}
|
|
23827
|
+
|
|
23828
|
+
unique_ptr<MacroFunction> function;
|
|
23400
23829
|
|
|
23401
23830
|
public:
|
|
23402
23831
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23403
|
-
auto result = make_unique<
|
|
23404
|
-
|
|
23832
|
+
auto result = make_unique<CreateMacroInfo>();
|
|
23833
|
+
result->function = function->Copy();
|
|
23405
23834
|
result->name = name;
|
|
23406
|
-
result
|
|
23835
|
+
CopyProperties(*result);
|
|
23407
23836
|
return move(result);
|
|
23408
23837
|
}
|
|
23409
23838
|
};
|
|
@@ -23412,7 +23841,7 @@ public:
|
|
|
23412
23841
|
//===----------------------------------------------------------------------===//
|
|
23413
23842
|
// DuckDB
|
|
23414
23843
|
//
|
|
23415
|
-
// duckdb/parser/parsed_data/
|
|
23844
|
+
// duckdb/parser/parsed_data/create_aggregate_function_info.hpp
|
|
23416
23845
|
//
|
|
23417
23846
|
//
|
|
23418
23847
|
//===----------------------------------------------------------------------===//
|
|
@@ -23424,29 +23853,27 @@ public:
|
|
|
23424
23853
|
|
|
23425
23854
|
namespace duckdb {
|
|
23426
23855
|
|
|
23427
|
-
struct
|
|
23428
|
-
|
|
23856
|
+
struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
|
|
23857
|
+
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
23858
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
23859
|
+
this->name = function.name;
|
|
23860
|
+
functions.AddFunction(move(function));
|
|
23429
23861
|
}
|
|
23430
|
-
|
|
23431
|
-
|
|
23862
|
+
|
|
23863
|
+
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
23864
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
23865
|
+
this->name = functions.name;
|
|
23866
|
+
for (auto &func : functions.functions) {
|
|
23867
|
+
func.name = functions.name;
|
|
23868
|
+
}
|
|
23432
23869
|
}
|
|
23433
23870
|
|
|
23434
|
-
|
|
23435
|
-
string view_name;
|
|
23436
|
-
//! Aliases of the view
|
|
23437
|
-
vector<string> aliases;
|
|
23438
|
-
//! Return types
|
|
23439
|
-
vector<LogicalType> types;
|
|
23440
|
-
//! The SelectStatement of the view
|
|
23441
|
-
unique_ptr<SelectStatement> query;
|
|
23871
|
+
AggregateFunctionSet functions;
|
|
23442
23872
|
|
|
23443
23873
|
public:
|
|
23444
23874
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23445
|
-
auto result = make_unique<
|
|
23875
|
+
auto result = make_unique<CreateAggregateFunctionInfo>(functions);
|
|
23446
23876
|
CopyProperties(*result);
|
|
23447
|
-
result->aliases = aliases;
|
|
23448
|
-
result->types = types;
|
|
23449
|
-
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
23450
23877
|
return move(result);
|
|
23451
23878
|
}
|
|
23452
23879
|
};
|
|
@@ -23455,7 +23882,7 @@ public:
|
|
|
23455
23882
|
//===----------------------------------------------------------------------===//
|
|
23456
23883
|
// DuckDB
|
|
23457
23884
|
//
|
|
23458
|
-
// duckdb/parser/parsed_data/
|
|
23885
|
+
// duckdb/parser/parsed_data/show_select_info.hpp
|
|
23459
23886
|
//
|
|
23460
23887
|
//
|
|
23461
23888
|
//===----------------------------------------------------------------------===//
|
|
@@ -23463,74 +23890,194 @@ public:
|
|
|
23463
23890
|
|
|
23464
23891
|
|
|
23465
23892
|
|
|
23893
|
+
|
|
23894
|
+
|
|
23895
|
+
namespace duckdb {
|
|
23896
|
+
|
|
23897
|
+
struct ShowSelectInfo : public ParseInfo {
|
|
23898
|
+
//! Types of projected columns
|
|
23899
|
+
vector<LogicalType> types;
|
|
23900
|
+
//! The QueryNode of select query
|
|
23901
|
+
unique_ptr<QueryNode> query;
|
|
23902
|
+
//! Aliases of projected columns
|
|
23903
|
+
vector<string> aliases;
|
|
23904
|
+
//! Whether or not we are requesting a summary or a describe
|
|
23905
|
+
bool is_summary;
|
|
23906
|
+
|
|
23907
|
+
unique_ptr<ShowSelectInfo> Copy() {
|
|
23908
|
+
auto result = make_unique<ShowSelectInfo>();
|
|
23909
|
+
result->types = types;
|
|
23910
|
+
result->query = query->Copy();
|
|
23911
|
+
result->aliases = aliases;
|
|
23912
|
+
result->is_summary = is_summary;
|
|
23913
|
+
return result;
|
|
23914
|
+
}
|
|
23915
|
+
};
|
|
23916
|
+
|
|
23917
|
+
} // namespace duckdb
|
|
23466
23918
|
//===----------------------------------------------------------------------===//
|
|
23467
23919
|
// DuckDB
|
|
23468
23920
|
//
|
|
23469
|
-
// duckdb/
|
|
23921
|
+
// duckdb/parser/parsed_data/export_table_data.hpp
|
|
23470
23922
|
//
|
|
23471
23923
|
//
|
|
23472
23924
|
//===----------------------------------------------------------------------===//
|
|
23473
23925
|
|
|
23474
23926
|
|
|
23475
|
-
//! The SelectStatement of the view
|
|
23476
23927
|
|
|
23477
23928
|
|
|
23478
23929
|
|
|
23479
23930
|
|
|
23931
|
+
namespace duckdb {
|
|
23932
|
+
|
|
23933
|
+
struct ExportedTableData {
|
|
23934
|
+
//! Name of the exported table
|
|
23935
|
+
string table_name;
|
|
23936
|
+
|
|
23937
|
+
//! Name of the schema
|
|
23938
|
+
string schema_name;
|
|
23939
|
+
|
|
23940
|
+
//! Path to be exported
|
|
23941
|
+
string file_path;
|
|
23942
|
+
};
|
|
23943
|
+
|
|
23944
|
+
struct ExportedTableInfo {
|
|
23945
|
+
TableCatalogEntry *entry;
|
|
23946
|
+
ExportedTableData table_data;
|
|
23947
|
+
};
|
|
23948
|
+
|
|
23949
|
+
struct BoundExportData : public ParseInfo {
|
|
23950
|
+
std::vector<ExportedTableInfo> data;
|
|
23951
|
+
};
|
|
23952
|
+
|
|
23953
|
+
} // namespace duckdb
|
|
23954
|
+
//===----------------------------------------------------------------------===//
|
|
23955
|
+
// DuckDB
|
|
23956
|
+
//
|
|
23957
|
+
// duckdb/parser/parsed_data/drop_info.hpp
|
|
23958
|
+
//
|
|
23959
|
+
//
|
|
23960
|
+
//===----------------------------------------------------------------------===//
|
|
23961
|
+
|
|
23962
|
+
|
|
23963
|
+
|
|
23480
23964
|
|
|
23481
23965
|
|
|
23482
23966
|
|
|
23483
23967
|
namespace duckdb {
|
|
23484
23968
|
|
|
23485
|
-
|
|
23969
|
+
struct DropInfo : public ParseInfo {
|
|
23970
|
+
DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
|
|
23971
|
+
}
|
|
23972
|
+
|
|
23973
|
+
//! The catalog type to drop
|
|
23974
|
+
CatalogType type;
|
|
23975
|
+
//! Schema name to drop from, if any
|
|
23976
|
+
string schema;
|
|
23977
|
+
//! Element name to drop
|
|
23978
|
+
string name;
|
|
23979
|
+
//! Ignore if the entry does not exist instead of failing
|
|
23980
|
+
bool if_exists = false;
|
|
23981
|
+
//! Cascade drop (drop all dependents instead of throwing an error if there
|
|
23982
|
+
//! are any)
|
|
23983
|
+
bool cascade = false;
|
|
23486
23984
|
|
|
23487
|
-
class MacroFunction {
|
|
23488
23985
|
public:
|
|
23489
|
-
|
|
23490
|
-
|
|
23986
|
+
unique_ptr<DropInfo> Copy() const {
|
|
23987
|
+
auto result = make_unique<DropInfo>();
|
|
23988
|
+
result->type = type;
|
|
23989
|
+
result->schema = schema;
|
|
23990
|
+
result->name = name;
|
|
23991
|
+
result->if_exists = if_exists;
|
|
23992
|
+
result->cascade = cascade;
|
|
23993
|
+
return result;
|
|
23994
|
+
}
|
|
23995
|
+
};
|
|
23491
23996
|
|
|
23492
|
-
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23498
|
-
|
|
23997
|
+
} // namespace duckdb
|
|
23998
|
+
//===----------------------------------------------------------------------===//
|
|
23999
|
+
// DuckDB
|
|
24000
|
+
//
|
|
24001
|
+
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
24002
|
+
//
|
|
24003
|
+
//
|
|
24004
|
+
//===----------------------------------------------------------------------===//
|
|
24005
|
+
|
|
24006
|
+
|
|
24007
|
+
|
|
24008
|
+
|
|
24009
|
+
|
|
24010
|
+
|
|
24011
|
+
//===----------------------------------------------------------------------===//
|
|
24012
|
+
// DuckDB
|
|
24013
|
+
//
|
|
24014
|
+
// duckdb/parser/tableref/basetableref.hpp
|
|
24015
|
+
//
|
|
24016
|
+
//
|
|
24017
|
+
//===----------------------------------------------------------------------===//
|
|
23499
24018
|
|
|
24019
|
+
|
|
24020
|
+
|
|
24021
|
+
|
|
24022
|
+
|
|
24023
|
+
|
|
24024
|
+
namespace duckdb {
|
|
24025
|
+
//! Represents a TableReference to a base table in the schema
|
|
24026
|
+
class BaseTableRef : public TableRef {
|
|
23500
24027
|
public:
|
|
23501
|
-
|
|
24028
|
+
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
23502
24029
|
}
|
|
23503
24030
|
|
|
23504
|
-
|
|
24031
|
+
//! Schema name
|
|
24032
|
+
string schema_name;
|
|
24033
|
+
//! Table name
|
|
24034
|
+
string table_name;
|
|
24035
|
+
//! Aliases for the column names
|
|
24036
|
+
vector<string> column_name_alias;
|
|
23505
24037
|
|
|
23506
|
-
|
|
24038
|
+
public:
|
|
24039
|
+
string ToString() const override;
|
|
24040
|
+
bool Equals(const TableRef *other_p) const override;
|
|
23507
24041
|
|
|
23508
|
-
|
|
23509
|
-
FunctionExpression &function_expr,
|
|
23510
|
-
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
23511
|
-
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
23512
|
-
};
|
|
24042
|
+
unique_ptr<TableRef> Copy() override;
|
|
23513
24043
|
|
|
24044
|
+
//! Serializes a blob into a BaseTableRef
|
|
24045
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
24046
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
24047
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24048
|
+
};
|
|
23514
24049
|
} // namespace duckdb
|
|
23515
24050
|
|
|
23516
24051
|
|
|
23517
|
-
namespace duckdb {
|
|
23518
24052
|
|
|
23519
|
-
|
|
23520
|
-
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
23521
|
-
}
|
|
24053
|
+
namespace duckdb {
|
|
23522
24054
|
|
|
23523
|
-
|
|
24055
|
+
struct CreateIndexInfo : public CreateInfo {
|
|
24056
|
+
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
23524
24057
|
}
|
|
23525
24058
|
|
|
23526
|
-
|
|
24059
|
+
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
24060
|
+
IndexType index_type;
|
|
24061
|
+
//! Name of the Index
|
|
24062
|
+
string index_name;
|
|
24063
|
+
//! If it is an unique index
|
|
24064
|
+
bool unique = false;
|
|
24065
|
+
//! The table to create the index on
|
|
24066
|
+
unique_ptr<BaseTableRef> table;
|
|
24067
|
+
//! Set of expressions to index by
|
|
24068
|
+
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23527
24069
|
|
|
23528
24070
|
public:
|
|
23529
24071
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23530
|
-
auto result = make_unique<
|
|
23531
|
-
result->function = function->Copy();
|
|
23532
|
-
result->name = name;
|
|
24072
|
+
auto result = make_unique<CreateIndexInfo>();
|
|
23533
24073
|
CopyProperties(*result);
|
|
24074
|
+
result->index_type = index_type;
|
|
24075
|
+
result->index_name = index_name;
|
|
24076
|
+
result->unique = unique;
|
|
24077
|
+
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
24078
|
+
for (auto &expr : expressions) {
|
|
24079
|
+
result->expressions.push_back(expr->Copy());
|
|
24080
|
+
}
|
|
23534
24081
|
return move(result);
|
|
23535
24082
|
}
|
|
23536
24083
|
};
|
|
@@ -23539,7 +24086,7 @@ public:
|
|
|
23539
24086
|
//===----------------------------------------------------------------------===//
|
|
23540
24087
|
// DuckDB
|
|
23541
24088
|
//
|
|
23542
|
-
// duckdb/parser/parsed_data/
|
|
24089
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23543
24090
|
//
|
|
23544
24091
|
//
|
|
23545
24092
|
//===----------------------------------------------------------------------===//
|
|
@@ -23548,34 +24095,17 @@ public:
|
|
|
23548
24095
|
|
|
23549
24096
|
|
|
23550
24097
|
|
|
23551
|
-
|
|
23552
24098
|
namespace duckdb {
|
|
23553
24099
|
|
|
23554
|
-
struct
|
|
23555
|
-
|
|
23556
|
-
string table_name;
|
|
23557
|
-
|
|
23558
|
-
//! Name of the schema
|
|
23559
|
-
string schema_name;
|
|
23560
|
-
|
|
23561
|
-
//! Path to be exported
|
|
23562
|
-
string file_path;
|
|
23563
|
-
};
|
|
23564
|
-
|
|
23565
|
-
struct ExportedTableInfo {
|
|
23566
|
-
TableCatalogEntry *entry;
|
|
23567
|
-
ExportedTableData table_data;
|
|
23568
|
-
};
|
|
23569
|
-
|
|
23570
|
-
struct BoundExportData : public ParseInfo {
|
|
23571
|
-
std::vector<ExportedTableInfo> data;
|
|
24100
|
+
struct VacuumInfo : public ParseInfo {
|
|
24101
|
+
// nothing for now
|
|
23572
24102
|
};
|
|
23573
24103
|
|
|
23574
24104
|
} // namespace duckdb
|
|
23575
24105
|
//===----------------------------------------------------------------------===//
|
|
23576
24106
|
// DuckDB
|
|
23577
24107
|
//
|
|
23578
|
-
// duckdb/parser/parsed_data/
|
|
24108
|
+
// duckdb/parser/parsed_data/create_collation_info.hpp
|
|
23579
24109
|
//
|
|
23580
24110
|
//
|
|
23581
24111
|
//===----------------------------------------------------------------------===//
|
|
@@ -23584,20 +24114,32 @@ struct BoundExportData : public ParseInfo {
|
|
|
23584
24114
|
|
|
23585
24115
|
|
|
23586
24116
|
|
|
24117
|
+
|
|
23587
24118
|
namespace duckdb {
|
|
23588
24119
|
|
|
23589
|
-
|
|
24120
|
+
struct CreateCollationInfo : public CreateInfo {
|
|
24121
|
+
CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
|
|
24122
|
+
: CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
|
|
24123
|
+
not_required_for_equality(not_required_for_equality_p) {
|
|
24124
|
+
this->name = move(name_p);
|
|
24125
|
+
}
|
|
23590
24126
|
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
24127
|
+
//! The name of the collation
|
|
24128
|
+
string name;
|
|
24129
|
+
//! The collation function to push in case collation is required
|
|
24130
|
+
ScalarFunction function;
|
|
24131
|
+
//! Whether or not the collation can be combined with other collations.
|
|
24132
|
+
bool combinable;
|
|
24133
|
+
//! Whether or not the collation is required for equality comparisons or not. For many collations a binary
|
|
24134
|
+
//! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
|
|
24135
|
+
//! speeds up processing.
|
|
24136
|
+
bool not_required_for_equality;
|
|
23594
24137
|
|
|
23595
24138
|
public:
|
|
23596
|
-
unique_ptr<
|
|
23597
|
-
auto result = make_unique<
|
|
23598
|
-
result
|
|
23599
|
-
result
|
|
23600
|
-
return result;
|
|
24139
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
24140
|
+
auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
|
|
24141
|
+
CopyProperties(*result);
|
|
24142
|
+
return move(result);
|
|
23601
24143
|
}
|
|
23602
24144
|
};
|
|
23603
24145
|
|
|
@@ -23605,7 +24147,7 @@ public:
|
|
|
23605
24147
|
//===----------------------------------------------------------------------===//
|
|
23606
24148
|
// DuckDB
|
|
23607
24149
|
//
|
|
23608
|
-
// duckdb/parser/parsed_data/
|
|
24150
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23609
24151
|
//
|
|
23610
24152
|
//
|
|
23611
24153
|
//===----------------------------------------------------------------------===//
|
|
@@ -23614,31 +24156,20 @@ public:
|
|
|
23614
24156
|
|
|
23615
24157
|
|
|
23616
24158
|
|
|
23617
|
-
|
|
23618
24159
|
namespace duckdb {
|
|
23619
24160
|
|
|
23620
|
-
|
|
23621
|
-
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
23622
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
23623
|
-
this->name = function.name;
|
|
23624
|
-
functions.AddFunction(move(function));
|
|
23625
|
-
}
|
|
23626
|
-
|
|
23627
|
-
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
23628
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
23629
|
-
this->name = functions.name;
|
|
23630
|
-
for (auto &func : functions.functions) {
|
|
23631
|
-
func.name = functions.name;
|
|
23632
|
-
}
|
|
23633
|
-
}
|
|
24161
|
+
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
23634
24162
|
|
|
23635
|
-
|
|
24163
|
+
struct LoadInfo : public ParseInfo {
|
|
24164
|
+
std::string filename;
|
|
24165
|
+
LoadType load_type;
|
|
23636
24166
|
|
|
23637
24167
|
public:
|
|
23638
|
-
unique_ptr<
|
|
23639
|
-
auto result = make_unique<
|
|
23640
|
-
|
|
23641
|
-
|
|
24168
|
+
unique_ptr<LoadInfo> Copy() const {
|
|
24169
|
+
auto result = make_unique<LoadInfo>();
|
|
24170
|
+
result->filename = filename;
|
|
24171
|
+
result->load_type = load_type;
|
|
24172
|
+
return result;
|
|
23642
24173
|
}
|
|
23643
24174
|
};
|
|
23644
24175
|
|
|
@@ -23646,7 +24177,7 @@ public:
|
|
|
23646
24177
|
//===----------------------------------------------------------------------===//
|
|
23647
24178
|
// DuckDB
|
|
23648
24179
|
//
|
|
23649
|
-
// duckdb/parser/parsed_data/
|
|
24180
|
+
// duckdb/parser/parsed_data/create_type_info.hpp
|
|
23650
24181
|
//
|
|
23651
24182
|
//
|
|
23652
24183
|
//===----------------------------------------------------------------------===//
|
|
@@ -23656,33 +24187,27 @@ public:
|
|
|
23656
24187
|
|
|
23657
24188
|
|
|
23658
24189
|
|
|
24190
|
+
|
|
24191
|
+
|
|
23659
24192
|
namespace duckdb {
|
|
23660
24193
|
|
|
23661
|
-
struct
|
|
23662
|
-
|
|
24194
|
+
struct CreateTypeInfo : public CreateInfo {
|
|
24195
|
+
|
|
24196
|
+
CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
|
|
23663
24197
|
}
|
|
23664
24198
|
|
|
23665
|
-
//!
|
|
23666
|
-
CatalogType type;
|
|
23667
|
-
//! Schema name to drop from, if any
|
|
23668
|
-
string schema;
|
|
23669
|
-
//! Element name to drop
|
|
24199
|
+
//! Name of the Type
|
|
23670
24200
|
string name;
|
|
23671
|
-
//!
|
|
23672
|
-
|
|
23673
|
-
//! Cascade drop (drop all dependents instead of throwing an error if there
|
|
23674
|
-
//! are any)
|
|
23675
|
-
bool cascade = false;
|
|
24201
|
+
//! Logical Type
|
|
24202
|
+
LogicalType type;
|
|
23676
24203
|
|
|
23677
24204
|
public:
|
|
23678
|
-
unique_ptr<
|
|
23679
|
-
auto result = make_unique<
|
|
23680
|
-
result
|
|
23681
|
-
result->schema = schema;
|
|
24205
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
24206
|
+
auto result = make_unique<CreateTypeInfo>();
|
|
24207
|
+
CopyProperties(*result);
|
|
23682
24208
|
result->name = name;
|
|
23683
|
-
result->
|
|
23684
|
-
result
|
|
23685
|
-
return result;
|
|
24209
|
+
result->type = type;
|
|
24210
|
+
return move(result);
|
|
23686
24211
|
}
|
|
23687
24212
|
};
|
|
23688
24213
|
|
|
@@ -23690,7 +24215,7 @@ public:
|
|
|
23690
24215
|
//===----------------------------------------------------------------------===//
|
|
23691
24216
|
// DuckDB
|
|
23692
24217
|
//
|
|
23693
|
-
// duckdb/parser/
|
|
24218
|
+
// duckdb/parser/tableref/subqueryref.hpp
|
|
23694
24219
|
//
|
|
23695
24220
|
//
|
|
23696
24221
|
//===----------------------------------------------------------------------===//
|
|
@@ -23701,31 +24226,27 @@ public:
|
|
|
23701
24226
|
|
|
23702
24227
|
|
|
23703
24228
|
namespace duckdb {
|
|
24229
|
+
//! Represents a subquery
|
|
24230
|
+
class SubqueryRef : public TableRef {
|
|
24231
|
+
public:
|
|
24232
|
+
explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
23704
24233
|
|
|
23705
|
-
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
|
|
23709
|
-
this->name = function.name;
|
|
23710
|
-
}
|
|
23711
|
-
CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
|
|
23712
|
-
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
|
|
23713
|
-
this->name = name;
|
|
23714
|
-
for (auto &function : functions) {
|
|
23715
|
-
function.name = name;
|
|
23716
|
-
}
|
|
23717
|
-
}
|
|
23718
|
-
|
|
23719
|
-
vector<PragmaFunction> functions;
|
|
24234
|
+
//! The subquery
|
|
24235
|
+
unique_ptr<SelectStatement> subquery;
|
|
24236
|
+
//! Aliases for the column names
|
|
24237
|
+
vector<string> column_name_alias;
|
|
23720
24238
|
|
|
23721
24239
|
public:
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
|
|
23725
|
-
|
|
23726
|
-
}
|
|
23727
|
-
};
|
|
24240
|
+
string ToString() const override;
|
|
24241
|
+
bool Equals(const TableRef *other_p) const override;
|
|
24242
|
+
|
|
24243
|
+
unique_ptr<TableRef> Copy() override;
|
|
23728
24244
|
|
|
24245
|
+
//! Serializes a blob into a SubqueryRef
|
|
24246
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
24247
|
+
//! Deserializes a blob back into a SubqueryRef
|
|
24248
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24249
|
+
};
|
|
23729
24250
|
} // namespace duckdb
|
|
23730
24251
|
//===----------------------------------------------------------------------===//
|
|
23731
24252
|
// DuckDB
|
|
@@ -23757,6 +24278,7 @@ public:
|
|
|
23757
24278
|
vector<string> expected_names;
|
|
23758
24279
|
|
|
23759
24280
|
public:
|
|
24281
|
+
string ToString() const override;
|
|
23760
24282
|
bool Equals(const TableRef *other_p) const override;
|
|
23761
24283
|
|
|
23762
24284
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23793,6 +24315,7 @@ public:
|
|
|
23793
24315
|
unique_ptr<TableRef> right;
|
|
23794
24316
|
|
|
23795
24317
|
public:
|
|
24318
|
+
string ToString() const override;
|
|
23796
24319
|
bool Equals(const TableRef *other_p) const override;
|
|
23797
24320
|
|
|
23798
24321
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23824,6 +24347,7 @@ public:
|
|
|
23824
24347
|
}
|
|
23825
24348
|
|
|
23826
24349
|
public:
|
|
24350
|
+
string ToString() const override;
|
|
23827
24351
|
bool Equals(const TableRef *other_p) const override;
|
|
23828
24352
|
|
|
23829
24353
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23873,6 +24397,7 @@ public:
|
|
|
23873
24397
|
vector<string> using_columns;
|
|
23874
24398
|
|
|
23875
24399
|
public:
|
|
24400
|
+
string ToString() const override;
|
|
23876
24401
|
bool Equals(const TableRef *other_p) const override;
|
|
23877
24402
|
|
|
23878
24403
|
unique_ptr<TableRef> Copy() override;
|
|
@@ -23884,41 +24409,6 @@ public:
|
|
|
23884
24409
|
};
|
|
23885
24410
|
} // namespace duckdb
|
|
23886
24411
|
|
|
23887
|
-
//===----------------------------------------------------------------------===//
|
|
23888
|
-
// DuckDB
|
|
23889
|
-
//
|
|
23890
|
-
// duckdb/parser/tableref/subqueryref.hpp
|
|
23891
|
-
//
|
|
23892
|
-
//
|
|
23893
|
-
//===----------------------------------------------------------------------===//
|
|
23894
|
-
|
|
23895
|
-
|
|
23896
|
-
|
|
23897
|
-
|
|
23898
|
-
|
|
23899
|
-
|
|
23900
|
-
namespace duckdb {
|
|
23901
|
-
//! Represents a subquery
|
|
23902
|
-
class SubqueryRef : public TableRef {
|
|
23903
|
-
public:
|
|
23904
|
-
explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
23905
|
-
|
|
23906
|
-
//! The subquery
|
|
23907
|
-
unique_ptr<SelectStatement> subquery;
|
|
23908
|
-
//! Aliases for the column names
|
|
23909
|
-
vector<string> column_name_alias;
|
|
23910
|
-
|
|
23911
|
-
public:
|
|
23912
|
-
bool Equals(const TableRef *other_p) const override;
|
|
23913
|
-
|
|
23914
|
-
unique_ptr<TableRef> Copy() override;
|
|
23915
|
-
|
|
23916
|
-
//! Serializes a blob into a SubqueryRef
|
|
23917
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
23918
|
-
//! Deserializes a blob back into a SubqueryRef
|
|
23919
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23920
|
-
};
|
|
23921
|
-
} // namespace duckdb
|
|
23922
24412
|
|
|
23923
24413
|
//===----------------------------------------------------------------------===//
|
|
23924
24414
|
// DuckDB
|
|
@@ -23939,8 +24429,7 @@ namespace duckdb {
|
|
|
23939
24429
|
//! Represents a Table producing function
|
|
23940
24430
|
class TableFunctionRef : public TableRef {
|
|
23941
24431
|
public:
|
|
23942
|
-
TableFunctionRef()
|
|
23943
|
-
}
|
|
24432
|
+
DUCKDB_API TableFunctionRef();
|
|
23944
24433
|
|
|
23945
24434
|
unique_ptr<ParsedExpression> function;
|
|
23946
24435
|
vector<string> column_name_alias;
|