duckdb 0.4.1-dev17.0 → 0.4.1-dev182.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/Makefile +2 -2
- package/binding.gyp +8 -5
- package/lib/duckdb.js +92 -64
- package/package.json +1 -1
- package/src/connection.cpp +92 -119
- package/src/data_chunk.cpp +185 -0
- package/src/database.cpp +6 -6
- package/src/duckdb.cpp +8196 -7680
- package/src/duckdb.hpp +1359 -1300
- package/src/duckdb_node.hpp +20 -17
- package/src/parquet-amalgamation.cpp +18017 -18013
- package/src/statement.cpp +15 -12
- package/test/udf.test.js +172 -107
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.4.1-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "f0bbcabe3"
|
|
15
|
+
#define DUCKDB_VERSION "v0.4.1-dev182"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -401,6 +401,7 @@ DUCKDB_API void DuckDBAssertInternal(bool condition, const char *condition_name,
|
|
|
401
401
|
|
|
402
402
|
#endif
|
|
403
403
|
|
|
404
|
+
|
|
404
405
|
//===----------------------------------------------------------------------===//
|
|
405
406
|
// DuckDB
|
|
406
407
|
//
|
|
@@ -982,7 +983,7 @@ enum class LogicalTypeId : uint8_t {
|
|
|
982
983
|
|
|
983
984
|
HUGEINT = 50,
|
|
984
985
|
POINTER = 51,
|
|
985
|
-
HASH = 52,
|
|
986
|
+
// HASH = 52, // deprecated, uses UBIGINT instead
|
|
986
987
|
VALIDITY = 53,
|
|
987
988
|
UUID = 54,
|
|
988
989
|
|
|
@@ -1094,7 +1095,7 @@ public:
|
|
|
1094
1095
|
static constexpr const LogicalTypeId INTERVAL = LogicalTypeId::INTERVAL;
|
|
1095
1096
|
static constexpr const LogicalTypeId HUGEINT = LogicalTypeId::HUGEINT;
|
|
1096
1097
|
static constexpr const LogicalTypeId UUID = LogicalTypeId::UUID;
|
|
1097
|
-
static constexpr const LogicalTypeId HASH = LogicalTypeId::
|
|
1098
|
+
static constexpr const LogicalTypeId HASH = LogicalTypeId::UBIGINT;
|
|
1098
1099
|
static constexpr const LogicalTypeId POINTER = LogicalTypeId::POINTER;
|
|
1099
1100
|
static constexpr const LogicalTypeId TABLE = LogicalTypeId::TABLE;
|
|
1100
1101
|
static constexpr const LogicalTypeId INVALID = LogicalTypeId::INVALID;
|
|
@@ -1123,6 +1124,7 @@ public:
|
|
|
1123
1124
|
struct DecimalType {
|
|
1124
1125
|
DUCKDB_API static uint8_t GetWidth(const LogicalType &type);
|
|
1125
1126
|
DUCKDB_API static uint8_t GetScale(const LogicalType &type);
|
|
1127
|
+
DUCKDB_API static uint8_t MaxWidth();
|
|
1126
1128
|
};
|
|
1127
1129
|
|
|
1128
1130
|
struct StringType {
|
|
@@ -1982,7 +1984,7 @@ public:
|
|
|
1982
1984
|
DUCKDB_API static string GetWorkingDirectory();
|
|
1983
1985
|
//! Gets the users home directory
|
|
1984
1986
|
DUCKDB_API static string GetHomeDirectory();
|
|
1985
|
-
//! Returns the system-available memory in bytes
|
|
1987
|
+
//! Returns the system-available memory in bytes. Returns DConstants::INVALID_INDEX if the system function fails.
|
|
1986
1988
|
DUCKDB_API static idx_t GetAvailableMemory();
|
|
1987
1989
|
//! Path separator for the current file system
|
|
1988
1990
|
DUCKDB_API static string PathSeparator();
|
|
@@ -5451,7 +5453,6 @@ private:
|
|
|
5451
5453
|
|
|
5452
5454
|
|
|
5453
5455
|
|
|
5454
|
-
|
|
5455
5456
|
//===----------------------------------------------------------------------===//
|
|
5456
5457
|
// DuckDB
|
|
5457
5458
|
//
|
|
@@ -5657,6 +5658,29 @@ using named_parameter_map_t = case_insensitive_map_t<Value>;
|
|
|
5657
5658
|
} // namespace duckdb
|
|
5658
5659
|
|
|
5659
5660
|
|
|
5661
|
+
|
|
5662
|
+
//===----------------------------------------------------------------------===//
|
|
5663
|
+
// DuckDB
|
|
5664
|
+
//
|
|
5665
|
+
// duckdb/main/external_dependencies.hpp
|
|
5666
|
+
//
|
|
5667
|
+
//
|
|
5668
|
+
//===----------------------------------------------------------------------===//
|
|
5669
|
+
|
|
5670
|
+
|
|
5671
|
+
|
|
5672
|
+
namespace duckdb {
|
|
5673
|
+
|
|
5674
|
+
enum ExternalDependenciesType { PYTHON_DEPENDENCY };
|
|
5675
|
+
class ExternalDependency {
|
|
5676
|
+
public:
|
|
5677
|
+
explicit ExternalDependency(ExternalDependenciesType type_p) : type(type_p) {};
|
|
5678
|
+
virtual ~ExternalDependency() {};
|
|
5679
|
+
ExternalDependenciesType type;
|
|
5680
|
+
};
|
|
5681
|
+
|
|
5682
|
+
} // namespace duckdb
|
|
5683
|
+
|
|
5660
5684
|
//===----------------------------------------------------------------------===//
|
|
5661
5685
|
// DuckDB
|
|
5662
5686
|
//
|
|
@@ -6360,6 +6384,11 @@ struct TableFunctionData : public FunctionData {
|
|
|
6360
6384
|
DUCKDB_API bool Equals(const FunctionData &other) const override;
|
|
6361
6385
|
};
|
|
6362
6386
|
|
|
6387
|
+
struct PyTableFunctionData : public TableFunctionData {
|
|
6388
|
+
//! External dependencies of this table function
|
|
6389
|
+
unique_ptr<ExternalDependency> external_dependency;
|
|
6390
|
+
};
|
|
6391
|
+
|
|
6363
6392
|
struct FunctionParameters {
|
|
6364
6393
|
vector<Value> values;
|
|
6365
6394
|
named_parameter_map_t named_parameters;
|
|
@@ -7551,10 +7580,12 @@ public:
|
|
|
7551
7580
|
|
|
7552
7581
|
|
|
7553
7582
|
|
|
7583
|
+
|
|
7584
|
+
|
|
7554
7585
|
//===----------------------------------------------------------------------===//
|
|
7555
7586
|
// DuckDB
|
|
7556
7587
|
//
|
|
7557
|
-
// duckdb/
|
|
7588
|
+
// duckdb/storage/statistics/node_statistics.hpp
|
|
7558
7589
|
//
|
|
7559
7590
|
//
|
|
7560
7591
|
//===----------------------------------------------------------------------===//
|
|
@@ -7563,420 +7594,62 @@ public:
|
|
|
7563
7594
|
|
|
7564
7595
|
|
|
7565
7596
|
|
|
7597
|
+
namespace duckdb {
|
|
7566
7598
|
|
|
7599
|
+
class NodeStatistics {
|
|
7600
|
+
public:
|
|
7601
|
+
NodeStatistics() : has_estimated_cardinality(false), has_max_cardinality(false) {
|
|
7602
|
+
}
|
|
7603
|
+
explicit NodeStatistics(idx_t estimated_cardinality)
|
|
7604
|
+
: has_estimated_cardinality(true), estimated_cardinality(estimated_cardinality), has_max_cardinality(false) {
|
|
7605
|
+
}
|
|
7606
|
+
NodeStatistics(idx_t estimated_cardinality, idx_t max_cardinality)
|
|
7607
|
+
: has_estimated_cardinality(true), estimated_cardinality(estimated_cardinality), has_max_cardinality(true),
|
|
7608
|
+
max_cardinality(max_cardinality) {
|
|
7609
|
+
}
|
|
7567
7610
|
|
|
7611
|
+
//! Whether or not the node has an estimated cardinality specified
|
|
7612
|
+
bool has_estimated_cardinality;
|
|
7613
|
+
//! The estimated cardinality at the specified node
|
|
7614
|
+
idx_t estimated_cardinality;
|
|
7615
|
+
//! Whether or not the node has a maximum cardinality specified
|
|
7616
|
+
bool has_max_cardinality;
|
|
7617
|
+
//! The max possible cardinality at the specified node
|
|
7618
|
+
idx_t max_cardinality;
|
|
7619
|
+
};
|
|
7568
7620
|
|
|
7569
|
-
namespace duckdb
|
|
7570
|
-
struct FunctionData;
|
|
7571
|
-
typedef std::pair<idx_t, idx_t> FrameBounds;
|
|
7621
|
+
} // namespace duckdb
|
|
7572
7622
|
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
}
|
|
7623
|
+
//===----------------------------------------------------------------------===//
|
|
7624
|
+
// DuckDB
|
|
7625
|
+
//
|
|
7626
|
+
// duckdb/planner/bound_result_modifier.hpp
|
|
7627
|
+
//
|
|
7628
|
+
//
|
|
7629
|
+
//===----------------------------------------------------------------------===//
|
|
7581
7630
|
|
|
7582
|
-
template <class STATE_TYPE, class OP>
|
|
7583
|
-
static inline void NullaryScatterLoop(STATE_TYPE **__restrict states, FunctionData *bind_data,
|
|
7584
|
-
const SelectionVector &ssel, idx_t count) {
|
|
7585
7631
|
|
|
7586
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7587
|
-
auto sidx = ssel.get_index(i);
|
|
7588
|
-
OP::template Operation<STATE_TYPE, OP>(states[sidx], bind_data, sidx);
|
|
7589
|
-
}
|
|
7590
|
-
}
|
|
7591
7632
|
|
|
7592
|
-
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
7593
|
-
static inline void UnaryFlatLoop(INPUT_TYPE *__restrict idata, FunctionData *bind_data,
|
|
7594
|
-
STATE_TYPE **__restrict states, ValidityMask &mask, idx_t count) {
|
|
7595
|
-
if (!mask.AllValid()) {
|
|
7596
|
-
idx_t base_idx = 0;
|
|
7597
|
-
auto entry_count = ValidityMask::EntryCount(count);
|
|
7598
|
-
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
|
7599
|
-
auto validity_entry = mask.GetValidityEntry(entry_idx);
|
|
7600
|
-
idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
|
|
7601
|
-
if (!OP::IgnoreNull() || ValidityMask::AllValid(validity_entry)) {
|
|
7602
|
-
// all valid: perform operation
|
|
7603
|
-
for (; base_idx < next; base_idx++) {
|
|
7604
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[base_idx], bind_data, idata, mask,
|
|
7605
|
-
base_idx);
|
|
7606
|
-
}
|
|
7607
|
-
} else if (ValidityMask::NoneValid(validity_entry)) {
|
|
7608
|
-
// nothing valid: skip all
|
|
7609
|
-
base_idx = next;
|
|
7610
|
-
continue;
|
|
7611
|
-
} else {
|
|
7612
|
-
// partially valid: need to check individual elements for validity
|
|
7613
|
-
idx_t start = base_idx;
|
|
7614
|
-
for (; base_idx < next; base_idx++) {
|
|
7615
|
-
if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
|
|
7616
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[base_idx], bind_data, idata, mask,
|
|
7617
|
-
base_idx);
|
|
7618
|
-
}
|
|
7619
|
-
}
|
|
7620
|
-
}
|
|
7621
|
-
}
|
|
7622
|
-
} else {
|
|
7623
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7624
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[i], bind_data, idata, mask, i);
|
|
7625
|
-
}
|
|
7626
|
-
}
|
|
7627
|
-
}
|
|
7628
7633
|
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
auto idx = isel.get_index(i);
|
|
7637
|
-
auto sidx = ssel.get_index(i);
|
|
7638
|
-
if (mask.RowIsValid(idx)) {
|
|
7639
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[sidx], bind_data, idata, mask, idx);
|
|
7640
|
-
}
|
|
7641
|
-
}
|
|
7642
|
-
} else {
|
|
7643
|
-
// quick path: no NULL values or NULL values are not ignored
|
|
7644
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7645
|
-
auto idx = isel.get_index(i);
|
|
7646
|
-
auto sidx = ssel.get_index(i);
|
|
7647
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[sidx], bind_data, idata, mask, idx);
|
|
7648
|
-
}
|
|
7649
|
-
}
|
|
7650
|
-
}
|
|
7634
|
+
//===----------------------------------------------------------------------===//
|
|
7635
|
+
// DuckDB
|
|
7636
|
+
//
|
|
7637
|
+
// duckdb/parser/result_modifier.hpp
|
|
7638
|
+
//
|
|
7639
|
+
//
|
|
7640
|
+
//===----------------------------------------------------------------------===//
|
|
7651
7641
|
|
|
7652
|
-
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
7653
|
-
static inline void UnaryFlatUpdateLoop(INPUT_TYPE *__restrict idata, FunctionData *bind_data,
|
|
7654
|
-
STATE_TYPE *__restrict state, idx_t count, ValidityMask &mask) {
|
|
7655
|
-
idx_t base_idx = 0;
|
|
7656
|
-
auto entry_count = ValidityMask::EntryCount(count);
|
|
7657
|
-
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
|
7658
|
-
auto validity_entry = mask.GetValidityEntry(entry_idx);
|
|
7659
|
-
idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
|
|
7660
|
-
if (!OP::IgnoreNull() || ValidityMask::AllValid(validity_entry)) {
|
|
7661
|
-
// all valid: perform operation
|
|
7662
|
-
for (; base_idx < next; base_idx++) {
|
|
7663
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, bind_data, idata, mask, base_idx);
|
|
7664
|
-
}
|
|
7665
|
-
} else if (ValidityMask::NoneValid(validity_entry)) {
|
|
7666
|
-
// nothing valid: skip all
|
|
7667
|
-
base_idx = next;
|
|
7668
|
-
continue;
|
|
7669
|
-
} else {
|
|
7670
|
-
// partially valid: need to check individual elements for validity
|
|
7671
|
-
idx_t start = base_idx;
|
|
7672
|
-
for (; base_idx < next; base_idx++) {
|
|
7673
|
-
if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
|
|
7674
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, bind_data, idata, mask, base_idx);
|
|
7675
|
-
}
|
|
7676
|
-
}
|
|
7677
|
-
}
|
|
7678
|
-
}
|
|
7679
|
-
}
|
|
7680
7642
|
|
|
7681
|
-
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
7682
|
-
static inline void UnaryUpdateLoop(INPUT_TYPE *__restrict idata, FunctionData *bind_data,
|
|
7683
|
-
STATE_TYPE *__restrict state, idx_t count, ValidityMask &mask,
|
|
7684
|
-
const SelectionVector &__restrict sel_vector) {
|
|
7685
|
-
if (OP::IgnoreNull() && !mask.AllValid()) {
|
|
7686
|
-
// potential NULL values and NULL values are ignored
|
|
7687
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7688
|
-
auto idx = sel_vector.get_index(i);
|
|
7689
|
-
if (mask.RowIsValid(idx)) {
|
|
7690
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, bind_data, idata, mask, idx);
|
|
7691
|
-
}
|
|
7692
|
-
}
|
|
7693
|
-
} else {
|
|
7694
|
-
// quick path: no NULL values or NULL values are not ignored
|
|
7695
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7696
|
-
auto idx = sel_vector.get_index(i);
|
|
7697
|
-
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, bind_data, idata, mask, idx);
|
|
7698
|
-
}
|
|
7699
|
-
}
|
|
7700
|
-
}
|
|
7701
7643
|
|
|
7702
|
-
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
7703
|
-
static inline void BinaryScatterLoop(A_TYPE *__restrict adata, FunctionData *bind_data, B_TYPE *__restrict bdata,
|
|
7704
|
-
STATE_TYPE **__restrict states, idx_t count, const SelectionVector &asel,
|
|
7705
|
-
const SelectionVector &bsel, const SelectionVector &ssel,
|
|
7706
|
-
ValidityMask &avalidity, ValidityMask &bvalidity) {
|
|
7707
|
-
if (OP::IgnoreNull() && (!avalidity.AllValid() || !bvalidity.AllValid())) {
|
|
7708
|
-
// potential NULL values and NULL values are ignored
|
|
7709
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7710
|
-
auto aidx = asel.get_index(i);
|
|
7711
|
-
auto bidx = bsel.get_index(i);
|
|
7712
|
-
auto sidx = ssel.get_index(i);
|
|
7713
|
-
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx)) {
|
|
7714
|
-
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(states[sidx], bind_data, adata, bdata,
|
|
7715
|
-
avalidity, bvalidity, aidx, bidx);
|
|
7716
|
-
}
|
|
7717
|
-
}
|
|
7718
|
-
} else {
|
|
7719
|
-
// quick path: no NULL values or NULL values are not ignored
|
|
7720
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7721
|
-
auto aidx = asel.get_index(i);
|
|
7722
|
-
auto bidx = bsel.get_index(i);
|
|
7723
|
-
auto sidx = ssel.get_index(i);
|
|
7724
|
-
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(states[sidx], bind_data, adata, bdata, avalidity,
|
|
7725
|
-
bvalidity, aidx, bidx);
|
|
7726
|
-
}
|
|
7727
|
-
}
|
|
7728
|
-
}
|
|
7729
7644
|
|
|
7730
|
-
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
7731
|
-
static inline void BinaryUpdateLoop(A_TYPE *__restrict adata, FunctionData *bind_data, B_TYPE *__restrict bdata,
|
|
7732
|
-
STATE_TYPE *__restrict state, idx_t count, const SelectionVector &asel,
|
|
7733
|
-
const SelectionVector &bsel, ValidityMask &avalidity, ValidityMask &bvalidity) {
|
|
7734
|
-
if (OP::IgnoreNull() && (!avalidity.AllValid() || !bvalidity.AllValid())) {
|
|
7735
|
-
// potential NULL values and NULL values are ignored
|
|
7736
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7737
|
-
auto aidx = asel.get_index(i);
|
|
7738
|
-
auto bidx = bsel.get_index(i);
|
|
7739
|
-
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx)) {
|
|
7740
|
-
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(state, bind_data, adata, bdata, avalidity,
|
|
7741
|
-
bvalidity, aidx, bidx);
|
|
7742
|
-
}
|
|
7743
|
-
}
|
|
7744
|
-
} else {
|
|
7745
|
-
// quick path: no NULL values or NULL values are not ignored
|
|
7746
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7747
|
-
auto aidx = asel.get_index(i);
|
|
7748
|
-
auto bidx = bsel.get_index(i);
|
|
7749
|
-
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(state, bind_data, adata, bdata, avalidity,
|
|
7750
|
-
bvalidity, aidx, bidx);
|
|
7751
|
-
}
|
|
7752
|
-
}
|
|
7753
|
-
}
|
|
7754
7645
|
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
7763
|
-
NullaryFlatLoop<STATE_TYPE, OP>(sdata, bind_data, count);
|
|
7764
|
-
} else {
|
|
7765
|
-
VectorData sdata;
|
|
7766
|
-
states.Orrify(count, sdata);
|
|
7767
|
-
NullaryScatterLoop<STATE_TYPE, OP>((STATE_TYPE **)sdata.data, bind_data, *sdata.sel, count);
|
|
7768
|
-
}
|
|
7769
|
-
}
|
|
7770
|
-
|
|
7771
|
-
template <class STATE_TYPE, class OP>
|
|
7772
|
-
static void NullaryUpdate(data_ptr_t state, FunctionData *bind_data, idx_t count) {
|
|
7773
|
-
OP::template ConstantOperation<STATE_TYPE, OP>((STATE_TYPE *)state, bind_data, count);
|
|
7774
|
-
}
|
|
7775
|
-
|
|
7776
|
-
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
7777
|
-
static void UnaryScatter(Vector &input, Vector &states, FunctionData *bind_data, idx_t count) {
|
|
7778
|
-
if (input.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
7779
|
-
states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
7780
|
-
if (OP::IgnoreNull() && ConstantVector::IsNull(input)) {
|
|
7781
|
-
// constant NULL input in function that ignores NULL values
|
|
7782
|
-
return;
|
|
7783
|
-
}
|
|
7784
|
-
// regular constant: get first state
|
|
7785
|
-
auto idata = ConstantVector::GetData<INPUT_TYPE>(input);
|
|
7786
|
-
auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
|
|
7787
|
-
OP::template ConstantOperation<INPUT_TYPE, STATE_TYPE, OP>(*sdata, bind_data, idata,
|
|
7788
|
-
ConstantVector::Validity(input), count);
|
|
7789
|
-
} else if (input.GetVectorType() == VectorType::FLAT_VECTOR &&
|
|
7790
|
-
states.GetVectorType() == VectorType::FLAT_VECTOR) {
|
|
7791
|
-
auto idata = FlatVector::GetData<INPUT_TYPE>(input);
|
|
7792
|
-
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
7793
|
-
UnaryFlatLoop<STATE_TYPE, INPUT_TYPE, OP>(idata, bind_data, sdata, FlatVector::Validity(input), count);
|
|
7794
|
-
} else {
|
|
7795
|
-
VectorData idata, sdata;
|
|
7796
|
-
input.Orrify(count, idata);
|
|
7797
|
-
states.Orrify(count, sdata);
|
|
7798
|
-
UnaryScatterLoop<STATE_TYPE, INPUT_TYPE, OP>((INPUT_TYPE *)idata.data, bind_data, (STATE_TYPE **)sdata.data,
|
|
7799
|
-
*idata.sel, *sdata.sel, idata.validity, count);
|
|
7800
|
-
}
|
|
7801
|
-
}
|
|
7802
|
-
|
|
7803
|
-
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
7804
|
-
static void UnaryUpdate(Vector &input, FunctionData *bind_data, data_ptr_t state, idx_t count) {
|
|
7805
|
-
switch (input.GetVectorType()) {
|
|
7806
|
-
case VectorType::CONSTANT_VECTOR: {
|
|
7807
|
-
if (OP::IgnoreNull() && ConstantVector::IsNull(input)) {
|
|
7808
|
-
return;
|
|
7809
|
-
}
|
|
7810
|
-
auto idata = ConstantVector::GetData<INPUT_TYPE>(input);
|
|
7811
|
-
OP::template ConstantOperation<INPUT_TYPE, STATE_TYPE, OP>((STATE_TYPE *)state, bind_data, idata,
|
|
7812
|
-
ConstantVector::Validity(input), count);
|
|
7813
|
-
break;
|
|
7814
|
-
}
|
|
7815
|
-
case VectorType::FLAT_VECTOR: {
|
|
7816
|
-
auto idata = FlatVector::GetData<INPUT_TYPE>(input);
|
|
7817
|
-
UnaryFlatUpdateLoop<STATE_TYPE, INPUT_TYPE, OP>(idata, bind_data, (STATE_TYPE *)state, count,
|
|
7818
|
-
FlatVector::Validity(input));
|
|
7819
|
-
break;
|
|
7820
|
-
}
|
|
7821
|
-
default: {
|
|
7822
|
-
VectorData idata;
|
|
7823
|
-
input.Orrify(count, idata);
|
|
7824
|
-
UnaryUpdateLoop<STATE_TYPE, INPUT_TYPE, OP>((INPUT_TYPE *)idata.data, bind_data, (STATE_TYPE *)state, count,
|
|
7825
|
-
idata.validity, *idata.sel);
|
|
7826
|
-
break;
|
|
7827
|
-
}
|
|
7828
|
-
}
|
|
7829
|
-
}
|
|
7830
|
-
|
|
7831
|
-
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
7832
|
-
static void BinaryScatter(FunctionData *bind_data, Vector &a, Vector &b, Vector &states, idx_t count) {
|
|
7833
|
-
VectorData adata, bdata, sdata;
|
|
7834
|
-
|
|
7835
|
-
a.Orrify(count, adata);
|
|
7836
|
-
b.Orrify(count, bdata);
|
|
7837
|
-
states.Orrify(count, sdata);
|
|
7838
|
-
|
|
7839
|
-
BinaryScatterLoop<STATE_TYPE, A_TYPE, B_TYPE, OP>((A_TYPE *)adata.data, bind_data, (B_TYPE *)bdata.data,
|
|
7840
|
-
(STATE_TYPE **)sdata.data, count, *adata.sel, *bdata.sel,
|
|
7841
|
-
*sdata.sel, adata.validity, bdata.validity);
|
|
7842
|
-
}
|
|
7843
|
-
|
|
7844
|
-
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
7845
|
-
static void BinaryUpdate(FunctionData *bind_data, Vector &a, Vector &b, data_ptr_t state, idx_t count) {
|
|
7846
|
-
VectorData adata, bdata;
|
|
7847
|
-
|
|
7848
|
-
a.Orrify(count, adata);
|
|
7849
|
-
b.Orrify(count, bdata);
|
|
7850
|
-
|
|
7851
|
-
BinaryUpdateLoop<STATE_TYPE, A_TYPE, B_TYPE, OP>((A_TYPE *)adata.data, bind_data, (B_TYPE *)bdata.data,
|
|
7852
|
-
(STATE_TYPE *)state, count, *adata.sel, *bdata.sel,
|
|
7853
|
-
adata.validity, bdata.validity);
|
|
7854
|
-
}
|
|
7855
|
-
|
|
7856
|
-
template <class STATE_TYPE, class OP>
|
|
7857
|
-
static void Combine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
|
|
7858
|
-
D_ASSERT(source.GetType().id() == LogicalTypeId::POINTER && target.GetType().id() == LogicalTypeId::POINTER);
|
|
7859
|
-
auto sdata = FlatVector::GetData<const STATE_TYPE *>(source);
|
|
7860
|
-
auto tdata = FlatVector::GetData<STATE_TYPE *>(target);
|
|
7861
|
-
|
|
7862
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7863
|
-
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i], bind_data);
|
|
7864
|
-
}
|
|
7865
|
-
}
|
|
7866
|
-
|
|
7867
|
-
template <class STATE_TYPE, class RESULT_TYPE, class OP>
|
|
7868
|
-
static void Finalize(Vector &states, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset) {
|
|
7869
|
-
if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
7870
|
-
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
7871
|
-
|
|
7872
|
-
auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
|
|
7873
|
-
auto rdata = ConstantVector::GetData<RESULT_TYPE>(result);
|
|
7874
|
-
OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, *sdata, rdata,
|
|
7875
|
-
ConstantVector::Validity(result), 0);
|
|
7876
|
-
} else {
|
|
7877
|
-
D_ASSERT(states.GetVectorType() == VectorType::FLAT_VECTOR);
|
|
7878
|
-
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
7879
|
-
|
|
7880
|
-
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
7881
|
-
auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
|
|
7882
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7883
|
-
OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, bind_data, sdata[i], rdata,
|
|
7884
|
-
FlatVector::Validity(result), i + offset);
|
|
7885
|
-
}
|
|
7886
|
-
}
|
|
7887
|
-
}
|
|
7888
|
-
|
|
7889
|
-
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
|
7890
|
-
static void UnaryWindow(Vector &input, const ValidityMask &ifilter, FunctionData *bind_data, data_ptr_t state,
|
|
7891
|
-
const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
|
|
7892
|
-
|
|
7893
|
-
auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
|
|
7894
|
-
const auto &ivalid = FlatVector::Validity(input);
|
|
7895
|
-
OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ifilter, ivalid, bind_data, (STATE *)state, frame,
|
|
7896
|
-
prev, result, rid, bias);
|
|
7897
|
-
}
|
|
7898
|
-
|
|
7899
|
-
template <class STATE_TYPE, class OP>
|
|
7900
|
-
static void Destroy(Vector &states, idx_t count) {
|
|
7901
|
-
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
7902
|
-
for (idx_t i = 0; i < count; i++) {
|
|
7903
|
-
OP::template Destroy<STATE_TYPE>(sdata[i]);
|
|
7904
|
-
}
|
|
7905
|
-
}
|
|
7906
|
-
};
|
|
7907
|
-
|
|
7908
|
-
} // namespace duckdb
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
//===----------------------------------------------------------------------===//
|
|
7913
|
-
// DuckDB
|
|
7914
|
-
//
|
|
7915
|
-
// duckdb/storage/statistics/node_statistics.hpp
|
|
7916
|
-
//
|
|
7917
|
-
//
|
|
7918
|
-
//===----------------------------------------------------------------------===//
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
namespace duckdb {
|
|
7925
|
-
|
|
7926
|
-
class NodeStatistics {
|
|
7927
|
-
public:
|
|
7928
|
-
NodeStatistics() : has_estimated_cardinality(false), has_max_cardinality(false) {
|
|
7929
|
-
}
|
|
7930
|
-
explicit NodeStatistics(idx_t estimated_cardinality)
|
|
7931
|
-
: has_estimated_cardinality(true), estimated_cardinality(estimated_cardinality), has_max_cardinality(false) {
|
|
7932
|
-
}
|
|
7933
|
-
NodeStatistics(idx_t estimated_cardinality, idx_t max_cardinality)
|
|
7934
|
-
: has_estimated_cardinality(true), estimated_cardinality(estimated_cardinality), has_max_cardinality(true),
|
|
7935
|
-
max_cardinality(max_cardinality) {
|
|
7936
|
-
}
|
|
7937
|
-
|
|
7938
|
-
//! Whether or not the node has an estimated cardinality specified
|
|
7939
|
-
bool has_estimated_cardinality;
|
|
7940
|
-
//! The estimated cardinality at the specified node
|
|
7941
|
-
idx_t estimated_cardinality;
|
|
7942
|
-
//! Whether or not the node has a maximum cardinality specified
|
|
7943
|
-
bool has_max_cardinality;
|
|
7944
|
-
//! The max possible cardinality at the specified node
|
|
7945
|
-
idx_t max_cardinality;
|
|
7946
|
-
};
|
|
7947
|
-
|
|
7948
|
-
} // namespace duckdb
|
|
7949
|
-
|
|
7950
|
-
//===----------------------------------------------------------------------===//
|
|
7951
|
-
// DuckDB
|
|
7952
|
-
//
|
|
7953
|
-
// duckdb/planner/bound_result_modifier.hpp
|
|
7954
|
-
//
|
|
7955
|
-
//
|
|
7956
|
-
//===----------------------------------------------------------------------===//
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
//===----------------------------------------------------------------------===//
|
|
7962
|
-
// DuckDB
|
|
7963
|
-
//
|
|
7964
|
-
// duckdb/parser/result_modifier.hpp
|
|
7965
|
-
//
|
|
7966
|
-
//
|
|
7967
|
-
//===----------------------------------------------------------------------===//
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
//===----------------------------------------------------------------------===//
|
|
7974
|
-
// DuckDB
|
|
7975
|
-
//
|
|
7976
|
-
// duckdb/common/enums/order_type.hpp
|
|
7977
|
-
//
|
|
7978
|
-
//
|
|
7979
|
-
//===----------------------------------------------------------------------===//
|
|
7646
|
+
//===----------------------------------------------------------------------===//
|
|
7647
|
+
// DuckDB
|
|
7648
|
+
//
|
|
7649
|
+
// duckdb/common/enums/order_type.hpp
|
|
7650
|
+
//
|
|
7651
|
+
//
|
|
7652
|
+
//===----------------------------------------------------------------------===//
|
|
7980
7653
|
|
|
7981
7654
|
|
|
7982
7655
|
|
|
@@ -9086,102 +8759,474 @@ public:
|
|
|
9086
8759
|
} // namespace duckdb
|
|
9087
8760
|
|
|
9088
8761
|
|
|
8762
|
+
//===----------------------------------------------------------------------===//
|
|
8763
|
+
// DuckDB
|
|
8764
|
+
//
|
|
8765
|
+
// duckdb/common/vector_operations/aggregate_executor.hpp
|
|
8766
|
+
//
|
|
8767
|
+
//
|
|
8768
|
+
//===----------------------------------------------------------------------===//
|
|
8769
|
+
|
|
9089
8770
|
|
|
9090
|
-
namespace duckdb {
|
|
9091
8771
|
|
|
9092
|
-
class BoundAggregateExpression;
|
|
9093
8772
|
|
|
9094
|
-
//! The type used for sizing hashed aggregate function states
|
|
9095
|
-
typedef idx_t (*aggregate_size_t)();
|
|
9096
|
-
//! The type used for initializing hashed aggregate function states
|
|
9097
|
-
typedef void (*aggregate_initialize_t)(data_ptr_t state);
|
|
9098
|
-
//! The type used for updating hashed aggregate functions
|
|
9099
|
-
typedef void (*aggregate_update_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, Vector &state,
|
|
9100
|
-
idx_t count);
|
|
9101
|
-
//! The type used for combining hashed aggregate states
|
|
9102
|
-
typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count);
|
|
9103
|
-
//! The type used for finalizing hashed aggregate function payloads
|
|
9104
|
-
typedef void (*aggregate_finalize_t)(Vector &state, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset);
|
|
9105
|
-
//! The type used for propagating statistics in aggregate functions (optional)
|
|
9106
|
-
typedef unique_ptr<BaseStatistics> (*aggregate_statistics_t)(ClientContext &context, BoundAggregateExpression &expr,
|
|
9107
|
-
FunctionData *bind_data,
|
|
9108
|
-
vector<unique_ptr<BaseStatistics>> &child_stats,
|
|
9109
|
-
NodeStatistics *node_stats);
|
|
9110
|
-
//! Binds the scalar function and creates the function data
|
|
9111
|
-
typedef unique_ptr<FunctionData> (*bind_aggregate_function_t)(ClientContext &context, AggregateFunction &function,
|
|
9112
|
-
vector<unique_ptr<Expression>> &arguments);
|
|
9113
|
-
//! The type used for the aggregate destructor method. NOTE: this method is used in destructors and MAY NOT throw.
|
|
9114
|
-
typedef void (*aggregate_destructor_t)(Vector &state, idx_t count);
|
|
9115
8773
|
|
|
9116
|
-
//! The type used for updating simple (non-grouped) aggregate functions
|
|
9117
|
-
typedef void (*aggregate_simple_update_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
|
|
9118
|
-
idx_t count);
|
|
9119
8774
|
|
|
9120
|
-
|
|
8775
|
+
|
|
8776
|
+
namespace duckdb {
|
|
8777
|
+
|
|
8778
|
+
struct AggregateInputData;
|
|
8779
|
+
|
|
9121
8780
|
typedef std::pair<idx_t, idx_t> FrameBounds;
|
|
9122
|
-
typedef void (*aggregate_window_t)(Vector inputs[], const ValidityMask &filter_mask, FunctionData *bind_data,
|
|
9123
|
-
idx_t input_count, data_ptr_t state, const FrameBounds &frame,
|
|
9124
|
-
const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias);
|
|
9125
8781
|
|
|
9126
|
-
class
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9135
|
-
: BaseScalarFunction(name, arguments, return_type, false, LogicalType(LogicalTypeId::INVALID),
|
|
9136
|
-
propagates_null_values),
|
|
9137
|
-
state_size(state_size), initialize(initialize), update(update), combine(combine), finalize(finalize),
|
|
9138
|
-
simple_update(simple_update), window(window), bind(bind), destructor(destructor), statistics(statistics) {
|
|
8782
|
+
class AggregateExecutor {
|
|
8783
|
+
private:
|
|
8784
|
+
template <class STATE_TYPE, class OP>
|
|
8785
|
+
static inline void NullaryFlatLoop(STATE_TYPE **__restrict states, AggregateInputData &aggr_input_data,
|
|
8786
|
+
idx_t count) {
|
|
8787
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8788
|
+
OP::template Operation<STATE_TYPE, OP>(states[i], aggr_input_data, i);
|
|
8789
|
+
}
|
|
9139
8790
|
}
|
|
9140
8791
|
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
aggregate_combine_t combine, aggregate_finalize_t finalize,
|
|
9145
|
-
aggregate_simple_update_t simple_update = nullptr,
|
|
9146
|
-
bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
|
|
9147
|
-
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9148
|
-
: BaseScalarFunction(name, arguments, return_type, false, LogicalType(LogicalTypeId::INVALID), false),
|
|
9149
|
-
state_size(state_size), initialize(initialize), update(update), combine(combine), finalize(finalize),
|
|
9150
|
-
simple_update(simple_update), window(window), bind(bind), destructor(destructor), statistics(statistics) {
|
|
9151
|
-
}
|
|
8792
|
+
template <class STATE_TYPE, class OP>
|
|
8793
|
+
static inline void NullaryScatterLoop(STATE_TYPE **__restrict states, AggregateInputData &aggr_input_data,
|
|
8794
|
+
const SelectionVector &ssel, idx_t count) {
|
|
9152
8795
|
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
|
|
9158
|
-
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9159
|
-
: AggregateFunction(string(), arguments, return_type, state_size, initialize, update, combine, finalize,
|
|
9160
|
-
propagates_null_values, simple_update, bind, destructor, statistics, window) {
|
|
8796
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8797
|
+
auto sidx = ssel.get_index(i);
|
|
8798
|
+
OP::template Operation<STATE_TYPE, OP>(states[sidx], aggr_input_data, sidx);
|
|
8799
|
+
}
|
|
9161
8800
|
}
|
|
9162
8801
|
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
8802
|
+
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
8803
|
+
static inline void UnaryFlatLoop(INPUT_TYPE *__restrict idata, AggregateInputData &aggr_input_data,
|
|
8804
|
+
STATE_TYPE **__restrict states, ValidityMask &mask, idx_t count) {
|
|
8805
|
+
if (!mask.AllValid()) {
|
|
8806
|
+
idx_t base_idx = 0;
|
|
8807
|
+
auto entry_count = ValidityMask::EntryCount(count);
|
|
8808
|
+
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
|
8809
|
+
auto validity_entry = mask.GetValidityEntry(entry_idx);
|
|
8810
|
+
idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
|
|
8811
|
+
if (!OP::IgnoreNull() || ValidityMask::AllValid(validity_entry)) {
|
|
8812
|
+
// all valid: perform operation
|
|
8813
|
+
for (; base_idx < next; base_idx++) {
|
|
8814
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[base_idx], aggr_input_data, idata,
|
|
8815
|
+
mask, base_idx);
|
|
8816
|
+
}
|
|
8817
|
+
} else if (ValidityMask::NoneValid(validity_entry)) {
|
|
8818
|
+
// nothing valid: skip all
|
|
8819
|
+
base_idx = next;
|
|
8820
|
+
continue;
|
|
8821
|
+
} else {
|
|
8822
|
+
// partially valid: need to check individual elements for validity
|
|
8823
|
+
idx_t start = base_idx;
|
|
8824
|
+
for (; base_idx < next; base_idx++) {
|
|
8825
|
+
if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
|
|
8826
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[base_idx], aggr_input_data, idata,
|
|
8827
|
+
mask, base_idx);
|
|
8828
|
+
}
|
|
8829
|
+
}
|
|
8830
|
+
}
|
|
8831
|
+
}
|
|
8832
|
+
} else {
|
|
8833
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8834
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[i], aggr_input_data, idata, mask, i);
|
|
8835
|
+
}
|
|
8836
|
+
}
|
|
8837
|
+
}
|
|
8838
|
+
|
|
8839
|
+
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
8840
|
+
static inline void UnaryScatterLoop(INPUT_TYPE *__restrict idata, AggregateInputData &aggr_input_data,
|
|
8841
|
+
STATE_TYPE **__restrict states, const SelectionVector &isel,
|
|
8842
|
+
const SelectionVector &ssel, ValidityMask &mask, idx_t count) {
|
|
8843
|
+
if (OP::IgnoreNull() && !mask.AllValid()) {
|
|
8844
|
+
// potential NULL values and NULL values are ignored
|
|
8845
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8846
|
+
auto idx = isel.get_index(i);
|
|
8847
|
+
auto sidx = ssel.get_index(i);
|
|
8848
|
+
if (mask.RowIsValid(idx)) {
|
|
8849
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[sidx], aggr_input_data, idata, mask, idx);
|
|
8850
|
+
}
|
|
8851
|
+
}
|
|
8852
|
+
} else {
|
|
8853
|
+
// quick path: no NULL values or NULL values are not ignored
|
|
8854
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8855
|
+
auto idx = isel.get_index(i);
|
|
8856
|
+
auto sidx = ssel.get_index(i);
|
|
8857
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(states[sidx], aggr_input_data, idata, mask, idx);
|
|
8858
|
+
}
|
|
8859
|
+
}
|
|
8860
|
+
}
|
|
8861
|
+
|
|
8862
|
+
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
8863
|
+
static inline void UnaryFlatUpdateLoop(INPUT_TYPE *__restrict idata, AggregateInputData &aggr_input_data,
|
|
8864
|
+
STATE_TYPE *__restrict state, idx_t count, ValidityMask &mask) {
|
|
8865
|
+
idx_t base_idx = 0;
|
|
8866
|
+
auto entry_count = ValidityMask::EntryCount(count);
|
|
8867
|
+
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
|
8868
|
+
auto validity_entry = mask.GetValidityEntry(entry_idx);
|
|
8869
|
+
idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
|
|
8870
|
+
if (!OP::IgnoreNull() || ValidityMask::AllValid(validity_entry)) {
|
|
8871
|
+
// all valid: perform operation
|
|
8872
|
+
for (; base_idx < next; base_idx++) {
|
|
8873
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, aggr_input_data, idata, mask, base_idx);
|
|
8874
|
+
}
|
|
8875
|
+
} else if (ValidityMask::NoneValid(validity_entry)) {
|
|
8876
|
+
// nothing valid: skip all
|
|
8877
|
+
base_idx = next;
|
|
8878
|
+
continue;
|
|
8879
|
+
} else {
|
|
8880
|
+
// partially valid: need to check individual elements for validity
|
|
8881
|
+
idx_t start = base_idx;
|
|
8882
|
+
for (; base_idx < next; base_idx++) {
|
|
8883
|
+
if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
|
|
8884
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, aggr_input_data, idata, mask,
|
|
8885
|
+
base_idx);
|
|
8886
|
+
}
|
|
8887
|
+
}
|
|
8888
|
+
}
|
|
8889
|
+
}
|
|
8890
|
+
}
|
|
8891
|
+
|
|
8892
|
+
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
8893
|
+
static inline void UnaryUpdateLoop(INPUT_TYPE *__restrict idata, AggregateInputData &aggr_input_data,
|
|
8894
|
+
STATE_TYPE *__restrict state, idx_t count, ValidityMask &mask,
|
|
8895
|
+
const SelectionVector &__restrict sel_vector) {
|
|
8896
|
+
if (OP::IgnoreNull() && !mask.AllValid()) {
|
|
8897
|
+
// potential NULL values and NULL values are ignored
|
|
8898
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8899
|
+
auto idx = sel_vector.get_index(i);
|
|
8900
|
+
if (mask.RowIsValid(idx)) {
|
|
8901
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, aggr_input_data, idata, mask, idx);
|
|
8902
|
+
}
|
|
8903
|
+
}
|
|
8904
|
+
} else {
|
|
8905
|
+
// quick path: no NULL values or NULL values are not ignored
|
|
8906
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8907
|
+
auto idx = sel_vector.get_index(i);
|
|
8908
|
+
OP::template Operation<INPUT_TYPE, STATE_TYPE, OP>(state, aggr_input_data, idata, mask, idx);
|
|
8909
|
+
}
|
|
8910
|
+
}
|
|
8911
|
+
}
|
|
8912
|
+
|
|
8913
|
+
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
8914
|
+
static inline void BinaryScatterLoop(A_TYPE *__restrict adata, AggregateInputData &aggr_input_data,
|
|
8915
|
+
B_TYPE *__restrict bdata, STATE_TYPE **__restrict states, idx_t count,
|
|
8916
|
+
const SelectionVector &asel, const SelectionVector &bsel,
|
|
8917
|
+
const SelectionVector &ssel, ValidityMask &avalidity,
|
|
8918
|
+
ValidityMask &bvalidity) {
|
|
8919
|
+
if (OP::IgnoreNull() && (!avalidity.AllValid() || !bvalidity.AllValid())) {
|
|
8920
|
+
// potential NULL values and NULL values are ignored
|
|
8921
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8922
|
+
auto aidx = asel.get_index(i);
|
|
8923
|
+
auto bidx = bsel.get_index(i);
|
|
8924
|
+
auto sidx = ssel.get_index(i);
|
|
8925
|
+
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx)) {
|
|
8926
|
+
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(states[sidx], aggr_input_data, adata, bdata,
|
|
8927
|
+
avalidity, bvalidity, aidx, bidx);
|
|
8928
|
+
}
|
|
8929
|
+
}
|
|
8930
|
+
} else {
|
|
8931
|
+
// quick path: no NULL values or NULL values are not ignored
|
|
8932
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8933
|
+
auto aidx = asel.get_index(i);
|
|
8934
|
+
auto bidx = bsel.get_index(i);
|
|
8935
|
+
auto sidx = ssel.get_index(i);
|
|
8936
|
+
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(states[sidx], aggr_input_data, adata, bdata,
|
|
8937
|
+
avalidity, bvalidity, aidx, bidx);
|
|
8938
|
+
}
|
|
8939
|
+
}
|
|
8940
|
+
}
|
|
8941
|
+
|
|
8942
|
+
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
8943
|
+
static inline void BinaryUpdateLoop(A_TYPE *__restrict adata, AggregateInputData &aggr_input_data,
|
|
8944
|
+
B_TYPE *__restrict bdata, STATE_TYPE *__restrict state, idx_t count,
|
|
8945
|
+
const SelectionVector &asel, const SelectionVector &bsel,
|
|
8946
|
+
ValidityMask &avalidity, ValidityMask &bvalidity) {
|
|
8947
|
+
if (OP::IgnoreNull() && (!avalidity.AllValid() || !bvalidity.AllValid())) {
|
|
8948
|
+
// potential NULL values and NULL values are ignored
|
|
8949
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8950
|
+
auto aidx = asel.get_index(i);
|
|
8951
|
+
auto bidx = bsel.get_index(i);
|
|
8952
|
+
if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx)) {
|
|
8953
|
+
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(state, aggr_input_data, adata, bdata,
|
|
8954
|
+
avalidity, bvalidity, aidx, bidx);
|
|
8955
|
+
}
|
|
8956
|
+
}
|
|
8957
|
+
} else {
|
|
8958
|
+
// quick path: no NULL values or NULL values are not ignored
|
|
8959
|
+
for (idx_t i = 0; i < count; i++) {
|
|
8960
|
+
auto aidx = asel.get_index(i);
|
|
8961
|
+
auto bidx = bsel.get_index(i);
|
|
8962
|
+
OP::template Operation<A_TYPE, B_TYPE, STATE_TYPE, OP>(state, aggr_input_data, adata, bdata, avalidity,
|
|
8963
|
+
bvalidity, aidx, bidx);
|
|
8964
|
+
}
|
|
8965
|
+
}
|
|
8966
|
+
}
|
|
8967
|
+
|
|
8968
|
+
public:
|
|
8969
|
+
template <class STATE_TYPE, class OP>
|
|
8970
|
+
static void NullaryScatter(Vector &states, AggregateInputData &aggr_input_data, idx_t count) {
|
|
8971
|
+
if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
8972
|
+
auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
|
|
8973
|
+
OP::template ConstantOperation<STATE_TYPE, OP>(*sdata, aggr_input_data, count);
|
|
8974
|
+
} else if (states.GetVectorType() == VectorType::FLAT_VECTOR) {
|
|
8975
|
+
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
8976
|
+
NullaryFlatLoop<STATE_TYPE, OP>(sdata, aggr_input_data, count);
|
|
8977
|
+
} else {
|
|
8978
|
+
VectorData sdata;
|
|
8979
|
+
states.Orrify(count, sdata);
|
|
8980
|
+
NullaryScatterLoop<STATE_TYPE, OP>((STATE_TYPE **)sdata.data, aggr_input_data, *sdata.sel, count);
|
|
8981
|
+
}
|
|
8982
|
+
}
|
|
8983
|
+
|
|
8984
|
+
template <class STATE_TYPE, class OP>
|
|
8985
|
+
static void NullaryUpdate(data_ptr_t state, AggregateInputData &aggr_input_data, idx_t count) {
|
|
8986
|
+
OP::template ConstantOperation<STATE_TYPE, OP>((STATE_TYPE *)state, aggr_input_data, count);
|
|
8987
|
+
}
|
|
8988
|
+
|
|
8989
|
+
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
8990
|
+
static void UnaryScatter(Vector &input, Vector &states, AggregateInputData &aggr_input_data, idx_t count) {
|
|
8991
|
+
if (input.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
8992
|
+
states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
8993
|
+
if (OP::IgnoreNull() && ConstantVector::IsNull(input)) {
|
|
8994
|
+
// constant NULL input in function that ignores NULL values
|
|
8995
|
+
return;
|
|
8996
|
+
}
|
|
8997
|
+
// regular constant: get first state
|
|
8998
|
+
auto idata = ConstantVector::GetData<INPUT_TYPE>(input);
|
|
8999
|
+
auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
|
|
9000
|
+
OP::template ConstantOperation<INPUT_TYPE, STATE_TYPE, OP>(*sdata, aggr_input_data, idata,
|
|
9001
|
+
ConstantVector::Validity(input), count);
|
|
9002
|
+
} else if (input.GetVectorType() == VectorType::FLAT_VECTOR &&
|
|
9003
|
+
states.GetVectorType() == VectorType::FLAT_VECTOR) {
|
|
9004
|
+
auto idata = FlatVector::GetData<INPUT_TYPE>(input);
|
|
9005
|
+
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
9006
|
+
UnaryFlatLoop<STATE_TYPE, INPUT_TYPE, OP>(idata, aggr_input_data, sdata, FlatVector::Validity(input),
|
|
9007
|
+
count);
|
|
9008
|
+
} else {
|
|
9009
|
+
VectorData idata, sdata;
|
|
9010
|
+
input.Orrify(count, idata);
|
|
9011
|
+
states.Orrify(count, sdata);
|
|
9012
|
+
UnaryScatterLoop<STATE_TYPE, INPUT_TYPE, OP>((INPUT_TYPE *)idata.data, aggr_input_data,
|
|
9013
|
+
(STATE_TYPE **)sdata.data, *idata.sel, *sdata.sel,
|
|
9014
|
+
idata.validity, count);
|
|
9015
|
+
}
|
|
9016
|
+
}
|
|
9017
|
+
|
|
9018
|
+
template <class STATE_TYPE, class INPUT_TYPE, class OP>
|
|
9019
|
+
static void UnaryUpdate(Vector &input, AggregateInputData &aggr_input_data, data_ptr_t state, idx_t count) {
|
|
9020
|
+
switch (input.GetVectorType()) {
|
|
9021
|
+
case VectorType::CONSTANT_VECTOR: {
|
|
9022
|
+
if (OP::IgnoreNull() && ConstantVector::IsNull(input)) {
|
|
9023
|
+
return;
|
|
9024
|
+
}
|
|
9025
|
+
auto idata = ConstantVector::GetData<INPUT_TYPE>(input);
|
|
9026
|
+
OP::template ConstantOperation<INPUT_TYPE, STATE_TYPE, OP>((STATE_TYPE *)state, aggr_input_data, idata,
|
|
9027
|
+
ConstantVector::Validity(input), count);
|
|
9028
|
+
break;
|
|
9029
|
+
}
|
|
9030
|
+
case VectorType::FLAT_VECTOR: {
|
|
9031
|
+
auto idata = FlatVector::GetData<INPUT_TYPE>(input);
|
|
9032
|
+
UnaryFlatUpdateLoop<STATE_TYPE, INPUT_TYPE, OP>(idata, aggr_input_data, (STATE_TYPE *)state, count,
|
|
9033
|
+
FlatVector::Validity(input));
|
|
9034
|
+
break;
|
|
9035
|
+
}
|
|
9036
|
+
default: {
|
|
9037
|
+
VectorData idata;
|
|
9038
|
+
input.Orrify(count, idata);
|
|
9039
|
+
UnaryUpdateLoop<STATE_TYPE, INPUT_TYPE, OP>((INPUT_TYPE *)idata.data, aggr_input_data, (STATE_TYPE *)state,
|
|
9040
|
+
count, idata.validity, *idata.sel);
|
|
9041
|
+
break;
|
|
9042
|
+
}
|
|
9043
|
+
}
|
|
9044
|
+
}
|
|
9045
|
+
|
|
9046
|
+
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
9047
|
+
static void BinaryScatter(AggregateInputData &aggr_input_data, Vector &a, Vector &b, Vector &states, idx_t count) {
|
|
9048
|
+
VectorData adata, bdata, sdata;
|
|
9049
|
+
|
|
9050
|
+
a.Orrify(count, adata);
|
|
9051
|
+
b.Orrify(count, bdata);
|
|
9052
|
+
states.Orrify(count, sdata);
|
|
9053
|
+
|
|
9054
|
+
BinaryScatterLoop<STATE_TYPE, A_TYPE, B_TYPE, OP>((A_TYPE *)adata.data, aggr_input_data, (B_TYPE *)bdata.data,
|
|
9055
|
+
(STATE_TYPE **)sdata.data, count, *adata.sel, *bdata.sel,
|
|
9056
|
+
*sdata.sel, adata.validity, bdata.validity);
|
|
9057
|
+
}
|
|
9058
|
+
|
|
9059
|
+
template <class STATE_TYPE, class A_TYPE, class B_TYPE, class OP>
|
|
9060
|
+
static void BinaryUpdate(AggregateInputData &aggr_input_data, Vector &a, Vector &b, data_ptr_t state, idx_t count) {
|
|
9061
|
+
VectorData adata, bdata;
|
|
9062
|
+
|
|
9063
|
+
a.Orrify(count, adata);
|
|
9064
|
+
b.Orrify(count, bdata);
|
|
9065
|
+
|
|
9066
|
+
BinaryUpdateLoop<STATE_TYPE, A_TYPE, B_TYPE, OP>((A_TYPE *)adata.data, aggr_input_data, (B_TYPE *)bdata.data,
|
|
9067
|
+
(STATE_TYPE *)state, count, *adata.sel, *bdata.sel,
|
|
9068
|
+
adata.validity, bdata.validity);
|
|
9069
|
+
}
|
|
9070
|
+
|
|
9071
|
+
template <class STATE_TYPE, class OP>
|
|
9072
|
+
static void Combine(Vector &source, Vector &target, AggregateInputData &aggr_input_data, idx_t count) {
|
|
9073
|
+
D_ASSERT(source.GetType().id() == LogicalTypeId::POINTER && target.GetType().id() == LogicalTypeId::POINTER);
|
|
9074
|
+
auto sdata = FlatVector::GetData<const STATE_TYPE *>(source);
|
|
9075
|
+
auto tdata = FlatVector::GetData<STATE_TYPE *>(target);
|
|
9076
|
+
|
|
9077
|
+
for (idx_t i = 0; i < count; i++) {
|
|
9078
|
+
OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i], aggr_input_data);
|
|
9079
|
+
}
|
|
9080
|
+
}
|
|
9081
|
+
|
|
9082
|
+
template <class STATE_TYPE, class RESULT_TYPE, class OP>
|
|
9083
|
+
static void Finalize(Vector &states, AggregateInputData &aggr_input_data, Vector &result, idx_t count,
|
|
9084
|
+
idx_t offset) {
|
|
9085
|
+
if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
9086
|
+
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
9087
|
+
|
|
9088
|
+
auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
|
|
9089
|
+
auto rdata = ConstantVector::GetData<RESULT_TYPE>(result);
|
|
9090
|
+
OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, *sdata, rdata,
|
|
9091
|
+
ConstantVector::Validity(result), 0);
|
|
9092
|
+
} else {
|
|
9093
|
+
D_ASSERT(states.GetVectorType() == VectorType::FLAT_VECTOR);
|
|
9094
|
+
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
9095
|
+
|
|
9096
|
+
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
9097
|
+
auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
|
|
9098
|
+
for (idx_t i = 0; i < count; i++) {
|
|
9099
|
+
OP::template Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[i], rdata,
|
|
9100
|
+
FlatVector::Validity(result), i + offset);
|
|
9101
|
+
}
|
|
9102
|
+
}
|
|
9103
|
+
}
|
|
9104
|
+
|
|
9105
|
+
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
|
9106
|
+
static void UnaryWindow(Vector &input, const ValidityMask &ifilter, AggregateInputData &aggr_input_data,
|
|
9107
|
+
data_ptr_t state, const FrameBounds &frame, const FrameBounds &prev, Vector &result,
|
|
9108
|
+
idx_t rid, idx_t bias) {
|
|
9109
|
+
|
|
9110
|
+
auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
|
|
9111
|
+
const auto &ivalid = FlatVector::Validity(input);
|
|
9112
|
+
OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ifilter, ivalid, aggr_input_data, (STATE *)state,
|
|
9113
|
+
frame, prev, result, rid, bias);
|
|
9114
|
+
}
|
|
9115
|
+
|
|
9116
|
+
template <class STATE_TYPE, class OP>
|
|
9117
|
+
static void Destroy(Vector &states, idx_t count) {
|
|
9118
|
+
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
|
9119
|
+
for (idx_t i = 0; i < count; i++) {
|
|
9120
|
+
OP::template Destroy<STATE_TYPE>(sdata[i]);
|
|
9121
|
+
}
|
|
9122
|
+
}
|
|
9123
|
+
};
|
|
9124
|
+
|
|
9125
|
+
} // namespace duckdb
|
|
9126
|
+
|
|
9127
|
+
|
|
9128
|
+
namespace duckdb {
|
|
9129
|
+
|
|
9130
|
+
class BoundAggregateExpression;
|
|
9131
|
+
|
|
9132
|
+
struct AggregateInputData {
|
|
9133
|
+
AggregateInputData(FunctionData *bind_data_p) : bind_data(bind_data_p) {};
|
|
9134
|
+
FunctionData *bind_data;
|
|
9135
|
+
};
|
|
9136
|
+
|
|
9137
|
+
//! The type used for sizing hashed aggregate function states
|
|
9138
|
+
typedef idx_t (*aggregate_size_t)();
|
|
9139
|
+
//! The type used for initializing hashed aggregate function states
|
|
9140
|
+
typedef void (*aggregate_initialize_t)(data_ptr_t state);
|
|
9141
|
+
//! The type used for updating hashed aggregate functions
|
|
9142
|
+
typedef void (*aggregate_update_t)(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count,
|
|
9143
|
+
Vector &state, idx_t count);
|
|
9144
|
+
//! The type used for combining hashed aggregate states
|
|
9145
|
+
typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, AggregateInputData &aggr_input_data, idx_t count);
|
|
9146
|
+
//! The type used for finalizing hashed aggregate function payloads
|
|
9147
|
+
typedef void (*aggregate_finalize_t)(Vector &state, AggregateInputData &aggr_input_data, Vector &result, idx_t count,
|
|
9148
|
+
idx_t offset);
|
|
9149
|
+
//! The type used for propagating statistics in aggregate functions (optional)
|
|
9150
|
+
typedef unique_ptr<BaseStatistics> (*aggregate_statistics_t)(ClientContext &context, BoundAggregateExpression &expr,
|
|
9151
|
+
FunctionData *bind_data,
|
|
9152
|
+
vector<unique_ptr<BaseStatistics>> &child_stats,
|
|
9153
|
+
NodeStatistics *node_stats);
|
|
9154
|
+
//! Binds the scalar function and creates the function data
|
|
9155
|
+
typedef unique_ptr<FunctionData> (*bind_aggregate_function_t)(ClientContext &context, AggregateFunction &function,
|
|
9156
|
+
vector<unique_ptr<Expression>> &arguments);
|
|
9157
|
+
//! The type used for the aggregate destructor method. NOTE: this method is used in destructors and MAY NOT throw.
|
|
9158
|
+
typedef void (*aggregate_destructor_t)(Vector &state, idx_t count);
|
|
9159
|
+
|
|
9160
|
+
//! The type used for updating simple (non-grouped) aggregate functions
|
|
9161
|
+
typedef void (*aggregate_simple_update_t)(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count,
|
|
9162
|
+
data_ptr_t state, idx_t count);
|
|
9163
|
+
|
|
9164
|
+
//! The type used for updating complex windowed aggregate functions (optional)
|
|
9165
|
+
typedef std::pair<idx_t, idx_t> FrameBounds;
|
|
9166
|
+
typedef void (*aggregate_window_t)(Vector inputs[], const ValidityMask &filter_mask,
|
|
9167
|
+
AggregateInputData &aggr_input_data, idx_t input_count, data_ptr_t state,
|
|
9168
|
+
const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid,
|
|
9169
|
+
idx_t bias);
|
|
9170
|
+
|
|
9171
|
+
class AggregateFunction : public BaseScalarFunction {
|
|
9172
|
+
public:
|
|
9173
|
+
DUCKDB_API AggregateFunction(const string &name, const vector<LogicalType> &arguments,
|
|
9174
|
+
const LogicalType &return_type, aggregate_size_t state_size,
|
|
9175
|
+
aggregate_initialize_t initialize, aggregate_update_t update,
|
|
9176
|
+
aggregate_combine_t combine, aggregate_finalize_t finalize,
|
|
9177
|
+
bool propagates_null_values = false, aggregate_simple_update_t simple_update = nullptr,
|
|
9178
|
+
bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
|
|
9179
|
+
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9180
|
+
: BaseScalarFunction(name, arguments, return_type, false, LogicalType(LogicalTypeId::INVALID),
|
|
9181
|
+
propagates_null_values),
|
|
9182
|
+
state_size(state_size), initialize(initialize), update(update), combine(combine), finalize(finalize),
|
|
9183
|
+
simple_update(simple_update), window(window), bind(bind), destructor(destructor), statistics(statistics) {
|
|
9184
|
+
}
|
|
9185
|
+
|
|
9186
|
+
DUCKDB_API AggregateFunction(const string &name, const vector<LogicalType> &arguments,
|
|
9187
|
+
const LogicalType &return_type, aggregate_size_t state_size,
|
|
9188
|
+
aggregate_initialize_t initialize, aggregate_update_t update,
|
|
9189
|
+
aggregate_combine_t combine, aggregate_finalize_t finalize,
|
|
9190
|
+
aggregate_simple_update_t simple_update = nullptr,
|
|
9191
|
+
bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
|
|
9192
|
+
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9193
|
+
: BaseScalarFunction(name, arguments, return_type, false, LogicalType(LogicalTypeId::INVALID), false),
|
|
9194
|
+
state_size(state_size), initialize(initialize), update(update), combine(combine), finalize(finalize),
|
|
9195
|
+
simple_update(simple_update), window(window), bind(bind), destructor(destructor), statistics(statistics) {
|
|
9196
|
+
}
|
|
9197
|
+
|
|
9198
|
+
DUCKDB_API AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type,
|
|
9199
|
+
aggregate_size_t state_size, aggregate_initialize_t initialize,
|
|
9200
|
+
aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize,
|
|
9201
|
+
bool propagates_null_values = false, aggregate_simple_update_t simple_update = nullptr,
|
|
9202
|
+
bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
|
|
9203
|
+
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9204
|
+
: AggregateFunction(string(), arguments, return_type, state_size, initialize, update, combine, finalize,
|
|
9205
|
+
propagates_null_values, simple_update, bind, destructor, statistics, window) {
|
|
9206
|
+
}
|
|
9207
|
+
|
|
9208
|
+
DUCKDB_API AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type,
|
|
9209
|
+
aggregate_size_t state_size, aggregate_initialize_t initialize,
|
|
9210
|
+
aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize,
|
|
9211
|
+
aggregate_simple_update_t simple_update = nullptr,
|
|
9212
|
+
bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
|
|
9213
|
+
aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
|
|
9214
|
+
: AggregateFunction(string(), arguments, return_type, state_size, initialize, update, combine, finalize, false,
|
|
9215
|
+
simple_update, bind, destructor, statistics, window) {
|
|
9216
|
+
}
|
|
9217
|
+
//! The hashed aggregate state sizing function
|
|
9218
|
+
aggregate_size_t state_size;
|
|
9219
|
+
//! The hashed aggregate state initialization function
|
|
9220
|
+
aggregate_initialize_t initialize;
|
|
9221
|
+
//! The hashed aggregate update state function
|
|
9222
|
+
aggregate_update_t update;
|
|
9223
|
+
//! The hashed aggregate combine states function
|
|
9224
|
+
aggregate_combine_t combine;
|
|
9225
|
+
//! The hashed aggregate finalization function
|
|
9226
|
+
aggregate_finalize_t finalize;
|
|
9227
|
+
//! The simple aggregate update function (may be null)
|
|
9228
|
+
aggregate_simple_update_t simple_update;
|
|
9229
|
+
//! The windowed aggregate frame update function (may be null)
|
|
9185
9230
|
aggregate_window_t window;
|
|
9186
9231
|
|
|
9187
9232
|
//! The bind function (may be null)
|
|
@@ -9260,64 +9305,66 @@ public:
|
|
|
9260
9305
|
}
|
|
9261
9306
|
|
|
9262
9307
|
template <class STATE, class OP>
|
|
9263
|
-
static void NullaryScatterUpdate(Vector inputs[],
|
|
9264
|
-
idx_t count) {
|
|
9308
|
+
static void NullaryScatterUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count,
|
|
9309
|
+
Vector &states, idx_t count) {
|
|
9265
9310
|
D_ASSERT(input_count == 0);
|
|
9266
|
-
AggregateExecutor::NullaryScatter<STATE, OP>(states,
|
|
9311
|
+
AggregateExecutor::NullaryScatter<STATE, OP>(states, aggr_input_data, count);
|
|
9267
9312
|
}
|
|
9268
9313
|
|
|
9269
9314
|
template <class STATE, class OP>
|
|
9270
|
-
static void NullaryUpdate(Vector inputs[],
|
|
9315
|
+
static void NullaryUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, data_ptr_t state,
|
|
9271
9316
|
idx_t count) {
|
|
9272
9317
|
D_ASSERT(input_count == 0);
|
|
9273
|
-
AggregateExecutor::NullaryUpdate<STATE, OP>(state,
|
|
9318
|
+
AggregateExecutor::NullaryUpdate<STATE, OP>(state, aggr_input_data, count);
|
|
9274
9319
|
}
|
|
9275
9320
|
|
|
9276
9321
|
template <class STATE, class T, class OP>
|
|
9277
|
-
static void UnaryScatterUpdate(Vector inputs[],
|
|
9278
|
-
idx_t count) {
|
|
9322
|
+
static void UnaryScatterUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count,
|
|
9323
|
+
Vector &states, idx_t count) {
|
|
9279
9324
|
D_ASSERT(input_count == 1);
|
|
9280
|
-
AggregateExecutor::UnaryScatter<STATE, T, OP>(inputs[0], states,
|
|
9325
|
+
AggregateExecutor::UnaryScatter<STATE, T, OP>(inputs[0], states, aggr_input_data, count);
|
|
9281
9326
|
}
|
|
9282
9327
|
|
|
9283
9328
|
template <class STATE, class INPUT_TYPE, class OP>
|
|
9284
|
-
static void UnaryUpdate(Vector inputs[],
|
|
9329
|
+
static void UnaryUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, data_ptr_t state,
|
|
9285
9330
|
idx_t count) {
|
|
9286
9331
|
D_ASSERT(input_count == 1);
|
|
9287
|
-
AggregateExecutor::UnaryUpdate<STATE, INPUT_TYPE, OP>(inputs[0],
|
|
9332
|
+
AggregateExecutor::UnaryUpdate<STATE, INPUT_TYPE, OP>(inputs[0], aggr_input_data, state, count);
|
|
9288
9333
|
}
|
|
9289
9334
|
|
|
9290
9335
|
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
|
9291
|
-
static void UnaryWindow(Vector inputs[], const ValidityMask &filter_mask,
|
|
9336
|
+
static void UnaryWindow(Vector inputs[], const ValidityMask &filter_mask, AggregateInputData &aggr_input_data,
|
|
9292
9337
|
idx_t input_count, data_ptr_t state, const FrameBounds &frame, const FrameBounds &prev,
|
|
9293
9338
|
Vector &result, idx_t rid, idx_t bias) {
|
|
9294
9339
|
D_ASSERT(input_count == 1);
|
|
9295
|
-
AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], filter_mask,
|
|
9296
|
-
frame, prev, result, rid, bias);
|
|
9340
|
+
AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], filter_mask, aggr_input_data,
|
|
9341
|
+
state, frame, prev, result, rid, bias);
|
|
9297
9342
|
}
|
|
9298
9343
|
|
|
9299
9344
|
template <class STATE, class A_TYPE, class B_TYPE, class OP>
|
|
9300
|
-
static void BinaryScatterUpdate(Vector inputs[],
|
|
9301
|
-
idx_t count) {
|
|
9345
|
+
static void BinaryScatterUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count,
|
|
9346
|
+
Vector &states, idx_t count) {
|
|
9302
9347
|
D_ASSERT(input_count == 2);
|
|
9303
|
-
AggregateExecutor::BinaryScatter<STATE, A_TYPE, B_TYPE, OP>(
|
|
9348
|
+
AggregateExecutor::BinaryScatter<STATE, A_TYPE, B_TYPE, OP>(aggr_input_data, inputs[0], inputs[1], states,
|
|
9349
|
+
count);
|
|
9304
9350
|
}
|
|
9305
9351
|
|
|
9306
9352
|
template <class STATE, class A_TYPE, class B_TYPE, class OP>
|
|
9307
|
-
static void BinaryUpdate(Vector inputs[],
|
|
9353
|
+
static void BinaryUpdate(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, data_ptr_t state,
|
|
9308
9354
|
idx_t count) {
|
|
9309
9355
|
D_ASSERT(input_count == 2);
|
|
9310
|
-
AggregateExecutor::BinaryUpdate<STATE, A_TYPE, B_TYPE, OP>(
|
|
9356
|
+
AggregateExecutor::BinaryUpdate<STATE, A_TYPE, B_TYPE, OP>(aggr_input_data, inputs[0], inputs[1], state, count);
|
|
9311
9357
|
}
|
|
9312
9358
|
|
|
9313
9359
|
template <class STATE, class OP>
|
|
9314
|
-
static void StateCombine(Vector &source, Vector &target,
|
|
9315
|
-
AggregateExecutor::Combine<STATE, OP>(source, target,
|
|
9360
|
+
static void StateCombine(Vector &source, Vector &target, AggregateInputData &aggr_input_data, idx_t count) {
|
|
9361
|
+
AggregateExecutor::Combine<STATE, OP>(source, target, aggr_input_data, count);
|
|
9316
9362
|
}
|
|
9317
9363
|
|
|
9318
9364
|
template <class STATE, class RESULT_TYPE, class OP>
|
|
9319
|
-
static void StateFinalize(Vector &states,
|
|
9320
|
-
|
|
9365
|
+
static void StateFinalize(Vector &states, AggregateInputData &aggr_input_data, Vector &result, idx_t count,
|
|
9366
|
+
idx_t offset) {
|
|
9367
|
+
AggregateExecutor::Finalize<STATE, RESULT_TYPE, OP>(states, aggr_input_data, result, count, offset);
|
|
9321
9368
|
}
|
|
9322
9369
|
|
|
9323
9370
|
template <class STATE, class OP>
|
|
@@ -10086,6 +10133,7 @@ private:
|
|
|
10086
10133
|
|
|
10087
10134
|
} // namespace duckdb
|
|
10088
10135
|
|
|
10136
|
+
|
|
10089
10137
|
namespace duckdb {
|
|
10090
10138
|
|
|
10091
10139
|
class ClientContext;
|
|
@@ -10124,6 +10172,7 @@ public:
|
|
|
10124
10172
|
};
|
|
10125
10173
|
|
|
10126
10174
|
} // namespace duckdb
|
|
10175
|
+
|
|
10127
10176
|
//===----------------------------------------------------------------------===//
|
|
10128
10177
|
// DuckDB
|
|
10129
10178
|
//
|
|
@@ -11264,6 +11313,7 @@ private:
|
|
|
11264
11313
|
|
|
11265
11314
|
} // namespace duckdb
|
|
11266
11315
|
|
|
11316
|
+
|
|
11267
11317
|
//===----------------------------------------------------------------------===//
|
|
11268
11318
|
// DuckDB
|
|
11269
11319
|
//
|
|
@@ -15358,6 +15408,7 @@ namespace duckdb {
|
|
|
15358
15408
|
using std::deque;
|
|
15359
15409
|
}
|
|
15360
15410
|
|
|
15411
|
+
|
|
15361
15412
|
//===----------------------------------------------------------------------===//
|
|
15362
15413
|
// DuckDB
|
|
15363
15414
|
//
|
|
@@ -17435,6 +17486,7 @@ private:
|
|
|
17435
17486
|
|
|
17436
17487
|
|
|
17437
17488
|
|
|
17489
|
+
|
|
17438
17490
|
//===----------------------------------------------------------------------===//
|
|
17439
17491
|
// DuckDB
|
|
17440
17492
|
//
|
|
@@ -17489,6 +17541,7 @@ private:
|
|
|
17489
17541
|
};
|
|
17490
17542
|
|
|
17491
17543
|
} // namespace duckdb
|
|
17544
|
+
|
|
17492
17545
|
//===----------------------------------------------------------------------===//
|
|
17493
17546
|
// DuckDB
|
|
17494
17547
|
//
|
|
@@ -17675,27 +17728,7 @@ public:
|
|
|
17675
17728
|
|
|
17676
17729
|
} // namespace duckdb
|
|
17677
17730
|
|
|
17678
|
-
//===----------------------------------------------------------------------===//
|
|
17679
|
-
// DuckDB
|
|
17680
|
-
//
|
|
17681
|
-
// duckdb/main/external_dependencies.hpp
|
|
17682
|
-
//
|
|
17683
|
-
//
|
|
17684
|
-
//===----------------------------------------------------------------------===//
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
namespace duckdb {
|
|
17689
|
-
|
|
17690
|
-
enum ExternalDependenciesType { PYTHON_DEPENDENCY };
|
|
17691
|
-
class ExternalDependency {
|
|
17692
|
-
public:
|
|
17693
|
-
explicit ExternalDependency(ExternalDependenciesType type_p) : type(type_p) {};
|
|
17694
|
-
virtual ~ExternalDependency() {};
|
|
17695
|
-
ExternalDependenciesType type;
|
|
17696
|
-
};
|
|
17697
17731
|
|
|
17698
|
-
} // namespace duckdb
|
|
17699
17732
|
|
|
17700
17733
|
namespace duckdb {
|
|
17701
17734
|
class Appender;
|
|
@@ -18087,6 +18120,7 @@ protected:
|
|
|
18087
18120
|
|
|
18088
18121
|
|
|
18089
18122
|
|
|
18123
|
+
|
|
18090
18124
|
namespace duckdb {
|
|
18091
18125
|
|
|
18092
18126
|
class ChunkCollection;
|
|
@@ -18701,6 +18735,7 @@ public:
|
|
|
18701
18735
|
|
|
18702
18736
|
} // namespace duckdb
|
|
18703
18737
|
|
|
18738
|
+
|
|
18704
18739
|
namespace duckdb {
|
|
18705
18740
|
class StorageManager;
|
|
18706
18741
|
class Catalog;
|
|
@@ -18732,6 +18767,8 @@ public:
|
|
|
18732
18767
|
|
|
18733
18768
|
DUCKDB_API static DatabaseInstance &GetDatabase(ClientContext &context);
|
|
18734
18769
|
|
|
18770
|
+
DUCKDB_API const unordered_set<std::string> &LoadedExtensions();
|
|
18771
|
+
|
|
18735
18772
|
private:
|
|
18736
18773
|
void Initialize(const char *path, DBConfig *config);
|
|
18737
18774
|
|
|
@@ -18843,6 +18880,7 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
|
|
|
18843
18880
|
}
|
|
18844
18881
|
#endif
|
|
18845
18882
|
#endif
|
|
18883
|
+
|
|
18846
18884
|
//===----------------------------------------------------------------------===//
|
|
18847
18885
|
// DuckDB
|
|
18848
18886
|
//
|
|
@@ -18863,6 +18901,10 @@ namespace duckdb {
|
|
|
18863
18901
|
//! The Date class is a static class that holds helper functions for the Date type.
|
|
18864
18902
|
class Date {
|
|
18865
18903
|
public:
|
|
18904
|
+
static const char *PINF; // NOLINT
|
|
18905
|
+
static const char *NINF; // NOLINT
|
|
18906
|
+
static const char *EPOCH; // NOLINT
|
|
18907
|
+
|
|
18866
18908
|
static const string_t MONTH_NAMES[12];
|
|
18867
18909
|
static const string_t MONTH_NAMES_ABBREVIATED[12];
|
|
18868
18910
|
static const string_t DAY_NAMES[7];
|
|
@@ -19075,6 +19117,8 @@ public:
|
|
|
19075
19117
|
|
|
19076
19118
|
|
|
19077
19119
|
namespace duckdb {
|
|
19120
|
+
class ClientContext;
|
|
19121
|
+
struct RandomEngine;
|
|
19078
19122
|
|
|
19079
19123
|
//! The UUID class contains static operations for the UUID type
|
|
19080
19124
|
class UUID {
|
|
@@ -19089,6 +19133,10 @@ public:
|
|
|
19089
19133
|
//! Convert a hugeint object to a uuid style string
|
|
19090
19134
|
static void ToString(hugeint_t input, char *buf);
|
|
19091
19135
|
|
|
19136
|
+
//! Convert a hugeint object to a uuid style string
|
|
19137
|
+
static hugeint_t GenerateRandomUUID(RandomEngine &engine);
|
|
19138
|
+
static hugeint_t GenerateRandomUUID();
|
|
19139
|
+
|
|
19092
19140
|
//! Convert a hugeint object to a uuid style string
|
|
19093
19141
|
static string ToString(hugeint_t input) {
|
|
19094
19142
|
char buff[STRING_SIZE];
|
|
@@ -22453,7 +22501,7 @@ protected:
|
|
|
22453
22501
|
//! Format is literals[0], specifiers[0], literals[1], ..., specifiers[n - 1], literals[n]
|
|
22454
22502
|
vector<string> literals;
|
|
22455
22503
|
//! The constant size that appears in the format string
|
|
22456
|
-
idx_t constant_size;
|
|
22504
|
+
idx_t constant_size = 0;
|
|
22457
22505
|
//! The max numeric width of the specifier (if it is parsed as a number), or -1 if it is not a number
|
|
22458
22506
|
vector<int> numeric_width;
|
|
22459
22507
|
|
|
@@ -22470,6 +22518,9 @@ struct StrfTimeFormat : public StrTimeFormat {
|
|
|
22470
22518
|
|
|
22471
22519
|
DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
|
|
22472
22520
|
|
|
22521
|
+
DUCKDB_API void ConvertDateVector(Vector &input, Vector &result, idx_t count);
|
|
22522
|
+
DUCKDB_API void ConvertTimestampVector(Vector &input, Vector &result, idx_t count);
|
|
22523
|
+
|
|
22473
22524
|
protected:
|
|
22474
22525
|
//! The variable-length specifiers. To determine total string size, these need to be checked.
|
|
22475
22526
|
vector<StrTimeSpecifier> var_length_specifiers;
|
|
@@ -22657,6 +22708,9 @@ struct BufferedCSVReaderOptions {
|
|
|
22657
22708
|
|
|
22658
22709
|
//! The date format to use (if any is specified)
|
|
22659
22710
|
std::map<LogicalTypeId, StrpTimeFormat> date_format = {{LogicalTypeId::DATE, {}}, {LogicalTypeId::TIMESTAMP, {}}};
|
|
22711
|
+
//! The date format to use for writing (if any is specified)
|
|
22712
|
+
std::map<LogicalTypeId, StrfTimeFormat> write_date_format = {{LogicalTypeId::DATE, {}},
|
|
22713
|
+
{LogicalTypeId::TIMESTAMP, {}}};
|
|
22660
22714
|
//! Whether or not a type format is specified
|
|
22661
22715
|
std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
|
|
22662
22716
|
|
|
@@ -22671,6 +22725,7 @@ struct BufferedCSVReaderOptions {
|
|
|
22671
22725
|
void SetReadOption(const string &loption, const Value &value, vector<string> &expected_names);
|
|
22672
22726
|
|
|
22673
22727
|
void SetWriteOption(const string &loption, const Value &value);
|
|
22728
|
+
void SetDateFormat(LogicalTypeId type, const string &format, bool read_format);
|
|
22674
22729
|
|
|
22675
22730
|
std::string ToString() const;
|
|
22676
22731
|
};
|
|
@@ -22851,29 +22906,286 @@ public:
|
|
|
22851
22906
|
|
|
22852
22907
|
namespace duckdb {
|
|
22853
22908
|
|
|
22854
|
-
class IsNullFilter : public TableFilter {
|
|
22909
|
+
class IsNullFilter : public TableFilter {
|
|
22910
|
+
public:
|
|
22911
|
+
IsNullFilter();
|
|
22912
|
+
|
|
22913
|
+
public:
|
|
22914
|
+
FilterPropagateResult CheckStatistics(BaseStatistics &stats) override;
|
|
22915
|
+
string ToString(const string &column_name) override;
|
|
22916
|
+
};
|
|
22917
|
+
|
|
22918
|
+
class IsNotNullFilter : public TableFilter {
|
|
22919
|
+
public:
|
|
22920
|
+
IsNotNullFilter();
|
|
22921
|
+
|
|
22922
|
+
public:
|
|
22923
|
+
FilterPropagateResult CheckStatistics(BaseStatistics &stats) override;
|
|
22924
|
+
string ToString(const string &column_name) override;
|
|
22925
|
+
};
|
|
22926
|
+
|
|
22927
|
+
} // namespace duckdb
|
|
22928
|
+
//===----------------------------------------------------------------------===//
|
|
22929
|
+
// DuckDB
|
|
22930
|
+
//
|
|
22931
|
+
// duckdb/common/compressed_file_system.hpp
|
|
22932
|
+
//
|
|
22933
|
+
//
|
|
22934
|
+
//===----------------------------------------------------------------------===//
|
|
22935
|
+
|
|
22936
|
+
|
|
22937
|
+
|
|
22938
|
+
|
|
22939
|
+
|
|
22940
|
+
|
|
22941
|
+
namespace duckdb {
|
|
22942
|
+
class CompressedFile;
|
|
22943
|
+
|
|
22944
|
+
struct StreamData {
|
|
22945
|
+
// various buffers & pointers
|
|
22946
|
+
bool write = false;
|
|
22947
|
+
unique_ptr<data_t[]> in_buff;
|
|
22948
|
+
unique_ptr<data_t[]> out_buff;
|
|
22949
|
+
data_ptr_t out_buff_start = nullptr;
|
|
22950
|
+
data_ptr_t out_buff_end = nullptr;
|
|
22951
|
+
data_ptr_t in_buff_start = nullptr;
|
|
22952
|
+
data_ptr_t in_buff_end = nullptr;
|
|
22953
|
+
|
|
22954
|
+
idx_t in_buf_size = 0;
|
|
22955
|
+
idx_t out_buf_size = 0;
|
|
22956
|
+
};
|
|
22957
|
+
|
|
22958
|
+
struct StreamWrapper {
|
|
22959
|
+
DUCKDB_API virtual ~StreamWrapper();
|
|
22960
|
+
|
|
22961
|
+
DUCKDB_API virtual void Initialize(CompressedFile &file, bool write) = 0;
|
|
22962
|
+
DUCKDB_API virtual bool Read(StreamData &stream_data) = 0;
|
|
22963
|
+
DUCKDB_API virtual void Write(CompressedFile &file, StreamData &stream_data, data_ptr_t buffer,
|
|
22964
|
+
int64_t nr_bytes) = 0;
|
|
22965
|
+
DUCKDB_API virtual void Close() = 0;
|
|
22966
|
+
};
|
|
22967
|
+
|
|
22968
|
+
class CompressedFileSystem : public FileSystem {
|
|
22969
|
+
public:
|
|
22970
|
+
DUCKDB_API int64_t Read(FileHandle &handle, void *buffer, int64_t nr_bytes) override;
|
|
22971
|
+
DUCKDB_API int64_t Write(FileHandle &handle, void *buffer, int64_t nr_bytes) override;
|
|
22972
|
+
|
|
22973
|
+
DUCKDB_API void Reset(FileHandle &handle) override;
|
|
22974
|
+
|
|
22975
|
+
DUCKDB_API int64_t GetFileSize(FileHandle &handle) override;
|
|
22976
|
+
|
|
22977
|
+
DUCKDB_API bool OnDiskFile(FileHandle &handle) override;
|
|
22978
|
+
DUCKDB_API bool CanSeek() override;
|
|
22979
|
+
|
|
22980
|
+
DUCKDB_API virtual unique_ptr<StreamWrapper> CreateStream() = 0;
|
|
22981
|
+
DUCKDB_API virtual idx_t InBufferSize() = 0;
|
|
22982
|
+
DUCKDB_API virtual idx_t OutBufferSize() = 0;
|
|
22983
|
+
};
|
|
22984
|
+
|
|
22985
|
+
class CompressedFile : public FileHandle {
|
|
22986
|
+
public:
|
|
22987
|
+
DUCKDB_API CompressedFile(CompressedFileSystem &fs, unique_ptr<FileHandle> child_handle_p, const string &path);
|
|
22988
|
+
DUCKDB_API virtual ~CompressedFile() override;
|
|
22989
|
+
|
|
22990
|
+
CompressedFileSystem &compressed_fs;
|
|
22991
|
+
unique_ptr<FileHandle> child_handle;
|
|
22992
|
+
//! Whether the file is opened for reading or for writing
|
|
22993
|
+
bool write = false;
|
|
22994
|
+
StreamData stream_data;
|
|
22995
|
+
|
|
22996
|
+
public:
|
|
22997
|
+
DUCKDB_API void Initialize(bool write);
|
|
22998
|
+
DUCKDB_API int64_t ReadData(void *buffer, int64_t nr_bytes);
|
|
22999
|
+
DUCKDB_API int64_t WriteData(data_ptr_t buffer, int64_t nr_bytes);
|
|
23000
|
+
DUCKDB_API void Close() override;
|
|
23001
|
+
|
|
23002
|
+
private:
|
|
23003
|
+
unique_ptr<StreamWrapper> stream_wrapper;
|
|
23004
|
+
};
|
|
23005
|
+
|
|
23006
|
+
} // namespace duckdb
|
|
23007
|
+
//===----------------------------------------------------------------------===//
|
|
23008
|
+
// DuckDB
|
|
23009
|
+
//
|
|
23010
|
+
// duckdb/parser/expression/between_expression.hpp
|
|
23011
|
+
//
|
|
23012
|
+
//
|
|
23013
|
+
//===----------------------------------------------------------------------===//
|
|
23014
|
+
|
|
23015
|
+
|
|
23016
|
+
|
|
23017
|
+
|
|
23018
|
+
|
|
23019
|
+
namespace duckdb {
|
|
23020
|
+
|
|
23021
|
+
class BetweenExpression : public ParsedExpression {
|
|
23022
|
+
public:
|
|
23023
|
+
DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
|
|
23024
|
+
unique_ptr<ParsedExpression> upper);
|
|
23025
|
+
|
|
23026
|
+
unique_ptr<ParsedExpression> input;
|
|
23027
|
+
unique_ptr<ParsedExpression> lower;
|
|
23028
|
+
unique_ptr<ParsedExpression> upper;
|
|
23029
|
+
|
|
23030
|
+
public:
|
|
23031
|
+
string ToString() const override;
|
|
23032
|
+
|
|
23033
|
+
static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
|
|
23034
|
+
|
|
23035
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23036
|
+
|
|
23037
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23038
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23039
|
+
|
|
23040
|
+
public:
|
|
23041
|
+
template <class T, class BASE>
|
|
23042
|
+
static string ToString(const T &entry) {
|
|
23043
|
+
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
23044
|
+
}
|
|
23045
|
+
};
|
|
23046
|
+
} // namespace duckdb
|
|
23047
|
+
|
|
23048
|
+
|
|
23049
|
+
//===----------------------------------------------------------------------===//
|
|
23050
|
+
// DuckDB
|
|
23051
|
+
//
|
|
23052
|
+
// duckdb/parser/expression/case_expression.hpp
|
|
23053
|
+
//
|
|
23054
|
+
//
|
|
23055
|
+
//===----------------------------------------------------------------------===//
|
|
23056
|
+
|
|
23057
|
+
|
|
23058
|
+
|
|
23059
|
+
|
|
23060
|
+
|
|
23061
|
+
|
|
23062
|
+
namespace duckdb {
|
|
23063
|
+
|
|
23064
|
+
struct CaseCheck {
|
|
23065
|
+
unique_ptr<ParsedExpression> when_expr;
|
|
23066
|
+
unique_ptr<ParsedExpression> then_expr;
|
|
23067
|
+
};
|
|
23068
|
+
|
|
23069
|
+
//! The CaseExpression represents a CASE expression in the query
|
|
23070
|
+
class CaseExpression : public ParsedExpression {
|
|
23071
|
+
public:
|
|
23072
|
+
DUCKDB_API CaseExpression();
|
|
23073
|
+
|
|
23074
|
+
vector<CaseCheck> case_checks;
|
|
23075
|
+
unique_ptr<ParsedExpression> else_expr;
|
|
23076
|
+
|
|
23077
|
+
public:
|
|
23078
|
+
string ToString() const override;
|
|
23079
|
+
|
|
23080
|
+
static bool Equals(const CaseExpression *a, const CaseExpression *b);
|
|
23081
|
+
|
|
23082
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23083
|
+
|
|
23084
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23085
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23086
|
+
|
|
23087
|
+
public:
|
|
23088
|
+
template <class T, class BASE>
|
|
23089
|
+
static string ToString(const T &entry) {
|
|
23090
|
+
string case_str = "CASE ";
|
|
23091
|
+
for (auto &check : entry.case_checks) {
|
|
23092
|
+
case_str += " WHEN (" + check.when_expr->ToString() + ")";
|
|
23093
|
+
case_str += " THEN (" + check.then_expr->ToString() + ")";
|
|
23094
|
+
}
|
|
23095
|
+
case_str += " ELSE " + entry.else_expr->ToString();
|
|
23096
|
+
case_str += " END";
|
|
23097
|
+
return case_str;
|
|
23098
|
+
}
|
|
23099
|
+
};
|
|
23100
|
+
} // namespace duckdb
|
|
23101
|
+
|
|
23102
|
+
//===----------------------------------------------------------------------===//
|
|
23103
|
+
// DuckDB
|
|
23104
|
+
//
|
|
23105
|
+
// duckdb/parser/expression/cast_expression.hpp
|
|
23106
|
+
//
|
|
23107
|
+
//
|
|
23108
|
+
//===----------------------------------------------------------------------===//
|
|
23109
|
+
|
|
23110
|
+
|
|
23111
|
+
|
|
23112
|
+
|
|
23113
|
+
|
|
23114
|
+
|
|
23115
|
+
namespace duckdb {
|
|
23116
|
+
|
|
23117
|
+
//! CastExpression represents a type cast from one SQL type to another SQL type
|
|
23118
|
+
class CastExpression : public ParsedExpression {
|
|
23119
|
+
public:
|
|
23120
|
+
DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
|
|
23121
|
+
|
|
23122
|
+
//! The child of the cast expression
|
|
23123
|
+
unique_ptr<ParsedExpression> child;
|
|
23124
|
+
//! The type to cast to
|
|
23125
|
+
LogicalType cast_type;
|
|
23126
|
+
//! Whether or not this is a try_cast expression
|
|
23127
|
+
bool try_cast;
|
|
23128
|
+
|
|
23129
|
+
public:
|
|
23130
|
+
string ToString() const override;
|
|
23131
|
+
|
|
23132
|
+
static bool Equals(const CastExpression *a, const CastExpression *b);
|
|
23133
|
+
|
|
23134
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23135
|
+
|
|
23136
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23137
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23138
|
+
|
|
23139
|
+
public:
|
|
23140
|
+
template <class T, class BASE>
|
|
23141
|
+
static string ToString(const T &entry) {
|
|
23142
|
+
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
23143
|
+
entry.cast_type.ToString() + ")";
|
|
23144
|
+
}
|
|
23145
|
+
};
|
|
23146
|
+
} // namespace duckdb
|
|
23147
|
+
|
|
23148
|
+
//===----------------------------------------------------------------------===//
|
|
23149
|
+
// DuckDB
|
|
23150
|
+
//
|
|
23151
|
+
// duckdb/parser/expression/collate_expression.hpp
|
|
23152
|
+
//
|
|
23153
|
+
//
|
|
23154
|
+
//===----------------------------------------------------------------------===//
|
|
23155
|
+
|
|
23156
|
+
|
|
23157
|
+
|
|
23158
|
+
|
|
23159
|
+
|
|
23160
|
+
namespace duckdb {
|
|
23161
|
+
|
|
23162
|
+
//! CollateExpression represents a COLLATE statement
|
|
23163
|
+
class CollateExpression : public ParsedExpression {
|
|
22855
23164
|
public:
|
|
22856
|
-
|
|
23165
|
+
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
22857
23166
|
|
|
22858
|
-
|
|
22859
|
-
|
|
22860
|
-
|
|
22861
|
-
|
|
23167
|
+
//! The child of the cast expression
|
|
23168
|
+
unique_ptr<ParsedExpression> child;
|
|
23169
|
+
//! The collation clause
|
|
23170
|
+
string collation;
|
|
22862
23171
|
|
|
22863
|
-
class IsNotNullFilter : public TableFilter {
|
|
22864
23172
|
public:
|
|
22865
|
-
|
|
23173
|
+
string ToString() const override;
|
|
22866
23174
|
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
};
|
|
23175
|
+
static bool Equals(const CollateExpression *a, const CollateExpression *b);
|
|
23176
|
+
|
|
23177
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
22871
23178
|
|
|
23179
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23180
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23181
|
+
};
|
|
22872
23182
|
} // namespace duckdb
|
|
23183
|
+
|
|
23184
|
+
|
|
22873
23185
|
//===----------------------------------------------------------------------===//
|
|
22874
23186
|
// DuckDB
|
|
22875
23187
|
//
|
|
22876
|
-
// duckdb/
|
|
23188
|
+
// duckdb/parser/expression/comparison_expression.hpp
|
|
22877
23189
|
//
|
|
22878
23190
|
//
|
|
22879
23191
|
//===----------------------------------------------------------------------===//
|
|
@@ -22882,73 +23194,35 @@ public:
|
|
|
22882
23194
|
|
|
22883
23195
|
|
|
22884
23196
|
|
|
22885
|
-
|
|
22886
23197
|
namespace duckdb {
|
|
22887
|
-
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
// various buffers & pointers
|
|
22891
|
-
bool write = false;
|
|
22892
|
-
unique_ptr<data_t[]> in_buff;
|
|
22893
|
-
unique_ptr<data_t[]> out_buff;
|
|
22894
|
-
data_ptr_t out_buff_start = nullptr;
|
|
22895
|
-
data_ptr_t out_buff_end = nullptr;
|
|
22896
|
-
data_ptr_t in_buff_start = nullptr;
|
|
22897
|
-
data_ptr_t in_buff_end = nullptr;
|
|
22898
|
-
|
|
22899
|
-
idx_t in_buf_size = 0;
|
|
22900
|
-
idx_t out_buf_size = 0;
|
|
22901
|
-
};
|
|
22902
|
-
|
|
22903
|
-
struct StreamWrapper {
|
|
22904
|
-
DUCKDB_API virtual ~StreamWrapper();
|
|
22905
|
-
|
|
22906
|
-
DUCKDB_API virtual void Initialize(CompressedFile &file, bool write) = 0;
|
|
22907
|
-
DUCKDB_API virtual bool Read(StreamData &stream_data) = 0;
|
|
22908
|
-
DUCKDB_API virtual void Write(CompressedFile &file, StreamData &stream_data, data_ptr_t buffer,
|
|
22909
|
-
int64_t nr_bytes) = 0;
|
|
22910
|
-
DUCKDB_API virtual void Close() = 0;
|
|
22911
|
-
};
|
|
22912
|
-
|
|
22913
|
-
class CompressedFileSystem : public FileSystem {
|
|
23198
|
+
//! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
|
|
23199
|
+
//! and has two children.
|
|
23200
|
+
class ComparisonExpression : public ParsedExpression {
|
|
22914
23201
|
public:
|
|
22915
|
-
DUCKDB_API
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
DUCKDB_API void Reset(FileHandle &handle) override;
|
|
23202
|
+
DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
23203
|
+
unique_ptr<ParsedExpression> right);
|
|
22919
23204
|
|
|
22920
|
-
|
|
23205
|
+
unique_ptr<ParsedExpression> left;
|
|
23206
|
+
unique_ptr<ParsedExpression> right;
|
|
22921
23207
|
|
|
22922
|
-
|
|
22923
|
-
|
|
23208
|
+
public:
|
|
23209
|
+
string ToString() const override;
|
|
22924
23210
|
|
|
22925
|
-
|
|
22926
|
-
DUCKDB_API virtual idx_t InBufferSize() = 0;
|
|
22927
|
-
DUCKDB_API virtual idx_t OutBufferSize() = 0;
|
|
22928
|
-
};
|
|
23211
|
+
static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
|
|
22929
23212
|
|
|
22930
|
-
|
|
22931
|
-
public:
|
|
22932
|
-
DUCKDB_API CompressedFile(CompressedFileSystem &fs, unique_ptr<FileHandle> child_handle_p, const string &path);
|
|
22933
|
-
DUCKDB_API virtual ~CompressedFile() override;
|
|
23213
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
22934
23214
|
|
|
22935
|
-
|
|
22936
|
-
unique_ptr<
|
|
22937
|
-
//! Whether the file is opened for reading or for writing
|
|
22938
|
-
bool write = false;
|
|
22939
|
-
StreamData stream_data;
|
|
23215
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23216
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
22940
23217
|
|
|
22941
23218
|
public:
|
|
22942
|
-
|
|
22943
|
-
|
|
22944
|
-
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
private:
|
|
22948
|
-
unique_ptr<StreamWrapper> stream_wrapper;
|
|
23219
|
+
template <class T, class BASE>
|
|
23220
|
+
static string ToString(const T &entry) {
|
|
23221
|
+
return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
|
|
23222
|
+
}
|
|
22949
23223
|
};
|
|
22950
|
-
|
|
22951
23224
|
} // namespace duckdb
|
|
23225
|
+
|
|
22952
23226
|
//===----------------------------------------------------------------------===//
|
|
22953
23227
|
// DuckDB
|
|
22954
23228
|
//
|
|
@@ -22997,10 +23271,11 @@ public:
|
|
|
22997
23271
|
}
|
|
22998
23272
|
};
|
|
22999
23273
|
} // namespace duckdb
|
|
23274
|
+
|
|
23000
23275
|
//===----------------------------------------------------------------------===//
|
|
23001
23276
|
// DuckDB
|
|
23002
23277
|
//
|
|
23003
|
-
// duckdb/parser/expression/
|
|
23278
|
+
// duckdb/parser/expression/constant_expression.hpp
|
|
23004
23279
|
//
|
|
23005
23280
|
//
|
|
23006
23281
|
//===----------------------------------------------------------------------===//
|
|
@@ -23009,32 +23284,185 @@ public:
|
|
|
23009
23284
|
|
|
23010
23285
|
|
|
23011
23286
|
|
|
23287
|
+
|
|
23012
23288
|
namespace duckdb {
|
|
23013
|
-
|
|
23289
|
+
|
|
23290
|
+
//! ConstantExpression represents a constant value in the query
|
|
23291
|
+
class ConstantExpression : public ParsedExpression {
|
|
23014
23292
|
public:
|
|
23015
|
-
DUCKDB_API
|
|
23293
|
+
DUCKDB_API explicit ConstantExpression(Value val);
|
|
23294
|
+
|
|
23295
|
+
//! The constant value referenced
|
|
23296
|
+
Value value;
|
|
23297
|
+
|
|
23298
|
+
public:
|
|
23299
|
+
string ToString() const override;
|
|
23300
|
+
|
|
23301
|
+
static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
|
|
23302
|
+
hash_t Hash() const override;
|
|
23303
|
+
|
|
23304
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23305
|
+
|
|
23306
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23307
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23308
|
+
};
|
|
23309
|
+
|
|
23310
|
+
} // namespace duckdb
|
|
23311
|
+
|
|
23312
|
+
//===----------------------------------------------------------------------===//
|
|
23313
|
+
// DuckDB
|
|
23314
|
+
//
|
|
23315
|
+
// duckdb/parser/expression/default_expression.hpp
|
|
23316
|
+
//
|
|
23317
|
+
//
|
|
23318
|
+
//===----------------------------------------------------------------------===//
|
|
23319
|
+
|
|
23320
|
+
|
|
23321
|
+
|
|
23016
23322
|
|
|
23017
|
-
|
|
23323
|
+
|
|
23324
|
+
namespace duckdb {
|
|
23325
|
+
//! Represents the default value of a column
|
|
23326
|
+
class DefaultExpression : public ParsedExpression {
|
|
23327
|
+
public:
|
|
23328
|
+
DefaultExpression();
|
|
23018
23329
|
|
|
23019
23330
|
public:
|
|
23020
23331
|
bool IsScalar() const override {
|
|
23021
23332
|
return false;
|
|
23022
23333
|
}
|
|
23023
23334
|
|
|
23024
|
-
string ToString() const override;
|
|
23335
|
+
string ToString() const override;
|
|
23336
|
+
|
|
23337
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23338
|
+
|
|
23339
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23340
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23341
|
+
};
|
|
23342
|
+
} // namespace duckdb
|
|
23343
|
+
|
|
23344
|
+
//===----------------------------------------------------------------------===//
|
|
23345
|
+
// DuckDB
|
|
23346
|
+
//
|
|
23347
|
+
// duckdb/parser/expression/function_expression.hpp
|
|
23348
|
+
//
|
|
23349
|
+
//
|
|
23350
|
+
//===----------------------------------------------------------------------===//
|
|
23351
|
+
|
|
23352
|
+
|
|
23353
|
+
|
|
23354
|
+
|
|
23355
|
+
|
|
23356
|
+
|
|
23357
|
+
|
|
23358
|
+
namespace duckdb {
|
|
23359
|
+
//! Represents a function call
|
|
23360
|
+
class FunctionExpression : public ParsedExpression {
|
|
23361
|
+
public:
|
|
23362
|
+
DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
|
|
23363
|
+
vector<unique_ptr<ParsedExpression>> children,
|
|
23364
|
+
unique_ptr<ParsedExpression> filter = nullptr,
|
|
23365
|
+
unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
|
|
23366
|
+
bool is_operator = false, bool export_state = false);
|
|
23367
|
+
DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
|
|
23368
|
+
unique_ptr<ParsedExpression> filter = nullptr,
|
|
23369
|
+
unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
|
|
23370
|
+
bool is_operator = false, bool export_state = false);
|
|
23371
|
+
|
|
23372
|
+
//! Schema of the function
|
|
23373
|
+
string schema;
|
|
23374
|
+
//! Function name
|
|
23375
|
+
string function_name;
|
|
23376
|
+
//! Whether or not the function is an operator, only used for rendering
|
|
23377
|
+
bool is_operator;
|
|
23378
|
+
//! List of arguments to the function
|
|
23379
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
23380
|
+
//! Whether or not the aggregate function is distinct, only used for aggregates
|
|
23381
|
+
bool distinct;
|
|
23382
|
+
//! Expression representing a filter, only used for aggregates
|
|
23383
|
+
unique_ptr<ParsedExpression> filter;
|
|
23384
|
+
//! Modifier representing an ORDER BY, only used for aggregates
|
|
23385
|
+
unique_ptr<OrderModifier> order_bys;
|
|
23386
|
+
//! whether this function should export its state or not
|
|
23387
|
+
bool export_state;
|
|
23388
|
+
|
|
23389
|
+
public:
|
|
23390
|
+
string ToString() const override;
|
|
23391
|
+
|
|
23392
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
23393
|
+
|
|
23394
|
+
static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
|
|
23395
|
+
hash_t Hash() const override;
|
|
23396
|
+
|
|
23397
|
+
void Serialize(FieldWriter &writer) const override;
|
|
23398
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23399
|
+
|
|
23400
|
+
void Verify() const override;
|
|
23401
|
+
|
|
23402
|
+
public:
|
|
23403
|
+
template <class T, class BASE>
|
|
23404
|
+
static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
|
|
23405
|
+
bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
|
|
23406
|
+
bool export_state = false, bool add_alias = false) {
|
|
23407
|
+
if (is_operator) {
|
|
23408
|
+
// built-in operator
|
|
23409
|
+
D_ASSERT(!distinct);
|
|
23410
|
+
if (entry.children.size() == 1) {
|
|
23411
|
+
if (StringUtil::Contains(function_name, "__postfix")) {
|
|
23412
|
+
return "(" + entry.children[0]->ToString() + ")" +
|
|
23413
|
+
StringUtil::Replace(function_name, "__postfix", "");
|
|
23414
|
+
} else {
|
|
23415
|
+
return function_name + "(" + entry.children[0]->ToString() + ")";
|
|
23416
|
+
}
|
|
23417
|
+
} else if (entry.children.size() == 2) {
|
|
23418
|
+
return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
|
|
23419
|
+
")";
|
|
23420
|
+
}
|
|
23421
|
+
}
|
|
23422
|
+
// standard function call
|
|
23423
|
+
string result = schema.empty() ? function_name : schema + "." + function_name;
|
|
23424
|
+
result += "(";
|
|
23425
|
+
if (distinct) {
|
|
23426
|
+
result += "DISTINCT ";
|
|
23427
|
+
}
|
|
23428
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
|
|
23429
|
+
return child->alias.empty() || !add_alias
|
|
23430
|
+
? child->ToString()
|
|
23431
|
+
: KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
|
|
23432
|
+
});
|
|
23433
|
+
// ordered aggregate
|
|
23434
|
+
if (order_bys && !order_bys->orders.empty()) {
|
|
23435
|
+
if (entry.children.empty()) {
|
|
23436
|
+
result += ") WITHIN GROUP (";
|
|
23437
|
+
}
|
|
23438
|
+
result += " ORDER BY ";
|
|
23439
|
+
for (idx_t i = 0; i < order_bys->orders.size(); i++) {
|
|
23440
|
+
if (i > 0) {
|
|
23441
|
+
result += ", ";
|
|
23442
|
+
}
|
|
23443
|
+
result += order_bys->orders[i].ToString();
|
|
23444
|
+
}
|
|
23445
|
+
}
|
|
23446
|
+
result += ")";
|
|
23447
|
+
|
|
23448
|
+
// filtered aggregate
|
|
23449
|
+
if (filter) {
|
|
23450
|
+
result += " FILTER (WHERE " + filter->ToString() + ")";
|
|
23451
|
+
}
|
|
23025
23452
|
|
|
23026
|
-
|
|
23027
|
-
|
|
23028
|
-
|
|
23453
|
+
if (export_state) {
|
|
23454
|
+
result += " EXPORT_STATE";
|
|
23455
|
+
}
|
|
23029
23456
|
|
|
23030
|
-
|
|
23031
|
-
|
|
23457
|
+
return result;
|
|
23458
|
+
}
|
|
23032
23459
|
};
|
|
23033
23460
|
} // namespace duckdb
|
|
23461
|
+
|
|
23034
23462
|
//===----------------------------------------------------------------------===//
|
|
23035
23463
|
// DuckDB
|
|
23036
23464
|
//
|
|
23037
|
-
// duckdb/parser/expression/
|
|
23465
|
+
// duckdb/parser/expression/lambda_expression.hpp
|
|
23038
23466
|
//
|
|
23039
23467
|
//
|
|
23040
23468
|
//===----------------------------------------------------------------------===//
|
|
@@ -23046,29 +23474,31 @@ public:
|
|
|
23046
23474
|
|
|
23047
23475
|
namespace duckdb {
|
|
23048
23476
|
|
|
23049
|
-
//!
|
|
23050
|
-
|
|
23477
|
+
//! LambdaExpression represents either:
|
|
23478
|
+
//! 1. A lambda operator that can be used for e.g. mapping an expression to a list
|
|
23479
|
+
//! 2. An OperatorExpression with the "->" operator
|
|
23480
|
+
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
23481
|
+
class LambdaExpression : public ParsedExpression {
|
|
23051
23482
|
public:
|
|
23052
|
-
|
|
23483
|
+
LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
|
|
23053
23484
|
|
|
23054
|
-
|
|
23055
|
-
|
|
23056
|
-
//! List of columns to exclude from the STAR expression
|
|
23057
|
-
case_insensitive_set_t exclude_list;
|
|
23058
|
-
//! List of columns to replace with another expression
|
|
23059
|
-
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
23485
|
+
unique_ptr<ParsedExpression> lhs;
|
|
23486
|
+
unique_ptr<ParsedExpression> rhs;
|
|
23060
23487
|
|
|
23061
23488
|
public:
|
|
23062
23489
|
string ToString() const override;
|
|
23063
23490
|
|
|
23064
|
-
static bool Equals(const
|
|
23491
|
+
static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
|
|
23492
|
+
hash_t Hash() const override;
|
|
23065
23493
|
|
|
23066
23494
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23067
23495
|
|
|
23068
23496
|
void Serialize(FieldWriter &writer) const override;
|
|
23069
23497
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23070
23498
|
};
|
|
23499
|
+
|
|
23071
23500
|
} // namespace duckdb
|
|
23501
|
+
|
|
23072
23502
|
//===----------------------------------------------------------------------===//
|
|
23073
23503
|
// DuckDB
|
|
23074
23504
|
//
|
|
@@ -23169,91 +23599,7 @@ public:
|
|
|
23169
23599
|
};
|
|
23170
23600
|
|
|
23171
23601
|
} // namespace duckdb
|
|
23172
|
-
//===----------------------------------------------------------------------===//
|
|
23173
|
-
// DuckDB
|
|
23174
|
-
//
|
|
23175
|
-
// duckdb/parser/expression/constant_expression.hpp
|
|
23176
|
-
//
|
|
23177
|
-
//
|
|
23178
|
-
//===----------------------------------------------------------------------===//
|
|
23179
|
-
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
namespace duckdb {
|
|
23186
|
-
|
|
23187
|
-
//! ConstantExpression represents a constant value in the query
|
|
23188
|
-
class ConstantExpression : public ParsedExpression {
|
|
23189
|
-
public:
|
|
23190
|
-
DUCKDB_API explicit ConstantExpression(Value val);
|
|
23191
|
-
|
|
23192
|
-
//! The constant value referenced
|
|
23193
|
-
Value value;
|
|
23194
|
-
|
|
23195
|
-
public:
|
|
23196
|
-
string ToString() const override;
|
|
23197
|
-
|
|
23198
|
-
static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
|
|
23199
|
-
hash_t Hash() const override;
|
|
23200
|
-
|
|
23201
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23202
|
-
|
|
23203
|
-
void Serialize(FieldWriter &writer) const override;
|
|
23204
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23205
|
-
};
|
|
23206
|
-
|
|
23207
|
-
} // namespace duckdb
|
|
23208
|
-
//===----------------------------------------------------------------------===//
|
|
23209
|
-
// DuckDB
|
|
23210
|
-
//
|
|
23211
|
-
// duckdb/parser/expression/subquery_expression.hpp
|
|
23212
|
-
//
|
|
23213
|
-
//
|
|
23214
|
-
//===----------------------------------------------------------------------===//
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
23602
|
|
|
23222
|
-
namespace duckdb {
|
|
23223
|
-
|
|
23224
|
-
//! Represents a subquery
|
|
23225
|
-
class SubqueryExpression : public ParsedExpression {
|
|
23226
|
-
public:
|
|
23227
|
-
SubqueryExpression();
|
|
23228
|
-
|
|
23229
|
-
//! The actual subquery
|
|
23230
|
-
unique_ptr<SelectStatement> subquery;
|
|
23231
|
-
//! The subquery type
|
|
23232
|
-
SubqueryType subquery_type;
|
|
23233
|
-
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
23234
|
-
//! subquery)
|
|
23235
|
-
unique_ptr<ParsedExpression> child;
|
|
23236
|
-
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
23237
|
-
ExpressionType comparison_type;
|
|
23238
|
-
|
|
23239
|
-
public:
|
|
23240
|
-
bool HasSubquery() const override {
|
|
23241
|
-
return true;
|
|
23242
|
-
}
|
|
23243
|
-
bool IsScalar() const override {
|
|
23244
|
-
return false;
|
|
23245
|
-
}
|
|
23246
|
-
|
|
23247
|
-
string ToString() const override;
|
|
23248
|
-
|
|
23249
|
-
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
23250
|
-
|
|
23251
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23252
|
-
|
|
23253
|
-
void Serialize(FieldWriter &writer) const override;
|
|
23254
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23255
|
-
};
|
|
23256
|
-
} // namespace duckdb
|
|
23257
23603
|
//===----------------------------------------------------------------------===//
|
|
23258
23604
|
// DuckDB
|
|
23259
23605
|
//
|
|
@@ -23290,50 +23636,11 @@ public:
|
|
|
23290
23636
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23291
23637
|
};
|
|
23292
23638
|
} // namespace duckdb
|
|
23293
|
-
//===----------------------------------------------------------------------===//
|
|
23294
|
-
// DuckDB
|
|
23295
|
-
//
|
|
23296
|
-
// duckdb/parser/expression/between_expression.hpp
|
|
23297
|
-
//
|
|
23298
|
-
//
|
|
23299
|
-
//===----------------------------------------------------------------------===//
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
namespace duckdb {
|
|
23306
|
-
|
|
23307
|
-
class BetweenExpression : public ParsedExpression {
|
|
23308
|
-
public:
|
|
23309
|
-
DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
|
|
23310
|
-
unique_ptr<ParsedExpression> upper);
|
|
23311
|
-
|
|
23312
|
-
unique_ptr<ParsedExpression> input;
|
|
23313
|
-
unique_ptr<ParsedExpression> lower;
|
|
23314
|
-
unique_ptr<ParsedExpression> upper;
|
|
23315
|
-
|
|
23316
|
-
public:
|
|
23317
|
-
string ToString() const override;
|
|
23318
|
-
|
|
23319
|
-
static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
|
|
23320
|
-
|
|
23321
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23322
23639
|
|
|
23323
|
-
void Serialize(FieldWriter &writer) const override;
|
|
23324
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23325
|
-
|
|
23326
|
-
public:
|
|
23327
|
-
template <class T, class BASE>
|
|
23328
|
-
static string ToString(const T &entry) {
|
|
23329
|
-
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
23330
|
-
}
|
|
23331
|
-
};
|
|
23332
|
-
} // namespace duckdb
|
|
23333
23640
|
//===----------------------------------------------------------------------===//
|
|
23334
23641
|
// DuckDB
|
|
23335
23642
|
//
|
|
23336
|
-
// duckdb/parser/expression/
|
|
23643
|
+
// duckdb/parser/expression/positional_reference_expression.hpp
|
|
23337
23644
|
//
|
|
23338
23645
|
//
|
|
23339
23646
|
//===----------------------------------------------------------------------===//
|
|
@@ -23343,10 +23650,11 @@ public:
|
|
|
23343
23650
|
|
|
23344
23651
|
|
|
23345
23652
|
namespace duckdb {
|
|
23346
|
-
|
|
23347
|
-
class DefaultExpression : public ParsedExpression {
|
|
23653
|
+
class PositionalReferenceExpression : public ParsedExpression {
|
|
23348
23654
|
public:
|
|
23349
|
-
|
|
23655
|
+
DUCKDB_API PositionalReferenceExpression(idx_t index);
|
|
23656
|
+
|
|
23657
|
+
idx_t index;
|
|
23350
23658
|
|
|
23351
23659
|
public:
|
|
23352
23660
|
bool IsScalar() const override {
|
|
@@ -23355,71 +23663,19 @@ public:
|
|
|
23355
23663
|
|
|
23356
23664
|
string ToString() const override;
|
|
23357
23665
|
|
|
23666
|
+
static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
|
|
23358
23667
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23668
|
+
hash_t Hash() const override;
|
|
23359
23669
|
|
|
23360
23670
|
void Serialize(FieldWriter &writer) const override;
|
|
23361
23671
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23362
23672
|
};
|
|
23363
23673
|
} // namespace duckdb
|
|
23364
23674
|
|
|
23365
|
-
|
|
23366
|
-
//===----------------------------------------------------------------------===//
|
|
23367
|
-
// DuckDB
|
|
23368
|
-
//
|
|
23369
|
-
// duckdb/parser/expression/case_expression.hpp
|
|
23370
|
-
//
|
|
23371
|
-
//
|
|
23372
|
-
//===----------------------------------------------------------------------===//
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
namespace duckdb {
|
|
23380
|
-
|
|
23381
|
-
struct CaseCheck {
|
|
23382
|
-
unique_ptr<ParsedExpression> when_expr;
|
|
23383
|
-
unique_ptr<ParsedExpression> then_expr;
|
|
23384
|
-
};
|
|
23385
|
-
|
|
23386
|
-
//! The CaseExpression represents a CASE expression in the query
|
|
23387
|
-
class CaseExpression : public ParsedExpression {
|
|
23388
|
-
public:
|
|
23389
|
-
DUCKDB_API CaseExpression();
|
|
23390
|
-
|
|
23391
|
-
vector<CaseCheck> case_checks;
|
|
23392
|
-
unique_ptr<ParsedExpression> else_expr;
|
|
23393
|
-
|
|
23394
|
-
public:
|
|
23395
|
-
string ToString() const override;
|
|
23396
|
-
|
|
23397
|
-
static bool Equals(const CaseExpression *a, const CaseExpression *b);
|
|
23398
|
-
|
|
23399
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23400
|
-
|
|
23401
|
-
void Serialize(FieldWriter &writer) const override;
|
|
23402
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23403
|
-
|
|
23404
|
-
public:
|
|
23405
|
-
template <class T, class BASE>
|
|
23406
|
-
static string ToString(const T &entry) {
|
|
23407
|
-
string case_str = "CASE ";
|
|
23408
|
-
for (auto &check : entry.case_checks) {
|
|
23409
|
-
case_str += " WHEN (" + check.when_expr->ToString() + ")";
|
|
23410
|
-
case_str += " THEN (" + check.then_expr->ToString() + ")";
|
|
23411
|
-
}
|
|
23412
|
-
case_str += " ELSE " + entry.else_expr->ToString();
|
|
23413
|
-
case_str += " END";
|
|
23414
|
-
return case_str;
|
|
23415
|
-
}
|
|
23416
|
-
};
|
|
23417
|
-
} // namespace duckdb
|
|
23418
|
-
|
|
23419
23675
|
//===----------------------------------------------------------------------===//
|
|
23420
23676
|
// DuckDB
|
|
23421
23677
|
//
|
|
23422
|
-
// duckdb/parser/expression/
|
|
23678
|
+
// duckdb/parser/expression/star_expression.hpp
|
|
23423
23679
|
//
|
|
23424
23680
|
//
|
|
23425
23681
|
//===----------------------------------------------------------------------===//
|
|
@@ -23431,41 +23687,34 @@ public:
|
|
|
23431
23687
|
|
|
23432
23688
|
namespace duckdb {
|
|
23433
23689
|
|
|
23434
|
-
//!
|
|
23435
|
-
class
|
|
23690
|
+
//! Represents a * expression in the SELECT clause
|
|
23691
|
+
class StarExpression : public ParsedExpression {
|
|
23436
23692
|
public:
|
|
23437
|
-
|
|
23693
|
+
StarExpression(string relation_name = string());
|
|
23438
23694
|
|
|
23439
|
-
//! The
|
|
23440
|
-
|
|
23441
|
-
//!
|
|
23442
|
-
|
|
23443
|
-
//!
|
|
23444
|
-
|
|
23695
|
+
//! The relation name in case of tbl.*, or empty if this is a normal *
|
|
23696
|
+
string relation_name;
|
|
23697
|
+
//! List of columns to exclude from the STAR expression
|
|
23698
|
+
case_insensitive_set_t exclude_list;
|
|
23699
|
+
//! List of columns to replace with another expression
|
|
23700
|
+
case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
|
|
23445
23701
|
|
|
23446
23702
|
public:
|
|
23447
23703
|
string ToString() const override;
|
|
23448
23704
|
|
|
23449
|
-
static bool Equals(const
|
|
23705
|
+
static bool Equals(const StarExpression *a, const StarExpression *b);
|
|
23450
23706
|
|
|
23451
23707
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23452
23708
|
|
|
23453
23709
|
void Serialize(FieldWriter &writer) const override;
|
|
23454
23710
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
23455
|
-
|
|
23456
|
-
public:
|
|
23457
|
-
template <class T, class BASE>
|
|
23458
|
-
static string ToString(const T &entry) {
|
|
23459
|
-
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
23460
|
-
entry.cast_type.ToString() + ")";
|
|
23461
|
-
}
|
|
23462
23711
|
};
|
|
23463
23712
|
} // namespace duckdb
|
|
23464
23713
|
|
|
23465
23714
|
//===----------------------------------------------------------------------===//
|
|
23466
23715
|
// DuckDB
|
|
23467
23716
|
//
|
|
23468
|
-
// duckdb/parser/expression/
|
|
23717
|
+
// duckdb/parser/expression/subquery_expression.hpp
|
|
23469
23718
|
//
|
|
23470
23719
|
//
|
|
23471
23720
|
//===----------------------------------------------------------------------===//
|
|
@@ -23474,22 +23723,36 @@ public:
|
|
|
23474
23723
|
|
|
23475
23724
|
|
|
23476
23725
|
|
|
23726
|
+
|
|
23727
|
+
|
|
23477
23728
|
namespace duckdb {
|
|
23478
23729
|
|
|
23479
|
-
//!
|
|
23480
|
-
class
|
|
23730
|
+
//! Represents a subquery
|
|
23731
|
+
class SubqueryExpression : public ParsedExpression {
|
|
23481
23732
|
public:
|
|
23482
|
-
|
|
23733
|
+
SubqueryExpression();
|
|
23483
23734
|
|
|
23484
|
-
//! The
|
|
23735
|
+
//! The actual subquery
|
|
23736
|
+
unique_ptr<SelectStatement> subquery;
|
|
23737
|
+
//! The subquery type
|
|
23738
|
+
SubqueryType subquery_type;
|
|
23739
|
+
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
23740
|
+
//! subquery)
|
|
23485
23741
|
unique_ptr<ParsedExpression> child;
|
|
23486
|
-
//! The
|
|
23487
|
-
|
|
23742
|
+
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
23743
|
+
ExpressionType comparison_type;
|
|
23488
23744
|
|
|
23489
23745
|
public:
|
|
23746
|
+
bool HasSubquery() const override {
|
|
23747
|
+
return true;
|
|
23748
|
+
}
|
|
23749
|
+
bool IsScalar() const override {
|
|
23750
|
+
return false;
|
|
23751
|
+
}
|
|
23752
|
+
|
|
23490
23753
|
string ToString() const override;
|
|
23491
23754
|
|
|
23492
|
-
static bool Equals(const
|
|
23755
|
+
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
23493
23756
|
|
|
23494
23757
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
23495
23758
|
|
|
@@ -23502,7 +23765,7 @@ public:
|
|
|
23502
23765
|
//===----------------------------------------------------------------------===//
|
|
23503
23766
|
// DuckDB
|
|
23504
23767
|
//
|
|
23505
|
-
// duckdb/parser/
|
|
23768
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23506
23769
|
//
|
|
23507
23770
|
//
|
|
23508
23771
|
//===----------------------------------------------------------------------===//
|
|
@@ -23512,41 +23775,27 @@ public:
|
|
|
23512
23775
|
|
|
23513
23776
|
|
|
23514
23777
|
namespace duckdb {
|
|
23515
|
-
//! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
|
|
23516
|
-
//! and has two children.
|
|
23517
|
-
class ComparisonExpression : public ParsedExpression {
|
|
23518
|
-
public:
|
|
23519
|
-
DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
23520
|
-
unique_ptr<ParsedExpression> right);
|
|
23521
|
-
|
|
23522
|
-
unique_ptr<ParsedExpression> left;
|
|
23523
|
-
unique_ptr<ParsedExpression> right;
|
|
23524
|
-
|
|
23525
|
-
public:
|
|
23526
|
-
string ToString() const override;
|
|
23527
23778
|
|
|
23528
|
-
|
|
23529
|
-
|
|
23530
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23779
|
+
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
23531
23780
|
|
|
23532
|
-
|
|
23533
|
-
|
|
23781
|
+
struct LoadInfo : public ParseInfo {
|
|
23782
|
+
std::string filename;
|
|
23783
|
+
LoadType load_type;
|
|
23534
23784
|
|
|
23535
23785
|
public:
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
|
|
23786
|
+
unique_ptr<LoadInfo> Copy() const {
|
|
23787
|
+
auto result = make_unique<LoadInfo>();
|
|
23788
|
+
result->filename = filename;
|
|
23789
|
+
result->load_type = load_type;
|
|
23790
|
+
return result;
|
|
23539
23791
|
}
|
|
23540
23792
|
};
|
|
23541
|
-
} // namespace duckdb
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
|
|
23545
23793
|
|
|
23794
|
+
} // namespace duckdb
|
|
23546
23795
|
//===----------------------------------------------------------------------===//
|
|
23547
23796
|
// DuckDB
|
|
23548
23797
|
//
|
|
23549
|
-
// duckdb/parser/
|
|
23798
|
+
// duckdb/parser/parsed_data/create_type_info.hpp
|
|
23550
23799
|
//
|
|
23551
23800
|
//
|
|
23552
23801
|
//===----------------------------------------------------------------------===//
|
|
@@ -23557,114 +23806,47 @@ public:
|
|
|
23557
23806
|
|
|
23558
23807
|
|
|
23559
23808
|
|
|
23809
|
+
|
|
23560
23810
|
namespace duckdb {
|
|
23561
|
-
//! Represents a function call
|
|
23562
|
-
class FunctionExpression : public ParsedExpression {
|
|
23563
|
-
public:
|
|
23564
|
-
DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
|
|
23565
|
-
vector<unique_ptr<ParsedExpression>> children,
|
|
23566
|
-
unique_ptr<ParsedExpression> filter = nullptr,
|
|
23567
|
-
unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
|
|
23568
|
-
bool is_operator = false, bool export_state = false);
|
|
23569
|
-
DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
|
|
23570
|
-
unique_ptr<ParsedExpression> filter = nullptr,
|
|
23571
|
-
unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
|
|
23572
|
-
bool is_operator = false, bool export_state = false);
|
|
23573
23811
|
|
|
23574
|
-
|
|
23575
|
-
string schema;
|
|
23576
|
-
//! Function name
|
|
23577
|
-
string function_name;
|
|
23578
|
-
//! Whether or not the function is an operator, only used for rendering
|
|
23579
|
-
bool is_operator;
|
|
23580
|
-
//! List of arguments to the function
|
|
23581
|
-
vector<unique_ptr<ParsedExpression>> children;
|
|
23582
|
-
//! Whether or not the aggregate function is distinct, only used for aggregates
|
|
23583
|
-
bool distinct;
|
|
23584
|
-
//! Expression representing a filter, only used for aggregates
|
|
23585
|
-
unique_ptr<ParsedExpression> filter;
|
|
23586
|
-
//! Modifier representing an ORDER BY, only used for aggregates
|
|
23587
|
-
unique_ptr<OrderModifier> order_bys;
|
|
23588
|
-
//! whether this function should export its state or not
|
|
23589
|
-
bool export_state;
|
|
23812
|
+
struct CreateTypeInfo : public CreateInfo {
|
|
23590
23813
|
|
|
23591
|
-
|
|
23592
|
-
|
|
23814
|
+
CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
|
|
23815
|
+
}
|
|
23593
23816
|
|
|
23594
|
-
|
|
23817
|
+
//! Name of the Type
|
|
23818
|
+
string name;
|
|
23819
|
+
//! Logical Type
|
|
23820
|
+
LogicalType type;
|
|
23595
23821
|
|
|
23596
|
-
|
|
23597
|
-
|
|
23822
|
+
public:
|
|
23823
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23824
|
+
auto result = make_unique<CreateTypeInfo>();
|
|
23825
|
+
CopyProperties(*result);
|
|
23826
|
+
result->name = name;
|
|
23827
|
+
result->type = type;
|
|
23828
|
+
return move(result);
|
|
23829
|
+
}
|
|
23830
|
+
};
|
|
23598
23831
|
|
|
23599
|
-
|
|
23600
|
-
|
|
23832
|
+
} // namespace duckdb
|
|
23833
|
+
//===----------------------------------------------------------------------===//
|
|
23834
|
+
// DuckDB
|
|
23835
|
+
//
|
|
23836
|
+
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
23837
|
+
//
|
|
23838
|
+
//
|
|
23839
|
+
//===----------------------------------------------------------------------===//
|
|
23601
23840
|
|
|
23602
|
-
void Verify() const override;
|
|
23603
23841
|
|
|
23604
|
-
public:
|
|
23605
|
-
template <class T, class BASE>
|
|
23606
|
-
static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
|
|
23607
|
-
bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
|
|
23608
|
-
bool export_state = false, bool add_alias = false) {
|
|
23609
|
-
if (is_operator) {
|
|
23610
|
-
// built-in operator
|
|
23611
|
-
D_ASSERT(!distinct);
|
|
23612
|
-
if (entry.children.size() == 1) {
|
|
23613
|
-
if (StringUtil::Contains(function_name, "__postfix")) {
|
|
23614
|
-
return "(" + entry.children[0]->ToString() + ")" +
|
|
23615
|
-
StringUtil::Replace(function_name, "__postfix", "");
|
|
23616
|
-
} else {
|
|
23617
|
-
return function_name + "(" + entry.children[0]->ToString() + ")";
|
|
23618
|
-
}
|
|
23619
|
-
} else if (entry.children.size() == 2) {
|
|
23620
|
-
return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
|
|
23621
|
-
")";
|
|
23622
|
-
}
|
|
23623
|
-
}
|
|
23624
|
-
// standard function call
|
|
23625
|
-
string result = schema.empty() ? function_name : schema + "." + function_name;
|
|
23626
|
-
result += "(";
|
|
23627
|
-
if (distinct) {
|
|
23628
|
-
result += "DISTINCT ";
|
|
23629
|
-
}
|
|
23630
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
|
|
23631
|
-
return child->alias.empty() || !add_alias
|
|
23632
|
-
? child->ToString()
|
|
23633
|
-
: KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
|
|
23634
|
-
});
|
|
23635
|
-
// ordered aggregate
|
|
23636
|
-
if (order_bys && !order_bys->orders.empty()) {
|
|
23637
|
-
if (entry.children.empty()) {
|
|
23638
|
-
result += ") WITHIN GROUP (";
|
|
23639
|
-
}
|
|
23640
|
-
result += " ORDER BY ";
|
|
23641
|
-
for (idx_t i = 0; i < order_bys->orders.size(); i++) {
|
|
23642
|
-
if (i > 0) {
|
|
23643
|
-
result += ", ";
|
|
23644
|
-
}
|
|
23645
|
-
result += order_bys->orders[i].ToString();
|
|
23646
|
-
}
|
|
23647
|
-
}
|
|
23648
|
-
result += ")";
|
|
23649
23842
|
|
|
23650
|
-
// filtered aggregate
|
|
23651
|
-
if (filter) {
|
|
23652
|
-
result += " FILTER (WHERE " + filter->ToString() + ")";
|
|
23653
|
-
}
|
|
23654
23843
|
|
|
23655
|
-
if (export_state) {
|
|
23656
|
-
result += " EXPORT_STATE";
|
|
23657
|
-
}
|
|
23658
23844
|
|
|
23659
|
-
return result;
|
|
23660
|
-
}
|
|
23661
|
-
};
|
|
23662
|
-
} // namespace duckdb
|
|
23663
23845
|
|
|
23664
23846
|
//===----------------------------------------------------------------------===//
|
|
23665
23847
|
// DuckDB
|
|
23666
23848
|
//
|
|
23667
|
-
// duckdb/parser/
|
|
23849
|
+
// duckdb/parser/tableref/basetableref.hpp
|
|
23668
23850
|
//
|
|
23669
23851
|
//
|
|
23670
23852
|
//===----------------------------------------------------------------------===//
|
|
@@ -23675,42 +23857,71 @@ public:
|
|
|
23675
23857
|
|
|
23676
23858
|
|
|
23677
23859
|
namespace duckdb {
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
//! 1. A lambda operator that can be used for e.g. mapping an expression to a list
|
|
23681
|
-
//! 2. An OperatorExpression with the "->" operator
|
|
23682
|
-
//! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
|
|
23683
|
-
class LambdaExpression : public ParsedExpression {
|
|
23860
|
+
//! Represents a TableReference to a base table in the schema
|
|
23861
|
+
class BaseTableRef : public TableRef {
|
|
23684
23862
|
public:
|
|
23685
|
-
|
|
23863
|
+
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
23864
|
+
}
|
|
23686
23865
|
|
|
23687
|
-
|
|
23688
|
-
|
|
23866
|
+
//! Schema name
|
|
23867
|
+
string schema_name;
|
|
23868
|
+
//! Table name
|
|
23869
|
+
string table_name;
|
|
23870
|
+
//! Aliases for the column names
|
|
23871
|
+
vector<string> column_name_alias;
|
|
23689
23872
|
|
|
23690
23873
|
public:
|
|
23691
23874
|
string ToString() const override;
|
|
23875
|
+
bool Equals(const TableRef *other_p) const override;
|
|
23692
23876
|
|
|
23693
|
-
|
|
23694
|
-
hash_t Hash() const override;
|
|
23695
|
-
|
|
23696
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
23877
|
+
unique_ptr<TableRef> Copy() override;
|
|
23697
23878
|
|
|
23698
|
-
|
|
23699
|
-
|
|
23879
|
+
//! Serializes a blob into a BaseTableRef
|
|
23880
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
23881
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
23882
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
23700
23883
|
};
|
|
23701
|
-
|
|
23702
23884
|
} // namespace duckdb
|
|
23703
23885
|
|
|
23704
23886
|
|
|
23705
23887
|
|
|
23888
|
+
namespace duckdb {
|
|
23706
23889
|
|
|
23890
|
+
struct CreateIndexInfo : public CreateInfo {
|
|
23891
|
+
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
23892
|
+
}
|
|
23707
23893
|
|
|
23894
|
+
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
23895
|
+
IndexType index_type;
|
|
23896
|
+
//! Name of the Index
|
|
23897
|
+
string index_name;
|
|
23898
|
+
//! If it is an unique index
|
|
23899
|
+
bool unique = false;
|
|
23900
|
+
//! The table to create the index on
|
|
23901
|
+
unique_ptr<BaseTableRef> table;
|
|
23902
|
+
//! Set of expressions to index by
|
|
23903
|
+
vector<unique_ptr<ParsedExpression>> expressions;
|
|
23708
23904
|
|
|
23905
|
+
public:
|
|
23906
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
23907
|
+
auto result = make_unique<CreateIndexInfo>();
|
|
23908
|
+
CopyProperties(*result);
|
|
23909
|
+
result->index_type = index_type;
|
|
23910
|
+
result->index_name = index_name;
|
|
23911
|
+
result->unique = unique;
|
|
23912
|
+
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
23913
|
+
for (auto &expr : expressions) {
|
|
23914
|
+
result->expressions.push_back(expr->Copy());
|
|
23915
|
+
}
|
|
23916
|
+
return move(result);
|
|
23917
|
+
}
|
|
23918
|
+
};
|
|
23709
23919
|
|
|
23920
|
+
} // namespace duckdb
|
|
23710
23921
|
//===----------------------------------------------------------------------===//
|
|
23711
23922
|
// DuckDB
|
|
23712
23923
|
//
|
|
23713
|
-
// duckdb/parser/parsed_data/
|
|
23924
|
+
// duckdb/parser/parsed_data/transaction_info.hpp
|
|
23714
23925
|
//
|
|
23715
23926
|
//
|
|
23716
23927
|
//===----------------------------------------------------------------------===//
|
|
@@ -23721,19 +23932,14 @@ public:
|
|
|
23721
23932
|
|
|
23722
23933
|
namespace duckdb {
|
|
23723
23934
|
|
|
23724
|
-
enum class
|
|
23725
|
-
|
|
23726
|
-
struct LoadInfo : public ParseInfo {
|
|
23727
|
-
std::string filename;
|
|
23728
|
-
LoadType load_type;
|
|
23935
|
+
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
23729
23936
|
|
|
23730
|
-
public
|
|
23731
|
-
|
|
23732
|
-
auto result = make_unique<LoadInfo>();
|
|
23733
|
-
result->filename = filename;
|
|
23734
|
-
result->load_type = load_type;
|
|
23735
|
-
return result;
|
|
23937
|
+
struct TransactionInfo : public ParseInfo {
|
|
23938
|
+
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23736
23939
|
}
|
|
23940
|
+
|
|
23941
|
+
//! The type of transaction statement
|
|
23942
|
+
TransactionType type;
|
|
23737
23943
|
};
|
|
23738
23944
|
|
|
23739
23945
|
} // namespace duckdb
|
|
@@ -23776,6 +23982,25 @@ public:
|
|
|
23776
23982
|
}
|
|
23777
23983
|
};
|
|
23778
23984
|
|
|
23985
|
+
} // namespace duckdb
|
|
23986
|
+
//===----------------------------------------------------------------------===//
|
|
23987
|
+
// DuckDB
|
|
23988
|
+
//
|
|
23989
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23990
|
+
//
|
|
23991
|
+
//
|
|
23992
|
+
//===----------------------------------------------------------------------===//
|
|
23993
|
+
|
|
23994
|
+
|
|
23995
|
+
|
|
23996
|
+
|
|
23997
|
+
|
|
23998
|
+
namespace duckdb {
|
|
23999
|
+
|
|
24000
|
+
struct VacuumInfo : public ParseInfo {
|
|
24001
|
+
// nothing for now
|
|
24002
|
+
};
|
|
24003
|
+
|
|
23779
24004
|
} // namespace duckdb
|
|
23780
24005
|
//===----------------------------------------------------------------------===//
|
|
23781
24006
|
// DuckDB
|
|
@@ -23824,106 +24049,38 @@ public:
|
|
|
23824
24049
|
//===----------------------------------------------------------------------===//
|
|
23825
24050
|
// DuckDB
|
|
23826
24051
|
//
|
|
23827
|
-
// duckdb/parser/parsed_data/
|
|
23828
|
-
//
|
|
23829
|
-
//
|
|
23830
|
-
//===----------------------------------------------------------------------===//
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
|
|
23834
|
-
|
|
23835
|
-
|
|
23836
|
-
namespace duckdb {
|
|
23837
|
-
|
|
23838
|
-
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
23839
|
-
|
|
23840
|
-
struct TransactionInfo : public ParseInfo {
|
|
23841
|
-
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
23842
|
-
}
|
|
23843
|
-
|
|
23844
|
-
//! The type of transaction statement
|
|
23845
|
-
TransactionType type;
|
|
23846
|
-
};
|
|
23847
|
-
|
|
23848
|
-
} // namespace duckdb
|
|
23849
|
-
//===----------------------------------------------------------------------===//
|
|
23850
|
-
// DuckDB
|
|
23851
|
-
//
|
|
23852
|
-
// duckdb/parser/parsed_data/create_macro_info.hpp
|
|
23853
|
-
//
|
|
23854
|
-
//
|
|
23855
|
-
//===----------------------------------------------------------------------===//
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
|
|
23860
|
-
//===----------------------------------------------------------------------===//
|
|
23861
|
-
// DuckDB
|
|
23862
|
-
//
|
|
23863
|
-
// duckdb/function/macro_function.hpp
|
|
24052
|
+
// duckdb/parser/parsed_data/create_aggregate_function_info.hpp
|
|
23864
24053
|
//
|
|
23865
24054
|
//
|
|
23866
24055
|
//===----------------------------------------------------------------------===//
|
|
23867
24056
|
|
|
23868
24057
|
|
|
23869
|
-
//! The SelectStatement of the view
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
|
|
23875
|
-
|
|
23876
|
-
|
|
23877
|
-
namespace duckdb {
|
|
23878
|
-
|
|
23879
|
-
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
23880
|
-
|
|
23881
|
-
class MacroFunction {
|
|
23882
|
-
public:
|
|
23883
|
-
// explicit MacroFunction(unique_ptr<ParsedExpression> expression);
|
|
23884
|
-
MacroFunction(MacroType type);
|
|
23885
|
-
|
|
23886
|
-
// MacroFunction(void);
|
|
23887
|
-
// The type
|
|
23888
|
-
MacroType type;
|
|
23889
|
-
//! The positional parameters
|
|
23890
|
-
vector<unique_ptr<ParsedExpression>> parameters;
|
|
23891
|
-
//! The default parameters and their associated values
|
|
23892
|
-
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
23893
|
-
|
|
23894
|
-
public:
|
|
23895
|
-
virtual ~MacroFunction() {
|
|
23896
|
-
}
|
|
23897
|
-
|
|
23898
|
-
void CopyProperties(MacroFunction &other);
|
|
23899
|
-
|
|
23900
|
-
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
23901
24058
|
|
|
23902
|
-
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
23903
|
-
FunctionExpression &function_expr,
|
|
23904
|
-
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
23905
|
-
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
23906
|
-
};
|
|
23907
24059
|
|
|
23908
|
-
} // namespace duckdb
|
|
23909
24060
|
|
|
23910
24061
|
|
|
23911
24062
|
namespace duckdb {
|
|
23912
24063
|
|
|
23913
|
-
struct
|
|
23914
|
-
|
|
24064
|
+
struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
|
|
24065
|
+
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
24066
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
24067
|
+
this->name = function.name;
|
|
24068
|
+
functions.AddFunction(move(function));
|
|
23915
24069
|
}
|
|
23916
24070
|
|
|
23917
|
-
|
|
24071
|
+
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
24072
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
24073
|
+
this->name = functions.name;
|
|
24074
|
+
for (auto &func : functions.functions) {
|
|
24075
|
+
func.name = functions.name;
|
|
24076
|
+
}
|
|
23918
24077
|
}
|
|
23919
24078
|
|
|
23920
|
-
|
|
24079
|
+
AggregateFunctionSet functions;
|
|
23921
24080
|
|
|
23922
24081
|
public:
|
|
23923
24082
|
unique_ptr<CreateInfo> Copy() const override {
|
|
23924
|
-
auto result = make_unique<
|
|
23925
|
-
result->function = function->Copy();
|
|
23926
|
-
result->name = name;
|
|
24083
|
+
auto result = make_unique<CreateAggregateFunctionInfo>(functions);
|
|
23927
24084
|
CopyProperties(*result);
|
|
23928
24085
|
return move(result);
|
|
23929
24086
|
}
|
|
@@ -23947,128 +24104,21 @@ namespace duckdb {
|
|
|
23947
24104
|
|
|
23948
24105
|
struct ShowSelectInfo : public ParseInfo {
|
|
23949
24106
|
//! Types of projected columns
|
|
23950
|
-
vector<LogicalType> types;
|
|
23951
|
-
//! The QueryNode of select query
|
|
23952
|
-
unique_ptr<QueryNode> query;
|
|
23953
|
-
//! Aliases of projected columns
|
|
23954
|
-
vector<string> aliases;
|
|
23955
|
-
//! Whether or not we are requesting a summary or a describe
|
|
23956
|
-
bool is_summary;
|
|
23957
|
-
|
|
23958
|
-
unique_ptr<ShowSelectInfo> Copy() {
|
|
23959
|
-
auto result = make_unique<ShowSelectInfo>();
|
|
23960
|
-
result->types = types;
|
|
23961
|
-
result->query = query->Copy();
|
|
23962
|
-
result->aliases = aliases;
|
|
23963
|
-
result->is_summary = is_summary;
|
|
23964
|
-
return result;
|
|
23965
|
-
}
|
|
23966
|
-
};
|
|
23967
|
-
|
|
23968
|
-
} // namespace duckdb
|
|
23969
|
-
//===----------------------------------------------------------------------===//
|
|
23970
|
-
// DuckDB
|
|
23971
|
-
//
|
|
23972
|
-
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
23973
|
-
//
|
|
23974
|
-
//
|
|
23975
|
-
//===----------------------------------------------------------------------===//
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
namespace duckdb {
|
|
23982
|
-
|
|
23983
|
-
struct VacuumInfo : public ParseInfo {
|
|
23984
|
-
// nothing for now
|
|
23985
|
-
};
|
|
23986
|
-
|
|
23987
|
-
} // namespace duckdb
|
|
23988
|
-
//===----------------------------------------------------------------------===//
|
|
23989
|
-
// DuckDB
|
|
23990
|
-
//
|
|
23991
|
-
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
23992
|
-
//
|
|
23993
|
-
//
|
|
23994
|
-
//===----------------------------------------------------------------------===//
|
|
23995
|
-
|
|
23996
|
-
|
|
23997
|
-
|
|
23998
|
-
|
|
23999
|
-
|
|
24000
|
-
|
|
24001
|
-
//===----------------------------------------------------------------------===//
|
|
24002
|
-
// DuckDB
|
|
24003
|
-
//
|
|
24004
|
-
// duckdb/parser/tableref/basetableref.hpp
|
|
24005
|
-
//
|
|
24006
|
-
//
|
|
24007
|
-
//===----------------------------------------------------------------------===//
|
|
24008
|
-
|
|
24009
|
-
|
|
24010
|
-
|
|
24011
|
-
|
|
24012
|
-
|
|
24013
|
-
|
|
24014
|
-
namespace duckdb {
|
|
24015
|
-
//! Represents a TableReference to a base table in the schema
|
|
24016
|
-
class BaseTableRef : public TableRef {
|
|
24017
|
-
public:
|
|
24018
|
-
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
24019
|
-
}
|
|
24020
|
-
|
|
24021
|
-
//! Schema name
|
|
24022
|
-
string schema_name;
|
|
24023
|
-
//! Table name
|
|
24024
|
-
string table_name;
|
|
24025
|
-
//! Aliases for the column names
|
|
24026
|
-
vector<string> column_name_alias;
|
|
24027
|
-
|
|
24028
|
-
public:
|
|
24029
|
-
string ToString() const override;
|
|
24030
|
-
bool Equals(const TableRef *other_p) const override;
|
|
24031
|
-
|
|
24032
|
-
unique_ptr<TableRef> Copy() override;
|
|
24033
|
-
|
|
24034
|
-
//! Serializes a blob into a BaseTableRef
|
|
24035
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
24036
|
-
//! Deserializes a blob back into a BaseTableRef
|
|
24037
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24038
|
-
};
|
|
24039
|
-
} // namespace duckdb
|
|
24040
|
-
|
|
24041
|
-
|
|
24042
|
-
|
|
24043
|
-
namespace duckdb {
|
|
24044
|
-
|
|
24045
|
-
struct CreateIndexInfo : public CreateInfo {
|
|
24046
|
-
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
24047
|
-
}
|
|
24048
|
-
|
|
24049
|
-
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
24050
|
-
IndexType index_type;
|
|
24051
|
-
//! Name of the Index
|
|
24052
|
-
string index_name;
|
|
24053
|
-
//! If it is an unique index
|
|
24054
|
-
bool unique = false;
|
|
24055
|
-
//! The table to create the index on
|
|
24056
|
-
unique_ptr<BaseTableRef> table;
|
|
24057
|
-
//! Set of expressions to index by
|
|
24058
|
-
vector<unique_ptr<ParsedExpression>> expressions;
|
|
24059
|
-
|
|
24060
|
-
public:
|
|
24061
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
24062
|
-
auto result = make_unique<CreateIndexInfo>();
|
|
24063
|
-
CopyProperties(*result);
|
|
24064
|
-
result->index_type = index_type;
|
|
24065
|
-
result->index_name = index_name;
|
|
24066
|
-
result->unique = unique;
|
|
24067
|
-
result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
|
|
24068
|
-
for (auto &expr : expressions) {
|
|
24069
|
-
result->expressions.push_back(expr->Copy());
|
|
24070
|
-
}
|
|
24071
|
-
return move(result);
|
|
24107
|
+
vector<LogicalType> types;
|
|
24108
|
+
//! The QueryNode of select query
|
|
24109
|
+
unique_ptr<QueryNode> query;
|
|
24110
|
+
//! Aliases of projected columns
|
|
24111
|
+
vector<string> aliases;
|
|
24112
|
+
//! Whether or not we are requesting a summary or a describe
|
|
24113
|
+
bool is_summary;
|
|
24114
|
+
|
|
24115
|
+
unique_ptr<ShowSelectInfo> Copy() {
|
|
24116
|
+
auto result = make_unique<ShowSelectInfo>();
|
|
24117
|
+
result->types = types;
|
|
24118
|
+
result->query = query->Copy();
|
|
24119
|
+
result->aliases = aliases;
|
|
24120
|
+
result->is_summary = is_summary;
|
|
24121
|
+
return result;
|
|
24072
24122
|
}
|
|
24073
24123
|
};
|
|
24074
24124
|
|
|
@@ -24112,7 +24162,7 @@ struct BoundExportData : public ParseInfo {
|
|
|
24112
24162
|
//===----------------------------------------------------------------------===//
|
|
24113
24163
|
// DuckDB
|
|
24114
24164
|
//
|
|
24115
|
-
// duckdb/parser/parsed_data/
|
|
24165
|
+
// duckdb/parser/parsed_data/create_macro_info.hpp
|
|
24116
24166
|
//
|
|
24117
24167
|
//
|
|
24118
24168
|
//===----------------------------------------------------------------------===//
|
|
@@ -24120,57 +24170,73 @@ struct BoundExportData : public ParseInfo {
|
|
|
24120
24170
|
|
|
24121
24171
|
|
|
24122
24172
|
|
|
24123
|
-
|
|
24124
|
-
namespace duckdb {
|
|
24125
|
-
|
|
24126
|
-
struct CreateSchemaInfo : public CreateInfo {
|
|
24127
|
-
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
24128
|
-
}
|
|
24129
|
-
|
|
24130
|
-
public:
|
|
24131
|
-
unique_ptr<CreateInfo> Copy() const override {
|
|
24132
|
-
auto result = make_unique<CreateSchemaInfo>();
|
|
24133
|
-
CopyProperties(*result);
|
|
24134
|
-
return move(result);
|
|
24135
|
-
}
|
|
24136
|
-
};
|
|
24137
|
-
|
|
24138
|
-
} // namespace duckdb
|
|
24139
24173
|
//===----------------------------------------------------------------------===//
|
|
24140
24174
|
// DuckDB
|
|
24141
24175
|
//
|
|
24142
|
-
// duckdb/
|
|
24176
|
+
// duckdb/function/macro_function.hpp
|
|
24143
24177
|
//
|
|
24144
24178
|
//
|
|
24145
24179
|
//===----------------------------------------------------------------------===//
|
|
24146
24180
|
|
|
24147
24181
|
|
|
24182
|
+
//! The SelectStatement of the view
|
|
24183
|
+
|
|
24184
|
+
|
|
24185
|
+
|
|
24148
24186
|
|
|
24149
24187
|
|
|
24150
24188
|
|
|
24151
24189
|
|
|
24152
24190
|
namespace duckdb {
|
|
24153
24191
|
|
|
24154
|
-
|
|
24155
|
-
|
|
24156
|
-
|
|
24157
|
-
|
|
24158
|
-
|
|
24192
|
+
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
24193
|
+
|
|
24194
|
+
class MacroFunction {
|
|
24195
|
+
public:
|
|
24196
|
+
// explicit MacroFunction(unique_ptr<ParsedExpression> expression);
|
|
24197
|
+
MacroFunction(MacroType type);
|
|
24198
|
+
|
|
24199
|
+
// MacroFunction(void);
|
|
24200
|
+
// The type
|
|
24201
|
+
MacroType type;
|
|
24202
|
+
//! The positional parameters
|
|
24203
|
+
vector<unique_ptr<ParsedExpression>> parameters;
|
|
24204
|
+
//! The default parameters and their associated values
|
|
24205
|
+
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
24206
|
+
|
|
24207
|
+
public:
|
|
24208
|
+
virtual ~MacroFunction() {
|
|
24159
24209
|
}
|
|
24160
24210
|
|
|
24161
|
-
|
|
24162
|
-
|
|
24163
|
-
|
|
24164
|
-
|
|
24165
|
-
|
|
24166
|
-
|
|
24211
|
+
void CopyProperties(MacroFunction &other);
|
|
24212
|
+
|
|
24213
|
+
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
24214
|
+
|
|
24215
|
+
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
24216
|
+
FunctionExpression &function_expr,
|
|
24217
|
+
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
24218
|
+
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
24219
|
+
};
|
|
24220
|
+
|
|
24221
|
+
} // namespace duckdb
|
|
24222
|
+
|
|
24223
|
+
|
|
24224
|
+
namespace duckdb {
|
|
24225
|
+
|
|
24226
|
+
struct CreateMacroInfo : public CreateFunctionInfo {
|
|
24227
|
+
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
24167
24228
|
}
|
|
24168
24229
|
|
|
24169
|
-
|
|
24230
|
+
CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
|
|
24231
|
+
}
|
|
24232
|
+
|
|
24233
|
+
unique_ptr<MacroFunction> function;
|
|
24170
24234
|
|
|
24171
24235
|
public:
|
|
24172
24236
|
unique_ptr<CreateInfo> Copy() const override {
|
|
24173
|
-
auto result = make_unique<
|
|
24237
|
+
auto result = make_unique<CreateMacroInfo>();
|
|
24238
|
+
result->function = function->Copy();
|
|
24239
|
+
result->name = name;
|
|
24174
24240
|
CopyProperties(*result);
|
|
24175
24241
|
return move(result);
|
|
24176
24242
|
}
|
|
@@ -24180,7 +24246,7 @@ public:
|
|
|
24180
24246
|
//===----------------------------------------------------------------------===//
|
|
24181
24247
|
// DuckDB
|
|
24182
24248
|
//
|
|
24183
|
-
// duckdb/parser/parsed_data/
|
|
24249
|
+
// duckdb/parser/parsed_data/create_view_info.hpp
|
|
24184
24250
|
//
|
|
24185
24251
|
//
|
|
24186
24252
|
//===----------------------------------------------------------------------===//
|
|
@@ -24190,26 +24256,31 @@ public:
|
|
|
24190
24256
|
|
|
24191
24257
|
|
|
24192
24258
|
|
|
24193
|
-
|
|
24194
|
-
|
|
24195
24259
|
namespace duckdb {
|
|
24196
24260
|
|
|
24197
|
-
struct
|
|
24198
|
-
|
|
24199
|
-
|
|
24261
|
+
struct CreateViewInfo : public CreateInfo {
|
|
24262
|
+
CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
|
|
24263
|
+
}
|
|
24264
|
+
CreateViewInfo(string schema, string view_name)
|
|
24265
|
+
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
24200
24266
|
}
|
|
24201
24267
|
|
|
24202
|
-
//!
|
|
24203
|
-
string
|
|
24204
|
-
//!
|
|
24205
|
-
|
|
24268
|
+
//! Table name to insert to
|
|
24269
|
+
string view_name;
|
|
24270
|
+
//! Aliases of the view
|
|
24271
|
+
vector<string> aliases;
|
|
24272
|
+
//! Return types
|
|
24273
|
+
vector<LogicalType> types;
|
|
24274
|
+
//! The SelectStatement of the view
|
|
24275
|
+
unique_ptr<SelectStatement> query;
|
|
24206
24276
|
|
|
24207
24277
|
public:
|
|
24208
24278
|
unique_ptr<CreateInfo> Copy() const override {
|
|
24209
|
-
auto result = make_unique<
|
|
24279
|
+
auto result = make_unique<CreateViewInfo>(schema, view_name);
|
|
24210
24280
|
CopyProperties(*result);
|
|
24211
|
-
result->
|
|
24212
|
-
result->
|
|
24281
|
+
result->aliases = aliases;
|
|
24282
|
+
result->types = types;
|
|
24283
|
+
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
24213
24284
|
return move(result);
|
|
24214
24285
|
}
|
|
24215
24286
|
};
|
|
@@ -24260,7 +24331,7 @@ public:
|
|
|
24260
24331
|
//===----------------------------------------------------------------------===//
|
|
24261
24332
|
// DuckDB
|
|
24262
24333
|
//
|
|
24263
|
-
// duckdb/parser/parsed_data/
|
|
24334
|
+
// duckdb/parser/parsed_data/create_schema_info.hpp
|
|
24264
24335
|
//
|
|
24265
24336
|
//
|
|
24266
24337
|
//===----------------------------------------------------------------------===//
|
|
@@ -24269,41 +24340,26 @@ public:
|
|
|
24269
24340
|
|
|
24270
24341
|
|
|
24271
24342
|
|
|
24272
|
-
|
|
24273
24343
|
namespace duckdb {
|
|
24274
24344
|
|
|
24275
|
-
struct
|
|
24276
|
-
|
|
24277
|
-
}
|
|
24278
|
-
CreateViewInfo(string schema, string view_name)
|
|
24279
|
-
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
24345
|
+
struct CreateSchemaInfo : public CreateInfo {
|
|
24346
|
+
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
24280
24347
|
}
|
|
24281
24348
|
|
|
24282
|
-
//! Table name to insert to
|
|
24283
|
-
string view_name;
|
|
24284
|
-
//! Aliases of the view
|
|
24285
|
-
vector<string> aliases;
|
|
24286
|
-
//! Return types
|
|
24287
|
-
vector<LogicalType> types;
|
|
24288
|
-
//! The SelectStatement of the view
|
|
24289
|
-
unique_ptr<SelectStatement> query;
|
|
24290
|
-
|
|
24291
24349
|
public:
|
|
24292
24350
|
unique_ptr<CreateInfo> Copy() const override {
|
|
24293
|
-
auto result = make_unique<
|
|
24351
|
+
auto result = make_unique<CreateSchemaInfo>();
|
|
24294
24352
|
CopyProperties(*result);
|
|
24295
|
-
result->aliases = aliases;
|
|
24296
|
-
result->types = types;
|
|
24297
|
-
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
24298
24353
|
return move(result);
|
|
24299
24354
|
}
|
|
24300
24355
|
};
|
|
24301
24356
|
|
|
24302
24357
|
} // namespace duckdb
|
|
24358
|
+
|
|
24303
24359
|
//===----------------------------------------------------------------------===//
|
|
24304
24360
|
// DuckDB
|
|
24305
24361
|
//
|
|
24306
|
-
// duckdb/parser/tableref/
|
|
24362
|
+
// duckdb/parser/tableref/crossproductref.hpp
|
|
24307
24363
|
//
|
|
24308
24364
|
//
|
|
24309
24365
|
//===----------------------------------------------------------------------===//
|
|
@@ -24314,27 +24370,33 @@ public:
|
|
|
24314
24370
|
|
|
24315
24371
|
namespace duckdb {
|
|
24316
24372
|
//! Represents a cross product
|
|
24317
|
-
class
|
|
24373
|
+
class CrossProductRef : public TableRef {
|
|
24318
24374
|
public:
|
|
24319
|
-
|
|
24375
|
+
CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
|
|
24320
24376
|
}
|
|
24321
24377
|
|
|
24378
|
+
//! The left hand side of the cross product
|
|
24379
|
+
unique_ptr<TableRef> left;
|
|
24380
|
+
//! The right hand side of the cross product
|
|
24381
|
+
unique_ptr<TableRef> right;
|
|
24382
|
+
|
|
24322
24383
|
public:
|
|
24323
24384
|
string ToString() const override;
|
|
24324
24385
|
bool Equals(const TableRef *other_p) const override;
|
|
24325
24386
|
|
|
24326
24387
|
unique_ptr<TableRef> Copy() override;
|
|
24327
24388
|
|
|
24328
|
-
//! Serializes a blob into a
|
|
24389
|
+
//! Serializes a blob into a CrossProductRef
|
|
24329
24390
|
void Serialize(FieldWriter &serializer) const override;
|
|
24330
|
-
//! Deserializes a blob back into a
|
|
24391
|
+
//! Deserializes a blob back into a CrossProductRef
|
|
24331
24392
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24332
24393
|
};
|
|
24333
24394
|
} // namespace duckdb
|
|
24395
|
+
|
|
24334
24396
|
//===----------------------------------------------------------------------===//
|
|
24335
24397
|
// DuckDB
|
|
24336
24398
|
//
|
|
24337
|
-
// duckdb/parser/tableref/
|
|
24399
|
+
// duckdb/parser/tableref/emptytableref.hpp
|
|
24338
24400
|
//
|
|
24339
24401
|
//
|
|
24340
24402
|
//===----------------------------------------------------------------------===//
|
|
@@ -24343,46 +24405,30 @@ public:
|
|
|
24343
24405
|
|
|
24344
24406
|
|
|
24345
24407
|
|
|
24346
|
-
|
|
24347
|
-
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
24408
|
namespace duckdb {
|
|
24351
|
-
//! Represents a
|
|
24352
|
-
class
|
|
24409
|
+
//! Represents a cross product
|
|
24410
|
+
class EmptyTableRef : public TableRef {
|
|
24353
24411
|
public:
|
|
24354
|
-
|
|
24412
|
+
EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
|
|
24355
24413
|
}
|
|
24356
24414
|
|
|
24357
|
-
//! The left hand side of the join
|
|
24358
|
-
unique_ptr<TableRef> left;
|
|
24359
|
-
//! The right hand side of the join
|
|
24360
|
-
unique_ptr<TableRef> right;
|
|
24361
|
-
//! The join condition
|
|
24362
|
-
unique_ptr<ParsedExpression> condition;
|
|
24363
|
-
//! The join type
|
|
24364
|
-
JoinType type;
|
|
24365
|
-
//! Natural join
|
|
24366
|
-
bool is_natural;
|
|
24367
|
-
//! The set of USING columns (if any)
|
|
24368
|
-
vector<string> using_columns;
|
|
24369
|
-
|
|
24370
24415
|
public:
|
|
24371
24416
|
string ToString() const override;
|
|
24372
24417
|
bool Equals(const TableRef *other_p) const override;
|
|
24373
24418
|
|
|
24374
24419
|
unique_ptr<TableRef> Copy() override;
|
|
24375
24420
|
|
|
24376
|
-
//! Serializes a blob into a
|
|
24421
|
+
//! Serializes a blob into a DummyTableRef
|
|
24377
24422
|
void Serialize(FieldWriter &serializer) const override;
|
|
24378
|
-
//! Deserializes a blob back into a
|
|
24423
|
+
//! Deserializes a blob back into a DummyTableRef
|
|
24379
24424
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24380
24425
|
};
|
|
24381
24426
|
} // namespace duckdb
|
|
24427
|
+
|
|
24382
24428
|
//===----------------------------------------------------------------------===//
|
|
24383
24429
|
// DuckDB
|
|
24384
24430
|
//
|
|
24385
|
-
// duckdb/parser/tableref/
|
|
24431
|
+
// duckdb/parser/tableref/expressionlistref.hpp
|
|
24386
24432
|
//
|
|
24387
24433
|
//
|
|
24388
24434
|
//===----------------------------------------------------------------------===//
|
|
@@ -24391,17 +24437,22 @@ public:
|
|
|
24391
24437
|
|
|
24392
24438
|
|
|
24393
24439
|
|
|
24440
|
+
|
|
24441
|
+
|
|
24442
|
+
|
|
24394
24443
|
namespace duckdb {
|
|
24395
|
-
//! Represents a
|
|
24396
|
-
class
|
|
24444
|
+
//! Represents an expression list as generated by a VALUES statement
|
|
24445
|
+
class ExpressionListRef : public TableRef {
|
|
24397
24446
|
public:
|
|
24398
|
-
|
|
24447
|
+
ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
|
|
24399
24448
|
}
|
|
24400
24449
|
|
|
24401
|
-
//!
|
|
24402
|
-
unique_ptr<
|
|
24403
|
-
//!
|
|
24404
|
-
|
|
24450
|
+
//! Value list, only used for VALUES statement
|
|
24451
|
+
vector<vector<unique_ptr<ParsedExpression>>> values;
|
|
24452
|
+
//! Expected SQL types
|
|
24453
|
+
vector<LogicalType> expected_types;
|
|
24454
|
+
//! The set of expected names
|
|
24455
|
+
vector<string> expected_names;
|
|
24405
24456
|
|
|
24406
24457
|
public:
|
|
24407
24458
|
string ToString() const override;
|
|
@@ -24409,19 +24460,17 @@ public:
|
|
|
24409
24460
|
|
|
24410
24461
|
unique_ptr<TableRef> Copy() override;
|
|
24411
24462
|
|
|
24412
|
-
//! Serializes a blob into a
|
|
24463
|
+
//! Serializes a blob into a ExpressionListRef
|
|
24413
24464
|
void Serialize(FieldWriter &serializer) const override;
|
|
24414
|
-
//! Deserializes a blob back into a
|
|
24465
|
+
//! Deserializes a blob back into a ExpressionListRef
|
|
24415
24466
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24416
24467
|
};
|
|
24417
24468
|
} // namespace duckdb
|
|
24418
24469
|
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
24470
|
//===----------------------------------------------------------------------===//
|
|
24422
24471
|
// DuckDB
|
|
24423
24472
|
//
|
|
24424
|
-
// duckdb/parser/tableref/
|
|
24473
|
+
// duckdb/parser/tableref/joinref.hpp
|
|
24425
24474
|
//
|
|
24426
24475
|
//
|
|
24427
24476
|
//===----------------------------------------------------------------------===//
|
|
@@ -24433,19 +24482,26 @@ public:
|
|
|
24433
24482
|
|
|
24434
24483
|
|
|
24435
24484
|
|
|
24485
|
+
|
|
24436
24486
|
namespace duckdb {
|
|
24437
|
-
//! Represents
|
|
24438
|
-
class
|
|
24487
|
+
//! Represents a JOIN between two expressions
|
|
24488
|
+
class JoinRef : public TableRef {
|
|
24439
24489
|
public:
|
|
24440
|
-
|
|
24490
|
+
JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
|
|
24441
24491
|
}
|
|
24442
24492
|
|
|
24443
|
-
//!
|
|
24444
|
-
|
|
24445
|
-
//!
|
|
24446
|
-
|
|
24447
|
-
//! The
|
|
24448
|
-
|
|
24493
|
+
//! The left hand side of the join
|
|
24494
|
+
unique_ptr<TableRef> left;
|
|
24495
|
+
//! The right hand side of the join
|
|
24496
|
+
unique_ptr<TableRef> right;
|
|
24497
|
+
//! The join condition
|
|
24498
|
+
unique_ptr<ParsedExpression> condition;
|
|
24499
|
+
//! The join type
|
|
24500
|
+
JoinType type;
|
|
24501
|
+
//! Natural join
|
|
24502
|
+
bool is_natural;
|
|
24503
|
+
//! The set of USING columns (if any)
|
|
24504
|
+
vector<string> using_columns;
|
|
24449
24505
|
|
|
24450
24506
|
public:
|
|
24451
24507
|
string ToString() const override;
|
|
@@ -24453,14 +24509,13 @@ public:
|
|
|
24453
24509
|
|
|
24454
24510
|
unique_ptr<TableRef> Copy() override;
|
|
24455
24511
|
|
|
24456
|
-
//! Serializes a blob into a
|
|
24512
|
+
//! Serializes a blob into a JoinRef
|
|
24457
24513
|
void Serialize(FieldWriter &serializer) const override;
|
|
24458
|
-
//! Deserializes a blob back into a
|
|
24514
|
+
//! Deserializes a blob back into a JoinRef
|
|
24459
24515
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
24460
24516
|
};
|
|
24461
24517
|
} // namespace duckdb
|
|
24462
24518
|
|
|
24463
|
-
|
|
24464
24519
|
//===----------------------------------------------------------------------===//
|
|
24465
24520
|
// DuckDB
|
|
24466
24521
|
//
|
|
@@ -24513,6 +24568,7 @@ public:
|
|
|
24513
24568
|
|
|
24514
24569
|
|
|
24515
24570
|
|
|
24571
|
+
|
|
24516
24572
|
namespace duckdb {
|
|
24517
24573
|
//! Represents a Table producing function
|
|
24518
24574
|
class TableFunctionRef : public TableRef {
|
|
@@ -24525,6 +24581,9 @@ public:
|
|
|
24525
24581
|
// if the function takes a subquery as argument its in here
|
|
24526
24582
|
unique_ptr<SelectStatement> subquery;
|
|
24527
24583
|
|
|
24584
|
+
// External dependencies of this table funcion
|
|
24585
|
+
unique_ptr<ExternalDependency> external_dependency;
|
|
24586
|
+
|
|
24528
24587
|
public:
|
|
24529
24588
|
string ToString() const override;
|
|
24530
24589
|
|