duckdb 0.6.2-dev1020.0 → 0.6.2-dev1030.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-dev1020.0",
5
+ "version": "0.6.2-dev1030.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -144,7 +144,6 @@ struct UniqueFunctor {
144
144
 
145
145
  template <class FUNCTION_FUNCTOR, bool IS_AGGR = false>
146
146
  static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vector &result) {
147
-
148
147
  auto count = args.size();
149
148
  Vector &lists = args.data[0];
150
149
 
@@ -167,6 +166,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
167
166
 
168
167
  auto lists_size = ListVector::GetListSize(lists);
169
168
  auto &child_vector = ListVector::GetEntry(lists);
169
+ child_vector.Flatten(lists_size);
170
170
 
171
171
  UnifiedVectorFormat child_data;
172
172
  child_vector.ToUnifiedFormat(lists_size, child_data);
@@ -216,7 +216,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
216
216
  // states vector is full, update
217
217
  if (states_idx == STANDARD_VECTOR_SIZE) {
218
218
  // update the aggregate state(s)
219
- Vector slice = Vector(child_vector, sel_vector, states_idx);
219
+ Vector slice(child_vector, sel_vector, states_idx);
220
220
  aggr.function.update(&slice, aggr_input_data, 1, state_vector_update, states_idx);
221
221
 
222
222
  // reset values
@@ -232,7 +232,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
232
232
 
233
233
  // update the remaining elements of the last list(s)
234
234
  if (states_idx != 0) {
235
- Vector slice = Vector(child_vector, sel_vector, states_idx);
235
+ Vector slice(child_vector, sel_vector, states_idx);
236
236
  aggr.function.update(&slice, aggr_input_data, 1, state_vector_update, states_idx);
237
237
  }
238
238
 
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.6.2-dev1020"
2
+ #define DUCKDB_VERSION "0.6.2-dev1030"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "46f8e0b7ce"
5
+ #define DUCKDB_SOURCE_ID "27846005c0"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -47,7 +47,7 @@ public:
47
47
  // note: original_arguments are optional (can be list of size 0)
48
48
  auto original_arguments = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
49
49
 
50
- auto func_catalog = Catalog::GetEntry(context, type, INVALID_CATALOG, DEFAULT_SCHEMA, name);
50
+ auto func_catalog = Catalog::GetEntry(context, type, SYSTEM_CATALOG, DEFAULT_SCHEMA, name);
51
51
  if (!func_catalog || func_catalog->type != type) {
52
52
  throw InternalException("Cant find catalog entry for function %s", name);
53
53
  }
@@ -5,6 +5,7 @@
5
5
  #include "duckdb/main/client_context.hpp"
6
6
  #include "duckdb/main/database.hpp"
7
7
  #include "duckdb/parser/expression/constant_expression.hpp"
8
+ #include "duckdb/parser/expression/function_expression.hpp"
8
9
  #include "duckdb/parser/expression/subquery_expression.hpp"
9
10
  #include "duckdb/parser/parsed_data/create_index_info.hpp"
10
11
  #include "duckdb/parser/parsed_data/create_macro_info.hpp"
@@ -128,6 +129,33 @@ void Binder::BindCreateViewInfo(CreateViewInfo &base) {
128
129
  base.types = query_node.types;
129
130
  }
130
131
 
132
+ static void QualifyFunctionNames(ClientContext &context, unique_ptr<ParsedExpression> &expr) {
133
+ switch (expr->GetExpressionClass()) {
134
+ case ExpressionClass::FUNCTION: {
135
+ auto &func = (FunctionExpression &)*expr;
136
+ auto function = (StandardEntry *)Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, func.catalog,
137
+ func.schema, func.function_name, true);
138
+ if (function) {
139
+ func.catalog = function->catalog->GetName();
140
+ func.schema = function->schema->name;
141
+ }
142
+ break;
143
+ }
144
+ case ExpressionClass::SUBQUERY: {
145
+ // replacing parameters within a subquery is slightly different
146
+ auto &sq = ((SubqueryExpression &)*expr).subquery;
147
+ ParsedExpressionIterator::EnumerateQueryNodeChildren(
148
+ *sq->node, [&](unique_ptr<ParsedExpression> &child) { QualifyFunctionNames(context, child); });
149
+ break;
150
+ }
151
+ default: // fall through
152
+ break;
153
+ }
154
+ // unfold child expressions
155
+ ParsedExpressionIterator::EnumerateChildren(
156
+ *expr, [&](unique_ptr<ParsedExpression> &child) { QualifyFunctionNames(context, child); });
157
+ }
158
+
131
159
  SchemaCatalogEntry *Binder::BindCreateFunctionInfo(CreateInfo &info) {
132
160
  auto &base = (CreateMacroInfo &)info;
133
161
  auto &scalar_function = (ScalarMacroFunction &)*base.function;
@@ -157,6 +185,7 @@ SchemaCatalogEntry *Binder::BindCreateFunctionInfo(CreateInfo &info) {
157
185
  auto this_macro_binding = make_unique<DummyBinding>(dummy_types, dummy_names, base.name);
158
186
  macro_binding = this_macro_binding.get();
159
187
  ExpressionBinder::QualifyColumnNames(*this, scalar_function.expression);
188
+ QualifyFunctionNames(context, scalar_function.expression);
160
189
 
161
190
  // create a copy of the expression because we do not want to alter the original
162
191
  auto expression = scalar_function.expression->Copy();
@@ -92,6 +92,11 @@ BindResult SelectBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, i
92
92
  "effects. This is not yet supported.",
93
93
  colref.column_names[0]);
94
94
  }
95
+ if (node.select_list[index]->HasSubquery()) {
96
+ throw BinderException("Alias \"%s\" referenced in a SELECT clause - but the expression has a subquery."
97
+ " This is not yet supported.",
98
+ colref.column_names[0]);
99
+ }
95
100
  auto result = BindResult(node.select_list[index]->Copy());
96
101
  if (result.expression->type == ExpressionType::BOUND_COLUMN_REF) {
97
102
  auto &result_expr = (BoundColumnRefExpression &)*result.expression;