duckdb 0.6.2-dev23.0 → 0.6.2-dev32.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.6.2-dev23.0",
5
+ "version": "0.6.2-dev32.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -5543,6 +5543,7 @@ void CatalogSet::CleanupEntry(CatalogEntry *catalog_entry) {
5543
5543
  // destroy the backed up entry: it is no longer required
5544
5544
  D_ASSERT(catalog_entry->parent);
5545
5545
  if (catalog_entry->parent->type != CatalogType::UPDATED_ENTRY) {
5546
+ lock_guard<mutex> write_lock(catalog.write_lock);
5546
5547
  lock_guard<mutex> lock(catalog_lock);
5547
5548
  if (!catalog_entry->deleted) {
5548
5549
  // delete the entry from the dependency manager, if it is not deleted yet
@@ -131115,6 +131116,10 @@ idx_t TableScanGetBatchIndex(ClientContext &context, const FunctionData *bind_da
131115
131116
  return 0;
131116
131117
  }
131117
131118
 
131119
+ BindInfo TableScanGetBindInfo(const FunctionData *bind_data) {
131120
+ return BindInfo(ScanType::TABLE);
131121
+ }
131122
+
131118
131123
  void TableScanDependency(unordered_set<CatalogEntry *> &entries, const FunctionData *bind_data_p) {
131119
131124
  auto &bind_data = (const TableScanBindData &)*bind_data_p;
131120
131125
  entries.insert(bind_data.table);
@@ -131394,6 +131399,7 @@ TableFunction TableScanFunction::GetFunction() {
131394
131399
  scan_function.to_string = TableScanToString;
131395
131400
  scan_function.table_scan_progress = TableScanProgress;
131396
131401
  scan_function.get_batch_index = TableScanGetBatchIndex;
131402
+ scan_function.get_batch_info = TableScanGetBindInfo;
131397
131403
  scan_function.projection_pushdown = true;
131398
131404
  scan_function.filter_pushdown = true;
131399
131405
  scan_function.filter_prune = true;
@@ -131612,8 +131618,9 @@ TableFunction::TableFunction(string name, vector<LogicalType> arguments, table_f
131612
131618
  : SimpleNamedParameterFunction(move(name), move(arguments)), bind(bind), init_global(init_global),
131613
131619
  init_local(init_local), function(function), in_out_function(nullptr), in_out_function_final(nullptr),
131614
131620
  statistics(nullptr), dependency(nullptr), cardinality(nullptr), pushdown_complex_filter(nullptr),
131615
- to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr), serialize(nullptr),
131616
- deserialize(nullptr), projection_pushdown(false), filter_pushdown(false), filter_prune(false) {
131621
+ to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr), get_batch_info(nullptr),
131622
+ serialize(nullptr), deserialize(nullptr), projection_pushdown(false), filter_pushdown(false),
131623
+ filter_prune(false) {
131617
131624
  }
131618
131625
 
131619
131626
  TableFunction::TableFunction(const vector<LogicalType> &arguments, table_function_t function,
@@ -131625,8 +131632,8 @@ TableFunction::TableFunction()
131625
131632
  : SimpleNamedParameterFunction("", {}), bind(nullptr), init_global(nullptr), init_local(nullptr), function(nullptr),
131626
131633
  in_out_function(nullptr), statistics(nullptr), dependency(nullptr), cardinality(nullptr),
131627
131634
  pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr),
131628
- serialize(nullptr), deserialize(nullptr), projection_pushdown(false), filter_pushdown(false),
131629
- filter_prune(false) {
131635
+ get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr), projection_pushdown(false),
131636
+ filter_pushdown(false), filter_prune(false) {
131630
131637
  }
131631
131638
 
131632
131639
  } // namespace duckdb
@@ -138357,6 +138364,13 @@ shared_ptr<Relation> Connection::ReadCSV(const string &csv_file, const vector<st
138357
138364
  return make_shared<ReadCSVRelation>(context, csv_file, move(column_list));
138358
138365
  }
138359
138366
 
138367
+ shared_ptr<Relation> Connection::ReadParquet(const string &parquet_file, bool binary_as_string) {
138368
+ vector<Value> params;
138369
+ params.emplace_back(parquet_file);
138370
+ named_parameter_map_t named_parameters({{"binary_as_string", Value::BOOLEAN(binary_as_string)}});
138371
+ return TableFunction("parquet_scan", params, named_parameters)->Alias(parquet_file);
138372
+ }
138373
+
138360
138374
  unordered_set<string> Connection::GetTableNames(const string &query) {
138361
138375
  return context->GetTableNames(query);
138362
138376
  }
@@ -224936,6 +224950,12 @@ void CommitState::CommitEntry(UndoFlags type, data_ptr_t data) {
224936
224950
  // set the commit timestamp of the catalog entry to the given id
224937
224951
  auto catalog_entry = Load<CatalogEntry *>(data);
224938
224952
  D_ASSERT(catalog_entry->parent);
224953
+
224954
+ auto &catalog = catalog_entry->catalog;
224955
+ D_ASSERT(catalog);
224956
+
224957
+ // Grab a write lock on the catalog
224958
+ lock_guard<mutex> write_lock(catalog->write_lock);
224939
224959
  catalog_entry->set->UpdateTimestamp(catalog_entry->parent, commit_id);
224940
224960
  if (catalog_entry->name != catalog_entry->parent->name) {
224941
224961
  catalog_entry->set->UpdateTimestamp(catalog_entry, commit_id);
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 "6f67ea9ef0"
15
- #define DUCKDB_VERSION "v0.6.2-dev23"
14
+ #define DUCKDB_SOURCE_ID "d7a5a682c4"
15
+ #define DUCKDB_VERSION "v0.6.2-dev32"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -13911,6 +13911,44 @@ public:
13911
13911
  GlobalTableFunctionState *global_state;
13912
13912
  };
13913
13913
 
13914
+ enum ScanType { TABLE, PARQUET };
13915
+
13916
+ struct BindInfo {
13917
+ public:
13918
+ explicit BindInfo(ScanType type_p) : type(type_p) {};
13919
+ unordered_map<string, Value> options;
13920
+ ScanType type;
13921
+ void InsertOption(string name, Value value) {
13922
+ if (options.find(name) != options.end()) {
13923
+ throw InternalException("This option already exists");
13924
+ }
13925
+ options[name] = value;
13926
+ }
13927
+ template <class T>
13928
+ T GetOption(string name) {
13929
+ if (options.find(name) == options.end()) {
13930
+ throw InternalException("This option does not exist");
13931
+ }
13932
+ return options[name].GetValue<T>();
13933
+ }
13934
+ template <class T>
13935
+ vector<T> GetOptionList(string name) {
13936
+ if (options.find(name) == options.end()) {
13937
+ throw InternalException("This option does not exist");
13938
+ }
13939
+ auto option = options[name];
13940
+ if (option.type().id() != LogicalTypeId::LIST) {
13941
+ throw InternalException("This option is not a list");
13942
+ }
13943
+ vector<T> result;
13944
+ auto list_children = ListValue::GetChildren(option);
13945
+ for (auto &child : list_children) {
13946
+ result.emplace_back(child.GetValue<T>());
13947
+ }
13948
+ return result;
13949
+ }
13950
+ };
13951
+
13914
13952
  typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, TableFunctionBindInput &input,
13915
13953
  vector<LogicalType> &return_types, vector<string> &names);
13916
13954
  typedef unique_ptr<GlobalTableFunctionState> (*table_function_init_global_t)(ClientContext &context,
@@ -13929,6 +13967,9 @@ typedef OperatorFinalizeResultType (*table_in_out_function_final_t)(ExecutionCon
13929
13967
  typedef idx_t (*table_function_get_batch_index_t)(ClientContext &context, const FunctionData *bind_data,
13930
13968
  LocalTableFunctionState *local_state,
13931
13969
  GlobalTableFunctionState *global_state);
13970
+
13971
+ typedef BindInfo (*table_function_get_bind_info)(const FunctionData *bind_data);
13972
+
13932
13973
  typedef double (*table_function_progress_t)(ClientContext &context, const FunctionData *bind_data,
13933
13974
  const GlobalTableFunctionState *global_state);
13934
13975
  typedef void (*table_function_dependency_t)(unordered_set<CatalogEntry *> &dependencies, const FunctionData *bind_data);
@@ -13992,6 +14033,8 @@ public:
13992
14033
  table_function_progress_t table_scan_progress;
13993
14034
  //! (Optional) returns the current batch index of the current scan operator
13994
14035
  table_function_get_batch_index_t get_batch_index;
14036
+ //! (Optional) returns the extra batch info, currently only used for the substrait extension
14037
+ table_function_get_bind_info get_batch_info;
13995
14038
 
13996
14039
  table_function_serialize_t serialize;
13997
14040
  table_function_deserialize_t deserialize;
@@ -16641,6 +16684,9 @@ public:
16641
16684
  //! Reads CSV file
16642
16685
  DUCKDB_API shared_ptr<Relation> ReadCSV(const string &csv_file);
16643
16686
  DUCKDB_API shared_ptr<Relation> ReadCSV(const string &csv_file, const vector<string> &columns);
16687
+
16688
+ //! Reads Parquet file
16689
+ DUCKDB_API shared_ptr<Relation> ReadParquet(const string &parquet_file, bool binary_as_string);
16644
16690
  //! Returns a relation from a query
16645
16691
  DUCKDB_API shared_ptr<Relation> RelationFromQuery(const string &query, const string &alias = "queryrelation",
16646
16692
  const string &error = "Expected a single SELECT statement");