duckdb 0.6.2-dev2448.0 → 0.6.2-dev2482.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/include/json_scan.hpp +7 -0
- package/src/duckdb/extension/json/json_functions/read_json.cpp +8 -7
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/main/relation/read_csv_relation.hpp +4 -5
- package/src/duckdb/src/include/duckdb/main/relation/read_json_relation.hpp +23 -0
- package/src/duckdb/src/include/duckdb.h +23 -0
- package/src/duckdb/src/main/capi/data_chunk-c.cpp +20 -1
- package/src/duckdb/src/main/relation/read_csv_relation.cpp +6 -6
- package/src/duckdb/src/main/relation/read_json_relation.cpp +20 -0
- package/src/duckdb/src/main/relation/table_function_relation.cpp +1 -1
- package/src/duckdb/ub_src_main_relation.cpp +2 -0
package/package.json
CHANGED
|
@@ -253,6 +253,13 @@ public:
|
|
|
253
253
|
|
|
254
254
|
struct JSONScan {
|
|
255
255
|
public:
|
|
256
|
+
static void AutoDetect(ClientContext &context, JSONScanData &bind_data, vector<LogicalType> &return_types,
|
|
257
|
+
vector<string> &names);
|
|
258
|
+
|
|
259
|
+
static void InitializeBindData(ClientContext &context, JSONScanData &bind_data,
|
|
260
|
+
const named_parameter_map_t &named_parameters, vector<string> &names,
|
|
261
|
+
vector<LogicalType> &return_types);
|
|
262
|
+
|
|
256
263
|
static double JSONScanProgress(ClientContext &context, const FunctionData *bind_data_p,
|
|
257
264
|
const GlobalTableFunctionState *global_state) {
|
|
258
265
|
auto &gstate = ((JSONGlobalTableFunctionState &)*global_state).state;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
namespace duckdb {
|
|
7
7
|
|
|
8
|
-
void AutoDetect(ClientContext &context, JSONScanData &bind_data, vector<LogicalType> &return_types,
|
|
9
|
-
|
|
8
|
+
void JSONScan::AutoDetect(ClientContext &context, JSONScanData &bind_data, vector<LogicalType> &return_types,
|
|
9
|
+
vector<string> &names) {
|
|
10
10
|
auto original_scan_type = bind_data.type;
|
|
11
11
|
bind_data.type = JSONScanType::SAMPLE; // Set scan type to sample for the auto-detect, we restore it later
|
|
12
12
|
JSONScanGlobalState gstate(context, bind_data);
|
|
@@ -81,9 +81,10 @@ void AutoDetect(ClientContext &context, JSONScanData &bind_data, vector<LogicalT
|
|
|
81
81
|
bind_data.stored_readers = std::move(gstate.json_readers);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
void
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
void JSONScan::InitializeBindData(ClientContext &context, JSONScanData &bind_data,
|
|
85
|
+
const named_parameter_map_t &named_parameters, vector<string> &names,
|
|
86
|
+
vector<LogicalType> &return_types) {
|
|
87
|
+
for (auto &kv : named_parameters) {
|
|
87
88
|
auto loption = StringUtil::Lower(kv.first);
|
|
88
89
|
if (loption == "columns") {
|
|
89
90
|
auto &child_type = kv.second.type();
|
|
@@ -159,7 +160,7 @@ unique_ptr<FunctionData> ReadJSONBind(ClientContext &context, TableFunctionBindI
|
|
|
159
160
|
auto result = JSONScanData::Bind(context, input);
|
|
160
161
|
auto &bind_data = (JSONScanData &)*result;
|
|
161
162
|
|
|
162
|
-
|
|
163
|
+
JSONScan::InitializeBindData(context, bind_data, input.named_parameters, names, return_types);
|
|
163
164
|
|
|
164
165
|
if (!bind_data.names.empty()) {
|
|
165
166
|
bind_data.auto_detect = false; // override auto_detect when columns are specified
|
|
@@ -170,7 +171,7 @@ unique_ptr<FunctionData> ReadJSONBind(ClientContext &context, TableFunctionBindI
|
|
|
170
171
|
bind_data.InitializeFormats();
|
|
171
172
|
|
|
172
173
|
if (bind_data.auto_detect) {
|
|
173
|
-
AutoDetect(context, bind_data, return_types, names);
|
|
174
|
+
JSONScan::AutoDetect(context, bind_data, return_types, names);
|
|
174
175
|
bind_data.names = names;
|
|
175
176
|
}
|
|
176
177
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev2482"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "5a54d814bf"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -17,14 +17,13 @@ struct BufferedCSVReaderOptions;
|
|
|
17
17
|
|
|
18
18
|
class ReadCSVRelation : public TableFunctionRelation {
|
|
19
19
|
public:
|
|
20
|
-
ReadCSVRelation(const std::shared_ptr<ClientContext> &context, string csv_file,
|
|
21
|
-
string alias = string());
|
|
22
|
-
ReadCSVRelation(const std::shared_ptr<ClientContext> &context, string csv_file,
|
|
23
|
-
string alias = string());
|
|
20
|
+
ReadCSVRelation(const std::shared_ptr<ClientContext> &context, const string &csv_file,
|
|
21
|
+
vector<ColumnDefinition> columns, string alias = string());
|
|
22
|
+
ReadCSVRelation(const std::shared_ptr<ClientContext> &context, const string &csv_file,
|
|
23
|
+
BufferedCSVReaderOptions options, string alias = string());
|
|
24
24
|
|
|
25
25
|
string alias;
|
|
26
26
|
bool auto_detect;
|
|
27
|
-
string csv_file;
|
|
28
27
|
|
|
29
28
|
public:
|
|
30
29
|
string GetAlias() override;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "duckdb/main/relation/table_function_relation.hpp"
|
|
4
|
+
#include "duckdb/main/client_context.hpp"
|
|
5
|
+
#include "duckdb/common/named_parameter_map.hpp"
|
|
6
|
+
#include "duckdb/parser/column_definition.hpp"
|
|
7
|
+
#include "duckdb/common/string.hpp"
|
|
8
|
+
#include "duckdb/common/vector.hpp"
|
|
9
|
+
|
|
10
|
+
namespace duckdb {
|
|
11
|
+
|
|
12
|
+
class ReadJSONRelation : public TableFunctionRelation {
|
|
13
|
+
public:
|
|
14
|
+
ReadJSONRelation(const shared_ptr<ClientContext> &context, string json_file, named_parameter_map_t options,
|
|
15
|
+
bool auto_detect, string alias = "");
|
|
16
|
+
string json_file;
|
|
17
|
+
string alias;
|
|
18
|
+
|
|
19
|
+
public:
|
|
20
|
+
string GetAlias() override;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace duckdb
|
|
@@ -192,6 +192,11 @@ typedef struct {
|
|
|
192
192
|
idx_t size;
|
|
193
193
|
} duckdb_blob;
|
|
194
194
|
|
|
195
|
+
typedef struct {
|
|
196
|
+
uint64_t offset;
|
|
197
|
+
uint64_t length;
|
|
198
|
+
} duckdb_list_entry;
|
|
199
|
+
|
|
195
200
|
typedef struct {
|
|
196
201
|
#if DUCKDB_API_VERSION < DUCKDB_API_0_3_2
|
|
197
202
|
void *data;
|
|
@@ -1561,6 +1566,24 @@ Returns the size of the child vector of the list
|
|
|
1561
1566
|
*/
|
|
1562
1567
|
DUCKDB_API idx_t duckdb_list_vector_get_size(duckdb_vector vector);
|
|
1563
1568
|
|
|
1569
|
+
/*!
|
|
1570
|
+
Sets the total size of the underlying child-vector of a list vector.
|
|
1571
|
+
|
|
1572
|
+
* vector: The list vector.
|
|
1573
|
+
* size: The size of the child list.
|
|
1574
|
+
* returns: The duckdb state. Returns DuckDBError if the vector is nullptr.
|
|
1575
|
+
*/
|
|
1576
|
+
DUCKDB_API duckdb_state duckdb_list_vector_set_size(duckdb_vector vector, idx_t size);
|
|
1577
|
+
|
|
1578
|
+
/*!
|
|
1579
|
+
Sets the total capacity of the underlying child-vector of a list.
|
|
1580
|
+
|
|
1581
|
+
* vector: The list vector.
|
|
1582
|
+
* required_capacity: the total capacity to reserve.
|
|
1583
|
+
* return: The duckdb state. Returns DuckDBError if the vector is nullptr.
|
|
1584
|
+
*/
|
|
1585
|
+
DUCKDB_API duckdb_state duckdb_list_vector_reserve(duckdb_vector vector, idx_t required_capacity);
|
|
1586
|
+
|
|
1564
1587
|
/*!
|
|
1565
1588
|
Retrieves the child vector of a struct vector.
|
|
1566
1589
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
#include "duckdb/main/capi/capi_internal.hpp"
|
|
2
1
|
#include "duckdb/common/types/data_chunk.hpp"
|
|
3
2
|
#include "duckdb/common/types/string_type.hpp"
|
|
3
|
+
#include "duckdb/main/capi/capi_internal.hpp"
|
|
4
|
+
|
|
4
5
|
#include <string.h>
|
|
5
6
|
|
|
6
7
|
duckdb_data_chunk duckdb_create_data_chunk(duckdb_logical_type *ctypes, idx_t column_count) {
|
|
@@ -128,6 +129,24 @@ idx_t duckdb_list_vector_get_size(duckdb_vector vector) {
|
|
|
128
129
|
return duckdb::ListVector::GetListSize(*v);
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
duckdb_state duckdb_list_vector_set_size(duckdb_vector vector, idx_t size) {
|
|
133
|
+
if (!vector) {
|
|
134
|
+
return duckdb_state::DuckDBError;
|
|
135
|
+
}
|
|
136
|
+
auto v = (duckdb::Vector *)vector;
|
|
137
|
+
duckdb::ListVector::SetListSize(*v, size);
|
|
138
|
+
return duckdb_state::DuckDBSuccess;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
duckdb_state duckdb_list_vector_reserve(duckdb_vector vector, idx_t required_capacity) {
|
|
142
|
+
if (!vector) {
|
|
143
|
+
return duckdb_state::DuckDBError;
|
|
144
|
+
}
|
|
145
|
+
auto v = (duckdb::Vector *)vector;
|
|
146
|
+
duckdb::ListVector::Reserve(*v, required_capacity);
|
|
147
|
+
return duckdb_state::DuckDBSuccess;
|
|
148
|
+
}
|
|
149
|
+
|
|
131
150
|
duckdb_vector duckdb_struct_vector_get_child(duckdb_vector vector, idx_t index) {
|
|
132
151
|
if (!vector) {
|
|
133
152
|
return nullptr;
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
namespace duckdb {
|
|
14
14
|
|
|
15
|
-
ReadCSVRelation::ReadCSVRelation(const std::shared_ptr<ClientContext> &context, string
|
|
15
|
+
ReadCSVRelation::ReadCSVRelation(const std::shared_ptr<ClientContext> &context, const string &csv_file,
|
|
16
16
|
vector<ColumnDefinition> columns_p, string alias_p)
|
|
17
|
-
: TableFunctionRelation(context, "read_csv", {Value(
|
|
18
|
-
auto_detect(false)
|
|
17
|
+
: TableFunctionRelation(context, "read_csv", {Value(csv_file)}, nullptr, false), alias(std::move(alias_p)),
|
|
18
|
+
auto_detect(false) {
|
|
19
19
|
|
|
20
20
|
if (alias.empty()) {
|
|
21
21
|
alias = StringUtil::Split(csv_file, ".")[0];
|
|
@@ -31,10 +31,10 @@ ReadCSVRelation::ReadCSVRelation(const std::shared_ptr<ClientContext> &context,
|
|
|
31
31
|
AddNamedParameter("columns", Value::STRUCT(std::move(column_names)));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
ReadCSVRelation::ReadCSVRelation(const std::shared_ptr<ClientContext> &context, string
|
|
34
|
+
ReadCSVRelation::ReadCSVRelation(const std::shared_ptr<ClientContext> &context, const string &csv_file,
|
|
35
35
|
BufferedCSVReaderOptions options, string alias_p)
|
|
36
|
-
: TableFunctionRelation(context, "read_csv_auto", {Value(
|
|
37
|
-
auto_detect(true)
|
|
36
|
+
: TableFunctionRelation(context, "read_csv_auto", {Value(csv_file)}, nullptr, false), alias(std::move(alias_p)),
|
|
37
|
+
auto_detect(true) {
|
|
38
38
|
|
|
39
39
|
if (alias.empty()) {
|
|
40
40
|
alias = StringUtil::Split(csv_file, ".")[0];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "duckdb/main/relation/read_json_relation.hpp"
|
|
2
|
+
#include "duckdb/parser/column_definition.hpp"
|
|
3
|
+
namespace duckdb {
|
|
4
|
+
|
|
5
|
+
ReadJSONRelation::ReadJSONRelation(const shared_ptr<ClientContext> &context, string json_file_p,
|
|
6
|
+
named_parameter_map_t options, bool auto_detect, string alias_p)
|
|
7
|
+
: TableFunctionRelation(context, auto_detect ? "read_json_auto" : "read_json", {Value(json_file_p)},
|
|
8
|
+
std::move(options)),
|
|
9
|
+
json_file(std::move(json_file_p)), alias(std::move(alias_p)) {
|
|
10
|
+
|
|
11
|
+
if (alias.empty()) {
|
|
12
|
+
alias = StringUtil::Split(json_file, ".")[0];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
string ReadJSONRelation::GetAlias() {
|
|
17
|
+
return alias;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
} // namespace duckdb
|
|
@@ -22,7 +22,7 @@ TableFunctionRelation::TableFunctionRelation(const std::shared_ptr<ClientContext
|
|
|
22
22
|
: Relation(context, RelationType::TABLE_FUNCTION_RELATION), name(std::move(name_p)),
|
|
23
23
|
parameters(std::move(parameters_p)), named_parameters(std::move(named_parameters)),
|
|
24
24
|
input_relation(std::move(input_relation_p)), auto_initialize(auto_init) {
|
|
25
|
-
|
|
25
|
+
InitializeColumns();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
TableFunctionRelation::TableFunctionRelation(const std::shared_ptr<ClientContext> &context, string name_p,
|