duckdb 0.7.2-dev2430.0 → 0.7.2-dev2552.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/connection.cpp +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
- package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
- package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
- package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
- package/src/duckdb/extension/json/json-extension.cpp +6 -6
- package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
- package/src/duckdb/src/catalog/catalog.cpp +166 -127
- package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
- package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
- package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
- package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
- package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
- package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
- package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
- package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
- package/src/duckdb/src/common/types.cpp +15 -27
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +6 -5
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/function/built_in_functions.cpp +10 -10
- package/src/duckdb/src/function/function_binder.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
- package/src/duckdb/src/function/table/arrow.cpp +32 -31
- package/src/duckdb/src/function/table/arrow_conversion.cpp +75 -59
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
- package/src/duckdb/src/function/table/table_scan.cpp +39 -37
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/udf_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
- package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
- package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
- package/src/duckdb/src/main/attached_database.cpp +12 -6
- package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
- package/src/duckdb/src/main/client_context.cpp +12 -11
- package/src/duckdb/src/main/database_manager.cpp +13 -12
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
- package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
- package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +36 -35
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
- package/src/duckdb/src/planner/binder.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
- package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
- package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
- package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
- package/src/duckdb/src/storage/checkpoint_manager.cpp +46 -46
- package/src/duckdb/src/storage/data_table.cpp +3 -6
- package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
- package/src/duckdb/src/storage/wal_replay.cpp +28 -30
- package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
- package/src/duckdb/src/transaction/cleanup_state.cpp +1 -1
- package/src/duckdb/src/transaction/commit_state.cpp +3 -4
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
@@ -18,44 +18,44 @@ BindResult ExpressionBinder::BindExpression(BetweenExpression &expr, idx_t depth
|
|
18
18
|
return BindResult(error);
|
19
19
|
}
|
20
20
|
// the children have been successfully resolved
|
21
|
-
auto &input = (
|
22
|
-
auto &lower = (
|
23
|
-
auto &upper = (
|
21
|
+
auto &input = BoundExpression::GetExpression(*expr.input);
|
22
|
+
auto &lower = BoundExpression::GetExpression(*expr.lower);
|
23
|
+
auto &upper = BoundExpression::GetExpression(*expr.upper);
|
24
24
|
|
25
|
-
auto input_sql_type = input
|
26
|
-
auto lower_sql_type = lower
|
27
|
-
auto upper_sql_type = upper
|
25
|
+
auto input_sql_type = input->return_type;
|
26
|
+
auto lower_sql_type = lower->return_type;
|
27
|
+
auto upper_sql_type = upper->return_type;
|
28
28
|
|
29
29
|
// cast the input types to the same type
|
30
30
|
// now obtain the result type of the input types
|
31
31
|
auto input_type = BoundComparisonExpression::BindComparison(input_sql_type, lower_sql_type);
|
32
32
|
input_type = BoundComparisonExpression::BindComparison(input_type, upper_sql_type);
|
33
33
|
// add casts (if necessary)
|
34
|
-
input
|
35
|
-
lower
|
36
|
-
upper
|
34
|
+
input = BoundCastExpression::AddCastToType(context, std::move(input), input_type);
|
35
|
+
lower = BoundCastExpression::AddCastToType(context, std::move(lower), input_type);
|
36
|
+
upper = BoundCastExpression::AddCastToType(context, std::move(upper), input_type);
|
37
37
|
if (input_type.id() == LogicalTypeId::VARCHAR) {
|
38
38
|
// handle collation
|
39
39
|
auto collation = StringType::GetCollation(input_type);
|
40
|
-
input
|
41
|
-
lower
|
42
|
-
upper
|
40
|
+
input = PushCollation(context, std::move(input), collation, false);
|
41
|
+
lower = PushCollation(context, std::move(lower), collation, false);
|
42
|
+
upper = PushCollation(context, std::move(upper), collation, false);
|
43
43
|
}
|
44
|
-
if (!input
|
44
|
+
if (!input->HasSideEffects() && !input->HasParameter() && !input->HasSubquery()) {
|
45
45
|
// the expression does not have side effects and can be copied: create two comparisons
|
46
46
|
// the reason we do this is that individual comparisons are easier to handle in optimizers
|
47
47
|
// if both comparisons remain they will be folded together again into a single BETWEEN in the optimizer
|
48
48
|
auto left_compare = make_uniq<BoundComparisonExpression>(ExpressionType::COMPARE_GREATERTHANOREQUALTO,
|
49
|
-
input
|
49
|
+
input->Copy(), std::move(lower));
|
50
50
|
auto right_compare = make_uniq<BoundComparisonExpression>(ExpressionType::COMPARE_LESSTHANOREQUALTO,
|
51
|
-
std::move(input
|
51
|
+
std::move(input), std::move(upper));
|
52
52
|
return BindResult(make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND,
|
53
53
|
std::move(left_compare), std::move(right_compare)));
|
54
54
|
} else {
|
55
55
|
// expression has side effects: we cannot duplicate it
|
56
56
|
// create a bound_between directly
|
57
|
-
return BindResult(
|
58
|
-
|
57
|
+
return BindResult(
|
58
|
+
make_uniq<BoundBetweenExpression>(std::move(input), std::move(lower), std::move(upper), true, true));
|
59
59
|
}
|
60
60
|
}
|
61
61
|
|
@@ -18,26 +18,26 @@ BindResult ExpressionBinder::BindExpression(CaseExpression &expr, idx_t depth) {
|
|
18
18
|
}
|
19
19
|
// the children have been successfully resolved
|
20
20
|
// figure out the result type of the CASE expression
|
21
|
-
auto
|
21
|
+
auto &else_expr = BoundExpression::GetExpression(*expr.else_expr);
|
22
|
+
auto return_type = else_expr->return_type;
|
22
23
|
for (auto &check : expr.case_checks) {
|
23
|
-
auto &then_expr = (
|
24
|
-
return_type = LogicalType::MaxLogicalType(return_type, then_expr
|
24
|
+
auto &then_expr = BoundExpression::GetExpression(*check.then_expr);
|
25
|
+
return_type = LogicalType::MaxLogicalType(return_type, then_expr->return_type);
|
25
26
|
}
|
26
27
|
|
27
28
|
// bind all the individual components of the CASE statement
|
28
29
|
auto result = make_uniq<BoundCaseExpression>(return_type);
|
29
30
|
for (idx_t i = 0; i < expr.case_checks.size(); i++) {
|
30
31
|
auto &check = expr.case_checks[i];
|
31
|
-
auto &when_expr = (
|
32
|
-
auto &then_expr = (
|
32
|
+
auto &when_expr = BoundExpression::GetExpression(*check.when_expr);
|
33
|
+
auto &then_expr = BoundExpression::GetExpression(*check.then_expr);
|
33
34
|
BoundCaseCheck result_check;
|
34
35
|
result_check.when_expr =
|
35
|
-
BoundCastExpression::AddCastToType(context, std::move(when_expr
|
36
|
-
result_check.then_expr = BoundCastExpression::AddCastToType(context, std::move(then_expr
|
36
|
+
BoundCastExpression::AddCastToType(context, std::move(when_expr), LogicalType::BOOLEAN);
|
37
|
+
result_check.then_expr = BoundCastExpression::AddCastToType(context, std::move(then_expr), return_type);
|
37
38
|
result->case_checks.push_back(std::move(result_check));
|
38
39
|
}
|
39
|
-
|
40
|
-
result->else_expr = BoundCastExpression::AddCastToType(context, std::move(else_expr.expr), return_type);
|
40
|
+
result->else_expr = BoundCastExpression::AddCastToType(context, std::move(else_expr), return_type);
|
41
41
|
return BindResult(std::move(result));
|
42
42
|
}
|
43
43
|
} // namespace duckdb
|
@@ -16,17 +16,17 @@ BindResult ExpressionBinder::BindExpression(CastExpression &expr, idx_t depth) {
|
|
16
16
|
// Right now just considering its DEFAULT_SCHEMA always
|
17
17
|
Binder::BindLogicalType(context, expr.cast_type);
|
18
18
|
// the children have been successfully resolved
|
19
|
-
auto &child = (
|
19
|
+
auto &child = BoundExpression::GetExpression(*expr.child);
|
20
20
|
if (expr.try_cast) {
|
21
|
-
if (child
|
21
|
+
if (child->return_type == expr.cast_type) {
|
22
22
|
// no cast required: type matches
|
23
|
-
return BindResult(std::move(child
|
23
|
+
return BindResult(std::move(child));
|
24
24
|
}
|
25
|
-
child
|
25
|
+
child = BoundCastExpression::AddCastToType(context, std::move(child), expr.cast_type, true);
|
26
26
|
} else {
|
27
27
|
// otherwise add a cast to the target type
|
28
|
-
child
|
28
|
+
child = BoundCastExpression::AddCastToType(context, std::move(child), expr.cast_type);
|
29
29
|
}
|
30
|
-
return BindResult(std::move(child
|
30
|
+
return BindResult(std::move(child));
|
31
31
|
}
|
32
32
|
} // namespace duckdb
|
@@ -10,17 +10,17 @@ BindResult ExpressionBinder::BindExpression(CollateExpression &expr, idx_t depth
|
|
10
10
|
if (!error.empty()) {
|
11
11
|
return BindResult(error);
|
12
12
|
}
|
13
|
-
auto &child = expr.child
|
14
|
-
if (child
|
13
|
+
auto &child = BoundExpression::GetExpression(*expr.child);
|
14
|
+
if (child->HasParameter()) {
|
15
15
|
throw ParameterNotResolvedException();
|
16
16
|
}
|
17
|
-
if (child
|
17
|
+
if (child->return_type.id() != LogicalTypeId::VARCHAR) {
|
18
18
|
throw BinderException("collations are only supported for type varchar");
|
19
19
|
}
|
20
20
|
// Validate the collation, but don't use it
|
21
|
-
PushCollation(context, child
|
22
|
-
child
|
23
|
-
return BindResult(std::move(child
|
21
|
+
PushCollation(context, child->Copy(), expr.collation, false);
|
22
|
+
child->return_type = LogicalType::VARCHAR_COLLATION(expr.collation);
|
23
|
+
return BindResult(std::move(child));
|
24
24
|
}
|
25
25
|
|
26
26
|
} // namespace duckdb
|
@@ -204,13 +204,13 @@ unique_ptr<ParsedExpression> ExpressionBinder::CreateStructPack(ColumnRefExpress
|
|
204
204
|
}
|
205
205
|
if (colref.column_names.size() == 2) {
|
206
206
|
auto &qualifier = colref.column_names[0];
|
207
|
-
if (catalog_entry->catalog
|
207
|
+
if (catalog_entry->catalog.GetName() != qualifier && catalog_entry->schema.name != qualifier) {
|
208
208
|
return nullptr;
|
209
209
|
}
|
210
210
|
} else if (colref.column_names.size() == 3) {
|
211
211
|
auto &catalog_name = colref.column_names[0];
|
212
212
|
auto &schema_name = colref.column_names[1];
|
213
|
-
if (catalog_entry->catalog
|
213
|
+
if (catalog_entry->catalog.GetName() != catalog_name || catalog_entry->schema.name != schema_name) {
|
214
214
|
return nullptr;
|
215
215
|
}
|
216
216
|
} else {
|
@@ -35,28 +35,29 @@ unique_ptr<Expression> ExpressionBinder::PushCollation(ClientContext &context, u
|
|
35
35
|
}
|
36
36
|
auto &catalog = Catalog::GetSystemCatalog(context);
|
37
37
|
auto splits = StringUtil::Split(StringUtil::Lower(collation), ".");
|
38
|
-
vector<CollateCatalogEntry
|
38
|
+
vector<reference<CollateCatalogEntry>> entries;
|
39
39
|
for (auto &collation_argument : splits) {
|
40
|
-
auto collation_entry = catalog.GetEntry<CollateCatalogEntry>(context, DEFAULT_SCHEMA, collation_argument);
|
41
|
-
if (collation_entry
|
40
|
+
auto &collation_entry = catalog.GetEntry<CollateCatalogEntry>(context, DEFAULT_SCHEMA, collation_argument);
|
41
|
+
if (collation_entry.combinable) {
|
42
42
|
entries.insert(entries.begin(), collation_entry);
|
43
43
|
} else {
|
44
|
-
if (!entries.empty() && !entries.back()
|
45
|
-
throw BinderException("Cannot combine collation types \"%s\" and \"%s\"", entries.back()
|
46
|
-
collation_entry
|
44
|
+
if (!entries.empty() && !entries.back().get().combinable) {
|
45
|
+
throw BinderException("Cannot combine collation types \"%s\" and \"%s\"", entries.back().get().name,
|
46
|
+
collation_entry.name);
|
47
47
|
}
|
48
48
|
entries.push_back(collation_entry);
|
49
49
|
}
|
50
50
|
}
|
51
|
-
for (auto &
|
52
|
-
|
51
|
+
for (auto &entry : entries) {
|
52
|
+
auto &collation_entry = entry.get();
|
53
|
+
if (equality_only && collation_entry.not_required_for_equality) {
|
53
54
|
continue;
|
54
55
|
}
|
55
56
|
vector<unique_ptr<Expression>> children;
|
56
57
|
children.push_back(std::move(source));
|
57
58
|
|
58
59
|
FunctionBinder function_binder(context);
|
59
|
-
auto function = function_binder.BindScalarFunction(collation_entry
|
60
|
+
auto function = function_binder.BindScalarFunction(collation_entry.function, std::move(children));
|
60
61
|
source = std::move(function);
|
61
62
|
}
|
62
63
|
return source;
|
@@ -119,28 +120,27 @@ BindResult ExpressionBinder::BindExpression(ComparisonExpression &expr, idx_t de
|
|
119
120
|
return BindResult(error);
|
120
121
|
}
|
121
122
|
// the children have been successfully resolved
|
122
|
-
auto &left = (
|
123
|
-
auto &right = (
|
124
|
-
auto left_sql_type = left
|
125
|
-
auto right_sql_type = right
|
123
|
+
auto &left = BoundExpression::GetExpression(*expr.left);
|
124
|
+
auto &right = BoundExpression::GetExpression(*expr.right);
|
125
|
+
auto left_sql_type = left->return_type;
|
126
|
+
auto right_sql_type = right->return_type;
|
126
127
|
// cast the input types to the same type
|
127
128
|
// now obtain the result type of the input types
|
128
129
|
auto input_type = BoundComparisonExpression::BindComparison(left_sql_type, right_sql_type);
|
129
130
|
// add casts (if necessary)
|
130
|
-
left
|
131
|
-
|
132
|
-
right
|
133
|
-
|
131
|
+
left = BoundCastExpression::AddCastToType(context, std::move(left), input_type,
|
132
|
+
input_type.id() == LogicalTypeId::ENUM);
|
133
|
+
right = BoundCastExpression::AddCastToType(context, std::move(right), input_type,
|
134
|
+
input_type.id() == LogicalTypeId::ENUM);
|
134
135
|
|
135
136
|
if (input_type.id() == LogicalTypeId::VARCHAR) {
|
136
137
|
// handle collation
|
137
138
|
auto collation = StringType::GetCollation(input_type);
|
138
|
-
left
|
139
|
-
right.
|
140
|
-
PushCollation(context, std::move(right.expr), collation, expr.type == ExpressionType::COMPARE_EQUAL);
|
139
|
+
left = PushCollation(context, std::move(left), collation, expr.type == ExpressionType::COMPARE_EQUAL);
|
140
|
+
right = PushCollation(context, std::move(right), collation, expr.type == ExpressionType::COMPARE_EQUAL);
|
141
141
|
}
|
142
142
|
// now create the bound comparison expression
|
143
|
-
return BindResult(make_uniq<BoundComparisonExpression>(expr.type, std::move(left
|
143
|
+
return BindResult(make_uniq<BoundComparisonExpression>(expr.type, std::move(left), std::move(right)));
|
144
144
|
}
|
145
145
|
|
146
146
|
} // namespace duckdb
|
@@ -19,9 +19,8 @@ BindResult ExpressionBinder::BindExpression(ConjunctionExpression &expr, idx_t d
|
|
19
19
|
// and construct the bound conjunction expression
|
20
20
|
auto result = make_uniq<BoundConjunctionExpression>(expr.type);
|
21
21
|
for (auto &child_expr : expr.children) {
|
22
|
-
auto &child = (
|
23
|
-
result->children.push_back(
|
24
|
-
BoundCastExpression::AddCastToType(context, std::move(child.expr), LogicalType::BOOLEAN));
|
22
|
+
auto &child = BoundExpression::GetExpression(*child_expr);
|
23
|
+
result->children.push_back(BoundCastExpression::AddCastToType(context, std::move(child), LogicalType::BOOLEAN));
|
25
24
|
}
|
26
25
|
// now create the bound conjunction expression
|
27
26
|
return BindResult(std::move(result));
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/catalog/catalog.hpp"
|
2
|
+
#include "duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp"
|
2
3
|
#include "duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp"
|
4
|
+
#include "duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp"
|
3
5
|
#include "duckdb/execution/expression_executor.hpp"
|
4
6
|
#include "duckdb/function/function_binder.hpp"
|
5
7
|
#include "duckdb/parser/expression/function_expression.hpp"
|
@@ -19,11 +21,12 @@ BindResult ExpressionBinder::BindExpression(FunctionExpression &function, idx_t
|
|
19
21
|
// lookup the function in the catalog
|
20
22
|
QueryErrorContext error_context(binder.root_statement, function.query_location);
|
21
23
|
auto func = Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, function.catalog, function.schema,
|
22
|
-
function.function_name,
|
24
|
+
function.function_name, OnEntryNotFound::RETURN_NULL, error_context);
|
23
25
|
if (!func) {
|
24
26
|
// function was not found - check if we this is a table function
|
25
|
-
auto table_func =
|
26
|
-
|
27
|
+
auto table_func =
|
28
|
+
Catalog::GetEntry(context, CatalogType::TABLE_FUNCTION_ENTRY, function.catalog, function.schema,
|
29
|
+
function.function_name, OnEntryNotFound::RETURN_NULL, error_context);
|
27
30
|
if (table_func) {
|
28
31
|
throw BinderException(binder.FormatError(
|
29
32
|
function,
|
@@ -52,7 +55,7 @@ BindResult ExpressionBinder::BindExpression(FunctionExpression &function, idx_t
|
|
52
55
|
}
|
53
56
|
// rebind the function
|
54
57
|
func = Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, function.catalog, function.schema,
|
55
|
-
function.function_name,
|
58
|
+
function.function_name, OnEntryNotFound::THROW_EXCEPTION, error_context);
|
56
59
|
}
|
57
60
|
|
58
61
|
if (func->type != CatalogType::AGGREGATE_FUNCTION_ENTRY &&
|
@@ -70,25 +73,24 @@ BindResult ExpressionBinder::BindExpression(FunctionExpression &function, idx_t
|
|
70
73
|
if (function.function_name != "->>") {
|
71
74
|
for (auto &child : function.children) {
|
72
75
|
if (child->expression_class == ExpressionClass::LAMBDA) {
|
73
|
-
return BindLambdaFunction(function, (
|
76
|
+
return BindLambdaFunction(function, func->Cast<ScalarFunctionCatalogEntry>(), depth);
|
74
77
|
}
|
75
78
|
}
|
76
79
|
}
|
77
80
|
|
78
81
|
// other scalar function
|
79
|
-
return BindFunction(function, (
|
82
|
+
return BindFunction(function, func->Cast<ScalarFunctionCatalogEntry>(), depth);
|
80
83
|
|
81
84
|
case CatalogType::MACRO_ENTRY:
|
82
85
|
// macro function
|
83
|
-
return BindMacro(function, (
|
86
|
+
return BindMacro(function, func->Cast<ScalarMacroCatalogEntry>(), depth, expr_ptr);
|
84
87
|
default:
|
85
88
|
// aggregate function
|
86
|
-
return BindAggregate(function, (
|
89
|
+
return BindAggregate(function, func->Cast<AggregateFunctionCatalogEntry>(), depth);
|
87
90
|
}
|
88
91
|
}
|
89
92
|
|
90
|
-
BindResult ExpressionBinder::BindFunction(FunctionExpression &function,
|
91
|
-
idx_t depth) {
|
93
|
+
BindResult ExpressionBinder::BindFunction(FunctionExpression &function, ScalarFunctionCatalogEntry &func, idx_t depth) {
|
92
94
|
|
93
95
|
// bind the children of the function expression
|
94
96
|
string error;
|
@@ -109,22 +111,21 @@ BindResult ExpressionBinder::BindFunction(FunctionExpression &function, optional
|
|
109
111
|
// extract the children and types
|
110
112
|
vector<unique_ptr<Expression>> children;
|
111
113
|
for (idx_t i = 0; i < function.children.size(); i++) {
|
112
|
-
auto &child = (
|
113
|
-
|
114
|
-
children.push_back(std::move(child.expr));
|
114
|
+
auto &child = BoundExpression::GetExpression(*function.children[i]);
|
115
|
+
children.push_back(std::move(child));
|
115
116
|
}
|
116
117
|
|
117
118
|
FunctionBinder function_binder(context);
|
118
119
|
unique_ptr<Expression> result =
|
119
|
-
function_binder.BindScalarFunction(
|
120
|
+
function_binder.BindScalarFunction(func, std::move(children), error, function.is_operator, &binder);
|
120
121
|
if (!result) {
|
121
122
|
throw BinderException(binder.FormatError(function, error));
|
122
123
|
}
|
123
124
|
return BindResult(std::move(result));
|
124
125
|
}
|
125
126
|
|
126
|
-
BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
127
|
-
|
127
|
+
BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function, ScalarFunctionCatalogEntry &func,
|
128
|
+
idx_t depth) {
|
128
129
|
|
129
130
|
// bind the children of the function expression
|
130
131
|
string error;
|
@@ -141,18 +142,16 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
|
141
142
|
}
|
142
143
|
|
143
144
|
// get the logical type of the children of the list
|
144
|
-
auto &list_child = function.children[0]
|
145
|
-
|
146
|
-
|
147
|
-
list_child.expr->return_type.id() != LogicalTypeId::SQLNULL &&
|
148
|
-
list_child.expr->return_type.id() != LogicalTypeId::UNKNOWN) {
|
145
|
+
auto &list_child = BoundExpression::GetExpression(*function.children[0]);
|
146
|
+
if (list_child->return_type.id() != LogicalTypeId::LIST && list_child->return_type.id() != LogicalTypeId::SQLNULL &&
|
147
|
+
list_child->return_type.id() != LogicalTypeId::UNKNOWN) {
|
149
148
|
throw BinderException(" Invalid LIST argument to " + function.function_name + "!");
|
150
149
|
}
|
151
150
|
|
152
|
-
LogicalType list_child_type = list_child
|
153
|
-
if (list_child
|
154
|
-
list_child
|
155
|
-
list_child_type = ListType::GetChildType(list_child
|
151
|
+
LogicalType list_child_type = list_child->return_type.id();
|
152
|
+
if (list_child->return_type.id() != LogicalTypeId::SQLNULL &&
|
153
|
+
list_child->return_type.id() != LogicalTypeId::UNKNOWN) {
|
154
|
+
list_child_type = ListType::GetChildType(list_child->return_type);
|
156
155
|
}
|
157
156
|
|
158
157
|
// bind the lambda parameter
|
@@ -164,12 +163,11 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
|
164
163
|
} else {
|
165
164
|
// successfully bound: replace the node with a BoundExpression
|
166
165
|
auto alias = function.children[1]->alias;
|
167
|
-
|
168
|
-
auto &be = function.children[1]->Cast<BoundExpression>();
|
169
|
-
be.alias = alias;
|
166
|
+
bind_lambda_result.expression->alias = alias;
|
170
167
|
if (!alias.empty()) {
|
171
|
-
|
168
|
+
bind_lambda_result.expression->alias = alias;
|
172
169
|
}
|
170
|
+
function.children[1] = make_uniq<BoundExpression>(std::move(bind_lambda_result.expression));
|
173
171
|
}
|
174
172
|
|
175
173
|
if (!error.empty()) {
|
@@ -183,9 +181,8 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
|
183
181
|
// extract the children and types
|
184
182
|
vector<unique_ptr<Expression>> children;
|
185
183
|
for (idx_t i = 0; i < function.children.size(); i++) {
|
186
|
-
auto &child = (
|
187
|
-
|
188
|
-
children.push_back(std::move(child.expr));
|
184
|
+
auto &child = BoundExpression::GetExpression(*function.children[i]);
|
185
|
+
children.push_back(std::move(child));
|
189
186
|
}
|
190
187
|
|
191
188
|
// capture the (lambda) columns
|
@@ -194,7 +191,7 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
|
194
191
|
|
195
192
|
FunctionBinder function_binder(context);
|
196
193
|
unique_ptr<Expression> result =
|
197
|
-
function_binder.BindScalarFunction(
|
194
|
+
function_binder.BindScalarFunction(func, std::move(children), error, function.is_operator, &binder);
|
198
195
|
if (!result) {
|
199
196
|
throw BinderException(binder.FormatError(function, error));
|
200
197
|
}
|
@@ -205,7 +202,7 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
|
205
202
|
// remove the lambda expression from the children
|
206
203
|
auto lambda = std::move(bound_function_expr.children.back());
|
207
204
|
bound_function_expr.children.pop_back();
|
208
|
-
auto &bound_lambda = (
|
205
|
+
auto &bound_lambda = lambda->Cast<BoundLambdaExpression>();
|
209
206
|
|
210
207
|
// push back (in reverse order) any nested lambda parameters so that we can later use them in the lambda expression
|
211
208
|
// (rhs)
|
@@ -234,8 +231,8 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
|
234
231
|
return BindResult(std::move(result));
|
235
232
|
}
|
236
233
|
|
237
|
-
BindResult ExpressionBinder::BindAggregate(FunctionExpression &expr,
|
238
|
-
|
234
|
+
BindResult ExpressionBinder::BindAggregate(FunctionExpression &expr, AggregateFunctionCatalogEntry &function,
|
235
|
+
idx_t depth) {
|
239
236
|
return BindResult(binder.FormatError(expr, UnsupportedAggregateMessage()));
|
240
237
|
}
|
241
238
|
|
@@ -44,17 +44,17 @@ void ExpressionBinder::ReplaceMacroParametersRecursive(unique_ptr<ParsedExpressi
|
|
44
44
|
*expr, [&](unique_ptr<ParsedExpression> &child) { ReplaceMacroParametersRecursive(child); });
|
45
45
|
}
|
46
46
|
|
47
|
-
BindResult ExpressionBinder::BindMacro(FunctionExpression &function,
|
48
|
-
|
47
|
+
BindResult ExpressionBinder::BindMacro(FunctionExpression &function, ScalarMacroCatalogEntry ¯o_func, idx_t depth,
|
48
|
+
unique_ptr<ParsedExpression> &expr) {
|
49
49
|
// recast function so we can access the scalar member function->expression
|
50
|
-
auto ¯o_def = macro_func
|
50
|
+
auto ¯o_def = macro_func.function->Cast<ScalarMacroFunction>();
|
51
51
|
|
52
52
|
// validate the arguments and separate positional and default arguments
|
53
53
|
vector<unique_ptr<ParsedExpression>> positionals;
|
54
54
|
unordered_map<string, unique_ptr<ParsedExpression>> defaults;
|
55
55
|
|
56
56
|
string error =
|
57
|
-
MacroFunction::ValidateArguments(*macro_func
|
57
|
+
MacroFunction::ValidateArguments(*macro_func.function, macro_func.name, function, positionals, defaults);
|
58
58
|
if (!error.empty()) {
|
59
59
|
throw BinderException(binder.FormatError(*expr, error));
|
60
60
|
}
|
@@ -75,7 +75,7 @@ BindResult ExpressionBinder::BindMacro(FunctionExpression &function, optional_pt
|
|
75
75
|
// now push the defaults into the positionals
|
76
76
|
positionals.push_back(std::move(defaults[it->first]));
|
77
77
|
}
|
78
|
-
auto new_macro_binding = make_uniq<DummyBinding>(types, names, macro_func
|
78
|
+
auto new_macro_binding = make_uniq<DummyBinding>(types, names, macro_func.name);
|
79
79
|
new_macro_binding->arguments = &positionals;
|
80
80
|
macro_binding = new_macro_binding.get();
|
81
81
|
|
@@ -8,27 +8,27 @@
|
|
8
8
|
|
9
9
|
namespace duckdb {
|
10
10
|
|
11
|
-
static LogicalType ResolveNotType(OperatorExpression &op, vector<
|
11
|
+
static LogicalType ResolveNotType(OperatorExpression &op, vector<unique_ptr<Expression>> &children) {
|
12
12
|
// NOT expression, cast child to BOOLEAN
|
13
13
|
D_ASSERT(children.size() == 1);
|
14
|
-
children[0]
|
14
|
+
children[0] = BoundCastExpression::AddDefaultCastToType(std::move(children[0]), LogicalType::BOOLEAN);
|
15
15
|
return LogicalType(LogicalTypeId::BOOLEAN);
|
16
16
|
}
|
17
17
|
|
18
|
-
static LogicalType ResolveInType(OperatorExpression &op, vector<
|
18
|
+
static LogicalType ResolveInType(OperatorExpression &op, vector<unique_ptr<Expression>> &children) {
|
19
19
|
if (children.empty()) {
|
20
20
|
throw InternalException("IN requires at least a single child node");
|
21
21
|
}
|
22
22
|
// get the maximum type from the children
|
23
|
-
LogicalType max_type = children[0]->
|
24
|
-
bool any_varchar = children[0]->
|
25
|
-
bool any_enum = children[0]->
|
23
|
+
LogicalType max_type = children[0]->return_type;
|
24
|
+
bool any_varchar = children[0]->return_type == LogicalType::VARCHAR;
|
25
|
+
bool any_enum = children[0]->return_type.id() == LogicalTypeId::ENUM;
|
26
26
|
for (idx_t i = 1; i < children.size(); i++) {
|
27
|
-
max_type = LogicalType::MaxLogicalType(max_type, children[i]->
|
28
|
-
if (children[i]->
|
27
|
+
max_type = LogicalType::MaxLogicalType(max_type, children[i]->return_type);
|
28
|
+
if (children[i]->return_type == LogicalType::VARCHAR) {
|
29
29
|
any_varchar = true;
|
30
30
|
}
|
31
|
-
if (children[i]->
|
31
|
+
if (children[i]->return_type.id() == LogicalTypeId::ENUM) {
|
32
32
|
any_enum = true;
|
33
33
|
}
|
34
34
|
}
|
@@ -40,18 +40,18 @@ static LogicalType ResolveInType(OperatorExpression &op, vector<BoundExpression
|
|
40
40
|
|
41
41
|
// cast all children to the same type
|
42
42
|
for (idx_t i = 0; i < children.size(); i++) {
|
43
|
-
children[i]
|
43
|
+
children[i] = BoundCastExpression::AddDefaultCastToType(std::move(children[i]), max_type);
|
44
44
|
}
|
45
45
|
// (NOT) IN always returns a boolean
|
46
46
|
return LogicalType::BOOLEAN;
|
47
47
|
}
|
48
48
|
|
49
|
-
static LogicalType ResolveOperatorType(OperatorExpression &op, vector<
|
49
|
+
static LogicalType ResolveOperatorType(OperatorExpression &op, vector<unique_ptr<Expression>> &children) {
|
50
50
|
switch (op.type) {
|
51
51
|
case ExpressionType::OPERATOR_IS_NULL:
|
52
52
|
case ExpressionType::OPERATOR_IS_NOT_NULL:
|
53
53
|
// IS (NOT) NULL always returns a boolean, and does not cast its children
|
54
|
-
if (!children[0]->
|
54
|
+
if (!children[0]->return_type.IsValid()) {
|
55
55
|
throw ParameterNotResolvedException();
|
56
56
|
}
|
57
57
|
return LogicalType::BOOLEAN;
|
@@ -60,7 +60,7 @@ static LogicalType ResolveOperatorType(OperatorExpression &op, vector<BoundExpre
|
|
60
60
|
return ResolveInType(op, children);
|
61
61
|
case ExpressionType::OPERATOR_COALESCE: {
|
62
62
|
ResolveInType(op, children);
|
63
|
-
return children[0]->
|
63
|
+
return children[0]->return_type;
|
64
64
|
}
|
65
65
|
case ExpressionType::OPERATOR_NOT:
|
66
66
|
return ResolveNotType(op, children);
|
@@ -90,8 +90,8 @@ BindResult ExpressionBinder::BindExpression(OperatorExpression &op, idx_t depth)
|
|
90
90
|
switch (op.type) {
|
91
91
|
case ExpressionType::ARRAY_EXTRACT: {
|
92
92
|
D_ASSERT(op.children[0]->expression_class == ExpressionClass::BOUND_EXPRESSION);
|
93
|
-
auto &b_exp = (
|
94
|
-
if (b_exp
|
93
|
+
auto &b_exp = BoundExpression::GetExpression(*op.children[0]);
|
94
|
+
if (b_exp->return_type.id() == LogicalTypeId::MAP) {
|
95
95
|
function_name = "map_extract";
|
96
96
|
} else {
|
97
97
|
function_name = "array_extract";
|
@@ -105,14 +105,14 @@ BindResult ExpressionBinder::BindExpression(OperatorExpression &op, idx_t depth)
|
|
105
105
|
D_ASSERT(op.children.size() == 2);
|
106
106
|
D_ASSERT(op.children[0]->expression_class == ExpressionClass::BOUND_EXPRESSION);
|
107
107
|
D_ASSERT(op.children[1]->expression_class == ExpressionClass::BOUND_EXPRESSION);
|
108
|
-
auto &extract_exp = (
|
109
|
-
auto &name_exp = (
|
110
|
-
auto extract_expr_type = extract_exp
|
108
|
+
auto &extract_exp = BoundExpression::GetExpression(*op.children[0]);
|
109
|
+
auto &name_exp = BoundExpression::GetExpression(*op.children[1]);
|
110
|
+
auto extract_expr_type = extract_exp->return_type.id();
|
111
111
|
if (extract_expr_type != LogicalTypeId::STRUCT && extract_expr_type != LogicalTypeId::UNION &&
|
112
112
|
extract_expr_type != LogicalTypeId::SQLNULL) {
|
113
113
|
return BindResult(StringUtil::Format(
|
114
114
|
"Cannot extract field %s from expression \"%s\" because it is not a struct or a union",
|
115
|
-
name_exp
|
115
|
+
name_exp->ToString(), extract_exp->ToString()));
|
116
116
|
}
|
117
117
|
function_name = extract_expr_type == LogicalTypeId::UNION ? "union_extract" : "struct_extract";
|
118
118
|
break;
|
@@ -131,10 +131,10 @@ BindResult ExpressionBinder::BindExpression(OperatorExpression &op, idx_t depth)
|
|
131
131
|
return BindExpression(function, depth, false);
|
132
132
|
}
|
133
133
|
|
134
|
-
vector<
|
134
|
+
vector<unique_ptr<Expression>> children;
|
135
135
|
for (idx_t i = 0; i < op.children.size(); i++) {
|
136
136
|
D_ASSERT(op.children[i]->expression_class == ExpressionClass::BOUND_EXPRESSION);
|
137
|
-
children.push_back((BoundExpression
|
137
|
+
children.push_back(std::move(BoundExpression::GetExpression(*op.children[i])));
|
138
138
|
}
|
139
139
|
// now resolve the types
|
140
140
|
LogicalType result_type = ResolveOperatorType(op, children);
|
@@ -143,13 +143,13 @@ BindResult ExpressionBinder::BindExpression(OperatorExpression &op, idx_t depth)
|
|
143
143
|
throw BinderException("COALESCE needs at least one child");
|
144
144
|
}
|
145
145
|
if (children.size() == 1) {
|
146
|
-
return BindResult(std::move(children[0]
|
146
|
+
return BindResult(std::move(children[0]));
|
147
147
|
}
|
148
148
|
}
|
149
149
|
|
150
150
|
auto result = make_uniq<BoundOperatorExpression>(op.type, result_type);
|
151
151
|
for (auto &child : children) {
|
152
|
-
result->children.push_back(std::move(child
|
152
|
+
result->children.push_back(std::move(child));
|
153
153
|
}
|
154
154
|
return BindResult(std::move(result));
|
155
155
|
}
|
@@ -75,7 +75,6 @@ BindResult ExpressionBinder::BindExpression(SubqueryExpression &expr, idx_t dept
|
|
75
75
|
// both binding the child and binding the subquery was successful
|
76
76
|
D_ASSERT(expr.subquery->node->type == QueryNodeType::BOUND_SUBQUERY_NODE);
|
77
77
|
auto bound_subquery = (BoundSubqueryNode *)expr.subquery->node.get();
|
78
|
-
auto child = (BoundExpression *)expr.child.get();
|
79
78
|
auto subquery_binder = std::move(bound_subquery->subquery_binder);
|
80
79
|
auto bound_node = std::move(bound_subquery->bound_node);
|
81
80
|
LogicalType return_type =
|
@@ -89,15 +88,16 @@ BindResult ExpressionBinder::BindExpression(SubqueryExpression &expr, idx_t dept
|
|
89
88
|
// ANY comparison
|
90
89
|
// cast child and subquery child to equivalent types
|
91
90
|
D_ASSERT(bound_node->types.size() == 1);
|
92
|
-
auto
|
93
|
-
|
91
|
+
auto &child = BoundExpression::GetExpression(*expr.child);
|
92
|
+
auto compare_type = LogicalType::MaxLogicalType(child->return_type, bound_node->types[0]);
|
93
|
+
child = BoundCastExpression::AddCastToType(context, std::move(child), compare_type);
|
94
94
|
result->child_type = bound_node->types[0];
|
95
95
|
result->child_target = compare_type;
|
96
|
+
result->child = std::move(child);
|
96
97
|
}
|
97
98
|
result->binder = std::move(subquery_binder);
|
98
99
|
result->subquery = std::move(bound_node);
|
99
100
|
result->subquery_type = expr.subquery_type;
|
100
|
-
result->child = child ? std::move(child->expr) : nullptr;
|
101
101
|
result->comparison_type = expr.comparison_type;
|
102
102
|
|
103
103
|
return BindResult(std::move(result));
|