duckdb 0.4.1-dev2230.0 → 0.4.1-dev2256.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +1377 -629
- package/src/duckdb.hpp +1290 -851
- package/src/parquet-amalgamation.cpp +30448 -30448
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 "895f02f49"
|
|
15
|
+
#define DUCKDB_VERSION "v0.4.1-dev2256"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -7823,6 +7823,8 @@ public:
|
|
|
7823
7823
|
virtual void Serialize(Serializer &serializer) const;
|
|
7824
7824
|
virtual void Serialize(FieldWriter &writer) const;
|
|
7825
7825
|
|
|
7826
|
+
idx_t GetDistinctCount();
|
|
7827
|
+
|
|
7826
7828
|
static unique_ptr<BaseStatistics> Deserialize(Deserializer &source, LogicalType type);
|
|
7827
7829
|
|
|
7828
7830
|
//! Verify that a vector does not violate the statistics
|
|
@@ -8694,116 +8696,10 @@ DUCKDB_API TypeCatalogEntry *Catalog::GetEntry(ClientContext &context, const str
|
|
|
8694
8696
|
|
|
8695
8697
|
} // namespace duckdb
|
|
8696
8698
|
|
|
8697
|
-
|
|
8698
|
-
//===----------------------------------------------------------------------===//
|
|
8699
|
-
// DuckDB
|
|
8700
|
-
//
|
|
8701
|
-
// duckdb/common/enums/logical_operator_type.hpp
|
|
8702
|
-
//
|
|
8703
|
-
//
|
|
8704
|
-
//===----------------------------------------------------------------------===//
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
namespace duckdb {
|
|
8711
|
-
|
|
8712
|
-
//===--------------------------------------------------------------------===//
|
|
8713
|
-
// Logical Operator Types
|
|
8714
|
-
//===--------------------------------------------------------------------===//
|
|
8715
|
-
enum class LogicalOperatorType : uint8_t {
|
|
8716
|
-
LOGICAL_INVALID = 0,
|
|
8717
|
-
LOGICAL_PROJECTION = 1,
|
|
8718
|
-
LOGICAL_FILTER = 2,
|
|
8719
|
-
LOGICAL_AGGREGATE_AND_GROUP_BY = 3,
|
|
8720
|
-
LOGICAL_WINDOW = 4,
|
|
8721
|
-
LOGICAL_UNNEST = 5,
|
|
8722
|
-
LOGICAL_LIMIT = 6,
|
|
8723
|
-
LOGICAL_ORDER_BY = 7,
|
|
8724
|
-
LOGICAL_TOP_N = 8,
|
|
8725
|
-
LOGICAL_COPY_TO_FILE = 10,
|
|
8726
|
-
LOGICAL_DISTINCT = 11,
|
|
8727
|
-
LOGICAL_SAMPLE = 12,
|
|
8728
|
-
LOGICAL_LIMIT_PERCENT = 13,
|
|
8729
|
-
|
|
8730
|
-
// -----------------------------
|
|
8731
|
-
// Data sources
|
|
8732
|
-
// -----------------------------
|
|
8733
|
-
LOGICAL_GET = 25,
|
|
8734
|
-
LOGICAL_CHUNK_GET = 26,
|
|
8735
|
-
LOGICAL_DELIM_GET = 27,
|
|
8736
|
-
LOGICAL_EXPRESSION_GET = 28,
|
|
8737
|
-
LOGICAL_DUMMY_SCAN = 29,
|
|
8738
|
-
LOGICAL_EMPTY_RESULT = 30,
|
|
8739
|
-
LOGICAL_CTE_REF = 31,
|
|
8740
|
-
// -----------------------------
|
|
8741
|
-
// Joins
|
|
8742
|
-
// -----------------------------
|
|
8743
|
-
LOGICAL_JOIN = 50,
|
|
8744
|
-
LOGICAL_DELIM_JOIN = 51,
|
|
8745
|
-
LOGICAL_COMPARISON_JOIN = 52,
|
|
8746
|
-
LOGICAL_ANY_JOIN = 53,
|
|
8747
|
-
LOGICAL_CROSS_PRODUCT = 54,
|
|
8748
|
-
// -----------------------------
|
|
8749
|
-
// SetOps
|
|
8750
|
-
// -----------------------------
|
|
8751
|
-
LOGICAL_UNION = 75,
|
|
8752
|
-
LOGICAL_EXCEPT = 76,
|
|
8753
|
-
LOGICAL_INTERSECT = 77,
|
|
8754
|
-
LOGICAL_RECURSIVE_CTE = 78,
|
|
8755
|
-
|
|
8756
|
-
// -----------------------------
|
|
8757
|
-
// Updates
|
|
8758
|
-
// -----------------------------
|
|
8759
|
-
LOGICAL_INSERT = 100,
|
|
8760
|
-
LOGICAL_DELETE = 101,
|
|
8761
|
-
LOGICAL_UPDATE = 102,
|
|
8762
|
-
|
|
8763
|
-
// -----------------------------
|
|
8764
|
-
// Schema
|
|
8765
|
-
// -----------------------------
|
|
8766
|
-
LOGICAL_ALTER = 125,
|
|
8767
|
-
LOGICAL_CREATE_TABLE = 126,
|
|
8768
|
-
LOGICAL_CREATE_INDEX = 127,
|
|
8769
|
-
LOGICAL_CREATE_SEQUENCE = 128,
|
|
8770
|
-
LOGICAL_CREATE_VIEW = 129,
|
|
8771
|
-
LOGICAL_CREATE_SCHEMA = 130,
|
|
8772
|
-
LOGICAL_CREATE_MACRO = 131,
|
|
8773
|
-
LOGICAL_DROP = 132,
|
|
8774
|
-
LOGICAL_PRAGMA = 133,
|
|
8775
|
-
LOGICAL_TRANSACTION = 134,
|
|
8776
|
-
LOGICAL_CREATE_TYPE = 135,
|
|
8777
|
-
|
|
8778
|
-
// -----------------------------
|
|
8779
|
-
// Explain
|
|
8780
|
-
// -----------------------------
|
|
8781
|
-
LOGICAL_EXPLAIN = 150,
|
|
8782
|
-
|
|
8783
|
-
// -----------------------------
|
|
8784
|
-
// Show
|
|
8785
|
-
// -----------------------------
|
|
8786
|
-
LOGICAL_SHOW = 160,
|
|
8787
|
-
|
|
8788
|
-
// -----------------------------
|
|
8789
|
-
// Helpers
|
|
8790
|
-
// -----------------------------
|
|
8791
|
-
LOGICAL_PREPARE = 175,
|
|
8792
|
-
LOGICAL_EXECUTE = 176,
|
|
8793
|
-
LOGICAL_EXPORT = 177,
|
|
8794
|
-
LOGICAL_VACUUM = 178,
|
|
8795
|
-
LOGICAL_SET = 179,
|
|
8796
|
-
LOGICAL_LOAD = 180
|
|
8797
|
-
};
|
|
8798
|
-
|
|
8799
|
-
DUCKDB_API string LogicalOperatorToString(LogicalOperatorType type);
|
|
8800
|
-
|
|
8801
|
-
} // namespace duckdb
|
|
8802
|
-
|
|
8803
8699
|
//===----------------------------------------------------------------------===//
|
|
8804
8700
|
// DuckDB
|
|
8805
8701
|
//
|
|
8806
|
-
// duckdb/
|
|
8702
|
+
// duckdb/optimizer/estimated_properties.hpp
|
|
8807
8703
|
//
|
|
8808
8704
|
//
|
|
8809
8705
|
//===----------------------------------------------------------------------===//
|
|
@@ -8815,7 +8711,7 @@ DUCKDB_API string LogicalOperatorToString(LogicalOperatorType type);
|
|
|
8815
8711
|
//===----------------------------------------------------------------------===//
|
|
8816
8712
|
// DuckDB
|
|
8817
8713
|
//
|
|
8818
|
-
// duckdb/
|
|
8714
|
+
// duckdb/optimizer/join_order/join_relation.hpp
|
|
8819
8715
|
//
|
|
8820
8716
|
//
|
|
8821
8717
|
//===----------------------------------------------------------------------===//
|
|
@@ -8824,122 +8720,98 @@ DUCKDB_API string LogicalOperatorToString(LogicalOperatorType type);
|
|
|
8824
8720
|
|
|
8825
8721
|
|
|
8826
8722
|
|
|
8827
|
-
//===----------------------------------------------------------------------===//
|
|
8828
|
-
// DuckDB
|
|
8829
|
-
//
|
|
8830
|
-
// duckdb/planner/bound_parameter_map.hpp
|
|
8831
|
-
//
|
|
8832
|
-
//
|
|
8833
|
-
//===----------------------------------------------------------------------===//
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
8723
|
|
|
8839
8724
|
|
|
8840
8725
|
namespace duckdb {
|
|
8726
|
+
class LogicalOperator;
|
|
8841
8727
|
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8728
|
+
//! Represents a single relation and any metadata accompanying that relation
|
|
8729
|
+
struct SingleJoinRelation {
|
|
8730
|
+
LogicalOperator *op;
|
|
8731
|
+
LogicalOperator *parent;
|
|
8845
8732
|
|
|
8846
|
-
|
|
8733
|
+
SingleJoinRelation() {
|
|
8734
|
+
}
|
|
8735
|
+
SingleJoinRelation(LogicalOperator *op, LogicalOperator *parent) : op(op), parent(parent) {
|
|
8736
|
+
}
|
|
8737
|
+
};
|
|
8847
8738
|
|
|
8739
|
+
//! Set of relations, used in the join graph.
|
|
8740
|
+
struct JoinRelationSet {
|
|
8741
|
+
JoinRelationSet(unique_ptr<idx_t[]> relations, idx_t count) : relations(move(relations)), count(count) {
|
|
8742
|
+
}
|
|
8848
8743
|
|
|
8849
|
-
|
|
8850
|
-
class ClientContext;
|
|
8851
|
-
class LogicalOperator;
|
|
8852
|
-
struct BoundParameterData;
|
|
8744
|
+
string ToString() const;
|
|
8853
8745
|
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
~PlanDeserializationState();
|
|
8746
|
+
unique_ptr<idx_t[]> relations;
|
|
8747
|
+
idx_t count;
|
|
8857
8748
|
|
|
8858
|
-
|
|
8859
|
-
bound_parameter_map_t parameter_data;
|
|
8749
|
+
static bool IsSubset(JoinRelationSet *super, JoinRelationSet *sub);
|
|
8860
8750
|
};
|
|
8861
8751
|
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8752
|
+
//! The JoinRelationTree is a structure holding all the created JoinRelationSet objects and allowing fast lookup on to
|
|
8753
|
+
//! them
|
|
8754
|
+
class JoinRelationSetManager {
|
|
8755
|
+
public:
|
|
8756
|
+
//! Contains a node with a JoinRelationSet and child relations
|
|
8757
|
+
// FIXME: this structure is inefficient, could use a bitmap for lookup instead (todo: profile)
|
|
8758
|
+
struct JoinRelationTreeNode {
|
|
8759
|
+
unique_ptr<JoinRelationSet> relation;
|
|
8760
|
+
unordered_map<idx_t, unique_ptr<JoinRelationTreeNode>> children;
|
|
8761
|
+
};
|
|
8870
8762
|
|
|
8871
|
-
|
|
8872
|
-
|
|
8763
|
+
public:
|
|
8764
|
+
//! Create or get a JoinRelationSet from a single node with the given index
|
|
8765
|
+
JoinRelationSet *GetJoinRelation(idx_t index);
|
|
8766
|
+
//! Create or get a JoinRelationSet from a set of relation bindings
|
|
8767
|
+
JoinRelationSet *GetJoinRelation(unordered_set<idx_t> &bindings);
|
|
8768
|
+
//! Create or get a JoinRelationSet from a (sorted, duplicate-free!) list of relations
|
|
8769
|
+
JoinRelationSet *GetJoinRelation(unique_ptr<idx_t[]> relations, idx_t count);
|
|
8770
|
+
//! Union two sets of relations together and create a new relation set
|
|
8771
|
+
JoinRelationSet *Union(JoinRelationSet *left, JoinRelationSet *right);
|
|
8772
|
+
// //! Create the set difference of left \ right (i.e. all elements in left that are not in right)
|
|
8773
|
+
// JoinRelationSet *Difference(JoinRelationSet *left, JoinRelationSet *right);
|
|
8873
8774
|
|
|
8874
|
-
|
|
8875
|
-
|
|
8775
|
+
private:
|
|
8776
|
+
JoinRelationTreeNode root;
|
|
8876
8777
|
};
|
|
8877
8778
|
|
|
8878
8779
|
} // namespace duckdb
|
|
8879
8780
|
|
|
8781
|
+
//===----------------------------------------------------------------------===//
|
|
8782
|
+
// DuckDB
|
|
8783
|
+
//
|
|
8784
|
+
// duckdb/parser/expression_map.hpp
|
|
8785
|
+
//
|
|
8786
|
+
//
|
|
8787
|
+
//===----------------------------------------------------------------------===//
|
|
8880
8788
|
|
|
8881
|
-
namespace duckdb {
|
|
8882
|
-
class BaseStatistics;
|
|
8883
|
-
class FieldWriter;
|
|
8884
|
-
class FieldReader;
|
|
8885
|
-
class ClientContext;
|
|
8886
|
-
|
|
8887
|
-
//! The Expression class represents a bound Expression with a return type
|
|
8888
|
-
class Expression : public BaseExpression {
|
|
8889
|
-
public:
|
|
8890
|
-
Expression(ExpressionType type, ExpressionClass expression_class, LogicalType return_type);
|
|
8891
|
-
~Expression() override;
|
|
8892
8789
|
|
|
8893
|
-
//! The return type of the expression
|
|
8894
|
-
LogicalType return_type;
|
|
8895
|
-
//! Expression statistics (if any) - ONLY USED FOR VERIFICATION
|
|
8896
|
-
unique_ptr<BaseStatistics> verification_stats;
|
|
8897
8790
|
|
|
8898
|
-
public:
|
|
8899
|
-
bool IsAggregate() const override;
|
|
8900
|
-
bool IsWindow() const override;
|
|
8901
|
-
bool HasSubquery() const override;
|
|
8902
|
-
bool IsScalar() const override;
|
|
8903
|
-
bool HasParameter() const override;
|
|
8904
|
-
virtual bool HasSideEffects() const;
|
|
8905
|
-
virtual bool PropagatesNullValues() const;
|
|
8906
|
-
virtual bool IsFoldable() const;
|
|
8907
8791
|
|
|
8908
|
-
hash_t Hash() const override;
|
|
8909
8792
|
|
|
8910
|
-
bool Equals(const BaseExpression *other) const override {
|
|
8911
|
-
if (!BaseExpression::Equals(other)) {
|
|
8912
|
-
return false;
|
|
8913
|
-
}
|
|
8914
|
-
return return_type == ((Expression *)other)->return_type;
|
|
8915
|
-
}
|
|
8916
8793
|
|
|
8917
|
-
static bool Equals(Expression *left, Expression *right) {
|
|
8918
|
-
return BaseExpression::Equals((BaseExpression *)left, (BaseExpression *)right);
|
|
8919
|
-
}
|
|
8920
|
-
//! Create a copy of this expression
|
|
8921
|
-
virtual unique_ptr<Expression> Copy() = 0;
|
|
8922
8794
|
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
//! Serializes an Expression to a stand-alone binary blob
|
|
8926
|
-
virtual void Serialize(FieldWriter &writer) const = 0;
|
|
8795
|
+
namespace duckdb {
|
|
8796
|
+
class Expression;
|
|
8927
8797
|
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8798
|
+
struct ExpressionHashFunction {
|
|
8799
|
+
uint64_t operator()(const BaseExpression *const &expr) const {
|
|
8800
|
+
return (uint64_t)expr->Hash();
|
|
8801
|
+
}
|
|
8802
|
+
};
|
|
8931
8803
|
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
void CopyProperties(Expression &other) {
|
|
8936
|
-
type = other.type;
|
|
8937
|
-
expression_class = other.expression_class;
|
|
8938
|
-
alias = other.alias;
|
|
8939
|
-
return_type = other.return_type;
|
|
8804
|
+
struct ExpressionEquality {
|
|
8805
|
+
bool operator()(const BaseExpression *const &a, const BaseExpression *const &b) const {
|
|
8806
|
+
return a->Equals(b);
|
|
8940
8807
|
}
|
|
8941
8808
|
};
|
|
8942
8809
|
|
|
8810
|
+
template <typename T>
|
|
8811
|
+
using expression_map_t = unordered_map<BaseExpression *, T, ExpressionHashFunction, ExpressionEquality>;
|
|
8812
|
+
|
|
8813
|
+
using expression_set_t = unordered_set<BaseExpression *, ExpressionHashFunction, ExpressionEquality>;
|
|
8814
|
+
|
|
8943
8815
|
} // namespace duckdb
|
|
8944
8816
|
|
|
8945
8817
|
//===----------------------------------------------------------------------===//
|
|
@@ -9118,7 +8990,7 @@ protected:
|
|
|
9118
8990
|
//===----------------------------------------------------------------------===//
|
|
9119
8991
|
// DuckDB
|
|
9120
8992
|
//
|
|
9121
|
-
// duckdb/
|
|
8993
|
+
// duckdb/storage/statistics/distinct_statistics.hpp
|
|
9122
8994
|
//
|
|
9123
8995
|
//
|
|
9124
8996
|
//===----------------------------------------------------------------------===//
|
|
@@ -9126,30 +8998,920 @@ protected:
|
|
|
9126
8998
|
|
|
9127
8999
|
|
|
9128
9000
|
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9001
|
+
//===----------------------------------------------------------------------===//
|
|
9002
|
+
// DuckDB
|
|
9003
|
+
//
|
|
9004
|
+
// duckdb/common/types/hyperloglog.hpp
|
|
9005
|
+
//
|
|
9006
|
+
//
|
|
9007
|
+
//===----------------------------------------------------------------------===//
|
|
9132
9008
|
|
|
9133
|
-
struct ColumnBinding {
|
|
9134
|
-
idx_t table_index;
|
|
9135
|
-
idx_t column_index;
|
|
9136
9009
|
|
|
9137
|
-
ColumnBinding() : table_index(DConstants::INVALID_INDEX), column_index(DConstants::INVALID_INDEX) {
|
|
9138
|
-
}
|
|
9139
|
-
ColumnBinding(idx_t table, idx_t column) : table_index(table), column_index(column) {
|
|
9140
|
-
}
|
|
9141
9010
|
|
|
9142
|
-
bool operator==(const ColumnBinding &rhs) const {
|
|
9143
|
-
return table_index == rhs.table_index && column_index == rhs.column_index;
|
|
9144
|
-
}
|
|
9145
|
-
};
|
|
9146
9011
|
|
|
9147
|
-
} // namespace duckdb
|
|
9148
9012
|
|
|
9149
9013
|
|
|
9150
9014
|
|
|
9151
|
-
|
|
9152
|
-
#
|
|
9015
|
+
// LICENSE_CHANGE_BEGIN
|
|
9016
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #1
|
|
9017
|
+
// See the end of this file for a list
|
|
9018
|
+
|
|
9019
|
+
//===----------------------------------------------------------------------===//
|
|
9020
|
+
// DuckDB
|
|
9021
|
+
//
|
|
9022
|
+
// third_party/hyperloglog/hyperloglog.hpp
|
|
9023
|
+
//
|
|
9024
|
+
//
|
|
9025
|
+
//===----------------------------------------------------------------------===//
|
|
9026
|
+
|
|
9027
|
+
|
|
9028
|
+
|
|
9029
|
+
#include <stdint.h>
|
|
9030
|
+
#include <string.h>
|
|
9031
|
+
|
|
9032
|
+
namespace duckdb_hll {
|
|
9033
|
+
|
|
9034
|
+
/* Error codes */
|
|
9035
|
+
#define HLL_C_OK 0
|
|
9036
|
+
#define HLL_C_ERR -1
|
|
9037
|
+
|
|
9038
|
+
typedef struct {
|
|
9039
|
+
void *ptr;
|
|
9040
|
+
} robj;
|
|
9041
|
+
|
|
9042
|
+
//! Create a new empty HyperLogLog object
|
|
9043
|
+
robj *hll_create(void);
|
|
9044
|
+
//! Convert hll from sparse to dense
|
|
9045
|
+
int hllSparseToDense(robj *o);
|
|
9046
|
+
//! Destroy the specified HyperLogLog object
|
|
9047
|
+
void hll_destroy(robj *obj);
|
|
9048
|
+
//! Add an element with the specified amount of bytes to the HyperLogLog. Returns C_ERR on failure, otherwise returns 0
|
|
9049
|
+
//! if the cardinality did not change, and 1 otherwise.
|
|
9050
|
+
int hll_add(robj *o, unsigned char *ele, size_t elesize);
|
|
9051
|
+
//! Returns the estimated amount of unique elements seen by the HyperLogLog. Returns C_OK on success, or C_ERR on
|
|
9052
|
+
//! failure.
|
|
9053
|
+
int hll_count(robj *o, size_t *result);
|
|
9054
|
+
//! Merge hll_count HyperLogLog objects into a single one. Returns NULL on failure, or the new HLL object on success.
|
|
9055
|
+
robj *hll_merge(robj **hlls, size_t hll_count);
|
|
9056
|
+
//! Get size (in bytes) of the HLL
|
|
9057
|
+
uint64_t get_size();
|
|
9058
|
+
|
|
9059
|
+
uint64_t MurmurHash64A(const void *key, int len, unsigned int seed);
|
|
9060
|
+
|
|
9061
|
+
} // namespace duckdb_hll
|
|
9062
|
+
|
|
9063
|
+
namespace duckdb {
|
|
9064
|
+
|
|
9065
|
+
void AddToLogsInternal(UnifiedVectorFormat &vdata, idx_t count, uint64_t indices[], uint8_t counts[], void ***logs[],
|
|
9066
|
+
const SelectionVector *log_sel);
|
|
9067
|
+
|
|
9068
|
+
void AddToSingleLogInternal(UnifiedVectorFormat &vdata, idx_t count, uint64_t indices[], uint8_t counts[], void *log);
|
|
9069
|
+
|
|
9070
|
+
} // namespace duckdb
|
|
9071
|
+
|
|
9072
|
+
|
|
9073
|
+
// LICENSE_CHANGE_END
|
|
9074
|
+
|
|
9075
|
+
|
|
9076
|
+
namespace duckdb {
|
|
9077
|
+
|
|
9078
|
+
enum class HLLStorageType { UNCOMPRESSED = 1 };
|
|
9079
|
+
|
|
9080
|
+
class FieldWriter;
|
|
9081
|
+
class FieldReader;
|
|
9082
|
+
|
|
9083
|
+
//! The HyperLogLog class holds a HyperLogLog counter for approximate cardinality counting
|
|
9084
|
+
class HyperLogLog {
|
|
9085
|
+
public:
|
|
9086
|
+
HyperLogLog();
|
|
9087
|
+
~HyperLogLog();
|
|
9088
|
+
// implicit copying of HyperLogLog is not allowed
|
|
9089
|
+
HyperLogLog(const HyperLogLog &) = delete;
|
|
9090
|
+
|
|
9091
|
+
//! Adds an element of the specified size to the HyperLogLog counter
|
|
9092
|
+
void Add(data_ptr_t element, idx_t size);
|
|
9093
|
+
//! Return the count of this HyperLogLog counter
|
|
9094
|
+
idx_t Count() const;
|
|
9095
|
+
//! Merge this HyperLogLog counter with another counter to create a new one
|
|
9096
|
+
unique_ptr<HyperLogLog> Merge(HyperLogLog &other);
|
|
9097
|
+
HyperLogLog *MergePointer(HyperLogLog &other);
|
|
9098
|
+
//! Merge a set of HyperLogLogs to create one big one
|
|
9099
|
+
static unique_ptr<HyperLogLog> Merge(HyperLogLog logs[], idx_t count);
|
|
9100
|
+
//! Get the size (in bytes) of a HLL
|
|
9101
|
+
static idx_t GetSize();
|
|
9102
|
+
//! Get pointer to the HLL
|
|
9103
|
+
data_ptr_t GetPtr() const;
|
|
9104
|
+
//! Get copy of the HLL
|
|
9105
|
+
unique_ptr<HyperLogLog> Copy();
|
|
9106
|
+
//! (De)Serialize the HLL
|
|
9107
|
+
void Serialize(FieldWriter &writer) const;
|
|
9108
|
+
static unique_ptr<HyperLogLog> Deserialize(FieldReader &reader);
|
|
9109
|
+
|
|
9110
|
+
public:
|
|
9111
|
+
//! Compute HLL hashes over vdata, and store them in 'hashes'
|
|
9112
|
+
//! Then, compute register indices and prefix lengths, and also store them in 'hashes' as a pair of uint32_t
|
|
9113
|
+
static void ProcessEntries(UnifiedVectorFormat &vdata, const LogicalType &type, uint64_t hashes[], uint8_t counts[],
|
|
9114
|
+
idx_t count);
|
|
9115
|
+
//! Add the indices and counts to the logs
|
|
9116
|
+
static void AddToLogs(UnifiedVectorFormat &vdata, idx_t count, uint64_t indices[], uint8_t counts[],
|
|
9117
|
+
HyperLogLog **logs[], const SelectionVector *log_sel);
|
|
9118
|
+
//! Add the indices and counts to THIS log
|
|
9119
|
+
void AddToLog(UnifiedVectorFormat &vdata, idx_t count, uint64_t indices[], uint8_t counts[]);
|
|
9120
|
+
|
|
9121
|
+
private:
|
|
9122
|
+
explicit HyperLogLog(void *hll);
|
|
9123
|
+
|
|
9124
|
+
void *hll;
|
|
9125
|
+
mutex lock;
|
|
9126
|
+
};
|
|
9127
|
+
} // namespace duckdb
|
|
9128
|
+
|
|
9129
|
+
|
|
9130
|
+
|
|
9131
|
+
namespace duckdb {
|
|
9132
|
+
class Serializer;
|
|
9133
|
+
class Deserializer;
|
|
9134
|
+
class Vector;
|
|
9135
|
+
|
|
9136
|
+
class DistinctStatistics : public BaseStatistics {
|
|
9137
|
+
public:
|
|
9138
|
+
DistinctStatistics();
|
|
9139
|
+
explicit DistinctStatistics(unique_ptr<HyperLogLog> log, idx_t sample_count, idx_t total_count);
|
|
9140
|
+
|
|
9141
|
+
//! The HLL of the table
|
|
9142
|
+
unique_ptr<HyperLogLog> log;
|
|
9143
|
+
//! How many values have been sampled into the HLL
|
|
9144
|
+
atomic<idx_t> sample_count;
|
|
9145
|
+
//! How many values have been inserted (before sampling)
|
|
9146
|
+
atomic<idx_t> total_count;
|
|
9147
|
+
|
|
9148
|
+
public:
|
|
9149
|
+
void Merge(const BaseStatistics &other) override;
|
|
9150
|
+
|
|
9151
|
+
unique_ptr<BaseStatistics> Copy() const override;
|
|
9152
|
+
|
|
9153
|
+
void Serialize(Serializer &serializer) const override;
|
|
9154
|
+
void Serialize(FieldWriter &writer) const override;
|
|
9155
|
+
|
|
9156
|
+
static unique_ptr<DistinctStatistics> Deserialize(Deserializer &source);
|
|
9157
|
+
static unique_ptr<DistinctStatistics> Deserialize(FieldReader &reader);
|
|
9158
|
+
|
|
9159
|
+
void Update(Vector &update, idx_t count, bool sample = true);
|
|
9160
|
+
void Update(UnifiedVectorFormat &update_data, const LogicalType &ptype, idx_t count, bool sample = true);
|
|
9161
|
+
|
|
9162
|
+
string ToString() const override;
|
|
9163
|
+
idx_t GetCount() const;
|
|
9164
|
+
|
|
9165
|
+
private:
|
|
9166
|
+
//! For distinct statistics we sample the input to speed up insertions
|
|
9167
|
+
static constexpr const double SAMPLE_RATE = 0.1;
|
|
9168
|
+
};
|
|
9169
|
+
|
|
9170
|
+
} // namespace duckdb
|
|
9171
|
+
|
|
9172
|
+
//===----------------------------------------------------------------------===//
|
|
9173
|
+
// DuckDB
|
|
9174
|
+
//
|
|
9175
|
+
// duckdb/planner/table_filter.hpp
|
|
9176
|
+
//
|
|
9177
|
+
//
|
|
9178
|
+
//===----------------------------------------------------------------------===//
|
|
9179
|
+
|
|
9180
|
+
|
|
9181
|
+
|
|
9182
|
+
|
|
9183
|
+
|
|
9184
|
+
|
|
9185
|
+
//===----------------------------------------------------------------------===//
|
|
9186
|
+
// DuckDB
|
|
9187
|
+
//
|
|
9188
|
+
// duckdb/common/enums/filter_propagate_result.hpp
|
|
9189
|
+
//
|
|
9190
|
+
//
|
|
9191
|
+
//===----------------------------------------------------------------------===//
|
|
9192
|
+
|
|
9193
|
+
|
|
9194
|
+
|
|
9195
|
+
|
|
9196
|
+
|
|
9197
|
+
namespace duckdb {
|
|
9198
|
+
|
|
9199
|
+
enum class FilterPropagateResult : uint8_t {
|
|
9200
|
+
NO_PRUNING_POSSIBLE = 0,
|
|
9201
|
+
FILTER_ALWAYS_TRUE = 1,
|
|
9202
|
+
FILTER_ALWAYS_FALSE = 2,
|
|
9203
|
+
FILTER_TRUE_OR_NULL = 3,
|
|
9204
|
+
FILTER_FALSE_OR_NULL = 4
|
|
9205
|
+
};
|
|
9206
|
+
|
|
9207
|
+
} // namespace duckdb
|
|
9208
|
+
|
|
9209
|
+
|
|
9210
|
+
namespace duckdb {
|
|
9211
|
+
class BaseStatistics;
|
|
9212
|
+
class FieldWriter;
|
|
9213
|
+
class FieldReader;
|
|
9214
|
+
|
|
9215
|
+
enum class TableFilterType : uint8_t {
|
|
9216
|
+
CONSTANT_COMPARISON = 0, // constant comparison (e.g. =C, >C, >=C, <C, <=C)
|
|
9217
|
+
IS_NULL = 1,
|
|
9218
|
+
IS_NOT_NULL = 2,
|
|
9219
|
+
CONJUNCTION_OR = 3,
|
|
9220
|
+
CONJUNCTION_AND = 4
|
|
9221
|
+
};
|
|
9222
|
+
|
|
9223
|
+
//! TableFilter represents a filter pushed down into the table scan.
|
|
9224
|
+
class TableFilter {
|
|
9225
|
+
public:
|
|
9226
|
+
TableFilter(TableFilterType filter_type_p) : filter_type(filter_type_p) {
|
|
9227
|
+
}
|
|
9228
|
+
virtual ~TableFilter() {
|
|
9229
|
+
}
|
|
9230
|
+
|
|
9231
|
+
TableFilterType filter_type;
|
|
9232
|
+
|
|
9233
|
+
public:
|
|
9234
|
+
//! Returns true if the statistics indicate that the segment can contain values that satisfy that filter
|
|
9235
|
+
virtual FilterPropagateResult CheckStatistics(BaseStatistics &stats) = 0;
|
|
9236
|
+
virtual string ToString(const string &column_name) = 0;
|
|
9237
|
+
virtual bool Equals(const TableFilter &other) const {
|
|
9238
|
+
return filter_type != other.filter_type;
|
|
9239
|
+
}
|
|
9240
|
+
|
|
9241
|
+
void Serialize(Serializer &serializer) const;
|
|
9242
|
+
virtual void Serialize(FieldWriter &writer) const = 0;
|
|
9243
|
+
static unique_ptr<TableFilter> Deserialize(Deserializer &source);
|
|
9244
|
+
};
|
|
9245
|
+
|
|
9246
|
+
class TableFilterSet {
|
|
9247
|
+
public:
|
|
9248
|
+
unordered_map<idx_t, unique_ptr<TableFilter>> filters;
|
|
9249
|
+
|
|
9250
|
+
public:
|
|
9251
|
+
void PushFilter(idx_t table_index, unique_ptr<TableFilter> filter);
|
|
9252
|
+
|
|
9253
|
+
bool Equals(TableFilterSet &other) {
|
|
9254
|
+
if (filters.size() != other.filters.size()) {
|
|
9255
|
+
return false;
|
|
9256
|
+
}
|
|
9257
|
+
for (auto &entry : filters) {
|
|
9258
|
+
auto other_entry = other.filters.find(entry.first);
|
|
9259
|
+
if (other_entry == other.filters.end()) {
|
|
9260
|
+
return false;
|
|
9261
|
+
}
|
|
9262
|
+
if (!entry.second->Equals(*other_entry->second)) {
|
|
9263
|
+
return false;
|
|
9264
|
+
}
|
|
9265
|
+
}
|
|
9266
|
+
return true;
|
|
9267
|
+
}
|
|
9268
|
+
static bool Equals(TableFilterSet *left, TableFilterSet *right) {
|
|
9269
|
+
if (left == right) {
|
|
9270
|
+
return true;
|
|
9271
|
+
}
|
|
9272
|
+
if (!left || !right) {
|
|
9273
|
+
return false;
|
|
9274
|
+
}
|
|
9275
|
+
return left->Equals(*right);
|
|
9276
|
+
}
|
|
9277
|
+
|
|
9278
|
+
void Serialize(Serializer &serializer) const;
|
|
9279
|
+
static unique_ptr<TableFilterSet> Deserialize(Deserializer &source);
|
|
9280
|
+
};
|
|
9281
|
+
|
|
9282
|
+
} // namespace duckdb
|
|
9283
|
+
|
|
9284
|
+
//===----------------------------------------------------------------------===//
|
|
9285
|
+
// DuckDB
|
|
9286
|
+
//
|
|
9287
|
+
// duckdb/catalog/catalog_entry/table_catalog_entry.hpp
|
|
9288
|
+
//
|
|
9289
|
+
//
|
|
9290
|
+
//===----------------------------------------------------------------------===//
|
|
9291
|
+
|
|
9292
|
+
|
|
9293
|
+
|
|
9294
|
+
//===----------------------------------------------------------------------===//
|
|
9295
|
+
// DuckDB
|
|
9296
|
+
//
|
|
9297
|
+
// duckdb/catalog/standard_entry.hpp
|
|
9298
|
+
//
|
|
9299
|
+
//
|
|
9300
|
+
//===----------------------------------------------------------------------===//
|
|
9301
|
+
|
|
9302
|
+
|
|
9303
|
+
|
|
9304
|
+
|
|
9305
|
+
|
|
9306
|
+
namespace duckdb {
|
|
9307
|
+
class SchemaCatalogEntry;
|
|
9308
|
+
|
|
9309
|
+
//! A StandardEntry is a catalog entry that is a member of a schema
|
|
9310
|
+
class StandardEntry : public CatalogEntry {
|
|
9311
|
+
public:
|
|
9312
|
+
StandardEntry(CatalogType type, SchemaCatalogEntry *schema, Catalog *catalog, string name)
|
|
9313
|
+
: CatalogEntry(type, catalog, name), schema(schema) {
|
|
9314
|
+
}
|
|
9315
|
+
~StandardEntry() override {
|
|
9316
|
+
}
|
|
9317
|
+
|
|
9318
|
+
//! The schema the entry belongs to
|
|
9319
|
+
SchemaCatalogEntry *schema;
|
|
9320
|
+
};
|
|
9321
|
+
} // namespace duckdb
|
|
9322
|
+
|
|
9323
|
+
|
|
9324
|
+
|
|
9325
|
+
//===----------------------------------------------------------------------===//
|
|
9326
|
+
// DuckDB
|
|
9327
|
+
//
|
|
9328
|
+
// duckdb/parser/constraint.hpp
|
|
9329
|
+
//
|
|
9330
|
+
//
|
|
9331
|
+
//===----------------------------------------------------------------------===//
|
|
9332
|
+
|
|
9333
|
+
|
|
9334
|
+
|
|
9335
|
+
|
|
9336
|
+
|
|
9337
|
+
|
|
9338
|
+
namespace duckdb {
|
|
9339
|
+
|
|
9340
|
+
class Serializer;
|
|
9341
|
+
class Deserializer;
|
|
9342
|
+
class FieldWriter;
|
|
9343
|
+
class FieldReader;
|
|
9344
|
+
|
|
9345
|
+
//===--------------------------------------------------------------------===//
|
|
9346
|
+
// Constraint Types
|
|
9347
|
+
//===--------------------------------------------------------------------===//
|
|
9348
|
+
enum class ConstraintType : uint8_t {
|
|
9349
|
+
INVALID = 0, // invalid constraint type
|
|
9350
|
+
NOT_NULL = 1, // NOT NULL constraint
|
|
9351
|
+
CHECK = 2, // CHECK constraint
|
|
9352
|
+
UNIQUE = 3, // UNIQUE constraint
|
|
9353
|
+
FOREIGN_KEY = 4, // FOREIGN KEY constraint
|
|
9354
|
+
};
|
|
9355
|
+
|
|
9356
|
+
enum class ForeignKeyType : uint8_t {
|
|
9357
|
+
FK_TYPE_PRIMARY_KEY_TABLE = 0, // main table
|
|
9358
|
+
FK_TYPE_FOREIGN_KEY_TABLE = 1, // referencing table
|
|
9359
|
+
FK_TYPE_SELF_REFERENCE_TABLE = 2 // self refrencing table
|
|
9360
|
+
};
|
|
9361
|
+
|
|
9362
|
+
struct ForeignKeyInfo {
|
|
9363
|
+
ForeignKeyType type;
|
|
9364
|
+
string schema;
|
|
9365
|
+
//! if type is FK_TYPE_FOREIGN_KEY_TABLE, means main key table, if type is FK_TYPE_PRIMARY_KEY_TABLE, means foreign
|
|
9366
|
+
//! key table
|
|
9367
|
+
string table;
|
|
9368
|
+
//! The set of main key table's column's index
|
|
9369
|
+
vector<storage_t> pk_keys;
|
|
9370
|
+
//! The set of foreign key table's column's index
|
|
9371
|
+
vector<idx_t> fk_keys;
|
|
9372
|
+
};
|
|
9373
|
+
|
|
9374
|
+
//! Constraint is the base class of any type of table constraint.
|
|
9375
|
+
class Constraint {
|
|
9376
|
+
public:
|
|
9377
|
+
DUCKDB_API explicit Constraint(ConstraintType type);
|
|
9378
|
+
DUCKDB_API virtual ~Constraint();
|
|
9379
|
+
|
|
9380
|
+
ConstraintType type;
|
|
9381
|
+
|
|
9382
|
+
public:
|
|
9383
|
+
DUCKDB_API virtual string ToString() const = 0;
|
|
9384
|
+
DUCKDB_API void Print() const;
|
|
9385
|
+
|
|
9386
|
+
DUCKDB_API virtual unique_ptr<Constraint> Copy() const = 0;
|
|
9387
|
+
//! Serializes a Constraint to a stand-alone binary blob
|
|
9388
|
+
DUCKDB_API void Serialize(Serializer &serializer) const;
|
|
9389
|
+
//! Serializes a Constraint to a stand-alone binary blob
|
|
9390
|
+
DUCKDB_API virtual void Serialize(FieldWriter &writer) const = 0;
|
|
9391
|
+
//! Deserializes a blob back into a Constraint
|
|
9392
|
+
DUCKDB_API static unique_ptr<Constraint> Deserialize(Deserializer &source);
|
|
9393
|
+
};
|
|
9394
|
+
} // namespace duckdb
|
|
9395
|
+
|
|
9396
|
+
//===----------------------------------------------------------------------===//
|
|
9397
|
+
// DuckDB
|
|
9398
|
+
//
|
|
9399
|
+
// duckdb/planner/bound_constraint.hpp
|
|
9400
|
+
//
|
|
9401
|
+
//
|
|
9402
|
+
//===----------------------------------------------------------------------===//
|
|
9403
|
+
|
|
9404
|
+
|
|
9405
|
+
|
|
9406
|
+
|
|
9407
|
+
|
|
9408
|
+
|
|
9409
|
+
|
|
9410
|
+
namespace duckdb {
|
|
9411
|
+
//! Bound equivalent of Constraint
|
|
9412
|
+
class BoundConstraint {
|
|
9413
|
+
public:
|
|
9414
|
+
explicit BoundConstraint(ConstraintType type) : type(type) {};
|
|
9415
|
+
virtual ~BoundConstraint() {
|
|
9416
|
+
}
|
|
9417
|
+
|
|
9418
|
+
void Serialize(Serializer &serializer) const {
|
|
9419
|
+
serializer.Write(type);
|
|
9420
|
+
}
|
|
9421
|
+
|
|
9422
|
+
static unique_ptr<BoundConstraint> Deserialize(Deserializer &source) {
|
|
9423
|
+
return make_unique<BoundConstraint>(source.Read<ConstraintType>());
|
|
9424
|
+
}
|
|
9425
|
+
|
|
9426
|
+
ConstraintType type;
|
|
9427
|
+
};
|
|
9428
|
+
} // namespace duckdb
|
|
9429
|
+
|
|
9430
|
+
//===----------------------------------------------------------------------===//
|
|
9431
|
+
// DuckDB
|
|
9432
|
+
//
|
|
9433
|
+
// duckdb/planner/expression.hpp
|
|
9434
|
+
//
|
|
9435
|
+
//
|
|
9436
|
+
//===----------------------------------------------------------------------===//
|
|
9437
|
+
|
|
9438
|
+
|
|
9439
|
+
|
|
9440
|
+
|
|
9441
|
+
|
|
9442
|
+
//===----------------------------------------------------------------------===//
|
|
9443
|
+
// DuckDB
|
|
9444
|
+
//
|
|
9445
|
+
// duckdb/planner/plan_serialization.hpp
|
|
9446
|
+
//
|
|
9447
|
+
//
|
|
9448
|
+
//===----------------------------------------------------------------------===//
|
|
9449
|
+
|
|
9450
|
+
|
|
9451
|
+
|
|
9452
|
+
//===----------------------------------------------------------------------===//
|
|
9453
|
+
// DuckDB
|
|
9454
|
+
//
|
|
9455
|
+
// duckdb/common/enums/logical_operator_type.hpp
|
|
9456
|
+
//
|
|
9457
|
+
//
|
|
9458
|
+
//===----------------------------------------------------------------------===//
|
|
9459
|
+
|
|
9460
|
+
|
|
9461
|
+
|
|
9462
|
+
|
|
9463
|
+
|
|
9464
|
+
namespace duckdb {
|
|
9465
|
+
|
|
9466
|
+
//===--------------------------------------------------------------------===//
|
|
9467
|
+
// Logical Operator Types
|
|
9468
|
+
//===--------------------------------------------------------------------===//
|
|
9469
|
+
enum class LogicalOperatorType : uint8_t {
|
|
9470
|
+
LOGICAL_INVALID = 0,
|
|
9471
|
+
LOGICAL_PROJECTION = 1,
|
|
9472
|
+
LOGICAL_FILTER = 2,
|
|
9473
|
+
LOGICAL_AGGREGATE_AND_GROUP_BY = 3,
|
|
9474
|
+
LOGICAL_WINDOW = 4,
|
|
9475
|
+
LOGICAL_UNNEST = 5,
|
|
9476
|
+
LOGICAL_LIMIT = 6,
|
|
9477
|
+
LOGICAL_ORDER_BY = 7,
|
|
9478
|
+
LOGICAL_TOP_N = 8,
|
|
9479
|
+
LOGICAL_COPY_TO_FILE = 10,
|
|
9480
|
+
LOGICAL_DISTINCT = 11,
|
|
9481
|
+
LOGICAL_SAMPLE = 12,
|
|
9482
|
+
LOGICAL_LIMIT_PERCENT = 13,
|
|
9483
|
+
|
|
9484
|
+
// -----------------------------
|
|
9485
|
+
// Data sources
|
|
9486
|
+
// -----------------------------
|
|
9487
|
+
LOGICAL_GET = 25,
|
|
9488
|
+
LOGICAL_CHUNK_GET = 26,
|
|
9489
|
+
LOGICAL_DELIM_GET = 27,
|
|
9490
|
+
LOGICAL_EXPRESSION_GET = 28,
|
|
9491
|
+
LOGICAL_DUMMY_SCAN = 29,
|
|
9492
|
+
LOGICAL_EMPTY_RESULT = 30,
|
|
9493
|
+
LOGICAL_CTE_REF = 31,
|
|
9494
|
+
// -----------------------------
|
|
9495
|
+
// Joins
|
|
9496
|
+
// -----------------------------
|
|
9497
|
+
LOGICAL_JOIN = 50,
|
|
9498
|
+
LOGICAL_DELIM_JOIN = 51,
|
|
9499
|
+
LOGICAL_COMPARISON_JOIN = 52,
|
|
9500
|
+
LOGICAL_ANY_JOIN = 53,
|
|
9501
|
+
LOGICAL_CROSS_PRODUCT = 54,
|
|
9502
|
+
// -----------------------------
|
|
9503
|
+
// SetOps
|
|
9504
|
+
// -----------------------------
|
|
9505
|
+
LOGICAL_UNION = 75,
|
|
9506
|
+
LOGICAL_EXCEPT = 76,
|
|
9507
|
+
LOGICAL_INTERSECT = 77,
|
|
9508
|
+
LOGICAL_RECURSIVE_CTE = 78,
|
|
9509
|
+
|
|
9510
|
+
// -----------------------------
|
|
9511
|
+
// Updates
|
|
9512
|
+
// -----------------------------
|
|
9513
|
+
LOGICAL_INSERT = 100,
|
|
9514
|
+
LOGICAL_DELETE = 101,
|
|
9515
|
+
LOGICAL_UPDATE = 102,
|
|
9516
|
+
|
|
9517
|
+
// -----------------------------
|
|
9518
|
+
// Schema
|
|
9519
|
+
// -----------------------------
|
|
9520
|
+
LOGICAL_ALTER = 125,
|
|
9521
|
+
LOGICAL_CREATE_TABLE = 126,
|
|
9522
|
+
LOGICAL_CREATE_INDEX = 127,
|
|
9523
|
+
LOGICAL_CREATE_SEQUENCE = 128,
|
|
9524
|
+
LOGICAL_CREATE_VIEW = 129,
|
|
9525
|
+
LOGICAL_CREATE_SCHEMA = 130,
|
|
9526
|
+
LOGICAL_CREATE_MACRO = 131,
|
|
9527
|
+
LOGICAL_DROP = 132,
|
|
9528
|
+
LOGICAL_PRAGMA = 133,
|
|
9529
|
+
LOGICAL_TRANSACTION = 134,
|
|
9530
|
+
LOGICAL_CREATE_TYPE = 135,
|
|
9531
|
+
|
|
9532
|
+
// -----------------------------
|
|
9533
|
+
// Explain
|
|
9534
|
+
// -----------------------------
|
|
9535
|
+
LOGICAL_EXPLAIN = 150,
|
|
9536
|
+
|
|
9537
|
+
// -----------------------------
|
|
9538
|
+
// Show
|
|
9539
|
+
// -----------------------------
|
|
9540
|
+
LOGICAL_SHOW = 160,
|
|
9541
|
+
|
|
9542
|
+
// -----------------------------
|
|
9543
|
+
// Helpers
|
|
9544
|
+
// -----------------------------
|
|
9545
|
+
LOGICAL_PREPARE = 175,
|
|
9546
|
+
LOGICAL_EXECUTE = 176,
|
|
9547
|
+
LOGICAL_EXPORT = 177,
|
|
9548
|
+
LOGICAL_VACUUM = 178,
|
|
9549
|
+
LOGICAL_SET = 179,
|
|
9550
|
+
LOGICAL_LOAD = 180
|
|
9551
|
+
};
|
|
9552
|
+
|
|
9553
|
+
DUCKDB_API string LogicalOperatorToString(LogicalOperatorType type);
|
|
9554
|
+
|
|
9555
|
+
} // namespace duckdb
|
|
9556
|
+
|
|
9557
|
+
|
|
9558
|
+
//===----------------------------------------------------------------------===//
|
|
9559
|
+
// DuckDB
|
|
9560
|
+
//
|
|
9561
|
+
// duckdb/planner/bound_parameter_map.hpp
|
|
9562
|
+
//
|
|
9563
|
+
//
|
|
9564
|
+
//===----------------------------------------------------------------------===//
|
|
9565
|
+
|
|
9566
|
+
|
|
9567
|
+
|
|
9568
|
+
|
|
9569
|
+
|
|
9570
|
+
|
|
9571
|
+
namespace duckdb {
|
|
9572
|
+
|
|
9573
|
+
struct BoundParameterData;
|
|
9574
|
+
|
|
9575
|
+
using bound_parameter_map_t = unordered_map<idx_t, shared_ptr<BoundParameterData>>;
|
|
9576
|
+
|
|
9577
|
+
} // namespace duckdb
|
|
9578
|
+
|
|
9579
|
+
|
|
9580
|
+
namespace duckdb {
|
|
9581
|
+
class ClientContext;
|
|
9582
|
+
class LogicalOperator;
|
|
9583
|
+
struct BoundParameterData;
|
|
9584
|
+
|
|
9585
|
+
struct PlanDeserializationState {
|
|
9586
|
+
PlanDeserializationState(ClientContext &context);
|
|
9587
|
+
~PlanDeserializationState();
|
|
9588
|
+
|
|
9589
|
+
ClientContext &context;
|
|
9590
|
+
bound_parameter_map_t parameter_data;
|
|
9591
|
+
};
|
|
9592
|
+
|
|
9593
|
+
struct LogicalDeserializationState {
|
|
9594
|
+
LogicalDeserializationState(PlanDeserializationState &gstate, LogicalOperatorType type,
|
|
9595
|
+
vector<unique_ptr<LogicalOperator>> &children);
|
|
9596
|
+
|
|
9597
|
+
PlanDeserializationState &gstate;
|
|
9598
|
+
LogicalOperatorType type;
|
|
9599
|
+
vector<unique_ptr<LogicalOperator>> &children;
|
|
9600
|
+
};
|
|
9601
|
+
|
|
9602
|
+
struct ExpressionDeserializationState {
|
|
9603
|
+
ExpressionDeserializationState(PlanDeserializationState &gstate, ExpressionType type);
|
|
9604
|
+
|
|
9605
|
+
PlanDeserializationState &gstate;
|
|
9606
|
+
ExpressionType type;
|
|
9607
|
+
};
|
|
9608
|
+
|
|
9609
|
+
} // namespace duckdb
|
|
9610
|
+
|
|
9611
|
+
|
|
9612
|
+
namespace duckdb {
|
|
9613
|
+
class BaseStatistics;
|
|
9614
|
+
class FieldWriter;
|
|
9615
|
+
class FieldReader;
|
|
9616
|
+
class ClientContext;
|
|
9617
|
+
|
|
9618
|
+
//! The Expression class represents a bound Expression with a return type
|
|
9619
|
+
class Expression : public BaseExpression {
|
|
9620
|
+
public:
|
|
9621
|
+
Expression(ExpressionType type, ExpressionClass expression_class, LogicalType return_type);
|
|
9622
|
+
~Expression() override;
|
|
9623
|
+
|
|
9624
|
+
//! The return type of the expression
|
|
9625
|
+
LogicalType return_type;
|
|
9626
|
+
//! Expression statistics (if any) - ONLY USED FOR VERIFICATION
|
|
9627
|
+
unique_ptr<BaseStatistics> verification_stats;
|
|
9628
|
+
|
|
9629
|
+
public:
|
|
9630
|
+
bool IsAggregate() const override;
|
|
9631
|
+
bool IsWindow() const override;
|
|
9632
|
+
bool HasSubquery() const override;
|
|
9633
|
+
bool IsScalar() const override;
|
|
9634
|
+
bool HasParameter() const override;
|
|
9635
|
+
virtual bool HasSideEffects() const;
|
|
9636
|
+
virtual bool PropagatesNullValues() const;
|
|
9637
|
+
virtual bool IsFoldable() const;
|
|
9638
|
+
|
|
9639
|
+
hash_t Hash() const override;
|
|
9640
|
+
|
|
9641
|
+
bool Equals(const BaseExpression *other) const override {
|
|
9642
|
+
if (!BaseExpression::Equals(other)) {
|
|
9643
|
+
return false;
|
|
9644
|
+
}
|
|
9645
|
+
return return_type == ((Expression *)other)->return_type;
|
|
9646
|
+
}
|
|
9647
|
+
|
|
9648
|
+
static bool Equals(Expression *left, Expression *right) {
|
|
9649
|
+
return BaseExpression::Equals((BaseExpression *)left, (BaseExpression *)right);
|
|
9650
|
+
}
|
|
9651
|
+
//! Create a copy of this expression
|
|
9652
|
+
virtual unique_ptr<Expression> Copy() = 0;
|
|
9653
|
+
|
|
9654
|
+
//! Serializes an Expression to a stand-alone binary blob
|
|
9655
|
+
void Serialize(Serializer &serializer) const;
|
|
9656
|
+
//! Serializes an Expression to a stand-alone binary blob
|
|
9657
|
+
virtual void Serialize(FieldWriter &writer) const = 0;
|
|
9658
|
+
|
|
9659
|
+
//! Deserializes a blob back into an Expression [CAN THROW:
|
|
9660
|
+
//! SerializationException]
|
|
9661
|
+
static unique_ptr<Expression> Deserialize(Deserializer &source, PlanDeserializationState &state);
|
|
9662
|
+
|
|
9663
|
+
protected:
|
|
9664
|
+
//! Copy base Expression properties from another expression to this one,
|
|
9665
|
+
//! used in Copy method
|
|
9666
|
+
void CopyProperties(Expression &other) {
|
|
9667
|
+
type = other.type;
|
|
9668
|
+
expression_class = other.expression_class;
|
|
9669
|
+
alias = other.alias;
|
|
9670
|
+
return_type = other.return_type;
|
|
9671
|
+
}
|
|
9672
|
+
};
|
|
9673
|
+
|
|
9674
|
+
} // namespace duckdb
|
|
9675
|
+
|
|
9676
|
+
|
|
9677
|
+
|
|
9678
|
+
//===----------------------------------------------------------------------===//
|
|
9679
|
+
// DuckDB
|
|
9680
|
+
//
|
|
9681
|
+
// duckdb/catalog/catalog_entry/column_dependency_manager.hpp
|
|
9682
|
+
//
|
|
9683
|
+
//
|
|
9684
|
+
//===----------------------------------------------------------------------===//
|
|
9685
|
+
|
|
9686
|
+
|
|
9687
|
+
|
|
9688
|
+
|
|
9689
|
+
|
|
9690
|
+
|
|
9691
|
+
//===----------------------------------------------------------------------===//
|
|
9692
|
+
// DuckDB
|
|
9693
|
+
//
|
|
9694
|
+
// duckdb/common/set.hpp
|
|
9695
|
+
//
|
|
9696
|
+
//
|
|
9697
|
+
//===----------------------------------------------------------------------===//
|
|
9698
|
+
|
|
9699
|
+
|
|
9700
|
+
|
|
9701
|
+
#include <set>
|
|
9702
|
+
|
|
9703
|
+
namespace duckdb {
|
|
9704
|
+
using std::set;
|
|
9705
|
+
}
|
|
9706
|
+
|
|
9707
|
+
//===----------------------------------------------------------------------===//
|
|
9708
|
+
// DuckDB
|
|
9709
|
+
//
|
|
9710
|
+
// duckdb/common/stack.hpp
|
|
9711
|
+
//
|
|
9712
|
+
//
|
|
9713
|
+
//===----------------------------------------------------------------------===//
|
|
9714
|
+
|
|
9715
|
+
|
|
9716
|
+
|
|
9717
|
+
#include <stack>
|
|
9718
|
+
|
|
9719
|
+
namespace duckdb {
|
|
9720
|
+
using std::stack;
|
|
9721
|
+
}
|
|
9722
|
+
|
|
9723
|
+
|
|
9724
|
+
namespace duckdb {
|
|
9725
|
+
|
|
9726
|
+
//! Dependency Manager local to a table, responsible for keeping track of generated column dependencies
|
|
9727
|
+
|
|
9728
|
+
class ColumnDependencyManager {
|
|
9729
|
+
public:
|
|
9730
|
+
DUCKDB_API ColumnDependencyManager();
|
|
9731
|
+
DUCKDB_API ~ColumnDependencyManager();
|
|
9732
|
+
DUCKDB_API ColumnDependencyManager(ColumnDependencyManager &&other) = default;
|
|
9733
|
+
ColumnDependencyManager(const ColumnDependencyManager &other) = delete;
|
|
9734
|
+
|
|
9735
|
+
public:
|
|
9736
|
+
//! Get the bind order that ensures dependencies are resolved before dependents are
|
|
9737
|
+
stack<column_t> GetBindOrder(const vector<ColumnDefinition> &columns);
|
|
9738
|
+
|
|
9739
|
+
//! Adds a connection between the dependent and its dependencies
|
|
9740
|
+
void AddGeneratedColumn(column_t index, const vector<column_t> &indices, bool root = true);
|
|
9741
|
+
//! Add a generated column from a column definition
|
|
9742
|
+
void AddGeneratedColumn(const ColumnDefinition &column, const case_insensitive_map_t<column_t> &name_map);
|
|
9743
|
+
|
|
9744
|
+
//! Removes the column(s) and outputs the new column indices
|
|
9745
|
+
vector<column_t> RemoveColumn(column_t index, column_t column_amount);
|
|
9746
|
+
|
|
9747
|
+
bool IsDependencyOf(column_t dependent, column_t dependency) const;
|
|
9748
|
+
bool HasDependencies(column_t index) const;
|
|
9749
|
+
const unordered_set<column_t> &GetDependencies(column_t index) const;
|
|
9750
|
+
|
|
9751
|
+
bool HasDependents(column_t index) const;
|
|
9752
|
+
const unordered_set<column_t> &GetDependents(column_t index) const;
|
|
9753
|
+
|
|
9754
|
+
private:
|
|
9755
|
+
void RemoveStandardColumn(column_t index);
|
|
9756
|
+
void RemoveGeneratedColumn(column_t index);
|
|
9757
|
+
|
|
9758
|
+
void AdjustSingle(column_t idx, idx_t offset);
|
|
9759
|
+
// Clean up the gaps created by a Remove operation
|
|
9760
|
+
vector<column_t> CleanupInternals(column_t column_amount);
|
|
9761
|
+
|
|
9762
|
+
private:
|
|
9763
|
+
//! A map of column dependency to generated column(s)
|
|
9764
|
+
unordered_map<column_t, unordered_set<column_t>> dependencies_map;
|
|
9765
|
+
//! A map of generated column name to (potentially generated)column dependencies
|
|
9766
|
+
unordered_map<column_t, unordered_set<column_t>> dependents_map;
|
|
9767
|
+
//! For resolve-order purposes, keep track of the 'direct' (not inherited) dependencies of a generated column
|
|
9768
|
+
unordered_map<column_t, unordered_set<column_t>> direct_dependencies;
|
|
9769
|
+
set<column_t> deleted_columns;
|
|
9770
|
+
};
|
|
9771
|
+
|
|
9772
|
+
} // namespace duckdb
|
|
9773
|
+
|
|
9774
|
+
|
|
9775
|
+
namespace duckdb {
|
|
9776
|
+
|
|
9777
|
+
class DataTable;
|
|
9778
|
+
struct CreateTableInfo;
|
|
9779
|
+
struct BoundCreateTableInfo;
|
|
9780
|
+
|
|
9781
|
+
struct RenameColumnInfo;
|
|
9782
|
+
struct AddColumnInfo;
|
|
9783
|
+
struct RemoveColumnInfo;
|
|
9784
|
+
struct SetDefaultInfo;
|
|
9785
|
+
struct ChangeColumnTypeInfo;
|
|
9786
|
+
struct AlterForeignKeyInfo;
|
|
9787
|
+
struct SetNotNullInfo;
|
|
9788
|
+
struct DropNotNullInfo;
|
|
9789
|
+
|
|
9790
|
+
//! A table catalog entry
|
|
9791
|
+
class TableCatalogEntry : public StandardEntry {
|
|
9792
|
+
public:
|
|
9793
|
+
//! Create a real TableCatalogEntry and initialize storage for it
|
|
9794
|
+
TableCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, BoundCreateTableInfo *info,
|
|
9795
|
+
std::shared_ptr<DataTable> inherited_storage = nullptr);
|
|
9796
|
+
|
|
9797
|
+
//! A reference to the underlying storage unit used for this table
|
|
9798
|
+
std::shared_ptr<DataTable> storage;
|
|
9799
|
+
//! A list of columns that are part of this table
|
|
9800
|
+
vector<ColumnDefinition> columns;
|
|
9801
|
+
//! A list of constraints that are part of this table
|
|
9802
|
+
vector<unique_ptr<Constraint>> constraints;
|
|
9803
|
+
//! A list of constraints that are part of this table
|
|
9804
|
+
vector<unique_ptr<BoundConstraint>> bound_constraints;
|
|
9805
|
+
ColumnDependencyManager column_dependency_manager;
|
|
9806
|
+
//! A map of column name to column index
|
|
9807
|
+
case_insensitive_map_t<column_t> name_map;
|
|
9808
|
+
|
|
9809
|
+
public:
|
|
9810
|
+
//! For debugging purposes, count how many columns are STANDARD
|
|
9811
|
+
idx_t StandardColumnCount() const;
|
|
9812
|
+
unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info) override;
|
|
9813
|
+
//! Returns whether or not a column with the given name exists
|
|
9814
|
+
DUCKDB_API bool ColumnExists(const string &name);
|
|
9815
|
+
//! Returns a reference to the column of the specified name. Throws an
|
|
9816
|
+
//! exception if the column does not exist.
|
|
9817
|
+
ColumnDefinition &GetColumn(const string &name);
|
|
9818
|
+
//! Returns a list of types of the table
|
|
9819
|
+
vector<LogicalType> GetTypes();
|
|
9820
|
+
string ToSQL() override;
|
|
9821
|
+
|
|
9822
|
+
//! Serialize the meta information of the TableCatalogEntry a serializer
|
|
9823
|
+
virtual void Serialize(Serializer &serializer);
|
|
9824
|
+
//! Deserializes to a CreateTableInfo
|
|
9825
|
+
static unique_ptr<CreateTableInfo> Deserialize(Deserializer &source, ClientContext &context);
|
|
9826
|
+
|
|
9827
|
+
unique_ptr<CatalogEntry> Copy(ClientContext &context) override;
|
|
9828
|
+
|
|
9829
|
+
void SetAsRoot() override;
|
|
9830
|
+
|
|
9831
|
+
void CommitAlter(AlterInfo &info);
|
|
9832
|
+
void CommitDrop();
|
|
9833
|
+
|
|
9834
|
+
//! Returns the column index of the specified column name.
|
|
9835
|
+
//! If the column does not exist:
|
|
9836
|
+
//! If if_exists is true, returns DConstants::INVALID_INDEX
|
|
9837
|
+
//! If if_exists is false, throws an exception
|
|
9838
|
+
column_t GetColumnIndex(string &name, bool if_exists = false);
|
|
9839
|
+
|
|
9840
|
+
private:
|
|
9841
|
+
const string &GetColumnName(column_t index);
|
|
9842
|
+
unique_ptr<CatalogEntry> RenameColumn(ClientContext &context, RenameColumnInfo &info);
|
|
9843
|
+
unique_ptr<CatalogEntry> AddColumn(ClientContext &context, AddColumnInfo &info);
|
|
9844
|
+
unique_ptr<CatalogEntry> RemoveColumn(ClientContext &context, RemoveColumnInfo &info);
|
|
9845
|
+
unique_ptr<CatalogEntry> SetDefault(ClientContext &context, SetDefaultInfo &info);
|
|
9846
|
+
unique_ptr<CatalogEntry> ChangeColumnType(ClientContext &context, ChangeColumnTypeInfo &info);
|
|
9847
|
+
unique_ptr<CatalogEntry> SetNotNull(ClientContext &context, SetNotNullInfo &info);
|
|
9848
|
+
unique_ptr<CatalogEntry> DropNotNull(ClientContext &context, DropNotNullInfo &info);
|
|
9849
|
+
unique_ptr<CatalogEntry> AddForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info);
|
|
9850
|
+
unique_ptr<CatalogEntry> DropForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info);
|
|
9851
|
+
};
|
|
9852
|
+
} // namespace duckdb
|
|
9853
|
+
|
|
9854
|
+
|
|
9855
|
+
namespace duckdb {
|
|
9856
|
+
|
|
9857
|
+
class EstimatedProperties {
|
|
9858
|
+
public:
|
|
9859
|
+
EstimatedProperties(double cardinality, double cost) : cardinality(cardinality), cost(cost) {};
|
|
9860
|
+
EstimatedProperties() : cardinality(0), cost(0) {};
|
|
9861
|
+
|
|
9862
|
+
double GetCardinality();
|
|
9863
|
+
double GetCost();
|
|
9864
|
+
void SetCost(double new_cost);
|
|
9865
|
+
void SetCardinality(double cardinality);
|
|
9866
|
+
|
|
9867
|
+
private:
|
|
9868
|
+
double cardinality;
|
|
9869
|
+
double cost;
|
|
9870
|
+
|
|
9871
|
+
public:
|
|
9872
|
+
unique_ptr<EstimatedProperties> Copy();
|
|
9873
|
+
};
|
|
9874
|
+
} // namespace duckdb
|
|
9875
|
+
|
|
9876
|
+
|
|
9877
|
+
|
|
9878
|
+
|
|
9879
|
+
|
|
9880
|
+
//===----------------------------------------------------------------------===//
|
|
9881
|
+
// DuckDB
|
|
9882
|
+
//
|
|
9883
|
+
// duckdb/planner/column_binding.hpp
|
|
9884
|
+
//
|
|
9885
|
+
//
|
|
9886
|
+
//===----------------------------------------------------------------------===//
|
|
9887
|
+
|
|
9888
|
+
|
|
9889
|
+
|
|
9890
|
+
|
|
9891
|
+
#include <functional>
|
|
9892
|
+
|
|
9893
|
+
namespace duckdb {
|
|
9894
|
+
|
|
9895
|
+
struct ColumnBinding {
|
|
9896
|
+
idx_t table_index;
|
|
9897
|
+
idx_t column_index;
|
|
9898
|
+
|
|
9899
|
+
ColumnBinding() : table_index(DConstants::INVALID_INDEX), column_index(DConstants::INVALID_INDEX) {
|
|
9900
|
+
}
|
|
9901
|
+
ColumnBinding(idx_t table, idx_t column) : table_index(table), column_index(column) {
|
|
9902
|
+
}
|
|
9903
|
+
|
|
9904
|
+
bool operator==(const ColumnBinding &rhs) const {
|
|
9905
|
+
return table_index == rhs.table_index && column_index == rhs.column_index;
|
|
9906
|
+
}
|
|
9907
|
+
};
|
|
9908
|
+
|
|
9909
|
+
} // namespace duckdb
|
|
9910
|
+
|
|
9911
|
+
|
|
9912
|
+
|
|
9913
|
+
#include <functional>
|
|
9914
|
+
#include <algorithm>
|
|
9153
9915
|
|
|
9154
9916
|
namespace duckdb {
|
|
9155
9917
|
|
|
@@ -9177,7 +9939,10 @@ public:
|
|
|
9177
9939
|
//! The types returned by this logical operator. Set by calling LogicalOperator::ResolveTypes.
|
|
9178
9940
|
vector<LogicalType> types;
|
|
9179
9941
|
//! Estimated Cardinality
|
|
9180
|
-
idx_t estimated_cardinality
|
|
9942
|
+
idx_t estimated_cardinality;
|
|
9943
|
+
bool has_estimated_cardinality;
|
|
9944
|
+
|
|
9945
|
+
unique_ptr<EstimatedProperties> estimated_props;
|
|
9181
9946
|
|
|
9182
9947
|
public:
|
|
9183
9948
|
virtual vector<ColumnBinding> GetColumnBindings();
|
|
@@ -9196,7 +9961,6 @@ public:
|
|
|
9196
9961
|
virtual void Verify(ClientContext &context);
|
|
9197
9962
|
|
|
9198
9963
|
void AddChild(unique_ptr<LogicalOperator> child);
|
|
9199
|
-
|
|
9200
9964
|
virtual idx_t EstimateCardinality(ClientContext &context);
|
|
9201
9965
|
|
|
9202
9966
|
//! Serializes a LogicalOperator to a stand-alone binary blob
|
|
@@ -11023,45 +11787,202 @@ private:
|
|
|
11023
11787
|
|
|
11024
11788
|
|
|
11025
11789
|
|
|
11026
|
-
namespace duckdb {
|
|
11790
|
+
namespace duckdb {
|
|
11791
|
+
|
|
11792
|
+
enum class PendingExecutionResult : uint8_t { RESULT_READY, RESULT_NOT_READY, EXECUTION_ERROR };
|
|
11793
|
+
|
|
11794
|
+
} // namespace duckdb
|
|
11795
|
+
|
|
11796
|
+
//===----------------------------------------------------------------------===//
|
|
11797
|
+
// DuckDB
|
|
11798
|
+
//
|
|
11799
|
+
// duckdb/execution/executor.hpp
|
|
11800
|
+
//
|
|
11801
|
+
//
|
|
11802
|
+
//===----------------------------------------------------------------------===//
|
|
11803
|
+
|
|
11804
|
+
|
|
11805
|
+
|
|
11806
|
+
|
|
11807
|
+
|
|
11808
|
+
//===----------------------------------------------------------------------===//
|
|
11809
|
+
// DuckDB
|
|
11810
|
+
//
|
|
11811
|
+
// duckdb/parallel/pipeline.hpp
|
|
11812
|
+
//
|
|
11813
|
+
//
|
|
11814
|
+
//===----------------------------------------------------------------------===//
|
|
11815
|
+
|
|
11816
|
+
|
|
11817
|
+
|
|
11818
|
+
|
|
11819
|
+
//===----------------------------------------------------------------------===//
|
|
11820
|
+
// DuckDB
|
|
11821
|
+
//
|
|
11822
|
+
// duckdb/execution/physical_operator.hpp
|
|
11823
|
+
//
|
|
11824
|
+
//
|
|
11825
|
+
//===----------------------------------------------------------------------===//
|
|
11826
|
+
|
|
11827
|
+
|
|
11828
|
+
|
|
11829
|
+
|
|
11830
|
+
//===----------------------------------------------------------------------===//
|
|
11831
|
+
// DuckDB
|
|
11832
|
+
//
|
|
11833
|
+
// duckdb/optimizer/join_node.hpp
|
|
11834
|
+
//
|
|
11835
|
+
//
|
|
11836
|
+
//===----------------------------------------------------------------------===//
|
|
11837
|
+
|
|
11838
|
+
|
|
11839
|
+
|
|
11840
|
+
|
|
11841
|
+
|
|
11842
|
+
//===----------------------------------------------------------------------===//
|
|
11843
|
+
// DuckDB
|
|
11844
|
+
//
|
|
11845
|
+
// duckdb/optimizer/join_order/query_graph.hpp
|
|
11846
|
+
//
|
|
11847
|
+
//
|
|
11848
|
+
//===----------------------------------------------------------------------===//
|
|
11849
|
+
|
|
11850
|
+
|
|
11851
|
+
|
|
11852
|
+
|
|
11853
|
+
//===----------------------------------------------------------------------===//
|
|
11854
|
+
// DuckDB
|
|
11855
|
+
//
|
|
11856
|
+
// duckdb/common/pair.hpp
|
|
11857
|
+
//
|
|
11858
|
+
//
|
|
11859
|
+
//===----------------------------------------------------------------------===//
|
|
11860
|
+
|
|
11861
|
+
|
|
11862
|
+
|
|
11863
|
+
#include <utility>
|
|
11864
|
+
|
|
11865
|
+
namespace duckdb {
|
|
11866
|
+
using std::make_pair;
|
|
11867
|
+
using std::pair;
|
|
11868
|
+
} // namespace duckdb
|
|
11869
|
+
|
|
11870
|
+
|
|
11871
|
+
|
|
11872
|
+
|
|
11873
|
+
|
|
11874
|
+
|
|
11875
|
+
|
|
11876
|
+
#include <functional>
|
|
11877
|
+
|
|
11878
|
+
namespace duckdb {
|
|
11879
|
+
class Expression;
|
|
11880
|
+
class LogicalOperator;
|
|
11881
|
+
|
|
11882
|
+
struct FilterInfo {
|
|
11883
|
+
idx_t filter_index;
|
|
11884
|
+
JoinRelationSet *left_set = nullptr;
|
|
11885
|
+
JoinRelationSet *right_set = nullptr;
|
|
11886
|
+
ColumnBinding left_binding;
|
|
11887
|
+
ColumnBinding right_binding;
|
|
11888
|
+
JoinRelationSet *set = nullptr;
|
|
11889
|
+
};
|
|
11890
|
+
|
|
11891
|
+
struct FilterNode {
|
|
11892
|
+
vector<FilterInfo *> filters;
|
|
11893
|
+
unordered_map<idx_t, unique_ptr<FilterNode>> children;
|
|
11894
|
+
};
|
|
11895
|
+
|
|
11896
|
+
struct NeighborInfo {
|
|
11897
|
+
JoinRelationSet *neighbor;
|
|
11898
|
+
vector<FilterInfo *> filters;
|
|
11899
|
+
};
|
|
11900
|
+
|
|
11901
|
+
//! The QueryGraph contains edges between relations and allows edges to be created/queried
|
|
11902
|
+
class QueryGraph {
|
|
11903
|
+
public:
|
|
11904
|
+
//! Contains a node with info about neighboring relations and child edge infos
|
|
11905
|
+
struct QueryEdge {
|
|
11906
|
+
vector<unique_ptr<NeighborInfo>> neighbors;
|
|
11907
|
+
unordered_map<idx_t, unique_ptr<QueryEdge>> children;
|
|
11908
|
+
};
|
|
11909
|
+
|
|
11910
|
+
public:
|
|
11911
|
+
string ToString() const;
|
|
11912
|
+
void Print();
|
|
11913
|
+
|
|
11914
|
+
//! Create an edge in the edge_set
|
|
11915
|
+
void CreateEdge(JoinRelationSet *left, JoinRelationSet *right, FilterInfo *info);
|
|
11916
|
+
//! Returns a connection if there is an edge that connects these two sets, or nullptr otherwise
|
|
11917
|
+
vector<NeighborInfo *> GetConnections(JoinRelationSet *node, JoinRelationSet *other);
|
|
11918
|
+
//! Enumerate the neighbors of a specific node that do not belong to any of the exclusion_set. Note that if a
|
|
11919
|
+
//! neighbor has multiple nodes, this function will return the lowest entry in that set.
|
|
11920
|
+
vector<idx_t> GetNeighbors(JoinRelationSet *node, unordered_set<idx_t> &exclusion_set);
|
|
11921
|
+
//! Enumerate all neighbors of a given JoinRelationSet node
|
|
11922
|
+
void EnumerateNeighbors(JoinRelationSet *node, const std::function<bool(NeighborInfo *)> &callback);
|
|
11923
|
+
|
|
11924
|
+
private:
|
|
11925
|
+
//! Get the QueryEdge of a specific node
|
|
11926
|
+
QueryEdge *GetQueryEdge(JoinRelationSet *left);
|
|
11927
|
+
|
|
11928
|
+
QueryEdge root;
|
|
11929
|
+
};
|
|
11930
|
+
|
|
11931
|
+
} // namespace duckdb
|
|
11932
|
+
|
|
11933
|
+
|
|
11934
|
+
|
|
11027
11935
|
|
|
11028
|
-
enum class PendingExecutionResult : uint8_t { RESULT_READY, RESULT_NOT_READY, EXECUTION_ERROR };
|
|
11029
11936
|
|
|
11030
|
-
} // namespace duckdb
|
|
11031
11937
|
|
|
11032
|
-
//===----------------------------------------------------------------------===//
|
|
11033
|
-
// DuckDB
|
|
11034
|
-
//
|
|
11035
|
-
// duckdb/execution/executor.hpp
|
|
11036
|
-
//
|
|
11037
|
-
//
|
|
11038
|
-
//===----------------------------------------------------------------------===//
|
|
11039
11938
|
|
|
11040
11939
|
|
|
11041
11940
|
|
|
11941
|
+
namespace duckdb {
|
|
11042
11942
|
|
|
11943
|
+
class JoinOrderOptimizer;
|
|
11043
11944
|
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11945
|
+
class JoinNode {
|
|
11946
|
+
public:
|
|
11947
|
+
//! Represents a node in the join plan
|
|
11948
|
+
JoinRelationSet *set;
|
|
11949
|
+
NeighborInfo *info;
|
|
11950
|
+
//! If the JoinNode is a base table, then base_cardinality is the cardinality before filters
|
|
11951
|
+
//! estimated_props.cardinality will be the cardinality after filters. With no filters, the two are equal
|
|
11952
|
+
bool has_filter;
|
|
11953
|
+
JoinNode *left;
|
|
11954
|
+
JoinNode *right;
|
|
11051
11955
|
|
|
11956
|
+
unique_ptr<EstimatedProperties> estimated_props;
|
|
11052
11957
|
|
|
11958
|
+
//! Create a leaf node in the join tree
|
|
11959
|
+
//! set cost to 0 for leaf nodes
|
|
11960
|
+
//! cost will be the cost to *produce* an intermediate table
|
|
11961
|
+
JoinNode(JoinRelationSet *set, const double base_cardinality);
|
|
11053
11962
|
|
|
11963
|
+
//! Create an intermediate node in the join tree. base_cardinality = estimated_props.cardinality
|
|
11964
|
+
JoinNode(JoinRelationSet *set, NeighborInfo *info, JoinNode *left, JoinNode *right, const double base_cardinality,
|
|
11965
|
+
double cost);
|
|
11054
11966
|
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
// duckdb/execution/physical_operator.hpp
|
|
11059
|
-
//
|
|
11060
|
-
//
|
|
11061
|
-
//===----------------------------------------------------------------------===//
|
|
11967
|
+
bool operator==(const JoinNode &other) {
|
|
11968
|
+
return other.set->ToString().compare(set->ToString()) == 0;
|
|
11969
|
+
}
|
|
11062
11970
|
|
|
11971
|
+
private:
|
|
11972
|
+
double base_cardinality;
|
|
11063
11973
|
|
|
11974
|
+
public:
|
|
11975
|
+
double GetCardinality() const;
|
|
11976
|
+
double GetCost();
|
|
11977
|
+
void SetCost(double cost);
|
|
11978
|
+
double GetBaseTableCardinality();
|
|
11979
|
+
void SetBaseTableCardinality(double base_card);
|
|
11980
|
+
void SetEstimatedCardinality(double estimated_card);
|
|
11981
|
+
void PrintJoinNode();
|
|
11982
|
+
string ToString();
|
|
11983
|
+
};
|
|
11064
11984
|
|
|
11985
|
+
} // namespace duckdb
|
|
11065
11986
|
|
|
11066
11987
|
|
|
11067
11988
|
//===----------------------------------------------------------------------===//
|
|
@@ -11309,7 +12230,9 @@ class PhysicalOperator {
|
|
|
11309
12230
|
public:
|
|
11310
12231
|
PhysicalOperator(PhysicalOperatorType type, vector<LogicalType> types, idx_t estimated_cardinality)
|
|
11311
12232
|
: type(type), types(std::move(types)), estimated_cardinality(estimated_cardinality) {
|
|
12233
|
+
estimated_props = make_unique<EstimatedProperties>(estimated_cardinality, 0);
|
|
11312
12234
|
}
|
|
12235
|
+
|
|
11313
12236
|
virtual ~PhysicalOperator() {
|
|
11314
12237
|
}
|
|
11315
12238
|
|
|
@@ -11321,6 +12244,8 @@ public:
|
|
|
11321
12244
|
vector<LogicalType> types;
|
|
11322
12245
|
//! The estimated cardinality of this physical operator
|
|
11323
12246
|
idx_t estimated_cardinality;
|
|
12247
|
+
unique_ptr<EstimatedProperties> estimated_props;
|
|
12248
|
+
|
|
11324
12249
|
//! The global sink state of this operator
|
|
11325
12250
|
unique_ptr<GlobalSinkState> sink_state;
|
|
11326
12251
|
//! The global state of this operator
|
|
@@ -11864,22 +12789,6 @@ private:
|
|
|
11864
12789
|
} // namespace duckdb
|
|
11865
12790
|
|
|
11866
12791
|
|
|
11867
|
-
//===----------------------------------------------------------------------===//
|
|
11868
|
-
// DuckDB
|
|
11869
|
-
//
|
|
11870
|
-
// duckdb/common/pair.hpp
|
|
11871
|
-
//
|
|
11872
|
-
//
|
|
11873
|
-
//===----------------------------------------------------------------------===//
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
#include <utility>
|
|
11878
|
-
|
|
11879
|
-
namespace duckdb {
|
|
11880
|
-
using std::make_pair;
|
|
11881
|
-
using std::pair;
|
|
11882
|
-
} // namespace duckdb
|
|
11883
12792
|
|
|
11884
12793
|
|
|
11885
12794
|
|
|
@@ -12107,256 +13016,68 @@ public:
|
|
|
12107
13016
|
public:
|
|
12108
13017
|
//! Returns the stored error message
|
|
12109
13018
|
const string &GetError();
|
|
12110
|
-
//! Returns whether or not an error occurred
|
|
12111
|
-
bool HasError() const;
|
|
12112
|
-
//! Returns the number of columns in the result
|
|
12113
|
-
idx_t ColumnCount();
|
|
12114
|
-
//! Returns the statement type of the underlying prepared statement object
|
|
12115
|
-
StatementType GetStatementType();
|
|
12116
|
-
//! Returns the underlying statement properties
|
|
12117
|
-
StatementProperties GetStatementProperties();
|
|
12118
|
-
//! Returns the result SQL types of the prepared statement
|
|
12119
|
-
const vector<LogicalType> &GetTypes();
|
|
12120
|
-
//! Returns the result names of the prepared statement
|
|
12121
|
-
const vector<string> &GetNames();
|
|
12122
|
-
|
|
12123
|
-
//! Create a pending query result of the prepared statement with the given set of arguments
|
|
12124
|
-
template <typename... Args>
|
|
12125
|
-
unique_ptr<PendingQueryResult> PendingQuery(Args... args) {
|
|
12126
|
-
vector<Value> values;
|
|
12127
|
-
return PendingQueryRecursive(values, args...);
|
|
12128
|
-
}
|
|
12129
|
-
|
|
12130
|
-
//! Execute the prepared statement with the given set of arguments
|
|
12131
|
-
template <typename... Args>
|
|
12132
|
-
unique_ptr<QueryResult> Execute(Args... args) {
|
|
12133
|
-
vector<Value> values;
|
|
12134
|
-
return ExecuteRecursive(values, args...);
|
|
12135
|
-
}
|
|
12136
|
-
|
|
12137
|
-
//! Create a pending query result of the prepared statement with the given set of arguments
|
|
12138
|
-
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(vector<Value> &values, bool allow_stream_result = true);
|
|
12139
|
-
|
|
12140
|
-
//! Execute the prepared statement with the given set of values
|
|
12141
|
-
DUCKDB_API unique_ptr<QueryResult> Execute(vector<Value> &values, bool allow_stream_result = true);
|
|
12142
|
-
|
|
12143
|
-
private:
|
|
12144
|
-
unique_ptr<PendingQueryResult> PendingQueryRecursive(vector<Value> &values) {
|
|
12145
|
-
return PendingQuery(values);
|
|
12146
|
-
}
|
|
12147
|
-
|
|
12148
|
-
template <typename T, typename... Args>
|
|
12149
|
-
unique_ptr<PendingQueryResult> PendingQueryRecursive(vector<Value> &values, T value, Args... args) {
|
|
12150
|
-
values.push_back(Value::CreateValue<T>(value));
|
|
12151
|
-
return PendingQueryRecursive(values, args...);
|
|
12152
|
-
}
|
|
12153
|
-
|
|
12154
|
-
unique_ptr<QueryResult> ExecuteRecursive(vector<Value> &values) {
|
|
12155
|
-
return Execute(values);
|
|
12156
|
-
}
|
|
12157
|
-
|
|
12158
|
-
template <typename T, typename... Args>
|
|
12159
|
-
unique_ptr<QueryResult> ExecuteRecursive(vector<Value> &values, T value, Args... args) {
|
|
12160
|
-
values.push_back(Value::CreateValue<T>(value));
|
|
12161
|
-
return ExecuteRecursive(values, args...);
|
|
12162
|
-
}
|
|
12163
|
-
};
|
|
12164
|
-
|
|
12165
|
-
} // namespace duckdb
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
//===----------------------------------------------------------------------===//
|
|
12169
|
-
// DuckDB
|
|
12170
|
-
//
|
|
12171
|
-
// duckdb/main/relation.hpp
|
|
12172
|
-
//
|
|
12173
|
-
//
|
|
12174
|
-
//===----------------------------------------------------------------------===//
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
//===----------------------------------------------------------------------===//
|
|
12180
|
-
// DuckDB
|
|
12181
|
-
//
|
|
12182
|
-
// duckdb/common/enums/join_type.hpp
|
|
12183
|
-
//
|
|
12184
|
-
//
|
|
12185
|
-
//===----------------------------------------------------------------------===//
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
namespace duckdb {
|
|
12192
|
-
|
|
12193
|
-
//===--------------------------------------------------------------------===//
|
|
12194
|
-
// Join Types
|
|
12195
|
-
//===--------------------------------------------------------------------===//
|
|
12196
|
-
enum class JoinType : uint8_t {
|
|
12197
|
-
INVALID = 0, // invalid join type
|
|
12198
|
-
LEFT = 1, // left
|
|
12199
|
-
RIGHT = 2, // right
|
|
12200
|
-
INNER = 3, // inner
|
|
12201
|
-
OUTER = 4, // outer
|
|
12202
|
-
SEMI = 5, // SEMI join returns left side row ONLY if it has a join partner, no duplicates
|
|
12203
|
-
ANTI = 6, // ANTI join returns left side row ONLY if it has NO join partner, no duplicates
|
|
12204
|
-
MARK = 7, // MARK join returns marker indicating whether or not there is a join partner (true), there is no join
|
|
12205
|
-
// partner (false)
|
|
12206
|
-
SINGLE = 8 // SINGLE join is like LEFT OUTER JOIN, BUT returns at most one join partner per entry on the LEFT side
|
|
12207
|
-
// (and NULL if no partner is found)
|
|
12208
|
-
};
|
|
12209
|
-
|
|
12210
|
-
//! Convert join type to string
|
|
12211
|
-
DUCKDB_API string JoinTypeToString(JoinType type);
|
|
12212
|
-
|
|
12213
|
-
//! True if join is left or full outer join
|
|
12214
|
-
bool IsLeftOuterJoin(JoinType type);
|
|
12215
|
-
|
|
12216
|
-
//! True if join is rght or full outer join
|
|
12217
|
-
bool IsRightOuterJoin(JoinType type);
|
|
12218
|
-
|
|
12219
|
-
} // namespace duckdb
|
|
12220
|
-
|
|
12221
|
-
//===----------------------------------------------------------------------===//
|
|
12222
|
-
// DuckDB
|
|
12223
|
-
//
|
|
12224
|
-
// duckdb/common/enums/relation_type.hpp
|
|
12225
|
-
//
|
|
12226
|
-
//
|
|
12227
|
-
//===----------------------------------------------------------------------===//
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
namespace duckdb {
|
|
12234
|
-
|
|
12235
|
-
//===--------------------------------------------------------------------===//
|
|
12236
|
-
// Catalog Types
|
|
12237
|
-
//===--------------------------------------------------------------------===//
|
|
12238
|
-
enum class RelationType : uint8_t {
|
|
12239
|
-
INVALID_RELATION,
|
|
12240
|
-
TABLE_RELATION,
|
|
12241
|
-
PROJECTION_RELATION,
|
|
12242
|
-
FILTER_RELATION,
|
|
12243
|
-
EXPLAIN_RELATION,
|
|
12244
|
-
CROSS_PRODUCT_RELATION,
|
|
12245
|
-
JOIN_RELATION,
|
|
12246
|
-
AGGREGATE_RELATION,
|
|
12247
|
-
SET_OPERATION_RELATION,
|
|
12248
|
-
DISTINCT_RELATION,
|
|
12249
|
-
LIMIT_RELATION,
|
|
12250
|
-
ORDER_RELATION,
|
|
12251
|
-
CREATE_VIEW_RELATION,
|
|
12252
|
-
CREATE_TABLE_RELATION,
|
|
12253
|
-
INSERT_RELATION,
|
|
12254
|
-
VALUE_LIST_RELATION,
|
|
12255
|
-
DELETE_RELATION,
|
|
12256
|
-
UPDATE_RELATION,
|
|
12257
|
-
WRITE_CSV_RELATION,
|
|
12258
|
-
READ_CSV_RELATION,
|
|
12259
|
-
SUBQUERY_RELATION,
|
|
12260
|
-
TABLE_FUNCTION_RELATION,
|
|
12261
|
-
VIEW_RELATION,
|
|
12262
|
-
QUERY_RELATION
|
|
12263
|
-
};
|
|
12264
|
-
|
|
12265
|
-
string RelationTypeToString(RelationType type);
|
|
12266
|
-
|
|
12267
|
-
} // namespace duckdb
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
//===----------------------------------------------------------------------===//
|
|
12274
|
-
// DuckDB
|
|
12275
|
-
//
|
|
12276
|
-
// duckdb/main/client_context.hpp
|
|
12277
|
-
//
|
|
12278
|
-
//
|
|
12279
|
-
//===----------------------------------------------------------------------===//
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
//===----------------------------------------------------------------------===//
|
|
12284
|
-
// DuckDB
|
|
12285
|
-
//
|
|
12286
|
-
// duckdb/catalog/catalog_entry/schema_catalog_entry.hpp
|
|
12287
|
-
//
|
|
12288
|
-
//
|
|
12289
|
-
//===----------------------------------------------------------------------===//
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
//===----------------------------------------------------------------------===//
|
|
12295
|
-
// DuckDB
|
|
12296
|
-
//
|
|
12297
|
-
// duckdb/catalog/catalog_set.hpp
|
|
12298
|
-
//
|
|
12299
|
-
//
|
|
12300
|
-
//===----------------------------------------------------------------------===//
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
//===----------------------------------------------------------------------===//
|
|
12306
|
-
// DuckDB
|
|
12307
|
-
//
|
|
12308
|
-
// duckdb/catalog/default/default_generator.hpp
|
|
12309
|
-
//
|
|
12310
|
-
//
|
|
12311
|
-
//===----------------------------------------------------------------------===//
|
|
12312
|
-
|
|
12313
|
-
|
|
13019
|
+
//! Returns whether or not an error occurred
|
|
13020
|
+
bool HasError() const;
|
|
13021
|
+
//! Returns the number of columns in the result
|
|
13022
|
+
idx_t ColumnCount();
|
|
13023
|
+
//! Returns the statement type of the underlying prepared statement object
|
|
13024
|
+
StatementType GetStatementType();
|
|
13025
|
+
//! Returns the underlying statement properties
|
|
13026
|
+
StatementProperties GetStatementProperties();
|
|
13027
|
+
//! Returns the result SQL types of the prepared statement
|
|
13028
|
+
const vector<LogicalType> &GetTypes();
|
|
13029
|
+
//! Returns the result names of the prepared statement
|
|
13030
|
+
const vector<string> &GetNames();
|
|
12314
13031
|
|
|
13032
|
+
//! Create a pending query result of the prepared statement with the given set of arguments
|
|
13033
|
+
template <typename... Args>
|
|
13034
|
+
unique_ptr<PendingQueryResult> PendingQuery(Args... args) {
|
|
13035
|
+
vector<Value> values;
|
|
13036
|
+
return PendingQueryRecursive(values, args...);
|
|
13037
|
+
}
|
|
12315
13038
|
|
|
13039
|
+
//! Execute the prepared statement with the given set of arguments
|
|
13040
|
+
template <typename... Args>
|
|
13041
|
+
unique_ptr<QueryResult> Execute(Args... args) {
|
|
13042
|
+
vector<Value> values;
|
|
13043
|
+
return ExecuteRecursive(values, args...);
|
|
13044
|
+
}
|
|
12316
13045
|
|
|
13046
|
+
//! Create a pending query result of the prepared statement with the given set of arguments
|
|
13047
|
+
DUCKDB_API unique_ptr<PendingQueryResult> PendingQuery(vector<Value> &values, bool allow_stream_result = true);
|
|
12317
13048
|
|
|
12318
|
-
|
|
12319
|
-
|
|
13049
|
+
//! Execute the prepared statement with the given set of values
|
|
13050
|
+
DUCKDB_API unique_ptr<QueryResult> Execute(vector<Value> &values, bool allow_stream_result = true);
|
|
12320
13051
|
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
13052
|
+
private:
|
|
13053
|
+
unique_ptr<PendingQueryResult> PendingQueryRecursive(vector<Value> &values) {
|
|
13054
|
+
return PendingQuery(values);
|
|
12324
13055
|
}
|
|
12325
|
-
|
|
13056
|
+
|
|
13057
|
+
template <typename T, typename... Args>
|
|
13058
|
+
unique_ptr<PendingQueryResult> PendingQueryRecursive(vector<Value> &values, T value, Args... args) {
|
|
13059
|
+
values.push_back(Value::CreateValue<T>(value));
|
|
13060
|
+
return PendingQueryRecursive(values, args...);
|
|
12326
13061
|
}
|
|
12327
13062
|
|
|
12328
|
-
|
|
12329
|
-
|
|
13063
|
+
unique_ptr<QueryResult> ExecuteRecursive(vector<Value> &values) {
|
|
13064
|
+
return Execute(values);
|
|
13065
|
+
}
|
|
12330
13066
|
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
13067
|
+
template <typename T, typename... Args>
|
|
13068
|
+
unique_ptr<QueryResult> ExecuteRecursive(vector<Value> &values, T value, Args... args) {
|
|
13069
|
+
values.push_back(Value::CreateValue<T>(value));
|
|
13070
|
+
return ExecuteRecursive(values, args...);
|
|
13071
|
+
}
|
|
12336
13072
|
};
|
|
12337
13073
|
|
|
12338
13074
|
} // namespace duckdb
|
|
12339
13075
|
|
|
12340
13076
|
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
//===----------------------------------------------------------------------===//
|
|
12347
|
-
// DuckDB
|
|
12348
|
-
//
|
|
12349
|
-
// duckdb/catalog/catalog_entry/table_catalog_entry.hpp
|
|
12350
|
-
//
|
|
12351
|
-
//
|
|
12352
|
-
//===----------------------------------------------------------------------===//
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
13077
|
//===----------------------------------------------------------------------===//
|
|
12357
13078
|
// DuckDB
|
|
12358
13079
|
//
|
|
12359
|
-
// duckdb/
|
|
13080
|
+
// duckdb/main/relation.hpp
|
|
12360
13081
|
//
|
|
12361
13082
|
//
|
|
12362
13083
|
//===----------------------------------------------------------------------===//
|
|
@@ -12364,30 +13085,10 @@ public:
|
|
|
12364
13085
|
|
|
12365
13086
|
|
|
12366
13087
|
|
|
12367
|
-
|
|
12368
|
-
namespace duckdb {
|
|
12369
|
-
class SchemaCatalogEntry;
|
|
12370
|
-
|
|
12371
|
-
//! A StandardEntry is a catalog entry that is a member of a schema
|
|
12372
|
-
class StandardEntry : public CatalogEntry {
|
|
12373
|
-
public:
|
|
12374
|
-
StandardEntry(CatalogType type, SchemaCatalogEntry *schema, Catalog *catalog, string name)
|
|
12375
|
-
: CatalogEntry(type, catalog, name), schema(schema) {
|
|
12376
|
-
}
|
|
12377
|
-
~StandardEntry() override {
|
|
12378
|
-
}
|
|
12379
|
-
|
|
12380
|
-
//! The schema the entry belongs to
|
|
12381
|
-
SchemaCatalogEntry *schema;
|
|
12382
|
-
};
|
|
12383
|
-
} // namespace duckdb
|
|
12384
|
-
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
13088
|
//===----------------------------------------------------------------------===//
|
|
12388
13089
|
// DuckDB
|
|
12389
13090
|
//
|
|
12390
|
-
// duckdb/
|
|
13091
|
+
// duckdb/common/enums/join_type.hpp
|
|
12391
13092
|
//
|
|
12392
13093
|
//
|
|
12393
13094
|
//===----------------------------------------------------------------------===//
|
|
@@ -12396,69 +13097,40 @@ public:
|
|
|
12396
13097
|
|
|
12397
13098
|
|
|
12398
13099
|
|
|
12399
|
-
|
|
12400
13100
|
namespace duckdb {
|
|
12401
13101
|
|
|
12402
|
-
class Serializer;
|
|
12403
|
-
class Deserializer;
|
|
12404
|
-
class FieldWriter;
|
|
12405
|
-
class FieldReader;
|
|
12406
|
-
|
|
12407
13102
|
//===--------------------------------------------------------------------===//
|
|
12408
|
-
//
|
|
13103
|
+
// Join Types
|
|
12409
13104
|
//===--------------------------------------------------------------------===//
|
|
12410
|
-
enum class
|
|
12411
|
-
INVALID = 0,
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
};
|
|
12423
|
-
|
|
12424
|
-
struct ForeignKeyInfo {
|
|
12425
|
-
ForeignKeyType type;
|
|
12426
|
-
string schema;
|
|
12427
|
-
//! if type is FK_TYPE_FOREIGN_KEY_TABLE, means main key table, if type is FK_TYPE_PRIMARY_KEY_TABLE, means foreign
|
|
12428
|
-
//! key table
|
|
12429
|
-
string table;
|
|
12430
|
-
//! The set of main key table's column's index
|
|
12431
|
-
vector<storage_t> pk_keys;
|
|
12432
|
-
//! The set of foreign key table's column's index
|
|
12433
|
-
vector<idx_t> fk_keys;
|
|
13105
|
+
enum class JoinType : uint8_t {
|
|
13106
|
+
INVALID = 0, // invalid join type
|
|
13107
|
+
LEFT = 1, // left
|
|
13108
|
+
RIGHT = 2, // right
|
|
13109
|
+
INNER = 3, // inner
|
|
13110
|
+
OUTER = 4, // outer
|
|
13111
|
+
SEMI = 5, // SEMI join returns left side row ONLY if it has a join partner, no duplicates
|
|
13112
|
+
ANTI = 6, // ANTI join returns left side row ONLY if it has NO join partner, no duplicates
|
|
13113
|
+
MARK = 7, // MARK join returns marker indicating whether or not there is a join partner (true), there is no join
|
|
13114
|
+
// partner (false)
|
|
13115
|
+
SINGLE = 8 // SINGLE join is like LEFT OUTER JOIN, BUT returns at most one join partner per entry on the LEFT side
|
|
13116
|
+
// (and NULL if no partner is found)
|
|
12434
13117
|
};
|
|
12435
13118
|
|
|
12436
|
-
//!
|
|
12437
|
-
|
|
12438
|
-
public:
|
|
12439
|
-
DUCKDB_API explicit Constraint(ConstraintType type);
|
|
12440
|
-
DUCKDB_API virtual ~Constraint();
|
|
13119
|
+
//! Convert join type to string
|
|
13120
|
+
DUCKDB_API string JoinTypeToString(JoinType type);
|
|
12441
13121
|
|
|
12442
|
-
|
|
13122
|
+
//! True if join is left or full outer join
|
|
13123
|
+
bool IsLeftOuterJoin(JoinType type);
|
|
12443
13124
|
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
DUCKDB_API void Print() const;
|
|
13125
|
+
//! True if join is rght or full outer join
|
|
13126
|
+
bool IsRightOuterJoin(JoinType type);
|
|
12447
13127
|
|
|
12448
|
-
DUCKDB_API virtual unique_ptr<Constraint> Copy() const = 0;
|
|
12449
|
-
//! Serializes a Constraint to a stand-alone binary blob
|
|
12450
|
-
DUCKDB_API void Serialize(Serializer &serializer) const;
|
|
12451
|
-
//! Serializes a Constraint to a stand-alone binary blob
|
|
12452
|
-
DUCKDB_API virtual void Serialize(FieldWriter &writer) const = 0;
|
|
12453
|
-
//! Deserializes a blob back into a Constraint
|
|
12454
|
-
DUCKDB_API static unique_ptr<Constraint> Deserialize(Deserializer &source);
|
|
12455
|
-
};
|
|
12456
13128
|
} // namespace duckdb
|
|
12457
13129
|
|
|
12458
13130
|
//===----------------------------------------------------------------------===//
|
|
12459
13131
|
// DuckDB
|
|
12460
13132
|
//
|
|
12461
|
-
// duckdb/
|
|
13133
|
+
// duckdb/common/enums/relation_type.hpp
|
|
12462
13134
|
//
|
|
12463
13135
|
//
|
|
12464
13136
|
//===----------------------------------------------------------------------===//
|
|
@@ -12467,206 +13139,119 @@ public:
|
|
|
12467
13139
|
|
|
12468
13140
|
|
|
12469
13141
|
|
|
12470
|
-
|
|
12471
|
-
|
|
12472
13142
|
namespace duckdb {
|
|
12473
|
-
//! Bound equivalent of Constraint
|
|
12474
|
-
class BoundConstraint {
|
|
12475
|
-
public:
|
|
12476
|
-
explicit BoundConstraint(ConstraintType type) : type(type) {};
|
|
12477
|
-
virtual ~BoundConstraint() {
|
|
12478
|
-
}
|
|
12479
13143
|
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
13144
|
+
//===--------------------------------------------------------------------===//
|
|
13145
|
+
// Catalog Types
|
|
13146
|
+
//===--------------------------------------------------------------------===//
|
|
13147
|
+
enum class RelationType : uint8_t {
|
|
13148
|
+
INVALID_RELATION,
|
|
13149
|
+
TABLE_RELATION,
|
|
13150
|
+
PROJECTION_RELATION,
|
|
13151
|
+
FILTER_RELATION,
|
|
13152
|
+
EXPLAIN_RELATION,
|
|
13153
|
+
CROSS_PRODUCT_RELATION,
|
|
13154
|
+
JOIN_RELATION,
|
|
13155
|
+
AGGREGATE_RELATION,
|
|
13156
|
+
SET_OPERATION_RELATION,
|
|
13157
|
+
DISTINCT_RELATION,
|
|
13158
|
+
LIMIT_RELATION,
|
|
13159
|
+
ORDER_RELATION,
|
|
13160
|
+
CREATE_VIEW_RELATION,
|
|
13161
|
+
CREATE_TABLE_RELATION,
|
|
13162
|
+
INSERT_RELATION,
|
|
13163
|
+
VALUE_LIST_RELATION,
|
|
13164
|
+
DELETE_RELATION,
|
|
13165
|
+
UPDATE_RELATION,
|
|
13166
|
+
WRITE_CSV_RELATION,
|
|
13167
|
+
READ_CSV_RELATION,
|
|
13168
|
+
SUBQUERY_RELATION,
|
|
13169
|
+
TABLE_FUNCTION_RELATION,
|
|
13170
|
+
VIEW_RELATION,
|
|
13171
|
+
QUERY_RELATION
|
|
13172
|
+
};
|
|
12483
13173
|
|
|
12484
|
-
|
|
12485
|
-
return make_unique<BoundConstraint>(source.Read<ConstraintType>());
|
|
12486
|
-
}
|
|
13174
|
+
string RelationTypeToString(RelationType type);
|
|
12487
13175
|
|
|
12488
|
-
ConstraintType type;
|
|
12489
|
-
};
|
|
12490
13176
|
} // namespace duckdb
|
|
12491
13177
|
|
|
12492
13178
|
|
|
12493
13179
|
|
|
12494
13180
|
|
|
13181
|
+
|
|
12495
13182
|
//===----------------------------------------------------------------------===//
|
|
12496
13183
|
// DuckDB
|
|
12497
13184
|
//
|
|
12498
|
-
// duckdb/
|
|
13185
|
+
// duckdb/main/client_context.hpp
|
|
12499
13186
|
//
|
|
12500
13187
|
//
|
|
12501
13188
|
//===----------------------------------------------------------------------===//
|
|
12502
13189
|
|
|
12503
13190
|
|
|
12504
13191
|
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
13192
|
//===----------------------------------------------------------------------===//
|
|
12509
13193
|
// DuckDB
|
|
12510
13194
|
//
|
|
12511
|
-
// duckdb/
|
|
13195
|
+
// duckdb/catalog/catalog_entry/schema_catalog_entry.hpp
|
|
12512
13196
|
//
|
|
12513
13197
|
//
|
|
12514
13198
|
//===----------------------------------------------------------------------===//
|
|
12515
13199
|
|
|
12516
13200
|
|
|
12517
13201
|
|
|
12518
|
-
#include <set>
|
|
12519
|
-
|
|
12520
|
-
namespace duckdb {
|
|
12521
|
-
using std::set;
|
|
12522
|
-
}
|
|
12523
13202
|
|
|
12524
13203
|
//===----------------------------------------------------------------------===//
|
|
12525
13204
|
// DuckDB
|
|
12526
13205
|
//
|
|
12527
|
-
// duckdb/
|
|
13206
|
+
// duckdb/catalog/catalog_set.hpp
|
|
12528
13207
|
//
|
|
12529
13208
|
//
|
|
12530
13209
|
//===----------------------------------------------------------------------===//
|
|
12531
13210
|
|
|
12532
13211
|
|
|
12533
13212
|
|
|
12534
|
-
#include <stack>
|
|
12535
|
-
|
|
12536
|
-
namespace duckdb {
|
|
12537
|
-
using std::stack;
|
|
12538
|
-
}
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
namespace duckdb {
|
|
12542
|
-
|
|
12543
|
-
//! Dependency Manager local to a table, responsible for keeping track of generated column dependencies
|
|
12544
|
-
|
|
12545
|
-
class ColumnDependencyManager {
|
|
12546
|
-
public:
|
|
12547
|
-
DUCKDB_API ColumnDependencyManager();
|
|
12548
|
-
DUCKDB_API ~ColumnDependencyManager();
|
|
12549
|
-
DUCKDB_API ColumnDependencyManager(ColumnDependencyManager &&other) = default;
|
|
12550
|
-
ColumnDependencyManager(const ColumnDependencyManager &other) = delete;
|
|
12551
|
-
|
|
12552
|
-
public:
|
|
12553
|
-
//! Get the bind order that ensures dependencies are resolved before dependents are
|
|
12554
|
-
stack<column_t> GetBindOrder(const vector<ColumnDefinition> &columns);
|
|
12555
|
-
|
|
12556
|
-
//! Adds a connection between the dependent and its dependencies
|
|
12557
|
-
void AddGeneratedColumn(column_t index, const vector<column_t> &indices, bool root = true);
|
|
12558
|
-
//! Add a generated column from a column definition
|
|
12559
|
-
void AddGeneratedColumn(const ColumnDefinition &column, const case_insensitive_map_t<column_t> &name_map);
|
|
12560
|
-
|
|
12561
|
-
//! Removes the column(s) and outputs the new column indices
|
|
12562
|
-
vector<column_t> RemoveColumn(column_t index, column_t column_amount);
|
|
12563
|
-
|
|
12564
|
-
bool IsDependencyOf(column_t dependent, column_t dependency) const;
|
|
12565
|
-
bool HasDependencies(column_t index) const;
|
|
12566
|
-
const unordered_set<column_t> &GetDependencies(column_t index) const;
|
|
12567
13213
|
|
|
12568
|
-
|
|
12569
|
-
|
|
13214
|
+
//===----------------------------------------------------------------------===//
|
|
13215
|
+
// DuckDB
|
|
13216
|
+
//
|
|
13217
|
+
// duckdb/catalog/default/default_generator.hpp
|
|
13218
|
+
//
|
|
13219
|
+
//
|
|
13220
|
+
//===----------------------------------------------------------------------===//
|
|
12570
13221
|
|
|
12571
|
-
private:
|
|
12572
|
-
void RemoveStandardColumn(column_t index);
|
|
12573
|
-
void RemoveGeneratedColumn(column_t index);
|
|
12574
13222
|
|
|
12575
|
-
void AdjustSingle(column_t idx, idx_t offset);
|
|
12576
|
-
// Clean up the gaps created by a Remove operation
|
|
12577
|
-
vector<column_t> CleanupInternals(column_t column_amount);
|
|
12578
13223
|
|
|
12579
|
-
private:
|
|
12580
|
-
//! A map of column dependency to generated column(s)
|
|
12581
|
-
unordered_map<column_t, unordered_set<column_t>> dependencies_map;
|
|
12582
|
-
//! A map of generated column name to (potentially generated)column dependencies
|
|
12583
|
-
unordered_map<column_t, unordered_set<column_t>> dependents_map;
|
|
12584
|
-
//! For resolve-order purposes, keep track of the 'direct' (not inherited) dependencies of a generated column
|
|
12585
|
-
unordered_map<column_t, unordered_set<column_t>> direct_dependencies;
|
|
12586
|
-
set<column_t> deleted_columns;
|
|
12587
|
-
};
|
|
12588
13224
|
|
|
12589
|
-
} // namespace duckdb
|
|
12590
13225
|
|
|
12591
13226
|
|
|
12592
13227
|
namespace duckdb {
|
|
13228
|
+
class ClientContext;
|
|
12593
13229
|
|
|
12594
|
-
class
|
|
12595
|
-
|
|
12596
|
-
|
|
13230
|
+
class DefaultGenerator {
|
|
13231
|
+
public:
|
|
13232
|
+
explicit DefaultGenerator(Catalog &catalog) : catalog(catalog), created_all_entries(false) {
|
|
13233
|
+
}
|
|
13234
|
+
virtual ~DefaultGenerator() {
|
|
13235
|
+
}
|
|
12597
13236
|
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
struct RemoveColumnInfo;
|
|
12601
|
-
struct SetDefaultInfo;
|
|
12602
|
-
struct ChangeColumnTypeInfo;
|
|
12603
|
-
struct AlterForeignKeyInfo;
|
|
12604
|
-
struct SetNotNullInfo;
|
|
12605
|
-
struct DropNotNullInfo;
|
|
13237
|
+
Catalog &catalog;
|
|
13238
|
+
atomic<bool> created_all_entries;
|
|
12606
13239
|
|
|
12607
|
-
//! A table catalog entry
|
|
12608
|
-
class TableCatalogEntry : public StandardEntry {
|
|
12609
13240
|
public:
|
|
12610
|
-
//!
|
|
12611
|
-
|
|
12612
|
-
|
|
13241
|
+
//! Creates a default entry with the specified name, or returns nullptr if no such entry can be generated
|
|
13242
|
+
virtual unique_ptr<CatalogEntry> CreateDefaultEntry(ClientContext &context, const string &entry_name) = 0;
|
|
13243
|
+
//! Get a list of all default entries in the generator
|
|
13244
|
+
virtual vector<string> GetDefaultEntries() = 0;
|
|
13245
|
+
};
|
|
12613
13246
|
|
|
12614
|
-
|
|
12615
|
-
std::shared_ptr<DataTable> storage;
|
|
12616
|
-
//! A list of columns that are part of this table
|
|
12617
|
-
vector<ColumnDefinition> columns;
|
|
12618
|
-
//! A list of constraints that are part of this table
|
|
12619
|
-
vector<unique_ptr<Constraint>> constraints;
|
|
12620
|
-
//! A list of constraints that are part of this table
|
|
12621
|
-
vector<unique_ptr<BoundConstraint>> bound_constraints;
|
|
12622
|
-
ColumnDependencyManager column_dependency_manager;
|
|
12623
|
-
//! A map of column name to column index
|
|
12624
|
-
case_insensitive_map_t<column_t> name_map;
|
|
13247
|
+
} // namespace duckdb
|
|
12625
13248
|
|
|
12626
|
-
public:
|
|
12627
|
-
//! For debugging purposes, count how many columns are STANDARD
|
|
12628
|
-
idx_t StandardColumnCount() const;
|
|
12629
|
-
unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info) override;
|
|
12630
|
-
//! Returns whether or not a column with the given name exists
|
|
12631
|
-
DUCKDB_API bool ColumnExists(const string &name);
|
|
12632
|
-
//! Returns a reference to the column of the specified name. Throws an
|
|
12633
|
-
//! exception if the column does not exist.
|
|
12634
|
-
ColumnDefinition &GetColumn(const string &name);
|
|
12635
|
-
//! Returns a list of types of the table
|
|
12636
|
-
vector<LogicalType> GetTypes();
|
|
12637
|
-
string ToSQL() override;
|
|
12638
13249
|
|
|
12639
|
-
//! Serialize the meta information of the TableCatalogEntry a serializer
|
|
12640
|
-
virtual void Serialize(Serializer &serializer);
|
|
12641
|
-
//! Deserializes to a CreateTableInfo
|
|
12642
|
-
static unique_ptr<CreateTableInfo> Deserialize(Deserializer &source, ClientContext &context);
|
|
12643
13250
|
|
|
12644
|
-
unique_ptr<CatalogEntry> Copy(ClientContext &context) override;
|
|
12645
13251
|
|
|
12646
|
-
void SetAsRoot() override;
|
|
12647
13252
|
|
|
12648
|
-
void CommitAlter(AlterInfo &info);
|
|
12649
|
-
void CommitDrop();
|
|
12650
13253
|
|
|
12651
|
-
//! Returns the column index of the specified column name.
|
|
12652
|
-
//! If the column does not exist:
|
|
12653
|
-
//! If if_exists is true, returns DConstants::INVALID_INDEX
|
|
12654
|
-
//! If if_exists is false, throws an exception
|
|
12655
|
-
column_t GetColumnIndex(string &name, bool if_exists = false);
|
|
12656
13254
|
|
|
12657
|
-
private:
|
|
12658
|
-
const string &GetColumnName(column_t index);
|
|
12659
|
-
unique_ptr<CatalogEntry> RenameColumn(ClientContext &context, RenameColumnInfo &info);
|
|
12660
|
-
unique_ptr<CatalogEntry> AddColumn(ClientContext &context, AddColumnInfo &info);
|
|
12661
|
-
unique_ptr<CatalogEntry> RemoveColumn(ClientContext &context, RemoveColumnInfo &info);
|
|
12662
|
-
unique_ptr<CatalogEntry> SetDefault(ClientContext &context, SetDefaultInfo &info);
|
|
12663
|
-
unique_ptr<CatalogEntry> ChangeColumnType(ClientContext &context, ChangeColumnTypeInfo &info);
|
|
12664
|
-
unique_ptr<CatalogEntry> SetNotNull(ClientContext &context, SetNotNullInfo &info);
|
|
12665
|
-
unique_ptr<CatalogEntry> DropNotNull(ClientContext &context, DropNotNullInfo &info);
|
|
12666
|
-
unique_ptr<CatalogEntry> AddForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info);
|
|
12667
|
-
unique_ptr<CatalogEntry> DropForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info);
|
|
12668
|
-
};
|
|
12669
|
-
} // namespace duckdb
|
|
12670
13255
|
|
|
12671
13256
|
//===----------------------------------------------------------------------===//
|
|
12672
13257
|
// DuckDB
|
|
@@ -23876,117 +24461,6 @@ private:
|
|
|
23876
24461
|
mutex lock;
|
|
23877
24462
|
};
|
|
23878
24463
|
|
|
23879
|
-
} // namespace duckdb
|
|
23880
|
-
//===----------------------------------------------------------------------===//
|
|
23881
|
-
// DuckDB
|
|
23882
|
-
//
|
|
23883
|
-
// duckdb/planner/table_filter.hpp
|
|
23884
|
-
//
|
|
23885
|
-
//
|
|
23886
|
-
//===----------------------------------------------------------------------===//
|
|
23887
|
-
|
|
23888
|
-
|
|
23889
|
-
|
|
23890
|
-
|
|
23891
|
-
|
|
23892
|
-
|
|
23893
|
-
//===----------------------------------------------------------------------===//
|
|
23894
|
-
// DuckDB
|
|
23895
|
-
//
|
|
23896
|
-
// duckdb/common/enums/filter_propagate_result.hpp
|
|
23897
|
-
//
|
|
23898
|
-
//
|
|
23899
|
-
//===----------------------------------------------------------------------===//
|
|
23900
|
-
|
|
23901
|
-
|
|
23902
|
-
|
|
23903
|
-
|
|
23904
|
-
|
|
23905
|
-
namespace duckdb {
|
|
23906
|
-
|
|
23907
|
-
enum class FilterPropagateResult : uint8_t {
|
|
23908
|
-
NO_PRUNING_POSSIBLE = 0,
|
|
23909
|
-
FILTER_ALWAYS_TRUE = 1,
|
|
23910
|
-
FILTER_ALWAYS_FALSE = 2,
|
|
23911
|
-
FILTER_TRUE_OR_NULL = 3,
|
|
23912
|
-
FILTER_FALSE_OR_NULL = 4
|
|
23913
|
-
};
|
|
23914
|
-
|
|
23915
|
-
} // namespace duckdb
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
namespace duckdb {
|
|
23919
|
-
class BaseStatistics;
|
|
23920
|
-
class FieldWriter;
|
|
23921
|
-
class FieldReader;
|
|
23922
|
-
|
|
23923
|
-
enum class TableFilterType : uint8_t {
|
|
23924
|
-
CONSTANT_COMPARISON = 0, // constant comparison (e.g. =C, >C, >=C, <C, <=C)
|
|
23925
|
-
IS_NULL = 1,
|
|
23926
|
-
IS_NOT_NULL = 2,
|
|
23927
|
-
CONJUNCTION_OR = 3,
|
|
23928
|
-
CONJUNCTION_AND = 4
|
|
23929
|
-
};
|
|
23930
|
-
|
|
23931
|
-
//! TableFilter represents a filter pushed down into the table scan.
|
|
23932
|
-
class TableFilter {
|
|
23933
|
-
public:
|
|
23934
|
-
TableFilter(TableFilterType filter_type_p) : filter_type(filter_type_p) {
|
|
23935
|
-
}
|
|
23936
|
-
virtual ~TableFilter() {
|
|
23937
|
-
}
|
|
23938
|
-
|
|
23939
|
-
TableFilterType filter_type;
|
|
23940
|
-
|
|
23941
|
-
public:
|
|
23942
|
-
//! Returns true if the statistics indicate that the segment can contain values that satisfy that filter
|
|
23943
|
-
virtual FilterPropagateResult CheckStatistics(BaseStatistics &stats) = 0;
|
|
23944
|
-
virtual string ToString(const string &column_name) = 0;
|
|
23945
|
-
virtual bool Equals(const TableFilter &other) const {
|
|
23946
|
-
return filter_type != other.filter_type;
|
|
23947
|
-
}
|
|
23948
|
-
|
|
23949
|
-
void Serialize(Serializer &serializer) const;
|
|
23950
|
-
virtual void Serialize(FieldWriter &writer) const = 0;
|
|
23951
|
-
static unique_ptr<TableFilter> Deserialize(Deserializer &source);
|
|
23952
|
-
};
|
|
23953
|
-
|
|
23954
|
-
class TableFilterSet {
|
|
23955
|
-
public:
|
|
23956
|
-
unordered_map<idx_t, unique_ptr<TableFilter>> filters;
|
|
23957
|
-
|
|
23958
|
-
public:
|
|
23959
|
-
void PushFilter(idx_t table_index, unique_ptr<TableFilter> filter);
|
|
23960
|
-
|
|
23961
|
-
bool Equals(TableFilterSet &other) {
|
|
23962
|
-
if (filters.size() != other.filters.size()) {
|
|
23963
|
-
return false;
|
|
23964
|
-
}
|
|
23965
|
-
for (auto &entry : filters) {
|
|
23966
|
-
auto other_entry = other.filters.find(entry.first);
|
|
23967
|
-
if (other_entry == other.filters.end()) {
|
|
23968
|
-
return false;
|
|
23969
|
-
}
|
|
23970
|
-
if (!entry.second->Equals(*other_entry->second)) {
|
|
23971
|
-
return false;
|
|
23972
|
-
}
|
|
23973
|
-
}
|
|
23974
|
-
return true;
|
|
23975
|
-
}
|
|
23976
|
-
static bool Equals(TableFilterSet *left, TableFilterSet *right) {
|
|
23977
|
-
if (left == right) {
|
|
23978
|
-
return true;
|
|
23979
|
-
}
|
|
23980
|
-
if (!left || !right) {
|
|
23981
|
-
return false;
|
|
23982
|
-
}
|
|
23983
|
-
return left->Equals(*right);
|
|
23984
|
-
}
|
|
23985
|
-
|
|
23986
|
-
void Serialize(Serializer &serializer) const;
|
|
23987
|
-
static unique_ptr<TableFilterSet> Deserialize(Deserializer &source);
|
|
23988
|
-
};
|
|
23989
|
-
|
|
23990
24464
|
} // namespace duckdb
|
|
23991
24465
|
//===----------------------------------------------------------------------===//
|
|
23992
24466
|
// DuckDB
|
|
@@ -25017,41 +25491,6 @@ private:
|
|
|
25017
25491
|
|
|
25018
25492
|
|
|
25019
25493
|
|
|
25020
|
-
//===----------------------------------------------------------------------===//
|
|
25021
|
-
// DuckDB
|
|
25022
|
-
//
|
|
25023
|
-
// duckdb/parser/expression_map.hpp
|
|
25024
|
-
//
|
|
25025
|
-
//
|
|
25026
|
-
//===----------------------------------------------------------------------===//
|
|
25027
|
-
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
namespace duckdb {
|
|
25035
|
-
class Expression;
|
|
25036
|
-
|
|
25037
|
-
struct ExpressionHashFunction {
|
|
25038
|
-
uint64_t operator()(const BaseExpression *const &expr) const {
|
|
25039
|
-
return (uint64_t)expr->Hash();
|
|
25040
|
-
}
|
|
25041
|
-
};
|
|
25042
|
-
|
|
25043
|
-
struct ExpressionEquality {
|
|
25044
|
-
bool operator()(const BaseExpression *const &a, const BaseExpression *const &b) const {
|
|
25045
|
-
return a->Equals(b);
|
|
25046
|
-
}
|
|
25047
|
-
};
|
|
25048
|
-
|
|
25049
|
-
template <typename T>
|
|
25050
|
-
using expression_map_t = unordered_map<BaseExpression *, T, ExpressionHashFunction, ExpressionEquality>;
|
|
25051
|
-
|
|
25052
|
-
using expression_set_t = unordered_set<BaseExpression *, ExpressionHashFunction, ExpressionEquality>;
|
|
25053
|
-
|
|
25054
|
-
} // namespace duckdb
|
|
25055
25494
|
|
|
25056
25495
|
|
|
25057
25496
|
|
|
@@ -25200,7 +25639,7 @@ public:
|
|
|
25200
25639
|
|
|
25201
25640
|
|
|
25202
25641
|
// LICENSE_CHANGE_BEGIN
|
|
25203
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #
|
|
25642
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
25204
25643
|
// See the end of this file for a list
|
|
25205
25644
|
|
|
25206
25645
|
// Copyright 2003-2009 The RE2 Authors. All Rights Reserved.
|
|
@@ -25404,7 +25843,7 @@ public:
|
|
|
25404
25843
|
|
|
25405
25844
|
|
|
25406
25845
|
// LICENSE_CHANGE_BEGIN
|
|
25407
|
-
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #
|
|
25846
|
+
// The following code up to LICENSE_CHANGE_END is subject to THIRD PARTY LICENSE #2
|
|
25408
25847
|
// See the end of this file for a list
|
|
25409
25848
|
|
|
25410
25849
|
// Copyright 2001-2010 The RE2 Authors. All Rights Reserved.
|