duckdb 0.7.2-dev2995.0 → 0.7.2-dev3117.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 +1 -0
- package/package.json +1 -1
- package/src/duckdb/extension/json/include/json_deserializer.hpp +1 -0
- package/src/duckdb/extension/json/include/json_serializer.hpp +8 -1
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +1 -3
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +3 -3
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +3 -2
- package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -7
- package/src/duckdb/src/common/enum_util.cpp +5908 -0
- package/src/duckdb/src/common/enums/expression_type.cpp +216 -4
- package/src/duckdb/src/common/enums/join_type.cpp +6 -5
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/exception.cpp +1 -1
- package/src/duckdb/src/common/exception_format_value.cpp +2 -2
- package/src/duckdb/src/common/multi_file_reader.cpp +14 -0
- package/src/duckdb/src/common/serializer/binary_deserializer.cpp +143 -0
- package/src/duckdb/src/common/serializer/binary_serializer.cpp +160 -0
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +3 -3
- package/src/duckdb/src/common/types.cpp +11 -10
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +4 -4
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +2 -1
- package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +2 -3
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +3 -3
- package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +1 -1
- package/src/duckdb/src/execution/operator/aggregate/grouped_aggregate_data.cpp +2 -2
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +3 -2
- package/src/duckdb/src/execution/operator/helper/physical_streaming_sample.cpp +2 -1
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +2 -1
- package/src/duckdb/src/execution/operator/join/physical_comparison_join.cpp +2 -1
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +165 -0
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +9 -7
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +25 -4
- package/src/duckdb/src/execution/physical_plan/plan_sample.cpp +2 -1
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +1 -1
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +5 -4
- package/src/duckdb/src/function/table/copy_csv.cpp +85 -29
- package/src/duckdb/src/function/table/read_csv.cpp +17 -11
- package/src/duckdb/src/function/table/system/duckdb_settings.cpp +2 -1
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +2 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +958 -0
- package/src/duckdb/src/include/duckdb/common/enums/join_type.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +4 -4
- package/src/duckdb/src/include/duckdb/common/exception_format_value.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +93 -0
- package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +92 -0
- package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +7 -3
- package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/vector.hpp +61 -14
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/distinct_aggregate_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/grouped_aggregate_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +68 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/copy_function.hpp +32 -4
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +4 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +1 -3
- package/src/duckdb/src/include/duckdb/main/database_path_and_type.hpp +24 -0
- package/src/duckdb/src/include/duckdb/main/relation/setop_relation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/sample_options.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_select_node.hpp +1 -1
- package/src/duckdb/src/include/duckdb/verification/deserialized_statement_verifier_v2.hpp +26 -0
- package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +1 -0
- package/src/duckdb/src/main/client_context.cpp +1 -0
- package/src/duckdb/src/main/client_verify.cpp +1 -0
- package/src/duckdb/src/main/database.cpp +11 -23
- package/src/duckdb/src/main/database_path_and_type.cpp +23 -0
- package/src/duckdb/src/main/relation/join_relation.cpp +2 -1
- package/src/duckdb/src/main/relation/setop_relation.cpp +2 -3
- package/src/duckdb/src/parser/expression/window_expression.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/sample_options.cpp +2 -2
- package/src/duckdb/src/parser/query_node/select_node.cpp +1 -1
- package/src/duckdb/src/parser/result_modifier.cpp +2 -2
- package/src/duckdb/src/parser/statement/select_statement.cpp +0 -44
- package/src/duckdb/src/parser/tableref/joinref.cpp +3 -3
- package/src/duckdb/src/parser/tableref.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +6 -0
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +4 -1
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +7 -0
- package/src/duckdb/src/planner/operator/logical_aggregate.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +2 -2
- package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +2 -1
- package/src/duckdb/src/verification/deserialized_statement_verifier_v2.cpp +20 -0
- package/src/duckdb/src/verification/statement_verifier.cpp +3 -0
- package/src/duckdb/ub_src_common.cpp +2 -2
- package/src/duckdb/ub_src_common_serializer.cpp +4 -2
- package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
- package/src/duckdb/ub_src_main.cpp +2 -0
- package/src/duckdb/src/common/serializer/enum_serializer.cpp +0 -1180
- package/src/duckdb/src/common/vector.cpp +0 -12
- package/src/duckdb/src/include/duckdb/common/serializer/enum_serializer.hpp +0 -113
@@ -7,9 +7,9 @@
|
|
7
7
|
#include "duckdb/function/copy_function.hpp"
|
8
8
|
#include "duckdb/function/scalar/string_functions.hpp"
|
9
9
|
#include "duckdb/function/table/read_csv.hpp"
|
10
|
-
#include "duckdb/main/config.hpp"
|
11
10
|
#include "duckdb/parser/parsed_data/copy_info.hpp"
|
12
11
|
#include "duckdb/common/multi_file_reader.hpp"
|
12
|
+
#include "duckdb/common/types/column/column_data_collection.hpp"
|
13
13
|
#include <limits>
|
14
14
|
|
15
15
|
namespace duckdb {
|
@@ -77,6 +77,14 @@ static unique_ptr<FunctionData> WriteCSVBind(ClientContext &context, CopyInfo &i
|
|
77
77
|
bind_data->Finalize();
|
78
78
|
bind_data->is_simple = bind_data->options.delimiter.size() == 1 && bind_data->options.escape.size() == 1 &&
|
79
79
|
bind_data->options.quote.size() == 1;
|
80
|
+
if (bind_data->is_simple) {
|
81
|
+
bind_data->requires_quotes = unique_ptr<bool[]>(new bool[256]);
|
82
|
+
memset(bind_data->requires_quotes.get(), 0, sizeof(bool) * 256);
|
83
|
+
bind_data->requires_quotes['\n'] = true;
|
84
|
+
bind_data->requires_quotes['\r'] = true;
|
85
|
+
bind_data->requires_quotes[bind_data->options.delimiter[0]] = true;
|
86
|
+
bind_data->requires_quotes[bind_data->options.quote[0]] = true;
|
87
|
+
}
|
80
88
|
return std::move(bind_data);
|
81
89
|
}
|
82
90
|
|
@@ -143,9 +151,10 @@ static bool RequiresQuotes(WriteCSVData &csv_data, const char *str, idx_t len) {
|
|
143
151
|
}
|
144
152
|
if (csv_data.is_simple) {
|
145
153
|
// simple CSV: check for newlines, quotes and delimiter all at once
|
154
|
+
auto str_data = reinterpret_cast<const_data_ptr_t>(str);
|
146
155
|
for (idx_t i = 0; i < len; i++) {
|
147
|
-
if (
|
148
|
-
//
|
156
|
+
if (csv_data.requires_quotes[str_data[i]]) {
|
157
|
+
// this byte requires quotes - write a quoted string
|
149
158
|
return true;
|
150
159
|
}
|
151
160
|
}
|
@@ -237,7 +246,7 @@ static void WriteQuotedString(Serializer &serializer, WriteCSVData &csv_data, co
|
|
237
246
|
//===--------------------------------------------------------------------===//
|
238
247
|
// Sink
|
239
248
|
//===--------------------------------------------------------------------===//
|
240
|
-
struct
|
249
|
+
struct LocalWriteCSVData : public LocalFunctionData {
|
241
250
|
//! The thread-local buffer to write data into
|
242
251
|
BufferedSerializer serializer;
|
243
252
|
//! A chunk with VARCHAR columns to cast intermediates into
|
@@ -264,8 +273,8 @@ struct GlobalWriteCSVData : public GlobalFunctionData {
|
|
264
273
|
};
|
265
274
|
|
266
275
|
static unique_ptr<LocalFunctionData> WriteCSVInitializeLocal(ExecutionContext &context, FunctionData &bind_data) {
|
267
|
-
auto &csv_data = (
|
268
|
-
auto local_data = make_uniq<
|
276
|
+
auto &csv_data = bind_data.Cast<WriteCSVData>();
|
277
|
+
auto local_data = make_uniq<LocalWriteCSVData>();
|
269
278
|
|
270
279
|
// create the chunk with VARCHAR types
|
271
280
|
vector<LogicalType> types;
|
@@ -277,7 +286,7 @@ static unique_ptr<LocalFunctionData> WriteCSVInitializeLocal(ExecutionContext &c
|
|
277
286
|
|
278
287
|
static unique_ptr<GlobalFunctionData> WriteCSVInitializeGlobal(ClientContext &context, FunctionData &bind_data,
|
279
288
|
const string &file_path) {
|
280
|
-
auto &csv_data = (
|
289
|
+
auto &csv_data = bind_data.Cast<WriteCSVData>();
|
281
290
|
auto &options = csv_data.options;
|
282
291
|
auto global_data = make_uniq<GlobalWriteCSVData>(FileSystem::GetFileSystem(context), file_path,
|
283
292
|
FileSystem::GetFileOpener(context), options.compression);
|
@@ -299,17 +308,12 @@ static unique_ptr<GlobalFunctionData> WriteCSVInitializeGlobal(ClientContext &co
|
|
299
308
|
return std::move(global_data);
|
300
309
|
}
|
301
310
|
|
302
|
-
static void
|
303
|
-
|
304
|
-
auto &csv_data = (
|
311
|
+
static void WriteCSVChunkInternal(ClientContext &context, FunctionData &bind_data, DataChunk &cast_chunk,
|
312
|
+
BufferedSerializer &writer, DataChunk &input) {
|
313
|
+
auto &csv_data = bind_data.Cast<WriteCSVData>();
|
305
314
|
auto &options = csv_data.options;
|
306
|
-
auto &local_data = (LocalReadCSVData &)lstate;
|
307
|
-
auto &global_state = (GlobalWriteCSVData &)gstate;
|
308
|
-
|
309
|
-
// write data into the local buffer
|
310
315
|
|
311
316
|
// first cast the columns of the chunk to varchar
|
312
|
-
auto &cast_chunk = local_data.cast_chunk;
|
313
317
|
cast_chunk.Reset();
|
314
318
|
cast_chunk.SetCardinality(input);
|
315
319
|
for (idx_t col_idx = 0; col_idx < input.ColumnCount(); col_idx++) {
|
@@ -332,12 +336,11 @@ static void WriteCSVSink(ExecutionContext &context, FunctionData &bind_data, Glo
|
|
332
336
|
input.data[col_idx], cast_chunk.data[col_idx], input.size());
|
333
337
|
} else {
|
334
338
|
// non varchar column, perform the cast
|
335
|
-
VectorOperations::Cast(context
|
339
|
+
VectorOperations::Cast(context, input.data[col_idx], cast_chunk.data[col_idx], input.size());
|
336
340
|
}
|
337
341
|
}
|
338
342
|
|
339
343
|
cast_chunk.Flatten();
|
340
|
-
auto &writer = local_data.serializer;
|
341
344
|
// now loop over the vectors and output the values
|
342
345
|
for (idx_t row_idx = 0; row_idx < cast_chunk.size(); row_idx++) {
|
343
346
|
// write values
|
@@ -353,16 +356,27 @@ static void WriteCSVSink(ExecutionContext &context, FunctionData &bind_data, Glo
|
|
353
356
|
|
354
357
|
// non-null value, fetch the string value from the cast chunk
|
355
358
|
auto str_data = FlatVector::GetData<string_t>(cast_chunk.data[col_idx]);
|
356
|
-
auto str_value = str_data[row_idx];
|
357
359
|
// FIXME: we could gain some performance here by checking for certain types if they ever require quotes
|
358
360
|
// (e.g. integers only require quotes if the delimiter is a number, decimals only require quotes if the
|
359
361
|
// delimiter is a number or "." character)
|
360
|
-
WriteQuotedString(writer, csv_data,
|
362
|
+
WriteQuotedString(writer, csv_data, str_data[row_idx].GetData(), str_data[row_idx].GetSize(),
|
361
363
|
csv_data.options.force_quote[col_idx]);
|
362
364
|
}
|
363
365
|
writer.WriteBufferData(csv_data.newline);
|
364
366
|
}
|
367
|
+
}
|
368
|
+
|
369
|
+
static void WriteCSVSink(ExecutionContext &context, FunctionData &bind_data, GlobalFunctionData &gstate,
|
370
|
+
LocalFunctionData &lstate, DataChunk &input) {
|
371
|
+
auto &csv_data = bind_data.Cast<WriteCSVData>();
|
372
|
+
auto &local_data = lstate.Cast<LocalWriteCSVData>();
|
373
|
+
auto &global_state = gstate.Cast<GlobalWriteCSVData>();
|
374
|
+
|
375
|
+
// write data into the local buffer
|
376
|
+
WriteCSVChunkInternal(context.client, bind_data, local_data.cast_chunk, local_data.serializer, input);
|
377
|
+
|
365
378
|
// check if we should flush what we have currently written
|
379
|
+
auto &writer = local_data.serializer;
|
366
380
|
if (writer.blob.size >= csv_data.flush_size) {
|
367
381
|
global_state.WriteData(writer.blob.data.get(), writer.blob.size);
|
368
382
|
writer.Reset();
|
@@ -374,8 +388,8 @@ static void WriteCSVSink(ExecutionContext &context, FunctionData &bind_data, Glo
|
|
374
388
|
//===--------------------------------------------------------------------===//
|
375
389
|
static void WriteCSVCombine(ExecutionContext &context, FunctionData &bind_data, GlobalFunctionData &gstate,
|
376
390
|
LocalFunctionData &lstate) {
|
377
|
-
auto &local_data = (
|
378
|
-
auto &global_state = (
|
391
|
+
auto &local_data = lstate.Cast<LocalWriteCSVData>();
|
392
|
+
auto &global_state = gstate.Cast<GlobalWriteCSVData>();
|
379
393
|
auto &writer = local_data.serializer;
|
380
394
|
// flush the local writer
|
381
395
|
if (writer.blob.size > 0) {
|
@@ -388,21 +402,61 @@ static void WriteCSVCombine(ExecutionContext &context, FunctionData &bind_data,
|
|
388
402
|
// Finalize
|
389
403
|
//===--------------------------------------------------------------------===//
|
390
404
|
void WriteCSVFinalize(ClientContext &context, FunctionData &bind_data, GlobalFunctionData &gstate) {
|
391
|
-
auto &global_state = (
|
405
|
+
auto &global_state = gstate.Cast<GlobalWriteCSVData>();
|
392
406
|
|
393
407
|
global_state.handle->Close();
|
394
408
|
global_state.handle.reset();
|
395
409
|
}
|
396
410
|
|
397
411
|
//===--------------------------------------------------------------------===//
|
398
|
-
//
|
412
|
+
// Execution Mode
|
399
413
|
//===--------------------------------------------------------------------===//
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
414
|
+
CopyFunctionExecutionMode WriteCSVExecutionMode(bool preserve_insertion_order, bool supports_batch_index) {
|
415
|
+
if (!preserve_insertion_order) {
|
416
|
+
return CopyFunctionExecutionMode::PARALLEL_COPY_TO_FILE;
|
417
|
+
}
|
418
|
+
if (supports_batch_index) {
|
419
|
+
return CopyFunctionExecutionMode::BATCH_COPY_TO_FILE;
|
404
420
|
}
|
405
|
-
return
|
421
|
+
return CopyFunctionExecutionMode::REGULAR_COPY_TO_FILE;
|
422
|
+
}
|
423
|
+
//===--------------------------------------------------------------------===//
|
424
|
+
// Prepare Batch
|
425
|
+
//===--------------------------------------------------------------------===//
|
426
|
+
struct WriteCSVBatchData : public PreparedBatchData {
|
427
|
+
//! The thread-local buffer to write data into
|
428
|
+
BufferedSerializer serializer;
|
429
|
+
};
|
430
|
+
|
431
|
+
unique_ptr<PreparedBatchData> WriteCSVPrepareBatch(ClientContext &context, FunctionData &bind_data,
|
432
|
+
GlobalFunctionData &gstate,
|
433
|
+
unique_ptr<ColumnDataCollection> collection) {
|
434
|
+
auto &csv_data = bind_data.Cast<WriteCSVData>();
|
435
|
+
|
436
|
+
// create the cast chunk with VARCHAR types
|
437
|
+
vector<LogicalType> types;
|
438
|
+
types.resize(csv_data.options.name_list.size(), LogicalType::VARCHAR);
|
439
|
+
DataChunk cast_chunk;
|
440
|
+
cast_chunk.Initialize(Allocator::Get(context), types);
|
441
|
+
|
442
|
+
auto batch = make_uniq<WriteCSVBatchData>();
|
443
|
+
// write CSV chunks to the batch data
|
444
|
+
for (auto &chunk : collection->Chunks()) {
|
445
|
+
WriteCSVChunkInternal(context, bind_data, cast_chunk, batch->serializer, chunk);
|
446
|
+
}
|
447
|
+
return std::move(batch);
|
448
|
+
}
|
449
|
+
|
450
|
+
//===--------------------------------------------------------------------===//
|
451
|
+
// Flush Batch
|
452
|
+
//===--------------------------------------------------------------------===//
|
453
|
+
void WriteCSVFlushBatch(ClientContext &context, FunctionData &bind_data, GlobalFunctionData &gstate,
|
454
|
+
PreparedBatchData &batch) {
|
455
|
+
auto &csv_batch = batch.Cast<WriteCSVBatchData>();
|
456
|
+
auto &global_state = gstate.Cast<GlobalWriteCSVData>();
|
457
|
+
auto &writer = csv_batch.serializer;
|
458
|
+
global_state.WriteData(writer.blob.data.get(), writer.blob.size);
|
459
|
+
writer.Reset();
|
406
460
|
}
|
407
461
|
|
408
462
|
void CSVCopyFunction::RegisterFunction(BuiltinFunctions &set) {
|
@@ -413,7 +467,9 @@ void CSVCopyFunction::RegisterFunction(BuiltinFunctions &set) {
|
|
413
467
|
info.copy_to_sink = WriteCSVSink;
|
414
468
|
info.copy_to_combine = WriteCSVCombine;
|
415
469
|
info.copy_to_finalize = WriteCSVFinalize;
|
416
|
-
info.
|
470
|
+
info.execution_mode = WriteCSVExecutionMode;
|
471
|
+
info.prepare_batch = WriteCSVPrepareBatch;
|
472
|
+
info.flush_batch = WriteCSVFlushBatch;
|
417
473
|
|
418
474
|
info.copy_from_bind = ReadCSVBind;
|
419
475
|
info.copy_from_function = ReadCSVTableFunction::GetFunction();
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#include "duckdb/main/client_context.hpp"
|
4
4
|
#include "duckdb/main/database.hpp"
|
5
5
|
#include "duckdb/common/string_util.hpp"
|
6
|
+
#include "duckdb/common/enum_util.hpp"
|
6
7
|
#include "duckdb/common/hive_partitioning.hpp"
|
7
8
|
#include "duckdb/common/union_by_name.hpp"
|
8
9
|
#include "duckdb/main/config.hpp"
|
@@ -59,7 +60,7 @@ uint8_t GetCandidateSpecificity(const LogicalType &candidate_type) {
|
|
59
60
|
auto it = auto_type_candidates_specificity.find(id);
|
60
61
|
if (it == auto_type_candidates_specificity.end()) {
|
61
62
|
throw BinderException("Auto Type Candidate of type %s is not accepted as a valid input",
|
62
|
-
|
63
|
+
EnumUtil::ToString(candidate_type.id()));
|
63
64
|
}
|
64
65
|
return it->second;
|
65
66
|
}
|
@@ -183,6 +184,10 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, TableFunctio
|
|
183
184
|
options.SetReadOption(loption, kv.second, names);
|
184
185
|
}
|
185
186
|
}
|
187
|
+
if (options.file_options.auto_detect_hive_partitioning) {
|
188
|
+
options.file_options.hive_partitioning = MultiFileReaderOptions::AutoDetectHivePartitioning(result->files);
|
189
|
+
}
|
190
|
+
|
186
191
|
if (!options.auto_detect && return_types.empty()) {
|
187
192
|
throw BinderException("read_csv requires columns to be specified through the 'columns' option. Use "
|
188
193
|
"read_csv_auto or set read_csv(..., "
|
@@ -234,6 +239,14 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, TableFunctio
|
|
234
239
|
} else {
|
235
240
|
result->reader_bind = MultiFileReader::BindOptions(options.file_options, result->files, return_types, names);
|
236
241
|
}
|
242
|
+
auto &fs = FileSystem::GetFileSystem(context);
|
243
|
+
for (auto &file : result->files) {
|
244
|
+
if (fs.IsPipe(file)) {
|
245
|
+
result->is_pipe = true;
|
246
|
+
result->single_threaded = true;
|
247
|
+
break;
|
248
|
+
}
|
249
|
+
}
|
237
250
|
result->return_types = return_types;
|
238
251
|
result->return_names = names;
|
239
252
|
result->FinalizeRead(context);
|
@@ -695,8 +708,9 @@ static unique_ptr<GlobalTableFunctionState> SingleThreadedCSVInit(ClientContext
|
|
695
708
|
return std::move(result);
|
696
709
|
} else {
|
697
710
|
bind_data.options.file_path = bind_data.files[0];
|
698
|
-
if (bind_data.initial_reader &&
|
699
|
-
// If this is
|
711
|
+
if (bind_data.initial_reader && bind_data.is_pipe) {
|
712
|
+
// If this is a pipe and an initial reader already exists due to read_csv_auto
|
713
|
+
// We must re-use it, since we can't restart the reader due for it being a pipe.
|
700
714
|
result->initial_reader = std::move(bind_data.initial_reader);
|
701
715
|
} else {
|
702
716
|
result->initial_reader = make_uniq<BufferedCSVReader>(context, bind_data.options, bind_data.csv_types);
|
@@ -793,14 +807,6 @@ static void SingleThreadedCSVFunction(ClientContext &context, TableFunctionInput
|
|
793
807
|
//===--------------------------------------------------------------------===//
|
794
808
|
static unique_ptr<GlobalTableFunctionState> ReadCSVInitGlobal(ClientContext &context, TableFunctionInitInput &input) {
|
795
809
|
auto &bind_data = (ReadCSVData &)*input.bind_data;
|
796
|
-
auto &fs = FileSystem::GetFileSystem(context);
|
797
|
-
for (auto &file : bind_data.files) {
|
798
|
-
if (!fs.FileExists(file)) {
|
799
|
-
bind_data.file_exists = false;
|
800
|
-
break;
|
801
|
-
}
|
802
|
-
}
|
803
|
-
bind_data.single_threaded = bind_data.single_threaded || !bind_data.file_exists;
|
804
810
|
if (bind_data.single_threaded) {
|
805
811
|
return SingleThreadedCSVInit(context, input);
|
806
812
|
} else {
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#include "duckdb/common/types/chunk_collection.hpp"
|
3
3
|
#include "duckdb/main/config.hpp"
|
4
4
|
#include "duckdb/main/client_context.hpp"
|
5
|
+
#include "duckdb/common/enum_util.hpp"
|
5
6
|
|
6
7
|
namespace duckdb {
|
7
8
|
|
@@ -49,7 +50,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBSettingsInit(ClientContext &context,
|
|
49
50
|
value.name = option->name;
|
50
51
|
value.value = option->get_setting(context).ToString();
|
51
52
|
value.description = option->description;
|
52
|
-
value.input_type =
|
53
|
+
value.input_type = EnumUtil::ToString(option->parameter_type);
|
53
54
|
|
54
55
|
result->settings.push_back(std::move(value));
|
55
56
|
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#include "duckdb/catalog/catalog.hpp"
|
4
4
|
#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
|
5
5
|
#include "duckdb/catalog/catalog_entry/type_catalog_entry.hpp"
|
6
|
+
#include "duckdb/common/enum_util.hpp"
|
6
7
|
#include "duckdb/common/exception.hpp"
|
7
8
|
#include "duckdb/main/client_context.hpp"
|
8
9
|
#include "duckdb/main/client_data.hpp"
|
@@ -112,7 +113,7 @@ void DuckDBTypesFunction(ClientContext &context, TableFunctionInput &data_p, Dat
|
|
112
113
|
output.SetValue(col++, count,
|
113
114
|
internal_type == PhysicalType::INVALID ? Value() : Value::BIGINT(GetTypeIdSize(internal_type)));
|
114
115
|
// logical_type, VARCHAR
|
115
|
-
output.SetValue(col++, count, Value(
|
116
|
+
output.SetValue(col++, count, Value(EnumUtil::ToString(type.id())));
|
116
117
|
// type_category, VARCHAR
|
117
118
|
string category;
|
118
119
|
switch (type.id()) {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.7.2-
|
2
|
+
#define DUCKDB_VERSION "0.7.2-dev3117"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "dd0e0da3f0"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|