duckdb 0.7.2-dev3353.0 → 0.7.2-dev3402.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/extension/json/buffered_json_reader.cpp +2 -3
- package/src/duckdb/extension/json/include/json_functions.hpp +5 -1
- package/src/duckdb/extension/json/include/json_scan.hpp +1 -0
- package/src/duckdb/extension/json/include/json_transform.hpp +2 -2
- package/src/duckdb/extension/json/json-extension.cpp +7 -3
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +16 -5
- package/src/duckdb/extension/json/json_functions/json_create.cpp +220 -93
- package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +283 -117
- package/src/duckdb/extension/json/json_functions/read_json.cpp +8 -6
- package/src/duckdb/extension/json/json_functions.cpp +17 -15
- package/src/duckdb/extension/json/json_scan.cpp +8 -4
- package/src/duckdb/extension/parquet/column_reader.cpp +6 -2
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +1 -2
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +2 -2
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +1 -0
- package/src/duckdb/extension/parquet/include/thrift_tools.hpp +3 -5
- package/src/duckdb/extension/parquet/parquet-extension.cpp +2 -4
- package/src/duckdb/extension/parquet/parquet_reader.cpp +11 -22
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +5 -0
- package/src/duckdb/extension/parquet/parquet_writer.cpp +4 -4
- package/src/duckdb/src/common/file_system.cpp +13 -20
- package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +2 -2
- package/src/duckdb/src/execution/index/art/art.cpp +3 -1
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +0 -1
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +1 -2
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +4 -5
- package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +1 -1
- package/src/duckdb/src/function/cast/cast_function_set.cpp +89 -25
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +20 -15
- package/src/duckdb/src/function/table/copy_csv.cpp +4 -5
- package/src/duckdb/src/function/table/read_csv.cpp +6 -5
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/file_opener.hpp +0 -1
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +7 -6
- package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +118 -0
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -2
- package/src/duckdb/src/include/duckdb/common/types/type_map.hpp +19 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_line_info.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +5 -5
- package/src/duckdb/src/main/client_context.cpp +0 -4
- package/src/duckdb/src/main/client_data.cpp +19 -0
- package/src/duckdb/src/main/database.cpp +4 -1
- package/src/duckdb/src/main/extension/extension_install.cpp +5 -6
- package/src/duckdb/src/main/extension/extension_load.cpp +11 -16
- package/src/duckdb/src/main/settings/settings.cpp +2 -3
package/package.json
CHANGED
@@ -162,9 +162,8 @@ BufferedJSONReader::BufferedJSONReader(ClientContext &context, BufferedJSONReade
|
|
162
162
|
void BufferedJSONReader::OpenJSONFile() {
|
163
163
|
lock_guard<mutex> guard(lock);
|
164
164
|
auto &file_system = FileSystem::GetFileSystem(context);
|
165
|
-
auto
|
166
|
-
|
167
|
-
FileLockType::NO_LOCK, options.compression, file_opener);
|
165
|
+
auto regular_file_handle =
|
166
|
+
file_system.OpenFile(file_path.c_str(), FileFlags::FILE_FLAGS_READ, FileLockType::NO_LOCK, options.compression);
|
168
167
|
file_handle = make_uniq<JSONFileHandle>(std::move(regular_file_handle), BufferAllocator::Get(context));
|
169
168
|
}
|
170
169
|
|
@@ -17,6 +17,7 @@ class TableRef;
|
|
17
17
|
struct ReplacementScanData;
|
18
18
|
class CastFunctionSet;
|
19
19
|
struct CastParameters;
|
20
|
+
struct CastLocalStateParameters;
|
20
21
|
struct JSONScanInfo;
|
21
22
|
class BuiltinFunctions;
|
22
23
|
|
@@ -56,6 +57,7 @@ public:
|
|
56
57
|
explicit JSONFunctionLocalState(ClientContext &context);
|
57
58
|
static unique_ptr<FunctionLocalState> Init(ExpressionState &state, const BoundFunctionExpression &expr,
|
58
59
|
FunctionData *bind_data);
|
60
|
+
static unique_ptr<FunctionLocalState> InitCastLocalState(CastLocalStateParameters ¶meters);
|
59
61
|
static JSONFunctionLocalState &ResetAndGet(ExpressionState &state);
|
60
62
|
|
61
63
|
public:
|
@@ -71,7 +73,9 @@ public:
|
|
71
73
|
ReplacementScanData *data);
|
72
74
|
static TableFunction GetReadJSONTableFunction(shared_ptr<JSONScanInfo> function_info);
|
73
75
|
static CopyFunction GetJSONCopyFunction();
|
74
|
-
static void
|
76
|
+
static void RegisterSimpleCastFunctions(CastFunctionSet &casts);
|
77
|
+
static void RegisterJSONCreateCastFunctions(CastFunctionSet &casts);
|
78
|
+
static void RegisterJSONTransformCastFunctions(CastFunctionSet &casts);
|
75
79
|
|
76
80
|
private:
|
77
81
|
// Scalar functions
|
@@ -87,6 +87,7 @@ public:
|
|
87
87
|
|
88
88
|
static unique_ptr<FunctionData> Bind(ClientContext &context, TableFunctionBindInput &input);
|
89
89
|
void InitializeFormats();
|
90
|
+
void InitializeFormats(bool auto_detect);
|
90
91
|
|
91
92
|
void Serialize(FieldWriter &writer);
|
92
93
|
void Deserialize(FieldReader &reader);
|
@@ -32,8 +32,8 @@ public:
|
|
32
32
|
//! Throws an error if an object has a key we didn't know about
|
33
33
|
bool error_unknown_key = false;
|
34
34
|
|
35
|
-
//!
|
36
|
-
bool
|
35
|
+
//! Whether to delay the error when transforming (e.g., when non-strict casting or reading from file)
|
36
|
+
bool delay_error = false;
|
37
37
|
//! Date format used for parsing (can be NULL)
|
38
38
|
DateFormatMap *date_format_map = nullptr;
|
39
39
|
//! String to store errors in
|
@@ -3,12 +3,14 @@
|
|
3
3
|
|
4
4
|
#include "duckdb/catalog/catalog_entry/macro_catalog_entry.hpp"
|
5
5
|
#include "duckdb/catalog/default/default_functions.hpp"
|
6
|
-
#include "duckdb/main/extension_util.hpp"
|
7
6
|
#include "duckdb/common/string_util.hpp"
|
7
|
+
#include "duckdb/function/copy_function.hpp"
|
8
|
+
#include "duckdb/main/extension_util.hpp"
|
8
9
|
#include "duckdb/parser/expression/constant_expression.hpp"
|
9
10
|
#include "duckdb/parser/expression/function_expression.hpp"
|
11
|
+
#include "duckdb/parser/parsed_data/create_pragma_function_info.hpp"
|
12
|
+
#include "duckdb/parser/parsed_data/create_type_info.hpp"
|
10
13
|
#include "duckdb/parser/tableref/table_function_ref.hpp"
|
11
|
-
#include "duckdb/function/copy_function.hpp"
|
12
14
|
#include "json_common.hpp"
|
13
15
|
#include "json_functions.hpp"
|
14
16
|
|
@@ -28,7 +30,9 @@ void JSONExtension::Load(DuckDB &db) {
|
|
28
30
|
ExtensionUtil::RegisterType(db_instance, JSONCommon::JSON_TYPE_NAME, std::move(json_type));
|
29
31
|
|
30
32
|
// JSON casts
|
31
|
-
JSONFunctions::
|
33
|
+
JSONFunctions::RegisterSimpleCastFunctions(DBConfig::GetConfig(db_instance).GetCastFunctions());
|
34
|
+
JSONFunctions::RegisterJSONCreateCastFunctions(DBConfig::GetConfig(db_instance).GetCastFunctions());
|
35
|
+
JSONFunctions::RegisterJSONTransformCastFunctions(DBConfig::GetConfig(db_instance).GetCastFunctions());
|
32
36
|
|
33
37
|
// JSON scalar functions
|
34
38
|
for (auto &fun : JSONFunctions::GetScalarFunctions()) {
|
@@ -98,10 +98,21 @@ static duckdb::unique_ptr<FunctionData> CopyFromJSONBind(ClientContext &context,
|
|
98
98
|
bind_data->timestamp_format = StringValue::Get(it->second.back());
|
99
99
|
}
|
100
100
|
|
101
|
-
bind_data->InitializeFormats();
|
102
|
-
|
103
101
|
bind_data->transform_options = JSONTransformOptions(true, true, true, true);
|
104
|
-
bind_data->transform_options.
|
102
|
+
bind_data->transform_options.delay_error = true;
|
103
|
+
|
104
|
+
it = info.options.find("auto_detect");
|
105
|
+
if (it != info.options.end()) {
|
106
|
+
// Wrap this with auto detect true/false so we can detect date/timestamp formats
|
107
|
+
// Note that auto_detect for names/types is not actually true because these are already know when we COPY
|
108
|
+
bind_data->InitializeFormats(true);
|
109
|
+
bind_data->options.format = JSONFormat::AUTO_DETECT;
|
110
|
+
bind_data->record_type = JSONRecordType::AUTO;
|
111
|
+
JSONScan::AutoDetect(context, *bind_data, expected_types, expected_names);
|
112
|
+
bind_data->auto_detect = true;
|
113
|
+
} else {
|
114
|
+
bind_data->InitializeFormats();
|
115
|
+
}
|
105
116
|
|
106
117
|
return std::move(bind_data);
|
107
118
|
}
|
@@ -113,8 +124,8 @@ CopyFunction JSONFunctions::GetJSONCopyFunction() {
|
|
113
124
|
function.plan = CopyToJSONPlan;
|
114
125
|
|
115
126
|
function.copy_from_bind = CopyFromJSONBind;
|
116
|
-
function.copy_from_function = JSONFunctions::GetReadJSONTableFunction(
|
117
|
-
|
127
|
+
function.copy_from_function = JSONFunctions::GetReadJSONTableFunction(make_shared<JSONScanInfo>(
|
128
|
+
JSONScanType::READ_JSON, JSONFormat::NEWLINE_DELIMITED, JSONRecordType::RECORDS, false));
|
118
129
|
|
119
130
|
return function;
|
120
131
|
}
|