duckdb 0.7.2-dev2320.0 → 0.7.2-dev2410.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 +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +2 -2
- package/src/duckdb/extension/icu/icu-makedate.cpp +52 -0
- package/src/duckdb/extension/icu/icu-strptime.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/calendar.cpp +4 -0
- package/src/duckdb/extension/icu/third_party/icu/i18n/dangical.cpp +28 -28
- package/src/duckdb/extension/icu/third_party/icu/i18n/dangical.h +4 -4
- package/src/duckdb/extension/json/include/json_common.hpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_create.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +1 -1
- package/src/duckdb/extension/json/json_functions.cpp +2 -2
- package/src/duckdb/extension/json/json_serializer.cpp +1 -1
- package/src/duckdb/extension/parquet/column_reader.cpp +1 -1
- package/src/duckdb/extension/parquet/column_writer.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +2 -2
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +2 -2
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/file_buffer.cpp +8 -0
- package/src/duckdb/src/common/operator/cast_operators.cpp +24 -25
- package/src/duckdb/src/common/radix_partitioning.cpp +34 -0
- package/src/duckdb/src/common/row_operations/row_heap_scatter.cpp +2 -2
- package/src/duckdb/src/common/row_operations/row_scatter.cpp +1 -1
- package/src/duckdb/src/common/sort/partition_state.cpp +44 -124
- package/src/duckdb/src/common/sort/sorted_block.cpp +1 -1
- package/src/duckdb/src/common/types/bit.cpp +18 -18
- package/src/duckdb/src/common/types/blob.cpp +7 -7
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +1 -1
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +1 -1
- package/src/duckdb/src/common/types/hash.cpp +1 -1
- package/src/duckdb/src/common/types/hyperloglog.cpp +1 -1
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +2 -2
- package/src/duckdb/src/common/types/string_heap.cpp +2 -2
- package/src/duckdb/src/common/types/string_type.cpp +2 -2
- package/src/duckdb/src/common/types/timestamp.cpp +1 -1
- package/src/duckdb/src/common/types/vector.cpp +7 -7
- package/src/duckdb/src/execution/index/art/art_key.cpp +2 -2
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +144 -31
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +698 -0
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +7 -1
- package/src/duckdb/src/function/aggregate/distributive/arg_min_max.cpp +2 -2
- package/src/duckdb/src/function/aggregate/distributive/bitagg.cpp +2 -2
- package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +2 -2
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +2 -2
- package/src/duckdb/src/function/aggregate/distributive/kurtosis.cpp +3 -2
- package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +2 -2
- package/src/duckdb/src/function/aggregate/distributive/skew.cpp +5 -1
- package/src/duckdb/src/function/aggregate/distributive/string_agg.cpp +1 -1
- package/src/duckdb/src/function/cast/list_casts.cpp +1 -1
- package/src/duckdb/src/function/cast/struct_cast.cpp +1 -1
- package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +3 -3
- package/src/duckdb/src/function/scalar/bit/bitstring.cpp +1 -1
- package/src/duckdb/src/function/scalar/blob/encode.cpp +1 -1
- package/src/duckdb/src/function/scalar/date/strftime.cpp +3 -3
- package/src/duckdb/src/function/scalar/generic/current_setting.cpp +1 -1
- package/src/duckdb/src/function/scalar/list/list_sort.cpp +30 -56
- package/src/duckdb/src/function/scalar/string/ascii.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/concat.cpp +6 -6
- package/src/duckdb/src/function/scalar/string/contains.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/damerau_levenshtein.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/hex.cpp +4 -4
- package/src/duckdb/src/function/scalar/string/instr.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/jaccard.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/jaro_winkler.cpp +5 -5
- package/src/duckdb/src/function/scalar/string/length.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/levenshtein.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/like.cpp +10 -11
- package/src/duckdb/src/function/scalar/string/mismatches.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/nfc_normalize.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/pad.cpp +3 -3
- package/src/duckdb/src/function/scalar/string/prefix.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/printf.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +4 -4
- package/src/duckdb/src/function/scalar/string/repeat.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/replace.cpp +3 -3
- package/src/duckdb/src/function/scalar/string/reverse.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/starts_with.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/string_split.cpp +3 -3
- package/src/duckdb/src/function/scalar/string/strip_accents.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/substring.cpp +3 -3
- package/src/duckdb/src/function/scalar/string/suffix.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/translate.cpp +3 -3
- package/src/duckdb/src/function/scalar/string/trim.cpp +3 -3
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +1 -1
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -7
- package/src/duckdb/src/function/scalar/union/union_extract.cpp +1 -1
- package/src/duckdb/src/function/table/copy_csv.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/crypto/md5.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/enums/debug_initialize.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/enums/order_type.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/file_buffer.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/radix.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +11 -60
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +8 -6
- package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +6 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +93 -0
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/macro_function.hpp +17 -0
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +3 -0
- package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/capi/cast/utils.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +7 -2
- package/src/duckdb/src/include/duckdb/main/settings.hpp +13 -3
- package/src/duckdb/src/include/duckdb/optimizer/cse_optimizer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +4 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/aggregate_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/alter_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +4 -3
- package/src/duckdb/src/include/duckdb/planner/expression_binder/check_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/constant_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/group_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/having_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/insert_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/lateral_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/qualify_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/relation_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/returning_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/table_function_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/update_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +12 -9
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +11 -5
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +1 -1
- package/src/duckdb/src/main/capi/cast/from_decimal-c.cpp +1 -1
- package/src/duckdb/src/main/capi/result-c.cpp +2 -2
- package/src/duckdb/src/main/config.cpp +26 -0
- package/src/duckdb/src/main/settings/settings.cpp +31 -8
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +9 -8
- package/src/duckdb/src/parser/expression/subquery_expression.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +2 -0
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +33 -29
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +8 -10
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +8 -7
- package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +6 -14
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +2 -5
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +1 -1
- package/src/duckdb/src/planner/binder/query_node/plan_select_node.cpp +8 -8
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +5 -5
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +2 -2
- package/src/duckdb/src/planner/binder/tableref/plan_expressionlistref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +4 -4
- package/src/duckdb/src/planner/expression.cpp +2 -1
- package/src/duckdb/src/planner/expression_binder/aggregate_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/alter_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/check_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/column_alias_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/constant_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/group_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/having_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/insert_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/relation_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/returning_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/update_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/where_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder.cpp +12 -12
- package/src/duckdb/src/storage/buffer/block_manager.cpp +1 -2
- package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +2 -2
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +1 -1
- package/src/duckdb/src/storage/compression/fsst.cpp +3 -3
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +1 -1
- package/src/duckdb/src/storage/meta_block_writer.cpp +4 -0
- package/src/duckdb/src/storage/partial_block_manager.cpp +11 -4
- package/src/duckdb/src/storage/single_file_block_manager.cpp +16 -9
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +5 -2
- package/src/duckdb/src/storage/statistics/string_stats.cpp +2 -2
- package/src/duckdb/src/storage/storage_manager.cpp +7 -2
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +21 -1
- package/src/duckdb/ub_src_execution_operator_join.cpp +2 -0
- package/src/statement.cpp +3 -3
@@ -33,6 +33,7 @@ public:
|
|
33
33
|
|
34
34
|
public:
|
35
35
|
//! Creates a new block inside the block manager
|
36
|
+
virtual unique_ptr<Block> ConvertBlock(block_id_t block_id, FileBuffer &source_buffer) = 0;
|
36
37
|
virtual unique_ptr<Block> CreateBlock(block_id_t block_id, FileBuffer *source_buffer) = 0;
|
37
38
|
//! Return the next free block id
|
38
39
|
virtual block_id_t GetFreeBlockId() = 0;
|
@@ -20,6 +20,9 @@ public:
|
|
20
20
|
using BlockManager::BlockManager;
|
21
21
|
|
22
22
|
// LCOV_EXCL_START
|
23
|
+
unique_ptr<Block> ConvertBlock(block_id_t block_id, FileBuffer &source_buffer) override {
|
24
|
+
throw InternalException("Cannot perform IO in in-memory database!");
|
25
|
+
}
|
23
26
|
unique_ptr<Block> CreateBlock(block_id_t block_id, FileBuffer *source_buffer) override {
|
24
27
|
throw InternalException("Cannot perform IO in in-memory database!");
|
25
28
|
}
|
@@ -15,24 +15,32 @@
|
|
15
15
|
#include "duckdb/common/unordered_set.hpp"
|
16
16
|
#include "duckdb/common/set.hpp"
|
17
17
|
#include "duckdb/common/vector.hpp"
|
18
|
+
#include "duckdb/main/config.hpp"
|
18
19
|
|
19
20
|
namespace duckdb {
|
20
21
|
|
21
22
|
class DatabaseInstance;
|
22
23
|
|
24
|
+
struct StorageManagerOptions {
|
25
|
+
bool read_only = false;
|
26
|
+
bool use_direct_io = false;
|
27
|
+
DebugInitialize debug_initialize = DebugInitialize::NO_INITIALIZE;
|
28
|
+
};
|
29
|
+
|
23
30
|
//! SingleFileBlockManager is an implementation for a BlockManager which manages blocks in a single file
|
24
31
|
class SingleFileBlockManager : public BlockManager {
|
25
32
|
//! The location in the file where the block writing starts
|
26
33
|
static constexpr uint64_t BLOCK_START = Storage::FILE_HEADER_SIZE * 3;
|
27
34
|
|
28
35
|
public:
|
29
|
-
SingleFileBlockManager(AttachedDatabase &db, string path,
|
36
|
+
SingleFileBlockManager(AttachedDatabase &db, string path, StorageManagerOptions options);
|
30
37
|
|
31
38
|
void GetFileFlags(uint8_t &flags, FileLockType &lock, bool create_new);
|
32
39
|
void CreateNewDatabase();
|
33
40
|
void LoadExistingDatabase();
|
34
41
|
|
35
42
|
//! Creates a new Block using the specified block_id and returns a pointer
|
43
|
+
unique_ptr<Block> ConvertBlock(block_id_t block_id, FileBuffer &source_buffer) override;
|
36
44
|
unique_ptr<Block> CreateBlock(block_id_t block_id, FileBuffer *source_buffer) override;
|
37
45
|
//! Return the next free block id
|
38
46
|
block_id_t GetFreeBlockId() override;
|
@@ -96,10 +104,8 @@ private:
|
|
96
104
|
block_id_t free_list_id;
|
97
105
|
//! The current header iteration count
|
98
106
|
uint64_t iteration_count;
|
99
|
-
//!
|
100
|
-
|
101
|
-
//! Whether or not to use Direct IO to read the blocks
|
102
|
-
bool use_direct_io;
|
107
|
+
//! The storage manager options
|
108
|
+
StorageManagerOptions options;
|
103
109
|
//! Lock for performing various operations in the single file block manager
|
104
110
|
mutex block_lock;
|
105
111
|
};
|
@@ -155,7 +155,7 @@ public:
|
|
155
155
|
remaining_space -= required_space;
|
156
156
|
auto dict_pos = end - *dictionary_size;
|
157
157
|
// now write the actual string data into the dictionary
|
158
|
-
memcpy(dict_pos, source_data[source_idx].
|
158
|
+
memcpy(dict_pos, source_data[source_idx].GetData(), string_length);
|
159
159
|
|
160
160
|
// place the dictionary offset into the set of vectors
|
161
161
|
result_data[target_idx] = *dictionary_size;
|
@@ -35,7 +35,7 @@ bool CastDecimalCInternal(duckdb_result *source, duckdb_string &result, idx_t co
|
|
35
35
|
throw duckdb::InternalException("Unimplemented internal type for decimal");
|
36
36
|
}
|
37
37
|
result.data = (char *)duckdb_malloc(sizeof(char) * (result_string.GetSize() + 1));
|
38
|
-
memcpy(result.data, result_string.
|
38
|
+
memcpy(result.data, result_string.GetData(), result_string.GetSize());
|
39
39
|
result.data[result_string.GetSize()] = '\0';
|
40
40
|
result.size = result_string.GetSize();
|
41
41
|
return true;
|
@@ -21,7 +21,7 @@ struct CStringConverter {
|
|
21
21
|
static DST Convert(SRC input) {
|
22
22
|
auto result = (char *)duckdb_malloc(input.GetSize() + 1);
|
23
23
|
assert(result);
|
24
|
-
memcpy((void *)result, input.
|
24
|
+
memcpy((void *)result, input.GetData(), input.GetSize());
|
25
25
|
auto write_arr = (char *)result;
|
26
26
|
write_arr[input.GetSize()] = '\0';
|
27
27
|
return result;
|
@@ -40,7 +40,7 @@ struct CBlobConverter {
|
|
40
40
|
result.data = (char *)duckdb_malloc(input.GetSize());
|
41
41
|
result.size = input.GetSize();
|
42
42
|
assert(result.data);
|
43
|
-
memcpy((void *)result.data, input.
|
43
|
+
memcpy((void *)result.data, input.GetData(), input.GetSize());
|
44
44
|
return result;
|
45
45
|
}
|
46
46
|
|
@@ -54,6 +54,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
54
54
|
DUCKDB_GLOBAL(DebugCheckpointAbort),
|
55
55
|
DUCKDB_LOCAL(DebugForceExternal),
|
56
56
|
DUCKDB_LOCAL(DebugForceNoCrossProduct),
|
57
|
+
DUCKDB_LOCAL(DebugAsOfIEJoin),
|
57
58
|
DUCKDB_GLOBAL(DebugWindowMode),
|
58
59
|
DUCKDB_GLOBAL_LOCAL(DefaultCollationSetting),
|
59
60
|
DUCKDB_GLOBAL(DefaultOrderSetting),
|
@@ -359,4 +360,29 @@ bool DBConfig::operator!=(const DBConfig &other) {
|
|
359
360
|
return !(other.options == options);
|
360
361
|
}
|
361
362
|
|
363
|
+
OrderType DBConfig::ResolveOrder(OrderType order_type) const {
|
364
|
+
if (order_type != OrderType::ORDER_DEFAULT) {
|
365
|
+
return order_type;
|
366
|
+
}
|
367
|
+
return options.default_order_type;
|
368
|
+
}
|
369
|
+
|
370
|
+
OrderByNullType DBConfig::ResolveNullOrder(OrderType order_type, OrderByNullType null_type) const {
|
371
|
+
if (null_type != OrderByNullType::ORDER_DEFAULT) {
|
372
|
+
return null_type;
|
373
|
+
}
|
374
|
+
switch (options.default_null_order) {
|
375
|
+
case DefaultOrderByNullType::NULLS_FIRST:
|
376
|
+
return OrderByNullType::NULLS_FIRST;
|
377
|
+
case DefaultOrderByNullType::NULLS_LAST:
|
378
|
+
return OrderByNullType::NULLS_LAST;
|
379
|
+
case DefaultOrderByNullType::NULLS_FIRST_ON_ASC_LAST_ON_DESC:
|
380
|
+
return order_type == OrderType::ASCENDING ? OrderByNullType::NULLS_FIRST : OrderByNullType::NULLS_LAST;
|
381
|
+
case DefaultOrderByNullType::NULLS_LAST_ON_ASC_FIRST_ON_DESC:
|
382
|
+
return order_type == OrderType::ASCENDING ? OrderByNullType::NULLS_LAST : OrderByNullType::NULLS_FIRST;
|
383
|
+
default:
|
384
|
+
throw InternalException("Unknown null order setting");
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
362
388
|
} // namespace duckdb
|
@@ -142,7 +142,7 @@ Value DebugForceNoCrossProduct::GetSetting(ClientContext &context) {
|
|
142
142
|
}
|
143
143
|
|
144
144
|
//===--------------------------------------------------------------------===//
|
145
|
-
//
|
145
|
+
// Ordered Aggregate Threshold
|
146
146
|
//===--------------------------------------------------------------------===//
|
147
147
|
|
148
148
|
void OrderedAggregateThreshold::ResetLocal(ClientContext &context) {
|
@@ -185,6 +185,21 @@ Value DebugWindowMode::GetSetting(ClientContext &context) {
|
|
185
185
|
return Value();
|
186
186
|
}
|
187
187
|
|
188
|
+
//===--------------------------------------------------------------------===//
|
189
|
+
// Debug AsOf Join
|
190
|
+
//===--------------------------------------------------------------------===//
|
191
|
+
void DebugAsOfIEJoin::ResetLocal(ClientContext &context) {
|
192
|
+
ClientConfig::GetConfig(context).force_no_cross_product = ClientConfig().force_asof_iejoin;
|
193
|
+
}
|
194
|
+
|
195
|
+
void DebugAsOfIEJoin::SetLocal(ClientContext &context, const Value &input) {
|
196
|
+
ClientConfig::GetConfig(context).force_asof_iejoin = input.GetValue<bool>();
|
197
|
+
}
|
198
|
+
|
199
|
+
Value DebugAsOfIEJoin::GetSetting(ClientContext &context) {
|
200
|
+
return Value::BOOLEAN(ClientConfig::GetConfig(context).force_asof_iejoin);
|
201
|
+
}
|
202
|
+
|
188
203
|
//===--------------------------------------------------------------------===//
|
189
204
|
// Default Collation
|
190
205
|
//===--------------------------------------------------------------------===//
|
@@ -253,14 +268,18 @@ void DefaultNullOrderSetting::SetGlobal(DatabaseInstance *db, DBConfig &config,
|
|
253
268
|
auto parameter = StringUtil::Lower(input.ToString());
|
254
269
|
|
255
270
|
if (parameter == "nulls_first" || parameter == "nulls first" || parameter == "null first" || parameter == "first") {
|
256
|
-
config.options.default_null_order =
|
271
|
+
config.options.default_null_order = DefaultOrderByNullType::NULLS_FIRST;
|
257
272
|
} else if (parameter == "nulls_last" || parameter == "nulls last" || parameter == "null last" ||
|
258
273
|
parameter == "last") {
|
259
|
-
config.options.default_null_order =
|
274
|
+
config.options.default_null_order = DefaultOrderByNullType::NULLS_LAST;
|
275
|
+
} else if (parameter == "nulls_first_on_asc_last_on_desc" || parameter == "sqlite" || parameter == "mysql") {
|
276
|
+
config.options.default_null_order = DefaultOrderByNullType::NULLS_FIRST_ON_ASC_LAST_ON_DESC;
|
277
|
+
} else if (parameter == "nulls_last_on_asc_first_on_desc" || parameter == "postgres") {
|
278
|
+
config.options.default_null_order = DefaultOrderByNullType::NULLS_LAST_ON_ASC_FIRST_ON_DESC;
|
260
279
|
} else {
|
261
|
-
throw ParserException(
|
262
|
-
|
263
|
-
|
280
|
+
throw ParserException("Unrecognized parameter for option NULL_ORDER \"%s\", expected either NULLS FIRST, NULLS "
|
281
|
+
"LAST, SQLite, MySQL or Postgres",
|
282
|
+
parameter);
|
264
283
|
}
|
265
284
|
}
|
266
285
|
|
@@ -271,10 +290,14 @@ void DefaultNullOrderSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config
|
|
271
290
|
Value DefaultNullOrderSetting::GetSetting(ClientContext &context) {
|
272
291
|
auto &config = DBConfig::GetConfig(context);
|
273
292
|
switch (config.options.default_null_order) {
|
274
|
-
case
|
293
|
+
case DefaultOrderByNullType::NULLS_FIRST:
|
275
294
|
return "nulls_first";
|
276
|
-
case
|
295
|
+
case DefaultOrderByNullType::NULLS_LAST:
|
277
296
|
return "nulls_last";
|
297
|
+
case DefaultOrderByNullType::NULLS_FIRST_ON_ASC_LAST_ON_DESC:
|
298
|
+
return "nulls_first_on_asc_last_on_desc";
|
299
|
+
case DefaultOrderByNullType::NULLS_LAST_ON_ASC_FIRST_ON_DESC:
|
300
|
+
return "nulls_last_on_asc_first_on_desc";
|
278
301
|
default:
|
279
302
|
throw InternalException("Unknown null order setting");
|
280
303
|
}
|
@@ -73,8 +73,8 @@ void CommonSubExpressionOptimizer::CountExpressions(Expression &expr, CSEReplace
|
|
73
73
|
ExpressionIterator::EnumerateChildren(expr, [&](Expression &child) { CountExpressions(child, state); });
|
74
74
|
}
|
75
75
|
|
76
|
-
void CommonSubExpressionOptimizer::PerformCSEReplacement(unique_ptr<Expression>
|
77
|
-
Expression &expr =
|
76
|
+
void CommonSubExpressionOptimizer::PerformCSEReplacement(unique_ptr<Expression> &expr_ptr, CSEReplacementState &state) {
|
77
|
+
Expression &expr = *expr_ptr;
|
78
78
|
if (expr.expression_class == ExpressionClass::BOUND_COLUMN_REF) {
|
79
79
|
auto &bound_column_ref = expr.Cast<BoundColumnRefExpression>();
|
80
80
|
// bound column ref, check if this one has already been recorded in the expression list
|
@@ -105,20 +105,20 @@ void CommonSubExpressionOptimizer::PerformCSEReplacement(unique_ptr<Expression>
|
|
105
105
|
if (node.column_index == DConstants::INVALID_INDEX) {
|
106
106
|
// has not been pushed yet: push it
|
107
107
|
node.column_index = state.expressions.size();
|
108
|
-
state.expressions.push_back(std::move(
|
108
|
+
state.expressions.push_back(std::move(expr_ptr));
|
109
109
|
} else {
|
110
|
-
state.cached_expressions.push_back(std::move(
|
110
|
+
state.cached_expressions.push_back(std::move(expr_ptr));
|
111
111
|
}
|
112
112
|
// replace the original expression with a bound column ref
|
113
|
-
|
114
|
-
|
113
|
+
expr_ptr = make_uniq<BoundColumnRefExpression>(alias, type,
|
114
|
+
ColumnBinding(state.projection_index, node.column_index));
|
115
115
|
return;
|
116
116
|
}
|
117
117
|
}
|
118
118
|
// this expression only occurs once, we can't perform CSE elimination
|
119
119
|
// look into the children to see if we can replace them
|
120
120
|
ExpressionIterator::EnumerateChildren(expr,
|
121
|
-
[&](unique_ptr<Expression> &child) { PerformCSEReplacement(
|
121
|
+
[&](unique_ptr<Expression> &child) { PerformCSEReplacement(child, state); });
|
122
122
|
}
|
123
123
|
|
124
124
|
void CommonSubExpressionOptimizer::ExtractCommonSubExpresions(LogicalOperator &op) {
|
@@ -143,8 +143,9 @@ void CommonSubExpressionOptimizer::ExtractCommonSubExpresions(LogicalOperator &o
|
|
143
143
|
state.projection_index = binder.GenerateTableIndex();
|
144
144
|
// we found common subexpressions to extract
|
145
145
|
// now we iterate over all the expressions and perform the actual CSE elimination
|
146
|
+
|
146
147
|
LogicalOperatorVisitor::EnumerateExpressions(
|
147
|
-
op, [&](unique_ptr<Expression> *child) { PerformCSEReplacement(child, state); });
|
148
|
+
op, [&](unique_ptr<Expression> *child) { PerformCSEReplacement(*child, state); });
|
148
149
|
D_ASSERT(state.expressions.size() > 0);
|
149
150
|
// create a projection node as the child of this node
|
150
151
|
auto projection = make_uniq<LogicalProjection>(state.projection_index, std::move(state.expressions));
|
@@ -77,7 +77,7 @@ unique_ptr<ParsedExpression> SubqueryExpression::Deserialize(ExpressionType type
|
|
77
77
|
void SubqueryExpression::FormatSerialize(FormatSerializer &serializer) const {
|
78
78
|
ParsedExpression::FormatSerialize(serializer);
|
79
79
|
serializer.WriteProperty("subquery_type", subquery_type);
|
80
|
-
serializer.WriteProperty("subquery", *subquery
|
80
|
+
serializer.WriteProperty("subquery", *subquery);
|
81
81
|
serializer.WriteOptionalProperty("child", child);
|
82
82
|
serializer.WriteProperty("comparison_type", comparison_type);
|
83
83
|
}
|
@@ -176,6 +176,8 @@ unique_ptr<QueryNode> Transformer::TransformPivotStatement(duckdb_libpgquery::PG
|
|
176
176
|
}
|
177
177
|
pivot_ref->pivots = std::move(columns);
|
178
178
|
select_node->from_table = std::move(pivot_ref);
|
179
|
+
// transform order by/limit modifiers
|
180
|
+
TransformModifiers(*stmt, *select_node);
|
179
181
|
return std::move(select_node);
|
180
182
|
}
|
181
183
|
|
@@ -8,6 +8,38 @@
|
|
8
8
|
|
9
9
|
namespace duckdb {
|
10
10
|
|
11
|
+
void Transformer::TransformModifiers(duckdb_libpgquery::PGSelectStmt &stmt, QueryNode &node) {
|
12
|
+
// transform the common properties
|
13
|
+
// both the set operations and the regular select can have an ORDER BY/LIMIT attached to them
|
14
|
+
vector<OrderByNode> orders;
|
15
|
+
TransformOrderBy(stmt.sortClause, orders);
|
16
|
+
if (!orders.empty()) {
|
17
|
+
auto order_modifier = make_uniq<OrderModifier>();
|
18
|
+
order_modifier->orders = std::move(orders);
|
19
|
+
node.modifiers.push_back(std::move(order_modifier));
|
20
|
+
}
|
21
|
+
if (stmt.limitCount || stmt.limitOffset) {
|
22
|
+
if (stmt.limitCount && stmt.limitCount->type == duckdb_libpgquery::T_PGLimitPercent) {
|
23
|
+
auto limit_percent_modifier = make_uniq<LimitPercentModifier>();
|
24
|
+
auto expr_node = reinterpret_cast<duckdb_libpgquery::PGLimitPercent *>(stmt.limitCount)->limit_percent;
|
25
|
+
limit_percent_modifier->limit = TransformExpression(expr_node);
|
26
|
+
if (stmt.limitOffset) {
|
27
|
+
limit_percent_modifier->offset = TransformExpression(stmt.limitOffset);
|
28
|
+
}
|
29
|
+
node.modifiers.push_back(std::move(limit_percent_modifier));
|
30
|
+
} else {
|
31
|
+
auto limit_modifier = make_uniq<LimitModifier>();
|
32
|
+
if (stmt.limitCount) {
|
33
|
+
limit_modifier->limit = TransformExpression(stmt.limitCount);
|
34
|
+
}
|
35
|
+
if (stmt.limitOffset) {
|
36
|
+
limit_modifier->offset = TransformExpression(stmt.limitOffset);
|
37
|
+
}
|
38
|
+
node.modifiers.push_back(std::move(limit_modifier));
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
11
43
|
unique_ptr<QueryNode> Transformer::TransformSelectInternal(duckdb_libpgquery::PGSelectStmt *stmt) {
|
12
44
|
D_ASSERT(stmt->type == duckdb_libpgquery::T_PGSelectStmt);
|
13
45
|
auto stack_checker = StackCheck();
|
@@ -119,35 +151,7 @@ unique_ptr<QueryNode> Transformer::TransformSelectInternal(duckdb_libpgquery::PG
|
|
119
151
|
default:
|
120
152
|
throw NotImplementedException("Statement type %d not implemented!", stmt->op);
|
121
153
|
}
|
122
|
-
|
123
|
-
// both the set operations and the regular select can have an ORDER BY/LIMIT attached to them
|
124
|
-
vector<OrderByNode> orders;
|
125
|
-
TransformOrderBy(stmt->sortClause, orders);
|
126
|
-
if (!orders.empty()) {
|
127
|
-
auto order_modifier = make_uniq<OrderModifier>();
|
128
|
-
order_modifier->orders = std::move(orders);
|
129
|
-
node->modifiers.push_back(std::move(order_modifier));
|
130
|
-
}
|
131
|
-
if (stmt->limitCount || stmt->limitOffset) {
|
132
|
-
if (stmt->limitCount && stmt->limitCount->type == duckdb_libpgquery::T_PGLimitPercent) {
|
133
|
-
auto limit_percent_modifier = make_uniq<LimitPercentModifier>();
|
134
|
-
auto expr_node = reinterpret_cast<duckdb_libpgquery::PGLimitPercent *>(stmt->limitCount)->limit_percent;
|
135
|
-
limit_percent_modifier->limit = TransformExpression(expr_node);
|
136
|
-
if (stmt->limitOffset) {
|
137
|
-
limit_percent_modifier->offset = TransformExpression(stmt->limitOffset);
|
138
|
-
}
|
139
|
-
node->modifiers.push_back(std::move(limit_percent_modifier));
|
140
|
-
} else {
|
141
|
-
auto limit_modifier = make_uniq<LimitModifier>();
|
142
|
-
if (stmt->limitCount) {
|
143
|
-
limit_modifier->limit = TransformExpression(stmt->limitCount);
|
144
|
-
}
|
145
|
-
if (stmt->limitOffset) {
|
146
|
-
limit_modifier->offset = TransformExpression(stmt->limitOffset);
|
147
|
-
}
|
148
|
-
node->modifiers.push_back(std::move(limit_modifier));
|
149
|
-
}
|
150
|
-
}
|
154
|
+
TransformModifiers(*stmt, *node);
|
151
155
|
return node;
|
152
156
|
}
|
153
157
|
|
@@ -60,7 +60,7 @@ static Value NegatePercentileValue(const Value &v, const bool desc) {
|
|
60
60
|
static void NegatePercentileFractions(ClientContext &context, unique_ptr<ParsedExpression> &fractions, bool desc) {
|
61
61
|
D_ASSERT(fractions.get());
|
62
62
|
D_ASSERT(fractions->expression_class == ExpressionClass::BOUND_EXPRESSION);
|
63
|
-
auto &bound = (
|
63
|
+
auto &bound = fractions->Cast<BoundExpression>();
|
64
64
|
|
65
65
|
if (!bound.expr->IsFoldable()) {
|
66
66
|
return;
|
@@ -81,7 +81,8 @@ static void NegatePercentileFractions(ClientContext &context, unique_ptr<ParsedE
|
|
81
81
|
}
|
82
82
|
}
|
83
83
|
|
84
|
-
BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFunctionCatalogEntry
|
84
|
+
BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, optional_ptr<AggregateFunctionCatalogEntry> func,
|
85
|
+
idx_t depth) {
|
85
86
|
// first bind the child of the aggregate expression (if any)
|
86
87
|
this->bound_aggregate = true;
|
87
88
|
unique_ptr<Expression> bound_filter;
|
@@ -137,7 +138,7 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFu
|
|
137
138
|
if (!success) {
|
138
139
|
throw BinderException(error);
|
139
140
|
}
|
140
|
-
auto &bound_expr =
|
141
|
+
auto &bound_expr = aggr.children[i]->Cast<BoundExpression>();
|
141
142
|
ExtractCorrelatedExpressions(binder, *bound_expr.expr);
|
142
143
|
}
|
143
144
|
if (aggr.filter) {
|
@@ -146,7 +147,7 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFu
|
|
146
147
|
if (!success) {
|
147
148
|
throw BinderException(error);
|
148
149
|
}
|
149
|
-
auto &bound_expr =
|
150
|
+
auto &bound_expr = aggr.filter->Cast<BoundExpression>();
|
150
151
|
ExtractCorrelatedExpressions(binder, *bound_expr.expr);
|
151
152
|
}
|
152
153
|
if (aggr.order_bys && !aggr.order_bys->orders.empty()) {
|
@@ -155,7 +156,7 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFu
|
|
155
156
|
if (!success) {
|
156
157
|
throw BinderException(error);
|
157
158
|
}
|
158
|
-
auto &bound_expr =
|
159
|
+
auto &bound_expr = order.expression->Cast<BoundExpression>();
|
159
160
|
ExtractCorrelatedExpressions(binder, *bound_expr.expr);
|
160
161
|
}
|
161
162
|
}
|
@@ -214,11 +215,8 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFu
|
|
214
215
|
auto &config = DBConfig::GetConfig(context);
|
215
216
|
for (auto &order : aggr.order_bys->orders) {
|
216
217
|
auto &order_expr = (BoundExpression &)*order.expression;
|
217
|
-
const auto sense =
|
218
|
-
|
219
|
-
const auto null_order = (order.null_order == OrderByNullType::ORDER_DEFAULT)
|
220
|
-
? config.options.default_null_order
|
221
|
-
: order.null_order;
|
218
|
+
const auto sense = config.ResolveOrder(order.type);
|
219
|
+
const auto null_order = config.ResolveNullOrder(sense, order.null_order);
|
222
220
|
order_bys->orders.emplace_back(sense, null_order, std::move(order_expr.expr));
|
223
221
|
}
|
224
222
|
}
|
@@ -8,7 +8,7 @@ namespace duckdb {
|
|
8
8
|
|
9
9
|
BindResult ExpressionBinder::BindExpression(CastExpression &expr, idx_t depth) {
|
10
10
|
// first try to bind the child of the cast expression
|
11
|
-
string error = Bind(
|
11
|
+
string error = Bind(expr.child, depth);
|
12
12
|
if (!error.empty()) {
|
13
13
|
return BindResult(error);
|
14
14
|
}
|
@@ -6,11 +6,11 @@ namespace duckdb {
|
|
6
6
|
|
7
7
|
BindResult ExpressionBinder::BindExpression(CollateExpression &expr, idx_t depth) {
|
8
8
|
// first try to bind the child of the cast expression
|
9
|
-
string error = Bind(
|
9
|
+
string error = Bind(expr.child, depth);
|
10
10
|
if (!error.empty()) {
|
11
11
|
return BindResult(error);
|
12
12
|
}
|
13
|
-
auto &child =
|
13
|
+
auto &child = expr.child->Cast<BoundExpression>();
|
14
14
|
if (child.expr->HasParameter()) {
|
15
15
|
throw ParameterNotResolvedException();
|
16
16
|
}
|
@@ -340,7 +340,7 @@ BindResult ExpressionBinder::BindExpression(ColumnRefExpression &colref_p, idx_t
|
|
340
340
|
// a generated column returns a generated expression, a struct on a column returns a struct extract
|
341
341
|
if (expr->type != ExpressionType::COLUMN_REF) {
|
342
342
|
auto alias = expr->alias;
|
343
|
-
auto result = BindExpression(
|
343
|
+
auto result = BindExpression(expr, depth);
|
344
344
|
if (result.expression) {
|
345
345
|
result.expression->alias = std::move(alias);
|
346
346
|
}
|
@@ -15,7 +15,7 @@
|
|
15
15
|
namespace duckdb {
|
16
16
|
|
17
17
|
BindResult ExpressionBinder::BindExpression(FunctionExpression &function, idx_t depth,
|
18
|
-
unique_ptr<ParsedExpression>
|
18
|
+
unique_ptr<ParsedExpression> &expr_ptr) {
|
19
19
|
// lookup the function in the catalog
|
20
20
|
QueryErrorContext error_context(binder.root_statement, function.query_location);
|
21
21
|
auto func = Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, function.catalog, function.schema,
|
@@ -87,7 +87,8 @@ BindResult ExpressionBinder::BindExpression(FunctionExpression &function, idx_t
|
|
87
87
|
}
|
88
88
|
}
|
89
89
|
|
90
|
-
BindResult ExpressionBinder::BindFunction(FunctionExpression &function, ScalarFunctionCatalogEntry
|
90
|
+
BindResult ExpressionBinder::BindFunction(FunctionExpression &function, optional_ptr<ScalarFunctionCatalogEntry> func,
|
91
|
+
idx_t depth) {
|
91
92
|
|
92
93
|
// bind the children of the function expression
|
93
94
|
string error;
|
@@ -122,8 +123,8 @@ BindResult ExpressionBinder::BindFunction(FunctionExpression &function, ScalarFu
|
|
122
123
|
return BindResult(std::move(result));
|
123
124
|
}
|
124
125
|
|
125
|
-
BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
126
|
-
idx_t depth) {
|
126
|
+
BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function,
|
127
|
+
optional_ptr<ScalarFunctionCatalogEntry> func, idx_t depth) {
|
127
128
|
|
128
129
|
// bind the children of the function expression
|
129
130
|
string error;
|
@@ -140,7 +141,7 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function, Sc
|
|
140
141
|
}
|
141
142
|
|
142
143
|
// get the logical type of the children of the list
|
143
|
-
auto &list_child =
|
144
|
+
auto &list_child = function.children[0]->Cast<BoundExpression>();
|
144
145
|
|
145
146
|
if (list_child.expr->return_type.id() != LogicalTypeId::LIST &&
|
146
147
|
list_child.expr->return_type.id() != LogicalTypeId::SQLNULL &&
|
@@ -233,8 +234,8 @@ BindResult ExpressionBinder::BindLambdaFunction(FunctionExpression &function, Sc
|
|
233
234
|
return BindResult(std::move(result));
|
234
235
|
}
|
235
236
|
|
236
|
-
BindResult ExpressionBinder::BindAggregate(FunctionExpression &expr,
|
237
|
-
idx_t depth) {
|
237
|
+
BindResult ExpressionBinder::BindAggregate(FunctionExpression &expr,
|
238
|
+
optional_ptr<AggregateFunctionCatalogEntry> function, idx_t depth) {
|
238
239
|
return BindResult(binder.FormatError(expr, UnsupportedAggregateMessage()));
|
239
240
|
}
|
240
241
|
|
@@ -78,13 +78,13 @@ BindResult ExpressionBinder::BindExpression(LambdaExpression &expr, idx_t depth,
|
|
78
78
|
|
79
79
|
// bind the parameter expressions
|
80
80
|
for (idx_t i = 0; i < expr.params.size(); i++) {
|
81
|
-
auto result = BindExpression(
|
81
|
+
auto result = BindExpression(expr.params[i], depth, false);
|
82
82
|
if (result.HasError()) {
|
83
83
|
throw InternalException("Error during lambda binding: %s", result.error);
|
84
84
|
}
|
85
85
|
}
|
86
86
|
|
87
|
-
auto result = BindExpression(
|
87
|
+
auto result = BindExpression(expr.expr, depth, false);
|
88
88
|
lambda_bindings->pop_back();
|
89
89
|
|
90
90
|
// successfully bound a subtree of nested lambdas, set this to nullptr in case other parts of the
|
@@ -44,10 +44,10 @@ 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, ScalarMacroCatalogEntry
|
48
|
-
unique_ptr<ParsedExpression>
|
47
|
+
BindResult ExpressionBinder::BindMacro(FunctionExpression &function, optional_ptr<ScalarMacroCatalogEntry> macro_func,
|
48
|
+
idx_t depth, unique_ptr<ParsedExpression> &expr) {
|
49
49
|
// recast function so we can access the scalar member function->expression
|
50
|
-
auto ¯o_def =
|
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;
|
@@ -56,7 +56,7 @@ BindResult ExpressionBinder::BindMacro(FunctionExpression &function, ScalarMacro
|
|
56
56
|
string error =
|
57
57
|
MacroFunction::ValidateArguments(*macro_func->function, macro_func->name, function, positionals, defaults);
|
58
58
|
if (!error.empty()) {
|
59
|
-
throw BinderException(binder.FormatError(*expr
|
59
|
+
throw BinderException(binder.FormatError(*expr, error));
|
60
60
|
}
|
61
61
|
|
62
62
|
// create a MacroBinding to bind this macro's parameters to its arguments
|
@@ -80,8 +80,8 @@ BindResult ExpressionBinder::BindMacro(FunctionExpression &function, ScalarMacro
|
|
80
80
|
macro_binding = new_macro_binding.get();
|
81
81
|
|
82
82
|
// replace current expression with stored macro expression, and replace params
|
83
|
-
|
84
|
-
ReplaceMacroParametersRecursive(
|
83
|
+
expr = macro_def.expression->Copy();
|
84
|
+
ReplaceMacroParametersRecursive(expr);
|
85
85
|
|
86
86
|
// bind the unfolded macro
|
87
87
|
return BindExpression(expr, depth);
|
@@ -127,8 +127,8 @@ BindResult ExpressionBinder::BindExpression(OperatorExpression &op, idx_t depth)
|
|
127
127
|
break;
|
128
128
|
}
|
129
129
|
if (!function_name.empty()) {
|
130
|
-
auto function =
|
131
|
-
return BindExpression(
|
130
|
+
auto function = make_uniq_base<ParsedExpression, FunctionExpression>(function_name, std::move(op.children));
|
131
|
+
return BindExpression(function, depth, false);
|
132
132
|
}
|
133
133
|
|
134
134
|
vector<BoundExpression *> children;
|
@@ -67,7 +67,7 @@ BindResult ExpressionBinder::BindExpression(SubqueryExpression &expr, idx_t dept
|
|
67
67
|
// now bind the child node of the subquery
|
68
68
|
if (expr.child) {
|
69
69
|
// first bind the children of the subquery, if any
|
70
|
-
string error = Bind(
|
70
|
+
string error = Bind(expr.child, depth);
|
71
71
|
if (!error.empty()) {
|
72
72
|
return BindResult(error);
|
73
73
|
}
|
@@ -64,14 +64,6 @@ static LogicalType ResolveWindowExpressionType(ExpressionType window_type, const
|
|
64
64
|
}
|
65
65
|
}
|
66
66
|
|
67
|
-
static inline OrderType ResolveOrderType(const DBConfig &config, OrderType type) {
|
68
|
-
return (type == OrderType::ORDER_DEFAULT) ? config.options.default_order_type : type;
|
69
|
-
}
|
70
|
-
|
71
|
-
static inline OrderByNullType ResolveNullOrder(const DBConfig &config, OrderByNullType null_order) {
|
72
|
-
return (null_order == OrderByNullType::ORDER_DEFAULT) ? config.options.default_null_order : null_order;
|
73
|
-
}
|
74
|
-
|
75
67
|
static unique_ptr<Expression> GetExpression(unique_ptr<ParsedExpression> &expr) {
|
76
68
|
if (!expr) {
|
77
69
|
return nullptr;
|
@@ -231,12 +223,12 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
|
|
231
223
|
LogicalType start_type = LogicalType::BIGINT;
|
232
224
|
if (window.start == WindowBoundary::EXPR_PRECEDING_RANGE) {
|
233
225
|
D_ASSERT(window.orders.size() == 1);
|
234
|
-
range_sense =
|
226
|
+
range_sense = config.ResolveOrder(window.orders[0].type);
|
235
227
|
const auto name = (range_sense == OrderType::ASCENDING) ? "-" : "+";
|
236
228
|
start_type = BindRangeExpression(context, name, window.start_expr, window.orders[0].expression);
|
237
229
|
} else if (window.start == WindowBoundary::EXPR_FOLLOWING_RANGE) {
|
238
230
|
D_ASSERT(window.orders.size() == 1);
|
239
|
-
range_sense =
|
231
|
+
range_sense = config.ResolveOrder(window.orders[0].type);
|
240
232
|
const auto name = (range_sense == OrderType::ASCENDING) ? "+" : "-";
|
241
233
|
start_type = BindRangeExpression(context, name, window.start_expr, window.orders[0].expression);
|
242
234
|
}
|
@@ -244,12 +236,12 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
|
|
244
236
|
LogicalType end_type = LogicalType::BIGINT;
|
245
237
|
if (window.end == WindowBoundary::EXPR_PRECEDING_RANGE) {
|
246
238
|
D_ASSERT(window.orders.size() == 1);
|
247
|
-
range_sense =
|
239
|
+
range_sense = config.ResolveOrder(window.orders[0].type);
|
248
240
|
const auto name = (range_sense == OrderType::ASCENDING) ? "-" : "+";
|
249
241
|
end_type = BindRangeExpression(context, name, window.end_expr, window.orders[0].expression);
|
250
242
|
} else if (window.end == WindowBoundary::EXPR_FOLLOWING_RANGE) {
|
251
243
|
D_ASSERT(window.orders.size() == 1);
|
252
|
-
range_sense =
|
244
|
+
range_sense = config.ResolveOrder(window.orders[0].type);
|
253
245
|
const auto name = (range_sense == OrderType::ASCENDING) ? "+" : "-";
|
254
246
|
end_type = BindRangeExpression(context, name, window.end_expr, window.orders[0].expression);
|
255
247
|
}
|
@@ -276,8 +268,8 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
|
|
276
268
|
}
|
277
269
|
|
278
270
|
for (auto &order : window.orders) {
|
279
|
-
auto type =
|
280
|
-
auto null_order = ResolveNullOrder(
|
271
|
+
auto type = config.ResolveOrder(order.type);
|
272
|
+
auto null_order = config.ResolveNullOrder(type, order.null_order);
|
281
273
|
auto expression = GetExpression(order.expression);
|
282
274
|
result->orders.emplace_back(type, null_order, std::move(expression));
|
283
275
|
}
|