duckdb 0.7.2-dev1867.0 → 0.7.2-dev1901.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/data_chunk.cpp +13 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +2 -2
- package/src/duckdb/src/common/sort/sorted_block.cpp +9 -4
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +4 -0
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +169 -60
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +15 -9
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +1 -7
- package/src/duckdb/src/include/duckdb/parser/parser_options.hpp +23 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -3
- package/src/duckdb/src/main/client_context.cpp +4 -2
- package/src/duckdb/src/main/config.cpp +2 -0
- package/src/duckdb/src/main/settings/settings.cpp +36 -0
- package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +4 -3
- package/src/duckdb/src/parser/parser.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +7 -3
- package/src/duckdb/src/parser/transformer.cpp +6 -5
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +949 -947
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +16431 -16385
- package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +503 -493
- package/test/udf.test.ts +9 -0
@@ -1144,9 +1144,11 @@ bool ClientContext::TryGetCurrentSetting(const std::string &key, Value &result)
|
|
1144
1144
|
}
|
1145
1145
|
|
1146
1146
|
ParserOptions ClientContext::GetParserOptions() const {
|
1147
|
+
auto &client_config = ClientConfig::GetConfig(*this);
|
1147
1148
|
ParserOptions options;
|
1148
|
-
options.preserve_identifier_case =
|
1149
|
-
options.
|
1149
|
+
options.preserve_identifier_case = client_config.preserve_identifier_case;
|
1150
|
+
options.integer_division = client_config.integer_division;
|
1151
|
+
options.max_expression_depth = client_config.max_expression_depth;
|
1150
1152
|
options.extensions = &DBConfig::GetConfig(*this).parser_extensions;
|
1151
1153
|
return options;
|
1152
1154
|
}
|
@@ -78,10 +78,12 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
78
78
|
DUCKDB_LOCAL(HomeDirectorySetting),
|
79
79
|
DUCKDB_LOCAL(LogQueryPathSetting),
|
80
80
|
DUCKDB_GLOBAL(ImmediateTransactionModeSetting),
|
81
|
+
DUCKDB_LOCAL(IntegerDivisionSetting),
|
81
82
|
DUCKDB_LOCAL(MaximumExpressionDepthSetting),
|
82
83
|
DUCKDB_GLOBAL(MaximumMemorySetting),
|
83
84
|
DUCKDB_GLOBAL_ALIAS("memory_limit", MaximumMemorySetting),
|
84
85
|
DUCKDB_GLOBAL_ALIAS("null_order", DefaultNullOrderSetting),
|
86
|
+
DUCKDB_LOCAL(OrderedAggregateThreshold),
|
85
87
|
DUCKDB_GLOBAL(PasswordSetting),
|
86
88
|
DUCKDB_LOCAL(PerfectHashThresholdSetting),
|
87
89
|
DUCKDB_LOCAL(PivotLimitSetting),
|
@@ -141,6 +141,26 @@ Value DebugForceNoCrossProduct::GetSetting(ClientContext &context) {
|
|
141
141
|
return Value::BOOLEAN(ClientConfig::GetConfig(context).force_no_cross_product);
|
142
142
|
}
|
143
143
|
|
144
|
+
//===--------------------------------------------------------------------===//
|
145
|
+
// Debug Ordered Aggregate Threshold
|
146
|
+
//===--------------------------------------------------------------------===//
|
147
|
+
|
148
|
+
void OrderedAggregateThreshold::ResetLocal(ClientContext &context) {
|
149
|
+
ClientConfig::GetConfig(context).ordered_aggregate_threshold = ClientConfig().ordered_aggregate_threshold;
|
150
|
+
}
|
151
|
+
|
152
|
+
void OrderedAggregateThreshold::SetLocal(ClientContext &context, const Value &input) {
|
153
|
+
const auto param = input.GetValue<uint64_t>();
|
154
|
+
if (!param) {
|
155
|
+
throw ParserException("Invalid option for PRAGMA ordered_aggregate_threshold, value must be positive");
|
156
|
+
}
|
157
|
+
ClientConfig::GetConfig(context).ordered_aggregate_threshold = param;
|
158
|
+
}
|
159
|
+
|
160
|
+
Value OrderedAggregateThreshold::GetSetting(ClientContext &context) {
|
161
|
+
return Value::UBIGINT(ClientConfig::GetConfig(context).ordered_aggregate_threshold);
|
162
|
+
}
|
163
|
+
|
144
164
|
//===--------------------------------------------------------------------===//
|
145
165
|
// Debug Window Mode
|
146
166
|
//===--------------------------------------------------------------------===//
|
@@ -660,6 +680,22 @@ Value HomeDirectorySetting::GetSetting(ClientContext &context) {
|
|
660
680
|
return Value(config.home_directory);
|
661
681
|
}
|
662
682
|
|
683
|
+
//===--------------------------------------------------------------------===//
|
684
|
+
// Integer Division
|
685
|
+
//===--------------------------------------------------------------------===//
|
686
|
+
void IntegerDivisionSetting::ResetLocal(ClientContext &context) {
|
687
|
+
ClientConfig::GetConfig(context).integer_division = ClientConfig().integer_division;
|
688
|
+
}
|
689
|
+
|
690
|
+
void IntegerDivisionSetting::SetLocal(ClientContext &context, const Value &input) {
|
691
|
+
auto &config = ClientConfig::GetConfig(context);
|
692
|
+
config.integer_division = input.GetValue<bool>();
|
693
|
+
}
|
694
|
+
|
695
|
+
Value IntegerDivisionSetting::GetSetting(ClientContext &context) {
|
696
|
+
auto &config = ClientConfig::GetConfig(context);
|
697
|
+
return Value(config.integer_division);
|
698
|
+
}
|
663
699
|
//===--------------------------------------------------------------------===//
|
664
700
|
// Log Query Path
|
665
701
|
//===--------------------------------------------------------------------===//
|
@@ -14,7 +14,7 @@ ArithmeticSimplificationRule::ArithmeticSimplificationRule(ExpressionRewriter &r
|
|
14
14
|
op->matchers.push_back(make_uniq<ExpressionMatcher>());
|
15
15
|
op->policy = SetMatcher::Policy::SOME;
|
16
16
|
// we only match on simple arithmetic expressions (+, -, *, /)
|
17
|
-
op->function = make_uniq<ManyFunctionMatcher>(unordered_set<string> {"+", "-", "*", "
|
17
|
+
op->function = make_uniq<ManyFunctionMatcher>(unordered_set<string> {"+", "-", "*", "//"});
|
18
18
|
// and only with numeric results
|
19
19
|
op->type = make_uniq<IntegerTypeMatcher>();
|
20
20
|
op->matchers[0]->type = make_uniq<IntegerTypeMatcher>();
|
@@ -55,8 +55,7 @@ unique_ptr<Expression> ArithmeticSimplificationRule::Apply(LogicalOperator &op,
|
|
55
55
|
return ExpressionRewriter::ConstantOrNull(std::move(root.children[1 - constant_child]),
|
56
56
|
Value::Numeric(root.return_type, 0));
|
57
57
|
}
|
58
|
-
} else {
|
59
|
-
D_ASSERT(func_name == "/");
|
58
|
+
} else if (func_name == "//") {
|
60
59
|
if (constant_child == 1) {
|
61
60
|
if (constant.value == 1) {
|
62
61
|
// divide by 1, replace with non-constant child
|
@@ -66,6 +65,8 @@ unique_ptr<Expression> ArithmeticSimplificationRule::Apply(LogicalOperator &op,
|
|
66
65
|
return make_uniq<BoundConstantExpression>(Value(root.return_type));
|
67
66
|
}
|
68
67
|
}
|
68
|
+
} else {
|
69
|
+
throw InternalException("Unrecognized function name in ArithmeticSimplificationRule");
|
69
70
|
}
|
70
71
|
return nullptr;
|
71
72
|
}
|
@@ -125,7 +125,7 @@ end:
|
|
125
125
|
}
|
126
126
|
|
127
127
|
void Parser::ParseQuery(const string &query) {
|
128
|
-
Transformer transformer(options
|
128
|
+
Transformer transformer(options);
|
129
129
|
string parser_error;
|
130
130
|
{
|
131
131
|
// check if there are any unicode spaces in the string
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include "duckdb/parser/statement/select_statement.hpp"
|
11
11
|
#include "duckdb/parser/query_node/select_node.hpp"
|
12
12
|
#include "duckdb/parser/tableref/emptytableref.hpp"
|
13
|
+
#include "duckdb/parser/parser_options.hpp"
|
13
14
|
#include "duckdb/parser/transformer.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
@@ -24,12 +25,15 @@ unique_ptr<ParsedExpression> Transformer::TransformUnaryOperator(const string &o
|
|
24
25
|
return std::move(result);
|
25
26
|
}
|
26
27
|
|
27
|
-
unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(
|
28
|
+
unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(string op, unique_ptr<ParsedExpression> left,
|
28
29
|
unique_ptr<ParsedExpression> right) {
|
29
30
|
vector<unique_ptr<ParsedExpression>> children;
|
30
31
|
children.push_back(std::move(left));
|
31
32
|
children.push_back(std::move(right));
|
32
33
|
|
34
|
+
if (options.integer_division && op == "/") {
|
35
|
+
op = "//";
|
36
|
+
}
|
33
37
|
if (op == "~" || op == "!~") {
|
34
38
|
// rewrite 'asdf' SIMILAR TO '.*sd.*' into regexp_full_match('asdf', '.*sd.*')
|
35
39
|
bool invert_similar = op == "!~";
|
@@ -47,7 +51,7 @@ unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(const string &
|
|
47
51
|
return make_uniq<ComparisonExpression>(target_type, std::move(children[0]), std::move(children[1]));
|
48
52
|
}
|
49
53
|
// not a special operator: convert to a function expression
|
50
|
-
auto result = make_uniq<FunctionExpression>(op, std::move(children));
|
54
|
+
auto result = make_uniq<FunctionExpression>(std::move(op), std::move(children));
|
51
55
|
result->is_operator = true;
|
52
56
|
return std::move(result);
|
53
57
|
}
|
@@ -197,7 +201,7 @@ unique_ptr<ParsedExpression> Transformer::TransformAExprInternal(duckdb_libpgque
|
|
197
201
|
// postfix operator, only ! is currently supported
|
198
202
|
return TransformUnaryOperator(name + "__postfix", std::move(left_expr));
|
199
203
|
} else {
|
200
|
-
return TransformBinaryOperator(name, std::move(left_expr), std::move(right_expr));
|
204
|
+
return TransformBinaryOperator(std::move(name), std::move(left_expr), std::move(right_expr));
|
201
205
|
}
|
202
206
|
}
|
203
207
|
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#include "duckdb/parser/statement/list.hpp"
|
5
5
|
#include "duckdb/parser/tableref/emptytableref.hpp"
|
6
6
|
#include "duckdb/parser/query_node/select_node.hpp"
|
7
|
+
#include "duckdb/parser/parser_options.hpp"
|
7
8
|
|
8
9
|
namespace duckdb {
|
9
10
|
|
@@ -21,12 +22,12 @@ StackChecker::StackChecker(StackChecker &&other) noexcept
|
|
21
22
|
other.stack_usage = 0;
|
22
23
|
}
|
23
24
|
|
24
|
-
Transformer::Transformer(
|
25
|
-
: parent(nullptr),
|
25
|
+
Transformer::Transformer(ParserOptions &options)
|
26
|
+
: parent(nullptr), options(options), stack_depth(DConstants::INVALID_INDEX) {
|
26
27
|
}
|
27
28
|
|
28
29
|
Transformer::Transformer(Transformer *parent)
|
29
|
-
: parent(parent),
|
30
|
+
: parent(parent), options(parent->options), stack_depth(DConstants::INVALID_INDEX) {
|
30
31
|
}
|
31
32
|
|
32
33
|
Transformer::~Transformer() {
|
@@ -63,10 +64,10 @@ StackChecker Transformer::StackCheck(idx_t extra_stack) {
|
|
63
64
|
node = node->parent;
|
64
65
|
}
|
65
66
|
D_ASSERT(node->stack_depth != DConstants::INVALID_INDEX);
|
66
|
-
if (node->stack_depth + extra_stack >= max_expression_depth) {
|
67
|
+
if (node->stack_depth + extra_stack >= options.max_expression_depth) {
|
67
68
|
throw ParserException("Max expression depth limit of %lld exceeded. Use \"SET max_expression_depth TO x\" to "
|
68
69
|
"increase the maximum expression depth.",
|
69
|
-
max_expression_depth);
|
70
|
+
options.max_expression_depth);
|
70
71
|
}
|
71
72
|
return StackChecker(*node, extra_stack);
|
72
73
|
}
|