duckdb 0.5.2-dev466.0 → 0.5.2-dev472.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.5.2-dev466.0",
4
+ "version": "0.5.2-dev472.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -177147,6 +177147,8 @@ struct BoundGroupInformation {
177147
177147
  //! The SELECT binder is responsible for binding an expression within the SELECT clause of a SQL statement
177148
177148
  class SelectBinder : public ExpressionBinder {
177149
177149
  public:
177150
+ SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
177151
+ case_insensitive_map_t<idx_t> alias_map);
177150
177152
  SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info);
177151
177153
 
177152
177154
  bool BoundAggregates() {
@@ -177170,8 +177172,10 @@ protected:
177170
177172
 
177171
177173
  BoundSelectNode &node;
177172
177174
  BoundGroupInformation &info;
177175
+ case_insensitive_map_t<idx_t> alias_map;
177173
177176
 
177174
177177
  protected:
177178
+ BindResult BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth);
177175
177179
  BindResult BindGroupingFunction(OperatorExpression &op, idx_t depth) override;
177176
177180
  BindResult BindWindow(WindowExpression &expr, idx_t depth);
177177
177181
 
@@ -179974,7 +179978,7 @@ unique_ptr<BoundQueryNode> Binder::BindNode(SelectNode &statement) {
179974
179978
  }
179975
179979
 
179976
179980
  // after that, we bind to the SELECT list
179977
- SelectBinder select_binder(*this, context, *result, info);
179981
+ SelectBinder select_binder(*this, context, *result, info, alias_map);
179978
179982
  vector<LogicalType> internal_sql_types;
179979
179983
  for (idx_t i = 0; i < statement.select_list.size(); i++) {
179980
179984
  bool is_window = statement.select_list[i]->IsWindow();
@@ -187875,8 +187879,13 @@ BindResult ReturningBinder::BindExpression(unique_ptr<ParsedExpression> *expr_pt
187875
187879
 
187876
187880
  namespace duckdb {
187877
187881
 
187882
+ SelectBinder::SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
187883
+ case_insensitive_map_t<idx_t> alias_map)
187884
+ : ExpressionBinder(binder, context), inside_window(false), node(node), info(info), alias_map(move(alias_map)) {
187885
+ }
187886
+
187878
187887
  SelectBinder::SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info)
187879
- : ExpressionBinder(binder, context), inside_window(false), node(node), info(info) {
187888
+ : SelectBinder(binder, context, node, info, case_insensitive_map_t<idx_t>()) {
187880
187889
  }
187881
187890
 
187882
187891
  BindResult SelectBinder::BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth, bool root_expression) {
@@ -187887,6 +187896,8 @@ BindResult SelectBinder::BindExpression(unique_ptr<ParsedExpression> *expr_ptr,
187887
187896
  return BindGroup(expr, depth, group_index);
187888
187897
  }
187889
187898
  switch (expr.expression_class) {
187899
+ case ExpressionClass::COLUMN_REF:
187900
+ return BindColumnRef(expr_ptr, depth);
187890
187901
  case ExpressionClass::DEFAULT:
187891
187902
  return BindResult("SELECT clause cannot contain DEFAULT clause");
187892
187903
  case ExpressionClass::WINDOW:
@@ -187923,6 +187934,37 @@ idx_t SelectBinder::TryBindGroup(ParsedExpression &expr, idx_t depth) {
187923
187934
  return DConstants::INVALID_INDEX;
187924
187935
  }
187925
187936
 
187937
+ BindResult SelectBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth) {
187938
+ // first try to bind the column reference regularly
187939
+ auto result = ExpressionBinder::BindExpression(expr_ptr, depth);
187940
+ if (!result.HasError()) {
187941
+ return result;
187942
+ }
187943
+ // binding failed
187944
+ // check in the alias map
187945
+ auto &colref = (ColumnRefExpression &)**expr_ptr;
187946
+ if (!colref.IsQualified()) {
187947
+ auto alias_entry = alias_map.find(colref.column_names[0]);
187948
+ if (alias_entry != alias_map.end()) {
187949
+ // found entry!
187950
+ auto index = alias_entry->second;
187951
+ if (index >= node.select_list.size()) {
187952
+ throw BinderException("Column \"%s\" referenced that exists in the SELECT clause - but this column "
187953
+ "cannot be referenced before it is defined",
187954
+ colref.column_names[0]);
187955
+ }
187956
+ if (node.select_list[index]->HasSideEffects()) {
187957
+ throw BinderException("Alias \"%s\" referenced in a SELECT clause - but the expression has side "
187958
+ "effects. This is not yet supported.",
187959
+ colref.column_names[0]);
187960
+ }
187961
+ return BindResult(node.select_list[index]->Copy());
187962
+ }
187963
+ }
187964
+ // entry was not found in the alias map: return the original error
187965
+ return result;
187966
+ }
187967
+
187926
187968
  BindResult SelectBinder::BindGroupingFunction(OperatorExpression &op, idx_t depth) {
187927
187969
  if (op.children.empty()) {
187928
187970
  throw InternalException("GROUPING requires at least one child");
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 "84b2449fa"
15
- #define DUCKDB_VERSION "v0.5.2-dev466"
14
+ #define DUCKDB_SOURCE_ID "bd8c9a162"
15
+ #define DUCKDB_VERSION "v0.5.2-dev472"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //