duckdb 0.6.1-dev83.0 → 0.6.1-dev86.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/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 "dfae126ebb"
15
- #define DUCKDB_VERSION "v0.6.1-dev83"
14
+ #define DUCKDB_SOURCE_ID "0c8bafb821"
15
+ #define DUCKDB_VERSION "v0.6.1-dev86"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -30902,10 +30902,12 @@ public:
30902
30902
  }
30903
30903
  };
30904
30904
  } // namespace duckdb
30905
+
30906
+
30905
30907
  //===----------------------------------------------------------------------===//
30906
30908
  // DuckDB
30907
30909
  //
30908
- // duckdb/parser/expression/positional_reference_expression.hpp
30910
+ // duckdb/parser/expression/case_expression.hpp
30909
30911
  //
30910
30912
  //
30911
30913
  //===----------------------------------------------------------------------===//
@@ -30914,32 +30916,51 @@ public:
30914
30916
 
30915
30917
 
30916
30918
 
30919
+
30917
30920
  namespace duckdb {
30918
- class PositionalReferenceExpression : public ParsedExpression {
30919
- public:
30920
- DUCKDB_API PositionalReferenceExpression(idx_t index);
30921
30921
 
30922
- idx_t index;
30922
+ struct CaseCheck {
30923
+ unique_ptr<ParsedExpression> when_expr;
30924
+ unique_ptr<ParsedExpression> then_expr;
30925
+ };
30923
30926
 
30927
+ //! The CaseExpression represents a CASE expression in the query
30928
+ class CaseExpression : public ParsedExpression {
30924
30929
  public:
30925
- bool IsScalar() const override {
30926
- return false;
30927
- }
30930
+ DUCKDB_API CaseExpression();
30931
+
30932
+ vector<CaseCheck> case_checks;
30933
+ unique_ptr<ParsedExpression> else_expr;
30928
30934
 
30935
+ public:
30929
30936
  string ToString() const override;
30930
30937
 
30931
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
30938
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
30939
+
30932
30940
  unique_ptr<ParsedExpression> Copy() const override;
30933
- hash_t Hash() const override;
30934
30941
 
30935
30942
  void Serialize(FieldWriter &writer) const override;
30936
30943
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30944
+
30945
+ public:
30946
+ template <class T, class BASE>
30947
+ static string ToString(const T &entry) {
30948
+ string case_str = "CASE ";
30949
+ for (auto &check : entry.case_checks) {
30950
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
30951
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
30952
+ }
30953
+ case_str += " ELSE " + entry.else_expr->ToString();
30954
+ case_str += " END";
30955
+ return case_str;
30956
+ }
30937
30957
  };
30938
30958
  } // namespace duckdb
30959
+
30939
30960
  //===----------------------------------------------------------------------===//
30940
30961
  // DuckDB
30941
30962
  //
30942
- // duckdb/parser/expression/case_expression.hpp
30963
+ // duckdb/parser/expression/cast_expression.hpp
30943
30964
  //
30944
30965
  //
30945
30966
  //===----------------------------------------------------------------------===//
@@ -30951,23 +30972,22 @@ public:
30951
30972
 
30952
30973
  namespace duckdb {
30953
30974
 
30954
- struct CaseCheck {
30955
- unique_ptr<ParsedExpression> when_expr;
30956
- unique_ptr<ParsedExpression> then_expr;
30957
- };
30958
-
30959
- //! The CaseExpression represents a CASE expression in the query
30960
- class CaseExpression : public ParsedExpression {
30975
+ //! CastExpression represents a type cast from one SQL type to another SQL type
30976
+ class CastExpression : public ParsedExpression {
30961
30977
  public:
30962
- DUCKDB_API CaseExpression();
30978
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
30963
30979
 
30964
- vector<CaseCheck> case_checks;
30965
- unique_ptr<ParsedExpression> else_expr;
30980
+ //! The child of the cast expression
30981
+ unique_ptr<ParsedExpression> child;
30982
+ //! The type to cast to
30983
+ LogicalType cast_type;
30984
+ //! Whether or not this is a try_cast expression
30985
+ bool try_cast;
30966
30986
 
30967
30987
  public:
30968
30988
  string ToString() const override;
30969
30989
 
30970
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
30990
+ static bool Equals(const CastExpression *a, const CastExpression *b);
30971
30991
 
30972
30992
  unique_ptr<ParsedExpression> Copy() const override;
30973
30993
 
@@ -30977,17 +30997,49 @@ public:
30977
30997
  public:
30978
30998
  template <class T, class BASE>
30979
30999
  static string ToString(const T &entry) {
30980
- string case_str = "CASE ";
30981
- for (auto &check : entry.case_checks) {
30982
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
30983
- case_str += " THEN (" + check.then_expr->ToString() + ")";
30984
- }
30985
- case_str += " ELSE " + entry.else_expr->ToString();
30986
- case_str += " END";
30987
- return case_str;
31000
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
31001
+ entry.cast_type.ToString() + ")";
30988
31002
  }
30989
31003
  };
30990
31004
  } // namespace duckdb
31005
+
31006
+ //===----------------------------------------------------------------------===//
31007
+ // DuckDB
31008
+ //
31009
+ // duckdb/parser/expression/collate_expression.hpp
31010
+ //
31011
+ //
31012
+ //===----------------------------------------------------------------------===//
31013
+
31014
+
31015
+
31016
+
31017
+
31018
+ namespace duckdb {
31019
+
31020
+ //! CollateExpression represents a COLLATE statement
31021
+ class CollateExpression : public ParsedExpression {
31022
+ public:
31023
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
31024
+
31025
+ //! The child of the cast expression
31026
+ unique_ptr<ParsedExpression> child;
31027
+ //! The collation clause
31028
+ string collation;
31029
+
31030
+ public:
31031
+ string ToString() const override;
31032
+
31033
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
31034
+
31035
+ unique_ptr<ParsedExpression> Copy() const override;
31036
+
31037
+ void Serialize(FieldWriter &writer) const override;
31038
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31039
+ };
31040
+ } // namespace duckdb
31041
+
31042
+
30991
31043
  //===----------------------------------------------------------------------===//
30992
31044
  // DuckDB
30993
31045
  //
@@ -31029,10 +31081,11 @@ public:
31029
31081
  }
31030
31082
  };
31031
31083
  } // namespace duckdb
31084
+
31032
31085
  //===----------------------------------------------------------------------===//
31033
31086
  // DuckDB
31034
31087
  //
31035
- // duckdb/parser/expression/constant_expression.hpp
31088
+ // duckdb/parser/expression/conjunction_expression.hpp
31036
31089
  //
31037
31090
  //
31038
31091
  //===----------------------------------------------------------------------===//
@@ -31044,31 +31097,44 @@ public:
31044
31097
 
31045
31098
  namespace duckdb {
31046
31099
 
31047
- //! ConstantExpression represents a constant value in the query
31048
- class ConstantExpression : public ParsedExpression {
31100
+ //! Represents a conjunction (AND/OR)
31101
+ class ConjunctionExpression : public ParsedExpression {
31049
31102
  public:
31050
- DUCKDB_API explicit ConstantExpression(Value val);
31103
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
31104
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
31105
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
31106
+ unique_ptr<ParsedExpression> right);
31051
31107
 
31052
- //! The constant value referenced
31053
- Value value;
31108
+ vector<unique_ptr<ParsedExpression>> children;
31054
31109
 
31055
31110
  public:
31111
+ void AddExpression(unique_ptr<ParsedExpression> expr);
31112
+
31056
31113
  string ToString() const override;
31057
31114
 
31058
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
31059
- hash_t Hash() const override;
31115
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
31060
31116
 
31061
31117
  unique_ptr<ParsedExpression> Copy() const override;
31062
31118
 
31063
31119
  void Serialize(FieldWriter &writer) const override;
31064
31120
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31065
- };
31066
31121
 
31122
+ public:
31123
+ template <class T, class BASE>
31124
+ static string ToString(const T &entry) {
31125
+ string result = "(" + entry.children[0]->ToString();
31126
+ for (idx_t i = 1; i < entry.children.size(); i++) {
31127
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
31128
+ }
31129
+ return result + ")";
31130
+ }
31131
+ };
31067
31132
  } // namespace duckdb
31133
+
31068
31134
  //===----------------------------------------------------------------------===//
31069
31135
  // DuckDB
31070
31136
  //
31071
- // duckdb/parser/expression/star_expression.hpp
31137
+ // duckdb/parser/expression/constant_expression.hpp
31072
31138
  //
31073
31139
  //
31074
31140
  //===----------------------------------------------------------------------===//
@@ -31080,33 +31146,28 @@ public:
31080
31146
 
