duckdb 0.6.2-dev416.0 → 0.6.2-dev447.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-dev416.0",
5
+ "version": "0.6.2-dev447.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -6290,7 +6290,7 @@ static DefaultView internal_views[] = {
6290
6290
  {"pg_catalog", "pg_index", "SELECT index_oid indexrelid, table_oid indrelid, 0 indnatts, 0 indnkeyatts, is_unique indisunique, is_primary indisprimary, false indisexclusion, true indimmediate, false indisclustered, true indisvalid, false indcheckxmin, true indisready, true indislive, false indisreplident, NULL::INT[] indkey, NULL::OID[] indcollation, NULL::OID[] indclass, NULL::INT[] indoption, expressions indexprs, NULL indpred FROM duckdb_indexes()"},
6291
6291
  {"pg_catalog", "pg_indexes", "SELECT schema_name schemaname, table_name tablename, index_name indexname, NULL \"tablespace\", sql indexdef FROM duckdb_indexes()"},
6292
6292
  {"pg_catalog", "pg_namespace", "SELECT oid, schema_name nspname, 0 nspowner, NULL nspacl FROM duckdb_schemas()"},
6293
- {"pg_catalog", "pg_proc", "SELECT f.function_oid oid, function_name proname, s.oid pronamespace FROM duckdb_functions() f LEFT JOIN duckdb_schemas() s USING (schema_name)"},
6293
+ {"pg_catalog", "pg_proc", "SELECT f.function_oid oid, function_name proname, s.oid pronamespace, varargs provariadic, function_type = 'aggregate' proisagg, function_type = 'table' proretset, return_type prorettype, parameter_types proargtypes, parameters proargnames FROM duckdb_functions() f LEFT JOIN duckdb_schemas() s USING (schema_name)"},
6294
6294
  {"pg_catalog", "pg_sequence", "SELECT sequence_oid seqrelid, 0 seqtypid, start_value seqstart, increment_by seqincrement, max_value seqmax, min_value seqmin, 0 seqcache, cycle seqcycle FROM duckdb_sequences()"},
6295
6295
  {"pg_catalog", "pg_sequences", "SELECT schema_name schemaname, sequence_name sequencename, 'duckdb' sequenceowner, 0 data_type, start_value, min_value, max_value, increment_by, cycle, 0 cache_size, last_value FROM duckdb_sequences()"},
6296
6296
  {"pg_catalog", "pg_settings", "SELECT name, value setting, description short_desc, CASE WHEN input_type = 'VARCHAR' THEN 'string' WHEN input_type = 'BOOLEAN' THEN 'bool' WHEN input_type IN ('BIGINT', 'UBIGINT') THEN 'integer' ELSE input_type END vartype FROM duckdb_settings()"},
