duckdb 0.3.5-dev651.0 → 0.3.5-dev653.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.5-dev651.0",
4
+ "version": "0.3.5-dev653.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -25201,8 +25201,9 @@ bool Printer::IsTerminal() {
25201
25201
 
25202
25202
  namespace duckdb {
25203
25203
 
25204
- ProgressBar::ProgressBar(Executor &executor, idx_t show_progress_after)
25205
- : executor(executor), show_progress_after(show_progress_after), current_percentage(-1) {
25204
+ ProgressBar::ProgressBar(Executor &executor, idx_t show_progress_after, bool print_progress)
25205
+ : executor(executor), show_progress_after(show_progress_after), current_percentage(-1),
25206
+ print_progress(print_progress) {
25206
25207
  }
25207
25208
 
25208
25209
  double ProgressBar::GetCurrentPercentage() {
@@ -25225,7 +25226,6 @@ void ProgressBar::Update(bool final) {
25225
25226
  return;
25226
25227
  }
25227
25228
  auto sufficient_time_elapsed = profiler.Elapsed() > show_progress_after / 1000.0;
25228
- auto print_progress = ClientConfig::GetConfig(executor.context).print_progress_bar;
25229
25229
  if (new_percentage > current_percentage) {
25230
25230
  current_percentage = new_percentage;
25231
25231
  }
@@ -65634,6 +65634,8 @@ public:
65634
65634
  bool SupportsBatchIndex() const override {
65635
65635
  return function.supports_batch_index;
65636
65636
  }
65637
+
65638
+ double GetProgress(ClientContext &context, GlobalSourceState &gstate) const override;
65637
65639
  };
65638
65640
 
65639
65641
  } // namespace duckdb
@@ -72390,6 +72392,14 @@ void PhysicalTableScan::GetData(ExecutionContext &context, DataChunk &chunk, Glo
72390
72392
  }
72391
72393
  }
72392
72394
 