31081
31147
  namespace duckdb {
31082
31148
 
31083
- //! Represents a * expression in the SELECT clause
31084
- class StarExpression : public ParsedExpression {
31149
+ //! ConstantExpression represents a constant value in the query
31150
+ class ConstantExpression : public ParsedExpression {
31085
31151
  public:
31086
- StarExpression(string relation_name = string());
31152
+ DUCKDB_API explicit ConstantExpression(Value val);
31087
31153
 
31088
- //! The relation name in case of tbl.*, or empty if this is a normal *
31089
- string relation_name;
31090
- //! List of columns to exclude from the STAR expression
31091
- case_insensitive_set_t exclude_list;
31092
- //! List of columns to replace with another expression
31093
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
31094
- //! Regular expression to select columns (if any)
31095
- string regex;
31096
- //! Whether or not this is a COLUMNS expression
31097
- bool columns = false;
31154
+ //! The constant value referenced
31155
+ Value value;
31098
31156
 
31099
31157
  public:
31100
31158
  string ToString() const override;
31101
31159
 
31102
- static bool Equals(const StarExpression *a, const StarExpression *b);
31160
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
31161
+ hash_t Hash() const override;
31103
31162
 
31104
31163
  unique_ptr<ParsedExpression> Copy() const override;
31105
31164
 
31106
31165
  void Serialize(FieldWriter &writer) const override;
31107
31166
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31108
31167
  };
31168
+
31109
31169
  } // namespace duckdb
31170
+
31110
31171
  //===----------------------------------------------------------------------===//
31111
31172
  // DuckDB
31112
31173
  //
@@ -31138,10 +31199,11 @@ public:
31138
31199
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31139
31200
  };
31140
31201
  } // namespace duckdb
31202
+
31141
31203
  //===----------------------------------------------------------------------===//
31142
31204
  // DuckDB
31143
31205
  //
31144
- // duckdb/parser/expression/operator_expression.hpp
31206
+ // duckdb/parser/expression/function_expression.hpp
31145
31207
  //
31146
31208
  //
31147
31209
  //===----------------------------------------------------------------------===//
@@ -31152,62 +31214,181 @@ public:
31152
31214
 
31153
31215
 
31154
31216
 
31155
-
31156
31217
  namespace duckdb {
31157
- //! Represents a built-in operator expression
31158
- class OperatorExpression : public ParsedExpression {
31218
+ //! Represents a function call
31219
+ class FunctionExpression : public ParsedExpression {
31159
31220
  public:
31160
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
31161
- unique_ptr<ParsedExpression> right = nullptr);
31162
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
31221
+ DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
31222
+ vector<unique_ptr<ParsedExpression>> children,
31223
+ unique_ptr<ParsedExpression> filter = nullptr,
31224
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
31225
+ bool is_operator = false, bool export_state = false);
31226
+ DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
31227
+ unique_ptr<ParsedExpression> filter = nullptr,
31228
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
31229
+ bool is_operator = false, bool export_state = false);
31163
31230
 
31231
+ //! Schema of the function
31232
+ string schema;
31233
+ //! Function name
31234
+ string function_name;
31235
+ //! Whether or not the function is an operator, only used for rendering
31236
+ bool is_operator;
31237
+ //! List of arguments to the function
31164
31238
  vector<unique_ptr<ParsedExpression>> children;
31239
+ //! Whether or not the aggregate function is distinct, only used for aggregates
31240
+ bool distinct;
31241
+ //! Expression representing a filter, only used for aggregates
31242
+ unique_ptr<ParsedExpression> filter;
31243
+ //! Modifier representing an ORDER BY, only used for aggregates
31244
+ unique_ptr<OrderModifier> order_bys;
31245
+ //! whether this function should export its state or not
31246
+ bool export_state;
31165
31247
 
31166
31248
  public:
31167
31249
  string ToString() const override;
31168
31250
 
31169
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
31170
-
31171
31251
  unique_ptr<ParsedExpression> Copy() const override;
31172
31252
 
31253
+ static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
31254
+ hash_t Hash() const override;
31255
+
31173
31256
  void Serialize(FieldWriter &writer) const override;
31174
31257
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31175
31258
 
31259
+ void Verify() const override;
31260
+
31176
31261
  public:
31177
31262
  template <class T, class BASE>