@@ -8284,56 +8284,6 @@ void DuckDBAssertInternal(bool condition, const char *condition_name, const char
8284
8284
 
8285
8285
 
8286
8286
 
8287
- //===----------------------------------------------------------------------===//
8288
- // DuckDB
8289
- //
8290
- // duckdb/common/profiler.hpp
8291
- //
8292
- //
8293
- //===----------------------------------------------------------------------===//
8294
-
8295
-
8296
-
8297
-
8298
-
8299
-
8300
- namespace duckdb {
8301
-
8302
- //! The profiler can be used to measure elapsed time
8303
- template <typename T>
8304
- class BaseProfiler {
8305
- public:
8306
- //! Starts the timer
8307
- void Start() {
8308
- finished = false;
8309
- start = Tick();
8310
- }
8311
- //! Finishes timing
8312
- void End() {
8313
- end = Tick();
8314
- finished = true;
8315
- }
8316
-
8317
- //! Returns the elapsed time in seconds. If End() has been called, returns
8318
- //! the total elapsed time. Otherwise returns how far along the timer is
8319
- //! right now.
8320
- double Elapsed() const {
8321
- auto _end = finished ? end : Tick();
8322
- return std::chrono::duration_cast<std::chrono::duration<double>>(_end - start).count();
8323
- }
8324
-
8325
- private:
8326
- time_point<T> Tick() const {
8327
- return T::now();
8328
- }
8329
- time_point<T> start;
8330
- time_point<T> end;
8331
- bool finished = false;
8332
- };
8333
-
8334
- using Profiler = BaseProfiler<system_clock>;
8335
-
8336
- } // namespace duckdb
8337
8287
 
8338
8288
 
8339
8289
 
@@ -30246,72 +30196,6 @@ bool PreservedError::operator==(const PreservedError &other) const {
30246
30196
 
30247
30197
  } // namespace duckdb
30248
30198
 
30249
- //===----------------------------------------------------------------------===//
30250
- // DuckDB
30251
- //
30252
- // duckdb/common/progress_bar.hpp
30253
- //
30254
- //
30255
- //===----------------------------------------------------------------------===//
30256
-
30257
-
30258
-
30259
-
30260
-
30261
-
30262
-
30263
-
30264
- namespace duckdb {
30265
-
30266
- class ProgressBar {
30267
- public:
30268
- explicit ProgressBar(Executor &executor, idx_t show_progress_after, bool print_progress);
30269
-
30270
- //! Starts the thread
30271
- void Start();
30272
- //! Updates the progress bar and prints it to the screen
30273
- void Update(bool final);
30274
- //! Gets current percentage
30275
- double GetCurrentPercentage();
30276
-
30277
- private:
30278
- static constexpr const idx_t PARTIAL_BLOCK_COUNT = 8;
30279
- #ifndef DUCKDB_ASCII_TREE_RENDERER
30280
- const char *PROGRESS_EMPTY = " ";
30281
- const char *PROGRESS_PARTIAL[PARTIAL_BLOCK_COUNT] {
30282
- " ", "\xE2\x96\x8F", "\xE2\x96\x8E", "\xE2\x96\x8D", "\xE2\x96\x8C", "\xE2\x96\x8B", "\xE2\x96\x8A",
30283
- "\xE2\x96\x89"};
30284
- const char *PROGRESS_BLOCK = "\xE2\x96\x88";
30285
- const char *PROGRESS_START = "\xE2\x96\x95";
30286
- const char *PROGRESS_END = "\xE2\x96\x8F";
30287
- #else
30288
- const char *PROGRESS_EMPTY = " ";
30289
- const char *PROGRESS_PARTIAL[PARTIAL_BLOCK_COUNT] {" ", " ", " ", " ", " ", " ", " ", " "};
30290
- const char *PROGRESS_BLOCK = "=";
30291
- const char *PROGRESS_START = "[";
30292
- const char *PROGRESS_END = "]";
30293
- #endif
30294
- static constexpr const idx_t PROGRESS_BAR_WIDTH = 60;
30295
-
30296
- void PrintProgressInternal(int percentage);
30297
- void PrintProgress(int percentage);
30298
- void FinishProgressBarPrint();
30299
-
30300
- private:
30301
- //! The executor
30302
- Executor &executor;
30303
- //! The profiler used to measure the time since the progress bar was started
30304
- Profiler profiler;
30305
- //! The time in ms after which to start displaying the progress bar
30306
- idx_t show_progress_after;
30307
- //! The current progress percentage
30308
- double current_percentage;
30309
- //! Whether or not we print the progress bar
30310
- bool print_progress;
30311
- //! Whether or not profiling is supported for the current query
30312
- bool supported = true;
30313
- };
30314
- } // namespace duckdb
30315
30199
 
30316
30200
 
30317
30201
 
@@ -30394,13 +30278,70 @@ idx_t Printer::TerminalWidth() {
30394
30278
  } // namespace duckdb
30395
30279
 
30396
30280
 
30281
+ //===----------------------------------------------------------------------===//
30282
+ // DuckDB
30283
+ //
30284
+ // duckdb/common/progress_bar/display/terminal_progress_bar_display.hpp
30285
+ //
30286
+ //
30287
+ //===----------------------------------------------------------------------===//
30288
+
30289
+
30290
+
30291
+
30397
30292
 
30398
30293
 
30399
30294
  namespace duckdb {
30400
30295
 
30401
- ProgressBar::ProgressBar(Executor &executor, idx_t show_progress_after, bool print_progress)
30402
- : executor(executor), show_progress_after(show_progress_after), current_percentage(-1),
30403
- print_progress(print_progress) {
30296
+ class TerminalProgressBarDisplay : public ProgressBarDisplay {
30297
+ public:
30298
+ TerminalProgressBarDisplay() {
30299
+ }
30300
+ ~TerminalProgressBarDisplay() override final {
30301
+ }
30302
+
30303
+ public:
30304
+ void Update(double percentage) override;
30305
+ void Finish() override;
30306
+
30307
+ private:
30308
+ static constexpr const idx_t PARTIAL_BLOCK_COUNT = 8;
30309
+ #ifndef DUCKDB_ASCII_TREE_RENDERER
30310
+ const char *PROGRESS_EMPTY = " ";
30311
+ const char *PROGRESS_PARTIAL[PARTIAL_BLOCK_COUNT] {
30312
+ " ", "\xE2\x96\x8F", "\xE2\x96\x8E", "\xE2\x96\x8D", "\xE2\x96\x8C", "\xE2\x96\x8B", "\xE2\x96\x8A",
30313
+ "\xE2\x96\x89"};
30314
+ const char *PROGRESS_BLOCK = "\xE2\x96\x88";
30315
+ const char *PROGRESS_START = "\xE2\x96\x95";
30316
+ const char *PROGRESS_END = "\xE2\x96\x8F";
30317
+ #else
30318
+ const char *PROGRESS_EMPTY = " ";
30319
+ const char *PROGRESS_PARTIAL[PARTIAL_BLOCK_COUNT] {" ", " ", " ", " ", " ", " ", " ", " "};
30320
+ const char *PROGRESS_BLOCK = "=";
30321
+ const char *PROGRESS_START = "[";
30322
+ const char *PROGRESS_END = "]";
30323
+ #endif
30324
+ static constexpr const idx_t PROGRESS_BAR_WIDTH = 60;
30325
+
30326
+ private:
30327
+ void PrintProgressInternal(int percentage);
30328
+ };
30329
+
30330
+ } // namespace duckdb
30331
+
30332
+
30333
+ namespace duckdb {
30334
+
30335
+ unique_ptr<ProgressBarDisplay> ProgressBar::DefaultProgressBarDisplay() {
30336
+ return make_unique<TerminalProgressBarDisplay>();
30337
+ }
30338
+
30339
+ ProgressBar::ProgressBar(Executor &executor, idx_t show_progress_after,
30340
+ progress_bar_display_create_func_t create_display_func)
30341
+ : executor(executor), show_progress_after(show_progress_after), current_percentage(-1) {
30342
+ if (create_display_func) {
30343
+ display = create_display_func();
30344
+ }
30404
30345
  }
30405
30346
 
30406
30347
  double ProgressBar::GetCurrentPercentage() {
@@ -30413,20 +30354,44 @@ void ProgressBar::Start() {
30413
30354
  supported = true;
30414
30355
  }
30415
30356
 
30416
- void ProgressBar::Update(bool final) {
30357
+ bool ProgressBar::PrintEnabled() const {
30358
+ return display != nullptr;
30359
+ }
30360
+
30361
+ bool ProgressBar::ShouldPrint(bool final) const {
30362
+ if (!PrintEnabled()) {
30363
+ // Don't print progress at all
30364
+ return false;
30365
+ }
30366
+ // FIXME - do we need to check supported before running `profiler.Elapsed()` ?
30367
+ auto sufficient_time_elapsed = profiler.Elapsed() > show_progress_after / 1000.0;
30368
+ if (!sufficient_time_elapsed) {
30369
+ // Don't print yet
30370
+ return false;
30371
+ }
30372
+ if (final) {
30373
+ // Print the last completed bar
30374
+ return true;
30375
+ }
30417
30376
  if (!supported) {
30377
+ return false;
30378
+ }
30379
+ return current_percentage > -1;
30380
+ }
30381
+
30382
+ void ProgressBar::Update(bool final) {
30383
+ if (!final && !supported) {
30418
30384
  return;
30419
30385
  }
30420
30386
  double new_percentage;
30421
30387
  supported = executor.GetPipelinesProgress(new_percentage);
30422
- if (!supported) {
30388
+ if (!final && !supported) {
30423
30389
  return;
30424
30390
  }
30425
- auto sufficient_time_elapsed = profiler.Elapsed() > show_progress_after / 1000.0;
30426
30391
  if (new_percentage > current_percentage) {
30427
30392
  current_percentage = new_percentage;
30428
30393
  }
30429
- if (supported && print_progress && sufficient_time_elapsed && current_percentage > -1 && print_progress) {
30394
+ if (ShouldPrint(final)) {
30430
30395
  #ifndef DUCKDB_DISABLE_PRINT
30431
30396
  if (final) {
30432
30397
  FinishProgressBarPrint();
@@ -30437,7 +30402,28 @@ void ProgressBar::Update(bool final) {
30437
30402
  }
30438
30403
  }
30439
30404
 
30440
- void ProgressBar::PrintProgressInternal(int percentage) {
30405
+ void ProgressBar::PrintProgress(int current_percentage) {
30406
+ D_ASSERT(display);
30407
+ display->Update(current_percentage);
30408
+ }
30409
+
30410
+ void ProgressBar::FinishProgressBarPrint() {
30411
+ if (finished) {
30412
+ return;
30413
+ }
30414
+ D_ASSERT(display);
30415
+ display->Finish();
30416
+ finished = true;
30417
+ }
30418
+
30419
+ } // namespace duckdb
30420
+
30421
+
30422
+
30423
+
30424
+ namespace duckdb {
30425
+
30426
+ void TerminalProgressBarDisplay::PrintProgressInternal(int percentage) {
30441
30427
  if (percentage > 100) {
30442
30428
  percentage = 100;
30443
30429
  }
@@ -30484,12 +30470,13 @@ void ProgressBar::PrintProgressInternal(int percentage) {
30484
30470
 
30485
30471
  Printer::RawPrint(OutputStream::STREAM_STDOUT, result);
30486
30472
  }
30487
- void ProgressBar::PrintProgress(int percentage) {
30473
+
30474
+ void TerminalProgressBarDisplay::Update(double percentage) {
30488
30475
  PrintProgressInternal(percentage);
30489
30476
  Printer::Flush(OutputStream::STREAM_STDOUT);
30490
30477
  }
30491
30478
 
30492
- void ProgressBar::FinishProgressBarPrint() {
30479
+ void TerminalProgressBarDisplay::Finish() {
30493
30480
  PrintProgressInternal(100);
30494
30481
  Printer::RawPrint(OutputStream::STREAM_STDOUT, "\n");
30495
30482
  Printer::Flush(OutputStream::STREAM_STDOUT);
@@ -136881,7 +136868,13 @@ unique_ptr<PendingQueryResult> ClientContext::PendingPreparedStatement(ClientCon
136881
136868
  active_query->executor = make_unique<Executor>(*this);
136882
136869
  auto &executor = *active_query->executor;
136883
136870
  if (config.enable_progress_bar) {
136884
- active_query->progress_bar = make_unique<ProgressBar>(executor, config.wait_time, config.print_progress_bar);
136871
+ progress_bar_display_create_func_t display_create_func = nullptr;
136872
+ if (config.print_progress_bar) {
136873
+ // If a custom display is set, use that, otherwise just use the default
136874
+ display_create_func =
136875
+ config.display_create_func ? config.display_create_func : ProgressBar::DefaultProgressBarDisplay;
136876
+ }
136877
+ active_query->progress_bar = make_unique<ProgressBar>(executor, config.wait_time, display_create_func);
136885
136878
  active_query->progress_bar->Start();
136886
136879
  query_progress = 0;
136887
136880
  }
@@ -138015,6 +138008,14 @@ struct EnableProgressBarSetting {
138015
138008
  static void SetLocal(ClientContext &context, const Value &parameter);
138016
138009
  static Value GetSetting(ClientContext &context);
138017
138010
  };
138011
+ struct EnableProgressBarPrintSetting {
138012
+ static constexpr const char *Name = "enable_progress_bar_print";
138013
+ static constexpr const char *Description =
138014
+ "Controls the printing of the progress bar, when 'enable_progress_bar' is true";
138015
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
138016
+ static void SetLocal(ClientContext &context, const Value &parameter);
138017
+ static Value GetSetting(ClientContext &context);
138018
+ };
138018
138019
 
138019
138020
  struct ExperimentalParallelCSVSetting {
138020
138021
  static constexpr const char *Name = "experimental_parallel_csv";
@@ -138249,6 +138250,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
138249
138250
  DUCKDB_GLOBAL(EnableHTTPMetadataCacheSetting),
138250
138251
  DUCKDB_LOCAL(EnableProfilingSetting),
138251
138252
  DUCKDB_LOCAL(EnableProgressBarSetting),
138253
+ DUCKDB_LOCAL(EnableProgressBarPrintSetting),
138252
138254
  DUCKDB_GLOBAL(ExperimentalParallelCSVSetting),
138253
138255
  DUCKDB_LOCAL(ExplainOutputSetting),
138254
138256
  DUCKDB_GLOBAL(ExternalThreadsSetting),
@@ -152672,6 +152674,17 @@ Value EnableProgressBarSetting::GetSetting(ClientContext &context) {
152672
152674
  return Value::BOOLEAN(ClientConfig::GetConfig(context).enable_progress_bar);
152673
152675
  }
152674
152676
 
152677
+ //===--------------------------------------------------------------------===//
152678
+ // Enable Progress Bar Print
152679
+ //===--------------------------------------------------------------------===//
152680
+ void EnableProgressBarPrintSetting::SetLocal(ClientContext &context, const Value &input) {
152681
+ ClientConfig::GetConfig(context).print_progress_bar = input.GetValue<bool>();
152682
+ }
152683
+
152684
+ Value EnableProgressBarPrintSetting::GetSetting(ClientContext &context) {
152685
+ return Value::BOOLEAN(ClientConfig::GetConfig(context).print_progress_bar);
152686
+ }
152687
+
152675
152688
  //===--------------------------------------------------------------------===//
152676
152689
  // Experimental Parallel CSV
152677
152690
  //===--------------------------------------------------------------------===//