duckdb 0.7.2-dev457.0 → 0.7.2-dev614.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/binding.gyp +9 -9
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-table-range.cpp +7 -7
- package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -0
- package/src/duckdb/extension/parquet/parquet_reader.cpp +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +13 -0
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +2 -21
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +8 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -0
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +48 -4
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -1
- package/src/duckdb/src/common/field_writer.cpp +1 -0
- package/src/duckdb/src/common/serializer/buffered_deserializer.cpp +4 -0
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +15 -2
- package/src/duckdb/src/common/types/blob.cpp +1 -1
- package/src/duckdb/src/common/types/chunk_collection.cpp +2 -2
- package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
- package/src/duckdb/src/common/types/value.cpp +8 -8
- package/src/duckdb/src/common/types.cpp +147 -64
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +12 -3
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +6 -11
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -40
- package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +1 -1
- package/src/duckdb/src/function/aggregate/nested/list.cpp +8 -8
- package/src/duckdb/src/function/cast/struct_cast.cpp +1 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +1 -1
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +5 -4
- package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_value.cpp +1 -1
- package/src/duckdb/src/function/scalar/map/map_entries.cpp +1 -1
- package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +1 -1
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +1 -1
- package/src/duckdb/src/function/table/arrow.cpp +5 -2
- package/src/duckdb/src/function/table/arrow_conversion.cpp +18 -0
- package/src/duckdb/src/function/table/system/test_all_types.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/table_function.cpp +11 -11
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/field_writer.hpp +12 -4
- package/src/duckdb/src/include/duckdb/common/{http_stats.hpp → http_state.hpp} +18 -4
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_deserializer.hpp +4 -2
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +8 -2
- package/src/duckdb/src/include/duckdb/common/serializer.hpp +13 -0
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/types.hpp +30 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +12 -1
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +8 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +6 -0
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -1
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +30 -32
- package/src/duckdb/src/main/client_data.cpp +7 -6
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/main/database.cpp +9 -0
- package/src/duckdb/src/main/query_profiler.cpp +17 -15
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +3 -4
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +5 -3
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +9 -2
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +2 -2
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +2 -0
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +3 -4
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +4 -3
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +2 -1
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +1 -0
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +11 -1
- package/src/duckdb/src/planner/binder/tableref/plan_cteref.cpp +1 -0
- package/src/duckdb/src/planner/expression_binder.cpp +1 -1
- package/src/duckdb/src/planner/logical_operator.cpp +4 -2
- package/src/duckdb/src/planner/planner.cpp +2 -1
- package/src/duckdb/src/storage/checkpoint_manager.cpp +8 -3
- package/src/duckdb/src/storage/meta_block_reader.cpp +22 -0
- package/src/duckdb/src/storage/statistics/list_stats.cpp +6 -2
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +3 -1
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +11 -7
- package/src/duckdb/src/storage/wal_replay.cpp +8 -5
- package/src/duckdb/src/storage/write_ahead_log.cpp +2 -2
- package/src/duckdb/src/transaction/commit_state.cpp +11 -7
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +1152 -1152
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
@@ -1332,7 +1332,7 @@ struct StructDatePart {
|
|
1332
1332
|
}
|
1333
1333
|
|
1334
1334
|
Function::EraseArgument(bound_function, arguments, 0);
|
1335
|
-
bound_function.return_type = LogicalType::STRUCT(
|
1335
|
+
bound_function.return_type = LogicalType::STRUCT(struct_children);
|
1336
1336
|
return make_unique<BindData>(bound_function.return_type, part_codes);
|
1337
1337
|
}
|
1338
1338
|
|
@@ -82,9 +82,10 @@ static unique_ptr<FunctionData> ListConcatBind(ClientContext &context, ScalarFun
|
|
82
82
|
throw ParameterNotResolvedException();
|
83
83
|
} else if (lhs.id() == LogicalTypeId::SQLNULL || rhs.id() == LogicalTypeId::SQLNULL) {
|
84
84
|
// we mimic postgres behaviour: list_concat(NULL, my_list) = my_list
|
85
|
-
|
86
|
-
bound_function.arguments[
|
87
|
-
bound_function.
|
85
|
+
auto return_type = rhs.id() == LogicalTypeId::SQLNULL ? lhs : rhs;
|
86
|
+
bound_function.arguments[0] = return_type;
|
87
|
+
bound_function.arguments[1] = return_type;
|
88
|
+
bound_function.return_type = return_type;
|
88
89
|
} else {
|
89
90
|
D_ASSERT(lhs.id() == LogicalTypeId::LIST);
|
90
91
|
D_ASSERT(rhs.id() == LogicalTypeId::LIST);
|
@@ -94,7 +95,7 @@ static unique_ptr<FunctionData> ListConcatBind(ClientContext &context, ScalarFun
|
|
94
95
|
for (const auto &argument : arguments) {
|
95
96
|
child_type = LogicalType::MaxLogicalType(child_type, ListType::GetChildType(argument->return_type));
|
96
97
|
}
|
97
|
-
auto list_type = LogicalType::LIST(
|
98
|
+
auto list_type = LogicalType::LIST(child_type);
|
98
99
|
|
99
100
|
bound_function.arguments[0] = list_type;
|
100
101
|
bound_function.arguments[1] = list_type;
|
@@ -124,7 +124,7 @@ static void ExecuteExpression(vector<LogicalType> &types, vector<LogicalType> &r
|
|
124
124
|
// set the other vectors
|
125
125
|
vector<Vector> slices;
|
126
126
|
for (idx_t col_idx = 0; col_idx < args.ColumnCount() - 1; col_idx++) {
|
127
|
-
slices.emplace_back(
|
127
|
+
slices.emplace_back(args.data[col_idx + 1], sel_vectors[col_idx], elem_cnt);
|
128
128
|
slices[col_idx].Flatten(elem_cnt);
|
129
129
|
input_chunk.data[col_idx + 2].Reference(slices[col_idx]);
|
130
130
|
}
|
@@ -195,10 +195,10 @@ static void ListLambdaFunction(DataChunk &args, ExpressionState &state, Vector &
|
|
195
195
|
|
196
196
|
// skip the list column
|
197
197
|
for (idx_t i = 1; i < args.ColumnCount(); i++) {
|
198
|
-
columns.emplace_back(
|
198
|
+
columns.emplace_back();
|
199
199
|
args.data[i].ToUnifiedFormat(count, columns[i - 1]);
|
200
200
|
indexes.push_back(0);
|
201
|
-
sel_vectors.emplace_back(
|
201
|
+
sel_vectors.emplace_back(STANDARD_VECTOR_SIZE);
|
202
202
|
types.push_back(args.data[i].GetType());
|
203
203
|
}
|
204
204
|
|
@@ -42,7 +42,7 @@ static unique_ptr<FunctionData> ListValueBind(ClientContext &context, ScalarFunc
|
|
42
42
|
|
43
43
|
// this is more for completeness reasons
|
44
44
|
bound_function.varargs = child_type;
|
45
|
-
bound_function.return_type = LogicalType::LIST(
|
45
|
+
bound_function.return_type = LogicalType::LIST(child_type);
|
46
46
|
return make_unique<VariableReturnBindData>(bound_function.return_type);
|
47
47
|
}
|
48
48
|
|
@@ -44,7 +44,7 @@ static unique_ptr<FunctionData> MapEntriesBind(ClientContext &context, ScalarFun
|
|
44
44
|
child_types.push_back(make_pair("k", key_type));
|
45
45
|
child_types.push_back(make_pair("v", value_type));
|
46
46
|
|
47
|
-
auto row_type = LogicalType::STRUCT(
|
47
|
+
auto row_type = LogicalType::STRUCT(child_types);
|
48
48
|
|
49
49
|
bound_function.return_type = LogicalType::LIST(row_type);
|
50
50
|
return make_unique<VariableReturnBindData>(bound_function.return_type);
|
@@ -74,7 +74,7 @@ static unique_ptr<FunctionData> StructInsertBind(ClientContext &context, ScalarF
|
|
74
74
|
}
|
75
75
|
|
76
76
|
// this is more for completeness reasons
|
77
|
-
bound_function.return_type = LogicalType::STRUCT(
|
77
|
+
bound_function.return_type = LogicalType::STRUCT(new_struct_children);
|
78
78
|
return make_unique<VariableReturnBindData>(bound_function.return_type);
|
79
79
|
}
|
80
80
|
|
@@ -54,7 +54,7 @@ static unique_ptr<FunctionData> StructPackBind(ClientContext &context, ScalarFun
|
|
54
54
|
}
|
55
55
|
|
56
56
|
// this is more for completeness reasons
|
57
|
-
bound_function.return_type = LogicalType::STRUCT(
|
57
|
+
bound_function.return_type = LogicalType::STRUCT(struct_children);
|
58
58
|
return make_unique<VariableReturnBindData>(bound_function.return_type);
|
59
59
|
}
|
60
60
|
|
@@ -101,6 +101,9 @@ LogicalType ArrowTableFunction::GetArrowLogicalType(
|
|
101
101
|
} else if (format == "tiM") {
|
102
102
|
arrow_convert_data[col_idx]->date_time_precision.emplace_back(ArrowDateTimeType::MONTHS);
|
103
103
|
return LogicalType::INTERVAL;
|
104
|
+
} else if (format == "tin") {
|
105
|
+
arrow_convert_data[col_idx]->date_time_precision.emplace_back(ArrowDateTimeType::MONTH_DAY_NANO);
|
106
|
+
return LogicalType::INTERVAL;
|
104
107
|
} else if (format == "+l") {
|
105
108
|
arrow_convert_data[col_idx]->variable_sz_type.emplace_back(ArrowVariableSizeType::NORMAL, 0);
|
106
109
|
auto child_type = GetArrowLogicalType(*schema.children[0], arrow_convert_data, col_idx);
|
@@ -114,14 +117,14 @@ LogicalType ArrowTableFunction::GetArrowLogicalType(
|
|
114
117
|
idx_t fixed_size = std::stoi(parameters);
|
115
118
|
arrow_convert_data[col_idx]->variable_sz_type.emplace_back(ArrowVariableSizeType::FIXED_SIZE, fixed_size);
|
116
119
|
auto child_type = GetArrowLogicalType(*schema.children[0], arrow_convert_data, col_idx);
|
117
|
-
return LogicalType::LIST(
|
120
|
+
return LogicalType::LIST(child_type);
|
118
121
|
} else if (format == "+s") {
|
119
122
|
child_list_t<LogicalType> child_types;
|
120
123
|
for (idx_t type_idx = 0; type_idx < (idx_t)schema.n_children; type_idx++) {
|
121
124
|
auto child_type = GetArrowLogicalType(*schema.children[type_idx], arrow_convert_data, col_idx);
|
122
125
|
child_types.push_back({schema.children[type_idx]->name, child_type});
|
123
126
|
}
|
124
|
-
return LogicalType::STRUCT(
|
127
|
+
return LogicalType::STRUCT(child_types);
|
125
128
|
|
126
129
|
} else if (format == "+m") {
|
127
130
|
arrow_convert_data[col_idx]->variable_sz_type.emplace_back(ArrowVariableSizeType::NORMAL, 0);
|
@@ -316,6 +316,20 @@ void IntervalConversionMonths(Vector &vector, ArrowArray &array, ArrowScanLocalS
|
|
316
316
|
}
|
317
317
|
}
|
318
318
|
|
319
|
+
void IntervalConversionMonthDayNanos(Vector &vector, ArrowArray &array, ArrowScanLocalState &scan_state,
|
320
|
+
int64_t nested_offset, idx_t size) {
|
321
|
+
auto tgt_ptr = (interval_t *)FlatVector::GetData(vector);
|
322
|
+
auto src_ptr = (ArrowInterval *)array.buffers[1] + scan_state.chunk_offset + array.offset;
|
323
|
+
if (nested_offset != -1) {
|
324
|
+
src_ptr = (ArrowInterval *)array.buffers[1] + nested_offset + array.offset;
|
325
|
+
}
|
326
|
+
for (idx_t row = 0; row < size; row++) {
|
327
|
+
tgt_ptr[row].days = src_ptr[row].days;
|
328
|
+
tgt_ptr[row].micros = src_ptr[row].nanoseconds / Interval::NANOS_PER_MICRO;
|
329
|
+
tgt_ptr[row].months = src_ptr[row].months;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
319
333
|
void ColumnArrowToDuckDB(Vector &vector, ArrowArray &array, ArrowScanLocalState &scan_state, idx_t size,
|
320
334
|
std::unordered_map<idx_t, unique_ptr<ArrowConvertData>> &arrow_convert_data, idx_t col_idx,
|
321
335
|
std::pair<idx_t, idx_t> &arrow_convert_idx, int64_t nested_offset, ValidityMask *parent_mask) {
|
@@ -509,6 +523,10 @@ void ColumnArrowToDuckDB(Vector &vector, ArrowArray &array, ArrowScanLocalState
|
|
509
523
|
IntervalConversionMonths(vector, array, scan_state, nested_offset, size);
|
510
524
|
break;
|
511
525
|
}
|
526
|
+
case ArrowDateTimeType::MONTH_DAY_NANO: {
|
527
|
+
IntervalConversionMonthDayNanos(vector, array, scan_state, nested_offset, size);
|
528
|
+
break;
|
529
|
+
}
|
512
530
|
default:
|
513
531
|
throw std::runtime_error("Unsupported precision for Interval/Duration Type ");
|
514
532
|
}
|
@@ -138,7 +138,7 @@ vector<TestType> TestAllTypesFun::GetTestTypes() {
|
|
138
138
|
child_list_t<LogicalType> struct_type_list;
|
139
139
|
struct_type_list.push_back(make_pair("a", LogicalType::INTEGER));
|
140
140
|
struct_type_list.push_back(make_pair("b", LogicalType::VARCHAR));
|
141
|
-
auto struct_type = LogicalType::STRUCT(
|
141
|
+
auto struct_type = LogicalType::STRUCT(struct_type_list);
|
142
142
|
|
143
143
|
child_list_t<Value> min_struct_list;
|
144
144
|
min_struct_list.push_back(make_pair("a", Value(LogicalType::INTEGER)));
|
@@ -156,7 +156,7 @@ vector<TestType> TestAllTypesFun::GetTestTypes() {
|
|
156
156
|
child_list_t<LogicalType> struct_list_type_list;
|
157
157
|
struct_list_type_list.push_back(make_pair("a", int_list_type));
|
158
158
|
struct_list_type_list.push_back(make_pair("b", varchar_list_type));
|
159
|
-
auto struct_list_type = LogicalType::STRUCT(
|
159
|
+
auto struct_list_type = LogicalType::STRUCT(struct_list_type_list);
|
160
160
|
|
161
161
|
child_list_t<Value> min_struct_vl_list;
|
162
162
|
min_struct_vl_list.push_back(make_pair("a", Value(int_list_type)));
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.7.2-
|
2
|
+
#define DUCKDB_VERSION "0.7.2-dev614"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "40e91c8873"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
@@ -14,12 +14,12 @@ TableFunctionInfo::~TableFunctionInfo() {
|
|
14
14
|
TableFunction::TableFunction(string name, vector<LogicalType> arguments, table_function_t function,
|
15
15
|
table_function_bind_t bind, table_function_init_global_t init_global,
|
16
16
|
table_function_init_local_t init_local)
|
17
|
-
: SimpleNamedParameterFunction(std::move(name), std::move(arguments)), bind(bind),
|
18
|
-
init_local(init_local), function(function), in_out_function(nullptr),
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
filter_prune(false) {
|
17
|
+
: SimpleNamedParameterFunction(std::move(name), std::move(arguments)), bind(bind), bind_replace(nullptr),
|
18
|
+
init_global(init_global), init_local(init_local), function(function), in_out_function(nullptr),
|
19
|
+
in_out_function_final(nullptr), statistics(nullptr), dependency(nullptr), cardinality(nullptr),
|
20
|
+
pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr),
|
21
|
+
get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr), projection_pushdown(false),
|
22
|
+
filter_pushdown(false), filter_prune(false) {
|
23
23
|
}
|
24
24
|
|
25
25
|
TableFunction::TableFunction(const vector<LogicalType> &arguments, table_function_t function,
|
@@ -28,11 +28,11 @@ TableFunction::TableFunction(const vector<LogicalType> &arguments, table_functio
|
|
28
28
|
: TableFunction(string(), arguments, function, bind, init_global, init_local) {
|
29
29
|
}
|
30
30
|
TableFunction::TableFunction()
|
31
|
-
: SimpleNamedParameterFunction("", {}), bind(nullptr),
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
filter_pushdown(false), filter_prune(false) {
|
31
|
+
: SimpleNamedParameterFunction("", {}), bind(nullptr), bind_replace(nullptr), init_global(nullptr),
|
32
|
+
init_local(nullptr), function(nullptr), in_out_function(nullptr), statistics(nullptr), dependency(nullptr),
|
33
|
+
cardinality(nullptr), pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr),
|
34
|
+
get_batch_index(nullptr), get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr),
|
35
|
+
projection_pushdown(false), filter_pushdown(false), filter_prune(false) {
|
36
36
|
}
|
37
37
|
|
38
38
|
bool TableFunction::Equal(const TableFunction &rhs) const {
|
@@ -205,6 +205,9 @@ public:
|
|
205
205
|
DUCKDB_API static LogicalType GetType(ClientContext &context, const string &catalog_name, const string &schema,
|
206
206
|
const string &name);
|
207
207
|
|
208
|
+
static bool TypeExists(ClientContext &context, const string &catalog_name, const string &schema,
|
209
|
+
const string &name);
|
210
|
+
|
208
211
|
template <class T>
|
209
212
|
T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
|
210
213
|
QueryErrorContext error_context = QueryErrorContext()) {
|
@@ -25,7 +25,7 @@ struct IndexWriteOperation {
|
|
25
25
|
|
26
26
|
class FieldWriter {
|
27
27
|
public:
|
28
|
-
DUCKDB_API FieldWriter(Serializer &serializer);
|
28
|
+
DUCKDB_API explicit FieldWriter(Serializer &serializer);
|
29
29
|
DUCKDB_API ~FieldWriter();
|
30
30
|
|
31
31
|
public:
|
@@ -128,11 +128,11 @@ public:
|
|
128
128
|
return *buffer;
|
129
129
|
}
|
130
130
|
|
131
|
-
private:
|
132
131
|
void AddField() {
|
133
132
|
field_count++;
|
134
133
|
}
|
135
134
|
|
135
|
+
private:
|
136
136
|
template <class T>
|
137
137
|
void Write(const T &element) {
|
138
138
|
WriteData((const_data_ptr_t)&element, sizeof(T));
|
@@ -152,7 +152,7 @@ DUCKDB_API void FieldWriter::Write(const string &val);
|
|
152
152
|
|
153
153
|
class FieldDeserializer : public Deserializer {
|
154
154
|
public:
|
155
|
-
FieldDeserializer(Deserializer &root);
|
155
|
+
explicit FieldDeserializer(Deserializer &root);
|
156
156
|
|
157
157
|
public:
|
158
158
|
void ReadData(data_ptr_t buffer, idx_t read_size) override;
|
@@ -163,6 +163,14 @@ public:
|
|
163
163
|
return root;
|
164
164
|
}
|
165
165
|
|
166
|
+
ClientContext &GetContext() override {
|
167
|
+
return root.GetContext();
|
168
|
+
}
|
169
|
+
|
170
|
+
Catalog *GetCatalog() override {
|
171
|
+
return root.GetCatalog();
|
172
|
+
}
|
173
|
+
|
166
174
|
private:
|
167
175
|
Deserializer &root;
|
168
176
|
idx_t remaining_data;
|
@@ -177,7 +185,7 @@ struct IndexReadOperation {
|
|
177
185
|
|
178
186
|
class FieldReader {
|
179
187
|
public:
|
180
|
-
DUCKDB_API FieldReader(Deserializer &source);
|
188
|
+
DUCKDB_API explicit FieldReader(Deserializer &source);
|
181
189
|
DUCKDB_API ~FieldReader();
|
182
190
|
|
183
191
|
public:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
//===----------------------------------------------------------------------===//
|
2
2
|
// DuckDB
|
3
3
|
//
|
4
|
-
// duckdb/common/
|
4
|
+
// duckdb/common/http_state.hpp
|
5
5
|
//
|
6
6
|
//
|
7
7
|
//===----------------------------------------------------------------------===//
|
@@ -15,7 +15,16 @@
|
|
15
15
|
|
16
16
|
namespace duckdb {
|
17
17
|
|
18
|
-
|
18
|
+
struct CachedFile {
|
19
|
+
//! Cached Data
|
20
|
+
shared_ptr<char> data;
|
21
|
+
//! Data capacity
|
22
|
+
uint64_t capacity = 0;
|
23
|
+
//! If we finished downloading the file
|
24
|
+
bool finished = false;
|
25
|
+
};
|
26
|
+
|
27
|
+
class HTTPState {
|
19
28
|
public:
|
20
29
|
atomic<idx_t> head_count {0};
|
21
30
|
atomic<idx_t> get_count {0};
|
@@ -23,6 +32,10 @@ public:
|
|
23
32
|
atomic<idx_t> post_count {0};
|
24
33
|
atomic<idx_t> total_bytes_received {0};
|
25
34
|
atomic<idx_t> total_bytes_sent {0};
|
35
|
+
//! Mutex to lock when getting the cached file(Parallel Only)
|
36
|
+
mutex cached_files_mutex;
|
37
|
+
//! In case of fully downloading the file, the cached files of this query
|
38
|
+
unordered_map<string, CachedFile> cached_files;
|
26
39
|
|
27
40
|
void Reset() {
|
28
41
|
head_count = 0;
|
@@ -31,13 +44,14 @@ public:
|
|
31
44
|
post_count = 0;
|
32
45
|
total_bytes_received = 0;
|
33
46
|
total_bytes_sent = 0;
|
47
|
+
cached_files.clear();
|
34
48
|
}
|
35
49
|
|
36
50
|
//! helper function to get the HTTP
|
37
|
-
static
|
51
|
+
static HTTPState *TryGetState(FileOpener *opener) {
|
38
52
|
auto client_context = FileOpener::TryGetClientContext(opener);
|
39
53
|
if (client_context) {
|
40
|
-
return client_context->client_data->
|
54
|
+
return client_context->client_data->http_state.get();
|
41
55
|
}
|
42
56
|
return nullptr;
|
43
57
|
}
|
@@ -26,14 +26,16 @@ public:
|
|
26
26
|
void ReadData(data_ptr_t buffer, uint64_t read_size) override;
|
27
27
|
};
|
28
28
|
|
29
|
-
class
|
29
|
+
class BufferedContextDeserializer : public BufferedDeserializer {
|
30
30
|
public:
|
31
|
-
|
31
|
+
BufferedContextDeserializer(ClientContext &context_p, data_ptr_t ptr, idx_t data_size)
|
32
32
|
: BufferedDeserializer(ptr, data_size), context(context_p) {
|
33
33
|
}
|
34
34
|
|
35
35
|
public:
|
36
36
|
ClientContext &context;
|
37
|
+
|
38
|
+
ClientContext &GetContext() override;
|
37
39
|
};
|
38
40
|
|
39
41
|
} // namespace duckdb
|
@@ -14,14 +14,16 @@ namespace duckdb {
|
|
14
14
|
|
15
15
|
class BufferedFileReader : public Deserializer {
|
16
16
|
public:
|
17
|
-
BufferedFileReader(FileSystem &fs, const char *path,
|
18
|
-
FileOpener *opener = nullptr);
|
17
|
+
BufferedFileReader(FileSystem &fs, const char *path, ClientContext *context,
|
18
|
+
FileLockType lock_type = FileLockType::READ_LOCK, FileOpener *opener = nullptr);
|
19
19
|
|
20
20
|
FileSystem &fs;
|
21
21
|
unique_ptr<data_t[]> data;
|
22
22
|
idx_t offset;
|
23
23
|
idx_t read_data;
|
24
24
|
unique_ptr<FileHandle> handle;
|
25
|
+
ClientContext *context;
|
26
|
+
Catalog *catalog = nullptr;
|
25
27
|
|
26
28
|
public:
|
27
29
|
void ReadData(data_ptr_t buffer, uint64_t read_size) override;
|
@@ -35,6 +37,10 @@ public:
|
|
35
37
|
void Seek(uint64_t location);
|
36
38
|
uint64_t CurrentOffset();
|
37
39
|
|
40
|
+
ClientContext &GetContext() override;
|
41
|
+
|
42
|
+
Catalog *GetCatalog() override;
|
43
|
+
|
38
44
|
private:
|
39
45
|
idx_t file_size;
|
40
46
|
idx_t total_read;
|
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
+
#include "duckdb/catalog/catalog.hpp"
|
11
12
|
#include "duckdb/common/common.hpp"
|
12
13
|
#include "duckdb/common/exception.hpp"
|
13
14
|
#include "duckdb/common/vector.hpp"
|
@@ -21,6 +22,8 @@ private:
|
|
21
22
|
uint64_t version = 0L;
|
22
23
|
|
23
24
|
public:
|
25
|
+
bool is_query_plan = false;
|
26
|
+
|
24
27
|
virtual ~Serializer() {
|
25
28
|
}
|
26
29
|
|
@@ -111,6 +114,16 @@ public:
|
|
111
114
|
//! Reads [read_size] bytes into the buffer
|
112
115
|
virtual void ReadData(data_ptr_t buffer, idx_t read_size) = 0;
|
113
116
|
|
117
|
+
//! Gets the context for the deserializer
|
118
|
+
virtual ClientContext &GetContext() {
|
119
|
+
throw InternalException("This deserializer does not have a client-context");
|
120
|
+
};
|
121
|
+
|
122
|
+
//! Gets the catalog for the deserializer
|
123
|
+
virtual Catalog *GetCatalog() {
|
124
|
+
return nullptr;
|
125
|
+
};
|
126
|
+
|
114
127
|
template <class T>
|
115
128
|
T Read() {
|
116
129
|
T value;
|
@@ -151,11 +151,11 @@ public:
|
|
151
151
|
//! Cannot be called with an empty list, use either EMPTYLIST or LIST with a type instead
|
152
152
|
DUCKDB_API static Value LIST(vector<Value> values);
|
153
153
|
//! Create a list value with the given entries
|
154
|
-
DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
|
154
|
+
DUCKDB_API static Value LIST(const LogicalType &child_type, vector<Value> values);
|
155
155
|
//! Create an empty list with the specified child-type
|
156
|
-
DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
|
156
|
+
DUCKDB_API static Value EMPTYLIST(const LogicalType &child_type);
|
157
157
|
//! Create a map value with the given entries
|
158
|
-
DUCKDB_API static Value MAP(LogicalType child_type, vector<Value> values);
|
158
|
+
DUCKDB_API static Value MAP(const LogicalType &child_type, vector<Value> values);
|
159
159
|
//! Create a union value from a selected value and a tag from a set of alternatives.
|
160
160
|
DUCKDB_API static Value UNION(child_list_t<LogicalType> members, uint8_t tag, Value value);
|
161
161
|
|
@@ -23,6 +23,20 @@ class Value;
|
|
23
23
|
class TypeCatalogEntry;
|
24
24
|
class Vector;
|
25
25
|
class ClientContext;
|
26
|
+
class FieldWriter;
|
27
|
+
|
28
|
+
//! Extra Type Info Type
|
29
|
+
enum class ExtraTypeInfoType : uint8_t {
|
30
|
+
INVALID_TYPE_INFO = 0,
|
31
|
+
GENERIC_TYPE_INFO = 1,
|
32
|
+
DECIMAL_TYPE_INFO = 2,
|
33
|
+
STRING_TYPE_INFO = 3,
|
34
|
+
LIST_TYPE_INFO = 4,
|
35
|
+
STRUCT_TYPE_INFO = 5,
|
36
|
+
ENUM_TYPE_INFO = 6,
|
37
|
+
USER_TYPE_INFO = 7,
|
38
|
+
AGGREGATE_STATE_TYPE_INFO = 8
|
39
|
+
};
|
26
40
|
|
27
41
|
struct hugeint_t {
|
28
42
|
public:
|
@@ -297,6 +311,11 @@ struct LogicalType {
|
|
297
311
|
inline const ExtraTypeInfo *AuxInfo() const {
|
298
312
|
return type_info_.get();
|
299
313
|
}
|
314
|
+
|
315
|
+
inline shared_ptr<ExtraTypeInfo> GetAuxInfoShrPtr() const {
|
316
|
+
return type_info_;
|
317
|
+
}
|
318
|
+
|
300
319
|
inline void CopyAuxInfo(const LogicalType& other) {
|
301
320
|
type_info_ = other.type_info_;
|
302
321
|
}
|
@@ -324,6 +343,9 @@ struct LogicalType {
|
|
324
343
|
|
325
344
|
//! Serializes a LogicalType to a stand-alone binary blob
|
326
345
|
DUCKDB_API void Serialize(Serializer &serializer) const;
|
346
|
+
|
347
|
+
DUCKDB_API void SerializeEnumType(Serializer &serializer) const;
|
348
|
+
|
327
349
|
//! Deserializes a blob back into an LogicalType
|
328
350
|
DUCKDB_API static LogicalType Deserialize(Deserializer &source);
|
329
351
|
|
@@ -349,6 +371,8 @@ struct LogicalType {
|
|
349
371
|
DUCKDB_API static void SetCatalog(LogicalType &type, TypeCatalogEntry* catalog_entry);
|
350
372
|
DUCKDB_API static TypeCatalogEntry* GetCatalog(const LogicalType &type);
|
351
373
|
|
374
|
+
DUCKDB_API static ExtraTypeInfoType GetExtraTypeInfoType(const ExtraTypeInfo &type);
|
375
|
+
|
352
376
|
//! Gets the decimal properties of a numeric type. Fails if the type is not numeric.
|
353
377
|
DUCKDB_API bool GetDecimalProperties(uint8_t &width, uint8_t &scale) const;
|
354
378
|
|
@@ -403,10 +427,10 @@ public:
|
|
403
427
|
// explicitly allowing these functions to be capitalized to be in-line with the remaining functions
|
404
428
|
DUCKDB_API static LogicalType DECIMAL(int width, int scale); // NOLINT
|
405
429
|
DUCKDB_API static LogicalType VARCHAR_COLLATION(string collation); // NOLINT
|
406
|
-
DUCKDB_API static LogicalType LIST( LogicalType child); // NOLINT
|
407
|
-
DUCKDB_API static LogicalType STRUCT( child_list_t<LogicalType> children); // NOLINT
|
430
|
+
DUCKDB_API static LogicalType LIST(const LogicalType &child); // NOLINT
|
431
|
+
DUCKDB_API static LogicalType STRUCT(const child_list_t<LogicalType> &children); // NOLINT
|
408
432
|
DUCKDB_API static LogicalType AGGREGATE_STATE(aggregate_state_t state_type); // NOLINT
|
409
|
-
DUCKDB_API static LogicalType MAP(LogicalType child); // NOLINT
|
433
|
+
DUCKDB_API static LogicalType MAP(const LogicalType &child); // NOLINT
|
410
434
|
DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
|
411
435
|
DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
|
412
436
|
DUCKDB_API static LogicalType UNION( child_list_t<LogicalType> members); // NOLINT
|
@@ -441,12 +465,14 @@ struct UserType{
|
|
441
465
|
struct EnumType{
|
442
466
|
DUCKDB_API static const string &GetTypeName(const LogicalType &type);
|
443
467
|
DUCKDB_API static int64_t GetPos(const LogicalType &type, const string_t& key);
|
444
|
-
DUCKDB_API static Vector &GetValuesInsertOrder(const LogicalType &type);
|
468
|
+
DUCKDB_API static const Vector &GetValuesInsertOrder(const LogicalType &type);
|
445
469
|
DUCKDB_API static idx_t GetSize(const LogicalType &type);
|
446
470
|
DUCKDB_API static const string GetValue(const Value &val);
|
447
471
|
DUCKDB_API static void SetCatalog(LogicalType &type, TypeCatalogEntry* catalog_entry);
|
448
472
|
DUCKDB_API static TypeCatalogEntry* GetCatalog(const LogicalType &type);
|
473
|
+
DUCKDB_API static string GetSchemaName(const LogicalType &type);
|
449
474
|
DUCKDB_API static PhysicalType GetPhysicalType(const LogicalType &type);
|
475
|
+
DUCKDB_API static void Serialize(FieldWriter& writer, const ExtraTypeInfo& type_info, bool serialize_internals);
|
450
476
|
};
|
451
477
|
|
452
478
|
struct StructType {
|
@@ -87,6 +87,7 @@ public:
|
|
87
87
|
// we have data left to read from the file
|
88
88
|
// read directly into the buffer
|
89
89
|
auto bytes_read = file_handle->Read((char *)buffer + result_offset, nr_bytes - result_offset);
|
90
|
+
file_size = file_handle->GetFileSize();
|
90
91
|
read_position += bytes_read;
|
91
92
|
if (reset_enabled) {
|
92
93
|
// if reset caching is enabled, we need to cache the bytes that we have read
|
@@ -32,7 +32,18 @@ enum class ArrowDateTimeType : uint8_t {
|
|
32
32
|
NANOSECONDS = 2,
|
33
33
|
SECONDS = 3,
|
34
34
|
DAYS = 4,
|
35
|
-
MONTHS = 5
|
35
|
+
MONTHS = 5,
|
36
|
+
MONTH_DAY_NANO = 6
|
37
|
+
};
|
38
|
+
|
39
|
+
struct ArrowInterval {
|
40
|
+
int32_t months;
|
41
|
+
int32_t days;
|
42
|
+
int64_t nanoseconds;
|
43
|
+
|
44
|
+
inline bool operator==(const ArrowInterval &rhs) const {
|
45
|
+
return this->days == rhs.days && this->months == rhs.months && this->nanoseconds == rhs.nanoseconds;
|
46
|
+
}
|
36
47
|
};
|
37
48
|
|
38
49
|
struct ArrowConvertData {
|
@@ -11,6 +11,8 @@
|
|
11
11
|
#include "duckdb/common/enums/operator_result_type.hpp"
|
12
12
|
#include "duckdb/execution/execution_context.hpp"
|
13
13
|
#include "duckdb/function/function.hpp"
|
14
|
+
#include "duckdb/planner/bind_context.hpp"
|
15
|
+
#include "duckdb/planner/logical_operator.hpp"
|
14
16
|
#include "duckdb/storage/statistics/node_statistics.hpp"
|
15
17
|
|
16
18
|
#include <functional>
|
@@ -136,6 +138,7 @@ public:
|
|
136
138
|
|
137
139
|
typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, TableFunctionBindInput &input,
|
138
140
|
vector<LogicalType> &return_types, vector<string> &names);
|
141
|
+
typedef unique_ptr<TableRef> (*table_function_bind_replace_t)(ClientContext &context, TableFunctionBindInput &input);
|
139
142
|
typedef unique_ptr<GlobalTableFunctionState> (*table_function_init_global_t)(ClientContext &context,
|
140
143
|
TableFunctionInitInput &input);
|
141
144
|
typedef unique_ptr<LocalTableFunctionState> (*table_function_init_local_t)(ExecutionContext &context,
|
@@ -185,6 +188,11 @@ public:
|
|
185
188
|
//! This function is used for determining the return type of a table producing function and returning bind data
|
186
189
|
//! The returned FunctionData object should be constant and should not be changed during execution.
|
187
190
|
table_function_bind_t bind;
|
191
|
+
//! (Optional) Bind replace function
|
192
|
+
//! This function is called before the regular bind function. It allows returning a TableRef will be used to
|
193
|
+
//! to generate a logical plan that replaces the LogicalGet of a regularly bound TableFunction. The BindReplace can
|
194
|
+
//! also return a nullptr to indicate a regular bind needs to be performed instead.
|
195
|
+
table_function_bind_replace_t bind_replace;
|
188
196
|
//! (Optional) global init function
|
189
197
|
//! Initialize the global operator state of the function.
|
190
198
|
//! The global operator state is used to keep track of the progress in the table function and is shared between
|
@@ -20,7 +20,7 @@ class BufferedFileWriter;
|
|
20
20
|
class ClientContext;
|
21
21
|
class CatalogSearchPath;
|
22
22
|
class FileOpener;
|
23
|
-
class
|
23
|
+
class HTTPState;
|
24
24
|
class QueryProfiler;
|
25
25
|
class QueryProfilerHistory;
|
26
26
|
class PreparedStatementData;
|
@@ -52,8 +52,8 @@ struct ClientData {
|
|
52
52
|
//! The file opener of the client context
|
53
53
|
unique_ptr<FileOpener> file_opener;
|
54
54
|
|
55
|
-
//!
|
56
|
-
unique_ptr<
|
55
|
+
//! HTTP State in this query
|
56
|
+
unique_ptr<HTTPState> http_state;
|
57
57
|
|
58
58
|
//! The file search path
|
59
59
|
string file_search_path;
|
@@ -96,6 +96,7 @@ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
|
|
96
96
|
{"http_retry_backoff", "httpfs"},
|
97
97
|
{"http_retry_wait_ms", "httpfs"},
|
98
98
|
{"http_timeout", "httpfs"},
|
99
|
+
{"force_download", "httpfs"},
|
99
100
|
{"s3_access_key_id", "httpfs"},
|
100
101
|
{"s3_endpoint", "httpfs"},
|
101
102
|
{"s3_region", "httpfs"},
|
@@ -59,6 +59,9 @@ public:
|
|
59
59
|
void Serialize(Serializer &serializer) const;
|
60
60
|
virtual void Serialize(FieldWriter &writer) const = 0;
|
61
61
|
static unique_ptr<AlterInfo> Deserialize(Deserializer &source);
|
62
|
+
virtual string GetColumnName() const {
|
63
|
+
return "";
|
64
|
+
};
|
62
65
|
|
63
66
|
AlterEntryData GetAlterEntryData() const;
|
64
67
|
};
|