31178
- static string ToString(const T &entry) {
31179
- auto op = ExpressionTypeToOperator(entry.type);
31180
- if (!op.empty()) {
31181
- // use the operator string to represent the operator
31182
- D_ASSERT(entry.children.size() == 2);
31183
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
31184
- }
31185
- switch (entry.type) {
31186
- case ExpressionType::COMPARE_IN:
31187
- case ExpressionType::COMPARE_NOT_IN: {
31188
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
31189
- string in_child = entry.children[0]->ToString();
31190
- string child_list = "(";
31191
- for (idx_t i = 1; i < entry.children.size(); i++) {
31192
- if (i > 1) {
31193
- child_list += ", ";
31263
+ static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
31264
+ bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
31265
+ bool export_state = false, bool add_alias = false) {
31266
+ if (is_operator) {
31267
+ // built-in operator
31268
+ D_ASSERT(!distinct);
31269
+ if (entry.children.size() == 1) {
31270
+ if (StringUtil::Contains(function_name, "__postfix")) {
31271
+ return "(" + entry.children[0]->ToString() + ")" +
31272
+ StringUtil::Replace(function_name, "__postfix", "");
31273
+ } else {
31274
+ return function_name + "(" + entry.children[0]->ToString() + ")";
31194
31275
  }
31195
- child_list += entry.children[i]->ToString();
31276
+ } else if (entry.children.size() == 2) {
31277
+ return StringUtil::Format("(%s %s %s)", entry.children[0]->ToString(), function_name,
31278
+ entry.children[1]->ToString());
31196
31279
  }
31197
- child_list += ")";
31198
- return "(" + in_child + op_type + child_list + ")";
31199
- }
31200
- case ExpressionType::OPERATOR_NOT: {
31201
- string result = "(";
31202
- result += ExpressionTypeToString(entry.type);
31203
- result += " ";
31204
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
31205
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
31206
- result += ")";
31207
- return result;
31208
31280
  }
31209
- case ExpressionType::GROUPING_FUNCTION:
31210
- case ExpressionType::OPERATOR_COALESCE: {
31281
+ // standard function call
31282
+ string result = schema.empty() ? function_name : schema + "." + function_name;
31283
+ result += "(";
31284
+ if (distinct) {
31285
+ result += "DISTINCT ";
31286
+ }
31287
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
31288
+ return child->alias.empty() || !add_alias
31289
+ ? child->ToString()
31290
+ : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
31291
+ });
31292
+ // ordered aggregate
31293
+ if (order_bys && !order_bys->orders.empty()) {
31294
+ if (entry.children.empty()) {
31295
+ result += ") WITHIN GROUP (";
31296
+ }
31297
+ result += " ORDER BY ";
31298
+ for (idx_t i = 0; i < order_bys->orders.size(); i++) {
31299
+ if (i > 0) {
31300
+ result += ", ";
31301
+ }
31302
+ result += order_bys->orders[i].ToString();
31303
+ }
31304
+ }
31305
+ result += ")";
31306
+
31307
+ // filtered aggregate
31308
+ if (filter) {
31309
+ result += " FILTER (WHERE " + filter->ToString() + ")";
31310
+ }
31311
+
31312
+ if (export_state) {
31313
+ result += " EXPORT_STATE";
31314
+ }
31315
+
31316
+ return result;
31317
+ }
31318
+ };
31319
+ } // namespace duckdb
31320
+
31321
+
31322
+ //===----------------------------------------------------------------------===//
31323
+ // DuckDB
31324
+ //
31325
+ // duckdb/parser/expression/operator_expression.hpp
31326
+ //
31327
+ //
31328
+ //===----------------------------------------------------------------------===//
31329
+
31330
+
31331
+
31332
+
31333
+
31334
+
31335
+
31336
+
31337
+ namespace duckdb {
31338
+ //! Represents a built-in operator expression
31339
+ class OperatorExpression : public ParsedExpression {
31340
+ public:
31341
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
31342
+ unique_ptr<ParsedExpression> right = nullptr);
31343
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
31344
+
31345
+ vector<unique_ptr<ParsedExpression>> children;
31346
+
31347
+ public:
31348
+ string ToString() const override;
31349
+
31350
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
31351
+
31352
+ unique_ptr<ParsedExpression> Copy() const override;
31353
+
31354
+ void Serialize(FieldWriter &writer) const override;
31355
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31356
+
31357
+ public:
31358
+ template <class T, class BASE>
31359
+ static string ToString(const T &entry) {
31360
+ auto op = ExpressionTypeToOperator(entry.type);
31361
+ if (!op.empty()) {
31362
+ // use the operator string to represent the operator
31363
+ D_ASSERT(entry.children.size() == 2);
31364
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
31365
+ }
31366
+ switch (entry.type) {
31367
+ case ExpressionType::COMPARE_IN:
31368
+ case ExpressionType::COMPARE_NOT_IN: {
31369
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
31370
+ string in_child = entry.children[0]->ToString();
31371
+ string child_list = "(";
31372
+ for (idx_t i = 1; i < entry.children.size(); i++) {
31373
+ if (i > 1) {
31374
+ child_list += ", ";
31375
+ }
31376
+ child_list += entry.children[i]->ToString();
31377
+ }
31378
+ child_list += ")";
31379
+ return "(" + in_child + op_type + child_list + ")";
31380
+ }
31381
+ case ExpressionType::OPERATOR_NOT: {
31382
+ string result = "(";
31383
+ result += ExpressionTypeToString(entry.type);
31384
+ result += " ";
31385
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
31386
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
31387
+ result += ")";
31388
+ return result;
31389
+ }
31390
+ case ExpressionType::GROUPING_FUNCTION:
31391
+ case ExpressionType::OPERATOR_COALESCE: {
31211
31392
  string result = ExpressionTypeToString(entry.type);
31212
31393
  result += "(";
31213
31394
  result += StringUtil::Join(entry.children, entry.children.size(), ", ",
@@ -31249,12 +31430,10 @@ public:
31249
31430
 
31250
31431
  } // namespace duckdb
31251
31432
 
31252
-
31253
-
31254
31433
  //===----------------------------------------------------------------------===//
31255
31434
  // DuckDB
31256
31435
  //
31257
- // duckdb/parser/expression/cast_expression.hpp
31436
+ // duckdb/parser/expression/parameter_expression.hpp
31258
31437
  //
31259
31438
  //
31260
31439
  //===----------------------------------------------------------------------===//
@@ -31263,44 +31442,37 @@ public:
31263
31442
 
31264
31443
 
31265
31444
 
31266
-
31267
31445
  namespace duckdb {
31268
-
31269
- //! CastExpression represents a type cast from one SQL type to another SQL type
31270
- class CastExpression : public ParsedExpression {
31446
+ class ParameterExpression : public ParsedExpression {
31271
31447
  public:
31272
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
31448
+ ParameterExpression();
31273
31449
 
31274
- //! The child of the cast expression
31275
- unique_ptr<ParsedExpression> child;
31276
- //! The type to cast to
31277
- LogicalType cast_type;
31278
- //! Whether or not this is a try_cast expression
31279
- bool try_cast;
31450
+ idx_t parameter_nr;
31280
31451
 
31281
31452
  public:
31453
+ bool IsScalar() const override {
31454
+ return true;
31455
+ }
31456
+ bool HasParameter() const override {
31457
+ return true;
31458
+ }
31459
+
31282
31460
  string ToString() const override;
31283
31461
 
31284
- static bool Equals(const CastExpression *a, const CastExpression *b);
31462
+ static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
31285
31463
 
31286
31464
  unique_ptr<ParsedExpression> Copy() const override;
31465
+ hash_t Hash() const override;
31287
31466
 
31288
31467
  void Serialize(FieldWriter &writer) const override;
31289
31468
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31290
-
31291
- public:
31292
- template <class T, class BASE>
31293
- static string ToString(const T &entry) {
31294
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
31295
- entry.cast_type.ToString() + ")";
31296
- }
31297
31469
  };
31298
31470
  } // namespace duckdb
31299
31471
 
31300
31472
  //===----------------------------------------------------------------------===//
31301
31473
  // DuckDB
31302
31474
  //
31303
- // duckdb/parser/expression/collate_expression.hpp
31475
+ // duckdb/parser/expression/positional_reference_expression.hpp
31304
31476
  //
31305
31477
  //
31306
31478
  //===----------------------------------------------------------------------===//
@@ -31310,35 +31482,32 @@ public:
31310
31482
 
31311
31483
 
31312
31484
  namespace duckdb {
31313
-
31314
- //! CollateExpression represents a COLLATE statement
31315
- class CollateExpression : public ParsedExpression {
31485
+ class PositionalReferenceExpression : public ParsedExpression {
31316
31486
  public:
31317
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
31487
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
31318
31488
 
31319
- //! The child of the cast expression
31320
- unique_ptr<ParsedExpression> child;
31321
- //! The collation clause
31322
- string collation;
31489
+ idx_t index;
31323
31490
 
31324
31491
  public:
31325
- string ToString() const override;
31492
+ bool IsScalar() const override {
31493
+ return false;
31494
+ }
31326
31495
 
31327
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
31496
+ string ToString() const override;
31328
31497
 
31498
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
31329
31499
  unique_ptr<ParsedExpression> Copy() const override;
31500
+ hash_t Hash() const override;
31330
31501
 
31331
31502
  void Serialize(FieldWriter &writer) const override;
31332
31503
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31333
31504
  };
31334
31505
  } // namespace duckdb
31335
31506
 
31336
-
31337
-
31338
31507
  //===----------------------------------------------------------------------===//
31339
31508
  // DuckDB
31340
31509
  //
31341
- // duckdb/parser/expression/conjunction_expression.hpp
31510
+ // duckdb/parser/expression/star_expression.hpp
31342
31511
  //
31343
31512
  //
31344
31513
  //===----------------------------------------------------------------------===//
@@ -31350,46 +31519,38 @@ public:
31350
31519
 
31351
31520
  namespace duckdb {
31352
31521
 
31353
- //! Represents a conjunction (AND/OR)
31354
- class ConjunctionExpression : public ParsedExpression {
31522
+ //! Represents a * expression in the SELECT clause
31523
+ class StarExpression : public ParsedExpression {
31355
31524
  public:
31356
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
31357
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
31358
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
31359
- unique_ptr<ParsedExpression> right);
31525
+ StarExpression(string relation_name = string());
31360
31526
 
31361
- vector<unique_ptr<ParsedExpression>> children;
31527
+ //! The relation name in case of tbl.*, or empty if this is a normal *
31528
+ string relation_name;
31529
+ //! List of columns to exclude from the STAR expression
31530
+ case_insensitive_set_t exclude_list;
31531
+ //! List of columns to replace with another expression
31532
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
31533
+ //! Regular expression to select columns (if any)
31534
+ string regex;
31535
+ //! Whether or not this is a COLUMNS expression
31536
+ bool columns = false;
31362
31537
 
31363
31538
  public:
31364
- void AddExpression(unique_ptr<ParsedExpression> expr);
31365
-
31366
31539
  string ToString() const override;
31367
31540
 
31368
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
31541
+ static bool Equals(const StarExpression *a, const StarExpression *b);
31369
31542
 
31370
31543
  unique_ptr<ParsedExpression> Copy() const override;
31371
31544
 
31372
31545
  void Serialize(FieldWriter &writer) const override;
31373
31546
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31374
-
31375
- public:
31376
- template <class T, class BASE>
31377
- static string ToString(const T &entry) {
31378
- string result = "(" + entry.children[0]->ToString();
31379
- for (idx_t i = 1; i < entry.children.size(); i++) {
31380
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
31381
- }
31382
- return result + ")";
31383
- }
31384
31547
  };
31385
31548
  } // namespace duckdb
31386
31549
 
31387
-
31388
-
31389
31550
  //===----------------------------------------------------------------------===//
31390
31551
  // DuckDB
31391
31552
  //
31392
- // duckdb/parser/expression/function_expression.hpp
31553
+ // duckdb/parser/expression/subquery_expression.hpp
31393
31554
  //
31394
31555
  //
31395
31556
  //===----------------------------------------------------------------------===//
@@ -31401,115 +31562,46 @@ public:
31401
31562
 
31402
31563
 
31403
31564
  namespace duckdb {
31404
- //! Represents a function call
31405
- class FunctionExpression : public ParsedExpression {
31565
+
31566
+ //! Represents a subquery
31567
+ class SubqueryExpression : public ParsedExpression {
31406
31568
  public:
31407
- DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
31408
- vector<unique_ptr<ParsedExpression>> children,
31409
- unique_ptr<ParsedExpression> filter = nullptr,
31410
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
31411
- bool is_operator = false, bool export_state = false);
31412
- DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
31413
- unique_ptr<ParsedExpression> filter = nullptr,
31414
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
31415
- bool is_operator = false, bool export_state = false);
31569
+ SubqueryExpression();
31416
31570
 
31417
- //! Schema of the function
31418
- string schema;
31419
- //! Function name
31420
- string function_name;
31421
- //! Whether or not the function is an operator, only used for rendering
31422
- bool is_operator;
31423
- //! List of arguments to the function
31424
- vector<unique_ptr<ParsedExpression>> children;
31425
- //! Whether or not the aggregate function is distinct, only used for aggregates
31426
- bool distinct;
31427
- //! Expression representing a filter, only used for aggregates
31428
- unique_ptr<ParsedExpression> filter;
31429
- //! Modifier representing an ORDER BY, only used for aggregates
31430
- unique_ptr<OrderModifier> order_bys;
31431
- //! whether this function should export its state or not
31432
- bool export_state;
31571
+ //! The actual subquery
31572
+ unique_ptr<SelectStatement> subquery;
31573
+ //! The subquery type
31574
+ SubqueryType subquery_type;
31575
+ //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
31576
+ //! subquery)
31577
+ unique_ptr<ParsedExpression> child;
31578
+ //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
31579
+ ExpressionType comparison_type;
31433
31580
 
31434
31581
  public:
31582
+ bool HasSubquery() const override {
31583
+ return true;
31584
+ }
31585
+ bool IsScalar() const override {
31586
+ return false;
31587
+ }
31588
+
31435
31589
  string ToString() const override;
31436
31590
 
31437
- unique_ptr<ParsedExpression> Copy() const override;
31591
+ static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
31438
31592
 
31439
- static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
31440
- hash_t Hash() const override;
31593
+ unique_ptr<ParsedExpression> Copy() const override;
31441
31594
 
31442
31595
  void Serialize(FieldWriter &writer) const override;
31443
31596
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31444
-
31445
- void Verify() const override;
31446
-
31447
- public:
31448
- template <class T, class BASE>
31449
- static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
31450
- bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
31451
- bool export_state = false, bool add_alias = false) {
31452
- if (is_operator) {
31453
- // built-in operator
31454
- D_ASSERT(!distinct);
31455
- if (entry.children.size() == 1) {
31456
- if (StringUtil::Contains(function_name, "__postfix")) {
31457
- return "(" + entry.children[0]->ToString() + ")" +
31458
- StringUtil::Replace(function_name, "__postfix", "");
31459
- } else {
31460
- return function_name + "(" + entry.children[0]->ToString() + ")";
31461
- }
31462
- } else if (entry.children.size() == 2) {
31463
- return StringUtil::Format("(%s %s %s)", entry.children[0]->ToString(), function_name,
31464
- entry.children[1]->ToString());
31465
- }
31466
- }
31467
- // standard function call
31468
- string result = schema.empty() ? function_name : schema + "." + function_name;
31469
- result += "(";
31470
- if (distinct) {
31471
- result += "DISTINCT ";
31472
- }
31473
- result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
31474
- return child->alias.empty() || !add_alias
31475
- ? child->ToString()
31476
- : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
31477
- });
31478
- // ordered aggregate
31479
- if (order_bys && !order_bys->orders.empty()) {
31480
- if (entry.children.empty()) {
31481
- result += ") WITHIN GROUP (";
31482
- }
31483
- result += " ORDER BY ";
31484
- for (idx_t i = 0; i < order_bys->orders.size(); i++) {
31485
- if (i > 0) {
31486
- result += ", ";
31487
- }
31488
- result += order_bys->orders[i].ToString();
31489
- }
31490
- }
31491
- result += ")";
31492
-
31493
- // filtered aggregate
31494
- if (filter) {
31495
- result += " FILTER (WHERE " + filter->ToString() + ")";
31496
- }
31497
-
31498
- if (export_state) {
31499
- result += " EXPORT_STATE";
31500
- }
31501
-
31502
- return result;
31503
- }
31504
31597
  };
31505
31598
  } // namespace duckdb
31506
31599
 
31507
31600
 
31508
-
31509
31601
  //===----------------------------------------------------------------------===//
31510
31602
  // DuckDB
31511
31603
  //
31512
- // duckdb/parser/expression/parameter_expression.hpp
31604
+ // duckdb/parser/parsed_data/create_view_info.hpp
31513
31605
  //
31514
31606
  //
31515
31607
  //===----------------------------------------------------------------------===//
@@ -31518,39 +31610,65 @@ public:
31518
31610
 
31519
31611
 
31520
31612
 
31521
- namespace duckdb {
31522
- class ParameterExpression : public ParsedExpression {
31523
- public:
31524
- ParameterExpression();
31525
31613
 
31526
- idx_t parameter_nr;
31614
+ namespace duckdb {
31527
31615
 
31528
- public:
31529
- bool IsScalar() const override {
31530
- return true;
31616
+ struct CreateViewInfo : public CreateInfo {
31617
+ CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
31531
31618
  }
31532
- bool HasParameter() const override {
31533
- return true;
31619
+ CreateViewInfo(string schema, string view_name)
31620
+ : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
31534
31621
  }
31535
31622
 
31536
- string ToString() const override;
31623
+ //! Table name to insert to
31624
+ string view_name;
31625
+ //! Aliases of the view
31626
+ vector<string> aliases;
31627
+ //! Return types
31628
+ vector<LogicalType> types;
31629
+ //! The SelectStatement of the view
31630
+ unique_ptr<SelectStatement> query;
31537
31631
 
31538
- static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
31632
+ public:
31633
+ unique_ptr<CreateInfo> Copy() const override {
31634
+ auto result = make_unique<CreateViewInfo>(schema, view_name);
31635
+ CopyProperties(*result);
31636
+ result->aliases = aliases;
31637
+ result->types = types;
31638
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
31639
+ return move(result);
31640
+ }
31539
31641
 
31540
- unique_ptr<ParsedExpression> Copy() const override;
31541
- hash_t Hash() const override;
31642
+ static unique_ptr<CreateViewInfo> Deserialize(Deserializer &deserializer) {
31643
+ auto result = make_unique<CreateViewInfo>();
31644
+ result->DeserializeBase(deserializer);
31542
31645
 
31543
- void Serialize(FieldWriter &writer) const override;
31544
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31545
- };
31546
- } // namespace duckdb
31646
+ FieldReader reader(deserializer);
31647
+ result->view_name = reader.ReadRequired<string>();
31648
+ result->aliases = reader.ReadRequiredList<string>();
31649
+ result->types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
31650
+ result->query = reader.ReadOptional<SelectStatement>(nullptr);
31651
+ reader.Finalize();
31547
31652
 
31653
+ return result;
31654
+ }
31548
31655
 
31656
+ protected:
31657
+ void SerializeInternal(Serializer &serializer) const override {
31658
+ FieldWriter writer(serializer);
31659
+ writer.WriteString(view_name);
31660
+ writer.WriteList<string>(aliases);
31661
+ writer.WriteRegularSerializableList(types);
31662
+ writer.WriteOptional(query);
31663
+ writer.Finalize();
31664
+ }
31665
+ };
31549
31666
 
31667
+ } // namespace duckdb
31550
31668
  //===----------------------------------------------------------------------===//
31551
31669
  // DuckDB
31552
31670
  //
31553
- // duckdb/parser/expression/subquery_expression.hpp
31671
+ // duckdb/parser/parsed_data/alter_function_info.hpp
31554
31672
  //
31555
31673
  //
31556
31674
  //===----------------------------------------------------------------------===//
@@ -31563,88 +31681,34 @@ public:
31563
31681
 
31564
31682
  namespace duckdb {
31565
31683
 
31566
- //! Represents a subquery
31567
- class SubqueryExpression : public ParsedExpression {
31568
- public:
31569
- SubqueryExpression();
31570
-
31571
- //! The actual subquery
31572
- unique_ptr<SelectStatement> subquery;
31573
- //! The subquery type
31574
- SubqueryType subquery_type;
31575
- //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
31576
- //! subquery)
31577
- unique_ptr<ParsedExpression> child;
31578
- //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
31579
- ExpressionType comparison_type;
31580
-
31581
- public:
31582
- bool HasSubquery() const override {
31583
- return true;
31584
- }
31585
- bool IsScalar() const override {
31586
- return false;
31587
- }
31588
-
31589
- string ToString() const override;
31684
+ //===--------------------------------------------------------------------===//
31685
+ // Alter Table
31686
+ //===--------------------------------------------------------------------===//
31687
+ enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
31590
31688
 
31591
- static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
31689
+ struct AlterFunctionInfo : public AlterInfo {
31690
+ AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
31691
+ virtual ~AlterFunctionInfo() override;
31592
31692
 
31593
- unique_ptr<ParsedExpression> Copy() const override;
31693
+ AlterFunctionType alter_function_type;
31594
31694
 
31695
+ public:
31696
+ CatalogType GetCatalogType() const override;
31595
31697
  void Serialize(FieldWriter &writer) const override;
31596
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
31698
+ static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
31597
31699
  };
31598
- } // namespace duckdb
31599
-
31600
-
31601
- //===----------------------------------------------------------------------===//
31602
- // DuckDB
31603
- //
31604
- // duckdb/parser/parsed_data/create_type_info.hpp
31605
- //
31606
- //
31607
- //===----------------------------------------------------------------------===//
31608
31700
 
31701
+ //===--------------------------------------------------------------------===//
31702
+ // AddFunctionOverloadInfo
31703
+ //===--------------------------------------------------------------------===//
31704
+ struct AddFunctionOverloadInfo : public AlterFunctionInfo {
31705
+ AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
31706
+ ~AddFunctionOverloadInfo() override;
31609
31707
 
31610
-
31611
-
31612
-
31613
-
31614
-
31615
-
31616
- namespace duckdb {
31617
-
31618
- struct CreateTypeInfo : public CreateInfo {
31619
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
31620
- }
31621
- CreateTypeInfo(string name_p, LogicalType type_p)
31622
- : CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
31623
- }
31624
-
31625
- //! Name of the Type
31626
- string name;
31627
- //! Logical Type
31628
- LogicalType type;
31629
- //! Used by create enum from query
31630
- unique_ptr<SQLStatement> query;
31708
+ ScalarFunctionSet new_overloads;
31631
31709
 
31632
31710
  public:
31633
- unique_ptr<CreateInfo> Copy() const override {
31634
- auto result = make_unique<CreateTypeInfo>();
31635
- CopyProperties(*result);
31636
- result->name = name;
31637
- result->type = type;
31638
- if (query) {
31639
- result->query = query->Copy();
31640
- }
31641
- return move(result);
31642
- }
31643
-
31644
- protected:
31645
- void SerializeInternal(Serializer &) const override {
31646
- throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
31647
- }
31711
+ unique_ptr<AlterInfo> Copy() const override;
31648
31712
  };
31649
31713
 
31650
31714
  } // namespace duckdb
@@ -31698,7 +31762,7 @@ public:
31698
31762
  //===----------------------------------------------------------------------===//
31699
31763
  // DuckDB
31700
31764
  //
31701
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
31765
+ // duckdb/parser/parsed_data/show_select_info.hpp
31702
31766
  //
31703
31767
  //
31704
31768
  //===----------------------------------------------------------------------===//
@@ -31710,28 +31774,23 @@ public:
31710
31774
 
31711
31775
  namespace duckdb {
31712
31776
 
31713
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
31714
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
31715
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
31716
- name = function.name;
31717
- functions.AddFunction(move(function));
31718
- }
31719
-
31720
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
31721
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
31722
- name = functions.name;
31723
- for (auto &func : functions.functions) {
31724
- func.name = functions.name;
31725
- }
31726
- }
31727
-
31728
- AggregateFunctionSet functions;
31777
+ struct ShowSelectInfo : public ParseInfo {
31778
+ //! Types of projected columns
31779
+ vector<LogicalType> types;
31780
+ //! The QueryNode of select query
31781
+ unique_ptr<QueryNode> query;
31782
+ //! Aliases of projected columns
31783
+ vector<string> aliases;
31784
+ //! Whether or not we are requesting a summary or a describe
31785
+ bool is_summary;
31729
31786
 
31730
- public:
31731
- unique_ptr<CreateInfo> Copy() const override {
31732
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
31733
- CopyProperties(*result);
31734
- return move(result);
31787
+ unique_ptr<ShowSelectInfo> Copy() {
31788
+ auto result = make_unique<ShowSelectInfo>();
31789
+ result->types = types;
31790
+ result->query = query->Copy();
31791
+ result->aliases = aliases;
31792
+ result->is_summary = is_summary;
31793
+ return result;
31735
31794
  }
31736
31795
  };
31737
31796
 
@@ -31739,7 +31798,7 @@ public:
31739
31798
  //===----------------------------------------------------------------------===//
31740
31799
  // DuckDB
31741
31800
  //
31742
- // duckdb/parser/parsed_data/vacuum_info.hpp
31801
+ // duckdb/parser/parsed_data/create_index_info.hpp
31743
31802
  //
31744
31803
  //
31745
31804
  //===----------------------------------------------------------------------===//
@@ -31748,20 +31807,11 @@ public:
31748
31807
 
31749
31808
 
31750
31809
 
31751
- //===----------------------------------------------------------------------===//
31752
- // DuckDB
31753
- //
31754
- // duckdb/planner/tableref/bound_basetableref.hpp
31755
- //
31756
- //
31757
- //===----------------------------------------------------------------------===//
31758
-
31759
-
31760
31810
 
31761
31811
  //===----------------------------------------------------------------------===//
31762
31812
  // DuckDB
31763
31813
  //
31764
- // duckdb/planner/bound_tableref.hpp
31814
+ // duckdb/parser/tableref/basetableref.hpp
31765
31815
  //
31766
31816
  //
31767
31817
  //===----------------------------------------------------------------------===//
@@ -31771,163 +31821,78 @@ public:
31771
31821
 
31772
31822
 
31773
31823
 
31774
-
31775
31824
  namespace duckdb {
31776
-
31777
- class BoundTableRef {
31778
- public:
31779
- explicit BoundTableRef(TableReferenceType type) : type(type) {
31780
- }
31781
- virtual ~BoundTableRef() {
31782
- }
31783
-
31784
- //! The type of table reference
31785
- TableReferenceType type;
31786
- //! The sample options (if any)
31787
- unique_ptr<SampleOptions> sample;
31788
- };
31789
- } // namespace duckdb
31790
-
31791
-
31792
-
31793
- namespace duckdb {
31794
- class TableCatalogEntry;
31795
-
31796
31825
  //! Represents a TableReference to a base table in the schema
31797
- class BoundBaseTableRef : public BoundTableRef {
31826
+ class BaseTableRef : public TableRef {
31798
31827
  public:
31799
- BoundBaseTableRef(TableCatalogEntry *table, unique_ptr<LogicalOperator> get)
31800
- : BoundTableRef(TableReferenceType::BASE_TABLE), table(table), get(move(get)) {
31828
+ BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
31801
31829
  }
31802
31830
 
31803
- TableCatalogEntry *table;
31804
- unique_ptr<LogicalOperator> get;
31805
- };
31806
- } // namespace duckdb
31807
-
31808
-
31809
-
31810
- namespace duckdb {
31811
-
31812
- struct VacuumOptions {
31813
- bool vacuum;
31814
- bool analyze;
31815
- };
31831
+ //! Schema name
31832
+ string schema_name;
31833
+ //! Table name
31834
+ string table_name;
31835
+ //! Aliases for the column names
31836
+ vector<string> column_name_alias;
31816
31837
 
31817
- struct VacuumInfo : public ParseInfo {
31818
31838
  public:
31819
- explicit VacuumInfo(VacuumOptions options) : options(options), has_table(false), table(nullptr) {};
31820
-
31821
- unique_ptr<VacuumInfo> Copy() {
31822
- auto result = make_unique<VacuumInfo>(options);
31823
- result->has_table = has_table;
31824
- if (has_table) {
31825
- result->ref = ref->Copy();
31826
- }
31827
- return result;
31828
- }
31839
+ string ToString() const override;
31840
+ bool Equals(const TableRef *other_p) const override;
31829
31841
 
31830
- const VacuumOptions options;
31842
+ unique_ptr<TableRef> Copy() override;
31831
31843
 
31832
- public:
31833
- bool has_table;
31834
- unique_ptr<TableRef> ref;
31835
- TableCatalogEntry *table;
31836
- unordered_map<idx_t, idx_t> column_id_map;
31837
- vector<string> columns;
31844
+ //! Serializes a blob into a BaseTableRef
31845
+ void Serialize(FieldWriter &serializer) const override;
31846
+ //! Deserializes a blob back into a BaseTableRef
31847
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
31838
31848
  };
31839
-
31840
31849
  } // namespace duckdb
31841
- //===----------------------------------------------------------------------===//
31842
- // DuckDB
31843
- //
31844
- // duckdb/parser/parsed_data/drop_info.hpp
31845
- //
31846
- //
31847
- //===----------------------------------------------------------------------===//
31848
-
31849
-
31850
31850
 
31851
31851
 
31852
31852
 
31853
31853
 
31854
31854
  namespace duckdb {
31855
31855
 
31856
- struct DropInfo : public ParseInfo {
31857
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
31858
- }
31859
-
31860
- //! The catalog type to drop
31861
- CatalogType type;
31862
- //! Schema name to drop from, if any
31863
- string schema;
31864
- //! Element name to drop
31865
- string name;
31866
- //! Ignore if the entry does not exist instead of failing
31867
- bool if_exists = false;
31868
- //! Cascade drop (drop all dependents instead of throwing an error if there
31869
- //! are any)
31870
- bool cascade = false;
31871
-
31872
- public:
31873
- unique_ptr<DropInfo> Copy() const {
31874
- auto result = make_unique<DropInfo>();
31875
- result->type = type;
31876
- result->schema = schema;
31877
- result->name = name;
31878
- result->if_exists = if_exists;
31879
- result->cascade = cascade;
31880
- return result;
31856
+ struct CreateIndexInfo : public CreateInfo {
31857
+ CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
31881
31858
  }
31882
- };
31883
-
31884
- } // namespace duckdb
31885
- //===----------------------------------------------------------------------===//
31886
- // DuckDB
31887
- //
31888
- // duckdb/parser/parsed_data/export_table_data.hpp
31889
- //
31890
- //
31891
- //===----------------------------------------------------------------------===//
31892
-
31893
-
31894
-
31895
-
31896
-
31897
-
31898
- namespace duckdb {
31899
- class TableCatalogEntry;
31900
31859
 
31901
- struct ExportedTableData {
31902
- //! Name of the exported table
31903
- string table_name;
31860
+ //! Index Type (e.g., B+-tree, Skip-List, ...)
31861
+ IndexType index_type;
31862
+ //! Name of the Index
31863
+ string index_name;
31864
+ //! Index Constraint Type
31865
+ IndexConstraintType constraint_type;
31866
+ //! The table to create the index on
31867
+ unique_ptr<BaseTableRef> table;
31868
+ //! Set of expressions to index by
31869
+ vector<unique_ptr<ParsedExpression>> expressions;
31870
+ vector<unique_ptr<ParsedExpression>> parsed_expressions;
31904
31871
 
31905
- //! Name of the schema
31906
- string schema_name;
31872
+ //! Types used for the CREATE INDEX scan
31873
+ vector<LogicalType> scan_types;
31874
+ //! The names of the columns, used for the CREATE INDEX scan
31875
+ vector<string> names;
31876
+ //! Column IDs needed for index creation
31877
+ vector<column_t> column_ids;
31907
31878
 
31908
- //! Path to be exported
31909
- string file_path;
31910
- };
31879
+ protected:
31880
+ void SerializeInternal(Serializer &serializer) const override;
31911
31881
 
31912
- struct ExportedTableInfo {
31913
- TableCatalogEntry *entry;
31914
- ExportedTableData table_data;
31915
- };
31882
+ public:
31883
+ unique_ptr<CreateInfo> Copy() const override;
31916
31884
 
31917
- struct BoundExportData : public ParseInfo {
31918
- std::vector<ExportedTableInfo> data;
31885
+ static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
31919
31886
  };
31920
31887
 
31921
31888
  } // namespace duckdb
31922
31889
  //===----------------------------------------------------------------------===//
31923
31890
  // DuckDB
31924
31891
  //
31925
- // duckdb/parser/parsed_data/alter_function_info.hpp
31892
+ // duckdb/parser/parsed_data/transaction_info.hpp
31926
31893
  //
31927
31894
  //
31928
- //===----------------------------------------------------------------------===//
31929
-
31930
-
31895
+ //===----------------------------------------------------------------------===//
31931
31896
 
31932
31897
 
31933
31898
 
@@ -31935,34 +31900,14 @@ struct BoundExportData : public ParseInfo {
31935
31900
 
31936
31901
  namespace duckdb {
31937
31902
 
31938
- //===--------------------------------------------------------------------===//
31939
- // Alter Table
31940
- //===--------------------------------------------------------------------===//
31941
- enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
31942
-
31943
- struct AlterFunctionInfo : public AlterInfo {
31944
- AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
31945
- virtual ~AlterFunctionInfo() override;
31946
-
31947
- AlterFunctionType alter_function_type;
31948
-
31949
- public:
31950
- CatalogType GetCatalogType() const override;
31951
- void Serialize(FieldWriter &writer) const override;
31952
- static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
31953
- };
31954
-
31955
- //===--------------------------------------------------------------------===//
31956
- // AddFunctionOverloadInfo
31957
- //===--------------------------------------------------------------------===//
31958
- struct AddFunctionOverloadInfo : public AlterFunctionInfo {
31959
- AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
31960
- ~AddFunctionOverloadInfo() override;
31903
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
31961
31904
 
31962
- ScalarFunctionSet new_overloads;
31905
+ struct TransactionInfo : public ParseInfo {
31906
+ explicit TransactionInfo(TransactionType type) : type(type) {
31907
+ }
31963
31908
 
31964
- public:
31965
- unique_ptr<AlterInfo> Copy() const override;
31909
+ //! The type of transaction statement
31910
+ TransactionType type;
31966
31911
  };
31967
31912
 
31968
31913
  } // namespace duckdb
@@ -31999,7 +31944,7 @@ public:
31999
31944
  //===----------------------------------------------------------------------===//
32000
31945
  // DuckDB
32001
31946
  //
32002
- // duckdb/parser/parsed_data/create_view_info.hpp
31947
+ // duckdb/parser/parsed_data/export_table_data.hpp
32003
31948
  //
32004
31949
  //
32005
31950
  //===----------------------------------------------------------------------===//
@@ -32010,63 +31955,33 @@ public:
32010
31955
 
32011
31956
 
32012
31957
  namespace duckdb {
31958
+ class TableCatalogEntry;
32013
31959
 
32014
- struct CreateViewInfo : public CreateInfo {
32015
- CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
32016
- }
32017
- CreateViewInfo(string schema, string view_name)
32018
- : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
32019
- }
32020
-
32021
- //! Table name to insert to
32022
- string view_name;
32023
- //! Aliases of the view
32024
- vector<string> aliases;
32025
- //! Return types
32026
- vector<LogicalType> types;
32027
- //! The SelectStatement of the view
32028
- unique_ptr<SelectStatement> query;
32029
-
32030
- public:
32031
- unique_ptr<CreateInfo> Copy() const override {
32032
- auto result = make_unique<CreateViewInfo>(schema, view_name);
32033
- CopyProperties(*result);
32034
- result->aliases = aliases;
32035
- result->types = types;
32036
- result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
32037
- return move(result);
32038
- }
31960
+ struct ExportedTableData {
31961
+ //! Name of the exported table
31962
+ string table_name;
32039
31963
 
32040
- static unique_ptr<CreateViewInfo> Deserialize(Deserializer &deserializer) {
32041
- auto result = make_unique<CreateViewInfo>();
32042
- result->DeserializeBase(deserializer);
31964
+ //! Name of the schema
31965
+ string schema_name;
32043
31966
 
32044
- FieldReader reader(deserializer);
32045
- result->view_name = reader.ReadRequired<string>();
32046
- result->aliases = reader.ReadRequiredList<string>();
32047
- result->types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
32048
- result->query = reader.ReadOptional<SelectStatement>(nullptr);
32049
- reader.Finalize();
31967
+ //! Path to be exported
31968
+ string file_path;
31969
+ };
32050
31970
 
32051
- return result;
32052
- }
31971
+ struct ExportedTableInfo {
31972
+ TableCatalogEntry *entry;
31973
+ ExportedTableData table_data;
31974
+ };
32053
31975
 
32054
- protected:
32055
- void SerializeInternal(Serializer &serializer) const override {
32056
- FieldWriter writer(serializer);
32057
- writer.WriteString(view_name);
32058
- writer.WriteList<string>(aliases);
32059
- writer.WriteRegularSerializableList(types);
32060
- writer.WriteOptional(query);
32061
- writer.Finalize();
32062
- }
31976
+ struct BoundExportData : public ParseInfo {
31977
+ std::vector<ExportedTableInfo> data;
32063
31978
  };
32064
31979
 
32065
31980
  } // namespace duckdb
32066
31981
  //===----------------------------------------------------------------------===//
32067
31982
  // DuckDB
32068
31983
  //
32069
- // duckdb/parser/parsed_data/create_schema_info.hpp
31984
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
32070
31985
  //
32071
31986
  //
32072
31987
  //===----------------------------------------------------------------------===//
@@ -32075,28 +31990,32 @@ protected:
32075
31990
 
32076
31991
 
32077
31992
 
31993
+
32078
31994
  namespace duckdb {
32079
31995
 
32080
- struct CreateSchemaInfo : public CreateInfo {
32081
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
31996
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
31997
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
31998
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
31999
+ name = function.name;
32000
+ functions.AddFunction(move(function));
32001
+ }
32002
+
32003
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
32004
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
32005
+ name = functions.name;
32006
+ for (auto &func : functions.functions) {
32007
+ func.name = functions.name;
32008
+ }
32082
32009
  }
32083
32010
 
32011
+ AggregateFunctionSet functions;
32012
+
32084
32013
  public:
32085
32014
  unique_ptr<CreateInfo> Copy() const override {
32086
- auto result = make_unique<CreateSchemaInfo>();
32015
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
32087
32016
  CopyProperties(*result);
32088
32017
  return move(result);
32089
32018
  }
32090
-
32091
- static unique_ptr<CreateSchemaInfo> Deserialize(Deserializer &deserializer) {
32092
- auto result = make_unique<CreateSchemaInfo>();
32093
- result->DeserializeBase(deserializer);
32094
- return result;
32095
- }
32096
-
32097
- protected:
32098
- void SerializeInternal(Serializer &) const override {
32099
- }
32100
32019
  };
32101
32020
 
32102
32021
  } // namespace duckdb
@@ -32183,6 +32102,43 @@ public:
32183
32102
  }
32184
32103
  };
32185
32104
 
32105
+ } // namespace duckdb
32106
+ //===----------------------------------------------------------------------===//
32107
+ // DuckDB
32108
+ //
32109
+ // duckdb/parser/parsed_data/create_schema_info.hpp
32110
+ //
32111
+ //
32112
+ //===----------------------------------------------------------------------===//
32113
+
32114
+
32115
+
32116
+
32117
+
32118
+ namespace duckdb {
32119
+
32120
+ struct CreateSchemaInfo : public CreateInfo {
32121
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
32122
+ }
32123
+
32124
+ public:
32125
+ unique_ptr<CreateInfo> Copy() const override {
32126
+ auto result = make_unique<CreateSchemaInfo>();
32127
+ CopyProperties(*result);
32128
+ return move(result);
32129
+ }
32130
+
32131
+ static unique_ptr<CreateSchemaInfo> Deserialize(Deserializer &deserializer) {
32132
+ auto result = make_unique<CreateSchemaInfo>();
32133
+ result->DeserializeBase(deserializer);
32134
+ return result;
32135
+ }
32136
+
32137
+ protected:
32138
+ void SerializeInternal(Serializer &) const override {
32139
+ }
32140
+ };
32141
+
32186
32142
  } // namespace duckdb
