duckdb 0.9.1-dev143.0 → 0.9.1-dev166.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.9.1-dev143.0",
5
+ "version": "0.9.1-dev166.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "v0.9.1-dev143"
2
+ #define DUCKDB_VERSION "v0.9.1-dev166"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "e2649c46be"
5
+ #define DUCKDB_SOURCE_ID "a20ac9759d"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -43,6 +43,8 @@ private:
43
43
 
44
44
  //! Push down a LogicalAggregate op
45
45
  unique_ptr<LogicalOperator> PushdownAggregate(unique_ptr<LogicalOperator> op);
46
+ //! Push down a distinct operator
47
+ unique_ptr<LogicalOperator> PushdownDistinct(unique_ptr<LogicalOperator> op);
46
48
  //! Push down a LogicalFilter op
47
49
  unique_ptr<LogicalOperator> PushdownFilter(unique_ptr<LogicalOperator> op);
48
50
  //! Push down a LogicalCrossProduct op
@@ -362,6 +362,7 @@ private:
362
362
 
363
363
  //! If only a schema name is provided (e.g. "a.b") then figure out if "a" is a schema or a catalog name
364
364
  void BindSchemaOrCatalog(string &catalog_name, string &schema_name);
365
+ const string BindCatalog(string &catalog_name);
365
366
  SchemaCatalogEntry &BindCreateSchema(CreateInfo &info);
366
367
 
367
368
  unique_ptr<BoundQueryNode> BindSelectNode(SelectNode &statement, unique_ptr<BoundTableRef> from_table);
@@ -33,6 +33,7 @@ unique_ptr<LogicalOperator> FilterPushdown::Rewrite(unique_ptr<LogicalOperator>
33
33
  case LogicalOperatorType::LOGICAL_UNION:
34
34
  return PushdownSetOperation(std::move(op));
35
35
  case LogicalOperatorType::LOGICAL_DISTINCT:
36
+ return PushdownDistinct(std::move(op));
36
37
  case LogicalOperatorType::LOGICAL_ORDER_BY: {
37
38
  // we can just push directly through these operations without any rewriting
38
39
  op->children[0] = Rewrite(std::move(op->children[0]));
@@ -0,0 +1,19 @@
1
+ #include "duckdb/optimizer/filter_pushdown.hpp"
2
+ #include "duckdb/planner/expression_iterator.hpp"
3
+ #include "duckdb/planner/operator/logical_distinct.hpp"
4
+
5
+ namespace duckdb {
6
+
7
+ unique_ptr<LogicalOperator> FilterPushdown::PushdownDistinct(unique_ptr<LogicalOperator> op) {
8
+ D_ASSERT(op->type == LogicalOperatorType::LOGICAL_DISTINCT);
9
+ auto &distinct = op->Cast<LogicalDistinct>();
10
+ if (!distinct.order_by) {
11
+ // regular DISTINCT - can just push down
12
+ op->children[0] = Rewrite(std::move(op->children[0]));
13
+ return op;
14
+ }
15
+ // no pushdown through DISTINCT ON (yet?)
16
+ return FinishPushdown(std::move(op));
17
+ }
18
+
19
+ } // namespace duckdb
@@ -68,6 +68,16 @@ void Binder::BindSchemaOrCatalog(string &catalog, string &schema) {
68
68
  BindSchemaOrCatalog(context, catalog, schema);
69
69
  }
70
70
 
71
+ const string Binder::BindCatalog(string &catalog) {
72
+ auto &db_manager = DatabaseManager::Get(context);
73
+ optional_ptr<AttachedDatabase> database = db_manager.GetDatabase(context, catalog);
74
+ if (database) {
75
+ return db_manager.GetDatabase(context, catalog).get()->GetName();
76
+ } else {
77
+ return db_manager.GetDefaultDatabase(context);
78
+ }
79
+ }
80
+
71
81
  SchemaCatalogEntry &Binder::BindSchema(CreateInfo &info) {
72
82
  BindSchemaOrCatalog(info.catalog, info.schema);
73
83
  if (IsInvalidCatalog(info.catalog) && info.temporary) {
@@ -456,9 +466,13 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
456
466
 
457
467
  auto catalog_type = stmt.info->type;
458
468
  switch (catalog_type) {
459
- case CatalogType::SCHEMA_ENTRY:
469
+ case CatalogType::SCHEMA_ENTRY: {
470
+ auto &base = stmt.info->Cast<CreateInfo>();
471
+ auto catalog = BindCatalog(base.catalog);
472
+ properties.modified_databases.insert(catalog);
460
473
  result.plan = make_uniq<LogicalCreate>(LogicalOperatorType::LOGICAL_CREATE_SCHEMA, std::move(stmt.info));
461
474
  break;
475
+ }
462
476
  case CatalogType::VIEW_ENTRY: {
463
477
  auto &base = stmt.info->Cast<CreateViewInfo>();
464
478
  // bind the schema
@@ -2,6 +2,8 @@
2
2
 
3
3
  #include "src/optimizer/pushdown/pushdown_cross_product.cpp"
4
4
 
5
+ #include "src/optimizer/pushdown/pushdown_distinct.cpp"
6
+
5
7
  #include "src/optimizer/pushdown/pushdown_filter.cpp"
6
8
 
7
9
  #include "src/optimizer/pushdown/pushdown_get.cpp"