duckdb 0.7.1-dev7.0 → 0.7.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/README.md +1 -1
- package/binding.gyp +7 -7
- package/package.json +3 -3
- package/src/duckdb/extension/json/buffered_json_reader.cpp +50 -9
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +7 -2
- package/src/duckdb/extension/json/include/json_scan.hpp +45 -10
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +35 -22
- package/src/duckdb/extension/json/json_functions/json_create.cpp +8 -8
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +8 -3
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +54 -10
- package/src/duckdb/extension/json/json_functions/read_json.cpp +104 -49
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +5 -3
- package/src/duckdb/extension/json/json_functions.cpp +7 -0
- package/src/duckdb/extension/json/json_scan.cpp +144 -37
- package/src/duckdb/extension/parquet/column_reader.cpp +7 -0
- package/src/duckdb/extension/parquet/include/column_reader.hpp +1 -0
- package/src/duckdb/extension/parquet/parquet-extension.cpp +2 -9
- package/src/duckdb/src/catalog/catalog.cpp +62 -13
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +8 -7
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +1 -0
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
- package/src/duckdb/src/common/bind_helpers.cpp +55 -0
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/file_system.cpp +28 -0
- package/src/duckdb/src/common/hive_partitioning.cpp +1 -0
- package/src/duckdb/src/common/local_file_system.cpp +4 -4
- package/src/duckdb/src/common/operator/cast_operators.cpp +14 -8
- package/src/duckdb/src/common/printer.cpp +1 -1
- package/src/duckdb/src/common/string_util.cpp +8 -4
- package/src/duckdb/src/common/types/partitioned_column_data.cpp +1 -0
- package/src/duckdb/src/common/types/time.cpp +1 -1
- package/src/duckdb/src/common/types/timestamp.cpp +35 -4
- package/src/duckdb/src/common/types.cpp +37 -11
- package/src/duckdb/src/execution/column_binding_resolver.cpp +5 -2
- package/src/duckdb/src/execution/index/art/art.cpp +117 -67
- package/src/duckdb/src/execution/index/art/art_key.cpp +24 -12
- package/src/duckdb/src/execution/index/art/leaf.cpp +7 -8
- package/src/duckdb/src/execution/index/art/node.cpp +13 -27
- package/src/duckdb/src/execution/index/art/node16.cpp +5 -8
- package/src/duckdb/src/execution/index/art/node256.cpp +3 -5
- package/src/duckdb/src/execution/index/art/node4.cpp +4 -7
- package/src/duckdb/src/execution/index/art/node48.cpp +5 -8
- package/src/duckdb/src/execution/index/art/prefix.cpp +2 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +6 -27
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +1 -9
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +1 -9
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -9
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +6 -11
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +13 -13
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +37 -0
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +0 -5
- package/src/duckdb/src/execution/physical_operator.cpp +6 -6
- package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
- package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -0
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +38 -11
- package/src/duckdb/src/function/scalar/generic/current_setting.cpp +2 -2
- package/src/duckdb/src/function/scalar/list/array_slice.cpp +2 -3
- package/src/duckdb/src/function/scalar/map/map.cpp +69 -21
- package/src/duckdb/src/function/scalar/string/like.cpp +6 -3
- package/src/duckdb/src/function/table/read_csv.cpp +17 -8
- package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +59 -0
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/table_scan.cpp +3 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +7 -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/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/bind_helpers.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/enums/wal_type.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +9 -1
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +4 -4
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +37 -41
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +8 -11
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +32 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -3
- package/src/duckdb/src/include/duckdb/main/{extension_functions.hpp → extension_entries.hpp} +27 -5
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +11 -1
- package/src/duckdb/src/include/duckdb/main/settings.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +0 -7
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -4
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +32 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +29 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +10 -3
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +1 -2
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +8 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +7 -1
- package/src/duckdb/src/include/duckdb/storage/index.hpp +47 -38
- package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +7 -0
- package/src/duckdb/src/main/client_context.cpp +2 -0
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/database.cpp +14 -5
- package/src/duckdb/src/main/extension/extension_alias.cpp +2 -1
- package/src/duckdb/src/main/extension/extension_helper.cpp +15 -0
- package/src/duckdb/src/main/extension/extension_install.cpp +60 -16
- package/src/duckdb/src/main/extension/extension_load.cpp +62 -13
- package/src/duckdb/src/main/settings/settings.cpp +16 -0
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +2 -6
- package/src/duckdb/src/parallel/pipeline_executor.cpp +1 -55
- package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +3 -0
- package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -13
- package/src/duckdb/src/parser/statement/delete_statement.cpp +3 -0
- package/src/duckdb/src/parser/statement/detach_statement.cpp +15 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +9 -0
- package/src/duckdb/src/parser/statement/update_statement.cpp +3 -0
- package/src/duckdb/src/parser/transform/expression/transform_case.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +19 -0
- package/src/duckdb/src/parser/transformer.cpp +2 -0
- package/src/duckdb/src/planner/bind_context.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -14
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +16 -14
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +13 -0
- package/src/duckdb/src/planner/binder/statement/bind_detach.cpp +19 -0
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +29 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +22 -1
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +2 -1
- package/src/duckdb/src/planner/binder.cpp +2 -0
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +32 -1
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +21 -5
- package/src/duckdb/src/planner/logical_operator.cpp +6 -1
- package/src/duckdb/src/planner/planner.cpp +1 -0
- package/src/duckdb/src/storage/buffer_manager.cpp +105 -26
- package/src/duckdb/src/storage/compression/bitpacking.cpp +16 -7
- package/src/duckdb/src/storage/data_table.cpp +66 -3
- package/src/duckdb/src/storage/index.cpp +1 -1
- package/src/duckdb/src/storage/local_storage.cpp +1 -1
- package/src/duckdb/src/storage/storage_info.cpp +2 -1
- package/src/duckdb/src/storage/table/column_data.cpp +4 -2
- package/src/duckdb/src/storage/table/update_segment.cpp +15 -0
- package/src/duckdb/src/storage/table_index_list.cpp +1 -2
- package/src/duckdb/src/storage/wal_replay.cpp +68 -0
- package/src/duckdb/src/storage/write_ahead_log.cpp +21 -1
- package/src/duckdb/src/transaction/commit_state.cpp +5 -2
- package/src/duckdb/third_party/concurrentqueue/blockingconcurrentqueue.h +2 -2
- package/src/duckdb/third_party/fmt/include/fmt/core.h +1 -2
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +14 -0
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +530 -1006
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +17659 -17626
- package/src/duckdb/third_party/thrift/thrift/Thrift.h +8 -2
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +2 -0
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
- package/src/statement.cpp +46 -12
- package/test/arrow.test.ts +3 -3
- package/test/prepare.test.ts +39 -1
- package/test/typescript_decls.test.ts +1 -1
- package/src/duckdb/src/include/duckdb/function/create_database_extension.hpp +0 -37
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
#include "duckdb/
|
|
2
|
-
#include "duckdb/common/string_util.hpp"
|
|
1
|
+
#include "duckdb/common/constants.hpp"
|
|
3
2
|
#include "duckdb/common/file_system.hpp"
|
|
4
|
-
#include "duckdb/
|
|
5
|
-
#include "duckdb/
|
|
6
|
-
#include "duckdb/parser/parser.hpp"
|
|
3
|
+
#include "duckdb/common/string_util.hpp"
|
|
4
|
+
#include "duckdb/function/pragma/pragma_functions.hpp"
|
|
7
5
|
#include "duckdb/main/config.hpp"
|
|
6
|
+
#include "duckdb/parser/parser.hpp"
|
|
7
|
+
#include "duckdb/parser/qualified_name.hpp"
|
|
8
|
+
#include "duckdb/parser/statement/copy_statement.hpp"
|
|
9
|
+
#include "duckdb/parser/statement/export_statement.hpp"
|
|
8
10
|
|
|
9
11
|
namespace duckdb {
|
|
10
12
|
|
|
@@ -20,8 +22,8 @@ string PragmaShowTablesExpanded(ClientContext &context, const FunctionParameters
|
|
|
20
22
|
return R"(
|
|
21
23
|
SELECT
|
|
22
24
|
t.table_name,
|
|
23
|
-
LIST(c.column_name order by c.
|
|
24
|
-
LIST(c.data_type order by c.
|
|
25
|
+
LIST(c.column_name order by c.column_index) AS column_names,
|
|
26
|
+
LIST(c.data_type order by c.column_index) AS column_types,
|
|
25
27
|
FIRST(t.temporary) AS temporary
|
|
26
28
|
FROM duckdb_tables t
|
|
27
29
|
JOIN duckdb_columns c
|
|
@@ -58,10 +60,35 @@ string PragmaFunctionsQuery(ClientContext &context, const FunctionParameters &pa
|
|
|
58
60
|
|
|
59
61
|
string PragmaShow(ClientContext &context, const FunctionParameters ¶meters) {
|
|
60
62
|
// PRAGMA table_info but with some aliases
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
auto table = QualifiedName::Parse(parameters.values[0].ToString());
|
|
64
|
+
|
|
65
|
+
// clang-format off
|
|
66
|
+
string sql = R"(
|
|
67
|
+
SELECT
|
|
68
|
+
name AS "column_name",
|
|
69
|
+
type as "column_type",
|
|
70
|
+
CASE WHEN "notnull" THEN 'NO' ELSE 'YES' END AS "null",
|
|
71
|
+
(SELECT
|
|
72
|
+
MIN(CASE
|
|
73
|
+
WHEN constraint_type='PRIMARY KEY' THEN 'PRI'
|
|
74
|
+
WHEN constraint_type='UNIQUE' THEN 'UNI'
|
|
75
|
+
ELSE NULL END)
|
|
76
|
+
FROM duckdb_constraints() c
|
|
77
|
+
WHERE c.table_oid=cols.table_oid
|
|
78
|
+
AND list_contains(constraint_column_names, cols.column_name)) AS "key",
|
|
79
|
+
dflt_value AS "default",
|
|
80
|
+
NULL AS "extra"
|
|
81
|
+
FROM pragma_table_info('%func_param_table%')
|
|
82
|
+
LEFT JOIN duckdb_columns cols
|
|
83
|
+
ON cols.column_name = pragma_table_info.name
|
|
84
|
+
AND cols.table_name='%table_name%'
|
|
85
|
+
AND cols.schema_name='%table_schema%';)";
|
|
86
|
+
// clang-format on
|
|
87
|
+
|
|
88
|
+
sql = StringUtil::Replace(sql, "%func_param_table%", parameters.values[0].ToString());
|
|
89
|
+
sql = StringUtil::Replace(sql, "%table_name%", table.name);
|
|
90
|
+
sql = StringUtil::Replace(sql, "%table_schema%", table.schema.empty() ? DEFAULT_SCHEMA : table.schema);
|
|
91
|
+
return sql;
|
|
65
92
|
}
|
|
66
93
|
|
|
67
94
|
string PragmaVersion(ClientContext &context, const FunctionParameters ¶meters) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#include "duckdb/main/client_context.hpp"
|
|
5
5
|
#include "duckdb/planner/expression/bound_function_expression.hpp"
|
|
6
6
|
#include "duckdb/execution/expression_executor.hpp"
|
|
7
|
-
|
|
7
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
8
8
|
namespace duckdb {
|
|
9
9
|
|
|
10
10
|
struct CurrentSettingBindData : public FunctionData {
|
|
@@ -51,7 +51,7 @@ unique_ptr<FunctionData> CurrentSettingBind(ClientContext &context, ScalarFuncti
|
|
|
51
51
|
auto key = StringUtil::Lower(key_str);
|
|
52
52
|
Value val;
|
|
53
53
|
if (!context.TryGetCurrentSetting(key, val)) {
|
|
54
|
-
throw
|
|
54
|
+
throw Catalog::UnrecognizedConfigurationError(context, key);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
bound_function.return_type = val.type();
|
|
@@ -52,6 +52,7 @@ template <typename INPUT_TYPE, typename INDEX_TYPE>
|
|
|
52
52
|
static bool ClampSlice(const INPUT_TYPE &value, INDEX_TYPE &begin, INDEX_TYPE &end, bool begin_valid, bool end_valid) {
|
|
53
53
|
// Clamp offsets
|
|
54
54
|
begin = begin_valid ? begin : 0;
|
|
55
|
+
begin = (begin > 0) ? begin - 1 : begin;
|
|
55
56
|
end = end_valid ? end : ValueLength<INPUT_TYPE, INDEX_TYPE>(value);
|
|
56
57
|
if (!ClampIndex(begin, value) || !ClampIndex(end, value)) {
|
|
57
58
|
return false;
|
|
@@ -88,7 +89,7 @@ static void ExecuteSlice(Vector &result, Vector &s, Vector &b, Vector &e, const
|
|
|
88
89
|
auto edata = ConstantVector::GetData<INDEX_TYPE>(e);
|
|
89
90
|
|
|
90
91
|
auto sliced = sdata[0];
|
|
91
|
-
auto begin =
|
|
92
|
+
auto begin = bdata[0];
|
|
92
93
|
auto end = edata[0];
|
|
93
94
|
|
|
94
95
|
auto svalid = !ConstantVector::IsNull(s);
|
|
@@ -120,8 +121,6 @@ static void ExecuteSlice(Vector &result, Vector &s, Vector &b, Vector &e, const
|
|
|
120
121
|
auto begin = ((INDEX_TYPE *)bdata.data)[bidx];
|
|
121
122
|
auto end = ((INDEX_TYPE *)edata.data)[eidx];
|
|
122
123
|
|
|
123
|
-
begin = (begin > 0) ? begin - 1 : begin;
|
|
124
|
-
|
|
125
124
|
auto svalid = sdata.validity.RowIsValid(sidx);
|
|
126
125
|
auto bvalid = bdata.validity.RowIsValid(bidx);
|
|
127
126
|
auto evalid = edata.validity.RowIsValid(eidx);
|
|
@@ -66,46 +66,94 @@ void MapConversionVerify(Vector &vector, idx_t count) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
// Example:
|
|
70
|
+
// source: [1,2,3], expansion_factor: 4
|
|
71
|
+
// target (result): [1,2,3,1,2,3,1,2,3,1,2,3]
|
|
72
|
+
static void CreateExpandedVector(const Vector &source, Vector &target, idx_t expansion_factor) {
|
|
73
|
+
idx_t count = ListVector::GetListSize(source);
|
|
74
|
+
auto &entry = ListVector::GetEntry(source);
|
|
75
|
+
|
|
76
|
+
idx_t target_idx = 0;
|
|
77
|
+
for (idx_t copy = 0; copy < expansion_factor; copy++) {
|
|
78
|
+
for (idx_t key_idx = 0; key_idx < count; key_idx++) {
|
|
79
|
+
target.SetValue(target_idx, entry.GetValue(key_idx));
|
|
80
|
+
target_idx++;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
83
|
+
D_ASSERT(target_idx == count * expansion_factor);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static void AlignVectorToReference(const Vector &original, const Vector &reference, idx_t tuple_count, Vector &result) {
|
|
87
|
+
auto original_length = ListVector::GetListSize(original);
|
|
88
|
+
auto new_length = ListVector::GetListSize(reference);
|
|
89
|
+
|
|
90
|
+
Vector expanded_const(ListType::GetChildType(original.GetType()), new_length);
|
|
91
|
+
|
|
92
|
+
auto expansion_factor = new_length / original_length;
|
|
93
|
+
if (expansion_factor != tuple_count) {
|
|
94
|
+
throw InvalidInputException("Error in MAP creation: key list and value list do not align. i.e. different "
|
|
95
|
+
"size or incompatible structure");
|
|
96
|
+
}
|
|
97
|
+
CreateExpandedVector(original, expanded_const, expansion_factor);
|
|
98
|
+
result.Reference(expanded_const);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static void MapFunction(DataChunk &args, ExpressionState &state, Vector &result) {
|
|
102
|
+
D_ASSERT(result.GetType().id() == LogicalTypeId::MAP);
|
|
79
103
|
|
|
80
104
|
auto &key_vector = MapVector::GetKeys(result);
|
|
81
105
|
auto &value_vector = MapVector::GetValues(result);
|
|
82
|
-
auto
|
|
106
|
+
auto result_data = ListVector::GetData(result);
|
|
83
107
|
|
|
108
|
+
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
84
109
|
if (args.data.empty()) {
|
|
85
110
|
ListVector::SetListSize(result, 0);
|
|
86
|
-
|
|
87
|
-
|
|
111
|
+
result_data->offset = 0;
|
|
112
|
+
result_data->length = 0;
|
|
88
113
|
result.Verify(args.size());
|
|
89
114
|
return;
|
|
90
115
|
}
|
|
91
116
|
|
|
92
|
-
|
|
117
|
+
bool keys_are_const = args.data[0].GetVectorType() == VectorType::CONSTANT_VECTOR;
|
|
118
|
+
bool values_are_const = args.data[1].GetVectorType() == VectorType::CONSTANT_VECTOR;
|
|
119
|
+
if (!keys_are_const || !values_are_const) {
|
|
120
|
+
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
121
|
+
}
|
|
122
|
+
|
|
93
123
|
auto key_count = ListVector::GetListSize(args.data[0]);
|
|
94
124
|
auto value_count = ListVector::GetListSize(args.data[1]);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
125
|
+
auto key_data = ListVector::GetData(args.data[0]);
|
|
126
|
+
auto value_data = ListVector::GetData(args.data[1]);
|
|
127
|
+
auto src_data = key_data;
|
|
128
|
+
|
|
129
|
+
if (keys_are_const && !values_are_const) {
|
|
130
|
+
AlignVectorToReference(args.data[0], args.data[1], args.size(), key_vector);
|
|
131
|
+
src_data = value_data;
|
|
132
|
+
} else if (values_are_const && !keys_are_const) {
|
|
133
|
+
AlignVectorToReference(args.data[1], args.data[0], args.size(), value_vector);
|
|
134
|
+
} else {
|
|
135
|
+
if (key_count != value_count || memcmp(key_data, value_data, args.size() * sizeof(list_entry_t)) != 0) {
|
|
136
|
+
throw InvalidInputException("Error in MAP creation: key list and value list do not align. i.e. different "
|
|
137
|
+
"size or incompatible structure");
|
|
138
|
+
}
|
|
99
139
|
}
|
|
100
|
-
ListVector::Reserve(result, key_count);
|
|
101
|
-
ListVector::SetListSize(result, key_count);
|
|
102
140
|
|
|
141
|
+
ListVector::SetListSize(result, MaxValue(key_count, value_count));
|
|
142
|
+
|
|
143
|
+
result_data = ListVector::GetData(result);
|
|
103
144
|
for (idx_t i = 0; i < args.size(); i++) {
|
|
104
|
-
|
|
145
|
+
result_data[i] = src_data[i];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// check whether one of the vectors has already been referenced to an expanded vector in the case of const/non-const
|
|
149
|
+
// combination. If not, then referencing is still necessary
|
|
150
|
+
if (!(keys_are_const && !values_are_const)) {
|
|
151
|
+
key_vector.Reference(ListVector::GetEntry(args.data[0]));
|
|
152
|
+
}
|
|
153
|
+
if (!(values_are_const && !keys_are_const)) {
|
|
154
|
+
value_vector.Reference(ListVector::GetEntry(args.data[1]));
|
|
105
155
|
}
|
|
106
156
|
|
|
107
|
-
key_vector.Reference(ListVector::GetEntry(args.data[0]));
|
|
108
|
-
value_vector.Reference(ListVector::GetEntry(args.data[1]));
|
|
109
157
|
MapConversionVerify(result, args.size());
|
|
110
158
|
result.Verify(args.size());
|
|
111
159
|
}
|
|
@@ -220,7 +220,7 @@ bool LikeOperatorFunction(string_t &s, string_t &pat, char escape) {
|
|
|
220
220
|
return LikeOperatorFunction(s.GetDataUnsafe(), s.GetSize(), pat.GetDataUnsafe(), pat.GetSize(), escape);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
bool LikeFun::Glob(const char *string, idx_t slen, const char *pattern, idx_t plen) {
|
|
223
|
+
bool LikeFun::Glob(const char *string, idx_t slen, const char *pattern, idx_t plen, bool allow_question_mark) {
|
|
224
224
|
idx_t sidx = 0;
|
|
225
225
|
idx_t pidx = 0;
|
|
226
226
|
main_loop : {
|
|
@@ -249,8 +249,11 @@ main_loop : {
|
|
|
249
249
|
return false;
|
|
250
250
|
}
|
|
251
251
|
case '?':
|
|
252
|
-
//
|
|
253
|
-
|
|
252
|
+
// when enabled: matches anything but null
|
|
253
|
+
if (allow_question_mark) {
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
DUCKDB_EXPLICIT_FALLTHROUGH;
|
|
254
257
|
case '[':
|
|
255
258
|
pidx++;
|
|
256
259
|
goto parse_bracket;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include "duckdb/parser/expression/function_expression.hpp"
|
|
11
11
|
#include "duckdb/parser/tableref/table_function_ref.hpp"
|
|
12
12
|
#include "duckdb/planner/operator/logical_get.hpp"
|
|
13
|
+
#include "duckdb/main/extension_helper.hpp"
|
|
13
14
|
|
|
14
15
|
#include <limits>
|
|
15
16
|
|
|
@@ -27,10 +28,7 @@ unique_ptr<CSVFileHandle> ReadCSV::OpenCSV(const string &file_path, FileCompress
|
|
|
27
28
|
void ReadCSVData::InitializeFiles(ClientContext &context, const vector<string> &patterns) {
|
|
28
29
|
auto &fs = FileSystem::GetFileSystem(context);
|
|
29
30
|
for (auto &file_pattern : patterns) {
|
|
30
|
-
auto found_files = fs.
|
|
31
|
-
if (found_files.empty()) {
|
|
32
|
-
throw IOException("No files found that match the pattern \"%s\"", file_pattern);
|
|
33
|
-
}
|
|
31
|
+
auto found_files = fs.GlobFiles(file_pattern, context);
|
|
34
32
|
files.insert(files.end(), found_files.begin(), found_files.end());
|
|
35
33
|
}
|
|
36
34
|
}
|
|
@@ -98,6 +96,17 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, TableFunctio
|
|
|
98
96
|
if (names.empty()) {
|
|
99
97
|
throw BinderException("read_csv requires at least a single column as input!");
|
|
100
98
|
}
|
|
99
|
+
} else if (loption == "column_names" || loption == "names") {
|
|
100
|
+
if (!options.name_list.empty()) {
|
|
101
|
+
throw BinderException("read_csv_auto column_names/names can only be supplied once");
|
|
102
|
+
}
|
|
103
|
+
if (kv.second.IsNull()) {
|
|
104
|
+
throw BinderException("read_csv_auto %s cannot be NULL", kv.first);
|
|
105
|
+
}
|
|
106
|
+
auto &children = ListValue::GetChildren(kv.second);
|
|
107
|
+
for (auto &child : children) {
|
|
108
|
+
options.name_list.push_back(StringValue::Get(child));
|
|
109
|
+
}
|
|
101
110
|
} else if (loption == "column_types" || loption == "types" || loption == "dtypes") {
|
|
102
111
|
auto &child_type = kv.second.type();
|
|
103
112
|
if (child_type.id() != LogicalTypeId::STRUCT && child_type.id() != LogicalTypeId::LIST) {
|
|
@@ -251,9 +260,6 @@ public:
|
|
|
251
260
|
: file_handle(std::move(file_handle_p)), system_threads(system_threads_p), buffer_size(buffer_size_p),
|
|
252
261
|
force_parallelism(force_parallelism_p) {
|
|
253
262
|
current_file_path = files_path_p[0];
|
|
254
|
-
for (idx_t i = 0; i < rows_to_skip; i++) {
|
|
255
|
-
file_handle->ReadLine();
|
|
256
|
-
}
|
|
257
263
|
estimated_linenr = rows_to_skip;
|
|
258
264
|
file_size = file_handle->FileSize();
|
|
259
265
|
first_file_size = file_size;
|
|
@@ -303,7 +309,7 @@ public:
|
|
|
303
309
|
progress = double(bytes_read) / double(file_size);
|
|
304
310
|
}
|
|
305
311
|
// now get the total percentage of files read
|
|
306
|
-
double percentage = double(file_index) / total_files;
|
|
312
|
+
double percentage = double(file_index - 1) / total_files;
|
|
307
313
|
percentage += (double(1) / double(total_files)) * progress;
|
|
308
314
|
return percentage * 100;
|
|
309
315
|
}
|
|
@@ -575,6 +581,7 @@ struct SingleThreadedCSVState : public GlobalTableFunctionState {
|
|
|
575
581
|
{
|
|
576
582
|
lock_guard<mutex> l(csv_lock);
|
|
577
583
|
if (initial_reader) {
|
|
584
|
+
total_size = initial_reader->file_handle ? initial_reader->file_handle->FileSize() : 0;
|
|
578
585
|
return std::move(initial_reader);
|
|
579
586
|
}
|
|
580
587
|
if (next_file >= total_files) {
|
|
@@ -963,6 +970,8 @@ TableFunction ReadCSVTableFunction::GetAutoFunction(bool list_parameter) {
|
|
|
963
970
|
read_csv_auto.named_parameters["column_types"] = LogicalType::ANY;
|
|
964
971
|
read_csv_auto.named_parameters["dtypes"] = LogicalType::ANY;
|
|
965
972
|
read_csv_auto.named_parameters["types"] = LogicalType::ANY;
|
|
973
|
+
read_csv_auto.named_parameters["names"] = LogicalType::LIST(LogicalType::VARCHAR);
|
|
974
|
+
read_csv_auto.named_parameters["column_names"] = LogicalType::LIST(LogicalType::VARCHAR);
|
|
966
975
|
return read_csv_auto;
|
|
967
976
|
}
|
|
968
977
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include "duckdb/function/table/system_functions.hpp"
|
|
2
|
+
#include "duckdb/storage/buffer_manager.hpp"
|
|
3
|
+
|
|
4
|
+
namespace duckdb {
|
|
5
|
+
|
|
6
|
+
struct DuckDBTemporaryFilesData : public GlobalTableFunctionState {
|
|
7
|
+
DuckDBTemporaryFilesData() : offset(0) {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
vector<TemporaryFileInformation> entries;
|
|
11
|
+
idx_t offset;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
static unique_ptr<FunctionData> DuckDBTemporaryFilesBind(ClientContext &context, TableFunctionBindInput &input,
|
|
15
|
+
vector<LogicalType> &return_types, vector<string> &names) {
|
|
16
|
+
names.emplace_back("path");
|
|
17
|
+
return_types.emplace_back(LogicalType::VARCHAR);
|
|
18
|
+
|
|
19
|
+
names.emplace_back("size");
|
|
20
|
+
return_types.emplace_back(LogicalType::BIGINT);
|
|
21
|
+
|
|
22
|
+
return nullptr;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
unique_ptr<GlobalTableFunctionState> DuckDBTemporaryFilesInit(ClientContext &context, TableFunctionInitInput &input) {
|
|
26
|
+
auto result = make_unique<DuckDBTemporaryFilesData>();
|
|
27
|
+
|
|
28
|
+
result->entries = BufferManager::GetBufferManager(context).GetTemporaryFiles();
|
|
29
|
+
return std::move(result);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void DuckDBTemporaryFilesFunction(ClientContext &context, TableFunctionInput &data_p, DataChunk &output) {
|
|
33
|
+
auto &data = (DuckDBTemporaryFilesData &)*data_p.global_state;
|
|
34
|
+
if (data.offset >= data.entries.size()) {
|
|
35
|
+
// finished returning values
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// start returning values
|
|
39
|
+
// either fill up the chunk or return all the remaining columns
|
|
40
|
+
idx_t count = 0;
|
|
41
|
+
while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
|
|
42
|
+
auto &entry = data.entries[data.offset++];
|
|
43
|
+
// return values:
|
|
44
|
+
idx_t col = 0;
|
|
45
|
+
// database_name, VARCHAR
|
|
46
|
+
output.SetValue(col++, count, entry.path);
|
|
47
|
+
// database_oid, BIGINT
|
|
48
|
+
output.SetValue(col++, count, Value::BIGINT(entry.size));
|
|
49
|
+
count++;
|
|
50
|
+
}
|
|
51
|
+
output.SetCardinality(count);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void DuckDBTemporaryFilesFun::RegisterFunction(BuiltinFunctions &set) {
|
|
55
|
+
set.AddFunction(TableFunction("duckdb_temporary_files", {}, DuckDBTemporaryFilesFunction, DuckDBTemporaryFilesBind,
|
|
56
|
+
DuckDBTemporaryFilesInit));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // namespace duckdb
|
|
@@ -29,6 +29,7 @@ void BuiltinFunctions::RegisterSQLiteFunctions() {
|
|
|
29
29
|
DuckDBSequencesFun::RegisterFunction(*this);
|
|
30
30
|
DuckDBSettingsFun::RegisterFunction(*this);
|
|
31
31
|
DuckDBTablesFun::RegisterFunction(*this);
|
|
32
|
+
DuckDBTemporaryFilesFun::RegisterFunction(*this);
|
|
32
33
|
DuckDBTypesFun::RegisterFunction(*this);
|
|
33
34
|
DuckDBViewsFun::RegisterFunction(*this);
|
|
34
35
|
TestAllTypesFun::RegisterFunction(*this);
|
|
@@ -287,9 +287,12 @@ void TableScanPushdownComplexFilter(ClientContext &context, LogicalGet &get, Fun
|
|
|
287
287
|
// behold
|
|
288
288
|
storage.info->indexes.Scan([&](Index &index) {
|
|
289
289
|
// first rewrite the index expression so the ColumnBindings align with the column bindings of the current table
|
|
290
|
+
|
|
290
291
|
if (index.unbound_expressions.size() > 1) {
|
|
292
|
+
// NOTE: index scans are not (yet) supported for compound index keys
|
|
291
293
|
return false;
|
|
292
294
|
}
|
|
295
|
+
|
|
293
296
|
auto index_expression = index.unbound_expressions[0]->Copy();
|
|
294
297
|
bool rewrite_possible = true;
|
|
295
298
|
RewriteIndexExpression(index, get, *index_expression, rewrite_possible);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.7.1
|
|
2
|
+
#define DUCKDB_VERSION "0.7.1"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "b00b93f0b1"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -29,6 +29,7 @@ struct CreateFunctionInfo;
|
|
|
29
29
|
struct CreateViewInfo;
|
|
30
30
|
struct CreateSequenceInfo;
|
|
31
31
|
struct CreateCollationInfo;
|
|
32
|
+
struct CreateIndexInfo;
|
|
32
33
|
struct CreateTypeInfo;
|
|
33
34
|
struct CreateTableInfo;
|
|
34
35
|
struct DatabaseSize;
|
|
@@ -137,6 +138,9 @@ public:
|
|
|
137
138
|
//! Creates a collation in the catalog
|
|
138
139
|
DUCKDB_API CatalogEntry *CreateCollation(CatalogTransaction transaction, CreateCollationInfo *info);
|
|
139
140
|
DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
|
|
141
|
+
//! Creates an index in the catalog
|
|
142
|
+
DUCKDB_API CatalogEntry *CreateIndex(CatalogTransaction transaction, CreateIndexInfo *info);
|
|
143
|
+
DUCKDB_API CatalogEntry *CreateIndex(ClientContext &context, CreateIndexInfo *info);
|
|
140
144
|
|
|
141
145
|
//! Creates a table in the catalog.
|
|
142
146
|
DUCKDB_API CatalogEntry *CreateTable(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
@@ -153,7 +157,7 @@ public:
|
|
|
153
157
|
//! Create a scalar or aggregate function in the catalog
|
|
154
158
|
DUCKDB_API CatalogEntry *CreateFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
155
159
|
CreateFunctionInfo *info);
|
|
156
|
-
//! Creates a
|
|
160
|
+
//! Creates a view in the catalog
|
|
157
161
|
DUCKDB_API CatalogEntry *CreateView(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
158
162
|
CreateViewInfo *info);
|
|
159
163
|
//! Creates a table in the catalog.
|
|
@@ -251,6 +255,8 @@ public:
|
|
|
251
255
|
|
|
252
256
|
virtual void Verify();
|
|
253
257
|
|
|
258
|
+
static CatalogException UnrecognizedConfigurationError(ClientContext &context, const string &name);
|
|
259
|
+
|
|
254
260
|
protected:
|
|
255
261
|
//! Reference to the database
|
|
256
262
|
AttachedDatabase &db;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//===----------------------------------------------------------------------===//
|
|
2
2
|
// DuckDB
|
|
3
3
|
//
|
|
4
|
-
// duckdb/catalog/catalog_entry/
|
|
4
|
+
// duckdb/catalog/catalog_entry/duck_index_entry.hpp
|
|
5
5
|
//
|
|
6
6
|
//
|
|
7
7
|
//===----------------------------------------------------------------------===//
|
|
@@ -34,7 +34,7 @@ public:
|
|
|
34
34
|
|
|
35
35
|
public:
|
|
36
36
|
string ToSQL() override;
|
|
37
|
-
void Serialize(
|
|
37
|
+
void Serialize(Serializer &serializer);
|
|
38
38
|
static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &source, ClientContext &context);
|
|
39
39
|
|
|
40
40
|
virtual string GetSchemaName() = 0;
|
|
@@ -17,5 +17,7 @@ class Value;
|
|
|
17
17
|
Value ConvertVectorToValue(vector<Value> set);
|
|
18
18
|
vector<bool> ParseColumnList(const vector<Value> &set, vector<string> &names, const string &option_name);
|
|
19
19
|
vector<bool> ParseColumnList(const Value &value, vector<string> &names, const string &option_name);
|
|
20
|
+
vector<idx_t> ParseColumnsOrdered(const vector<Value> &set, vector<string> &names, const string &loption);
|
|
21
|
+
vector<idx_t> ParseColumnsOrdered(const Value &value, vector<string> &names, const string &loption);
|
|
20
22
|
|
|
21
23
|
} // namespace duckdb
|
|
@@ -43,11 +43,12 @@ enum class StatementType : uint8_t {
|
|
|
43
43
|
RELATION_STATEMENT,
|
|
44
44
|
EXTENSION_STATEMENT,
|
|
45
45
|
LOGICAL_PLAN_STATEMENT,
|
|
46
|
-
ATTACH_STATEMENT
|
|
46
|
+
ATTACH_STATEMENT,
|
|
47
|
+
DETACH_STATEMENT
|
|
47
48
|
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
string StatementTypeToString(StatementType type);
|
|
51
|
+
DUCKDB_API string StatementTypeToString(StatementType type);
|
|
51
52
|
|
|
52
53
|
enum class StatementReturnType : uint8_t {
|
|
53
54
|
QUERY_RESULT, // the statement returns a query result (e.g. for display to the user)
|
|
@@ -262,6 +262,16 @@ public:
|
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
+
class MissingExtensionException : public IOException {
|
|
266
|
+
public:
|
|
267
|
+
DUCKDB_API explicit MissingExtensionException(const string &msg);
|
|
268
|
+
|
|
269
|
+
template <typename... Args>
|
|
270
|
+
explicit MissingExtensionException(const string &msg, Args... params)
|
|
271
|
+
: IOException(ConstructMessage(msg, params...)) {
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
265
275
|
class SerializationException : public Exception {
|
|
266
276
|
public:
|
|
267
277
|
DUCKDB_API explicit SerializationException(const string &msg);
|
|
@@ -188,6 +188,7 @@ public:
|
|
|
188
188
|
//! Runs a glob on the file system, returning a list of matching files
|
|
189
189
|
DUCKDB_API virtual vector<string> Glob(const string &path, FileOpener *opener = nullptr);
|
|
190
190
|
DUCKDB_API virtual vector<string> Glob(const string &path, ClientContext &context);
|
|
191
|
+
DUCKDB_API vector<string> GlobFiles(const string &path, ClientContext &context);
|
|
191
192
|
|
|
192
193
|
//! registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.
|
|
193
194
|
DUCKDB_API virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
|
|
@@ -52,7 +52,15 @@ struct HivePartitionKey {
|
|
|
52
52
|
|
|
53
53
|
struct Equality {
|
|
54
54
|
bool operator()(const HivePartitionKey &a, const HivePartitionKey &b) const {
|
|
55
|
-
|
|
55
|
+
if (a.values.size() != b.values.size()) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
for (idx_t i = 0; i < a.values.size(); i++) {
|
|
59
|
+
if (!Value::NotDistinctFrom(a.values[i], b.values[i])) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
56
64
|
}
|
|
57
65
|
};
|
|
58
66
|
};
|
|
@@ -78,13 +78,13 @@ protected:
|
|
|
78
78
|
case 2:
|
|
79
79
|
case 3:
|
|
80
80
|
case 4:
|
|
81
|
-
return GetBufferSize(1);
|
|
81
|
+
return GetBufferSize(1 << 1);
|
|
82
82
|
case 5:
|
|
83
|
-
return GetBufferSize(2);
|
|
83
|
+
return GetBufferSize(1 << 2);
|
|
84
84
|
case 6:
|
|
85
|
-
return GetBufferSize(3);
|
|
85
|
+
return GetBufferSize(1 << 3);
|
|
86
86
|
default:
|
|
87
|
-
return GetBufferSize(4);
|
|
87
|
+
return GetBufferSize(1 << 4);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
void InitializeAppendStateInternal(PartitionedColumnDataAppendState &state) const override;
|
|
@@ -145,8 +145,15 @@ public:
|
|
|
145
145
|
DUCKDB_API static string Replace(string source, const string &from, const string &to);
|
|
146
146
|
|
|
147
147
|
//! Get the levenshtein distance from two strings
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
//! The not_equal_penalty is the penalty given when two characters in a string are not equal
|
|
149
|
+
//! The regular levenshtein distance has a not equal penalty of 1, which means changing a character is as expensive
|
|
150
|
+
//! as adding or removing one For similarity searches we often want to give extra weight to changing a character For
|
|
151
|
+
//! example: with an equal penalty of 1, "pg_am" is closer to "depdelay" than "depdelay_minutes"
|
|
152
|
+
//! with an equal penalty of 3, "depdelay_minutes" is closer to "depdelay" than to "pg_am"
|
|
153
|
+
DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2, idx_t not_equal_penalty = 1);
|
|
154
|
+
|
|
155
|
+
//! Returns the similarity score between two strings
|
|
156
|
+
DUCKDB_API static idx_t SimilarityScore(const string &s1, const string &s2);
|
|
150
157
|
//! Get the top-n strings (sorted by the given score distance) from a set of scores.
|
|
151
158
|
//! At least one entry is returned (if there is one).
|
|
152
159
|
//! Strings are only returned if they have a score less than the threshold.
|
|
@@ -93,6 +93,8 @@ struct timestamp_ns_t : public timestamp_t {}; // NOLINT
|
|
|
93
93
|
struct timestamp_ms_t : public timestamp_t {}; // NOLINT
|
|
94
94
|
struct timestamp_sec_t : public timestamp_t {}; // NOLINT
|
|
95
95
|
|
|
96
|
+
enum class TimestampCastResult : uint8_t { SUCCESS, ERROR_INCORRECT_FORMAT, ERROR_NON_UTC_TIMEZONE };
|
|
97
|
+
|
|
96
98
|
//! The Timestamp class is a static class that holds helper functions for the Timestamp
|
|
97
99
|
//! type.
|
|
98
100
|
class Timestamp {
|
|
@@ -110,7 +112,7 @@ public:
|
|
|
110
112
|
//! If the tz is not empty, the result is still an instant, but the parts can be extracted and applied to the TZ
|
|
111
113
|
DUCKDB_API static bool TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, bool &has_offset,
|
|
112
114
|
string_t &tz);
|
|
113
|
-
DUCKDB_API static
|
|
115
|
+
DUCKDB_API static TimestampCastResult TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result);
|
|
114
116
|
DUCKDB_API static timestamp_t FromCString(const char *str, idx_t len);
|
|
115
117
|
//! Convert a date object to a string in the format "YYYY-MM-DD hh:mm:ss"
|
|
116
118
|
DUCKDB_API static string ToString(timestamp_t timestamp);
|
|
@@ -161,6 +163,8 @@ public:
|
|
|
161
163
|
|
|
162
164
|
DUCKDB_API static string ConversionError(const string &str);
|
|
163
165
|
DUCKDB_API static string ConversionError(string_t str);
|
|
166
|
+
DUCKDB_API static string UnsupportedTimezoneError(const string &str);
|
|
167
|
+
DUCKDB_API static string UnsupportedTimezoneError(string_t str);
|
|
164
168
|
};
|
|
165
169
|
|
|
166
170
|
} // namespace duckdb
|