duckdb 0.5.2-dev12.0 → 0.5.2-dev139.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 +4679 -2859
- package/src/duckdb.hpp +251 -105
- package/src/parquet-amalgamation.cpp +36857 -36855
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.2-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "94bb77371"
|
|
15
|
+
#define DUCKDB_VERSION "v0.5.2-dev139"
|
|
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
|
//===----------------------------------------------------------------------===//
|
|
@@ -27883,6 +27980,53 @@ public:
|
|
|
27883
27980
|
|
|
27884
27981
|
|
|
27885
27982
|
|
|
27983
|
+
//===----------------------------------------------------------------------===//
|
|
27984
|
+
// DuckDB
|
|
27985
|
+
//
|
|
27986
|
+
// duckdb/parser/parsed_data/alter_function_info.hpp
|
|
27987
|
+
//
|
|
27988
|
+
//
|
|
27989
|
+
//===----------------------------------------------------------------------===//
|
|
27990
|
+
|
|
27991
|
+
|
|
27992
|
+
|
|
27993
|
+
|
|
27994
|
+
|
|
27995
|
+
|
|
27996
|
+
|
|
27997
|
+
namespace duckdb {
|
|
27998
|
+
|
|
27999
|
+
//===--------------------------------------------------------------------===//
|
|
28000
|
+
// Alter Table
|
|
28001
|
+
//===--------------------------------------------------------------------===//
|
|
28002
|
+
enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
|
|
28003
|
+
|
|
28004
|
+
struct AlterFunctionInfo : public AlterInfo {
|
|
28005
|
+
AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
|
|
28006
|
+
virtual ~AlterFunctionInfo() override;
|
|
28007
|
+
|
|
28008
|
+
AlterFunctionType alter_function_type;
|
|
28009
|
+
|
|
28010
|
+
public:
|
|
28011
|
+
CatalogType GetCatalogType() const override;
|
|
28012
|
+
void Serialize(FieldWriter &writer) const override;
|
|
28013
|
+
static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
|
|
28014
|
+
};
|
|
28015
|
+
|
|
28016
|
+
//===--------------------------------------------------------------------===//
|
|
28017
|
+
// AddFunctionOverloadInfo
|
|
28018
|
+
//===--------------------------------------------------------------------===//
|
|
28019
|
+
struct AddFunctionOverloadInfo : public AlterFunctionInfo {
|
|
28020
|
+
AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
|
|
28021
|
+
~AddFunctionOverloadInfo() override;
|
|
28022
|
+
|
|
28023
|
+
ScalarFunctionSet new_overloads;
|
|
28024
|
+
|
|
28025
|
+
public:
|
|
28026
|
+
unique_ptr<AlterInfo> Copy() const override;
|
|
28027
|
+
};
|
|
28028
|
+
|
|
28029
|
+
} // namespace duckdb
|
|
27886
28030
|
//===----------------------------------------------------------------------===//
|
|
27887
28031
|
// DuckDB
|
|
27888
28032
|
//
|
|
@@ -28452,14 +28596,16 @@ struct ShowSelectInfo : public ParseInfo {
|
|
|
28452
28596
|
namespace duckdb {
|
|
28453
28597
|
|
|
28454
28598
|
struct CreateTypeInfo : public CreateInfo {
|
|
28455
|
-
|
|
28456
28599
|
CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
|
|
28457
28600
|
}
|
|
28601
|
+
CreateTypeInfo(string name_p, LogicalType type_p)
|
|
28602
|
+
: CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
|
|
28603
|
+
}
|
|
28458
28604
|
|
|
28459
28605
|
//! Name of the Type
|
|
28460
28606
|
string name;
|
|
28461
28607
|
//! Logical Type
|
|
28462
|
-
LogicalType type;
|
|
28608
|
+
LogicalType type;
|
|
28463
28609
|
|
|
28464
28610
|
public:
|
|
28465
28611
|
unique_ptr<CreateInfo> Copy() const override {
|