duckdb 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/extension/core_functions/scalar/generic/current_setting.cpp +1 -4
- package/src/duckdb/extension/icu/icu-strptime.cpp +2 -1
- package/src/duckdb/extension/json/include/json_common.hpp +2 -4
- package/src/duckdb/extension/json/json_functions.cpp +5 -1
- package/src/duckdb/extension/parquet/column_writer.cpp +31 -21
- package/src/duckdb/extension/parquet/geo_parquet.cpp +21 -6
- package/src/duckdb/extension/parquet/include/column_writer.hpp +2 -2
- package/src/duckdb/extension/parquet/include/geo_parquet.hpp +28 -1
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +7 -2
- package/src/duckdb/extension/parquet/include/reader/string_column_reader.hpp +13 -0
- package/src/duckdb/extension/parquet/include/writer/array_column_writer.hpp +4 -0
- package/src/duckdb/extension/parquet/parquet_extension.cpp +56 -1
- package/src/duckdb/extension/parquet/parquet_reader.cpp +4 -1
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +5 -7
- package/src/duckdb/extension/parquet/parquet_writer.cpp +15 -8
- package/src/duckdb/extension/parquet/reader/string_column_reader.cpp +17 -4
- package/src/duckdb/extension/parquet/writer/array_column_writer.cpp +22 -28
- package/src/duckdb/extension/parquet/writer/primitive_column_writer.cpp +17 -5
- package/src/duckdb/extension/parquet/writer/struct_column_writer.cpp +3 -2
- package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -2
- package/src/duckdb/src/common/enum_util.cpp +20 -0
- package/src/duckdb/src/common/file_system.cpp +0 -30
- package/src/duckdb/src/common/sorting/sort.cpp +25 -6
- package/src/duckdb/src/common/sorting/sorted_run_merger.cpp +1 -0
- package/src/duckdb/src/common/string_util.cpp +24 -0
- package/src/duckdb/src/common/virtual_file_system.cpp +59 -10
- package/src/duckdb/src/execution/index/art/art_merger.cpp +0 -3
- package/src/duckdb/src/execution/index/art/prefix.cpp +4 -0
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +3 -3
- package/src/duckdb/src/function/table/system/duckdb_connection_count.cpp +45 -0
- package/src/duckdb/src/function/table/system/duckdb_settings.cpp +11 -1
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +3 -3
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +4 -1
- package/src/duckdb/src/include/duckdb/function/scalar/variant_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/logging/log_storage.hpp +6 -6
- package/src/duckdb/src/include/duckdb/logging/log_type.hpp +26 -3
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/connection.hpp +0 -1
- package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +0 -1
- package/src/duckdb/src/include/duckdb/main/database_file_path_manager.hpp +12 -1
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/relation/create_table_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/create_view_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/delete_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/explain_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/insert_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/query_relation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/relation/update_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/write_csv_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/write_parquet_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +3 -1
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +62 -3
- package/src/duckdb/src/include/duckdb/planner/expression_binder/lateral_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dependent_join.hpp +3 -3
- package/src/duckdb/src/include/duckdb/planner/subquery/flatten_dependent_join.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/subquery/has_correlated_expressions.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/subquery/rewrite_cte_scan.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_joinref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_analyze.hpp +6 -1
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_analyze.hpp +5 -1
- package/src/duckdb/src/include/duckdb/storage/metadata/metadata_manager.hpp +9 -7
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table/array_column_data.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +6 -6
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +5 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_id_column_data.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +2 -1
- package/src/duckdb/src/include/duckdb/transaction/update_info.hpp +4 -1
- package/src/duckdb/src/include/duckdb/transaction/wal_write_state.hpp +1 -1
- package/src/duckdb/src/logging/log_types.cpp +63 -0
- package/src/duckdb/src/main/attached_database.cpp +16 -3
- package/src/duckdb/src/main/client_context.cpp +27 -19
- package/src/duckdb/src/main/connection.cpp +2 -5
- package/src/duckdb/src/main/database_file_path_manager.cpp +23 -6
- package/src/duckdb/src/main/database_manager.cpp +18 -3
- package/src/duckdb/src/main/http/http_util.cpp +3 -1
- package/src/duckdb/src/main/relation/create_table_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/create_view_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/delete_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/explain_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/insert_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/query_relation.cpp +4 -0
- package/src/duckdb/src/main/relation/update_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/write_csv_relation.cpp +8 -0
- package/src/duckdb/src/main/relation/write_parquet_relation.cpp +8 -0
- package/src/duckdb/src/main/relation.cpp +2 -2
- package/src/duckdb/src/optimizer/filter_combiner.cpp +7 -0
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +9 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +4 -1
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +3 -7
- package/src/duckdb/src/parser/statement/relation_statement.cpp +1 -4
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +2 -0
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +8 -6
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +1 -5
- package/src/duckdb/src/planner/binder/statement/bind_merge_into.cpp +10 -2
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +20 -3
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +8 -3
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +9 -2
- package/src/duckdb/src/planner/binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +9 -13
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +4 -0
- package/src/duckdb/src/planner/expression_binder.cpp +3 -1
- package/src/duckdb/src/planner/operator/logical_dependent_join.cpp +2 -2
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +12 -14
- package/src/duckdb/src/planner/subquery/has_correlated_expressions.cpp +1 -1
- package/src/duckdb/src/planner/subquery/rewrite_cte_scan.cpp +2 -2
- package/src/duckdb/src/storage/compression/bitpacking.cpp +1 -2
- package/src/duckdb/src/storage/data_table.cpp +2 -2
- package/src/duckdb/src/storage/local_storage.cpp +1 -1
- package/src/duckdb/src/storage/metadata/metadata_manager.cpp +67 -25
- package/src/duckdb/src/storage/statistics/string_stats.cpp +8 -0
- package/src/duckdb/src/storage/table/array_column_data.cpp +6 -5
- package/src/duckdb/src/storage/table/column_data.cpp +23 -9
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +15 -1
- package/src/duckdb/src/storage/table/list_column_data.cpp +5 -4
- package/src/duckdb/src/storage/table/row_group.cpp +8 -8
- package/src/duckdb/src/storage/table/row_group_collection.cpp +12 -8
- package/src/duckdb/src/storage/table/row_id_column_data.cpp +5 -4
- package/src/duckdb/src/storage/table/standard_column_data.cpp +9 -8
- package/src/duckdb/src/storage/table/struct_column_data.cpp +10 -9
- package/src/duckdb/src/storage/table/update_segment.cpp +12 -10
- package/src/duckdb/src/transaction/commit_state.cpp +18 -0
- package/src/duckdb/src/transaction/duck_transaction.cpp +2 -10
- package/src/duckdb/src/transaction/wal_write_state.cpp +5 -5
- package/src/duckdb/third_party/httplib/httplib.hpp +6 -1
- package/src/duckdb/ub_src_function_table_system.cpp +2 -0
@@ -318,6 +318,8 @@ public:
|
|
318
318
|
//! Transforms an complex JSON to a JSON string
|
319
319
|
DUCKDB_API static string ToComplexJSONMap(const ComplexJSON &complex_json);
|
320
320
|
|
321
|
+
DUCKDB_API static string ValidateJSON(const char *data, const idx_t &len);
|
322
|
+
|
321
323
|
DUCKDB_API static string GetFileName(const string &file_path);
|
322
324
|
DUCKDB_API static string GetFileExtension(const string &file_name);
|
323
325
|
DUCKDB_API static string GetFileStem(const string &file_name);
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "duckdb/common/file_system.hpp"
|
12
12
|
#include "duckdb/common/map.hpp"
|
13
13
|
#include "duckdb/common/unordered_set.hpp"
|
14
|
+
#include "duckdb/main/extension_helper.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
|
@@ -82,8 +83,10 @@ protected:
|
|
82
83
|
}
|
83
84
|
|
84
85
|
private:
|
86
|
+
FileSystem &FindFileSystem(const string &path, optional_ptr<FileOpener> file_opener);
|
87
|
+
FileSystem &FindFileSystem(const string &path, optional_ptr<DatabaseInstance> database_instance);
|
85
88
|
FileSystem &FindFileSystem(const string &path);
|
86
|
-
FileSystem
|
89
|
+
optional_ptr<FileSystem> FindFileSystemInternal(const string &path);
|
87
90
|
|
88
91
|
private:
|
89
92
|
vector<unique_ptr<FileSystem>> sub_systems;
|
@@ -29,7 +29,7 @@ struct VariantTypeofFun {
|
|
29
29
|
static constexpr const char *Name = "variant_typeof";
|
30
30
|
static constexpr const char *Parameters = "input_variant";
|
31
31
|
static constexpr const char *Description = "Returns the internal type of the `input_variant`.";
|
32
|
-
static constexpr const char *Example = "variant_typeof({'a': 42, 'b': [1,2,3])::VARIANT)";
|
32
|
+
static constexpr const char *Example = "variant_typeof({'a': 42, 'b': [1,2,3]})::VARIANT)";
|
33
33
|
static constexpr const char *Categories = "variant";
|
34
34
|
|
35
35
|
static ScalarFunction GetFunction();
|
@@ -47,6 +47,10 @@ struct DuckDBSchemasFun {
|
|
47
47
|
static void RegisterFunction(BuiltinFunctions &set);
|
48
48
|
};
|
49
49
|
|
50
|
+
struct DuckDBConnectionCountFun {
|
51
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
52
|
+
};
|
53
|
+
|
50
54
|
struct DuckDBApproxDatabaseCountFun {
|
51
55
|
static void RegisterFunction(BuiltinFunctions &set);
|
52
56
|
};
|
@@ -33,7 +33,7 @@ struct CSVReaderOptions;
|
|
33
33
|
|
34
34
|
//! Logging storage can store entries normalized or denormalized. This enum describes what a single table/file/etc
|
35
35
|
//! contains
|
36
|
-
enum class LoggingTargetTable {
|
36
|
+
enum class LoggingTargetTable : uint8_t {
|
37
37
|
ALL_LOGS, // Denormalized: log entries consisting of both the full log entry and the context
|
38
38
|
LOG_ENTRIES, // Normalized: contains only the log entries and a context_id
|
39
39
|
LOG_CONTEXTS, // Normalized: contains only the log contexts
|
@@ -165,7 +165,7 @@ private:
|
|
165
165
|
//! Debug option for testing buffering behaviour
|
166
166
|
bool only_flush_on_full_buffer = false;
|
167
167
|
//! The buffers used for each table
|
168
|
-
|
168
|
+
map<LoggingTargetTable, unique_ptr<DataChunk>> buffers;
|
169
169
|
//! This flag is set whenever a new context_is written to the entry buffer. It means that the next flush of
|
170
170
|
//! LoggingTargetTable::LOG_ENTRIES also requires a flush of LoggingTargetTable::LOG_CONTEXTS
|
171
171
|
bool flush_contexts_on_next_entry_flush = false;
|
@@ -218,9 +218,9 @@ private:
|
|
218
218
|
void InitializeCastChunk(LoggingTargetTable table);
|
219
219
|
|
220
220
|
//! The cast buffers used to cast from the original types to the VARCHAR types ready to write to CSV format
|
221
|
-
|
221
|
+
map<LoggingTargetTable, unique_ptr<DataChunk>> cast_buffers;
|
222
222
|
//! The writers to be registered by child classes
|
223
|
-
|
223
|
+
map<LoggingTargetTable, unique_ptr<CSVWriter>> writers;
|
224
224
|
|
225
225
|
//! CSV Options to initialize the CSVWriters with. TODO: cleanup, this is now a little bit of a mixed bag of
|
226
226
|
//! settings
|
@@ -302,7 +302,7 @@ private:
|
|
302
302
|
};
|
303
303
|
|
304
304
|
//! The table info per table
|
305
|
-
|
305
|
+
map<LoggingTargetTable, TableWriter> tables;
|
306
306
|
|
307
307
|
//! Base path to generate the file paths from
|
308
308
|
string base_path;
|
@@ -349,7 +349,7 @@ private:
|
|
349
349
|
//! Helper function to get the buffer
|
350
350
|
ColumnDataCollection &GetBuffer(LoggingTargetTable table) const;
|
351
351
|
|
352
|
-
|
352
|
+
map<LoggingTargetTable, unique_ptr<ColumnDataCollection>> log_storage_buffers;
|
353
353
|
};
|
354
354
|
|
355
355
|
} // namespace duckdb
|
@@ -17,6 +17,9 @@ struct FileHandle;
|
|
17
17
|
struct BaseRequest;
|
18
18
|
struct HTTPResponse;
|
19
19
|
class PhysicalOperator;
|
20
|
+
class AttachedDatabase;
|
21
|
+
class RowGroup;
|
22
|
+
struct DataTableInfo;
|
20
23
|
|
21
24
|
//! Log types provide some structure to the formats that the different log messages can have
|
22
25
|
//! For now, this holds a type that the VARCHAR value will be auto-cast into.
|
@@ -54,9 +57,7 @@ public:
|
|
54
57
|
|
55
58
|
QueryLogType() : LogType(NAME, LEVEL) {};
|
56
59
|
|
57
|
-
static string ConstructLogMessage(const string &str)
|
58
|
-
return str;
|
59
|
-
}
|
60
|
+
static string ConstructLogMessage(const string &str);
|
60
61
|
};
|
61
62
|
|
62
63
|
class FileSystemLogType : public LogType {
|
@@ -105,4 +106,26 @@ public:
|
|
105
106
|
const vector<pair<string, string>> &info);
|
106
107
|
};
|
107
108
|
|
109
|
+
class CheckpointLogType : public LogType {
|
110
|
+
public:
|
111
|
+
static constexpr const char *NAME = "Checkpoint";
|
112
|
+
static constexpr LogLevel LEVEL = LogLevel::LOG_DEBUG;
|
113
|
+
|
114
|
+
//! Construct the log type
|
115
|
+
CheckpointLogType();
|
116
|
+
|
117
|
+
static LogicalType GetLogType();
|
118
|
+
|
119
|
+
//! Vacuum
|
120
|
+
static string ConstructLogMessage(const AttachedDatabase &db, DataTableInfo &table, idx_t segment_idx,
|
121
|
+
idx_t merge_count, idx_t target_count, idx_t merge_rows, idx_t row_start);
|
122
|
+
//! Checkpoint
|
123
|
+
static string ConstructLogMessage(const AttachedDatabase &db, DataTableInfo &table, idx_t segment_idx,
|
124
|
+
RowGroup &row_group);
|
125
|
+
|
126
|
+
private:
|
127
|
+
static string CreateLog(const AttachedDatabase &db, DataTableInfo &table, const char *op, vector<Value> map_keys,
|
128
|
+
vector<Value> map_values);
|
129
|
+
};
|
130
|
+
|
108
131
|
} // namespace duckdb
|
@@ -40,6 +40,9 @@ struct StoredDatabasePath {
|
|
40
40
|
|
41
41
|
DatabaseFilePathManager &manager;
|
42
42
|
string path;
|
43
|
+
|
44
|
+
public:
|
45
|
+
void OnDetach();
|
43
46
|
};
|
44
47
|
|
45
48
|
//! AttachOptions holds information about a database we plan to attach. These options are generalized, i.e.,
|
@@ -103,6 +106,7 @@ public:
|
|
103
106
|
void SetInitialDatabase();
|
104
107
|
void SetReadOnlyDatabase();
|
105
108
|
void OnDetach(ClientContext &context);
|
109
|
+
string StoredPath() const;
|
106
110
|
|
107
111
|
static bool NameIsReserved(const string &name);
|
108
112
|
static string ExtractDatabaseName(const string &dbpath, FileSystem &fs);
|
@@ -304,6 +304,8 @@ private:
|
|
304
304
|
CreatePreparedStatementInternal(ClientContextLock &lock, const string &query, unique_ptr<SQLStatement> statement,
|
305
305
|
optional_ptr<case_insensitive_map_t<BoundParameterData>> values);
|
306
306
|
|
307
|
+
SettingLookupResult TryGetCurrentSettingInternal(const string &key, Value &result) const;
|
308
|
+
|
307
309
|
private:
|
308
310
|
//! Lock on using the ClientContext in parallel
|
309
311
|
mutex context_lock;
|
@@ -19,13 +19,24 @@ struct AttachOptions;
|
|
19
19
|
|
20
20
|
enum class InsertDatabasePathResult { SUCCESS, ALREADY_EXISTS };
|
21
21
|
|
22
|
+
struct DatabasePathInfo {
|
23
|
+
explicit DatabasePathInfo(string name_p) : name(std::move(name_p)), is_attached(true) {
|
24
|
+
}
|
25
|
+
|
26
|
+
string name;
|
27
|
+
bool is_attached;
|
28
|
+
};
|
29
|
+
|
22
30
|
//! The DatabaseFilePathManager is used to ensure we only ever open a single database file once
|
23
31
|
class DatabaseFilePathManager {
|
24
32
|
public:
|
25
33
|
idx_t ApproxDatabaseCount() const;
|
26
34
|
InsertDatabasePathResult InsertDatabasePath(const string &path, const string &name, OnCreateConflict on_conflict,
|
27
35
|
AttachOptions &options);
|
36
|
+
//! Erase a database path - indicating we are done with using it
|
28
37
|
void EraseDatabasePath(const string &path);
|
38
|
+
//! Called when a database is detached, but before it is fully finished being used
|
39
|
+
void DetachDatabase(const string &path);
|
29
40
|
|
30
41
|
private:
|
31
42
|
//! The lock to add entries to the database path map
|
@@ -33,7 +44,7 @@ private:
|
|
33
44
|
//! A set containing all attached database path
|
34
45
|
//! This allows to attach many databases efficiently, and to avoid attaching the
|
35
46
|
//! same file path twice
|
36
|
-
case_insensitive_map_t<
|
47
|
+
case_insensitive_map_t<DatabasePathInfo> db_paths;
|
37
48
|
};
|
38
49
|
|
39
50
|
} // namespace duckdb
|
@@ -48,6 +48,7 @@ public:
|
|
48
48
|
void FinalizeStartup();
|
49
49
|
//! Get an attached database by its name
|
50
50
|
optional_ptr<AttachedDatabase> GetDatabase(ClientContext &context, const string &name);
|
51
|
+
shared_ptr<AttachedDatabase> GetDatabase(const string &name);
|
51
52
|
//! Attach a new database
|
52
53
|
shared_ptr<AttachedDatabase> AttachDatabase(ClientContext &context, AttachInfo &info, AttachOptions &options);
|
53
54
|
|
@@ -103,6 +104,8 @@ public:
|
|
103
104
|
//! Gets a list of all attached database paths
|
104
105
|
vector<string> GetAttachedDatabasePaths();
|
105
106
|
|
107
|
+
shared_ptr<AttachedDatabase> GetDatabaseInternal(const lock_guard<mutex> &, const string &name);
|
108
|
+
|
106
109
|
private:
|
107
110
|
//! The system database is a special database that holds system entries (e.g. functions)
|
108
111
|
shared_ptr<AttachedDatabase> system;
|
@@ -26,6 +26,8 @@ public:
|
|
26
26
|
|
27
27
|
public:
|
28
28
|
BoundStatement Bind(Binder &binder) override;
|
29
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
30
|
+
string GetQuery() override;
|
29
31
|
const vector<ColumnDefinition> &Columns() override;
|
30
32
|
string ToString(idx_t depth) override;
|
31
33
|
bool IsReadOnly() override {
|
@@ -26,6 +26,8 @@ public:
|
|
26
26
|
|
27
27
|
public:
|
28
28
|
BoundStatement Bind(Binder &binder) override;
|
29
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
30
|
+
string GetQuery() override;
|
29
31
|
const vector<ColumnDefinition> &Columns() override;
|
30
32
|
string ToString(idx_t depth) override;
|
31
33
|
bool IsReadOnly() override {
|
@@ -26,6 +26,8 @@ public:
|
|
26
26
|
|
27
27
|
public:
|
28
28
|
BoundStatement Bind(Binder &binder) override;
|
29
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
30
|
+
string GetQuery() override;
|
29
31
|
const vector<ColumnDefinition> &Columns() override;
|
30
32
|
string ToString(idx_t depth) override;
|
31
33
|
bool IsReadOnly() override {
|
@@ -24,6 +24,8 @@ public:
|
|
24
24
|
|
25
25
|
public:
|
26
26
|
BoundStatement Bind(Binder &binder) override;
|
27
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
28
|
+
string GetQuery() override;
|
27
29
|
const vector<ColumnDefinition> &Columns() override;
|
28
30
|
string ToString(idx_t depth) override;
|
29
31
|
bool IsReadOnly() override {
|
@@ -23,6 +23,8 @@ public:
|
|
23
23
|
|
24
24
|
public:
|
25
25
|
BoundStatement Bind(Binder &binder) override;
|
26
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
27
|
+
string GetQuery() override;
|
26
28
|
const vector<ColumnDefinition> &Columns() override;
|
27
29
|
string ToString(idx_t depth) override;
|
28
30
|
bool IsReadOnly() override {
|
@@ -28,6 +28,7 @@ public:
|
|
28
28
|
public:
|
29
29
|
static unique_ptr<SelectStatement> ParseStatement(ClientContext &context, const string &query, const string &error);
|
30
30
|
unique_ptr<QueryNode> GetQueryNode() override;
|
31
|
+
string GetQuery() override;
|
31
32
|
unique_ptr<TableRef> GetTableRef() override;
|
32
33
|
BoundStatement Bind(Binder &binder) override;
|
33
34
|
|
@@ -29,6 +29,8 @@ public:
|
|
29
29
|
|
30
30
|
public:
|
31
31
|
BoundStatement Bind(Binder &binder) override;
|
32
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
33
|
+
string GetQuery() override;
|
32
34
|
const vector<ColumnDefinition> &Columns() override;
|
33
35
|
string ToString(idx_t depth) override;
|
34
36
|
bool IsReadOnly() override {
|
@@ -23,6 +23,8 @@ public:
|
|
23
23
|
|
24
24
|
public:
|
25
25
|
BoundStatement Bind(Binder &binder) override;
|
26
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
27
|
+
string GetQuery() override;
|
26
28
|
const vector<ColumnDefinition> &Columns() override;
|
27
29
|
string ToString(idx_t depth) override;
|
28
30
|
bool IsReadOnly() override {
|
@@ -24,6 +24,8 @@ public:
|
|
24
24
|
|
25
25
|
public:
|
26
26
|
BoundStatement Bind(Binder &binder) override;
|
27
|
+
unique_ptr<QueryNode> GetQueryNode() override;
|
28
|
+
string GetQuery() override;
|
27
29
|
const vector<ColumnDefinition> &Columns() override;
|
28
30
|
string ToString(idx_t depth) override;
|
29
31
|
bool IsReadOnly() override {
|
@@ -78,7 +78,8 @@ public:
|
|
78
78
|
|
79
79
|
public:
|
80
80
|
DUCKDB_API virtual const vector<ColumnDefinition> &Columns() = 0;
|
81
|
-
DUCKDB_API virtual unique_ptr<QueryNode> GetQueryNode();
|
81
|
+
DUCKDB_API virtual unique_ptr<QueryNode> GetQueryNode() = 0;
|
82
|
+
DUCKDB_API virtual string GetQuery();
|
82
83
|
DUCKDB_API virtual BoundStatement Bind(Binder &binder);
|
83
84
|
DUCKDB_API virtual string GetAlias();
|
84
85
|
|
@@ -296,7 +296,9 @@ public:
|
|
296
296
|
Value result;
|
297
297
|
auto lookup_result = TryGetSecretKeyOrSetting(secret_key, setting_name, result);
|
298
298
|
if (lookup_result) {
|
299
|
-
|
299
|
+
if (!result.IsNull()) {
|
300
|
+
value_out = result.GetValue<TYPE>();
|
301
|
+
}
|
300
302
|
}
|
301
303
|
return lookup_result;
|
302
304
|
}
|
@@ -102,8 +102,9 @@ private:
|
|
102
102
|
void ExtractFilterBindings(const Expression &expr, vector<ColumnBinding> &bindings);
|
103
103
|
//! Generate filters from the current set of filters stored in the FilterCombiner
|
104
104
|
void GenerateFilters();
|
105
|
-
//! if there are filters in this FilterPushdown node, push them into the combiner
|
106
|
-
|
105
|
+
//! if there are filters in this FilterPushdown node, push them into the combiner. Returns
|
106
|
+
//! FilterResult::UNSATISFIABLE if the subtree should be stripped, or FilterResult::SUCCESS otherwise
|
107
|
+
FilterResult PushFilters();
|
107
108
|
};
|
108
109
|
|
109
110
|
} // namespace duckdb
|
@@ -100,6 +100,65 @@ struct CorrelatedColumnInfo {
|
|
100
100
|
}
|
101
101
|
};
|
102
102
|
|
103
|
+
struct CorrelatedColumns {
|
104
|
+
private:
|
105
|
+
using container_type = vector<CorrelatedColumnInfo>;
|
106
|
+
|
107
|
+
public:
|
108
|
+
CorrelatedColumns() : delim_index(1ULL << 63) {
|
109
|
+
}
|
110
|
+
|
111
|
+
void AddColumn(container_type::value_type info) {
|
112
|
+
// Add to beginning
|
113
|
+
correlated_columns.insert(correlated_columns.begin(), std::move(info));
|
114
|
+
delim_index++;
|
115
|
+
}
|
116
|
+
|
117
|
+
void SetDelimIndexToZero() {
|
118
|
+
delim_index = 0;
|
119
|
+
}
|
120
|
+
|
121
|
+
idx_t GetDelimIndex() const {
|
122
|
+
return delim_index;
|
123
|
+
}
|
124
|
+
|
125
|
+
const container_type::value_type &operator[](const idx_t &index) const {
|
126
|
+
return correlated_columns.at(index);
|
127
|
+
}
|
128
|
+
|
129
|
+
idx_t size() const { // NOLINT: match stl case
|
130
|
+
return correlated_columns.size();
|
131
|
+
}
|
132
|
+
|
133
|
+
bool empty() const { // NOLINT: match stl case
|
134
|
+
return correlated_columns.empty();
|
135
|
+
}
|
136
|
+
|
137
|
+
void clear() { // NOLINT: match stl case
|
138
|
+
correlated_columns.clear();
|
139
|
+
}
|
140
|
+
|
141
|
+
container_type::iterator begin() { // NOLINT: match stl case
|
142
|
+
return correlated_columns.begin();
|
143
|
+
}
|
144
|
+
|
145
|
+
container_type::iterator end() { // NOLINT: match stl case
|
146
|
+
return correlated_columns.end();
|
147
|
+
}
|
148
|
+
|
149
|
+
container_type::const_iterator begin() const { // NOLINT: match stl case
|
150
|
+
return correlated_columns.begin();
|
151
|
+
}
|
152
|
+
|
153
|
+
container_type::const_iterator end() const { // NOLINT: match stl case
|
154
|
+
return correlated_columns.end();
|
155
|
+
}
|
156
|
+
|
157
|
+
private:
|
158
|
+
container_type correlated_columns;
|
159
|
+
idx_t delim_index;
|
160
|
+
};
|
161
|
+
|
103
162
|
//! Bind the parsed query tree to the actual columns present in the catalog.
|
104
163
|
/*!
|
105
164
|
The binder is responsible for binding tables and columns to actual physical
|
@@ -124,7 +183,7 @@ public:
|
|
124
183
|
BindContext bind_context;
|
125
184
|
//! The set of correlated columns bound by this binder (FIXME: this should probably be an unordered_set and not a
|
126
185
|
//! vector)
|
127
|
-
|
186
|
+
CorrelatedColumns correlated_columns;
|
128
187
|
//! The set of parameter expressions bound by this binder
|
129
188
|
optional_ptr<BoundParameterMap> parameters;
|
130
189
|
//! The alias for the currently processing subquery, if it exists
|
@@ -200,7 +259,7 @@ public:
|
|
200
259
|
|
201
260
|
vector<reference<ExpressionBinder>> &GetActiveBinders();
|
202
261
|
|
203
|
-
void MergeCorrelatedColumns(
|
262
|
+
void MergeCorrelatedColumns(CorrelatedColumns &other);
|
204
263
|
//! Add a correlated column to this binder (if it does not exist)
|
205
264
|
void AddCorrelatedColumn(const CorrelatedColumnInfo &info);
|
206
265
|
|
@@ -428,7 +487,7 @@ private:
|
|
428
487
|
void PlanSubqueries(unique_ptr<Expression> &expr, unique_ptr<LogicalOperator> &root);
|
429
488
|
unique_ptr<Expression> PlanSubquery(BoundSubqueryExpression &expr, unique_ptr<LogicalOperator> &root);
|
430
489
|
unique_ptr<LogicalOperator> PlanLateralJoin(unique_ptr<LogicalOperator> left, unique_ptr<LogicalOperator> right,
|
431
|
-
|
490
|
+
CorrelatedColumns &correlated_columns,
|
432
491
|
JoinType join_type = JoinType::INNER,
|
433
492
|
unique_ptr<Expression> condition = nullptr);
|
434
493
|
|
@@ -24,7 +24,7 @@ public:
|
|
24
24
|
return !correlated_columns.empty();
|
25
25
|
}
|
26
26
|
|
27
|
-
static void ReduceExpressionDepth(LogicalOperator &op, const
|
27
|
+
static void ReduceExpressionDepth(LogicalOperator &op, const CorrelatedColumns &info);
|
28
28
|
|
29
29
|
protected:
|
30
30
|
BindResult BindExpression(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth,
|
@@ -37,7 +37,7 @@ private:
|
|
37
37
|
void ExtractCorrelatedColumns(Expression &expr);
|
38
38
|
|
39
39
|
private:
|
40
|
-
|
40
|
+
CorrelatedColumns correlated_columns;
|
41
41
|
};
|
42
42
|
|
43
43
|
} // namespace duckdb
|
@@ -27,7 +27,7 @@ public:
|
|
27
27
|
|
28
28
|
public:
|
29
29
|
explicit LogicalDependentJoin(unique_ptr<LogicalOperator> left, unique_ptr<LogicalOperator> right,
|
30
|
-
|
30
|
+
CorrelatedColumns correlated_columns, JoinType type,
|
31
31
|
unique_ptr<Expression> condition);
|
32
32
|
|
33
33
|
explicit LogicalDependentJoin(JoinType type);
|
@@ -35,7 +35,7 @@ public:
|
|
35
35
|
//! The conditions of the join
|
36
36
|
unique_ptr<Expression> join_condition;
|
37
37
|
//! The list of columns that have correlations with the right
|
38
|
-
|
38
|
+
CorrelatedColumns correlated_columns;
|
39
39
|
|
40
40
|
SubqueryType subquery_type = SubqueryType::INVALID;
|
41
41
|
bool perform_delim = true;
|
@@ -51,7 +51,7 @@ public:
|
|
51
51
|
|
52
52
|
public:
|
53
53
|
static unique_ptr<LogicalOperator> Create(unique_ptr<LogicalOperator> left, unique_ptr<LogicalOperator> right,
|
54
|
-
|
54
|
+
CorrelatedColumns correlated_columns, JoinType type,
|
55
55
|
unique_ptr<Expression> condition);
|
56
56
|
};
|
57
57
|
} // namespace duckdb
|
@@ -18,7 +18,7 @@ namespace duckdb {
|
|
18
18
|
//! The FlattenDependentJoins class is responsible for pushing the dependent join down into the plan to create a
|
19
19
|
//! flattened subquery
|
20
20
|
struct FlattenDependentJoins {
|
21
|
-
FlattenDependentJoins(Binder &binder, const
|
21
|
+
FlattenDependentJoins(Binder &binder, const CorrelatedColumns &correlated, bool perform_delim = true,
|
22
22
|
bool any_join = false, optional_ptr<FlattenDependentJoins> parent = nullptr);
|
23
23
|
|
24
24
|
static unique_ptr<LogicalOperator> DecorrelateIndependent(Binder &binder, unique_ptr<LogicalOperator> plan);
|
@@ -47,7 +47,7 @@ public:
|
|
47
47
|
reference_map_t<LogicalOperator, bool> has_correlated_expressions;
|
48
48
|
column_binding_map_t<idx_t> correlated_map;
|
49
49
|
column_binding_map_t<idx_t> replacement_map;
|
50
|
-
const
|
50
|
+
const CorrelatedColumns &correlated_columns;
|
51
51
|
vector<LogicalType> delim_types;
|
52
52
|
|
53
53
|
bool perform_delim;
|
@@ -16,7 +16,7 @@ namespace duckdb {
|
|
16
16
|
//! Helper class to recursively detect correlated expressions inside a single LogicalOperator
|
17
17
|
class HasCorrelatedExpressions : public LogicalOperatorVisitor {
|
18
18
|
public:
|
19
|
-
explicit HasCorrelatedExpressions(const
|
19
|
+
explicit HasCorrelatedExpressions(const CorrelatedColumns &correlated, bool lateral = false,
|
20
20
|
idx_t lateral_depth = 0);
|
21
21
|
|
22
22
|
void VisitOperator(LogicalOperator &op) override;
|
@@ -28,7 +28,7 @@ protected:
|
|
28
28
|
unique_ptr<Expression> VisitReplace(BoundColumnRefExpression &expr, unique_ptr<Expression> *expr_ptr) override;
|
29
29
|
unique_ptr<Expression> VisitReplace(BoundSubqueryExpression &expr, unique_ptr<Expression> *expr_ptr) override;
|
30
30
|
|
31
|
-
const
|
31
|
+
const CorrelatedColumns &correlated_columns;
|
32
32
|
// Tracks number of nested laterals
|
33
33
|
idx_t lateral_depth;
|
34
34
|
};
|
@@ -17,13 +17,13 @@ namespace duckdb {
|
|
17
17
|
//! Helper class to rewrite correlated cte scans within a single LogicalOperator
|
18
18
|
class RewriteCTEScan : public LogicalOperatorVisitor {
|
19
19
|
public:
|
20
|
-
RewriteCTEScan(idx_t table_index, const
|
20
|
+
RewriteCTEScan(idx_t table_index, const CorrelatedColumns &correlated_columns);
|
21
21
|
|
22
22
|
void VisitOperator(LogicalOperator &op) override;
|
23
23
|
|
24
24
|
private:
|
25
25
|
idx_t table_index;
|
26
|
-
const
|
26
|
+
const CorrelatedColumns &correlated_columns;
|
27
27
|
};
|
28
28
|
|
29
29
|
} // namespace duckdb
|
@@ -47,7 +47,7 @@ public:
|
|
47
47
|
//! Whether or not this is a lateral join
|
48
48
|
bool lateral;
|
49
49
|
//! The correlated columns of the right-side with the left-side
|
50
|
-
|
50
|
+
CorrelatedColumns correlated_columns;
|
51
51
|
//! The mark index, for mark joins generated by the relational API
|
52
52
|
idx_t mark_index {};
|
53
53
|
};
|
@@ -82,7 +82,12 @@ unique_ptr<AnalyzeState> AlpInitAnalyze(ColumnData &col_data, PhysicalType type)
|
|
82
82
|
*/
|
83
83
|
template <class T>
|
84
84
|
bool AlpAnalyze(AnalyzeState &state, Vector &input, idx_t count) {
|
85
|
-
|
85
|
+
if (state.info.GetBlockSize() + state.info.GetBlockHeaderSize() < DEFAULT_BLOCK_ALLOC_SIZE) {
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
|
89
|
+
auto &analyze_state = state.Cast<AlpAnalyzeState<T>>();
|
90
|
+
|
86
91
|
bool must_skip_current_vector = alp::AlpUtils::MustSkipSamplingFromCurrentVector(
|
87
92
|
analyze_state.vectors_count, analyze_state.vectors_sampled_count, count);
|
88
93
|
analyze_state.vectors_count += 1;
|
@@ -47,8 +47,12 @@ unique_ptr<AnalyzeState> AlpRDInitAnalyze(ColumnData &col_data, PhysicalType typ
|
|
47
47
|
*/
|
48
48
|
template <class T>
|
49
49
|
bool AlpRDAnalyze(AnalyzeState &state, Vector &input, idx_t count) {
|
50
|
+
if (state.info.GetBlockSize() + state.info.GetBlockHeaderSize() < DEFAULT_BLOCK_ALLOC_SIZE) {
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
|
50
54
|
using EXACT_TYPE = typename FloatingToExact<T>::TYPE;
|
51
|
-
auto &analyze_state =
|
55
|
+
auto &analyze_state = state.Cast<AlpRDAnalyzeState<T>>();
|
52
56
|
|
53
57
|
bool must_skip_current_vector = alp::AlpUtils::MustSkipSamplingFromCurrentVector(
|
54
58
|
analyze_state.vectors_count, analyze_state.vectors_sampled_count, count);
|
@@ -92,17 +92,19 @@ public:
|
|
92
92
|
protected:
|
93
93
|
BlockManager &block_manager;
|
94
94
|
BufferManager &buffer_manager;
|
95
|
+
mutable mutex block_lock;
|
95
96
|
unordered_map<block_id_t, MetadataBlock> blocks;
|
96
97
|
unordered_map<block_id_t, idx_t> modified_blocks;
|
97
98
|
|
98
99
|
protected:
|
99
|
-
block_id_t AllocateNewBlock();
|
100
|
-
block_id_t PeekNextBlockId();
|
101
|
-
block_id_t GetNextBlockId();
|
102
|
-
|
103
|
-
void AddBlock(MetadataBlock new_block, bool if_exists = false);
|
104
|
-
void AddAndRegisterBlock(MetadataBlock block);
|
105
|
-
void ConvertToTransient(MetadataBlock &block);
|
100
|
+
block_id_t AllocateNewBlock(unique_lock<mutex> &block_lock);
|
101
|
+
block_id_t PeekNextBlockId() const;
|
102
|
+
block_id_t GetNextBlockId() const;
|
103
|
+
|
104
|
+
void AddBlock(unique_lock<mutex> &block_lock, MetadataBlock new_block, bool if_exists = false);
|
105
|
+
void AddAndRegisterBlock(unique_lock<mutex> &block_lock, MetadataBlock block);
|
106
|
+
void ConvertToTransient(unique_lock<mutex> &block_lock, MetadataBlock &block);
|
107
|
+
MetadataPointer FromDiskPointerInternal(unique_lock<mutex> &block_lock, MetaBlockPointer pointer);
|
106
108
|
};
|
107
109
|
|
108
110
|
} // namespace duckdb
|