72395
+ double PhysicalTableScan::GetProgress(ClientContext &context, GlobalSourceState &gstate_p) const {
72396
+ if (function.table_scan_progress) {
72397
+ return function.table_scan_progress(context, bind_data.get());
72398
+ }
72399
+ // if table_scan_progress is not implemented we don't support this function yet in the progress bar
72400
+ return -1;
72401
+ }
72402
+
72393
72403
  idx_t PhysicalTableScan::GetBatchIndex(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
72394
72404
  LocalSourceState &lstate) const {
72395
72405
  D_ASSERT(SupportsBatchIndex());
@@ -74027,6 +74037,10 @@ idx_t PhysicalOperator::GetBatchIndex(ExecutionContext &context, DataChunk &chun
74027
74037
  LocalSourceState &lstate) const {
74028
74038
  throw InternalException("Calling GetBatchIndex on a node that does not support it");
74029
74039
  }
74040
+
74041
+ double PhysicalOperator::GetProgress(ClientContext &context, GlobalSourceState &gstate) const {
74042
+ return -1;
74043
+ }
74030
74044
  // LCOV_EXCL_STOP
74031
74045
 
74032
74046
  //===--------------------------------------------------------------------===//
@@ -114395,7 +114409,7 @@ unique_ptr<PendingQueryResult> ClientContext::PendingPreparedStatement(ClientCon
114395
114409
  active_query->executor = make_unique<Executor>(*this);
114396
114410
  auto &executor = *active_query->executor;
114397
114411
  if (config.enable_progress_bar) {
114398
- active_query->progress_bar = make_unique<ProgressBar>(executor, config.wait_time);
114412
+ active_query->progress_bar = make_unique<ProgressBar>(executor, config.wait_time, config.print_progress_bar);
114399
114413
  active_query->progress_bar->Start();
114400
114414
  query_progress = 0;
114401
114415
  }
@@ -139428,12 +139442,24 @@ void Executor::Flush(ThreadContext &tcontext) {
139428
139442
  bool Executor::GetPipelinesProgress(double &current_progress) { // LCOV_EXCL_START
139429
139443
  lock_guard<mutex> elock(executor_lock);
139430
139444
 
139431
- if (!pipelines.empty()) {
139432
- return pipelines.back()->GetProgress(current_progress);
139433
- } else {
139434
- current_progress = -1;
139435
- return true;
139445
+ vector<double> progress;
139446
+ vector<idx_t> cardinality;
139447
+ idx_t total_cardinality = 0;
139448
+ for (auto &pipeline : pipelines) {
139449
+ double child_percentage;
139450
+ idx_t child_cardinality;
139451
+ if (!pipeline->GetProgress(child_percentage, child_cardinality)) {
139452
+ return false;
139453
+ }
139454
+ progress.push_back(child_percentage);
139455
+ cardinality.push_back(child_cardinality);
139456
+ total_cardinality += child_cardinality;
139436
139457
  }
139458
+ current_progress = 0;
139459
+ for (size_t i = 0; i < progress.size(); i++) {
139460
+ current_progress += progress[i] * double(cardinality[i]) / double(total_cardinality);
139461
+ }
139462
+ return true;
139437
139463
  } // LCOV_EXCL_STOP
139438
139464
 
139439
139465
  bool Executor::HasResultCollector() {
@@ -139553,50 +139579,13 @@ ClientContext &Pipeline::GetClientContext() {
139553
139579
  return executor.context;
139554
139580
  }
139555
139581
 
139556
- // LCOV_EXCL_START
139557
- bool Pipeline::GetProgressInternal(ClientContext &context, PhysicalOperator *op, double &current_percentage) {
139558
- current_percentage = -1;
139559
- switch (op->type) {
139560
- case PhysicalOperatorType::TABLE_SCAN: {
139561
- auto &get = (PhysicalTableScan &)*op;
139562
- if (get.function.table_scan_progress) {
139563
- current_percentage = get.function.table_scan_progress(context, get.bind_data.get());
139564
- return true;
139565
- }
139566
- // If the table_scan_progress is not implemented it means we don't support this function yet in the progress
139567
- // bar
139568
- return false;
139569
- }
139570
- // If it is not a table scan we go down on all children until we reach the leaf operators
139571
- default: {
139572
- vector<idx_t> progress;
139573
- vector<idx_t> cardinality;
139574
- double total_cardinality = 0;
139575
- current_percentage = 0;
139576
- for (auto &op_child : op->children) {
139577
- double child_percentage = 0;
139578
- if (!GetProgressInternal(context, op_child.get(), child_percentage)) {
139579
- return false;
139580
- }
139581
- if (!Value::DoubleIsFinite(child_percentage)) {
139582
- return false;
139583
- }
139584
- progress.push_back(child_percentage);
139585
- cardinality.push_back(op_child->estimated_cardinality);
139586
- total_cardinality += op_child->estimated_cardinality;
139587
- }
139588
- for (size_t i = 0; i < progress.size(); i++) {
139589
- current_percentage += progress[i] * cardinality[i] / total_cardinality;
139590
- }
139591
- return true;
139592
- }
139593
- }
139594
- }
139595
- // LCOV_EXCL_STOP
139582
+ bool Pipeline::GetProgress(double &current_percentage, idx_t &source_cardinality) {
139583
+ D_ASSERT(source);
139596
139584
 
139597
- bool Pipeline::GetProgress(double &current_percentage) {
139598
139585
  auto &client = executor.context;
139599
- return GetProgressInternal(client, source, current_percentage);
139586
+ current_percentage = source->GetProgress(client, *source_state);
139587
+ source_cardinality = source->estimated_cardinality;
139588
+ return current_percentage >= 0;
139600
139589
  }
139601
139590
 
139602
139591
  void Pipeline::ScheduleSequentialTask(shared_ptr<Event> &event) {
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 "a25b6e307"
15
- #define DUCKDB_VERSION "v0.3.5-dev651"
14
+ #define DUCKDB_SOURCE_ID "ac159c167"
15
+ #define DUCKDB_VERSION "v0.3.5-dev653"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -10410,6 +10410,9 @@ public:
10410
10410
  return false;
10411
10411
  }
10412
10412
 
10413
+ //! Returns the current progress percentage, or a negative value if progress bars are not supported
10414
+ virtual double GetProgress(ClientContext &context, GlobalSourceState &gstate) const;
10415
+
10413
10416
  public:
10414
10417
  // Sink interface
10415
10418
 
@@ -10851,7 +10854,7 @@ public:
10851
10854
  void Print() const;
10852
10855
 
10853
10856
  //! Returns query progress
10854
- bool GetProgress(double &current_percentage);
10857
+ bool GetProgress(double &current_percentage, idx_t &estimated_cardinality);
10855
10858
 
10856
10859
  //! Returns a list of all operators (including source and sink) involved in this pipeline
10857
10860
  vector<PhysicalOperator *> GetOperators() const;
@@ -10885,7 +10888,6 @@ private:
10885
10888
  idx_t base_batch_index = 0;
10886
10889
 
10887
10890
  private:
10888
- bool GetProgressInternal(ClientContext &context, PhysicalOperator *op, double &current_percentage);
10889
10891
  void ScheduleSequentialTask(shared_ptr<Event> &event);
10890
10892
  bool LaunchScanTasks(shared_ptr<Event> &event, idx_t max_threads);
10891
10893
 
@@ -17168,7 +17170,7 @@ namespace duckdb {
17168
17170
 
17169
17171
  class ProgressBar {
17170
17172
  public:
17171
- explicit ProgressBar(Executor &executor, idx_t show_progress_after);
17173
+ explicit ProgressBar(Executor &executor, idx_t show_progress_after, bool print_progress);
17172
17174
 
17173
17175
  //! Starts the thread
17174
17176
  void Start();
@@ -17190,6 +17192,8 @@ private:
17190
17192
  idx_t show_progress_after;
17191
17193
  //! The current progress percentage
17192
17194
  double current_percentage;
17195
+ //! Whether or not we print the progress bar
17196
+ bool print_progress;
17193
17197
  //! Whether or not profiling is supported for the current query
17194
17198
  bool supported = true;
17195
17199
  };