32187
32143
  //===----------------------------------------------------------------------===//
32188
32144
  // DuckDB
@@ -32225,7 +32181,7 @@ public:
32225
32181
  //===----------------------------------------------------------------------===//
32226
32182
  // DuckDB
32227
32183
  //
32228
- // duckdb/parser/parsed_data/transaction_info.hpp
32184
+ // duckdb/parser/parsed_data/vacuum_info.hpp
32229
32185
  //
32230
32186
  //
32231
32187
  //===----------------------------------------------------------------------===//
@@ -32234,36 +32190,20 @@ public:
32234
32190
 
32235
32191
 
32236
32192
 
32237
- namespace duckdb {
32238
-
32239
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
32240
-
32241
- struct TransactionInfo : public ParseInfo {
32242
- explicit TransactionInfo(TransactionType type) : type(type) {
32243
- }
32244
-
32245
- //! The type of transaction statement
32246
- TransactionType type;
32247
- };
32248
-
32249
- } // namespace duckdb
32250
32193
  //===----------------------------------------------------------------------===//
32251
32194
  // DuckDB
32252
32195
  //
32253
- // duckdb/parser/parsed_data/create_index_info.hpp
32196
+ // duckdb/planner/tableref/bound_basetableref.hpp
32254
32197
  //
32255
32198
  //
