duckdb 0.3.3-dev933.0 → 0.3.3-dev948.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.cpp +56 -15
- package/src/duckdb.hpp +18 -3
- package/src/parquet-amalgamation.cpp +30417 -30417
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -4710,11 +4710,13 @@ data_ptr_t Allocator::ReallocateData(data_ptr_t pointer, idx_t size) {
|
|
|
4710
4710
|
namespace duckdb {
|
|
4711
4711
|
class ResultArrowArrayStreamWrapper {
|
|
4712
4712
|
public:
|
|
4713
|
-
explicit ResultArrowArrayStreamWrapper(unique_ptr<QueryResult> result, idx_t
|
|
4713
|
+
explicit ResultArrowArrayStreamWrapper(unique_ptr<QueryResult> result, idx_t batch_size);
|
|
4714
4714
|
ArrowArrayStream stream;
|
|
4715
4715
|
unique_ptr<QueryResult> result;
|
|
4716
4716
|
std::string last_error;
|
|
4717
|
-
idx_t
|
|
4717
|
+
idx_t batch_size;
|
|
4718
|
+
vector<LogicalType> column_types;
|
|
4719
|
+
vector<string> column_names;
|
|
4718
4720
|
|
|
4719
4721
|
private:
|
|
4720
4722
|
static int MyStreamGetSchema(struct ArrowArrayStream *stream, struct ArrowSchema *out);
|
|
@@ -4724,6 +4726,7 @@ private:
|
|
|
4724
4726
|
};
|
|
4725
4727
|
} // namespace duckdb
|
|
4726
4728
|
|
|
4729
|
+
|
|
4727
4730
|
namespace duckdb {
|
|
4728
4731
|
|
|
4729
4732
|
ArrowSchemaWrapper::~ArrowSchemaWrapper() {
|
|
@@ -4792,6 +4795,11 @@ int ResultArrowArrayStreamWrapper::MyStreamGetSchema(struct ArrowArrayStream *st
|
|
|
4792
4795
|
return -1;
|
|
4793
4796
|
}
|
|
4794
4797
|
auto my_stream = (ResultArrowArrayStreamWrapper *)stream->private_data;
|
|
4798
|
+
if (!my_stream->column_types.empty()) {
|
|
4799
|
+
QueryResult::ToArrowSchema(out, my_stream->column_types, my_stream->column_names);
|
|
4800
|
+
return 0;
|
|
4801
|
+
}
|
|
4802
|
+
|
|
4795
4803
|
auto &result = *my_stream->result;
|
|
4796
4804
|
if (!result.success) {
|
|
4797
4805
|
my_stream->last_error = "Query Failed";
|
|
@@ -4804,7 +4812,11 @@ int ResultArrowArrayStreamWrapper::MyStreamGetSchema(struct ArrowArrayStream *st
|
|
|
4804
4812
|
return -1;
|
|
4805
4813
|
}
|
|
4806
4814
|
}
|
|
4807
|
-
|
|
4815
|
+
if (my_stream->column_types.empty()) {
|
|
4816
|
+
my_stream->column_types = result.types;
|
|
4817
|
+
my_stream->column_names = result.names;
|
|
4818
|
+
}
|
|
4819
|
+
QueryResult::ToArrowSchema(out, my_stream->column_types, my_stream->column_names);
|
|
4808
4820
|
return 0;
|
|
4809
4821
|
}
|
|
4810
4822
|
|
|
@@ -4826,13 +4838,17 @@ int ResultArrowArrayStreamWrapper::MyStreamGetNext(struct ArrowArrayStream *stre
|
|
|
4826
4838
|
return 0;
|
|
4827
4839
|
}
|
|
4828
4840
|
}
|
|
4841
|
+
if (my_stream->column_types.empty()) {
|
|
4842
|
+
my_stream->column_types = result.types;
|
|
4843
|
+
my_stream->column_names = result.names;
|
|
4844
|
+
}
|
|
4829
4845
|
unique_ptr<DataChunk> chunk_result = result.Fetch();
|
|
4830
4846
|
if (!chunk_result) {
|
|
4831
4847
|
// Nothing to output
|
|
4832
4848
|
out->release = nullptr;
|
|
4833
4849
|
return 0;
|
|
4834
4850
|
}
|
|
4835
|
-
|
|
4851
|
+
while (chunk_result->size() < my_stream->batch_size) {
|
|
4836
4852
|
auto new_chunk = result.Fetch();
|
|
4837
4853
|
if (!new_chunk) {
|
|
4838
4854
|
break;
|
|
@@ -4860,15 +4876,15 @@ const char *ResultArrowArrayStreamWrapper::MyStreamGetLastError(struct ArrowArra
|
|
|
4860
4876
|
auto my_stream = (ResultArrowArrayStreamWrapper *)stream->private_data;
|
|
4861
4877
|
return my_stream->last_error.c_str();
|
|
4862
4878
|
}
|
|
4863
|
-
ResultArrowArrayStreamWrapper::ResultArrowArrayStreamWrapper(unique_ptr<QueryResult> result_p, idx_t
|
|
4879
|
+
ResultArrowArrayStreamWrapper::ResultArrowArrayStreamWrapper(unique_ptr<QueryResult> result_p, idx_t batch_size_p)
|
|
4864
4880
|
: result(move(result_p)) {
|
|
4865
4881
|
//! We first initialize the private data of the stream
|
|
4866
4882
|
stream.private_data = this;
|
|
4867
4883
|
//! Ceil Approx_Batch_Size/STANDARD_VECTOR_SIZE
|
|
4868
|
-
if (
|
|
4884
|
+
if (batch_size_p == 0) {
|
|
4869
4885
|
throw std::runtime_error("Approximate Batch Size of Record Batch MUST be higher than 0");
|
|
4870
4886
|
}
|
|
4871
|
-
|
|
4887
|
+
batch_size = batch_size_p;
|
|
4872
4888
|
//! We initialize the stream functions
|
|
4873
4889
|
stream.get_schema = ResultArrowArrayStreamWrapper::MyStreamGetSchema;
|
|
4874
4890
|
stream.get_next = ResultArrowArrayStreamWrapper::MyStreamGetNext;
|
|
@@ -4876,6 +4892,30 @@ ResultArrowArrayStreamWrapper::ResultArrowArrayStreamWrapper(unique_ptr<QueryRes
|
|
|
4876
4892
|
stream.get_last_error = ResultArrowArrayStreamWrapper::MyStreamGetLastError;
|
|
4877
4893
|
}
|
|
4878
4894
|
|
|
4895
|
+
unique_ptr<DataChunk> ArrowUtil::FetchNext(QueryResult &result) {
|
|
4896
|
+
auto chunk = result.Fetch();
|
|
4897
|
+
if (!result.success) {
|
|
4898
|
+
throw std::runtime_error(result.error);
|
|
4899
|
+
}
|
|
4900
|
+
return chunk;
|
|
4901
|
+
}
|
|
4902
|
+
|
|
4903
|
+
unique_ptr<DataChunk> ArrowUtil::FetchChunk(QueryResult *result, idx_t chunk_size) {
|
|
4904
|
+
|
|
4905
|
+
auto data_chunk = FetchNext(*result);
|
|
4906
|
+
if (!data_chunk) {
|
|
4907
|
+
return data_chunk;
|
|
4908
|
+
}
|
|
4909
|
+
while (data_chunk->size() < chunk_size) {
|
|
4910
|
+
auto next_chunk = FetchNext(*result);
|
|
4911
|
+
if (!next_chunk || next_chunk->size() == 0) {
|
|
4912
|
+
break;
|
|
4913
|
+
}
|
|
4914
|
+
data_chunk->Append(*next_chunk, true);
|
|
4915
|
+
}
|
|
4916
|
+
return data_chunk;
|
|
4917
|
+
}
|
|
4918
|
+
|
|
4879
4919
|
} // namespace duckdb
|
|
4880
4920
|
|
|
4881
4921
|
|
|
@@ -101378,7 +101418,7 @@ duckdb_state duckdb_query_arrow_schema(duckdb_arrow result, duckdb_arrow_schema
|
|
|
101378
101418
|
return DuckDBSuccess;
|
|
101379
101419
|
}
|
|
101380
101420
|
auto wrapper = (ArrowResultWrapper *)result;
|
|
101381
|
-
|
|
101421
|
+
QueryResult::ToArrowSchema((ArrowSchema *)*out_schema, wrapper->result->types, wrapper->result->names);
|
|
101382
101422
|
return DuckDBSuccess;
|
|
101383
101423
|
}
|
|
101384
101424
|
|
|
@@ -115359,20 +115399,21 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
|
|
|
115359
115399
|
}
|
|
115360
115400
|
}
|
|
115361
115401
|
|
|
115362
|
-
void QueryResult::ToArrowSchema(ArrowSchema *out_schema) {
|
|
115402
|
+
void QueryResult::ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names) {
|
|
115363
115403
|
D_ASSERT(out_schema);
|
|
115364
|
-
|
|
115404
|
+
D_ASSERT(types.size() == names.size());
|
|
115405
|
+
idx_t column_count = types.size();
|
|
115365
115406
|
// Allocate as unique_ptr first to cleanup properly on error
|
|
115366
115407
|
auto root_holder = make_unique<DuckDBArrowSchemaHolder>();
|
|
115367
115408
|
|
|
115368
115409
|
// Allocate the children
|
|
115369
|
-
root_holder->children.resize(
|
|
115370
|
-
root_holder->children_ptrs.resize(
|
|
115371
|
-
for (size_t i = 0; i <
|
|
115410
|
+
root_holder->children.resize(column_count);
|
|
115411
|
+
root_holder->children_ptrs.resize(column_count, nullptr);
|
|
115412
|
+
for (size_t i = 0; i < column_count; ++i) {
|
|
115372
115413
|
root_holder->children_ptrs[i] = &root_holder->children[i];
|
|
115373
115414
|
}
|
|
115374
115415
|
out_schema->children = root_holder->children_ptrs.data();
|
|
115375
|
-
out_schema->n_children =
|
|
115416
|
+
out_schema->n_children = column_count;
|
|
115376
115417
|
|
|
115377
115418
|
// Store the schema
|
|
115378
115419
|
out_schema->format = "+s"; // struct apparently
|
|
@@ -115382,7 +115423,7 @@ void QueryResult::ToArrowSchema(ArrowSchema *out_schema) {
|
|
|
115382
115423
|
out_schema->dictionary = nullptr;
|
|
115383
115424
|
|
|
115384
115425
|
// Configure all child schemas
|
|
115385
|
-
for (idx_t col_idx = 0; col_idx <
|
|
115426
|
+
for (idx_t col_idx = 0; col_idx < column_count; col_idx++) {
|
|
115386
115427
|
|
|
115387
115428
|
auto &child = root_holder->children[col_idx];
|
|
115388
115429
|
InitializeChild(child, names[col_idx]);
|
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.3-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "41e7c6bd4"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev948"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -4014,6 +4014,9 @@ struct ArrowArrayStream {
|
|
|
4014
4014
|
|
|
4015
4015
|
//! Here we have the internal duckdb classes that interact with Arrow's Internal Header (i.e., duckdb/commons/arrow.hpp)
|
|
4016
4016
|
namespace duckdb {
|
|
4017
|
+
class QueryResult;
|
|
4018
|
+
class DataChunk;
|
|
4019
|
+
|
|
4017
4020
|
class ArrowSchemaWrapper {
|
|
4018
4021
|
public:
|
|
4019
4022
|
ArrowSchema arrow_schema;
|
|
@@ -4049,6 +4052,14 @@ public:
|
|
|
4049
4052
|
arrow_array_stream.release = nullptr;
|
|
4050
4053
|
}
|
|
4051
4054
|
};
|
|
4055
|
+
|
|
4056
|
+
class ArrowUtil {
|
|
4057
|
+
public:
|
|
4058
|
+
static unique_ptr<DataChunk> FetchChunk(QueryResult *result, idx_t chunk_size);
|
|
4059
|
+
|
|
4060
|
+
private:
|
|
4061
|
+
static unique_ptr<DataChunk> FetchNext(QueryResult &result);
|
|
4062
|
+
};
|
|
4052
4063
|
} // namespace duckdb
|
|
4053
4064
|
|
|
4054
4065
|
|
|
@@ -9760,7 +9771,7 @@ public:
|
|
|
9760
9771
|
}
|
|
9761
9772
|
}
|
|
9762
9773
|
|
|
9763
|
-
DUCKDB_API void ToArrowSchema(ArrowSchema *
|
|
9774
|
+
DUCKDB_API static void ToArrowSchema(ArrowSchema *out_schema, vector<LogicalType> &types, vector<string> &names);
|
|
9764
9775
|
|
|
9765
9776
|
private:
|
|
9766
9777
|
//! The current chunk used by the iterator
|
|
@@ -16507,6 +16518,8 @@ class LogicalOperator;
|
|
|
16507
16518
|
class QueryNode;
|
|
16508
16519
|
class TableRef;
|
|
16509
16520
|
|
|
16521
|
+
class ExtraDependencies {};
|
|
16522
|
+
|
|
16510
16523
|
class Relation : public std::enable_shared_from_this<Relation> {
|
|
16511
16524
|
public:
|
|
16512
16525
|
DUCKDB_API Relation(const std::shared_ptr<ClientContext> &context, RelationType type)
|
|
@@ -16521,6 +16534,8 @@ public:
|
|
|
16521
16534
|
|
|
16522
16535
|
RelationType type;
|
|
16523
16536
|
|
|
16537
|
+
unique_ptr<ExtraDependencies> extra_dependencies;
|
|
16538
|
+
|
|
16524
16539
|
public:
|
|
16525
16540
|
DUCKDB_API virtual const vector<ColumnDefinition> &Columns() = 0;
|
|
16526
16541
|
DUCKDB_API virtual unique_ptr<QueryNode> GetQueryNode();
|