duckdb 0.5.1 → 0.5.2-dev113.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 +3292 -2231
- package/src/duckdb.hpp +937 -791
- package/src/parquet-amalgamation.cpp +36973 -36971
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.5.
|
|
14
|
+
#define DUCKDB_SOURCE_ID "878befda2"
|
|
15
|
+
#define DUCKDB_VERSION "v0.5.2-dev113"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -1170,7 +1170,7 @@ struct UserType{
|
|
|
1170
1170
|
|
|
1171
1171
|
struct EnumType{
|
|
1172
1172
|
DUCKDB_API static const string &GetTypeName(const LogicalType &type);
|
|
1173
|
-
DUCKDB_API static int64_t GetPos(const LogicalType &type, const
|
|
1173
|
+
DUCKDB_API static int64_t GetPos(const LogicalType &type, const string_t& key);
|
|
1174
1174
|
DUCKDB_API static Vector &GetValuesInsertOrder(const LogicalType &type);
|
|
1175
1175
|
DUCKDB_API static idx_t GetSize(const LogicalType &type);
|
|
1176
1176
|
DUCKDB_API static const string GetValue(const Value &val);
|
|
@@ -2871,6 +2871,7 @@ public:
|
|
|
2871
2871
|
|
|
2872
2872
|
namespace duckdb {
|
|
2873
2873
|
|
|
2874
|
+
class CastFunctionSet;
|
|
2874
2875
|
class Deserializer;
|
|
2875
2876
|
class Serializer;
|
|
2876
2877
|
|
|
@@ -3052,12 +3053,20 @@ public:
|
|
|
3052
3053
|
DUCKDB_API uintptr_t GetPointer() const;
|
|
3053
3054
|
|
|
3054
3055
|
//! Cast this value to another type, throws exception if its not possible
|
|
3055
|
-
DUCKDB_API Value CastAs(const LogicalType &target_type, bool strict = false) const;
|
|
3056
|
+
DUCKDB_API Value CastAs(CastFunctionSet &set, const LogicalType &target_type, bool strict = false) const;
|
|
3057
|
+
DUCKDB_API Value CastAs(ClientContext &context, const LogicalType &target_type, bool strict = false) const;
|
|
3058
|
+
DUCKDB_API Value DefaultCastAs(const LogicalType &target_type, bool strict = false) const;
|
|
3056
3059
|
//! Tries to cast this value to another type, and stores the result in "new_value"
|
|
3057
|
-
DUCKDB_API bool TryCastAs(const LogicalType &target_type, Value &new_value,
|
|
3058
|
-
bool strict = false) const;
|
|
3060
|
+
DUCKDB_API bool TryCastAs(CastFunctionSet &set, const LogicalType &target_type, Value &new_value,
|
|
3061
|
+
string *error_message, bool strict = false) const;
|
|
3062
|
+
DUCKDB_API bool TryCastAs(ClientContext &context, const LogicalType &target_type, Value &new_value,
|
|
3063
|
+
string *error_message, bool strict = false) const;
|
|
3064
|
+
DUCKDB_API bool DefaultTryCastAs(const LogicalType &target_type, Value &new_value, string *error_message,
|
|
3065
|
+
bool strict = false) const;
|
|
3059
3066
|
//! Tries to cast this value to another type, and stores the result in THIS value again
|
|
3060
|
-
DUCKDB_API bool TryCastAs(const LogicalType &target_type, bool strict = false);
|
|
3067
|
+
DUCKDB_API bool TryCastAs(CastFunctionSet &set, const LogicalType &target_type, bool strict = false);
|
|
3068
|
+
DUCKDB_API bool TryCastAs(ClientContext &context, const LogicalType &target_type, bool strict = false);
|
|
3069
|
+
DUCKDB_API bool DefaultTryCastAs(const LogicalType &target_type, bool strict = false);
|
|
3061
3070
|
|
|
3062
3071
|
//! Serializes a Value to a stand-alone binary blob
|
|
3063
3072
|
DUCKDB_API void Serialize(Serializer &serializer) const;
|
|
@@ -3098,7 +3107,9 @@ public:
|
|
|
3098
3107
|
|
|
3099
3108
|
//! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
|
|
3100
3109
|
//! function, NULL values are equivalent and floating point values that are close are equivalent.
|
|
3101
|
-
DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
|
|
3110
|
+
DUCKDB_API static bool ValuesAreEqual(CastFunctionSet &set, const Value &result_value, const Value &value);
|
|
3111
|
+
DUCKDB_API static bool ValuesAreEqual(ClientContext &context, const Value &result_value, const Value &value);
|
|
3112
|
+
DUCKDB_API static bool DefaultValuesAreEqual(const Value &result_value, const Value &value);
|
|
3102
3113
|
//! Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.
|
|
3103
3114
|
DUCKDB_API static bool NotDistinctFrom(const Value &lvalue, const Value &rvalue);
|
|
3104
3115
|
|
|
@@ -4818,6 +4829,7 @@ private:
|
|
|
4818
4829
|
#include <functional>
|
|
4819
4830
|
|
|
4820
4831
|
namespace duckdb {
|
|
4832
|
+
class CastFunctionSet;
|
|
4821
4833
|
|
|
4822
4834
|
// VectorOperations contains a set of operations that operate on sets of
|
|
4823
4835
|
// vectors. In general, the operators must all have the same type, otherwise an
|
|
@@ -4959,10 +4971,16 @@ struct VectorOperations {
|
|
|
4959
4971
|
//! Cast the data from the source type to the target type. Any elements that could not be converted are turned into
|
|
4960
4972
|
//! NULLs. If any elements cannot be converted, returns false and fills in the error_message. If no error message is
|
|
4961
4973
|
//! provided, an exception is thrown instead.
|
|
4962
|
-
DUCKDB_API static bool TryCast(Vector &source, Vector &result, idx_t count,
|
|
4963
|
-
bool strict = false);
|
|
4974
|
+
DUCKDB_API static bool TryCast(CastFunctionSet &set, Vector &source, Vector &result, idx_t count,
|
|
4975
|
+
string *error_message, bool strict = false);
|
|
4976
|
+
DUCKDB_API static bool DefaultTryCast(Vector &source, Vector &result, idx_t count, string *error_message,
|
|
4977
|
+
bool strict = false);
|
|
4978
|
+
DUCKDB_API static bool TryCast(ClientContext &context, Vector &source, Vector &result, idx_t count,
|
|
4979
|
+
string *error_message, bool strict = false);
|
|
4964
4980
|
//! Cast the data from the source type to the target type. Throws an exception if the cast fails.
|
|
4965
|
-
DUCKDB_API static void Cast(Vector &source, Vector &result, idx_t count,
|
|
4981
|
+
DUCKDB_API static void Cast(ClientContext &context, Vector &source, Vector &result, idx_t count,
|
|
4982
|
+
bool strict = false);
|
|
4983
|
+
DUCKDB_API static void DefaultCast(Vector &source, Vector &result, idx_t count, bool strict = false);
|
|
4966
4984
|
|
|
4967
4985
|
// Copy the data of <source> to the target vector
|
|
4968
4986
|
static void Copy(const Vector &source, Vector &target, idx_t source_count, idx_t source_offset,
|
|
@@ -6987,28 +7005,6 @@ public:
|
|
|
6987
7005
|
DUCKDB_API static string CallToString(const string &name, const vector<LogicalType> &arguments,
|
|
6988
7006
|
const named_parameter_type_map_t &named_parameters);
|
|
6989
7007
|
|
|
6990
|
-
//! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
|
|
6991
|
-
//! returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6992
|
-
DUCKDB_API static idx_t BindFunction(const string &name, ScalarFunctionSet &functions,
|
|
6993
|
-
const vector<LogicalType> &arguments, string &error);
|
|
6994
|
-
DUCKDB_API static idx_t BindFunction(const string &name, ScalarFunctionSet &functions,
|
|
6995
|
-
vector<unique_ptr<Expression>> &arguments, string &error);
|
|
6996
|
-
//! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
|
|
6997
|
-
//! function, returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
6998
|
-
DUCKDB_API static idx_t BindFunction(const string &name, AggregateFunctionSet &functions,
|
|
6999
|
-
const vector<LogicalType> &arguments, string &error);
|
|
7000
|
-
DUCKDB_API static idx_t BindFunction(const string &name, AggregateFunctionSet &functions,
|
|
7001
|
-
vector<unique_ptr<Expression>> &arguments, string &error);
|
|
7002
|
-
//! Bind a table function from the set of functions and input arguments. Returns the index of the chosen
|
|
7003
|
-
//! function, returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
7004
|
-
DUCKDB_API static idx_t BindFunction(const string &name, TableFunctionSet &functions,
|
|
7005
|
-
const vector<LogicalType> &arguments, string &error);
|
|
7006
|
-
DUCKDB_API static idx_t BindFunction(const string &name, TableFunctionSet &functions,
|
|
7007
|
-
vector<unique_ptr<Expression>> &arguments, string &error);
|
|
7008
|
-
//! Bind a pragma function from the set of functions and input arguments
|
|
7009
|
-
DUCKDB_API static idx_t BindFunction(const string &name, PragmaFunctionSet &functions, PragmaInfo &info,
|
|
7010
|
-
string &error);
|
|
7011
|
-
|
|
7012
7008
|
//! Used in the bind to erase an argument from a function
|
|
7013
7009
|
DUCKDB_API static void EraseArgument(SimpleFunction &bound_function, vector<unique_ptr<Expression>> &arguments,
|
|
7014
7010
|
idx_t argument_index);
|
|
@@ -7068,9 +7064,6 @@ public:
|
|
|
7068
7064
|
public:
|
|
7069
7065
|
DUCKDB_API hash_t Hash() const;
|
|
7070
7066
|
|
|
7071
|
-
//! Cast a set of expressions to the arguments of this function
|
|
7072
|
-
DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
|
|
7073
|
-
|
|
7074
7067
|
DUCKDB_API string ToString() override;
|
|
7075
7068
|
};
|
|
7076
7069
|
|
|
@@ -8032,20 +8025,6 @@ public:
|
|
|
8032
8025
|
function_serialize_t serialize;
|
|
8033
8026
|
function_deserialize_t deserialize;
|
|
8034
8027
|
|
|
8035
|
-
DUCKDB_API static unique_ptr<Expression> BindScalarFunction(ClientContext &context, const string &schema,
|
|
8036
|
-
const string &name,
|
|
8037
|
-
vector<unique_ptr<Expression>> children, string &error,
|
|
8038
|
-
bool is_operator = false, Binder *binder = nullptr);
|
|
8039
|
-
DUCKDB_API static unique_ptr<Expression> BindScalarFunction(ClientContext &context,
|
|
8040
|
-
ScalarFunctionCatalogEntry &function,
|
|
8041
|
-
vector<unique_ptr<Expression>> children, string &error,
|
|
8042
|
-
bool is_operator = false, Binder *binder = nullptr);
|
|
8043
|
-
|
|
8044
|
-
DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
|
|
8045
|
-
ScalarFunction bound_function,
|
|
8046
|
-
vector<unique_ptr<Expression>> children,
|
|
8047
|
-
bool is_operator = false);
|
|
8048
|
-
|
|
8049
8028
|
DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
|
|
8050
8029
|
DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
|
|
8051
8030
|
|
|
@@ -9491,7 +9470,7 @@ struct ForeignKeyInfo {
|
|
|
9491
9470
|
//! The set of main key table's column's index
|
|
9492
9471
|
vector<storage_t> pk_keys;
|
|
9493
9472
|
//! The set of foreign key table's column's index
|
|
9494
|
-
vector<
|
|
9473
|
+
vector<storage_t> fk_keys;
|
|
9495
9474
|
};
|
|
9496
9475
|
|
|
9497
9476
|
//! Constraint is the base class of any type of table constraint.
|
|
@@ -10705,16 +10684,6 @@ public:
|
|
|
10705
10684
|
return !(*this == rhs);
|
|
10706
10685
|
}
|
|
10707
10686
|
|
|
10708
|
-
DUCKDB_API static unique_ptr<BoundAggregateExpression>
|
|
10709
|
-
BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
|
|
10710
|
-
vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
|
|
10711
|
-
bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr);
|
|
10712
|
-
|
|
10713
|
-
DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
|
|
10714
|
-
vector<unique_ptr<Expression>> &children,
|
|
10715
|
-
unique_ptr<FunctionData> bind_info,
|
|
10716
|
-
unique_ptr<BoundOrderModifier> order_bys);
|
|
10717
|
-
|
|
10718
10687
|
public:
|
|
10719
10688
|
template <class STATE, class RESULT_TYPE, class OP>
|
|
10720
10689
|
static AggregateFunction NullaryAggregate(LogicalType return_type) {
|
|
@@ -11416,6 +11385,7 @@ public:
|
|
|
11416
11385
|
DUCKDB_API ~ColumnDataCollection();
|
|
11417
11386
|
|
|
11418
11387
|
public:
|
|
11388
|
+
//! The types of columns in the ColumnDataCollection
|
|
11419
11389
|
DUCKDB_API vector<LogicalType> &Types() {
|
|
11420
11390
|
return types;
|
|
11421
11391
|
}
|
|
@@ -13805,6 +13775,7 @@ struct ParseInfo {
|
|
|
13805
13775
|
|
|
13806
13776
|
|
|
13807
13777
|
namespace duckdb {
|
|
13778
|
+
struct AlterInfo;
|
|
13808
13779
|
|
|
13809
13780
|
enum class OnCreateConflict : uint8_t {
|
|
13810
13781
|
// Standard: throw error
|
|
@@ -13812,7 +13783,9 @@ enum class OnCreateConflict : uint8_t {
|
|
|
13812
13783
|
// CREATE IF NOT EXISTS, silently do nothing on conflict
|
|
13813
13784
|
IGNORE_ON_CONFLICT,
|
|
13814
13785
|
// CREATE OR REPLACE
|
|
13815
|
-
REPLACE_ON_CONFLICT
|
|
13786
|
+
REPLACE_ON_CONFLICT,
|
|
13787
|
+
// Update on conflict - only support for functions. Add a function overload if the function already exists.
|
|
13788
|
+
ALTER_ON_CONFLICT
|
|
13816
13789
|
};
|
|
13817
13790
|
|
|
13818
13791
|
struct CreateInfo : public ParseInfo {
|
|
@@ -13849,6 +13822,8 @@ public:
|
|
|
13849
13822
|
virtual unique_ptr<CreateInfo> Copy() const = 0;
|
|
13850
13823
|
|
|
13851
13824
|
DUCKDB_API void CopyProperties(CreateInfo &other) const;
|
|
13825
|
+
//! Generates an alter statement from the create statement - used for OnCreateConflict::ALTER_ON_CONFLICT
|
|
13826
|
+
DUCKDB_API virtual unique_ptr<AlterInfo> GetAlterInfo() const;
|
|
13852
13827
|
};
|
|
13853
13828
|
|
|
13854
13829
|
} // namespace duckdb
|
|
@@ -13926,6 +13901,15 @@ protected:
|
|
|
13926
13901
|
|
|
13927
13902
|
|
|
13928
13903
|
|
|
13904
|
+
//===----------------------------------------------------------------------===//
|
|
13905
|
+
// DuckDB
|
|
13906
|
+
//
|
|
13907
|
+
// duckdb/parser/parsed_data/alter_info.hpp
|
|
13908
|
+
//
|
|
13909
|
+
//
|
|
13910
|
+
//===----------------------------------------------------------------------===//
|
|
13911
|
+
|
|
13912
|
+
|
|
13929
13913
|
|
|
13930
13914
|
|
|
13931
13915
|
|
|
@@ -13938,14 +13922,13 @@ enum class AlterType : uint8_t {
|
|
|
13938
13922
|
ALTER_TABLE = 1,
|
|
13939
13923
|
ALTER_VIEW = 2,
|
|
13940
13924
|
ALTER_SEQUENCE = 3,
|
|
13941
|
-
CHANGE_OWNERSHIP = 4
|
|
13925
|
+
CHANGE_OWNERSHIP = 4,
|
|
13926
|
+
ALTER_FUNCTION = 5
|
|
13942
13927
|
};
|
|
13943
13928
|
|
|
13944
|
-
enum AlterForeignKeyType : uint8_t { AFT_ADD = 0, AFT_DELETE = 1 };
|
|
13945
|
-
|
|
13946
13929
|
struct AlterInfo : public ParseInfo {
|
|
13947
13930
|
AlterInfo(AlterType type, string schema, string name, bool if_exists);
|
|
13948
|
-
~AlterInfo() override;
|
|
13931
|
+
virtual ~AlterInfo() override;
|
|
13949
13932
|
|
|
13950
13933
|
AlterType type;
|
|
13951
13934
|
//! if exists
|
|
@@ -13963,6 +13946,16 @@ public:
|
|
|
13963
13946
|
static unique_ptr<AlterInfo> Deserialize(Deserializer &source);
|
|
13964
13947
|
};
|
|
13965
13948
|
|
|
13949
|
+
} // namespace duckdb
|
|
13950
|
+
|
|
13951
|
+
|
|
13952
|
+
|
|
13953
|
+
|
|
13954
|
+
|
|
13955
|
+
namespace duckdb {
|
|
13956
|
+
|
|
13957
|
+
enum AlterForeignKeyType : uint8_t { AFT_ADD = 0, AFT_DELETE = 1 };
|
|
13958
|
+
|
|
13966
13959
|
//===--------------------------------------------------------------------===//
|
|
13967
13960
|
// Change Ownership
|
|
13968
13961
|
//===--------------------------------------------------------------------===//
|
|
@@ -14409,7 +14402,7 @@ public:
|
|
|
14409
14402
|
ChunkCollection(Allocator &allocator);
|
|
14410
14403
|
ChunkCollection(ClientContext &context);
|
|
14411
14404
|
|
|
14412
|
-
//! The
|
|
14405
|
+
//! The types of columns in the ChunkCollection
|
|
14413
14406
|
DUCKDB_API vector<LogicalType> &Types() {
|
|
14414
14407
|
return types;
|
|
14415
14408
|
}
|
|
@@ -14748,17 +14741,124 @@ public:
|
|
|
14748
14741
|
|
|
14749
14742
|
|
|
14750
14743
|
|
|
14744
|
+
//===----------------------------------------------------------------------===//
|
|
14745
|
+
// DuckDB
|
|
14746
|
+
//
|
|
14747
|
+
// duckdb/function/cast/default_casts.hpp
|
|
14748
|
+
//
|
|
14749
|
+
//
|
|
14750
|
+
//===----------------------------------------------------------------------===//
|
|
14751
|
+
|
|
14752
|
+
|
|
14753
|
+
|
|
14754
|
+
|
|
14755
|
+
|
|
14756
|
+
|
|
14757
|
+
namespace duckdb {
|
|
14758
|
+
class CastFunctionSet;
|
|
14759
|
+
|
|
14760
|
+
//! Extra data that can be attached to a bind function of a cast, and is available during binding
|
|
14761
|
+
struct BindCastInfo {
|
|
14762
|
+
DUCKDB_API virtual ~BindCastInfo();
|
|
14763
|
+
};
|
|
14764
|
+
|
|
14765
|
+
//! Extra data that can be returned by the bind of a cast, and is available during execution of a cast
|
|
14766
|
+
struct BoundCastData {
|
|
14767
|
+
DUCKDB_API virtual ~BoundCastData();
|
|
14768
|
+
|
|
14769
|
+
DUCKDB_API virtual unique_ptr<BoundCastData> Copy() const = 0;
|
|
14770
|
+
};
|
|
14771
|
+
|
|
14772
|
+
struct CastParameters {
|
|
14773
|
+
CastParameters() {
|
|
14774
|
+
}
|
|
14775
|
+
CastParameters(BoundCastData *cast_data, bool strict, string *error_message)
|
|
14776
|
+
: cast_data(cast_data), strict(strict), error_message(error_message) {
|
|
14777
|
+
}
|
|
14778
|
+
CastParameters(CastParameters &parent, BoundCastData *cast_data = nullptr)
|
|
14779
|
+
: cast_data(cast_data), strict(parent.strict), error_message(parent.error_message) {
|
|
14780
|
+
}
|
|
14781
|
+
|
|
14782
|
+
//! The bound cast data (if any)
|
|
14783
|
+
BoundCastData *cast_data = nullptr;
|
|
14784
|
+
//! whether or not to enable strict casting
|
|
14785
|
+
bool strict = false;
|
|
14786
|
+
// out: error message in case cast has failed
|
|
14787
|
+
string *error_message = nullptr;
|
|
14788
|
+
};
|
|
14789
|
+
|
|
14790
|
+
typedef bool (*cast_function_t)(Vector &source, Vector &result, idx_t count, CastParameters ¶meters);
|
|
14791
|
+
|
|
14792
|
+
struct BoundCastInfo {
|
|
14793
|
+
BoundCastInfo(cast_function_t function,
|
|
14794
|
+
unique_ptr<BoundCastData> cast_data = nullptr); // NOLINT: allow explicit cast from cast_function_t
|
|
14795
|
+
|
|
14796
|
+
cast_function_t function;
|
|
14797
|
+
unique_ptr<BoundCastData> cast_data;
|
|
14798
|
+
|
|
14799
|
+
public:
|
|
14800
|
+
BoundCastInfo Copy() const;
|
|
14801
|
+
};
|
|
14802
|
+
|
|
14803
|
+
struct BindCastInput {
|
|
14804
|
+
BindCastInput(CastFunctionSet &function_set, BindCastInfo *info) : function_set(function_set), info(info) {
|
|
14805
|
+
}
|
|
14806
|
+
|
|
14807
|
+
CastFunctionSet &function_set;
|
|
14808
|
+
BindCastInfo *info;
|
|
14809
|
+
};
|
|
14810
|
+
|
|
14811
|
+
struct DefaultCasts {
|
|
14812
|
+
static BoundCastInfo GetDefaultCastFunction(BindCastInput &input, const LogicalType &source,
|
|
14813
|
+
const LogicalType &target);
|
|
14814
|
+
|
|
14815
|
+
static bool NopCast(Vector &source, Vector &result, idx_t count, CastParameters ¶meters);
|
|
14816
|
+
static bool TryVectorNullCast(Vector &source, Vector &result, idx_t count, CastParameters ¶meters);
|
|
14817
|
+
static bool ReinterpretCast(Vector &source, Vector &result, idx_t count, CastParameters ¶meters);
|
|
14818
|
+
|
|
14819
|
+
private:
|
|
14820
|
+
static BoundCastInfo BlobCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14821
|
+
static BoundCastInfo DateCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14822
|
+
static BoundCastInfo DecimalCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14823
|
+
static BoundCastInfo EnumCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14824
|
+
static BoundCastInfo IntervalCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14825
|
+
static BoundCastInfo ListCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14826
|
+
static BoundCastInfo NumericCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14827
|
+
static BoundCastInfo MapCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14828
|
+
static BoundCastInfo PointerCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14829
|
+
static BoundCastInfo StringCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14830
|
+
static BoundCastInfo StructCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14831
|
+
static BoundCastInfo TimeCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14832
|
+
static BoundCastInfo TimeTzCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14833
|
+
static BoundCastInfo TimestampCastSwitch(BindCastInput &input, const LogicalType &source,
|
|
14834
|
+
const LogicalType &target);
|
|
14835
|
+
static BoundCastInfo TimestampTzCastSwitch(BindCastInput &input, const LogicalType &source,
|
|
14836
|
+
const LogicalType &target);
|
|
14837
|
+
static BoundCastInfo TimestampNsCastSwitch(BindCastInput &input, const LogicalType &source,
|
|
14838
|
+
const LogicalType &target);
|
|
14839
|
+
static BoundCastInfo TimestampMsCastSwitch(BindCastInput &input, const LogicalType &source,
|
|
14840
|
+
const LogicalType &target);
|
|
14841
|
+
static BoundCastInfo TimestampSecCastSwitch(BindCastInput &input, const LogicalType &source,
|
|
14842
|
+
const LogicalType &target);
|
|
14843
|
+
static BoundCastInfo UUIDCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
|
|
14844
|
+
};
|
|
14845
|
+
|
|
14846
|
+
} // namespace duckdb
|
|
14847
|
+
|
|
14751
14848
|
|
|
14752
14849
|
namespace duckdb {
|
|
14753
14850
|
|
|
14754
14851
|
class BoundCastExpression : public Expression {
|
|
14755
14852
|
public:
|
|
14756
|
-
BoundCastExpression(unique_ptr<Expression> child, LogicalType target_type,
|
|
14853
|
+
BoundCastExpression(unique_ptr<Expression> child, LogicalType target_type, BoundCastInfo bound_cast,
|
|
14854
|
+
bool try_cast = false);
|
|
14757
14855
|
|
|
14758
14856
|
//! The child type
|
|
14759
14857
|
unique_ptr<Expression> child;
|
|
14760
14858
|
//! Whether to use try_cast or not. try_cast converts cast failures into NULLs instead of throwing an error.
|
|
14761
14859
|
bool try_cast;
|
|
14860
|
+
//! The bound cast info
|
|
14861
|
+
BoundCastInfo bound_cast;
|
|
14762
14862
|
|
|
14763
14863
|
public:
|
|
14764
14864
|
LogicalType source_type() {
|
|
@@ -14766,9 +14866,12 @@ public:
|
|
|
14766
14866
|
return child->return_type;
|
|
14767
14867
|
}
|
|
14768
14868
|
|
|
14869
|
+
//! Cast an expression to the specified SQL type, using only the built-in SQL casts
|
|
14870
|
+
static unique_ptr<Expression> AddDefaultCastToType(unique_ptr<Expression> expr, const LogicalType &target_type,
|
|
14871
|
+
bool try_cast = false);
|
|
14769
14872
|
//! Cast an expression to the specified SQL type if required
|
|
14770
|
-
static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr,
|
|
14771
|
-
bool try_cast = false);
|
|
14873
|
+
static unique_ptr<Expression> AddCastToType(ClientContext &context, unique_ptr<Expression> expr,
|
|
14874
|
+
const LogicalType &target_type, bool try_cast = false);
|
|
14772
14875
|
//! Returns true if a cast is invertible (i.e. CAST(s -> t -> s) = s for all values of s). This is not true for e.g.
|
|
14773
14876
|
//! boolean casts, because that can be e.g. -1 -> TRUE -> 1. This is necessary to prevent some optimizer bugs.
|
|
14774
14877
|
static bool CastIsInvertible(const LogicalType &source_type, const LogicalType &target_type);
|
|
@@ -15621,21 +15724,21 @@ class ScalarFunctionSet : public FunctionSet<ScalarFunction> {
|
|
|
15621
15724
|
public:
|
|
15622
15725
|
DUCKDB_API explicit ScalarFunctionSet(string name);
|
|
15623
15726
|
|
|
15624
|
-
DUCKDB_API ScalarFunction GetFunctionByArguments(const vector<LogicalType> &arguments);
|
|
15727
|
+
DUCKDB_API ScalarFunction GetFunctionByArguments(ClientContext &context, const vector<LogicalType> &arguments);
|
|
15625
15728
|
};
|
|
15626
15729
|
|
|
15627
15730
|
class AggregateFunctionSet : public FunctionSet<AggregateFunction> {
|
|
15628
15731
|
public:
|
|
15629
15732
|
DUCKDB_API explicit AggregateFunctionSet(string name);
|
|
15630
15733
|
|
|
15631
|
-
DUCKDB_API AggregateFunction GetFunctionByArguments(const vector<LogicalType> &arguments);
|
|
15734
|
+
DUCKDB_API AggregateFunction GetFunctionByArguments(ClientContext &context, const vector<LogicalType> &arguments);
|
|
15632
15735
|
};
|
|
15633
15736
|
|
|
15634
15737
|
class TableFunctionSet : public FunctionSet<TableFunction> {
|
|
15635
15738
|
public:
|
|
15636
15739
|
DUCKDB_API explicit TableFunctionSet(string name);
|
|
15637
15740
|
|
|
15638
|
-
TableFunction GetFunctionByArguments(const vector<LogicalType> &arguments);
|
|
15741
|
+
TableFunction GetFunctionByArguments(ClientContext &context, const vector<LogicalType> &arguments);
|
|
15639
15742
|
};
|
|
15640
15743
|
|
|
15641
15744
|
class PragmaFunctionSet : public FunctionSet<PragmaFunction> {
|
|
@@ -16079,11 +16182,13 @@ public:
|
|
|
16079
16182
|
//! TableBinding is exactly like the Binding, except it keeps track of which columns were bound in the linked LogicalGet
|
|
16080
16183
|
//! node for projection pushdown purposes.
|
|
16081
16184
|
struct TableBinding : public Binding {
|
|
16082
|
-
TableBinding(const string &alias, vector<LogicalType> types, vector<string> names,
|
|
16083
|
-
bool add_row_id = false);
|
|
16185
|
+
TableBinding(const string &alias, vector<LogicalType> types, vector<string> names,
|
|
16186
|
+
vector<column_t> &bound_column_ids, StandardEntry *entry, idx_t index, bool add_row_id = false);
|
|
16084
16187
|
|
|
16085
|
-
//! the
|
|
16086
|
-
|
|
16188
|
+
//! A reference to the set of bound column ids
|
|
16189
|
+
vector<column_t> &bound_column_ids;
|
|
16190
|
+
//! The underlying catalog entry (if any)
|
|
16191
|
+
StandardEntry *entry;
|
|
16087
16192
|
|
|
16088
16193
|
public:
|
|
16089
16194
|
unique_ptr<ParsedExpression> ExpandGeneratedColumn(const string &column_name);
|
|
@@ -16175,10 +16280,10 @@ public:
|
|
|
16175
16280
|
|
|
16176
16281
|
//! Adds a base table with the given alias to the BindContext.
|
|
16177
16282
|
void AddBaseTable(idx_t index, const string &alias, const vector<string> &names, const vector<LogicalType> &types,
|
|
16178
|
-
|
|
16283
|
+
vector<column_t> &bound_column_ids, StandardEntry *entry);
|
|
16179
16284
|
//! Adds a call to a table function with the given alias to the BindContext.
|
|
16180
16285
|
void AddTableFunction(idx_t index, const string &alias, const vector<string> &names,
|
|
16181
|
-
const vector<LogicalType> &types,
|
|
16286
|
+
const vector<LogicalType> &types, vector<column_t> &bound_column_ids, StandardEntry *entry);
|
|
16182
16287
|
//! Adds a table view with a given alias to the BindContext.
|
|
16183
16288
|
void AddView(idx_t index, const string &alias, SubqueryRef &ref, BoundQueryNode &subquery, ViewCatalogEntry *view);
|
|
16184
16289
|
//! Adds a subquery with a given alias to the BindContext.
|
|
@@ -21196,6 +21301,7 @@ public:
|
|
|
21196
21301
|
|
|
21197
21302
|
} // namespace duckdb
|
|
21198
21303
|
|
|
21304
|
+
|
|
21199
21305
|
//===----------------------------------------------------------------------===//
|
|
21200
21306
|
// DuckDB
|
|
21201
21307
|
//
|
|
@@ -21234,9 +21340,10 @@ public:
|
|
|
21234
21340
|
|
|
21235
21341
|
|
|
21236
21342
|
namespace duckdb {
|
|
21343
|
+
class CastFunctionSet;
|
|
21237
21344
|
class ClientContext;
|
|
21238
|
-
class TableFunctionRef;
|
|
21239
21345
|
class CompressionFunction;
|
|
21346
|
+
class TableFunctionRef;
|
|
21240
21347
|
|
|
21241
21348
|
struct CompressionFunctionSet;
|
|
21242
21349
|
struct DBConfig;
|
|
@@ -21328,6 +21435,7 @@ struct DBConfigOptions {
|
|
|
21328
21435
|
//! Whether unsigned extensions should be loaded
|
|
21329
21436
|
bool allow_unsigned_extensions = false;
|
|
21330
21437
|
};
|
|
21438
|
+
|
|
21331
21439
|
struct DBConfig {
|
|
21332
21440
|
friend class DatabaseInstance;
|
|
21333
21441
|
friend class StorageManager;
|
|
@@ -21347,9 +21455,9 @@ public:
|
|
|
21347
21455
|
unique_ptr<Allocator> allocator;
|
|
21348
21456
|
//! Database configuration options
|
|
21349
21457
|
DBConfigOptions options;
|
|
21350
|
-
|
|
21351
21458
|
//! Extensions made to the parser
|
|
21352
21459
|
vector<ParserExtension> parser_extensions;
|
|
21460
|
+
//! Extensions made to the optimizer
|
|
21353
21461
|
vector<OptimizerExtension> optimizer_extensions;
|
|
21354
21462
|
|
|
21355
21463
|
DUCKDB_API void AddExtensionOption(string name, string description, LogicalType parameter,
|
|
@@ -21377,8 +21485,11 @@ public:
|
|
|
21377
21485
|
//! Return the compression function for the specified compression type/physical type combo
|
|
21378
21486
|
DUCKDB_API CompressionFunction *GetCompressionFunction(CompressionType type, PhysicalType data_type);
|
|
21379
21487
|
|
|
21488
|
+
DUCKDB_API CastFunctionSet &GetCastFunctions();
|
|
21489
|
+
|
|
21380
21490
|
private:
|
|
21381
21491
|
unique_ptr<CompressionFunctionSet> compression_functions;
|
|
21492
|
+
unique_ptr<CastFunctionSet> cast_functions;
|
|
21382
21493
|
};
|
|
21383
21494
|
|
|
21384
21495
|
} // namespace duckdb
|
|
@@ -22416,29 +22527,14 @@ public:
|
|
|
22416
22527
|
namespace duckdb {
|
|
22417
22528
|
|
|
22418
22529
|
struct CreateScalarFunctionInfo : public CreateFunctionInfo {
|
|
22419
|
-
explicit CreateScalarFunctionInfo(ScalarFunction function)
|
|
22420
|
-
|
|
22421
|
-
name = function.name;
|
|
22422
|
-
functions.AddFunction(move(function));
|
|
22423
|
-
}
|
|
22424
|
-
explicit CreateScalarFunctionInfo(ScalarFunctionSet set)
|
|
22425
|
-
: CreateFunctionInfo(CatalogType::SCALAR_FUNCTION_ENTRY), functions(move(set)) {
|
|
22426
|
-
name = functions.name;
|
|
22427
|
-
for (auto &func : functions.functions) {
|
|
22428
|
-
func.name = functions.name;
|
|
22429
|
-
}
|
|
22430
|
-
}
|
|
22530
|
+
DUCKDB_API explicit CreateScalarFunctionInfo(ScalarFunction function);
|
|
22531
|
+
DUCKDB_API explicit CreateScalarFunctionInfo(ScalarFunctionSet set);
|
|
22431
22532
|
|
|
22432
22533
|
ScalarFunctionSet functions;
|
|
22433
22534
|
|
|
22434
22535
|
public:
|
|
22435
|
-
unique_ptr<CreateInfo> Copy() const override
|
|
22436
|
-
|
|
22437
|
-
set.functions = functions.functions;
|
|
22438
|
-
auto result = make_unique<CreateScalarFunctionInfo>(move(set));
|
|
22439
|
-
CopyProperties(*result);
|
|
22440
|
-
return move(result);
|
|
22441
|
-
}
|
|
22536
|
+
DUCKDB_API unique_ptr<CreateInfo> Copy() const override;
|
|
22537
|
+
DUCKDB_API unique_ptr<AlterInfo> GetAlterInfo() const override;
|
|
22442
22538
|
};
|
|
22443
22539
|
|
|
22444
22540
|
} // namespace duckdb
|
|
@@ -22449,12 +22545,13 @@ namespace duckdb {
|
|
|
22449
22545
|
//! A table function in the catalog
|
|
22450
22546
|
class ScalarFunctionCatalogEntry : public StandardEntry {
|
|
22451
22547
|
public:
|
|
22452
|
-
ScalarFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateScalarFunctionInfo *info)
|
|
22453
|
-
: StandardEntry(CatalogType::SCALAR_FUNCTION_ENTRY, schema, catalog, info->name), functions(info->functions) {
|
|
22454
|
-
}
|
|
22548
|
+
ScalarFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateScalarFunctionInfo *info);
|
|
22455
22549
|
|
|
22456
22550
|
//! The scalar functions
|
|
22457
22551
|
ScalarFunctionSet functions;
|
|
22552
|
+
|
|
22553
|
+
public:
|
|
22554
|
+
unique_ptr<CatalogEntry> AlterEntry(ClientContext &context, AlterInfo *info) override;
|
|
22458
22555
|
};
|
|
22459
22556
|
} // namespace duckdb
|
|
22460
22557
|
//===----------------------------------------------------------------------===//
|
|
@@ -27150,6 +27247,75 @@ private:
|
|
|
27150
27247
|
unique_ptr<StreamWrapper> stream_wrapper;
|
|
27151
27248
|
};
|
|
27152
27249
|
|
|
27250
|
+
} // namespace duckdb
|
|
27251
|
+
//===----------------------------------------------------------------------===//
|
|
27252
|
+
// DuckDB
|
|
27253
|
+
//
|
|
27254
|
+
// duckdb/parser/expression/default_expression.hpp
|
|
27255
|
+
//
|
|
27256
|
+
//
|
|
27257
|
+
//===----------------------------------------------------------------------===//
|
|
27258
|
+
|
|
27259
|
+
|
|
27260
|
+
|
|
27261
|
+
|
|
27262
|
+
|
|
27263
|
+
namespace duckdb {
|
|
27264
|
+
//! Represents the default value of a column
|
|
27265
|
+
class DefaultExpression : public ParsedExpression {
|
|
27266
|
+
public:
|
|
27267
|
+
DefaultExpression();
|
|
27268
|
+
|
|
27269
|
+
public:
|
|
27270
|
+
bool IsScalar() const override {
|
|
27271
|
+
return false;
|
|
27272
|
+
}
|
|
27273
|
+
|
|
27274
|
+
string ToString() const override;
|
|
27275
|
+
|
|
27276
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
27277
|
+
|
|
27278
|
+
void Serialize(FieldWriter &writer) const override;
|
|
27279
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27280
|
+
};
|
|
27281
|
+
} // namespace duckdb
|
|
27282
|
+
//===----------------------------------------------------------------------===//
|
|
27283
|
+
// DuckDB
|
|
27284
|
+
//
|
|
27285
|
+
// duckdb/parser/expression/parameter_expression.hpp
|
|
27286
|
+
//
|
|
27287
|
+
//
|
|
27288
|
+
//===----------------------------------------------------------------------===//
|
|
27289
|
+
|
|
27290
|
+
|
|
27291
|
+
|
|
27292
|
+
|
|
27293
|
+
|
|
27294
|
+
namespace duckdb {
|
|
27295
|
+
class ParameterExpression : public ParsedExpression {
|
|
27296
|
+
public:
|
|
27297
|
+
ParameterExpression();
|
|
27298
|
+
|
|
27299
|
+
idx_t parameter_nr;
|
|
27300
|
+
|
|
27301
|
+
public:
|
|
27302
|
+
bool IsScalar() const override {
|
|
27303
|
+
return true;
|
|
27304
|
+
}
|
|
27305
|
+
bool HasParameter() const override {
|
|
27306
|
+
return true;
|
|
27307
|
+
}
|
|
27308
|
+
|
|
27309
|
+
string ToString() const override;
|
|
27310
|
+
|
|
27311
|
+
static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
|
|
27312
|
+
|
|
27313
|
+
unique_ptr<ParsedExpression> Copy() const override;
|
|
27314
|
+
hash_t Hash() const override;
|
|
27315
|
+
|
|
27316
|
+
void Serialize(FieldWriter &writer) const override;
|
|
27317
|
+
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27318
|
+
};
|
|
27153
27319
|
} // namespace duckdb
|
|
27154
27320
|
//===----------------------------------------------------------------------===//
|
|
27155
27321
|
// DuckDB
|
|
@@ -27271,7 +27437,7 @@ public:
|
|
|
27271
27437
|
//===----------------------------------------------------------------------===//
|
|
27272
27438
|
// DuckDB
|
|
27273
27439
|
//
|
|
27274
|
-
// duckdb/parser/expression/
|
|
27440
|
+
// duckdb/parser/expression/comparison_expression.hpp
|
|
27275
27441
|
//
|
|
27276
27442
|
//
|
|
27277
27443
|
//===----------------------------------------------------------------------===//
|
|
@@ -27280,77 +27446,33 @@ public:
|
|
|
27280
27446
|
|
|
27281
27447
|
|
|
27282
27448
|
|
|
27283
|
-
|
|
27284
27449
|
namespace duckdb {
|
|
27285
|
-
|
|
27286
|
-
//!
|
|
27287
|
-
class
|
|
27450
|
+
//! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
|
|
27451
|
+
//! and has two children.
|
|
27452
|
+
class ComparisonExpression : public ParsedExpression {
|
|
27288
27453
|
public:
|
|
27289
|
-
DUCKDB_API
|
|
27454
|
+
DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
27455
|
+
unique_ptr<ParsedExpression> right);
|
|
27290
27456
|
|
|
27291
|
-
|
|
27292
|
-
|
|
27457
|
+
unique_ptr<ParsedExpression> left;
|
|
27458
|
+
unique_ptr<ParsedExpression> right;
|
|
27293
27459
|
|
|
27294
27460
|
public:
|
|
27295
27461
|
string ToString() const override;
|
|
27296
27462
|
|
|
27297
|
-
static bool Equals(const
|
|
27298
|
-
hash_t Hash() const override;
|
|
27463
|
+
static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
|
|
27299
27464
|
|
|
27300
27465
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27301
27466
|
|
|
27302
27467
|
void Serialize(FieldWriter &writer) const override;
|
|
27303
27468
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27304
|
-
};
|
|
27305
|
-
|
|
27306
|
-
} // namespace duckdb
|
|
27307
|
-
//===----------------------------------------------------------------------===//
|
|
27308
|
-
// DuckDB
|
|
27309
|
-
//
|
|
27310
|
-
// duckdb/parser/expression/subquery_expression.hpp
|
|
27311
|
-
//
|
|
27312
|
-
//
|
|
27313
|
-
//===----------------------------------------------------------------------===//
|
|
27314
|
-
|
|
27315
|
-
|
|
27316
|
-
|
|
27317
|
-
|
|
27318
|
-
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
namespace duckdb {
|
|
27322
|
-
|
|
27323
|
-
//! Represents a subquery
|
|
27324
|
-
class SubqueryExpression : public ParsedExpression {
|
|
27325
|
-
public:
|
|
27326
|
-
SubqueryExpression();
|
|
27327
|
-
|
|
27328
|
-
//! The actual subquery
|
|
27329
|
-
unique_ptr<SelectStatement> subquery;
|
|
27330
|
-
//! The subquery type
|
|
27331
|
-
SubqueryType subquery_type;
|
|
27332
|
-
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
27333
|
-
//! subquery)
|
|
27334
|
-
unique_ptr<ParsedExpression> child;
|
|
27335
|
-
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
27336
|
-
ExpressionType comparison_type;
|
|
27337
27469
|
|
|
27338
27470
|
public:
|
|
27339
|
-
|
|
27340
|
-
|
|
27341
|
-
|
|
27342
|
-
|
|
27343
|
-
return false;
|
|
27471
|
+
template <class T, class BASE>
|
|
27472
|
+
static string ToString(const T &entry) {
|
|
27473
|
+
return StringUtil::Format("(%s) %s (%s)", entry.left->ToString(), ExpressionTypeToOperator(entry.type),
|
|
27474
|
+
entry.right->ToString());
|
|
27344
27475
|
}
|
|
27345
|
-
|
|
27346
|
-
string ToString() const override;
|
|
27347
|
-
|
|
27348
|
-
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
27349
|
-
|
|
27350
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
27351
|
-
|
|
27352
|
-
void Serialize(FieldWriter &writer) const override;
|
|
27353
|
-
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27354
27476
|
};
|
|
27355
27477
|
} // namespace duckdb
|
|
27356
27478
|
//===----------------------------------------------------------------------===//
|
|
@@ -27394,7 +27516,7 @@ public:
|
|
|
27394
27516
|
//===----------------------------------------------------------------------===//
|
|
27395
27517
|
// DuckDB
|
|
27396
27518
|
//
|
|
27397
|
-
// duckdb/parser/expression/
|
|
27519
|
+
// duckdb/parser/expression/operator_expression.hpp
|
|
27398
27520
|
//
|
|
27399
27521
|
//
|
|
27400
27522
|
//===----------------------------------------------------------------------===//
|
|
@@ -27403,21 +27525,23 @@ public:
|
|
|
27403
27525
|
|
|
27404
27526
|
|
|
27405
27527
|
|
|
27406
|
-
namespace duckdb {
|
|
27407
27528
|
|
|
27408
|
-
|
|
27529
|
+
|
|
27530
|
+
|
|
27531
|
+
namespace duckdb {
|
|
27532
|
+
//! Represents a built-in operator expression
|
|
27533
|
+
class OperatorExpression : public ParsedExpression {
|
|
27409
27534
|
public:
|
|
27410
|
-
DUCKDB_API
|
|
27411
|
-
|
|
27535
|
+
DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
|
|
27536
|
+
unique_ptr<ParsedExpression> right = nullptr);
|
|
27537
|
+
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
27412
27538
|
|
|
27413
|
-
unique_ptr<ParsedExpression
|
|
27414
|
-
unique_ptr<ParsedExpression> lower;
|
|
27415
|
-
unique_ptr<ParsedExpression> upper;
|
|
27539
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
27416
27540
|
|
|
27417
27541
|
public:
|
|
27418
27542
|
string ToString() const override;
|
|
27419
27543
|
|
|
27420
|
-
static bool Equals(const
|
|
27544
|
+
static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
|
|
27421
27545
|
|
|
27422
27546
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27423
27547
|
|
|
@@ -27427,16 +27551,82 @@ public:
|
|
|
27427
27551
|
public:
|
|
27428
27552
|
template <class T, class BASE>
|
|
27429
27553
|
static string ToString(const T &entry) {
|
|
27430
|
-
|
|
27431
|
-
|
|
27554
|
+
auto op = ExpressionTypeToOperator(entry.type);
|
|
27555
|
+
if (!op.empty()) {
|
|
27556
|
+
// use the operator string to represent the operator
|
|
27557
|
+
D_ASSERT(entry.children.size() == 2);
|
|
27558
|
+
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
27559
|
+
}
|
|
27560
|
+
switch (entry.type) {
|
|
27561
|
+
case ExpressionType::COMPARE_IN:
|
|
27562
|
+
case ExpressionType::COMPARE_NOT_IN: {
|
|
27563
|
+
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
27564
|
+
string in_child = entry.children[0]->ToString();
|
|
27565
|
+
string child_list = "(";
|
|
27566
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
27567
|
+
if (i > 1) {
|
|
27568
|
+
child_list += ", ";
|
|
27569
|
+
}
|
|
27570
|
+
child_list += entry.children[i]->ToString();
|
|
27571
|
+
}
|
|
27572
|
+
child_list += ")";
|
|
27573
|
+
return "(" + in_child + op_type + child_list + ")";
|
|
27574
|
+
}
|
|
27575
|
+
case ExpressionType::OPERATOR_NOT: {
|
|
27576
|
+
string result = "(";
|
|
27577
|
+
result += ExpressionTypeToString(entry.type);
|
|
27578
|
+
result += " ";
|
|
27579
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
27580
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
27581
|
+
result += ")";
|
|
27582
|
+
return result;
|
|
27583
|
+
}
|
|
27584
|
+
case ExpressionType::GROUPING_FUNCTION:
|
|
27585
|
+
case ExpressionType::OPERATOR_COALESCE: {
|
|
27586
|
+
string result = ExpressionTypeToString(entry.type);
|
|
27587
|
+
result += "(";
|
|
27588
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
27589
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
27590
|
+
result += ")";
|
|
27591
|
+
return result;
|
|
27592
|
+
}
|
|
27593
|
+
case ExpressionType::OPERATOR_IS_NULL:
|
|
27594
|
+
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
27595
|
+
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
27596
|
+
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
27597
|
+
case ExpressionType::ARRAY_EXTRACT:
|
|
27598
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
27599
|
+
case ExpressionType::ARRAY_SLICE:
|
|
27600
|
+
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
27601
|
+
entry.children[2]->ToString() + "]";
|
|
27602
|
+
case ExpressionType::STRUCT_EXTRACT: {
|
|
27603
|
+
if (entry.children[1]->type != ExpressionType::VALUE_CONSTANT) {
|
|
27604
|
+
return string();
|
|
27605
|
+
}
|
|
27606
|
+
auto child_string = entry.children[1]->ToString();
|
|
27607
|
+
D_ASSERT(child_string.size() >= 3);
|
|
27608
|
+
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
27609
|
+
return "(" + entry.children[0]->ToString() + ")." +
|
|
27610
|
+
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
27611
|
+
}
|
|
27612
|
+
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
27613
|
+
string result = "(ARRAY[";
|
|
27614
|
+
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
27615
|
+
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
27616
|
+
result += "])";
|
|
27617
|
+
return result;
|
|
27618
|
+
}
|
|
27619
|
+
default:
|
|
27620
|
+
throw InternalException("Unrecognized operator type");
|
|
27621
|
+
}
|
|
27622
|
+
}
|
|
27432
27623
|
};
|
|
27433
|
-
} // namespace duckdb
|
|
27434
|
-
|
|
27435
27624
|
|
|
27625
|
+
} // namespace duckdb
|
|
27436
27626
|
//===----------------------------------------------------------------------===//
|
|
27437
27627
|
// DuckDB
|
|
27438
27628
|
//
|
|
27439
|
-
// duckdb/parser/expression/
|
|
27629
|
+
// duckdb/parser/expression/positional_reference_expression.hpp
|
|
27440
27630
|
//
|
|
27441
27631
|
//
|
|
27442
27632
|
//===----------------------------------------------------------------------===//
|
|
@@ -27445,51 +27635,32 @@ public:
|
|
|
27445
27635
|
|
|
27446
27636
|
|
|
27447
27637
|
|
|
27448
|
-
|
|
27449
27638
|
namespace duckdb {
|
|
27450
|
-
|
|
27451
|
-
struct CaseCheck {
|
|
27452
|
-
unique_ptr<ParsedExpression> when_expr;
|
|
27453
|
-
unique_ptr<ParsedExpression> then_expr;
|
|
27454
|
-
};
|
|
27455
|
-
|
|
27456
|
-
//! The CaseExpression represents a CASE expression in the query
|
|
27457
|
-
class CaseExpression : public ParsedExpression {
|
|
27639
|
+
class PositionalReferenceExpression : public ParsedExpression {
|
|
27458
27640
|
public:
|
|
27459
|
-
DUCKDB_API
|
|
27641
|
+
DUCKDB_API PositionalReferenceExpression(idx_t index);
|
|
27460
27642
|
|
|
27461
|
-
|
|
27462
|
-
unique_ptr<ParsedExpression> else_expr;
|
|
27643
|
+
idx_t index;
|
|
27463
27644
|
|
|
27464
27645
|
public:
|
|
27465
|
-
|
|
27646
|
+
bool IsScalar() const override {
|
|
27647
|
+
return false;
|
|
27648
|
+
}
|
|
27466
27649
|
|
|
27467
|
-
|
|
27650
|
+
string ToString() const override;
|
|
27468
27651
|
|
|
27652
|
+
static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
|
|
27469
27653
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27654
|
+
hash_t Hash() const override;
|
|
27470
27655
|
|
|
27471
27656
|
void Serialize(FieldWriter &writer) const override;
|
|
27472
27657
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27473
|
-
|
|
27474
|
-
public:
|
|
27475
|
-
template <class T, class BASE>
|
|
27476
|
-
static string ToString(const T &entry) {
|
|
27477
|
-
string case_str = "CASE ";
|
|
27478
|
-
for (auto &check : entry.case_checks) {
|
|
27479
|
-
case_str += " WHEN (" + check.when_expr->ToString() + ")";
|
|
27480
|
-
case_str += " THEN (" + check.then_expr->ToString() + ")";
|
|
27481
|
-
}
|
|
27482
|
-
case_str += " ELSE " + entry.else_expr->ToString();
|
|
27483
|
-
case_str += " END";
|
|
27484
|
-
return case_str;
|
|
27485
|
-
}
|
|
27486
27658
|
};
|
|
27487
27659
|
} // namespace duckdb
|
|
27488
|
-
|
|
27489
27660
|
//===----------------------------------------------------------------------===//
|
|
27490
27661
|
// DuckDB
|
|
27491
27662
|
//
|
|
27492
|
-
// duckdb/parser/expression/
|
|
27663
|
+
// duckdb/parser/expression/conjunction_expression.hpp
|
|
27493
27664
|
//
|
|
27494
27665
|
//
|
|
27495
27666
|
//===----------------------------------------------------------------------===//
|
|
@@ -27501,22 +27672,22 @@ public:
|
|
|
27501
27672
|
|
|
27502
27673
|
namespace duckdb {
|
|
27503
27674
|
|
|
27504
|
-
//!
|
|
27505
|
-
class
|
|
27675
|
+
//! Represents a conjunction (AND/OR)
|
|
27676
|
+
class ConjunctionExpression : public ParsedExpression {
|
|
27506
27677
|
public:
|
|
27507
|
-
DUCKDB_API
|
|
27678
|
+
DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
|
|
27679
|
+
DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
27680
|
+
DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
27681
|
+
unique_ptr<ParsedExpression> right);
|
|
27508
27682
|
|
|
27509
|
-
|
|
27510
|
-
unique_ptr<ParsedExpression> child;
|
|
27511
|
-
//! The type to cast to
|
|
27512
|
-
LogicalType cast_type;
|
|
27513
|
-
//! Whether or not this is a try_cast expression
|
|
27514
|
-
bool try_cast;
|
|
27683
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
27515
27684
|
|
|
27516
27685
|
public:
|
|
27686
|
+
void AddExpression(unique_ptr<ParsedExpression> expr);
|
|
27687
|
+
|
|
27517
27688
|
string ToString() const override;
|
|
27518
27689
|
|
|
27519
|
-
static bool Equals(const
|
|
27690
|
+
static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
|
|
27520
27691
|
|
|
27521
27692
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27522
27693
|
|
|
@@ -27526,16 +27697,18 @@ public:
|
|
|
27526
27697
|
public:
|
|
27527
27698
|
template <class T, class BASE>
|
|
27528
27699
|
static string ToString(const T &entry) {
|
|
27529
|
-
|
|
27530
|
-
|
|
27700
|
+
string result = "(" + entry.children[0]->ToString();
|
|
27701
|
+
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
27702
|
+
result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
|
|
27703
|
+
}
|
|
27704
|
+
return result + ")";
|
|
27531
27705
|
}
|
|
27532
27706
|
};
|
|
27533
27707
|
} // namespace duckdb
|
|
27534
|
-
|
|
27535
27708
|
//===----------------------------------------------------------------------===//
|
|
27536
27709
|
// DuckDB
|
|
27537
27710
|
//
|
|
27538
|
-
// duckdb/parser/expression/
|
|
27711
|
+
// duckdb/parser/expression/between_expression.hpp
|
|
27539
27712
|
//
|
|
27540
27713
|
//
|
|
27541
27714
|
//===----------------------------------------------------------------------===//
|
|
@@ -27546,33 +27719,36 @@ public:
|
|
|
27546
27719
|
|
|
27547
27720
|
namespace duckdb {
|
|
27548
27721
|
|
|
27549
|
-
|
|
27550
|
-
class CollateExpression : public ParsedExpression {
|
|
27722
|
+
class BetweenExpression : public ParsedExpression {
|
|
27551
27723
|
public:
|
|
27552
|
-
|
|
27724
|
+
DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
|
|
27725
|
+
unique_ptr<ParsedExpression> upper);
|
|
27553
27726
|
|
|
27554
|
-
|
|
27555
|
-
unique_ptr<ParsedExpression>
|
|
27556
|
-
|
|
27557
|
-
string collation;
|
|
27727
|
+
unique_ptr<ParsedExpression> input;
|
|
27728
|
+
unique_ptr<ParsedExpression> lower;
|
|
27729
|
+
unique_ptr<ParsedExpression> upper;
|
|
27558
27730
|
|
|
27559
27731
|
public:
|
|
27560
27732
|
string ToString() const override;
|
|
27561
27733
|
|
|
27562
|
-
static bool Equals(const
|
|
27734
|
+
static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
|
|
27563
27735
|
|
|
27564
27736
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27565
27737
|
|
|
27566
27738
|
void Serialize(FieldWriter &writer) const override;
|
|
27567
27739
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27740
|
+
|
|
27741
|
+
public:
|
|
27742
|
+
template <class T, class BASE>
|
|
27743
|
+
static string ToString(const T &entry) {
|
|
27744
|
+
return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
|
|
27745
|
+
}
|
|
27568
27746
|
};
|
|
27569
27747
|
} // namespace duckdb
|
|
27570
|
-
|
|
27571
|
-
|
|
27572
27748
|
//===----------------------------------------------------------------------===//
|
|
27573
27749
|
// DuckDB
|
|
27574
27750
|
//
|
|
27575
|
-
// duckdb/parser/expression/
|
|
27751
|
+
// duckdb/parser/expression/cast_expression.hpp
|
|
27576
27752
|
//
|
|
27577
27753
|
//
|
|
27578
27754
|
//===----------------------------------------------------------------------===//
|
|
@@ -27581,21 +27757,25 @@ public:
|
|
|
27581
27757
|
|
|
27582
27758
|
|
|
27583
27759
|
|
|
27760
|
+
|
|
27584
27761
|
namespace duckdb {
|
|
27585
|
-
|
|
27586
|
-
//!
|
|
27587
|
-
class
|
|
27762
|
+
|
|
27763
|
+
//! CastExpression represents a type cast from one SQL type to another SQL type
|
|
27764
|
+
class CastExpression : public ParsedExpression {
|
|
27588
27765
|
public:
|
|
27589
|
-
DUCKDB_API
|
|
27590
|
-
unique_ptr<ParsedExpression> right);
|
|
27766
|
+
DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
|
|
27591
27767
|
|
|
27592
|
-
|
|
27593
|
-
unique_ptr<ParsedExpression>
|
|
27768
|
+
//! The child of the cast expression
|
|
27769
|
+
unique_ptr<ParsedExpression> child;
|
|
27770
|
+
//! The type to cast to
|
|
27771
|
+
LogicalType cast_type;
|
|
27772
|
+
//! Whether or not this is a try_cast expression
|
|
27773
|
+
bool try_cast;
|
|
27594
27774
|
|
|
27595
27775
|
public:
|
|
27596
27776
|
string ToString() const override;
|
|
27597
27777
|
|
|
27598
|
-
static bool Equals(const
|
|
27778
|
+
static bool Equals(const CastExpression *a, const CastExpression *b);
|
|
27599
27779
|
|
|
27600
27780
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27601
27781
|
|
|
@@ -27605,16 +27785,17 @@ public:
|
|
|
27605
27785
|
public:
|
|
27606
27786
|
template <class T, class BASE>
|
|
27607
27787
|
static string ToString(const T &entry) {
|
|
27608
|
-
return
|
|
27609
|
-
|
|
27788
|
+
return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
|
|
27789
|
+
entry.cast_type.ToString() + ")";
|
|
27610
27790
|
}
|
|
27611
27791
|
};
|
|
27612
27792
|
} // namespace duckdb
|
|
27613
27793
|
|
|
27794
|
+
|
|
27614
27795
|
//===----------------------------------------------------------------------===//
|
|
27615
27796
|
// DuckDB
|
|
27616
27797
|
//
|
|
27617
|
-
// duckdb/parser/expression/
|
|
27798
|
+
// duckdb/parser/expression/case_expression.hpp
|
|
27618
27799
|
//
|
|
27619
27800
|
//
|
|
27620
27801
|
//===----------------------------------------------------------------------===//
|
|
@@ -27626,22 +27807,23 @@ public:
|
|
|
27626
27807
|
|
|
27627
27808
|
namespace duckdb {
|
|
27628
27809
|
|
|
27629
|
-
|
|
27630
|
-
|
|
27810
|
+
struct CaseCheck {
|
|
27811
|
+
unique_ptr<ParsedExpression> when_expr;
|
|
27812
|
+
unique_ptr<ParsedExpression> then_expr;
|
|
27813
|
+
};
|
|
27814
|
+
|
|
27815
|
+
//! The CaseExpression represents a CASE expression in the query
|
|
27816
|
+
class CaseExpression : public ParsedExpression {
|
|
27631
27817
|
public:
|
|
27632
|
-
DUCKDB_API
|
|
27633
|
-
DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
27634
|
-
DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
|
27635
|
-
unique_ptr<ParsedExpression> right);
|
|
27818
|
+
DUCKDB_API CaseExpression();
|
|
27636
27819
|
|
|
27637
|
-
vector<
|
|
27820
|
+
vector<CaseCheck> case_checks;
|
|
27821
|
+
unique_ptr<ParsedExpression> else_expr;
|
|
27638
27822
|
|
|
27639
27823
|
public:
|
|
27640
|
-
void AddExpression(unique_ptr<ParsedExpression> expr);
|
|
27641
|
-
|
|
27642
27824
|
string ToString() const override;
|
|
27643
27825
|
|
|
27644
|
-
static bool Equals(const
|
|
27826
|
+
static bool Equals(const CaseExpression *a, const CaseExpression *b);
|
|
27645
27827
|
|
|
27646
27828
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27647
27829
|
|
|
@@ -27651,11 +27833,14 @@ public:
|
|
|
27651
27833
|
public:
|
|
27652
27834
|
template <class T, class BASE>
|
|
27653
27835
|
static string ToString(const T &entry) {
|
|
27654
|
-
string
|
|
27655
|
-
for (
|
|
27656
|
-
|
|
27836
|
+
string case_str = "CASE ";
|
|
27837
|
+
for (auto &check : entry.case_checks) {
|
|
27838
|
+
case_str += " WHEN (" + check.when_expr->ToString() + ")";
|
|
27839
|
+
case_str += " THEN (" + check.then_expr->ToString() + ")";
|
|
27657
27840
|
}
|
|
27658
|
-
|
|
27841
|
+
case_str += " ELSE " + entry.else_expr->ToString();
|
|
27842
|
+
case_str += " END";
|
|
27843
|
+
return case_str;
|
|
27659
27844
|
}
|
|
27660
27845
|
};
|
|
27661
27846
|
} // namespace duckdb
|
|
@@ -27664,7 +27849,7 @@ public:
|
|
|
27664
27849
|
//===----------------------------------------------------------------------===//
|
|
27665
27850
|
// DuckDB
|
|
27666
27851
|
//
|
|
27667
|
-
// duckdb/parser/expression/
|
|
27852
|
+
// duckdb/parser/expression/collate_expression.hpp
|
|
27668
27853
|
//
|
|
27669
27854
|
//
|
|
27670
27855
|
//===----------------------------------------------------------------------===//
|
|
@@ -27674,18 +27859,22 @@ public:
|
|
|
27674
27859
|
|
|
27675
27860
|
|
|
27676
27861
|
namespace duckdb {
|
|
27677
|
-
//! Represents the default value of a column
|
|
27678
|
-
class DefaultExpression : public ParsedExpression {
|
|
27679
|
-
public:
|
|
27680
|
-
DefaultExpression();
|
|
27681
27862
|
|
|
27863
|
+
//! CollateExpression represents a COLLATE statement
|
|
27864
|
+
class CollateExpression : public ParsedExpression {
|
|
27682
27865
|
public:
|
|
27683
|
-
|
|
27684
|
-
|
|
27685
|
-
|
|
27866
|
+
CollateExpression(string collation, unique_ptr<ParsedExpression> child);
|
|
27867
|
+
|
|
27868
|
+
//! The child of the cast expression
|
|
27869
|
+
unique_ptr<ParsedExpression> child;
|
|
27870
|
+
//! The collation clause
|
|
27871
|
+
string collation;
|
|
27686
27872
|
|
|
27873
|
+
public:
|
|
27687
27874
|
string ToString() const override;
|
|
27688
27875
|
|
|
27876
|
+
static bool Equals(const CollateExpression *a, const CollateExpression *b);
|
|
27877
|
+
|
|
27689
27878
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27690
27879
|
|
|
27691
27880
|
void Serialize(FieldWriter &writer) const override;
|
|
@@ -27695,10 +27884,11 @@ public:
|
|
|
27695
27884
|
|
|
27696
27885
|
|
|
27697
27886
|
|
|
27887
|
+
|
|
27698
27888
|
//===----------------------------------------------------------------------===//
|
|
27699
27889
|
// DuckDB
|
|
27700
27890
|
//
|
|
27701
|
-
// duckdb/parser/expression/
|
|
27891
|
+
// duckdb/parser/expression/constant_expression.hpp
|
|
27702
27892
|
//
|
|
27703
27893
|
//
|
|
27704
27894
|
//===----------------------------------------------------------------------===//
|
|
@@ -27708,108 +27898,41 @@ public:
|
|
|
27708
27898
|
|
|
27709
27899
|
|
|
27710
27900
|
|
|
27901
|
+
namespace duckdb {
|
|
27711
27902
|
|
|
27903
|
+
//! ConstantExpression represents a constant value in the query
|
|
27904
|
+
class ConstantExpression : public ParsedExpression {
|
|
27905
|
+
public:
|
|
27906
|
+
DUCKDB_API explicit ConstantExpression(Value val);
|
|
27712
27907
|
|
|
27713
|
-
|
|
27714
|
-
|
|
27715
|
-
class OperatorExpression : public ParsedExpression {
|
|
27716
|
-
public:
|
|
27717
|
-
DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
|
|
27718
|
-
unique_ptr<ParsedExpression> right = nullptr);
|
|
27719
|
-
DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
|
|
27720
|
-
|
|
27721
|
-
vector<unique_ptr<ParsedExpression>> children;
|
|
27908
|
+
//! The constant value referenced
|
|
27909
|
+
Value value;
|
|
27722
27910
|
|
|
27723
27911
|
public:
|
|
27724
27912
|
string ToString() const override;
|
|
27725
27913
|
|
|
27726
|
-
static bool Equals(const
|
|
27914
|
+
static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
|
|
27915
|
+
hash_t Hash() const override;
|
|
27727
27916
|
|
|
27728
27917
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27729
27918
|
|
|
27730
27919
|
void Serialize(FieldWriter &writer) const override;
|
|
27731
27920
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27732
|
-
|
|
27733
|
-
public:
|
|
27734
|
-
template <class T, class BASE>
|
|
27735
|
-
static string ToString(const T &entry) {
|
|
27736
|
-
auto op = ExpressionTypeToOperator(entry.type);
|
|
27737
|
-
if (!op.empty()) {
|
|
27738
|
-
// use the operator string to represent the operator
|
|
27739
|
-
D_ASSERT(entry.children.size() == 2);
|
|
27740
|
-
return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
|
|
27741
|
-
}
|
|
27742
|
-
switch (entry.type) {
|
|
27743
|
-
case ExpressionType::COMPARE_IN:
|
|
27744
|
-
case ExpressionType::COMPARE_NOT_IN: {
|
|
27745
|
-
string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
|
|
27746
|
-
string in_child = entry.children[0]->ToString();
|
|
27747
|
-
string child_list = "(";
|
|
27748
|
-
for (idx_t i = 1; i < entry.children.size(); i++) {
|
|
27749
|
-
if (i > 1) {
|
|
27750
|
-
child_list += ", ";
|
|
27751
|
-
}
|
|
27752
|
-
child_list += entry.children[i]->ToString();
|
|
27753
|
-
}
|
|
27754
|
-
child_list += ")";
|
|
27755
|
-
return "(" + in_child + op_type + child_list + ")";
|
|
27756
|
-
}
|
|
27757
|
-
case ExpressionType::OPERATOR_NOT: {
|
|
27758
|
-
string result = "(";
|
|
27759
|
-
result += ExpressionTypeToString(entry.type);
|
|
27760
|
-
result += " ";
|
|
27761
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
27762
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
27763
|
-
result += ")";
|
|
27764
|
-
return result;
|
|
27765
|
-
}
|
|
27766
|
-
case ExpressionType::GROUPING_FUNCTION:
|
|
27767
|
-
case ExpressionType::OPERATOR_COALESCE: {
|
|
27768
|
-
string result = ExpressionTypeToString(entry.type);
|
|
27769
|
-
result += "(";
|
|
27770
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
27771
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
27772
|
-
result += ")";
|
|
27773
|
-
return result;
|
|
27774
|
-
}
|
|
27775
|
-
case ExpressionType::OPERATOR_IS_NULL:
|
|
27776
|
-
return "(" + entry.children[0]->ToString() + " IS NULL)";
|
|
27777
|
-
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
|
27778
|
-
return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
|
|
27779
|
-
case ExpressionType::ARRAY_EXTRACT:
|
|
27780
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
|
|
27781
|
-
case ExpressionType::ARRAY_SLICE:
|
|
27782
|
-
return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
|
|
27783
|
-
entry.children[2]->ToString() + "]";
|
|
27784
|
-
case ExpressionType::STRUCT_EXTRACT: {
|
|
27785
|
-
if (entry.children[1]->type != ExpressionType::VALUE_CONSTANT) {
|
|
27786
|
-
return string();
|
|
27787
|
-
}
|
|
27788
|
-
auto child_string = entry.children[1]->ToString();
|
|
27789
|
-
D_ASSERT(child_string.size() >= 3);
|
|
27790
|
-
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
|
27791
|
-
return "(" + entry.children[0]->ToString() + ")." +
|
|
27792
|
-
KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
|
|
27793
|
-
}
|
|
27794
|
-
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
|
27795
|
-
string result = "(ARRAY[";
|
|
27796
|
-
result += StringUtil::Join(entry.children, entry.children.size(), ", ",
|
|
27797
|
-
[](const unique_ptr<BASE> &child) { return child->ToString(); });
|
|
27798
|
-
result += "])";
|
|
27799
|
-
return result;
|
|
27800
|
-
}
|
|
27801
|
-
default:
|
|
27802
|
-
throw InternalException("Unrecognized operator type");
|
|
27803
|
-
}
|
|
27804
|
-
}
|
|
27805
27921
|
};
|
|
27806
27922
|
|
|
27807
27923
|
} // namespace duckdb
|
|
27808
27924
|
|
|
27925
|
+
|
|
27926
|
+
|
|
27927
|
+
|
|
27928
|
+
|
|
27929
|
+
|
|
27930
|
+
|
|
27931
|
+
|
|
27809
27932
|
//===----------------------------------------------------------------------===//
|
|
27810
27933
|
// DuckDB
|
|
27811
27934
|
//
|
|
27812
|
-
// duckdb/parser/expression/
|
|
27935
|
+
// duckdb/parser/expression/subquery_expression.hpp
|
|
27813
27936
|
//
|
|
27814
27937
|
//
|
|
27815
27938
|
//===----------------------------------------------------------------------===//
|
|
@@ -27818,37 +27941,49 @@ public:
|
|
|
27818
27941
|
|
|
27819
27942
|
|
|
27820
27943
|
|
|
27944
|
+
|
|
27945
|
+
|
|
27821
27946
|
namespace duckdb {
|
|
27822
|
-
|
|
27947
|
+
|
|
27948
|
+
//! Represents a subquery
|
|
27949
|
+
class SubqueryExpression : public ParsedExpression {
|
|
27823
27950
|
public:
|
|
27824
|
-
|
|
27951
|
+
SubqueryExpression();
|
|
27825
27952
|
|
|
27826
|
-
|
|
27953
|
+
//! The actual subquery
|
|
27954
|
+
unique_ptr<SelectStatement> subquery;
|
|
27955
|
+
//! The subquery type
|
|
27956
|
+
SubqueryType subquery_type;
|
|
27957
|
+
//! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
|
|
27958
|
+
//! subquery)
|
|
27959
|
+
unique_ptr<ParsedExpression> child;
|
|
27960
|
+
//! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
|
|
27961
|
+
ExpressionType comparison_type;
|
|
27827
27962
|
|
|
27828
27963
|
public:
|
|
27829
|
-
bool
|
|
27964
|
+
bool HasSubquery() const override {
|
|
27830
27965
|
return true;
|
|
27831
27966
|
}
|
|
27832
|
-
bool
|
|
27833
|
-
return
|
|
27967
|
+
bool IsScalar() const override {
|
|
27968
|
+
return false;
|
|
27834
27969
|
}
|
|
27835
27970
|
|
|
27836
27971
|
string ToString() const override;
|
|
27837
27972
|
|
|
27838
|
-
static bool Equals(const
|
|
27973
|
+
static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
27839
27974
|
|
|
27840
27975
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
27841
|
-
hash_t Hash() const override;
|
|
27842
27976
|
|
|
27843
27977
|
void Serialize(FieldWriter &writer) const override;
|
|
27844
27978
|
static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
|
|
27845
27979
|
};
|
|
27846
27980
|
} // namespace duckdb
|
|
27847
27981
|
|
|
27982
|
+
|
|
27848
27983
|
//===----------------------------------------------------------------------===//
|
|
27849
27984
|
// DuckDB
|
|
27850
27985
|
//
|
|
27851
|
-
// duckdb/parser/
|
|
27986
|
+
// duckdb/parser/parsed_data/export_table_data.hpp
|
|
27852
27987
|
//
|
|
27853
27988
|
//
|
|
27854
27989
|
//===----------------------------------------------------------------------===//
|
|
@@ -27857,36 +27992,145 @@ public:
|
|
|
27857
27992
|
|
|
27858
27993
|
|
|
27859
27994
|
|
|
27995
|
+
|
|
27860
27996
|
namespace duckdb {
|
|
27861
|
-
class
|
|
27862
|
-
|
|
27863
|
-
|
|
27997
|
+
class TableCatalogEntry;
|
|
27998
|
+
|
|
27999
|
+
struct ExportedTableData {
|
|
28000
|
+
//! Name of the exported table
|
|
28001
|
+
string table_name;
|
|
28002
|
+
|
|
28003
|
+
//! Name of the schema
|
|
28004
|
+
string schema_name;
|
|
28005
|
+
|
|
28006
|
+
//! Path to be exported
|
|
28007
|
+
string file_path;
|
|
28008
|
+
};
|
|
28009
|
+
|
|
28010
|
+
struct ExportedTableInfo {
|
|
28011
|
+
TableCatalogEntry *entry;
|
|
28012
|
+
ExportedTableData table_data;
|
|
28013
|
+
};
|
|
28014
|
+
|
|
28015
|
+
struct BoundExportData : public ParseInfo {
|
|
28016
|
+
std::vector<ExportedTableInfo> data;
|
|
28017
|
+
};
|
|
28018
|
+
|
|
28019
|
+
} // namespace duckdb
|
|
28020
|
+
//===----------------------------------------------------------------------===//
|
|
28021
|
+
// DuckDB
|
|
28022
|
+
//
|
|
28023
|
+
// duckdb/parser/parsed_data/transaction_info.hpp
|
|
28024
|
+
//
|
|
28025
|
+
//
|
|
28026
|
+
//===----------------------------------------------------------------------===//
|
|
28027
|
+
|
|
28028
|
+
|
|
28029
|
+
|
|
28030
|
+
|
|
28031
|
+
|
|
28032
|
+
namespace duckdb {
|
|
28033
|
+
|
|
28034
|
+
enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
|
|
28035
|
+
|
|
28036
|
+
struct TransactionInfo : public ParseInfo {
|
|
28037
|
+
explicit TransactionInfo(TransactionType type) : type(type) {
|
|
28038
|
+
}
|
|
28039
|
+
|
|
28040
|
+
//! The type of transaction statement
|
|
28041
|
+
TransactionType type;
|
|
28042
|
+
};
|
|
28043
|
+
|
|
28044
|
+
} // namespace duckdb
|
|
28045
|
+
//===----------------------------------------------------------------------===//
|
|
28046
|
+
// DuckDB
|
|
28047
|
+
//
|
|
28048
|
+
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
28049
|
+
//
|
|
28050
|
+
//
|
|
28051
|
+
//===----------------------------------------------------------------------===//
|
|
28052
|
+
|
|
28053
|
+
|
|
28054
|
+
|
|
28055
|
+
|
|
28056
|
+
|
|
28057
|
+
|
|
28058
|
+
//===----------------------------------------------------------------------===//
|
|
28059
|
+
// DuckDB
|
|
28060
|
+
//
|
|
28061
|
+
// duckdb/parser/tableref/basetableref.hpp
|
|
28062
|
+
//
|
|
28063
|
+
//
|
|
28064
|
+
//===----------------------------------------------------------------------===//
|
|
28065
|
+
|
|
28066
|
+
|
|
27864
28067
|
|
|
27865
|
-
idx_t index;
|
|
27866
28068
|
|
|
28069
|
+
|
|
28070
|
+
|
|
28071
|
+
namespace duckdb {
|
|
28072
|
+
//! Represents a TableReference to a base table in the schema
|
|
28073
|
+
class BaseTableRef : public TableRef {
|
|
27867
28074
|
public:
|
|
27868
|
-
|
|
27869
|
-
return false;
|
|
28075
|
+
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
27870
28076
|
}
|
|
27871
28077
|
|
|
28078
|
+
//! Schema name
|
|
28079
|
+
string schema_name;
|
|
28080
|
+
//! Table name
|
|
28081
|
+
string table_name;
|
|
28082
|
+
//! Aliases for the column names
|
|
28083
|
+
vector<string> column_name_alias;
|
|
28084
|
+
|
|
28085
|
+
public:
|
|
27872
28086
|
string ToString() const override;
|
|
28087
|
+
bool Equals(const TableRef *other_p) const override;
|
|
27873
28088
|
|
|
27874
|
-
|
|
27875
|
-
unique_ptr<ParsedExpression> Copy() const override;
|
|
27876
|
-
hash_t Hash() const override;
|
|
28089
|
+
unique_ptr<TableRef> Copy() override;
|
|
27877
28090
|
|
|
27878
|
-
|
|
27879
|
-
|
|
28091
|
+
//! Serializes a blob into a BaseTableRef
|
|
28092
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
28093
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
28094
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
27880
28095
|
};
|
|
27881
28096
|
} // namespace duckdb
|
|
27882
28097
|
|
|
27883
28098
|
|
|
27884
28099
|
|
|
28100
|
+
namespace duckdb {
|
|
28101
|
+
|
|
28102
|
+
struct CreateIndexInfo : public CreateInfo {
|
|
28103
|
+
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
28104
|
+
}
|
|
28105
|
+
|
|
28106
|
+
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
28107
|
+
IndexType index_type;
|
|
28108
|
+
//! Name of the Index
|
|
28109
|
+
string index_name;
|
|
28110
|
+
//! Index Constraint Type
|
|
28111
|
+
IndexConstraintType constraint_type;
|
|
28112
|
+
//! The table to create the index on
|
|
28113
|
+
unique_ptr<BaseTableRef> table;
|
|
28114
|
+
//! Set of expressions to index by
|
|
28115
|
+
vector<unique_ptr<ParsedExpression>> expressions;
|
|
28116
|
+
vector<unique_ptr<ParsedExpression>> parsed_expressions;
|
|
28117
|
+
|
|
28118
|
+
vector<idx_t> column_ids;
|
|
28119
|
+
|
|
28120
|
+
protected:
|
|
28121
|
+
void SerializeInternal(Serializer &serializer) const override;
|
|
28122
|
+
|
|
28123
|
+
public:
|
|
28124
|
+
unique_ptr<CreateInfo> Copy() const override;
|
|
28125
|
+
|
|
28126
|
+
static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
|
|
28127
|
+
};
|
|
27885
28128
|
|
|
28129
|
+
} // namespace duckdb
|
|
27886
28130
|
//===----------------------------------------------------------------------===//
|
|
27887
28131
|
// DuckDB
|
|
27888
28132
|
//
|
|
27889
|
-
// duckdb/parser/parsed_data/
|
|
28133
|
+
// duckdb/parser/parsed_data/create_aggregate_function_info.hpp
|
|
27890
28134
|
//
|
|
27891
28135
|
//
|
|
27892
28136
|
//===----------------------------------------------------------------------===//
|
|
@@ -27895,27 +28139,61 @@ public:
|
|
|
27895
28139
|
|
|
27896
28140
|
|
|
27897
28141
|
|
|
28142
|
+
|
|
27898
28143
|
namespace duckdb {
|
|
27899
28144
|
|
|
27900
|
-
struct
|
|
27901
|
-
|
|
28145
|
+
struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
|
|
28146
|
+
explicit CreateAggregateFunctionInfo(AggregateFunction function)
|
|
28147
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
28148
|
+
name = function.name;
|
|
28149
|
+
functions.AddFunction(move(function));
|
|
27902
28150
|
}
|
|
27903
28151
|
|
|
28152
|
+
explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
|
|
28153
|
+
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
28154
|
+
name = functions.name;
|
|
28155
|
+
for (auto &func : functions.functions) {
|
|
28156
|
+
func.name = functions.name;
|
|
28157
|
+
}
|
|
28158
|
+
}
|
|
28159
|
+
|
|
28160
|
+
AggregateFunctionSet functions;
|
|
28161
|
+
|
|
27904
28162
|
public:
|
|
27905
28163
|
unique_ptr<CreateInfo> Copy() const override {
|
|
27906
|
-
auto result = make_unique<
|
|
28164
|
+
auto result = make_unique<CreateAggregateFunctionInfo>(functions);
|
|
27907
28165
|
CopyProperties(*result);
|
|
27908
28166
|
return move(result);
|
|
27909
28167
|
}
|
|
28168
|
+
};
|
|
27910
28169
|
|
|
27911
|
-
|
|
27912
|
-
|
|
27913
|
-
|
|
27914
|
-
|
|
27915
|
-
|
|
28170
|
+
} // namespace duckdb
|
|
28171
|
+
//===----------------------------------------------------------------------===//
|
|
28172
|
+
// DuckDB
|
|
28173
|
+
//
|
|
28174
|
+
// duckdb/parser/parsed_data/vacuum_info.hpp
|
|
28175
|
+
//
|
|
28176
|
+
//
|
|
28177
|
+
//===----------------------------------------------------------------------===//
|
|
27916
28178
|
|
|
27917
|
-
|
|
27918
|
-
|
|
28179
|
+
|
|
28180
|
+
|
|
28181
|
+
|
|
28182
|
+
|
|
28183
|
+
namespace duckdb {
|
|
28184
|
+
|
|
28185
|
+
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
28186
|
+
|
|
28187
|
+
struct LoadInfo : public ParseInfo {
|
|
28188
|
+
std::string filename;
|
|
28189
|
+
LoadType load_type;
|
|
28190
|
+
|
|
28191
|
+
public:
|
|
28192
|
+
unique_ptr<LoadInfo> Copy() const {
|
|
28193
|
+
auto result = make_unique<LoadInfo>();
|
|
28194
|
+
result->filename = filename;
|
|
28195
|
+
result->load_type = load_type;
|
|
28196
|
+
return result;
|
|
27919
28197
|
}
|
|
27920
28198
|
};
|
|
27921
28199
|
|
|
@@ -27923,7 +28201,7 @@ protected:
|
|
|
27923
28201
|
//===----------------------------------------------------------------------===//
|
|
27924
28202
|
// DuckDB
|
|
27925
28203
|
//
|
|
27926
|
-
// duckdb/parser/parsed_data/
|
|
28204
|
+
// duckdb/parser/parsed_data/create_view_info.hpp
|
|
27927
28205
|
//
|
|
27928
28206
|
//
|
|
27929
28207
|
//===----------------------------------------------------------------------===//
|
|
@@ -27935,42 +28213,62 @@ protected:
|
|
|
27935
28213
|
|
|
27936
28214
|
namespace duckdb {
|
|
27937
28215
|
|
|
27938
|
-
struct
|
|
27939
|
-
|
|
27940
|
-
: CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
|
|
27941
|
-
not_required_for_equality(not_required_for_equality_p) {
|
|
27942
|
-
this->name = move(name_p);
|
|
28216
|
+
struct CreateViewInfo : public CreateInfo {
|
|
28217
|
+
CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
|
|
27943
28218
|
}
|
|
27944
|
-
|
|
27945
|
-
|
|
27946
|
-
string name;
|
|
27947
|
-
//! The collation function to push in case collation is required
|
|
27948
|
-
ScalarFunction function;
|
|
27949
|
-
//! Whether or not the collation can be combined with other collations.
|
|
27950
|
-
bool combinable;
|
|
27951
|
-
//! Whether or not the collation is required for equality comparisons or not. For many collations a binary
|
|
27952
|
-
//! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
|
|
27953
|
-
//! speeds up processing.
|
|
27954
|
-
bool not_required_for_equality;
|
|
27955
|
-
|
|
27956
|
-
protected:
|
|
27957
|
-
void SerializeInternal(Serializer &) const override {
|
|
27958
|
-
throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(type));
|
|
28219
|
+
CreateViewInfo(string schema, string view_name)
|
|
28220
|
+
: CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
|
|
27959
28221
|
}
|
|
27960
28222
|
|
|
28223
|
+
//! Table name to insert to
|
|
28224
|
+
string view_name;
|
|
28225
|
+
//! Aliases of the view
|
|
28226
|
+
vector<string> aliases;
|
|
28227
|
+
//! Return types
|
|
28228
|
+
vector<LogicalType> types;
|
|
28229
|
+
//! The SelectStatement of the view
|
|
28230
|
+
unique_ptr<SelectStatement> query;
|
|
28231
|
+
|
|
27961
28232
|
public:
|
|
27962
28233
|
unique_ptr<CreateInfo> Copy() const override {
|
|
27963
|
-
auto result = make_unique<
|
|
28234
|
+
auto result = make_unique<CreateViewInfo>(schema, view_name);
|
|
27964
28235
|
CopyProperties(*result);
|
|
28236
|
+
result->aliases = aliases;
|
|
28237
|
+
result->types = types;
|
|
28238
|
+
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
27965
28239
|
return move(result);
|
|
27966
28240
|
}
|
|
28241
|
+
|
|
28242
|
+
static unique_ptr<CreateViewInfo> Deserialize(Deserializer &deserializer) {
|
|
28243
|
+
auto result = make_unique<CreateViewInfo>();
|
|
28244
|
+
result->DeserializeBase(deserializer);
|
|
28245
|
+
|
|
28246
|
+
FieldReader reader(deserializer);
|
|
28247
|
+
result->view_name = reader.ReadRequired<string>();
|
|
28248
|
+
result->aliases = reader.ReadRequiredList<string>();
|
|
28249
|
+
result->types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
|
|
28250
|
+
result->query = reader.ReadOptional<SelectStatement>(nullptr);
|
|
28251
|
+
reader.Finalize();
|
|
28252
|
+
|
|
28253
|
+
return result;
|
|
28254
|
+
}
|
|
28255
|
+
|
|
28256
|
+
protected:
|
|
28257
|
+
void SerializeInternal(Serializer &serializer) const override {
|
|
28258
|
+
FieldWriter writer(serializer);
|
|
28259
|
+
writer.WriteString(view_name);
|
|
28260
|
+
writer.WriteList<string>(aliases);
|
|
28261
|
+
writer.WriteRegularSerializableList(types);
|
|
28262
|
+
writer.WriteOptional(query);
|
|
28263
|
+
writer.Finalize();
|
|
28264
|
+
}
|
|
27967
28265
|
};
|
|
27968
28266
|
|
|
27969
28267
|
} // namespace duckdb
|
|
27970
28268
|
//===----------------------------------------------------------------------===//
|
|
27971
28269
|
// DuckDB
|
|
27972
28270
|
//
|
|
27973
|
-
// duckdb/parser/parsed_data/
|
|
28271
|
+
// duckdb/parser/parsed_data/show_select_info.hpp
|
|
27974
28272
|
//
|
|
27975
28273
|
//
|
|
27976
28274
|
//===----------------------------------------------------------------------===//
|
|
@@ -27979,54 +28277,155 @@ public:
|
|
|
27979
28277
|
|
|
27980
28278
|
|
|
27981
28279
|
|
|
28280
|
+
|
|
27982
28281
|
namespace duckdb {
|
|
27983
28282
|
|
|
27984
|
-
|
|
28283
|
+
struct ShowSelectInfo : public ParseInfo {
|
|
28284
|
+
//! Types of projected columns
|
|
28285
|
+
vector<LogicalType> types;
|
|
28286
|
+
//! The QueryNode of select query
|
|
28287
|
+
unique_ptr<QueryNode> query;
|
|
28288
|
+
//! Aliases of projected columns
|
|
28289
|
+
vector<string> aliases;
|
|
28290
|
+
//! Whether or not we are requesting a summary or a describe
|
|
28291
|
+
bool is_summary;
|
|
27985
28292
|
|
|
27986
|
-
|
|
27987
|
-
|
|
28293
|
+
unique_ptr<ShowSelectInfo> Copy() {
|
|
28294
|
+
auto result = make_unique<ShowSelectInfo>();
|
|
28295
|
+
result->types = types;
|
|
28296
|
+
result->query = query->Copy();
|
|
28297
|
+
result->aliases = aliases;
|
|
28298
|
+
result->is_summary = is_summary;
|
|
28299
|
+
return result;
|
|
27988
28300
|
}
|
|
28301
|
+
};
|
|
27989
28302
|
|
|
27990
|
-
|
|
27991
|
-
|
|
28303
|
+
} // namespace duckdb
|
|
28304
|
+
//===----------------------------------------------------------------------===//
|
|
28305
|
+
// DuckDB
|
|
28306
|
+
//
|
|
28307
|
+
// duckdb/parser/parsed_data/alter_function_info.hpp
|
|
28308
|
+
//
|
|
28309
|
+
//
|
|
28310
|
+
//===----------------------------------------------------------------------===//
|
|
28311
|
+
|
|
28312
|
+
|
|
28313
|
+
|
|
28314
|
+
|
|
28315
|
+
|
|
28316
|
+
|
|
28317
|
+
|
|
28318
|
+
namespace duckdb {
|
|
28319
|
+
|
|
28320
|
+
//===--------------------------------------------------------------------===//
|
|
28321
|
+
// Alter Table
|
|
28322
|
+
//===--------------------------------------------------------------------===//
|
|
28323
|
+
enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
|
|
28324
|
+
|
|
28325
|
+
struct AlterFunctionInfo : public AlterInfo {
|
|
28326
|
+
AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
|
|
28327
|
+
virtual ~AlterFunctionInfo() override;
|
|
28328
|
+
|
|
28329
|
+
AlterFunctionType alter_function_type;
|
|
28330
|
+
|
|
28331
|
+
public:
|
|
28332
|
+
CatalogType GetCatalogType() const override;
|
|
28333
|
+
void Serialize(FieldWriter &writer) const override;
|
|
28334
|
+
static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
|
|
27992
28335
|
};
|
|
27993
28336
|
|
|
27994
|
-
|
|
27995
|
-
|
|
27996
|
-
|
|
27997
|
-
|
|
27998
|
-
|
|
27999
|
-
|
|
28000
|
-
|
|
28001
|
-
|
|
28337
|
+
//===--------------------------------------------------------------------===//
|
|
28338
|
+
// AddFunctionOverloadInfo
|
|
28339
|
+
//===--------------------------------------------------------------------===//
|
|
28340
|
+
struct AddFunctionOverloadInfo : public AlterFunctionInfo {
|
|
28341
|
+
AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
|
|
28342
|
+
~AddFunctionOverloadInfo() override;
|
|
28343
|
+
|
|
28344
|
+
ScalarFunctionSet new_overloads;
|
|
28345
|
+
|
|
28346
|
+
public:
|
|
28347
|
+
unique_ptr<AlterInfo> Copy() const override;
|
|
28348
|
+
};
|
|
28349
|
+
|
|
28350
|
+
} // namespace duckdb
|
|
28351
|
+
//===----------------------------------------------------------------------===//
|
|
28352
|
+
// DuckDB
|
|
28353
|
+
//
|
|
28354
|
+
// duckdb/parser/parsed_data/create_macro_info.hpp
|
|
28355
|
+
//
|
|
28356
|
+
//
|
|
28357
|
+
//===----------------------------------------------------------------------===//
|
|
28358
|
+
|
|
28359
|
+
|
|
28360
|
+
|
|
28361
|
+
|
|
28362
|
+
//===----------------------------------------------------------------------===//
|
|
28363
|
+
// DuckDB
|
|
28364
|
+
//
|
|
28365
|
+
// duckdb/function/macro_function.hpp
|
|
28366
|
+
//
|
|
28367
|
+
//
|
|
28368
|
+
//===----------------------------------------------------------------------===//
|
|
28369
|
+
|
|
28370
|
+
|
|
28371
|
+
|
|
28372
|
+
|
|
28373
|
+
|
|
28374
|
+
|
|
28375
|
+
|
|
28376
|
+
|
|
28377
|
+
|
|
28378
|
+
|
|
28379
|
+
namespace duckdb {
|
|
28380
|
+
|
|
28381
|
+
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
28382
|
+
|
|
28383
|
+
class MacroFunction {
|
|
28384
|
+
public:
|
|
28385
|
+
MacroFunction(MacroType type);
|
|
28386
|
+
|
|
28387
|
+
//! The type
|
|
28388
|
+
MacroType type;
|
|
28389
|
+
//! The positional parameters
|
|
28390
|
+
vector<unique_ptr<ParsedExpression>> parameters;
|
|
28391
|
+
//! The default parameters and their associated values
|
|
28392
|
+
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
28393
|
+
|
|
28394
|
+
public:
|
|
28395
|
+
virtual ~MacroFunction() {
|
|
28396
|
+
}
|
|
28397
|
+
|
|
28398
|
+
void CopyProperties(MacroFunction &other);
|
|
28002
28399
|
|
|
28400
|
+
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
28003
28401
|
|
|
28402
|
+
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
28403
|
+
FunctionExpression &function_expr,
|
|
28404
|
+
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
28405
|
+
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
28004
28406
|
|
|
28407
|
+
virtual string ToSQL(const string &schema, const string &name);
|
|
28408
|
+
};
|
|
28005
28409
|
|
|
28410
|
+
} // namespace duckdb
|
|
28006
28411
|
|
|
28007
28412
|
|
|
28008
28413
|
namespace duckdb {
|
|
28009
28414
|
|
|
28010
|
-
struct
|
|
28011
|
-
|
|
28012
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
|
|
28013
|
-
name = function.name;
|
|
28014
|
-
functions.AddFunction(move(function));
|
|
28415
|
+
struct CreateMacroInfo : public CreateFunctionInfo {
|
|
28416
|
+
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
28015
28417
|
}
|
|
28016
28418
|
|
|
28017
|
-
|
|
28018
|
-
: CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
|
|
28019
|
-
name = functions.name;
|
|
28020
|
-
for (auto &func : functions.functions) {
|
|
28021
|
-
func.name = functions.name;
|
|
28022
|
-
}
|
|
28419
|
+
CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
|
|
28023
28420
|
}
|
|
28024
28421
|
|
|
28025
|
-
|
|
28422
|
+
unique_ptr<MacroFunction> function;
|
|
28026
28423
|
|
|
28027
28424
|
public:
|
|
28028
28425
|
unique_ptr<CreateInfo> Copy() const override {
|
|
28029
|
-
auto result = make_unique<
|
|
28426
|
+
auto result = make_unique<CreateMacroInfo>();
|
|
28427
|
+
result->function = function->Copy();
|
|
28428
|
+
result->name = name;
|
|
28030
28429
|
CopyProperties(*result);
|
|
28031
28430
|
return move(result);
|
|
28032
28431
|
}
|
|
@@ -28080,7 +28479,7 @@ public:
|
|
|
28080
28479
|
//===----------------------------------------------------------------------===//
|
|
28081
28480
|
// DuckDB
|
|
28082
28481
|
//
|
|
28083
|
-
// duckdb/parser/parsed_data/
|
|
28482
|
+
// duckdb/parser/parsed_data/create_pragma_function_info.hpp
|
|
28084
28483
|
//
|
|
28085
28484
|
//
|
|
28086
28485
|
//===----------------------------------------------------------------------===//
|
|
@@ -28092,140 +28491,25 @@ public:
|
|
|
28092
28491
|
|
|
28093
28492
|
namespace duckdb {
|
|
28094
28493
|
|
|
28095
|
-
struct
|
|
28096
|
-
|
|
28494
|
+
struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
|
|
28495
|
+
explicit CreatePragmaFunctionInfo(PragmaFunction function)
|
|
28496
|
+
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(function.name) {
|
|
28497
|
+
name = function.name;
|
|
28498
|
+
functions.AddFunction(move(function));
|
|
28097
28499
|
}
|
|
28098
|
-
|
|
28099
|
-
:
|
|
28500
|
+
CreatePragmaFunctionInfo(string name, PragmaFunctionSet functions_)
|
|
28501
|
+
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(functions_) {
|
|
28502
|
+
this->name = name;
|
|
28100
28503
|
}
|
|
28101
28504
|
|
|
28102
|
-
|
|
28103
|
-
string view_name;
|
|
28104
|
-
//! Aliases of the view
|
|
28105
|
-
vector<string> aliases;
|
|
28106
|
-
//! Return types
|
|
28107
|
-
vector<LogicalType> types;
|
|
28108
|
-
//! The SelectStatement of the view
|
|
28109
|
-
unique_ptr<SelectStatement> query;
|
|
28505
|
+
PragmaFunctionSet functions;
|
|
28110
28506
|
|
|
28111
28507
|
public:
|
|
28112
28508
|
unique_ptr<CreateInfo> Copy() const override {
|
|
28113
|
-
auto result = make_unique<
|
|
28509
|
+
auto result = make_unique<CreatePragmaFunctionInfo>(functions.name, functions);
|
|
28114
28510
|
CopyProperties(*result);
|
|
28115
|
-
result->aliases = aliases;
|
|
28116
|
-
result->types = types;
|
|
28117
|
-
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
|
|
28118
28511
|
return move(result);
|
|
28119
28512
|
}
|
|
28120
|
-
|
|
28121
|
-
static unique_ptr<CreateViewInfo> Deserialize(Deserializer &deserializer) {
|
|
28122
|
-
auto result = make_unique<CreateViewInfo>();
|
|
28123
|
-
result->DeserializeBase(deserializer);
|
|
28124
|
-
|
|
28125
|
-
FieldReader reader(deserializer);
|
|
28126
|
-
result->view_name = reader.ReadRequired<string>();
|
|
28127
|
-
result->aliases = reader.ReadRequiredList<string>();
|
|
28128
|
-
result->types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
|
|
28129
|
-
result->query = reader.ReadOptional<SelectStatement>(nullptr);
|
|
28130
|
-
reader.Finalize();
|
|
28131
|
-
|
|
28132
|
-
return result;
|
|
28133
|
-
}
|
|
28134
|
-
|
|
28135
|
-
protected:
|
|
28136
|
-
void SerializeInternal(Serializer &serializer) const override {
|
|
28137
|
-
FieldWriter writer(serializer);
|
|
28138
|
-
writer.WriteString(view_name);
|
|
28139
|
-
writer.WriteList<string>(aliases);
|
|
28140
|
-
writer.WriteRegularSerializableList(types);
|
|
28141
|
-
writer.WriteOptional(query);
|
|
28142
|
-
writer.Finalize();
|
|
28143
|
-
}
|
|
28144
|
-
};
|
|
28145
|
-
|
|
28146
|
-
} // namespace duckdb
|
|
28147
|
-
//===----------------------------------------------------------------------===//
|
|
28148
|
-
// DuckDB
|
|
28149
|
-
//
|
|
28150
|
-
// duckdb/parser/parsed_data/create_index_info.hpp
|
|
28151
|
-
//
|
|
28152
|
-
//
|
|
28153
|
-
//===----------------------------------------------------------------------===//
|
|
28154
|
-
|
|
28155
|
-
|
|
28156
|
-
|
|
28157
|
-
|
|
28158
|
-
|
|
28159
|
-
|
|
28160
|
-
//===----------------------------------------------------------------------===//
|
|
28161
|
-
// DuckDB
|
|
28162
|
-
//
|
|
28163
|
-
// duckdb/parser/tableref/basetableref.hpp
|
|
28164
|
-
//
|
|
28165
|
-
//
|
|
28166
|
-
//===----------------------------------------------------------------------===//
|
|
28167
|
-
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
|
|
28173
|
-
namespace duckdb {
|
|
28174
|
-
//! Represents a TableReference to a base table in the schema
|
|
28175
|
-
class BaseTableRef : public TableRef {
|
|
28176
|
-
public:
|
|
28177
|
-
BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
|
|
28178
|
-
}
|
|
28179
|
-
|
|
28180
|
-
//! Schema name
|
|
28181
|
-
string schema_name;
|
|
28182
|
-
//! Table name
|
|
28183
|
-
string table_name;
|
|
28184
|
-
//! Aliases for the column names
|
|
28185
|
-
vector<string> column_name_alias;
|
|
28186
|
-
|
|
28187
|
-
public:
|
|
28188
|
-
string ToString() const override;
|
|
28189
|
-
bool Equals(const TableRef *other_p) const override;
|
|
28190
|
-
|
|
28191
|
-
unique_ptr<TableRef> Copy() override;
|
|
28192
|
-
|
|
28193
|
-
//! Serializes a blob into a BaseTableRef
|
|
28194
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
28195
|
-
//! Deserializes a blob back into a BaseTableRef
|
|
28196
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28197
|
-
};
|
|
28198
|
-
} // namespace duckdb
|
|
28199
|
-
|
|
28200
|
-
|
|
28201
|
-
|
|
28202
|
-
namespace duckdb {
|
|
28203
|
-
|
|
28204
|
-
struct CreateIndexInfo : public CreateInfo {
|
|
28205
|
-
CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
|
|
28206
|
-
}
|
|
28207
|
-
|
|
28208
|
-
//! Index Type (e.g., B+-tree, Skip-List, ...)
|
|
28209
|
-
IndexType index_type;
|
|
28210
|
-
//! Name of the Index
|
|
28211
|
-
string index_name;
|
|
28212
|
-
//! Index Constraint Type
|
|
28213
|
-
IndexConstraintType constraint_type;
|
|
28214
|
-
//! The table to create the index on
|
|
28215
|
-
unique_ptr<BaseTableRef> table;
|
|
28216
|
-
//! Set of expressions to index by
|
|
28217
|
-
vector<unique_ptr<ParsedExpression>> expressions;
|
|
28218
|
-
vector<unique_ptr<ParsedExpression>> parsed_expressions;
|
|
28219
|
-
|
|
28220
|
-
vector<idx_t> column_ids;
|
|
28221
|
-
|
|
28222
|
-
protected:
|
|
28223
|
-
void SerializeInternal(Serializer &serializer) const override;
|
|
28224
|
-
|
|
28225
|
-
public:
|
|
28226
|
-
unique_ptr<CreateInfo> Copy() const override;
|
|
28227
|
-
|
|
28228
|
-
static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
|
|
28229
28513
|
};
|
|
28230
28514
|
|
|
28231
28515
|
} // namespace duckdb
|
|
@@ -28334,7 +28618,7 @@ public:
|
|
|
28334
28618
|
//===----------------------------------------------------------------------===//
|
|
28335
28619
|
// DuckDB
|
|
28336
28620
|
//
|
|
28337
|
-
// duckdb/parser/parsed_data/
|
|
28621
|
+
// duckdb/parser/parsed_data/create_collation_info.hpp
|
|
28338
28622
|
//
|
|
28339
28623
|
//
|
|
28340
28624
|
//===----------------------------------------------------------------------===//
|
|
@@ -28343,55 +28627,35 @@ public:
|
|
|
28343
28627
|
|
|
28344
28628
|
|
|
28345
28629
|
|
|
28346
|
-
namespace duckdb {
|
|
28347
|
-
|
|
28348
|
-
enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
|
|
28349
28630
|
|
|
28350
|
-
|
|
28351
|
-
std::string filename;
|
|
28352
|
-
LoadType load_type;
|
|
28631
|
+
namespace duckdb {
|
|
28353
28632
|
|
|
28354
|
-
public
|
|
28355
|
-
|
|
28356
|
-
|
|
28357
|
-
|
|
28358
|
-
|
|
28359
|
-
return result;
|
|
28633
|
+
struct CreateCollationInfo : public CreateInfo {
|
|
28634
|
+
CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
|
|
28635
|
+
: CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
|
|
28636
|
+
not_required_for_equality(not_required_for_equality_p) {
|
|
28637
|
+
this->name = move(name_p);
|
|
28360
28638
|
}
|
|
28361
|
-
};
|
|
28362
|
-
|
|
28363
|
-
} // namespace duckdb
|
|
28364
|
-
//===----------------------------------------------------------------------===//
|
|
28365
|
-
// DuckDB
|
|
28366
|
-
//
|
|
28367
|
-
// duckdb/parser/parsed_data/create_pragma_function_info.hpp
|
|
28368
|
-
//
|
|
28369
|
-
//
|
|
28370
|
-
//===----------------------------------------------------------------------===//
|
|
28371
|
-
|
|
28372
|
-
|
|
28373
|
-
|
|
28374
28639
|
|
|
28640
|
+
//! The name of the collation
|
|
28641
|
+
string name;
|
|
28642
|
+
//! The collation function to push in case collation is required
|
|
28643
|
+
ScalarFunction function;
|
|
28644
|
+
//! Whether or not the collation can be combined with other collations.
|
|
28645
|
+
bool combinable;
|
|
28646
|
+
//! Whether or not the collation is required for equality comparisons or not. For many collations a binary
|
|
28647
|
+
//! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
|
|
28648
|
+
//! speeds up processing.
|
|
28649
|
+
bool not_required_for_equality;
|
|
28375
28650
|
|
|
28376
|
-
|
|
28377
|
-
|
|
28378
|
-
|
|
28379
|
-
struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
|
|
28380
|
-
explicit CreatePragmaFunctionInfo(PragmaFunction function)
|
|
28381
|
-
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(function.name) {
|
|
28382
|
-
name = function.name;
|
|
28383
|
-
functions.AddFunction(move(function));
|
|
28384
|
-
}
|
|
28385
|
-
CreatePragmaFunctionInfo(string name, PragmaFunctionSet functions_)
|
|
28386
|
-
: CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(functions_) {
|
|
28387
|
-
this->name = name;
|
|
28651
|
+
protected:
|
|
28652
|
+
void SerializeInternal(Serializer &) const override {
|
|
28653
|
+
throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(type));
|
|
28388
28654
|
}
|
|
28389
28655
|
|
|
28390
|
-
PragmaFunctionSet functions;
|
|
28391
|
-
|
|
28392
28656
|
public:
|
|
28393
28657
|
unique_ptr<CreateInfo> Copy() const override {
|
|
28394
|
-
auto result = make_unique<
|
|
28658
|
+
auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
|
|
28395
28659
|
CopyProperties(*result);
|
|
28396
28660
|
return move(result);
|
|
28397
28661
|
}
|
|
@@ -28401,7 +28665,7 @@ public:
|
|
|
28401
28665
|
//===----------------------------------------------------------------------===//
|
|
28402
28666
|
// DuckDB
|
|
28403
28667
|
//
|
|
28404
|
-
// duckdb/parser/parsed_data/
|
|
28668
|
+
// duckdb/parser/parsed_data/create_schema_info.hpp
|
|
28405
28669
|
//
|
|
28406
28670
|
//
|
|
28407
28671
|
//===----------------------------------------------------------------------===//
|
|
@@ -28410,27 +28674,28 @@ public:
|
|
|
28410
28674
|
|
|
28411
28675
|
|
|
28412
28676
|
|
|
28413
|
-
|
|
28414
28677
|
namespace duckdb {
|
|
28415
28678
|
|
|
28416
|
-
struct
|
|
28417
|
-
|
|
28418
|
-
|
|
28419
|
-
|
|
28420
|
-
|
|
28421
|
-
|
|
28422
|
-
|
|
28423
|
-
|
|
28424
|
-
|
|
28679
|
+
struct CreateSchemaInfo : public CreateInfo {
|
|
28680
|
+
CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
|
|
28681
|
+
}
|
|
28682
|
+
|
|
28683
|
+
public:
|
|
28684
|
+
unique_ptr<CreateInfo> Copy() const override {
|
|
28685
|
+
auto result = make_unique<CreateSchemaInfo>();
|
|
28686
|
+
CopyProperties(*result);
|
|
28687
|
+
return move(result);
|
|
28688
|
+
}
|
|
28425
28689
|
|
|
28426
|
-
unique_ptr<
|
|
28427
|
-
auto result = make_unique<
|
|
28428
|
-
result->
|
|
28429
|
-
result->query = query->Copy();
|
|
28430
|
-
result->aliases = aliases;
|
|
28431
|
-
result->is_summary = is_summary;
|
|
28690
|
+
static unique_ptr<CreateSchemaInfo> Deserialize(Deserializer &deserializer) {
|
|
28691
|
+
auto result = make_unique<CreateSchemaInfo>();
|
|
28692
|
+
result->DeserializeBase(deserializer);
|
|
28432
28693
|
return result;
|
|
28433
28694
|
}
|
|
28695
|
+
|
|
28696
|
+
protected:
|
|
28697
|
+
void SerializeInternal(Serializer &) const override {
|
|
28698
|
+
}
|
|
28434
28699
|
};
|
|
28435
28700
|
|
|
28436
28701
|
} // namespace duckdb
|
|
@@ -28452,14 +28717,16 @@ struct ShowSelectInfo : public ParseInfo {
|
|
|
28452
28717
|
namespace duckdb {
|
|
28453
28718
|
|
|
28454
28719
|
struct CreateTypeInfo : public CreateInfo {
|
|
28455
|
-
|
|
28456
28720
|
CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
|
|
28457
28721
|
}
|
|
28722
|
+
CreateTypeInfo(string name_p, LogicalType type_p)
|
|
28723
|
+
: CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
|
|
28724
|
+
}
|
|
28458
28725
|
|
|
28459
28726
|
//! Name of the Type
|
|
28460
28727
|
string name;
|
|
28461
28728
|
//! Logical Type
|
|
28462
|
-
LogicalType type;
|
|
28729
|
+
LogicalType type;
|
|
28463
28730
|
|
|
28464
28731
|
public:
|
|
28465
28732
|
unique_ptr<CreateInfo> Copy() const override {
|
|
@@ -28480,7 +28747,7 @@ protected:
|
|
|
28480
28747
|
//===----------------------------------------------------------------------===//
|
|
28481
28748
|
// DuckDB
|
|
28482
28749
|
//
|
|
28483
|
-
// duckdb/parser/
|
|
28750
|
+
// duckdb/parser/tableref/subqueryref.hpp
|
|
28484
28751
|
//
|
|
28485
28752
|
//
|
|
28486
28753
|
//===----------------------------------------------------------------------===//
|
|
@@ -28491,44 +28758,32 @@ protected:
|
|
|
28491
28758
|
|
|
28492
28759
|
|
|
28493
28760
|
namespace duckdb {
|
|
28494
|
-
|
|
28495
|
-
|
|
28496
|
-
|
|
28497
|
-
|
|
28498
|
-
string table_name;
|
|
28761
|
+
//! Represents a subquery
|
|
28762
|
+
class SubqueryRef : public TableRef {
|
|
28763
|
+
public:
|
|
28764
|
+
explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
28499
28765
|
|
|
28500
|
-
//!
|
|
28501
|
-
|
|
28766
|
+
//! The subquery
|
|
28767
|
+
unique_ptr<SelectStatement> subquery;
|
|
28768
|
+
//! Aliases for the column names
|
|
28769
|
+
vector<string> column_name_alias;
|
|
28502
28770
|
|
|
28503
|
-
|
|
28504
|
-
string
|
|
28505
|
-
|
|
28771
|
+
public:
|
|
28772
|
+
string ToString() const override;
|
|
28773
|
+
bool Equals(const TableRef *other_p) const override;
|
|
28506
28774
|
|
|
28507
|
-
|
|
28508
|
-
TableCatalogEntry *entry;
|
|
28509
|
-
ExportedTableData table_data;
|
|
28510
|
-
};
|
|
28775
|
+
unique_ptr<TableRef> Copy() override;
|
|
28511
28776
|
|
|
28512
|
-
|
|
28513
|
-
|
|
28777
|
+
//! Serializes a blob into a SubqueryRef
|
|
28778
|
+
void Serialize(FieldWriter &serializer) const override;
|
|
28779
|
+
//! Deserializes a blob back into a SubqueryRef
|
|
28780
|
+
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28514
28781
|
};
|
|
28515
|
-
|
|
28516
28782
|
} // namespace duckdb
|
|
28517
28783
|
//===----------------------------------------------------------------------===//
|
|
28518
28784
|
// DuckDB
|
|
28519
28785
|
//
|
|
28520
|
-
// duckdb/parser/
|
|
28521
|
-
//
|
|
28522
|
-
//
|
|
28523
|
-
//===----------------------------------------------------------------------===//
|
|
28524
|
-
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
28528
|
-
//===----------------------------------------------------------------------===//
|
|
28529
|
-
// DuckDB
|
|
28530
|
-
//
|
|
28531
|
-
// duckdb/function/macro_function.hpp
|
|
28786
|
+
// duckdb/parser/tableref/joinref.hpp
|
|
28532
28787
|
//
|
|
28533
28788
|
//
|
|
28534
28789
|
//===----------------------------------------------------------------------===//
|
|
@@ -28541,81 +28796,25 @@ struct BoundExportData : public ParseInfo {
|
|
|
28541
28796
|
|
|
28542
28797
|
|
|
28543
28798
|
|
|
28544
|
-
|
|
28545
|
-
namespace duckdb {
|
|
28546
|
-
|
|
28547
|
-
enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
|
|
28548
|
-
|
|
28549
|
-
class MacroFunction {
|
|
28550
|
-
public:
|
|
28551
|
-
MacroFunction(MacroType type);
|
|
28552
|
-
|
|
28553
|
-
//! The type
|
|
28554
|
-
MacroType type;
|
|
28555
|
-
//! The positional parameters
|
|
28556
|
-
vector<unique_ptr<ParsedExpression>> parameters;
|
|
28557
|
-
//! The default parameters and their associated values
|
|
28558
|
-
unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
|
|
28559
|
-
|
|
28560
|
-
public:
|
|
28561
|
-
virtual ~MacroFunction() {
|
|
28562
|
-
}
|
|
28563
|
-
|
|
28564
|
-
void CopyProperties(MacroFunction &other);
|
|
28565
|
-
|
|
28566
|
-
virtual unique_ptr<MacroFunction> Copy() = 0;
|
|
28567
|
-
|
|
28568
|
-
static string ValidateArguments(MacroFunction ¯o_function, const string &name,
|
|
28569
|
-
FunctionExpression &function_expr,
|
|
28570
|
-
vector<unique_ptr<ParsedExpression>> &positionals,
|
|
28571
|
-
unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
|
|
28572
|
-
|
|
28573
|
-
virtual string ToSQL(const string &schema, const string &name);
|
|
28574
|
-
};
|
|
28575
|
-
|
|
28576
|
-
} // namespace duckdb
|
|
28577
|
-
|
|
28578
|
-
|
|
28579
28799
|
namespace duckdb {
|
|
28580
|
-
|
|
28581
|
-
|
|
28582
|
-
CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
|
|
28583
|
-
}
|
|
28584
|
-
|
|
28585
|
-
CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
|
|
28586
|
-
}
|
|
28587
|
-
|
|
28588
|
-
unique_ptr<MacroFunction> function;
|
|
28589
|
-
|
|
28800
|
+
//! Represents a JOIN between two expressions
|
|
28801
|
+
class JoinRef : public TableRef {
|
|
28590
28802
|
public:
|
|
28591
|
-
|
|
28592
|
-
auto result = make_unique<CreateMacroInfo>();
|
|
28593
|
-
result->function = function->Copy();
|
|
28594
|
-
result->name = name;
|
|
28595
|
-
CopyProperties(*result);
|
|
28596
|
-
return move(result);
|
|
28803
|
+
JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
|
|
28597
28804
|
}
|
|
28598
|
-
};
|
|
28599
|
-
|
|
28600
|
-
} // namespace duckdb
|
|
28601
|
-
//===----------------------------------------------------------------------===//
|
|
28602
|
-
// DuckDB
|
|
28603
|
-
//
|
|
28604
|
-
// duckdb/parser/tableref/emptytableref.hpp
|
|
28605
|
-
//
|
|
28606
|
-
//
|
|
28607
|
-
//===----------------------------------------------------------------------===//
|
|
28608
|
-
|
|
28609
28805
|
|
|
28610
|
-
|
|
28611
|
-
|
|
28612
|
-
|
|
28613
|
-
|
|
28614
|
-
//!
|
|
28615
|
-
|
|
28616
|
-
|
|
28617
|
-
|
|
28618
|
-
|
|
28806
|
+
//! The left hand side of the join
|
|
28807
|
+
unique_ptr<TableRef> left;
|
|
28808
|
+
//! The right hand side of the join
|
|
28809
|
+
unique_ptr<TableRef> right;
|
|
28810
|
+
//! The join condition
|
|
28811
|
+
unique_ptr<ParsedExpression> condition;
|
|
28812
|
+
//! The join type
|
|
28813
|
+
JoinType type;
|
|
28814
|
+
//! Natural join
|
|
28815
|
+
bool is_natural;
|
|
28816
|
+
//! The set of USING columns (if any)
|
|
28817
|
+
vector<string> using_columns;
|
|
28619
28818
|
|
|
28620
28819
|
public:
|
|
28621
28820
|
string ToString() const override;
|
|
@@ -28623,16 +28822,16 @@ public:
|
|
|
28623
28822
|
|
|
28624
28823
|
unique_ptr<TableRef> Copy() override;
|
|
28625
28824
|
|
|
28626
|
-
//! Serializes a blob into a
|
|
28825
|
+
//! Serializes a blob into a JoinRef
|
|
28627
28826
|
void Serialize(FieldWriter &serializer) const override;
|
|
28628
|
-
//! Deserializes a blob back into a
|
|
28827
|
+
//! Deserializes a blob back into a JoinRef
|
|
28629
28828
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28630
28829
|
};
|
|
28631
28830
|
} // namespace duckdb
|
|
28632
28831
|
//===----------------------------------------------------------------------===//
|
|
28633
28832
|
// DuckDB
|
|
28634
28833
|
//
|
|
28635
|
-
// duckdb/parser/tableref/
|
|
28834
|
+
// duckdb/parser/tableref/table_function_ref.hpp
|
|
28636
28835
|
//
|
|
28637
28836
|
//
|
|
28638
28837
|
//===----------------------------------------------------------------------===//
|
|
@@ -28642,30 +28841,37 @@ public:
|
|
|
28642
28841
|
|
|
28643
28842
|
|
|
28644
28843
|
|
|
28844
|
+
|
|
28845
|
+
|
|
28846
|
+
|
|
28645
28847
|
namespace duckdb {
|
|
28646
|
-
//! Represents a
|
|
28647
|
-
class
|
|
28848
|
+
//! Represents a Table producing function
|
|
28849
|
+
class TableFunctionRef : public TableRef {
|
|
28648
28850
|
public:
|
|
28649
|
-
|
|
28851
|
+
DUCKDB_API TableFunctionRef();
|
|
28650
28852
|
|
|
28651
|
-
|
|
28652
|
-
unique_ptr<SelectStatement> subquery;
|
|
28653
|
-
//! Aliases for the column names
|
|
28853
|
+
unique_ptr<ParsedExpression> function;
|
|
28654
28854
|
vector<string> column_name_alias;
|
|
28655
28855
|
|
|
28856
|
+
// if the function takes a subquery as argument its in here
|
|
28857
|
+
unique_ptr<SelectStatement> subquery;
|
|
28858
|
+
|
|
28859
|
+
// External dependencies of this table funcion
|
|
28860
|
+
unique_ptr<ExternalDependency> external_dependency;
|
|
28861
|
+
|
|
28656
28862
|
public:
|
|
28657
28863
|
string ToString() const override;
|
|
28864
|
+
|
|
28658
28865
|
bool Equals(const TableRef *other_p) const override;
|
|
28659
28866
|
|
|
28660
28867
|
unique_ptr<TableRef> Copy() override;
|
|
28661
28868
|
|
|
28662
|
-
//! Serializes a blob into a
|
|
28869
|
+
//! Serializes a blob into a BaseTableRef
|
|
28663
28870
|
void Serialize(FieldWriter &serializer) const override;
|
|
28664
|
-
//! Deserializes a blob back into a
|
|
28871
|
+
//! Deserializes a blob back into a BaseTableRef
|
|
28665
28872
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28666
28873
|
};
|
|
28667
28874
|
} // namespace duckdb
|
|
28668
|
-
|
|
28669
28875
|
//===----------------------------------------------------------------------===//
|
|
28670
28876
|
// DuckDB
|
|
28671
28877
|
//
|
|
@@ -28702,8 +28908,6 @@ public:
|
|
|
28702
28908
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28703
28909
|
};
|
|
28704
28910
|
} // namespace duckdb
|
|
28705
|
-
|
|
28706
|
-
|
|
28707
28911
|
//===----------------------------------------------------------------------===//
|
|
28708
28912
|
// DuckDB
|
|
28709
28913
|
//
|
|
@@ -28745,11 +28949,10 @@ public:
|
|
|
28745
28949
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28746
28950
|
};
|
|
28747
28951
|
} // namespace duckdb
|
|
28748
|
-
|
|
28749
28952
|
//===----------------------------------------------------------------------===//
|
|
28750
28953
|
// DuckDB
|
|
28751
28954
|
//
|
|
28752
|
-
// duckdb/parser/tableref/
|
|
28955
|
+
// duckdb/parser/tableref/emptytableref.hpp
|
|
28753
28956
|
//
|
|
28754
28957
|
//
|
|
28755
28958
|
//===----------------------------------------------------------------------===//
|
|
@@ -28758,86 +28961,29 @@ public:
|
|
|
28758
28961
|
|
|
28759
28962
|
|
|
28760
28963
|
|
|
28761
|
-
|
|
28762
|
-
|
|
28763
|
-
|
|
28764
|
-
|
|
28765
28964
|
namespace duckdb {
|
|
28766
|
-
//! Represents a
|
|
28767
|
-
class
|
|
28965
|
+
//! Represents a cross product
|
|
28966
|
+
class EmptyTableRef : public TableRef {
|
|
28768
28967
|
public:
|
|
28769
|
-
|
|
28968
|
+
EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
|
|
28770
28969
|
}
|
|
28771
28970
|
|
|
28772
|
-
//! The left hand side of the join
|
|
28773
|
-
unique_ptr<TableRef> left;
|
|
28774
|
-
//! The right hand side of the join
|
|
28775
|
-
unique_ptr<TableRef> right;
|
|
28776
|
-
//! The join condition
|
|
28777
|
-
unique_ptr<ParsedExpression> condition;
|
|
28778
|
-
//! The join type
|
|
28779
|
-
JoinType type;
|
|
28780
|
-
//! Natural join
|
|
28781
|
-
bool is_natural;
|
|
28782
|
-
//! The set of USING columns (if any)
|
|
28783
|
-
vector<string> using_columns;
|
|
28784
|
-
|
|
28785
28971
|
public:
|
|
28786
28972
|
string ToString() const override;
|
|
28787
28973
|
bool Equals(const TableRef *other_p) const override;
|
|
28788
28974
|
|
|
28789
28975
|
unique_ptr<TableRef> Copy() override;
|
|
28790
28976
|
|
|
28791
|
-
//! Serializes a blob into a
|
|
28977
|
+
//! Serializes a blob into a DummyTableRef
|
|
28792
28978
|
void Serialize(FieldWriter &serializer) const override;
|
|
28793
|
-
//! Deserializes a blob back into a
|
|
28979
|
+
//! Deserializes a blob back into a DummyTableRef
|
|
28794
28980
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28795
28981
|
};
|
|
28796
28982
|
} // namespace duckdb
|
|
28797
28983
|
|
|
28798
28984
|
|
|
28799
|
-
//===----------------------------------------------------------------------===//
|
|
28800
|
-
// DuckDB
|
|
28801
|
-
//
|
|
28802
|
-
// duckdb/parser/tableref/table_function_ref.hpp
|
|
28803
|
-
//
|
|
28804
|
-
//
|
|
28805
|
-
//===----------------------------------------------------------------------===//
|
|
28806
|
-
|
|
28807
|
-
|
|
28808
|
-
|
|
28809
|
-
|
|
28810
|
-
|
|
28811
|
-
|
|
28812
|
-
|
|
28813
|
-
|
|
28814
|
-
|
|
28815
|
-
namespace duckdb {
|
|
28816
|
-
//! Represents a Table producing function
|
|
28817
|
-
class TableFunctionRef : public TableRef {
|
|
28818
|
-
public:
|
|
28819
|
-
DUCKDB_API TableFunctionRef();
|
|
28820
|
-
|
|
28821
|
-
unique_ptr<ParsedExpression> function;
|
|
28822
|
-
vector<string> column_name_alias;
|
|
28823
|
-
|
|
28824
|
-
// if the function takes a subquery as argument its in here
|
|
28825
|
-
unique_ptr<SelectStatement> subquery;
|
|
28826
|
-
|
|
28827
|
-
// External dependencies of this table funcion
|
|
28828
|
-
unique_ptr<ExternalDependency> external_dependency;
|
|
28829
28985
|
|
|
28830
|
-
public:
|
|
28831
|
-
string ToString() const override;
|
|
28832
28986
|
|
|
28833
|
-
bool Equals(const TableRef *other_p) const override;
|
|
28834
28987
|
|
|
28835
|
-
unique_ptr<TableRef> Copy() override;
|
|
28836
28988
|
|
|
28837
|
-
//! Serializes a blob into a BaseTableRef
|
|
28838
|
-
void Serialize(FieldWriter &serializer) const override;
|
|
28839
|
-
//! Deserializes a blob back into a BaseTableRef
|
|
28840
|
-
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
|
28841
|
-
};
|
|
28842
|
-
} // namespace duckdb
|
|
28843
28989
|
|