duckdb 0.7.2-dev717.0 → 0.7.2-dev832.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/binding.gyp +2 -0
- package/lib/duckdb.d.ts +12 -1
- package/lib/duckdb.js +19 -0
- package/package.json +1 -1
- package/src/duckdb/extension/json/include/json_common.hpp +1 -0
- package/src/duckdb/extension/json/include/json_functions.hpp +1 -0
- package/src/duckdb/extension/json/include/json_serializer.hpp +77 -0
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +147 -0
- package/src/duckdb/extension/json/json_functions.cpp +1 -0
- package/src/duckdb/extension/json/json_scan.cpp +2 -2
- package/src/duckdb/extension/json/json_serializer.cpp +217 -0
- package/src/duckdb/src/common/enums/expression_type.cpp +8 -222
- package/src/duckdb/src/common/enums/join_type.cpp +3 -22
- package/src/duckdb/src/common/exception.cpp +2 -2
- package/src/duckdb/src/common/serializer/enum_serializer.cpp +1172 -0
- package/src/duckdb/src/common/types/value.cpp +117 -0
- package/src/duckdb/src/common/types/vector.cpp +140 -1
- package/src/duckdb/src/common/types.cpp +166 -89
- package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +243 -0
- package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +79 -0
- package/src/duckdb/src/function/scalar/string/regexp.cpp +21 -80
- package/src/duckdb/src/function/table/arrow_conversion.cpp +7 -1
- package/src/duckdb/src/function/table/table_scan.cpp +1 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/aggregate_handling.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/expression_type.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/enums/joinref_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/order_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/set_operation_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/exception.hpp +40 -9
- package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/serializer/enum_serializer.hpp +113 -0
- package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +336 -0
- package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +268 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +126 -0
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +12 -0
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types.hpp +8 -2
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +81 -1
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/sample_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/recursive_cte_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +11 -1
- package/src/duckdb/src/include/duckdb/parser/result_modifier.hpp +24 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +6 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/expressionlistref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +3 -1
- package/src/duckdb/src/main/extension/extension_install.cpp +7 -2
- package/src/duckdb/src/optimizer/deliminator.cpp +1 -1
- package/src/duckdb/src/optimizer/filter_combiner.cpp +1 -1
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +3 -3
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +2 -2
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +1 -1
- package/src/duckdb/src/parser/common_table_expression_info.cpp +19 -0
- package/src/duckdb/src/parser/expression/between_expression.cpp +17 -0
- package/src/duckdb/src/parser/expression/case_expression.cpp +28 -0
- package/src/duckdb/src/parser/expression/cast_expression.cpp +17 -0
- package/src/duckdb/src/parser/expression/collate_expression.cpp +16 -0
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +15 -0
- package/src/duckdb/src/parser/expression/comparison_expression.cpp +16 -0
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +15 -0
- package/src/duckdb/src/parser/expression/constant_expression.cpp +14 -0
- package/src/duckdb/src/parser/expression/default_expression.cpp +7 -0
- package/src/duckdb/src/parser/expression/function_expression.cpp +35 -0
- package/src/duckdb/src/parser/expression/lambda_expression.cpp +16 -0
- package/src/duckdb/src/parser/expression/operator_expression.cpp +15 -0
- package/src/duckdb/src/parser/expression/parameter_expression.cpp +15 -0
- package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +14 -0
- package/src/duckdb/src/parser/expression/star_expression.cpp +20 -0
- package/src/duckdb/src/parser/expression/subquery_expression.cpp +20 -0
- package/src/duckdb/src/parser/expression/window_expression.cpp +43 -0
- package/src/duckdb/src/parser/parsed_data/sample_options.cpp +22 -10
- package/src/duckdb/src/parser/parsed_expression.cpp +72 -0
- package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +21 -0
- package/src/duckdb/src/parser/query_node/select_node.cpp +31 -0
- package/src/duckdb/src/parser/query_node/set_operation_node.cpp +17 -0
- package/src/duckdb/src/parser/query_node.cpp +50 -0
- package/src/duckdb/src/parser/result_modifier.cpp +78 -0
- package/src/duckdb/src/parser/statement/select_statement.cpp +12 -0
- package/src/duckdb/src/parser/tableref/basetableref.cpp +21 -0
- package/src/duckdb/src/parser/tableref/emptytableref.cpp +4 -0
- package/src/duckdb/src/parser/tableref/expressionlistref.cpp +17 -0
- package/src/duckdb/src/parser/tableref/joinref.cpp +25 -0
- package/src/duckdb/src/parser/tableref/pivotref.cpp +53 -0
- package/src/duckdb/src/parser/tableref/subqueryref.cpp +15 -0
- package/src/duckdb/src/parser/tableref/table_function.cpp +17 -0
- package/src/duckdb/src/parser/tableref.cpp +46 -0
- package/src/duckdb/src/parser/transform/expression/transform_bool_expr.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -0
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_expression.cpp +4 -0
- package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +0 -1
- package/src/duckdb/third_party/re2/re2/re2.cc +9 -0
- package/src/duckdb/third_party/re2/re2/re2.h +2 -0
- package/src/duckdb/ub_extension_json_json_functions.cpp +2 -0
- package/src/duckdb/ub_src_common_serializer.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_string_regexp.cpp +4 -0
- package/src/duckdb/ub_src_parser.cpp +2 -0
- package/src/utils.cpp +12 -0
- package/test/extension.test.ts +44 -26
@@ -16,14 +16,19 @@
|
|
16
16
|
namespace duckdb {
|
17
17
|
class FieldWriter;
|
18
18
|
class FieldReader;
|
19
|
+
class FormatDeserializer;
|
20
|
+
class FormatSerializer;
|
19
21
|
|
20
|
-
enum ResultModifierType : uint8_t {
|
22
|
+
enum class ResultModifierType : uint8_t {
|
21
23
|
LIMIT_MODIFIER = 1,
|
22
24
|
ORDER_MODIFIER = 2,
|
23
25
|
DISTINCT_MODIFIER = 3,
|
24
26
|
LIMIT_PERCENT_MODIFIER = 4
|
25
27
|
};
|
26
28
|
|
29
|
+
const char *ToString(ResultModifierType value);
|
30
|
+
ResultModifierType ResultModifierFromString(const char *value);
|
31
|
+
|
27
32
|
//! A ResultModifier
|
28
33
|
class ResultModifier {
|
29
34
|
public:
|
@@ -46,6 +51,9 @@ public:
|
|
46
51
|
virtual void Serialize(FieldWriter &writer) const = 0;
|
47
52
|
//! Deserializes a blob back into a ResultModifier
|
48
53
|
static unique_ptr<ResultModifier> Deserialize(Deserializer &source);
|
54
|
+
|
55
|
+
virtual void FormatSerialize(FormatSerializer &serializer) const;
|
56
|
+
static unique_ptr<ResultModifier> FormatDeserialize(FormatDeserializer &deserializer);
|
49
57
|
};
|
50
58
|
|
51
59
|
//! Single node in ORDER BY statement
|
@@ -65,6 +73,9 @@ public:
|
|
65
73
|
void Serialize(Serializer &serializer) const;
|
66
74
|
string ToString() const;
|
67
75
|
static OrderByNode Deserialize(Deserializer &source);
|
76
|
+
|
77
|
+
void FormatSerialize(FormatSerializer &serializer) const;
|
78
|
+
static OrderByNode FormatDeserialize(FormatDeserializer &deserializer);
|
68
79
|
};
|
69
80
|
|
70
81
|
class LimitModifier : public ResultModifier {
|
@@ -82,6 +93,9 @@ public:
|
|
82
93
|
unique_ptr<ResultModifier> Copy() const override;
|
83
94
|
void Serialize(FieldWriter &writer) const override;
|
84
95
|
static unique_ptr<ResultModifier> Deserialize(FieldReader &reader);
|
96
|
+
|
97
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
98
|
+
static unique_ptr<ResultModifier> FormatDeserialize(FormatDeserializer &deserializer);
|
85
99
|
};
|
86
100
|
|
87
101
|
class OrderModifier : public ResultModifier {
|
@@ -97,6 +111,9 @@ public:
|
|
97
111
|
unique_ptr<ResultModifier> Copy() const override;
|
98
112
|
void Serialize(FieldWriter &writer) const override;
|
99
113
|
static unique_ptr<ResultModifier> Deserialize(FieldReader &reader);
|
114
|
+
|
115
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
116
|
+
static unique_ptr<ResultModifier> FormatDeserialize(FormatDeserializer &deserializer);
|
100
117
|
};
|
101
118
|
|
102
119
|
class DistinctModifier : public ResultModifier {
|
@@ -112,6 +129,9 @@ public:
|
|
112
129
|
unique_ptr<ResultModifier> Copy() const override;
|
113
130
|
void Serialize(FieldWriter &writer) const override;
|
114
131
|
static unique_ptr<ResultModifier> Deserialize(FieldReader &reader);
|
132
|
+
|
133
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
134
|
+
static unique_ptr<ResultModifier> FormatDeserialize(FormatDeserializer &deserializer);
|
115
135
|
};
|
116
136
|
|
117
137
|
class LimitPercentModifier : public ResultModifier {
|
@@ -129,6 +149,9 @@ public:
|
|
129
149
|
unique_ptr<ResultModifier> Copy() const override;
|
130
150
|
void Serialize(FieldWriter &writer) const override;
|
131
151
|
static unique_ptr<ResultModifier> Deserialize(FieldReader &reader);
|
152
|
+
|
153
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
154
|
+
static unique_ptr<ResultModifier> FormatDeserialize(FormatDeserializer &deserializer);
|
132
155
|
};
|
133
156
|
|
134
157
|
} // namespace duckdb
|
@@ -19,7 +19,8 @@ namespace duckdb {
|
|
19
19
|
//! SQLStatement is the base class of any type of SQL statement.
|
20
20
|
class SQLStatement {
|
21
21
|
public:
|
22
|
-
explicit SQLStatement(StatementType type) : type(type) {
|
22
|
+
explicit SQLStatement(StatementType type) : type(type) {
|
23
|
+
}
|
23
24
|
virtual ~SQLStatement() {
|
24
25
|
}
|
25
26
|
|
@@ -10,13 +10,15 @@
|
|
10
10
|
|
11
11
|
#include "duckdb/common/unordered_map.hpp"
|
12
12
|
#include "duckdb/parser/parsed_expression.hpp"
|
13
|
-
#include "duckdb/parser/query_node.hpp"
|
14
13
|
#include "duckdb/parser/sql_statement.hpp"
|
15
14
|
#include "duckdb/parser/tableref.hpp"
|
15
|
+
#include "duckdb/parser/query_node.hpp"
|
16
16
|
|
17
17
|
namespace duckdb {
|
18
18
|
|
19
19
|
class QueryNode;
|
20
|
+
class FormatSerializer;
|
21
|
+
class FormatDeserializer;
|
20
22
|
|
21
23
|
//! SelectStatement is a typical SELECT clause
|
22
24
|
class SelectStatement : public SQLStatement {
|
@@ -42,5 +44,8 @@ public:
|
|
42
44
|
static unique_ptr<SelectStatement> Deserialize(Deserializer &source);
|
43
45
|
//! Whether or not the statements are equivalent
|
44
46
|
bool Equals(const SQLStatement *other) const;
|
47
|
+
|
48
|
+
void FormatSerialize(FormatSerializer &serializer) const;
|
49
|
+
static unique_ptr<SelectStatement> FormatDeserialize(FormatDeserializer &deserializer);
|
45
50
|
};
|
46
51
|
} // namespace duckdb
|
@@ -38,5 +38,9 @@ public:
|
|
38
38
|
void Serialize(FieldWriter &serializer) const override;
|
39
39
|
//! Deserializes a blob back into a BaseTableRef
|
40
40
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
41
|
+
|
42
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
43
|
+
|
44
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
41
45
|
};
|
42
46
|
} // namespace duckdb
|
@@ -27,5 +27,7 @@ public:
|
|
27
27
|
void Serialize(FieldWriter &serializer) const override;
|
28
28
|
//! Deserializes a blob back into a DummyTableRef
|
29
29
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
30
|
+
|
31
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
30
32
|
};
|
31
33
|
} // namespace duckdb
|
@@ -37,5 +37,8 @@ public:
|
|
37
37
|
void Serialize(FieldWriter &serializer) const override;
|
38
38
|
//! Deserializes a blob back into a ExpressionListRef
|
39
39
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
40
|
+
|
41
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
42
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
40
43
|
};
|
41
44
|
} // namespace duckdb
|
@@ -47,5 +47,8 @@ public:
|
|
47
47
|
void Serialize(FieldWriter &serializer) const override;
|
48
48
|
//! Deserializes a blob back into a JoinRef
|
49
49
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
50
|
+
|
51
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
52
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
50
53
|
};
|
51
54
|
} // namespace duckdb
|
@@ -24,6 +24,9 @@ struct PivotColumnEntry {
|
|
24
24
|
void Serialize(Serializer &serializer) const;
|
25
25
|
PivotColumnEntry Copy() const;
|
26
26
|
static PivotColumnEntry Deserialize(Deserializer &source);
|
27
|
+
|
28
|
+
void FormatSerialize(FormatSerializer &serializer) const;
|
29
|
+
static PivotColumnEntry FormatDeserialize(FormatDeserializer &source);
|
27
30
|
};
|
28
31
|
|
29
32
|
struct PivotColumn {
|
@@ -39,6 +42,9 @@ struct PivotColumn {
|
|
39
42
|
void Serialize(Serializer &serializer) const;
|
40
43
|
PivotColumn Copy() const;
|
41
44
|
static PivotColumn Deserialize(Deserializer &source);
|
45
|
+
|
46
|
+
void FormatSerialize(FormatSerializer &serializer) const;
|
47
|
+
static PivotColumn FormatDeserialize(FormatDeserializer &source);
|
42
48
|
};
|
43
49
|
|
44
50
|
//! Represents a PIVOT or UNPIVOT expression
|
@@ -72,5 +78,8 @@ public:
|
|
72
78
|
void Serialize(FieldWriter &serializer) const override;
|
73
79
|
//! Deserializes a blob back into a JoinRef
|
74
80
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
81
|
+
|
82
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
83
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
75
84
|
};
|
76
85
|
} // namespace duckdb
|
@@ -32,5 +32,8 @@ public:
|
|
32
32
|
void Serialize(FieldWriter &serializer) const override;
|
33
33
|
//! Deserializes a blob back into a SubqueryRef
|
34
34
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
35
|
+
|
36
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
37
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
35
38
|
};
|
36
39
|
} // namespace duckdb
|
@@ -40,5 +40,8 @@ public:
|
|
40
40
|
void Serialize(FieldWriter &serializer) const override;
|
41
41
|
//! Deserializes a blob back into a BaseTableRef
|
42
42
|
static unique_ptr<TableRef> Deserialize(FieldReader &source);
|
43
|
+
|
44
|
+
void FormatSerialize(FormatSerializer &serializer) const override;
|
45
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source);
|
43
46
|
};
|
44
47
|
} // namespace duckdb
|
@@ -48,8 +48,10 @@ public:
|
|
48
48
|
DUCKDB_API virtual void Serialize(FieldWriter &writer) const = 0;
|
49
49
|
//! Deserializes a blob back into a TableRef
|
50
50
|
DUCKDB_API static unique_ptr<TableRef> Deserialize(Deserializer &source);
|
51
|
-
|
52
51
|
//! Copy the properties of this table ref to the target
|
53
52
|
void CopyProperties(TableRef &target) const;
|
53
|
+
|
54
|
+
virtual void FormatSerialize(FormatSerializer &serializer) const;
|
55
|
+
static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &deserializer);
|
54
56
|
};
|
55
57
|
} // namespace duckdb
|
@@ -206,8 +206,13 @@ void ExtensionHelper::InstallExtensionInternal(DBConfig &config, ClientConfig *c
|
|
206
206
|
if (exact_match) {
|
207
207
|
message += "\nAre you using a development build? In this case, extensions might not (yet) be uploaded.";
|
208
208
|
}
|
209
|
-
|
210
|
-
|
209
|
+
if (res.error() == duckdb_httplib::Error::Success) {
|
210
|
+
throw HTTPException(res.value(), "Failed to download extension \"%s\" at URL \"%s%s\"\n%s", extension_name,
|
211
|
+
url_base, url_local_part, message);
|
212
|
+
} else {
|
213
|
+
throw IOException("Failed to download extension \"%s\" at URL \"%s%s\"\n%s (ERROR %s)", extension_name,
|
214
|
+
url_base, url_local_part, message, to_string(res.error()));
|
215
|
+
}
|
211
216
|
}
|
212
217
|
auto decompressed_body = GZipFileSystem::UncompressGZIPString(res->body);
|
213
218
|
std::ofstream out(temp_path, std::ios::binary);
|
@@ -424,7 +424,7 @@ bool Deliminator::RemoveInequalityCandidate(unique_ptr<LogicalOperator> *plan, u
|
|
424
424
|
parent_expr =
|
425
425
|
make_unique<BoundColumnRefExpression>(parent_expr->alias, parent_expr->return_type, it->first);
|
426
426
|
parent_cond.comparison =
|
427
|
-
parent_delim_get_side == 0 ? child_cond.comparison :
|
427
|
+
parent_delim_get_side == 0 ? child_cond.comparison : FlipComparisonExpression(child_cond.comparison);
|
428
428
|
break;
|
429
429
|
}
|
430
430
|
}
|
@@ -604,7 +604,7 @@ FilterResult FilterCombiner::AddBoundComparisonFilter(Expression *expr) {
|
|
604
604
|
|
605
605
|
// create the ExpressionValueInformation
|
606
606
|
ExpressionValueInformation info;
|
607
|
-
info.comparison_type = left_is_scalar ?
|
607
|
+
info.comparison_type = left_is_scalar ? FlipComparisonExpression(comparison.type) : comparison.type;
|
608
608
|
info.constant = constant_value;
|
609
609
|
|
610
610
|
// get the current bucket of constant values
|
@@ -138,7 +138,7 @@ bool JoinOrderOptimizer::ExtractJoinRelations(LogicalOperator &input_op, vector<
|
|
138
138
|
std::swap(join.children[0], join.children[1]);
|
139
139
|
for (auto &cond : join.conditions) {
|
140
140
|
std::swap(cond.left, cond.right);
|
141
|
-
cond.comparison =
|
141
|
+
cond.comparison = FlipComparisonExpression(cond.comparison);
|
142
142
|
}
|
143
143
|
}
|
144
144
|
}
|
@@ -769,7 +769,7 @@ JoinOrderOptimizer::GenerateJoins(vector<unique_ptr<LogicalOperator>> &extracted
|
|
769
769
|
|
770
770
|
if (invert) {
|
771
771
|
// reverse comparison expression if we reverse the order of the children
|
772
|
-
cond.comparison =
|
772
|
+
cond.comparison = FlipComparisonExpression(cond.comparison);
|
773
773
|
}
|
774
774
|
join->conditions.push_back(std::move(cond));
|
775
775
|
}
|
@@ -846,7 +846,7 @@ JoinOrderOptimizer::GenerateJoins(vector<unique_ptr<LogicalOperator>> &extracted
|
|
846
846
|
cond.comparison = comparison.type;
|
847
847
|
if (invert) {
|
848
848
|
// reverse comparison expression if we reverse the order of the children
|
849
|
-
cond.comparison =
|
849
|
+
cond.comparison = FlipComparisonExpression(comparison.type);
|
850
850
|
}
|
851
851
|
// now find the join to push it into
|
852
852
|
auto node = result_operator.get();
|
@@ -99,7 +99,7 @@ unique_ptr<Expression> MoveConstantsRule::Apply(LogicalOperator &op, vector<Expr
|
|
99
99
|
outer_constant->value = std::move(result_value);
|
100
100
|
// in this case, we should also flip the comparison
|
101
101
|
// e.g. if we have [4 - x < 2] then we should have [x > 2]
|
102
|
-
comparison->type =
|
102
|
+
comparison->type = FlipComparisonExpression(comparison->type);
|
103
103
|
}
|
104
104
|
} else {
|
105
105
|
D_ASSERT(op_type == "*");
|
@@ -129,7 +129,7 @@ unique_ptr<Expression> MoveConstantsRule::Apply(LogicalOperator &op, vector<Expr
|
|
129
129
|
}
|
130
130
|
if (inner_value < 0) {
|
131
131
|
// multiply by negative value, need to flip expression
|
132
|
-
comparison->type =
|
132
|
+
comparison->type = FlipComparisonExpression(comparison->type);
|
133
133
|
}
|
134
134
|
// else divide the RHS by the LHS
|
135
135
|
// we need to do a range check on the cast even though we do a division
|
@@ -165,7 +165,7 @@ void StatisticsPropagator::UpdateFilterStatistics(Expression &left, Expression &
|
|
165
165
|
if (left.type == ExpressionType::VALUE_CONSTANT && right.type == ExpressionType::BOUND_COLUMN_REF) {
|
166
166
|
constant = (BoundConstantExpression *)&left;
|
167
167
|
columnref = (BoundColumnRefExpression *)&right;
|
168
|
-
comparison_type =
|
168
|
+
comparison_type = FlipComparisonExpression(comparison_type);
|
169
169
|
} else if (left.type == ExpressionType::BOUND_COLUMN_REF && right.type == ExpressionType::VALUE_CONSTANT) {
|
170
170
|
columnref = (BoundColumnRefExpression *)&left;
|
171
171
|
constant = (BoundConstantExpression *)&right;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#include "duckdb/parser/common_table_expression_info.hpp"
|
2
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
3
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
4
|
+
|
5
|
+
namespace duckdb {
|
6
|
+
|
7
|
+
void CommonTableExpressionInfo::FormatSerialize(FormatSerializer &serializer) const {
|
8
|
+
serializer.WriteProperty("aliases", aliases);
|
9
|
+
serializer.WriteProperty("query", query);
|
10
|
+
}
|
11
|
+
|
12
|
+
unique_ptr<CommonTableExpressionInfo> CommonTableExpressionInfo::FormatDeserialize(FormatDeserializer &deserializer) {
|
13
|
+
auto result = make_unique<CommonTableExpressionInfo>();
|
14
|
+
result->aliases = deserializer.ReadProperty<vector<string>>("aliases");
|
15
|
+
result->query = deserializer.ReadProperty<unique_ptr<SelectStatement>>("query");
|
16
|
+
return result;
|
17
|
+
}
|
18
|
+
|
19
|
+
} // namespace duckdb
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/parser/expression/between_expression.hpp"
|
2
2
|
#include "duckdb/common/field_writer.hpp"
|
3
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
4
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
3
5
|
|
4
6
|
namespace duckdb {
|
5
7
|
|
@@ -45,4 +47,19 @@ unique_ptr<ParsedExpression> BetweenExpression::Deserialize(ExpressionType type,
|
|
45
47
|
return make_unique<BetweenExpression>(std::move(input), std::move(lower), std::move(upper));
|
46
48
|
}
|
47
49
|
|
50
|
+
void BetweenExpression::FormatSerialize(FormatSerializer &serializer) const {
|
51
|
+
ParsedExpression::FormatSerialize(serializer);
|
52
|
+
serializer.WriteProperty("input", *input);
|
53
|
+
serializer.WriteProperty("lower", *lower);
|
54
|
+
serializer.WriteProperty("upper", *upper);
|
55
|
+
}
|
56
|
+
|
57
|
+
unique_ptr<ParsedExpression> BetweenExpression::FormatDeserialize(ExpressionType type,
|
58
|
+
FormatDeserializer &deserializer) {
|
59
|
+
auto input = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("input");
|
60
|
+
auto lower = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("lower");
|
61
|
+
auto upper = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("upper");
|
62
|
+
return make_unique<BetweenExpression>(std::move(input), std::move(lower), std::move(upper));
|
63
|
+
}
|
64
|
+
|
48
65
|
} // namespace duckdb
|
@@ -3,8 +3,23 @@
|
|
3
3
|
#include "duckdb/common/exception.hpp"
|
4
4
|
#include "duckdb/common/field_writer.hpp"
|
5
5
|
|
6
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
7
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
8
|
+
|
6
9
|
namespace duckdb {
|
7
10
|
|
11
|
+
void CaseCheck::FormatSerialize(FormatSerializer &serializer) const {
|
12
|
+
serializer.WriteProperty("when_expr", when_expr);
|
13
|
+
serializer.WriteProperty("then_expr", then_expr);
|
14
|
+
}
|
15
|
+
|
16
|
+
CaseCheck CaseCheck::FormatDeserialize(FormatDeserializer &deserializer) {
|
17
|
+
CaseCheck check;
|
18
|
+
deserializer.ReadProperty("when_expr", check.when_expr);
|
19
|
+
deserializer.ReadProperty("then_expr", check.then_expr);
|
20
|
+
return check;
|
21
|
+
}
|
22
|
+
|
8
23
|
CaseExpression::CaseExpression() : ParsedExpression(ExpressionType::CASE_EXPR, ExpressionClass::CASE) {
|
9
24
|
}
|
10
25
|
|
@@ -69,4 +84,17 @@ unique_ptr<ParsedExpression> CaseExpression::Deserialize(ExpressionType type, Fi
|
|
69
84
|
return std::move(result);
|
70
85
|
}
|
71
86
|
|
87
|
+
void CaseExpression::FormatSerialize(FormatSerializer &serializer) const {
|
88
|
+
ParsedExpression::FormatSerialize(serializer);
|
89
|
+
serializer.WriteProperty("case_checks", case_checks);
|
90
|
+
serializer.WriteProperty("else_expr", *else_expr);
|
91
|
+
}
|
92
|
+
|
93
|
+
unique_ptr<ParsedExpression> CaseExpression::FormatDeserialize(ExpressionType type, FormatDeserializer &deserializer) {
|
94
|
+
auto result = make_unique<CaseExpression>();
|
95
|
+
deserializer.ReadProperty("case_checks", result->case_checks);
|
96
|
+
deserializer.ReadProperty("else_expr", result->else_expr);
|
97
|
+
return std::move(result);
|
98
|
+
}
|
99
|
+
|
72
100
|
} // namespace duckdb
|
@@ -3,6 +3,9 @@
|
|
3
3
|
#include "duckdb/common/exception.hpp"
|
4
4
|
#include "duckdb/common/field_writer.hpp"
|
5
5
|
|
6
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
7
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
8
|
+
|
6
9
|
namespace duckdb {
|
7
10
|
|
8
11
|
CastExpression::CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast_p)
|
@@ -48,4 +51,18 @@ unique_ptr<ParsedExpression> CastExpression::Deserialize(ExpressionType type, Fi
|
|
48
51
|
return make_unique_base<ParsedExpression, CastExpression>(cast_type, std::move(child), try_cast);
|
49
52
|
}
|
50
53
|
|
54
|
+
void CastExpression::FormatSerialize(FormatSerializer &serializer) const {
|
55
|
+
ParsedExpression::FormatSerialize(serializer);
|
56
|
+
serializer.WriteProperty("child", *child);
|
57
|
+
serializer.WriteProperty("cast_type", cast_type);
|
58
|
+
serializer.WriteProperty("try_cast", try_cast);
|
59
|
+
}
|
60
|
+
|
61
|
+
unique_ptr<ParsedExpression> CastExpression::FormatDeserialize(ExpressionType type, FormatDeserializer &deserializer) {
|
62
|
+
auto child = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("child");
|
63
|
+
auto cast_type = deserializer.ReadProperty<LogicalType>("cast_type");
|
64
|
+
auto try_cast = deserializer.ReadProperty<bool>("try_cast");
|
65
|
+
return make_unique_base<ParsedExpression, CastExpression>(cast_type, std::move(child), try_cast);
|
66
|
+
}
|
67
|
+
|
51
68
|
} // namespace duckdb
|
@@ -3,6 +3,9 @@
|
|
3
3
|
#include "duckdb/common/exception.hpp"
|
4
4
|
#include "duckdb/common/field_writer.hpp"
|
5
5
|
|
6
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
7
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
8
|
+
|
6
9
|
namespace duckdb {
|
7
10
|
|
8
11
|
CollateExpression::CollateExpression(string collation_p, unique_ptr<ParsedExpression> child)
|
@@ -42,4 +45,17 @@ unique_ptr<ParsedExpression> CollateExpression::Deserialize(ExpressionType type,
|
|
42
45
|
return make_unique_base<ParsedExpression, CollateExpression>(collation, std::move(child));
|
43
46
|
}
|
44
47
|
|
48
|
+
void CollateExpression::FormatSerialize(FormatSerializer &serializer) const {
|
49
|
+
ParsedExpression::FormatSerialize(serializer);
|
50
|
+
serializer.WriteProperty("child", *child);
|
51
|
+
serializer.WriteProperty("collation", collation);
|
52
|
+
}
|
53
|
+
|
54
|
+
unique_ptr<ParsedExpression> CollateExpression::FormatDeserialize(ExpressionType type,
|
55
|
+
FormatDeserializer &deserializer) {
|
56
|
+
auto child = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("child");
|
57
|
+
auto collation = deserializer.ReadProperty<string>("collation");
|
58
|
+
return make_unique_base<ParsedExpression, CollateExpression>(collation, std::move(child));
|
59
|
+
}
|
60
|
+
|
45
61
|
} // namespace duckdb
|
@@ -5,6 +5,9 @@
|
|
5
5
|
#include "duckdb/common/string_util.hpp"
|
6
6
|
#include "duckdb/parser/qualified_name.hpp"
|
7
7
|
|
8
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
9
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
10
|
+
|
8
11
|
namespace duckdb {
|
9
12
|
|
10
13
|
ColumnRefExpression::ColumnRefExpression(string column_name, string table_name)
|
@@ -100,4 +103,16 @@ unique_ptr<ParsedExpression> ColumnRefExpression::Deserialize(ExpressionType typ
|
|
100
103
|
return std::move(expression);
|
101
104
|
}
|
102
105
|
|
106
|
+
void ColumnRefExpression::FormatSerialize(FormatSerializer &serializer) const {
|
107
|
+
ParsedExpression::FormatSerialize(serializer);
|
108
|
+
serializer.WriteProperty("column_names", column_names);
|
109
|
+
}
|
110
|
+
|
111
|
+
unique_ptr<ParsedExpression> ColumnRefExpression::FormatDeserialize(ExpressionType type,
|
112
|
+
FormatDeserializer &deserializer) {
|
113
|
+
auto column_names = deserializer.ReadProperty<vector<string>>("column_names");
|
114
|
+
auto expression = make_unique<ColumnRefExpression>(std::move(column_names));
|
115
|
+
return std::move(expression);
|
116
|
+
}
|
117
|
+
|
103
118
|
} // namespace duckdb
|
@@ -4,6 +4,9 @@
|
|
4
4
|
#include "duckdb/common/field_writer.hpp"
|
5
5
|
#include "duckdb/parser/expression/cast_expression.hpp"
|
6
6
|
|
7
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
8
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
9
|
+
|
7
10
|
namespace duckdb {
|
8
11
|
|
9
12
|
ComparisonExpression::ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
|
@@ -42,4 +45,17 @@ unique_ptr<ParsedExpression> ComparisonExpression::Deserialize(ExpressionType ty
|
|
42
45
|
return make_unique<ComparisonExpression>(type, std::move(left_child), std::move(right_child));
|
43
46
|
}
|
44
47
|
|
48
|
+
void ComparisonExpression::FormatSerialize(FormatSerializer &serializer) const {
|
49
|
+
ParsedExpression::FormatSerialize(serializer);
|
50
|
+
serializer.WriteProperty("left", *left);
|
51
|
+
serializer.WriteProperty("right", *right);
|
52
|
+
}
|
53
|
+
|
54
|
+
unique_ptr<ParsedExpression> ComparisonExpression::FormatDeserialize(ExpressionType type,
|
55
|
+
FormatDeserializer &deserializer) {
|
56
|
+
auto left = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("left");
|
57
|
+
auto right = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("right");
|
58
|
+
return make_unique<ComparisonExpression>(type, std::move(left), std::move(right));
|
59
|
+
}
|
60
|
+
|
45
61
|
} // namespace duckdb
|
@@ -3,6 +3,9 @@
|
|
3
3
|
#include "duckdb/common/field_writer.hpp"
|
4
4
|
#include "duckdb/parser/expression_util.hpp"
|
5
5
|
|
6
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
7
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
8
|
+
|
6
9
|
namespace duckdb {
|
7
10
|
|
8
11
|
ConjunctionExpression::ConjunctionExpression(ExpressionType type)
|
@@ -65,4 +68,16 @@ unique_ptr<ParsedExpression> ConjunctionExpression::Deserialize(ExpressionType t
|
|
65
68
|
return std::move(result);
|
66
69
|
}
|
67
70
|
|
71
|
+
void ConjunctionExpression::FormatSerialize(FormatSerializer &serializer) const {
|
72
|
+
ParsedExpression::FormatSerialize(serializer);
|
73
|
+
serializer.WriteProperty("children", children);
|
74
|
+
}
|
75
|
+
|
76
|
+
unique_ptr<ParsedExpression> ConjunctionExpression::FormatDeserialize(ExpressionType type,
|
77
|
+
FormatDeserializer &deserializer) {
|
78
|
+
auto result = make_unique<ConjunctionExpression>(type);
|
79
|
+
result->children = deserializer.ReadProperty<vector<unique_ptr<ParsedExpression>>>("children");
|
80
|
+
return std::move(result);
|
81
|
+
}
|
82
|
+
|
68
83
|
} // namespace duckdb
|
@@ -5,6 +5,9 @@
|
|
5
5
|
#include "duckdb/common/types/hash.hpp"
|
6
6
|
#include "duckdb/common/value_operations/value_operations.hpp"
|
7
7
|
|
8
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
9
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
10
|
+
|
8
11
|
namespace duckdb {
|
9
12
|
|
10
13
|
ConstantExpression::ConstantExpression(Value val)
|
@@ -38,4 +41,15 @@ unique_ptr<ParsedExpression> ConstantExpression::Deserialize(ExpressionType type
|
|
38
41
|
return make_unique<ConstantExpression>(std::move(value));
|
39
42
|
}
|
40
43
|
|
44
|
+
void ConstantExpression::FormatSerialize(FormatSerializer &serializer) const {
|
45
|
+
ParsedExpression::FormatSerialize(serializer);
|
46
|
+
serializer.WriteProperty("value", value);
|
47
|
+
}
|
48
|
+
|
49
|
+
unique_ptr<ParsedExpression> ConstantExpression::FormatDeserialize(ExpressionType type,
|
50
|
+
FormatDeserializer &deserializer) {
|
51
|
+
auto value = deserializer.ReadProperty<Value>("value");
|
52
|
+
return make_unique<ConstantExpression>(std::move(value));
|
53
|
+
}
|
54
|
+
|
41
55
|
} // namespace duckdb
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
#include "duckdb/common/exception.hpp"
|
4
4
|
|
5
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
6
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
7
|
+
|
5
8
|
namespace duckdb {
|
6
9
|
|
7
10
|
DefaultExpression::DefaultExpression() : ParsedExpression(ExpressionType::VALUE_DEFAULT, ExpressionClass::DEFAULT) {
|
@@ -24,4 +27,8 @@ unique_ptr<ParsedExpression> DefaultExpression::Deserialize(ExpressionType type,
|
|
24
27
|
return make_unique<DefaultExpression>();
|
25
28
|
}
|
26
29
|
|
30
|
+
void DefaultExpression::FormatSerialize(FormatSerializer &serializer) const {
|
31
|
+
ParsedExpression::FormatSerialize(serializer);
|
32
|
+
}
|
33
|
+
|
27
34
|
} // namespace duckdb
|
@@ -6,6 +6,9 @@
|
|
6
6
|
#include "duckdb/common/field_writer.hpp"
|
7
7
|
#include "duckdb/common/types/hash.hpp"
|
8
8
|
|
9
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
10
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
11
|
+
|
9
12
|
namespace duckdb {
|
10
13
|
|
11
14
|
FunctionExpression::FunctionExpression(string catalog, string schema, const string &function_name,
|
@@ -122,4 +125,36 @@ void FunctionExpression::Verify() const {
|
|
122
125
|
D_ASSERT(!function_name.empty());
|
123
126
|
}
|
124
127
|
|
128
|
+
void FunctionExpression::FormatSerialize(FormatSerializer &serializer) const {
|
129
|
+
ParsedExpression::FormatSerialize(serializer);
|
130
|
+
serializer.WriteProperty("function_name", function_name);
|
131
|
+
serializer.WriteProperty("schema", schema);
|
132
|
+
serializer.WriteProperty("children", children);
|
133
|
+
serializer.WriteOptionalProperty("filter", filter);
|
134
|
+
serializer.WriteProperty("order_bys", (ResultModifier &)*order_bys);
|
135
|
+
serializer.WriteProperty("distinct", distinct);
|
136
|
+
serializer.WriteProperty("is_operator", is_operator);
|
137
|
+
serializer.WriteProperty("export_state", export_state);
|
138
|
+
serializer.WriteProperty("catalog", catalog);
|
139
|
+
}
|
140
|
+
|
141
|
+
unique_ptr<ParsedExpression> FunctionExpression::FormatDeserialize(ExpressionType type,
|
142
|
+
FormatDeserializer &deserializer) {
|
143
|
+
auto function_name = deserializer.ReadProperty<string>("function_name");
|
144
|
+
auto schema = deserializer.ReadProperty<string>("schema");
|
145
|
+
auto children = deserializer.ReadProperty<vector<unique_ptr<ParsedExpression>>>("children");
|
146
|
+
auto filter = deserializer.ReadOptionalProperty<unique_ptr<ParsedExpression>>("filter");
|
147
|
+
auto order_bys = unique_ptr_cast<ResultModifier, OrderModifier>(
|
148
|
+
deserializer.ReadProperty<unique_ptr<ResultModifier>>("order_bys"));
|
149
|
+
auto distinct = deserializer.ReadProperty<bool>("distinct");
|
150
|
+
auto is_operator = deserializer.ReadProperty<bool>("is_operator");
|
151
|
+
auto export_state = deserializer.ReadProperty<bool>("export_state");
|
152
|
+
auto catalog = deserializer.ReadProperty<string>("catalog");
|
153
|
+
|
154
|
+
unique_ptr<FunctionExpression> function;
|
155
|
+
function = make_unique<FunctionExpression>(catalog, schema, function_name, std::move(children), std::move(filter),
|
156
|
+
std::move(order_bys), distinct, is_operator, export_state);
|
157
|
+
return std::move(function);
|
158
|
+
}
|
159
|
+
|
125
160
|
} // namespace duckdb
|