32256
32199
  //===----------------------------------------------------------------------===//
32257
32200
 
32258
32201
 
32259
32202
 
32260
-
32261
-
32262
-
32263
32203
  //===----------------------------------------------------------------------===//
32264
32204
  // DuckDB
32265
32205
  //
32266
- // duckdb/parser/tableref/basetableref.hpp
32206
+ // duckdb/planner/bound_tableref.hpp
32267
32207
  //
32268
32208
  //
32269
32209
  //===----------------------------------------------------------------------===//
@@ -32273,75 +32213,77 @@ struct TransactionInfo : public ParseInfo {
32273
32213
 
32274
32214
 
32275
32215
 
32216
+
32276
32217
  namespace duckdb {
32277
- //! Represents a TableReference to a base table in the schema
32278
- class BaseTableRef : public TableRef {
32218
+
32219
+ class BoundTableRef {
32279
32220
  public:
32280
- BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
32221
+ explicit BoundTableRef(TableReferenceType type) : type(type) {
32222
+ }
32223
+ virtual ~BoundTableRef() {
32281
32224
  }
32282
32225
 
32283
- //! Schema name
32284
- string schema_name;
32285
- //! Table name
32286
- string table_name;
32287
- //! Aliases for the column names
32288
- vector<string> column_name_alias;
32226
+ //! The type of table reference
32227
+ TableReferenceType type;
32228
+ //! The sample options (if any)
32229
+ unique_ptr<SampleOptions> sample;
32230
+ };
32231
+ } // namespace duckdb
32289
32232
 
32290
- public:
32291
- string ToString() const override;
32292
- bool Equals(const TableRef *other_p) const override;
32293
32233
 
32294
- unique_ptr<TableRef> Copy() override;
32295
32234
 
32296
- //! Serializes a blob into a BaseTableRef
32297
- void Serialize(FieldWriter &serializer) const override;
32298
- //! Deserializes a blob back into a BaseTableRef
32299
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
32235
+ namespace duckdb {
32236
+ class TableCatalogEntry;
32237
+
32238
+ //! Represents a TableReference to a base table in the schema
32239
+ class BoundBaseTableRef : public BoundTableRef {
32240
+ public:
32241
+ BoundBaseTableRef(TableCatalogEntry *table, unique_ptr<LogicalOperator> get)
32242
+ : BoundTableRef(TableReferenceType::BASE_TABLE), table(table), get(move(get)) {
32243
+ }
32244
+
32245
+ TableCatalogEntry *table;
32246
+ unique_ptr<LogicalOperator> get;
32300
32247
  };
32301
32248
  } // namespace duckdb
32302
32249
 
32303
32250
 
32304
32251
 
32305
-
32306
32252
  namespace duckdb {
32307
32253
 
32308
- struct CreateIndexInfo : public CreateInfo {
32309
- CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
32310
- }
32254
+ struct VacuumOptions {
32255
+ bool vacuum;
32256
+ bool analyze;
32257
+ };
32311
32258
 
32312
- //! Index Type (e.g., B+-tree, Skip-List, ...)
32313
- IndexType index_type;
32314
- //! Name of the Index
32315
- string index_name;
32316
- //! Index Constraint Type
32317
- IndexConstraintType constraint_type;
32318
- //! The table to create the index on
32319
- unique_ptr<BaseTableRef> table;
32320
- //! Set of expressions to index by
32321
- vector<unique_ptr<ParsedExpression>> expressions;
32322
- vector<unique_ptr<ParsedExpression>> parsed_expressions;
32259
+ struct VacuumInfo : public ParseInfo {
32260
+ public:
32261
+ explicit VacuumInfo(VacuumOptions options) : options(options), has_table(false), table(nullptr) {};
32323
32262
 
32324
- //! Types used for the CREATE INDEX scan
32325
- vector<LogicalType> scan_types;
32326
- //! The names of the columns, used for the CREATE INDEX scan
32327
- vector<string> names;
32328
- //! Column IDs needed for index creation
32329
- vector<column_t> column_ids;
32263
+ unique_ptr<VacuumInfo> Copy() {
32264
+ auto result = make_unique<VacuumInfo>(options);
32265
+ result->has_table = has_table;
32266
+ if (has_table) {
32267
+ result->ref = ref->Copy();
32268
+ }
32269
+ return result;
32270
+ }
32330
32271
 
32331
- protected:
32332
- void SerializeInternal(Serializer &serializer) const override;
32272
+ const VacuumOptions options;
32333
32273
 
32334
32274
  public:
32335
- unique_ptr<CreateInfo> Copy() const override;
32336
-
32337
- static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
32275
+ bool has_table;
32276
+ unique_ptr<TableRef> ref;
32277
+ TableCatalogEntry *table;
32278
+ unordered_map<idx_t, idx_t> column_id_map;
32279
+ vector<string> columns;
32338
32280
  };
32339
32281
 
32340
32282
  } // namespace duckdb
32341
32283
  //===----------------------------------------------------------------------===//
32342
32284
  // DuckDB
32343
32285
  //
32344
- // duckdb/parser/parsed_data/show_select_info.hpp
32286
+ // duckdb/parser/parsed_data/drop_info.hpp
32345
32287
  //
32346
32288
  //
32347
32289
  //===----------------------------------------------------------------------===//
@@ -32353,22 +32295,30 @@ public:
32353
32295
 
32354
32296
  namespace duckdb {
32355
32297
 
32356
- struct ShowSelectInfo : public ParseInfo {
32357
- //! Types of projected columns
32358
- vector<LogicalType> types;
32359
- //! The QueryNode of select query
32360
- unique_ptr<QueryNode> query;
32361
- //! Aliases of projected columns
32362
- vector<string> aliases;
32363
- //! Whether or not we are requesting a summary or a describe
32364
- bool is_summary;
32298
+ struct DropInfo : public ParseInfo {
32299
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
32300
+ }
32365
32301
 
32366
- unique_ptr<ShowSelectInfo> Copy() {
32367
- auto result = make_unique<ShowSelectInfo>();
32368
- result->types = types;
32369
- result->query = query->Copy();
32370
- result->aliases = aliases;
32371
- result->is_summary = is_summary;
32302
+ //! The catalog type to drop
32303
+ CatalogType type;
32304
+ //! Schema name to drop from, if any
32305
+ string schema;
32306
+ //! Element name to drop
32307
+ string name;
32308
+ //! Ignore if the entry does not exist instead of failing
32309
+ bool if_exists = false;
32310
+ //! Cascade drop (drop all dependents instead of throwing an error if there
32311
+ //! are any)
32312
+ bool cascade = false;
32313
+
32314
+ public:
32315
+ unique_ptr<DropInfo> Copy() const {
32316
+ auto result = make_unique<DropInfo>();
32317
+ result->type = type;
32318
+ result->schema = schema;
32319
+ result->name = name;
32320
+ result->if_exists = if_exists;
32321
+ result->cascade = cascade;
32372
32322
  return result;
32373
32323
  }
32374
32324
  };
@@ -32377,7 +32327,7 @@ struct ShowSelectInfo : public ParseInfo {
32377
32327
  //===----------------------------------------------------------------------===//
32378
32328
  // DuckDB
32379
32329
  //
32380
- // duckdb/parser/tableref/expressionlistref.hpp
32330
+ // duckdb/parser/parsed_data/create_type_info.hpp
32381
32331
  //
32382
32332
  //
32383
32333
  //===----------------------------------------------------------------------===//
@@ -32390,35 +32340,44 @@ struct ShowSelectInfo : public ParseInfo {
32390
32340
 
32391
32341
 
32392
32342
  namespace duckdb {
32393
- //! Represents an expression list as generated by a VALUES statement
32394
- class ExpressionListRef : public TableRef {
32395
- public:
32396
- ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
32343
+
32344
+ struct CreateTypeInfo : public CreateInfo {
32345
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
32346
+ }
32347
+ CreateTypeInfo(string name_p, LogicalType type_p)
32348
+ : CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
32397
32349
  }
32398
32350
 
32399
- //! Value list, only used for VALUES statement
32400
- vector<vector<unique_ptr<ParsedExpression>>> values;
32401
- //! Expected SQL types
32402
- vector<LogicalType> expected_types;
32403
- //! The set of expected names
32404
- vector<string> expected_names;
32351
+ //! Name of the Type
32352
+ string name;
32353
+ //! Logical Type
32354
+ LogicalType type;
32355
+ //! Used by create enum from query
32356
+ unique_ptr<SQLStatement> query;
32405
32357
 
32406
32358
  public:
32407
- string ToString() const override;
32408
- bool Equals(const TableRef *other_p) const override;
32409
-
32410
- unique_ptr<TableRef> Copy() override;
32359
+ unique_ptr<CreateInfo> Copy() const override {
32360
+ auto result = make_unique<CreateTypeInfo>();
32361
+ CopyProperties(*result);
32362
+ result->name = name;
32363
+ result->type = type;
32364
+ if (query) {
32365
+ result->query = query->Copy();
32366
+ }
32367
+ return move(result);
32368
+ }
32411
32369
 
32412
- //! Serializes a blob into a ExpressionListRef
32413
- void Serialize(FieldWriter &serializer) const override;
32414
- //! Deserializes a blob back into a ExpressionListRef
32415
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
32370
+ protected:
32371
+ void SerializeInternal(Serializer &) const override {
32372
+ throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
32373
+ }
32416
32374
  };
32375
+
32417
32376
  } // namespace duckdb
32418
32377
  //===----------------------------------------------------------------------===//
32419
32378
  // DuckDB
32420
32379
  //
32421
- // duckdb/parser/tableref/joinref.hpp
32380
+ // duckdb/parser/tableref/table_function_ref.hpp
32422
32381
  //
32423
32382
  //
32424
32383
  //===----------------------------------------------------------------------===//
@@ -32432,41 +32391,38 @@ public:
32432
32391
 
32433
32392
 
32434
32393
  namespace duckdb {
32435
- //! Represents a JOIN between two expressions
32436
- class JoinRef : public TableRef {
32394
+ //! Represents a Table producing function
32395
+ class TableFunctionRef : public TableRef {
32437
32396
  public:
32438
- JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
32439
- }
32397
+ DUCKDB_API TableFunctionRef();
32440
32398
 
32441
- //! The left hand side of the join
32442
- unique_ptr<TableRef> left;
32443
- //! The right hand side of the join
32444
- unique_ptr<TableRef> right;
32445
- //! The join condition
32446
- unique_ptr<ParsedExpression> condition;
32447
- //! The join type
32448
- JoinType type;
32449
- //! Natural join
32450
- bool is_natural;
32451
- //! The set of USING columns (if any)
32452
- vector<string> using_columns;
32399
+ unique_ptr<ParsedExpression> function;
32400
+ vector<string> column_name_alias;
32401
+
32402
+ // if the function takes a subquery as argument its in here
32403
+ unique_ptr<SelectStatement> subquery;
32404
+
32405
+ // External dependencies of this table funcion
32406
+ unique_ptr<ExternalDependency> external_dependency;
32453
32407
 
32454
32408
  public:
32455
32409
  string ToString() const override;
32410
+
32456
32411
  bool Equals(const TableRef *other_p) const override;
32457
32412
 
32458
32413
  unique_ptr<TableRef> Copy() override;
32459
32414
 
32460
- //! Serializes a blob into a JoinRef
32415
+ //! Serializes a blob into a BaseTableRef
32461
32416
  void Serialize(FieldWriter &serializer) const override;
32462
- //! Deserializes a blob back into a JoinRef
32417
+ //! Deserializes a blob back into a BaseTableRef
32463
32418
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
32464
32419
  };
32465
32420
  } // namespace duckdb
32421
+
32466
32422
  //===----------------------------------------------------------------------===//
32467
32423
  // DuckDB
32468
32424
  //
32469
- // duckdb/parser/tableref/subqueryref.hpp
32425
+ // duckdb/parser/tableref/crossproductref.hpp
32470
32426
  //
32471
32427
  //
32472
32428
  //===----------------------------------------------------------------------===//
@@ -32475,17 +32431,17 @@ public:
32475
32431
 
32476
32432
 
32477
32433
 
32478
-
32479
32434
  namespace duckdb {
32480
- //! Represents a subquery
32481
- class SubqueryRef : public TableRef {
32435
+ //! Represents a cross product
32436
+ class CrossProductRef : public TableRef {
32482
32437
  public:
32483
- explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
32438
+ CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
32439
+ }
32484
32440
 
32485
- //! The subquery
32486
- unique_ptr<SelectStatement> subquery;
32487
- //! Aliases for the column names
32488
- vector<string> column_name_alias;
32441
+ //! The left hand side of the cross product
32442
+ unique_ptr<TableRef> left;
32443
+ //! The right hand side of the cross product
32444
+ unique_ptr<TableRef> right;
32489
32445
 
32490
32446
  public:
32491
32447
  string ToString() const override;
@@ -32493,12 +32449,13 @@ public:
32493
32449
 
32494
32450
  unique_ptr<TableRef> Copy() override;
32495
32451
 
32496
- //! Serializes a blob into a SubqueryRef
32452
+ //! Serializes a blob into a CrossProductRef
32497
32453
  void Serialize(FieldWriter &serializer) const override;
32498
- //! Deserializes a blob back into a SubqueryRef
32454
+ //! Deserializes a blob back into a CrossProductRef
32499
32455
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
32500
32456
  };
32501
32457
  } // namespace duckdb
32458
+
32502
32459
  //===----------------------------------------------------------------------===//
32503
32460
  // DuckDB
32504
32461
  //
@@ -32530,10 +32487,11 @@ public:
32530
32487
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
32531
32488
  };
32532
32489
  } // namespace duckdb
32490
+
32533
32491
  //===----------------------------------------------------------------------===//
32534
32492
  // DuckDB
32535
32493
  //
32536
- // duckdb/parser/tableref/crossproductref.hpp
32494
+ // duckdb/parser/tableref/expressionlistref.hpp
32537
32495
  //
32538
32496
  //
32539
32497
  //===----------------------------------------------------------------------===//
@@ -32542,17 +32500,22 @@ public:
32542
32500
 
32543
32501
 
32544
32502
 
32503
+
32504
+
32505
+
32545
32506
  namespace duckdb {
32546
- //! Represents a cross product
32547
- class CrossProductRef : public TableRef {
32507
+ //! Represents an expression list as generated by a VALUES statement
32508
+ class ExpressionListRef : public TableRef {
32548
32509
  public:
32549
- CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
32510
+ ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
32550
32511
  }
32551
32512
 
32552
- //! The left hand side of the cross product
32553
- unique_ptr<TableRef> left;
32554
- //! The right hand side of the cross product
32555
- unique_ptr<TableRef> right;
32513
+ //! Value list, only used for VALUES statement
32514
+ vector<vector<unique_ptr<ParsedExpression>>> values;
32515
+ //! Expected SQL types
32516
+ vector<LogicalType> expected_types;
32517
+ //! The set of expected names
32518
+ vector<string> expected_names;
32556
32519
 
32557
32520
  public:
32558
32521
  string ToString() const override;
@@ -32560,16 +32523,17 @@ public:
32560
32523
 
32561
32524
  unique_ptr<TableRef> Copy() override;
32562
32525
 
32563
- //! Serializes a blob into a CrossProductRef
32526
+ //! Serializes a blob into a ExpressionListRef
32564
32527
  void Serialize(FieldWriter &serializer) const override;
32565
- //! Deserializes a blob back into a CrossProductRef
32528
+ //! Deserializes a blob back into a ExpressionListRef
32566
32529
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
32567
32530
  };
32568
32531
  } // namespace duckdb
32532
+
32569
32533
  //===----------------------------------------------------------------------===//
32570
32534
  // DuckDB
32571
32535
  //
32572
- // duckdb/parser/tableref/table_function_ref.hpp
32536
+ // duckdb/parser/tableref/joinref.hpp
32573
32537
  //
32574
32538
  //
32575
32539
  //===----------------------------------------------------------------------===//
@@ -32583,37 +32547,73 @@ public:
32583
32547
 
32584
32548
 
32585
32549
  namespace duckdb {
32586
- //! Represents a Table producing function
32587
- class TableFunctionRef : public TableRef {
32550
+ //! Represents a JOIN between two expressions
32551
+ class JoinRef : public TableRef {
32588
32552
  public:
32589
- DUCKDB_API TableFunctionRef();
32590
-
32591
- unique_ptr<ParsedExpression> function;
32592
- vector<string> column_name_alias;
32593
-
32594
- // if the function takes a subquery as argument its in here
32595
- unique_ptr<SelectStatement> subquery;
32553
+ JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
32554
+ }
32596
32555
 
32597
- // External dependencies of this table funcion
32598
- unique_ptr<ExternalDependency> external_dependency;
32556
+ //! The left hand side of the join
32557
+ unique_ptr<TableRef> left;
32558
+ //! The right hand side of the join
32559
+ unique_ptr<TableRef> right;
32560
+ //! The join condition
32561
+ unique_ptr<ParsedExpression> condition;
32562
+ //! The join type
32563
+ JoinType type;
32564
+ //! Natural join
32565
+ bool is_natural;
32566
+ //! The set of USING columns (if any)
32567
+ vector<string> using_columns;
32599
32568
 
32600
32569
  public:
32601
32570
  string ToString() const override;
32602
-
32603
32571
  bool Equals(const TableRef *other_p) const override;
32604
32572
 
32605
32573
  unique_ptr<TableRef> Copy() override;
32606
32574
 
32607
- //! Serializes a blob into a BaseTableRef
32575
+ //! Serializes a blob into a JoinRef
32608
32576
  void Serialize(FieldWriter &serializer) const override;
32609
- //! Deserializes a blob back into a BaseTableRef
32577
+ //! Deserializes a blob back into a JoinRef
32610
32578
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
32611
32579
  };
32612
32580
  } // namespace duckdb
32613
32581
 
32582
+ //===----------------------------------------------------------------------===//
32583
+ // DuckDB
32584
+ //
32585
+ // duckdb/parser/tableref/subqueryref.hpp
32586
+ //
32587
+ //
32588
+ //===----------------------------------------------------------------------===//
32589
+
32590
+
32591
+
32592
+
32593
+
32594
+
32595
+ namespace duckdb {
32596
+ //! Represents a subquery
32597
+ class SubqueryRef : public TableRef {
32598
+ public:
32599
+ explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
32614
32600
 
32601
+ //! The subquery
32602
+ unique_ptr<SelectStatement> subquery;
32603
+ //! Aliases for the column names
32604
+ vector<string> column_name_alias;
32615
32605
 
32606
+ public:
32607
+ string ToString() const override;
32608
+ bool Equals(const TableRef *other_p) const override;
32616
32609
 
32610
+ unique_ptr<TableRef> Copy() override;
32617
32611
 
32612
+ //! Serializes a blob into a SubqueryRef
32613
+ void Serialize(FieldWriter &serializer) const override;
32614
+ //! Deserializes a blob back into a SubqueryRef
32615
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
32616
+ };
32617
+ } // namespace duckdb
32618
32618
 
32619
32619