duckdb 0.7.2-dev333.0 → 0.7.2-dev457.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.
Files changed (81) hide show
  1. package/binding.gyp +1 -0
  2. package/lib/duckdb.d.ts +42 -0
  3. package/package.json +1 -1
  4. package/src/connection.cpp +1 -2
  5. package/src/database.cpp +1 -1
  6. package/src/duckdb/extension/icu/icu-extension.cpp +2 -0
  7. package/src/duckdb/extension/icu/icu-list-range.cpp +207 -0
  8. package/src/duckdb/extension/icu/include/icu-list-range.hpp +17 -0
  9. package/src/duckdb/extension/json/json_functions/read_json.cpp +6 -5
  10. package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +0 -1
  11. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +8 -6
  12. package/src/duckdb/src/common/exception.cpp +15 -1
  13. package/src/duckdb/src/common/preserved_error.cpp +7 -5
  14. package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +20 -5
  15. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +9 -1
  16. package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +5 -8
  17. package/src/duckdb/src/execution/physical_plan/plan_positional_join.cpp +14 -5
  18. package/src/duckdb/src/function/aggregate/distributive/bool.cpp +2 -0
  19. package/src/duckdb/src/function/aggregate/distributive/count.cpp +1 -0
  20. package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +2 -0
  21. package/src/duckdb/src/function/aggregate/distributive/sum.cpp +8 -0
  22. package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +15 -0
  23. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +42 -11
  24. package/src/duckdb/src/function/cast/time_casts.cpp +2 -2
  25. package/src/duckdb/src/function/function_binder.cpp +1 -8
  26. package/src/duckdb/src/function/scalar/date/current.cpp +0 -2
  27. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  28. package/src/duckdb/src/include/duckdb/common/exception.hpp +38 -2
  29. package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +3 -1
  30. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +0 -3
  31. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +6 -3
  32. package/src/duckdb/src/include/duckdb/function/function_binder.hpp +3 -6
  33. package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +2 -0
  34. package/src/duckdb/src/include/duckdb/main/relation/explain_relation.hpp +2 -1
  35. package/src/duckdb/src/include/duckdb/main/relation.hpp +2 -1
  36. package/src/duckdb/src/include/duckdb/optimizer/rule/list.hpp +1 -0
  37. package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +24 -0
  38. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +2 -2
  39. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +2 -2
  40. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
  41. package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -3
  42. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +3 -0
  43. package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +3 -0
  44. package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +4 -1
  45. package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +3 -0
  46. package/src/duckdb/src/main/extension/extension_install.cpp +2 -2
  47. package/src/duckdb/src/main/prepared_statement.cpp +4 -0
  48. package/src/duckdb/src/main/relation/explain_relation.cpp +3 -3
  49. package/src/duckdb/src/main/relation.cpp +3 -2
  50. package/src/duckdb/src/optimizer/optimizer.cpp +1 -0
  51. package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +30 -0
  52. package/src/duckdb/src/parser/expression/star_expression.cpp +6 -6
  53. package/src/duckdb/src/parser/parsed_expression_iterator.cpp +7 -1
  54. package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +17 -2
  55. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +45 -40
  56. package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +7 -0
  57. package/src/duckdb/src/parser/transform/helpers/transform_orderby.cpp +0 -7
  58. package/src/duckdb/src/planner/bind_context.cpp +2 -25
  59. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +6 -4
  60. package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +3 -2
  61. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +176 -0
  62. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +57 -82
  63. package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +11 -0
  64. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  65. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
  66. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  67. package/src/duckdb/src/planner/binder.cpp +12 -23
  68. package/src/duckdb/src/planner/bound_result_modifier.cpp +26 -0
  69. package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +9 -2
  70. package/src/duckdb/src/planner/expression_iterator.cpp +5 -0
  71. package/src/duckdb/src/planner/logical_operator_visitor.cpp +5 -0
  72. package/src/duckdb/src/planner/operator/logical_distinct.cpp +3 -0
  73. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  74. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -1
  75. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +8141 -8313
  76. package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
  77. package/src/duckdb/ub_src_planner_binder_expression.cpp +2 -0
  78. package/src/duckdb_node.hpp +2 -1
  79. package/src/statement.cpp +5 -5
  80. package/src/utils.cpp +15 -2
  81. package/test/syntax_error.test.ts +3 -1
@@ -24,5 +24,7 @@
24
24
 
25
25
  #include "src/optimizer/rule/in_clause_simplification_rule.cpp"
26
26
 
27
+ #include "src/optimizer/rule/ordered_aggregate_optimizer.cpp"
28
+
27
29
  #include "src/optimizer/rule/regex_optimizations.cpp"
28
30
 
@@ -28,6 +28,8 @@
28
28
 
29
29
  #include "src/planner/binder/expression/bind_positional_reference_expression.cpp"
30
30
 
31
+ #include "src/planner/binder/expression/bind_star_expression.cpp"
32
+
31
33
  #include "src/planner/binder/expression/bind_subquery_expression.cpp"
32
34
 
33
35
  #include "src/planner/binder/expression/bind_unnest_expression.cpp"
@@ -198,7 +198,8 @@ struct TaskHolder {
198
198
 
199
199
  class Utils {
200
200
  public:
201
- static Napi::Value CreateError(Napi::Env env, std::string msg);
201
+ static Napi::Object CreateError(Napi::Env env, duckdb::PreservedError &e);
202
+ static Napi::Object CreateError(Napi::Env env, std::string msg);
202
203
  static bool OtherIsInt(Napi::Number source);
203
204
 
204
205
  template <class T>
package/src/statement.cpp CHANGED
@@ -78,7 +78,7 @@ struct PrepareTask : public Task {
78
78
 
79
79
  auto cb = callback.Value();
80
80
  if (statement.statement->HasError()) {
81
- cb.MakeCallback(statement.Value(), {Utils::CreateError(env, statement.statement->error.Message())});
81
+ cb.MakeCallback(statement.Value(), {Utils::CreateError(env, statement.statement->error)});
82
82
  return;
83
83
  }
84
84
  cb.MakeCallback(statement.Value(), {env.Null(), statement.Value()});
@@ -282,11 +282,11 @@ struct RunPreparedTask : public Task {
282
282
  return;
283
283
  }
284
284
  if (statement.statement->HasError()) {
285
- cb.MakeCallback(statement.Value(), {Utils::CreateError(env, statement.statement->GetError())});
285
+ cb.MakeCallback(statement.Value(), {Utils::CreateError(env, statement.statement->GetErrorObject())});
286
286
  return;
287
287
  }
288
288
  if (result->HasError()) {
289
- cb.MakeCallback(statement.Value(), {Utils::CreateError(env, result->GetError())});
289
+ cb.MakeCallback(statement.Value(), {Utils::CreateError(env, result->GetErrorObject())});
290
290
  return;
291
291
  }
292
292
 
@@ -427,9 +427,9 @@ struct RunQueryTask : public Task {
427
427
  if (!statement.statement) {
428
428
  deferred.Reject(Utils::CreateError(env, "statement was finalized"));
429
429
  } else if (statement.statement->HasError()) {
430
- deferred.Reject(Utils::CreateError(env, statement.statement->GetError()));
430
+ deferred.Reject(Utils::CreateError(env, statement.statement->GetErrorObject()));
431
431
  } else if (result->HasError()) {
432
- deferred.Reject(Utils::CreateError(env, result->GetError()));
432
+ deferred.Reject(Utils::CreateError(env, result->GetErrorObject()));
433
433
  } else {
434
434
  auto db = statement.connection_ref->database_ref->Value();
435
435
  auto query_result = QueryResult::constructor.New({db});
package/src/utils.cpp CHANGED
@@ -12,11 +12,24 @@ bool Utils::OtherIsInt(Napi::Number source) {
12
12
  }
13
13
  }
14
14
 
15
- Napi::Value Utils::CreateError(Napi::Env env, std::string msg) {
15
+ static void SetString(Napi::Object &obj, const std::string &key, const std::string &value) {
16
+ obj.Set(Napi::String::New(obj.Env(), key), Napi::String::New(obj.Env(), value));
17
+ }
18
+
19
+ Napi::Object Utils::CreateError(Napi::Env env, duckdb::PreservedError &error) {
20
+ auto obj = Utils::CreateError(env, error.Message());
21
+
22
+ SetString(obj, "errorType", duckdb::Exception::ExceptionTypeToString(error.Type()));
23
+
24
+ return obj;
25
+ }
26
+
27
+ Napi::Object Utils::CreateError(Napi::Env env, std::string msg) {
16
28
  auto err = Napi::Error::New(env, Napi::String::New(env, msg).Utf8Value()).Value();
17
29
  Napi::Object obj = err.As<Napi::Object>();
18
30
  obj.Set(Napi::String::New(env, "errno"), Napi::Number::New(env, Database::DUCKDB_NODEJS_ERROR));
19
- obj.Set(Napi::String::New(env, "code"), Napi::String::New(env, "DUCKDB_NODEJS_ERROR"));
31
+ SetString(obj, "code", "DUCKDB_NODEJS_ERROR");
32
+ SetString(obj, "errorType", "Invalid");
20
33
 
21
34
  return obj;
22
35
  }
@@ -8,8 +8,10 @@ describe('exec', function() {
8
8
  });
9
9
 
10
10
  it("doesn't crash on a syntax error", function(done) {
11
- db.exec("syntax error", function(err: null | Error) {
11
+ db.exec("syntax error", function(err: null | duckdb.DuckDbError) {
12
12
  assert.notEqual(err, null, "Expected an error")
13
+ assert.equal(err?.errorType, 'Parser');
14
+ assert.ok(err?.message.startsWith('Parser Error: syntax error at or near "syntax"'))
13
15
  done();
14
16
  });
15
17
  });