duckdb 0.4.1-dev55.0 → 0.4.1-dev68.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 "5b3021280"
15
- #define DUCKDB_VERSION "v0.4.1-dev55"
14
+ #define DUCKDB_SOURCE_ID "995622ad3"
15
+ #define DUCKDB_VERSION "v0.4.1-dev68"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -18876,6 +18876,10 @@ namespace duckdb {
18876
18876
  //! The Date class is a static class that holds helper functions for the Date type.
18877
18877
  class Date {
18878
18878
  public:
18879
+ static const char *PINF; // NOLINT
18880
+ static const char *NINF; // NOLINT
18881
+ static const char *EPOCH; // NOLINT
18882
+
18879
18883
  static const string_t MONTH_NAMES[12];
18880
18884
  static const string_t MONTH_NAMES_ABBREVIATED[12];
18881
18885
  static const string_t DAY_NAMES[7];
@@ -22965,7 +22969,7 @@ private:
22965
22969
  //===----------------------------------------------------------------------===//
22966
22970
  // DuckDB
22967
22971
  //
22968
- // duckdb/parser/expression/conjunction_expression.hpp
22972
+ // duckdb/parser/expression/between_expression.hpp
22969
22973
  //
22970
22974
  //
22971
22975
  //===----------------------------------------------------------------------===//
@@ -22974,25 +22978,21 @@ private:
22974
22978
 
22975
22979
 
22976
22980
 
22977
-
22978
22981
  namespace duckdb {
22979
22982
 
22980
- //! Represents a conjunction (AND/OR)
22981
- class ConjunctionExpression : public ParsedExpression {
22983
+ class BetweenExpression : public ParsedExpression {
22982
22984
  public:
22983
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22984
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22985
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22986
- unique_ptr<ParsedExpression> right);
22985
+ DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22986
+ unique_ptr<ParsedExpression> upper);
22987
22987
 
22988
- vector<unique_ptr<ParsedExpression>> children;
22988
+ unique_ptr<ParsedExpression> input;
22989
+ unique_ptr<ParsedExpression> lower;
22990
+ unique_ptr<ParsedExpression> upper;
22989
22991
 
22990
22992
  public:
22991
- void AddExpression(unique_ptr<ParsedExpression> expr);
22992
-
22993
22993
  string ToString() const override;
22994
22994
 
22995
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22995
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22996
22996
 
22997
22997
  unique_ptr<ParsedExpression> Copy() const override;
22998
22998
 
@@ -23002,18 +23002,16 @@ public:
23002
23002
  public:
23003
23003
  template <class T, class BASE>
23004
23004
  static string ToString(const T &entry) {
23005
- string result = "(" + entry.children[0]->ToString();
23006
- for (idx_t i = 1; i < entry.children.size(); i++) {
23007
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
23008
- }
23009
- return result + ")";
23005
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
23010
23006
  }
23011
23007
  };
23012
23008
  } // namespace duckdb
23009
+
23010
+
23013
23011
  //===----------------------------------------------------------------------===//
23014
23012
  // DuckDB
23015
23013
  //
23016
- // duckdb/parser/expression/positional_reference_expression.hpp
23014
+ // duckdb/parser/expression/case_expression.hpp
23017
23015
  //
23018
23016
  //
23019
23017
  //===----------------------------------------------------------------------===//
@@ -23022,32 +23020,51 @@ public:
23022
23020
 
23023
23021
 
23024
23022
 
23023
+
23025
23024
  namespace duckdb {
23026
- class PositionalReferenceExpression : public ParsedExpression {
23027
- public:
23028
- DUCKDB_API PositionalReferenceExpression(idx_t index);
23029
23025
 
23030
- idx_t index;
23026
+ struct CaseCheck {
23027
+ unique_ptr<ParsedExpression> when_expr;
23028
+ unique_ptr<ParsedExpression> then_expr;
23029
+ };
23031
23030
 
23031
+ //! The CaseExpression represents a CASE expression in the query
23032
+ class CaseExpression : public ParsedExpression {
23032
23033
  public:
23033
- bool IsScalar() const override {
23034
- return false;
23035
- }
23034
+ DUCKDB_API CaseExpression();
23035
+
23036
+ vector<CaseCheck> case_checks;
23037
+ unique_ptr<ParsedExpression> else_expr;
23036
23038
 
23039
+ public:
23037
23040
  string ToString() const override;
23038
23041
 
23039
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
23042
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
23043
+
23040
23044
  unique_ptr<ParsedExpression> Copy() const override;
23041
- hash_t Hash() const override;
23042
23045
 
23043
23046
  void Serialize(FieldWriter &writer) const override;
23044
23047
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23048
+
23049
+ public:
23050
+ template <class T, class BASE>
23051
+ static string ToString(const T &entry) {
23052
+ string case_str = "CASE ";
23053
+ for (auto &check : entry.case_checks) {
23054
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
23055
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
23056
+ }
23057
+ case_str += " ELSE " + entry.else_expr->ToString();
23058
+ case_str += " END";
23059
+ return case_str;
23060
+ }
23045
23061
  };
23046
23062
  } // namespace duckdb
23063
+
23047
23064
  //===----------------------------------------------------------------------===//
23048
23065
  // DuckDB
23049
23066
  //
23050
- // duckdb/parser/expression/star_expression.hpp
23067
+ // duckdb/parser/expression/cast_expression.hpp
23051
23068
  //
23052
23069
  //
23053
23070
  //===----------------------------------------------------------------------===//
@@ -23059,33 +23076,41 @@ public:
23059
23076
 
23060
23077
  namespace duckdb {
23061
23078
 
23062
- //! Represents a * expression in the SELECT clause
23063
- class StarExpression : public ParsedExpression {
23079
+ //! CastExpression represents a type cast from one SQL type to another SQL type
23080
+ class CastExpression : public ParsedExpression {
23064
23081
  public:
23065
- StarExpression(string relation_name = string());
23082
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
23066
23083
 
23067
- //! The relation name in case of tbl.*, or empty if this is a normal *
23068
- string relation_name;
23069
- //! List of columns to exclude from the STAR expression
23070
- case_insensitive_set_t exclude_list;
23071
- //! List of columns to replace with another expression
23072
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23084
+ //! The child of the cast expression
23085
+ unique_ptr<ParsedExpression> child;
23086
+ //! The type to cast to
23087
+ LogicalType cast_type;
23088
+ //! Whether or not this is a try_cast expression
23089
+ bool try_cast;
23073
23090
 
23074
23091
  public:
23075
23092
  string ToString() const override;
23076
23093
 
23077
- static bool Equals(const StarExpression *a, const StarExpression *b);
23094
+ static bool Equals(const CastExpression *a, const CastExpression *b);
23078
23095
 
23079
23096
  unique_ptr<ParsedExpression> Copy() const override;
23080
23097
 
23081
23098
  void Serialize(FieldWriter &writer) const override;
23082
23099
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23100
+
23101
+ public:
23102
+ template <class T, class BASE>
23103
+ static string ToString(const T &entry) {
23104
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
23105
+ entry.cast_type.ToString() + ")";
23106
+ }
23083
23107
  };
23084
23108
  } // namespace duckdb
23109
+
23085
23110
  //===----------------------------------------------------------------------===//
23086
23111
  // DuckDB
23087
23112
  //
23088
- // duckdb/parser/expression/operator_expression.hpp
23113
+ // duckdb/parser/expression/collate_expression.hpp
23089
23114
  //
23090
23115
  //
23091
23116
  //===----------------------------------------------------------------------===//
@@ -23094,98 +23119,35 @@ public:
23094
23119
 
23095
23120
 
23096
23121
 
23097
-
23098
-
23099
-
23100
23122
  namespace duckdb {
23101
- //! Represents a built-in operator expression
23102
- class OperatorExpression : public ParsedExpression {
23123
+
23124
+ //! CollateExpression represents a COLLATE statement
23125
+ class CollateExpression : public ParsedExpression {
23103
23126
  public:
23104
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
23105
- unique_ptr<ParsedExpression> right = nullptr);
23106
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23127
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
23107
23128
 
23108
- vector<unique_ptr<ParsedExpression>> children;
23129
+ //! The child of the cast expression
23130
+ unique_ptr<ParsedExpression> child;
23131
+ //! The collation clause
23132
+ string collation;
23109
23133
 
23110
23134
  public:
23111
23135
  string ToString() const override;
23112
23136
 
23113
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23137
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
23114
23138
 
23115
23139
  unique_ptr<ParsedExpression> Copy() const override;
23116
23140
 
23117
23141
  void Serialize(FieldWriter &writer) const override;
23118
23142
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23119
-
23120
- public:
23121
- template <class T, class BASE>
23122
- static string ToString(const T &entry) {
23123
- auto op = ExpressionTypeToOperator(entry.type);
23124
- if (!op.empty()) {
23125
- // use the operator string to represent the operator
23126
- D_ASSERT(entry.children.size() == 2);
23127
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23128
- }
23129
- switch (entry.type) {
23130
- case ExpressionType::COMPARE_IN:
23131
- case ExpressionType::COMPARE_NOT_IN: {
23132
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23133
- string in_child = entry.children[0]->ToString();
23134
- string child_list = "(";
23135
- for (idx_t i = 1; i < entry.children.size(); i++) {
23136
- if (i > 1) {
23137
- child_list += ", ";
23138
- }
23139
- child_list += entry.children[i]->ToString();
23140
- }
23141
- child_list += ")";
23142
- return "(" + in_child + op_type + child_list + ")";
23143
- }
23144
- case ExpressionType::OPERATOR_NOT:
23145
- case ExpressionType::GROUPING_FUNCTION:
23146
- case ExpressionType::OPERATOR_COALESCE: {
23147
- string result = ExpressionTypeToString(entry.type);
23148
- result += "(";
23149
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23150
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23151
- result += ")";
23152
- return result;
23153
- }
23154
- case ExpressionType::OPERATOR_IS_NULL:
23155
- return "(" + entry.children[0]->ToString() + " IS NULL)";
23156
- case ExpressionType::OPERATOR_IS_NOT_NULL:
23157
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23158
- case ExpressionType::ARRAY_EXTRACT:
23159
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23160
- case ExpressionType::ARRAY_SLICE:
23161
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23162
- entry.children[2]->ToString() + "]";
23163
- case ExpressionType::STRUCT_EXTRACT: {
23164
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
23165
- auto child_string = entry.children[1]->ToString();
23166
- D_ASSERT(child_string.size() >= 3);
23167
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23168
- return "(" + entry.children[0]->ToString() + ")." +
23169
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23170
- }
23171
- case ExpressionType::ARRAY_CONSTRUCTOR: {
23172
- string result = "(ARRAY[";
23173
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23174
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23175
- result += "])";
23176
- return result;
23177
- }
23178
- default:
23179
- throw InternalException("Unrecognized operator type");
23180
- }
23181
- }
23182
23143
  };
23183
-
23184
23144
  } // namespace duckdb
23145
+
23146
+
23185
23147
  //===----------------------------------------------------------------------===//
23186
23148
  // DuckDB
23187
23149
  //
23188
- // duckdb/parser/expression/constant_expression.hpp
23150
+ // duckdb/parser/expression/comparison_expression.hpp
23189
23151
  //
23190
23152
  //
23191
23153
  //===----------------------------------------------------------------------===//
@@ -23194,34 +23156,39 @@ public:
23194
23156
 
23195
23157
 
23196
23158
 
23197
-
23198
23159
  namespace duckdb {
23199
-
23200
- //! ConstantExpression represents a constant value in the query
23201
- class ConstantExpression : public ParsedExpression {
23160
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
23161
+ //! and has two children.
23162
+ class ComparisonExpression : public ParsedExpression {
23202
23163
  public:
23203
- DUCKDB_API explicit ConstantExpression(Value val);
23164
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23165
+ unique_ptr<ParsedExpression> right);
23204
23166
 
23205
- //! The constant value referenced
23206
- Value value;
23167
+ unique_ptr<ParsedExpression> left;
23168
+ unique_ptr<ParsedExpression> right;
23207
23169
 
23208
23170
  public:
23209
23171
  string ToString() const override;
23210
23172
 
23211
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
23212
- hash_t Hash() const override;
23173
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
23213
23174
 
23214
23175
  unique_ptr<ParsedExpression> Copy() const override;
23215
23176
 
23216
23177
  void Serialize(FieldWriter &writer) const override;
23217
23178
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23218
- };
23219
23179
 
23180
+ public:
23181
+ template <class T, class BASE>
23182
+ static string ToString(const T &entry) {
23183
+ return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
23184
+ }
23185
+ };
23220
23186
  } // namespace duckdb
23187
+
23221
23188
  //===----------------------------------------------------------------------===//
23222
23189
  // DuckDB
23223
23190
  //
23224
- // duckdb/parser/expression/subquery_expression.hpp
23191
+ // duckdb/parser/expression/conjunction_expression.hpp
23225
23192
  //
23226
23193
  //
23227
23194
  //===----------------------------------------------------------------------===//
@@ -23231,46 +23198,46 @@ public:
23231
23198
 
23232
23199
 
23233
23200
 
23234
-
23235
23201
  namespace duckdb {
23236
23202
 
23237
- //! Represents a subquery
23238
- class SubqueryExpression : public ParsedExpression {
23203
+ //! Represents a conjunction (AND/OR)
23204
+ class ConjunctionExpression : public ParsedExpression {
23239
23205
  public:
23240
- SubqueryExpression();
23206
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
23207
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23208
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23209
+ unique_ptr<ParsedExpression> right);
23241
23210
 
23242
- //! The actual subquery
23243
- unique_ptr<SelectStatement> subquery;
23244
- //! The subquery type
23245
- SubqueryType subquery_type;
23246
- //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
23247
- //! subquery)
23248
- unique_ptr<ParsedExpression> child;
23249
- //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
23250
- ExpressionType comparison_type;
23211
+ vector<unique_ptr<ParsedExpression>> children;
23251
23212
 
23252
23213
  public:
23253
- bool HasSubquery() const override {
23254
- return true;
23255
- }
23256
- bool IsScalar() const override {
23257
- return false;
23258
- }
23214
+ void AddExpression(unique_ptr<ParsedExpression> expr);
23259
23215
 
23260
23216
  string ToString() const override;
23261
23217
 
23262
- static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
23218
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
23263
23219
 
23264
23220
  unique_ptr<ParsedExpression> Copy() const override;
23265
23221
 
23266
23222
  void Serialize(FieldWriter &writer) const override;
23267
23223
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23224
+
23225
+ public:
23226
+ template <class T, class BASE>
23227
+ static string ToString(const T &entry) {
23228
+ string result = "(" + entry.children[0]->ToString();
23229
+ for (idx_t i = 1; i < entry.children.size(); i++) {
23230
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
23231
+ }
23232
+ return result + ")";
23233
+ }
23268
23234
  };
23269
23235
  } // namespace duckdb
23236
+
23270
23237
  //===----------------------------------------------------------------------===//
23271
23238
  // DuckDB
23272
23239
  //
23273
- // duckdb/parser/expression/parameter_expression.hpp
23240
+ // duckdb/parser/expression/constant_expression.hpp
23274
23241
  //
23275
23242
  //
23276
23243
  //===----------------------------------------------------------------------===//
@@ -23279,70 +23246,31 @@ public:
23279
23246
 
23280
23247
 
23281
23248
 
23282
- namespace duckdb {
23283
- class ParameterExpression : public ParsedExpression {
23284
- public:
23285
- ParameterExpression();
23286
-
23287
- idx_t parameter_nr;
23288
-
23289
- public:
23290
- bool IsScalar() const override {
23291
- return true;
23292
- }
23293
- bool HasParameter() const override {
23294
- return true;
23295
- }
23296
-
23297
- string ToString() const override;
23298
-
23299
- unique_ptr<ParsedExpression> Copy() const override;
23300
- hash_t Hash() const override;
23301
-
23302
- void Serialize(FieldWriter &writer) const override;
23303
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23304
- };
23305
- } // namespace duckdb
23306
- //===----------------------------------------------------------------------===//
23307
- // DuckDB
23308
- //
23309
- // duckdb/parser/expression/between_expression.hpp
23310
- //
23311
- //
23312
- //===----------------------------------------------------------------------===//
23313
-
23314
-
23315
-
23316
-
23317
23249
 
23318
23250
  namespace duckdb {
23319
23251
 
23320
- class BetweenExpression : public ParsedExpression {
23252
+ //! ConstantExpression represents a constant value in the query
23253
+ class ConstantExpression : public ParsedExpression {
23321
23254
  public:
23322
- DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
23323
- unique_ptr<ParsedExpression> upper);
23255
+ DUCKDB_API explicit ConstantExpression(Value val);
23324
23256
 
23325
- unique_ptr<ParsedExpression> input;
23326
- unique_ptr<ParsedExpression> lower;
23327
- unique_ptr<ParsedExpression> upper;
23257
+ //! The constant value referenced
23258
+ Value value;
23328
23259
 
23329
23260
  public:
23330
23261
  string ToString() const override;
23331
23262
 
23332
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
23263
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
23264
+ hash_t Hash() const override;
23333
23265
 
23334
23266
  unique_ptr<ParsedExpression> Copy() const override;
23335
23267
 
23336
23268
  void Serialize(FieldWriter &writer) const override;
23337
23269
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23338
-
23339
- public:
23340
- template <class T, class BASE>
23341
- static string ToString(const T &entry) {
23342
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
23343
- }
23344
23270
  };
23271
+
23345
23272
  } // namespace duckdb
23273
+
23346
23274
  //===----------------------------------------------------------------------===//
23347
23275
  // DuckDB
23348
23276
  //
@@ -23375,187 +23303,6 @@ public:
23375
23303
  };
23376
23304
  } // namespace duckdb
23377
23305
 
23378
-
23379
- //===----------------------------------------------------------------------===//
23380
- // DuckDB
23381
- //
23382
- // duckdb/parser/expression/case_expression.hpp
23383
- //
23384
- //
23385
- //===----------------------------------------------------------------------===//
23386
-
23387
-
23388
-
23389
-
23390
-
23391
-
23392
- namespace duckdb {
23393
-
23394
- struct CaseCheck {
23395
- unique_ptr<ParsedExpression> when_expr;
23396
- unique_ptr<ParsedExpression> then_expr;
23397
- };
23398
-
23399
- //! The CaseExpression represents a CASE expression in the query
23400
- class CaseExpression : public ParsedExpression {
23401
- public:
23402
- DUCKDB_API CaseExpression();
23403
-
23404
- vector<CaseCheck> case_checks;
23405
- unique_ptr<ParsedExpression> else_expr;
23406
-
23407
- public:
23408
- string ToString() const override;
23409
-
23410
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
23411
-
23412
- unique_ptr<ParsedExpression> Copy() const override;
23413
-
23414
- void Serialize(FieldWriter &writer) const override;
23415
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23416
-
23417
- public:
23418
- template <class T, class BASE>
23419
- static string ToString(const T &entry) {
23420
- string case_str = "CASE ";
23421
- for (auto &check : entry.case_checks) {
23422
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
23423
- case_str += " THEN (" + check.then_expr->ToString() + ")";
23424
- }
23425
- case_str += " ELSE " + entry.else_expr->ToString();
23426
- case_str += " END";
23427
- return case_str;
23428
- }
23429
- };
23430
- } // namespace duckdb
23431
-
23432
- //===----------------------------------------------------------------------===//
23433
- // DuckDB
23434
- //
23435
- // duckdb/parser/expression/cast_expression.hpp
23436
- //
23437
- //
23438
- //===----------------------------------------------------------------------===//
23439
-
23440
-
23441
-
23442
-
23443
-
23444
-
23445
- namespace duckdb {
23446
-
23447
- //! CastExpression represents a type cast from one SQL type to another SQL type
23448
- class CastExpression : public ParsedExpression {
23449
- public:
23450
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
23451
-
23452
- //! The child of the cast expression
23453
- unique_ptr<ParsedExpression> child;
23454
- //! The type to cast to
23455
- LogicalType cast_type;
23456
- //! Whether or not this is a try_cast expression
23457
- bool try_cast;
23458
-
23459
- public:
23460
- string ToString() const override;
23461
-
23462
- static bool Equals(const CastExpression *a, const CastExpression *b);
23463
-
23464
- unique_ptr<ParsedExpression> Copy() const override;
23465
-
23466
- void Serialize(FieldWriter &writer) const override;
23467
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23468
-
23469
- public:
23470
- template <class T, class BASE>
23471
- static string ToString(const T &entry) {
23472
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
23473
- entry.cast_type.ToString() + ")";
23474
- }
23475
- };
23476
- } // namespace duckdb
23477
-
23478
- //===----------------------------------------------------------------------===//
23479
- // DuckDB
23480
- //
23481
- // duckdb/parser/expression/collate_expression.hpp
23482
- //
23483
- //
23484
- //===----------------------------------------------------------------------===//
23485
-
23486
-
23487
-
23488
-
23489
-
23490
- namespace duckdb {
23491
-
23492
- //! CollateExpression represents a COLLATE statement
23493
- class CollateExpression : public ParsedExpression {
23494
- public:
23495
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
23496
-
23497
- //! The child of the cast expression
23498
- unique_ptr<ParsedExpression> child;
23499
- //! The collation clause
23500
- string collation;
23501
-
23502
- public:
23503
- string ToString() const override;
23504
-
23505
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
23506
-
23507
- unique_ptr<ParsedExpression> Copy() const override;
23508
-
23509
- void Serialize(FieldWriter &writer) const override;
23510
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23511
- };
23512
- } // namespace duckdb
23513
-
23514
-
23515
- //===----------------------------------------------------------------------===//
23516
- // DuckDB
23517
- //
23518
- // duckdb/parser/expression/comparison_expression.hpp
23519
- //
23520
- //
23521
- //===----------------------------------------------------------------------===//
23522
-
23523
-
23524
-
23525
-
23526
-
23527
- namespace duckdb {
23528
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
23529
- //! and has two children.
23530
- class ComparisonExpression : public ParsedExpression {
23531
- public:
23532
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23533
- unique_ptr<ParsedExpression> right);
23534
-
23535
- unique_ptr<ParsedExpression> left;
23536
- unique_ptr<ParsedExpression> right;
23537
-
23538
- public:
23539
- string ToString() const override;
23540
-
23541
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
23542
-
23543
- unique_ptr<ParsedExpression> Copy() const override;
23544
-
23545
- void Serialize(FieldWriter &writer) const override;
23546
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23547
-
23548
- public:
23549
- template <class T, class BASE>
23550
- static string ToString(const T &entry) {
23551
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
23552
- }
23553
- };
23554
- } // namespace duckdb
23555
-
23556
-
23557
-
23558
-
23559
23306
  //===----------------------------------------------------------------------===//
23560
23307
  // DuckDB
23561
23308
  //
@@ -23714,16 +23461,10 @@ public:
23714
23461
 
23715
23462
  } // namespace duckdb
23716
23463
 
23717
-
23718
-
23719
-
23720
-
23721
-
23722
-
23723
23464
  //===----------------------------------------------------------------------===//
23724
23465
  // DuckDB
23725
23466
  //
23726
- // duckdb/parser/parsed_data/vacuum_info.hpp
23467
+ // duckdb/parser/expression/operator_expression.hpp
23727
23468
  //
23728
23469
  //
23729
23470
  //===----------------------------------------------------------------------===//
@@ -23732,28 +23473,99 @@ public:
23732
23473
 
23733
23474
 
23734
23475
 
23735
- namespace duckdb {
23736
23476
 
23737
- enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23738
23477
 
23739
- struct LoadInfo : public ParseInfo {
23740
- std::string filename;
23741
- LoadType load_type;
23742
23478
 
23479
+ namespace duckdb {
23480
+ //! Represents a built-in operator expression
23481
+ class OperatorExpression : public ParsedExpression {
23743
23482
  public:
23744
- unique_ptr<LoadInfo> Copy() const {
23745
- auto result = make_unique<LoadInfo>();
23746
- result->filename = filename;
23747
- result->load_type = load_type;
23748
- return result;
23483
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
23484
+ unique_ptr<ParsedExpression> right = nullptr);
23485
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23486
+
23487
+ vector<unique_ptr<ParsedExpression>> children;
23488
+
23489
+ public:
23490
+ string ToString() const override;
23491
+
23492
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23493
+
23494
+ unique_ptr<ParsedExpression> Copy() const override;
23495
+
23496
+ void Serialize(FieldWriter &writer) const override;
23497
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23498
+
23499
+ public:
23500
+ template <class T, class BASE>
23501
+ static string ToString(const T &entry) {
23502
+ auto op = ExpressionTypeToOperator(entry.type);
23503
+ if (!op.empty()) {
23504
+ // use the operator string to represent the operator
23505
+ D_ASSERT(entry.children.size() == 2);
23506
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23507
+ }
23508
+ switch (entry.type) {
23509
+ case ExpressionType::COMPARE_IN:
23510
+ case ExpressionType::COMPARE_NOT_IN: {
23511
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23512
+ string in_child = entry.children[0]->ToString();
23513
+ string child_list = "(";
23514
+ for (idx_t i = 1; i < entry.children.size(); i++) {
23515
+ if (i > 1) {
23516
+ child_list += ", ";
23517
+ }
23518
+ child_list += entry.children[i]->ToString();
23519
+ }
23520
+ child_list += ")";
23521
+ return "(" + in_child + op_type + child_list + ")";
23522
+ }
23523
+ case ExpressionType::OPERATOR_NOT:
23524
+ case ExpressionType::GROUPING_FUNCTION:
23525
+ case ExpressionType::OPERATOR_COALESCE: {
23526
+ string result = ExpressionTypeToString(entry.type);
23527
+ result += "(";
23528
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23529
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23530
+ result += ")";
23531
+ return result;
23532
+ }
23533
+ case ExpressionType::OPERATOR_IS_NULL:
23534
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
23535
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
23536
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23537
+ case ExpressionType::ARRAY_EXTRACT:
23538
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23539
+ case ExpressionType::ARRAY_SLICE:
23540
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23541
+ entry.children[2]->ToString() + "]";
23542
+ case ExpressionType::STRUCT_EXTRACT: {
23543
+ D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
23544
+ auto child_string = entry.children[1]->ToString();
23545
+ D_ASSERT(child_string.size() >= 3);
23546
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23547
+ return "(" + entry.children[0]->ToString() + ")." +
23548
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23549
+ }
23550
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
23551
+ string result = "(ARRAY[";
23552
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23553
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23554
+ result += "])";
23555
+ return result;
23556
+ }
23557
+ default:
23558
+ throw InternalException("Unrecognized operator type");
23559
+ }
23749
23560
  }
23750
23561
  };
23751
23562
 
23752
23563
  } // namespace duckdb
23564
+
23753
23565
  //===----------------------------------------------------------------------===//
23754
23566
  // DuckDB
23755
23567
  //
23756
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23568
+ // duckdb/parser/expression/parameter_expression.hpp
23757
23569
  //
23758
23570
  //
23759
23571
  //===----------------------------------------------------------------------===//
@@ -23762,38 +23574,35 @@ public:
23762
23574
 
23763
23575
 
23764
23576
 
23765
-
23766
23577
  namespace duckdb {
23578
+ class ParameterExpression : public ParsedExpression {
23579
+ public:
23580
+ ParameterExpression();
23767
23581
 
23768
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23769
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
23770
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23771
- functions.push_back(move(function));
23772
- this->name = function.name;
23582
+ idx_t parameter_nr;
23583
+
23584
+ public:
23585
+ bool IsScalar() const override {
23586
+ return true;
23773
23587
  }
23774
- CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23775
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23776
- this->name = name;
23777
- for (auto &function : functions) {
23778
- function.name = name;
23779
- }
23588
+ bool HasParameter() const override {
23589
+ return true;
23780
23590
  }
23781
23591
 
23782
- vector<PragmaFunction> functions;
23592
+ string ToString() const override;
23783
23593
 
23784
- public:
23785
- unique_ptr<CreateInfo> Copy() const override {
23786
- auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23787
- CopyProperties(*result);
23788
- return move(result);
23789
- }
23790
- };
23594
+ unique_ptr<ParsedExpression> Copy() const override;
23595
+ hash_t Hash() const override;
23791
23596
 
23597
+ void Serialize(FieldWriter &writer) const override;
23598
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23599
+ };
23792
23600
  } // namespace duckdb
23601
+
23793
23602
  //===----------------------------------------------------------------------===//
23794
23603
  // DuckDB
23795
23604
  //
23796
- // duckdb/parser/parsed_data/drop_info.hpp
23605
+ // duckdb/parser/expression/positional_reference_expression.hpp
23797
23606
  //
23798
23607
  //
23799
23608
  //===----------------------------------------------------------------------===//
@@ -23802,42 +23611,33 @@ public:
23802
23611
 
23803
23612
 
23804
23613
 
23805
-
23806
23614
  namespace duckdb {
23615
+ class PositionalReferenceExpression : public ParsedExpression {
23616
+ public:
23617
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
23807
23618
 
23808
- struct DropInfo : public ParseInfo {
23809
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23810
- }
23811
-
23812
- //! The catalog type to drop
23813
- CatalogType type;
23814
- //! Schema name to drop from, if any
23815
- string schema;
23816
- //! Element name to drop
23817
- string name;
23818
- //! Ignore if the entry does not exist instead of failing
23819
- bool if_exists = false;
23820
- //! Cascade drop (drop all dependents instead of throwing an error if there
23821
- //! are any)
23822
- bool cascade = false;
23619
+ idx_t index;
23823
23620
 
23824
23621
  public:
23825
- unique_ptr<DropInfo> Copy() const {
23826
- auto result = make_unique<DropInfo>();
23827
- result->type = type;
23828
- result->schema = schema;
23829
- result->name = name;
23830
- result->if_exists = if_exists;
23831
- result->cascade = cascade;
23832
- return result;
23622
+ bool IsScalar() const override {
23623
+ return false;
23833
23624
  }
23834
- };
23835
23625
 
23626
+ string ToString() const override;
23627
+
23628
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
23629
+ unique_ptr<ParsedExpression> Copy() const override;
23630
+ hash_t Hash() const override;
23631
+
23632
+ void Serialize(FieldWriter &writer) const override;
23633
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23634
+ };
23836
23635
  } // namespace duckdb
23636
+
23837
23637
  //===----------------------------------------------------------------------===//
23838
23638
  // DuckDB
23839
23639
  //
23840
- // duckdb/parser/parsed_data/transaction_info.hpp
23640
+ // duckdb/parser/expression/star_expression.hpp
23841
23641
  //
23842
23642
  //
23843
23643
  //===----------------------------------------------------------------------===//
@@ -23846,42 +23646,42 @@ public:
23846
23646
 
23847
23647
 
23848
23648
 
23849
- namespace duckdb {
23850
23649
 
23851
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
23650
+ namespace duckdb {
23852
23651
 
23853
- struct TransactionInfo : public ParseInfo {
23854
- explicit TransactionInfo(TransactionType type) : type(type) {
23855
- }
23652
+ //! Represents a * expression in the SELECT clause
23653
+ class StarExpression : public ParsedExpression {
23654
+ public:
23655
+ StarExpression(string relation_name = string());
23856
23656
 
23857
- //! The type of transaction statement
23858
- TransactionType type;
23859
- };
23657
+ //! The relation name in case of tbl.*, or empty if this is a normal *
23658
+ string relation_name;
23659
+ //! List of columns to exclude from the STAR expression
23660
+ case_insensitive_set_t exclude_list;
23661
+ //! List of columns to replace with another expression
23662
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23860
23663
 
23861
- } // namespace duckdb
23862
- //===----------------------------------------------------------------------===//
23863
- // DuckDB
23864
- //
23865
- // duckdb/parser/parsed_data/create_macro_info.hpp
23866
- //
23867
- //
23868
- //===----------------------------------------------------------------------===//
23664
+ public:
23665
+ string ToString() const override;
23869
23666
 
23667
+ static bool Equals(const StarExpression *a, const StarExpression *b);
23870
23668
 
23669
+ unique_ptr<ParsedExpression> Copy() const override;
23871
23670
 
23671
+ void Serialize(FieldWriter &writer) const override;
23672
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23673
+ };
23674
+ } // namespace duckdb
23872
23675
 
23873
23676
  //===----------------------------------------------------------------------===//
23874
23677
  // DuckDB
23875
23678
  //
23876
- // duckdb/function/macro_function.hpp
23679
+ // duckdb/parser/expression/subquery_expression.hpp
23877
23680
  //
23878
23681
  //
23879
23682
  //===----------------------------------------------------------------------===//
23880
23683
 
23881
23684
 
23882
- //! The SelectStatement of the view
23883
-
23884
-
23885
23685
 
23886
23686
 
23887
23687
 
@@ -23889,64 +23689,45 @@ struct TransactionInfo : public ParseInfo {
23889
23689
 
23890
23690
  namespace duckdb {
23891
23691
 
23892
- enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
23893
-
23894
- class MacroFunction {
23692
+ //! Represents a subquery
23693
+ class SubqueryExpression : public ParsedExpression {
23895
23694
  public:
23896
- // explicit MacroFunction(unique_ptr<ParsedExpression> expression);
23897
- MacroFunction(MacroType type);
23695
+ SubqueryExpression();
23898
23696
 
23899
- // MacroFunction(void);
23900
- // The type
23901
- MacroType type;
23902
- //! The positional parameters
23903
- vector<unique_ptr<ParsedExpression>> parameters;
23904
- //! The default parameters and their associated values
23905
- unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
23697
+ //! The actual subquery
23698
+ unique_ptr<SelectStatement> subquery;
23699
+ //! The subquery type
23700
+ SubqueryType subquery_type;
23701
+ //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
23702
+ //! subquery)
23703
+ unique_ptr<ParsedExpression> child;
23704
+ //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
23705
+ ExpressionType comparison_type;
23906
23706
 
23907
23707
  public:
23908
- virtual ~MacroFunction() {
23708
+ bool HasSubquery() const override {
23709
+ return true;
23710
+ }
23711
+ bool IsScalar() const override {
23712
+ return false;
23909
23713
  }
23910
23714
 
23911
- void CopyProperties(MacroFunction &other);
23715
+ string ToString() const override;
23912
23716
 
23913
- virtual unique_ptr<MacroFunction> Copy() = 0;
23717
+ static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
23914
23718
 
23915
- static string ValidateArguments(MacroFunction &macro_function, const string &name,
23916
- FunctionExpression &function_expr,
23917
- vector<unique_ptr<ParsedExpression>> &positionals,
23918
- unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
23919
- };
23719
+ unique_ptr<ParsedExpression> Copy() const override;
23920
23720
 
23721
+ void Serialize(FieldWriter &writer) const override;
23722
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23723
+ };
23921
23724
  } // namespace duckdb
23922
23725
 
23923
23726
 
23924
- namespace duckdb {
23925
-
23926
- struct CreateMacroInfo : public CreateFunctionInfo {
23927
- CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
23928
- }
23929
-
23930
- CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
23931
- }
23932
-
23933
- unique_ptr<MacroFunction> function;
23934
-
23935
- public:
23936
- unique_ptr<CreateInfo> Copy() const override {
23937
- auto result = make_unique<CreateMacroInfo>();
23938
- result->function = function->Copy();
23939
- result->name = name;
23940
- CopyProperties(*result);
23941
- return move(result);
23942
- }
23943
- };
23944
-
23945
- } // namespace duckdb
23946
23727
  //===----------------------------------------------------------------------===//
23947
23728
  // DuckDB
23948
23729
  //
23949
- // duckdb/parser/parsed_data/show_select_info.hpp
23730
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23950
23731
  //
23951
23732
  //
23952
23733
  //===----------------------------------------------------------------------===//
@@ -23955,25 +23736,19 @@ public:
23955
23736
 
23956
23737
 
23957
23738
 
23958
-
23959
23739
  namespace duckdb {
23960
23740
 
23961
- struct ShowSelectInfo : public ParseInfo {
23962
- //! Types of projected columns
23963
- vector<LogicalType> types;
23964
- //! The QueryNode of select query
23965
- unique_ptr<QueryNode> query;
23966
- //! Aliases of projected columns
23967
- vector<string> aliases;
23968
- //! Whether or not we are requesting a summary or a describe
23969
- bool is_summary;
23741
+ enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23970
23742
 
23971
- unique_ptr<ShowSelectInfo> Copy() {
23972
- auto result = make_unique<ShowSelectInfo>();
23973
- result->types = types;
23974
- result->query = query->Copy();
23975
- result->aliases = aliases;
23976
- result->is_summary = is_summary;
23743
+ struct LoadInfo : public ParseInfo {
23744
+ std::string filename;
23745
+ LoadType load_type;
23746
+
23747
+ public:
23748
+ unique_ptr<LoadInfo> Copy() const {
23749
+ auto result = make_unique<LoadInfo>();
23750
+ result->filename = filename;
23751
+ result->load_type = load_type;
23977
23752
  return result;
23978
23753
  }
23979
23754
  };
@@ -23982,7 +23757,7 @@ struct ShowSelectInfo : public ParseInfo {
23982
23757
  //===----------------------------------------------------------------------===//
23983
23758
  // DuckDB
23984
23759
  //
23985
- // duckdb/parser/parsed_data/vacuum_info.hpp
23760
+ // duckdb/parser/parsed_data/create_type_info.hpp
23986
23761
  //
23987
23762
  //
23988
23763
  //===----------------------------------------------------------------------===//
@@ -23991,10 +23766,29 @@ struct ShowSelectInfo : public ParseInfo {
23991
23766
 
23992
23767
 
23993
23768
 
23769
+
23770
+
23771
+
23994
23772
  namespace duckdb {
23995
23773
 
23996
- struct VacuumInfo : public ParseInfo {
23997
- // nothing for now
23774
+ struct CreateTypeInfo : public CreateInfo {
23775
+
23776
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23777
+ }
23778
+
23779
+ //! Name of the Type
23780
+ string name;
23781
+ //! Logical Type
23782
+ LogicalType type;
23783
+
23784
+ public:
23785
+ unique_ptr<CreateInfo> Copy() const override {
23786
+ auto result = make_unique<CreateTypeInfo>();
23787
+ CopyProperties(*result);
23788
+ result->name = name;
23789
+ result->type = type;
23790
+ return move(result);
23791
+ }
23998
23792
  };
23999
23793
 
24000
23794
  } // namespace duckdb
@@ -24085,6 +23879,211 @@ public:
24085
23879
  }
24086
23880
  };
24087
23881
 
23882
+ } // namespace duckdb
23883
+ //===----------------------------------------------------------------------===//
23884
+ // DuckDB
23885
+ //
23886
+ // duckdb/parser/parsed_data/transaction_info.hpp
23887
+ //
23888
+ //
23889
+ //===----------------------------------------------------------------------===//
23890
+
23891
+
23892
+
23893
+
23894
+
23895
+ namespace duckdb {
23896
+
23897
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
23898
+
23899
+ struct TransactionInfo : public ParseInfo {
23900
+ explicit TransactionInfo(TransactionType type) : type(type) {
23901
+ }
23902
+
23903
+ //! The type of transaction statement
23904
+ TransactionType type;
23905
+ };
23906
+
23907
+ } // namespace duckdb
23908
+ //===----------------------------------------------------------------------===//
23909
+ // DuckDB
23910
+ //
23911
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23912
+ //
23913
+ //
23914
+ //===----------------------------------------------------------------------===//
23915
+
23916
+
23917
+
23918
+
23919
+
23920
+
23921
+ namespace duckdb {
23922
+
23923
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23924
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
23925
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23926
+ functions.push_back(move(function));
23927
+ this->name = function.name;
23928
+ }
23929
+ CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23930
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23931
+ this->name = name;
23932
+ for (auto &function : functions) {
23933
+ function.name = name;
23934
+ }
23935
+ }
23936
+
23937
+ vector<PragmaFunction> functions;
23938
+
23939
+ public:
23940
+ unique_ptr<CreateInfo> Copy() const override {
23941
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23942
+ CopyProperties(*result);
23943
+ return move(result);
23944
+ }
23945
+ };
23946
+
23947
+ } // namespace duckdb
23948
+ //===----------------------------------------------------------------------===//
23949
+ // DuckDB
23950
+ //
23951
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23952
+ //
23953
+ //
23954
+ //===----------------------------------------------------------------------===//
23955
+
23956
+
23957
+
23958
+
23959
+
23960
+ namespace duckdb {
23961
+
23962
+ struct VacuumInfo : public ParseInfo {
23963
+ // nothing for now
23964
+ };
23965
+
23966
+ } // namespace duckdb
23967
+ //===----------------------------------------------------------------------===//
23968
+ // DuckDB
23969
+ //
23970
+ // duckdb/parser/parsed_data/drop_info.hpp
23971
+ //
23972
+ //
23973
+ //===----------------------------------------------------------------------===//
23974
+
23975
+
23976
+
23977
+
23978
+
23979
+
23980
+ namespace duckdb {
23981
+
23982
+ struct DropInfo : public ParseInfo {
23983
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23984
+ }
23985
+
23986
+ //! The catalog type to drop
23987
+ CatalogType type;
23988
+ //! Schema name to drop from, if any
23989
+ string schema;
23990
+ //! Element name to drop
23991
+ string name;
23992
+ //! Ignore if the entry does not exist instead of failing
23993
+ bool if_exists = false;
23994
+ //! Cascade drop (drop all dependents instead of throwing an error if there
23995
+ //! are any)
23996
+ bool cascade = false;
23997
+
23998
+ public:
23999
+ unique_ptr<DropInfo> Copy() const {
24000
+ auto result = make_unique<DropInfo>();
24001
+ result->type = type;
24002
+ result->schema = schema;
24003
+ result->name = name;
24004
+ result->if_exists = if_exists;
24005
+ result->cascade = cascade;
24006
+ return result;
24007
+ }
24008
+ };
24009
+
24010
+ } // namespace duckdb
24011
+ //===----------------------------------------------------------------------===//
24012
+ // DuckDB
24013
+ //
24014
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
24015
+ //
24016
+ //
24017
+ //===----------------------------------------------------------------------===//
24018
+
24019
+
24020
+
24021
+
24022
+
24023
+
24024
+ namespace duckdb {
24025
+
24026
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
24027
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
24028
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
24029
+ this->name = function.name;
24030
+ functions.AddFunction(move(function));
24031
+ }
24032
+
24033
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
24034
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
24035
+ this->name = functions.name;
24036
+ for (auto &func : functions.functions) {
24037
+ func.name = functions.name;
24038
+ }
24039
+ }
24040
+
24041
+ AggregateFunctionSet functions;
24042
+
24043
+ public:
24044
+ unique_ptr<CreateInfo> Copy() const override {
24045
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
24046
+ CopyProperties(*result);
24047
+ return move(result);
24048
+ }
24049
+ };
24050
+
24051
+ } // namespace duckdb
24052
+ //===----------------------------------------------------------------------===//
24053
+ // DuckDB
24054
+ //
24055
+ // duckdb/parser/parsed_data/show_select_info.hpp
24056
+ //
24057
+ //
24058
+ //===----------------------------------------------------------------------===//
24059
+
24060
+
24061
+
24062
+
24063
+
24064
+
24065
+ namespace duckdb {
24066
+
24067
+ struct ShowSelectInfo : public ParseInfo {
24068
+ //! Types of projected columns
24069
+ vector<LogicalType> types;
24070
+ //! The QueryNode of select query
24071
+ unique_ptr<QueryNode> query;
24072
+ //! Aliases of projected columns
24073
+ vector<string> aliases;
24074
+ //! Whether or not we are requesting a summary or a describe
24075
+ bool is_summary;
24076
+
24077
+ unique_ptr<ShowSelectInfo> Copy() {
24078
+ auto result = make_unique<ShowSelectInfo>();
24079
+ result->types = types;
24080
+ result->query = query->Copy();
24081
+ result->aliases = aliases;
24082
+ result->is_summary = is_summary;
24083
+ return result;
24084
+ }
24085
+ };
24086
+
24088
24087
  } // namespace duckdb
24089
24088
  //===----------------------------------------------------------------------===//
24090
24089
  // DuckDB
@@ -24125,7 +24124,7 @@ struct BoundExportData : public ParseInfo {
24125
24124
  //===----------------------------------------------------------------------===//
24126
24125
  // DuckDB
24127
24126
  //
24128
- // duckdb/parser/parsed_data/create_schema_info.hpp
24127
+ // duckdb/parser/parsed_data/create_macro_info.hpp
24129
24128
  //
24130
24129
  //
24131
24130
  //===----------------------------------------------------------------------===//
@@ -24133,57 +24132,73 @@ struct BoundExportData : public ParseInfo {
24133
24132
 
24134
24133
 
24135
24134
 
24136
-
24137
- namespace duckdb {
24138
-
24139
- struct CreateSchemaInfo : public CreateInfo {
24140
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
24141
- }
24142
-
24143
- public:
24144
- unique_ptr<CreateInfo> Copy() const override {
24145
- auto result = make_unique<CreateSchemaInfo>();
24146
- CopyProperties(*result);
24147
- return move(result);
24148
- }
24149
- };
24150
-
24151
- } // namespace duckdb
24152
24135
  //===----------------------------------------------------------------------===//
24153
24136
  // DuckDB
24154
24137
  //
24155
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
24138
+ // duckdb/function/macro_function.hpp
24156
24139
  //
24157
24140
  //
24158
24141
  //===----------------------------------------------------------------------===//
24159
24142
 
24160
24143
 
24144
+ //! The SelectStatement of the view
24145
+
24146
+
24147
+
24161
24148
 
24162
24149
 
24163
24150
 
24164
24151
 
24165
24152
  namespace duckdb {
24166
24153
 
24167
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
24168
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
24169
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
24170
- this->name = function.name;
24171
- functions.AddFunction(move(function));
24154
+ enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
24155
+
24156
+ class MacroFunction {
24157
+ public:
24158
+ // explicit MacroFunction(unique_ptr<ParsedExpression> expression);
24159
+ MacroFunction(MacroType type);
24160
+
24161
+ // MacroFunction(void);
24162
+ // The type
24163
+ MacroType type;
24164
+ //! The positional parameters
24165
+ vector<unique_ptr<ParsedExpression>> parameters;
24166
+ //! The default parameters and their associated values
24167
+ unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
24168
+
24169
+ public:
24170
+ virtual ~MacroFunction() {
24172
24171
  }
24173
24172
 
24174
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
24175
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
24176
- this->name = functions.name;
24177
- for (auto &func : functions.functions) {
24178
- func.name = functions.name;
24179
- }
24173
+ void CopyProperties(MacroFunction &other);
24174
+
24175
+ virtual unique_ptr<MacroFunction> Copy() = 0;
24176
+
24177
+ static string ValidateArguments(MacroFunction &macro_function, const string &name,
24178
+ FunctionExpression &function_expr,
24179
+ vector<unique_ptr<ParsedExpression>> &positionals,
24180
+ unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
24181
+ };
24182
+
24183
+ } // namespace duckdb
24184
+
24185
+
24186
+ namespace duckdb {
24187
+
24188
+ struct CreateMacroInfo : public CreateFunctionInfo {
24189
+ CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
24180
24190
  }
24181
24191
 
24182
- AggregateFunctionSet functions;
24192
+ CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
24193
+ }
24194
+
24195
+ unique_ptr<MacroFunction> function;
24183
24196
 
24184
24197
  public:
24185
24198
  unique_ptr<CreateInfo> Copy() const override {
24186
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
24199
+ auto result = make_unique<CreateMacroInfo>();
24200
+ result->function = function->Copy();
24201
+ result->name = name;
24187
24202
  CopyProperties(*result);
24188
24203
  return move(result);
24189
24204
  }
@@ -24193,7 +24208,7 @@ public:
24193
24208
  //===----------------------------------------------------------------------===//
24194
24209
  // DuckDB
24195
24210
  //
24196
- // duckdb/parser/parsed_data/create_type_info.hpp
24211
+ // duckdb/parser/parsed_data/create_view_info.hpp
24197
24212
  //
24198
24213
  //
24199
24214
  //===----------------------------------------------------------------------===//
@@ -24203,26 +24218,31 @@ public:
24203
24218
 
24204
24219
 
24205
24220
 
24206
-
24207
-
24208
24221
  namespace duckdb {
24209
24222
 
24210
- struct CreateTypeInfo : public CreateInfo {
24211
-
24212
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
24223
+ struct CreateViewInfo : public CreateInfo {
24224
+ CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
24225
+ }
24226
+ CreateViewInfo(string schema, string view_name)
24227
+ : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
24213
24228
  }
24214
24229
 
24215
- //! Name of the Type
24216
- string name;
24217
- //! Logical Type
24218
- LogicalType type;
24230
+ //! Table name to insert to
24231
+ string view_name;
24232
+ //! Aliases of the view
24233
+ vector<string> aliases;
24234
+ //! Return types
24235
+ vector<LogicalType> types;
24236
+ //! The SelectStatement of the view
24237
+ unique_ptr<SelectStatement> query;
24219
24238
 
24220
24239
  public:
24221
24240
  unique_ptr<CreateInfo> Copy() const override {
24222
- auto result = make_unique<CreateTypeInfo>();
24241
+ auto result = make_unique<CreateViewInfo>(schema, view_name);
24223
24242
  CopyProperties(*result);
24224
- result->name = name;
24225
- result->type = type;
24243
+ result->aliases = aliases;
24244
+ result->types = types;
24245
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
24226
24246
  return move(result);
24227
24247
  }
24228
24248
  };
@@ -24273,7 +24293,7 @@ public:
24273
24293
  //===----------------------------------------------------------------------===//
24274
24294
  // DuckDB
24275
24295
  //
24276
- // duckdb/parser/parsed_data/create_view_info.hpp
24296
+ // duckdb/parser/parsed_data/create_schema_info.hpp
24277
24297
  //
24278
24298
  //
24279
24299
  //===----------------------------------------------------------------------===//
@@ -24282,41 +24302,26 @@ public:
24282
24302
 
24283
24303
 
24284
24304
 
24285
-
24286
24305
  namespace duckdb {
24287
24306
 
24288
- struct CreateViewInfo : public CreateInfo {
24289
- CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
24290
- }
24291
- CreateViewInfo(string schema, string view_name)
24292
- : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
24307
+ struct CreateSchemaInfo : public CreateInfo {
24308
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
24293
24309
  }
24294
24310
 
24295
- //! Table name to insert to
24296
- string view_name;
24297
- //! Aliases of the view
24298
- vector<string> aliases;
24299
- //! Return types
24300
- vector<LogicalType> types;
24301
- //! The SelectStatement of the view
24302
- unique_ptr<SelectStatement> query;
24303
-
24304
24311
  public:
24305
24312
  unique_ptr<CreateInfo> Copy() const override {
24306
- auto result = make_unique<CreateViewInfo>(schema, view_name);
24313
+ auto result = make_unique<CreateSchemaInfo>();
24307
24314
  CopyProperties(*result);
24308
- result->aliases = aliases;
24309
- result->types = types;
24310
- result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
24311
24315
  return move(result);
24312
24316
  }
24313
24317
  };
24314
24318
 
24315
24319
  } // namespace duckdb
24320
+
24316
24321
  //===----------------------------------------------------------------------===//
24317
24322
  // DuckDB
24318
24323
  //
24319
- // duckdb/parser/tableref/emptytableref.hpp
24324
+ // duckdb/parser/tableref/crossproductref.hpp
24320
24325
  //
24321
24326
  //
24322
24327
  //===----------------------------------------------------------------------===//
@@ -24327,27 +24332,33 @@ public:
24327
24332
 
24328
24333
  namespace duckdb {
24329
24334
  //! Represents a cross product
24330
- class EmptyTableRef : public TableRef {
24335
+ class CrossProductRef : public TableRef {
24331
24336
  public:
24332
- EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
24337
+ CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
24333
24338
  }
24334
24339
 
24340
+ //! The left hand side of the cross product
24341
+ unique_ptr<TableRef> left;
24342
+ //! The right hand side of the cross product
24343
+ unique_ptr<TableRef> right;
24344
+
24335
24345
  public:
24336
24346
  string ToString() const override;
24337
24347
  bool Equals(const TableRef *other_p) const override;
24338
24348
 
24339
24349
  unique_ptr<TableRef> Copy() override;
24340
24350
 
24341
- //! Serializes a blob into a DummyTableRef
24351
+ //! Serializes a blob into a CrossProductRef
24342
24352
  void Serialize(FieldWriter &serializer) const override;
24343
- //! Deserializes a blob back into a DummyTableRef
24353
+ //! Deserializes a blob back into a CrossProductRef
24344
24354
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24345
24355
  };
24346
24356
  } // namespace duckdb
24357
+
24347
24358
  //===----------------------------------------------------------------------===//
24348
24359
  // DuckDB
24349
24360
  //
24350
- // duckdb/parser/tableref/joinref.hpp
24361
+ // duckdb/parser/tableref/emptytableref.hpp
24351
24362
  //
24352
24363
  //
24353
24364
  //===----------------------------------------------------------------------===//
@@ -24356,46 +24367,30 @@ public:
24356
24367
 
24357
24368
 
24358
24369
 
24359
-
24360
-
24361
-
24362
-
24363
24370
  namespace duckdb {
24364
- //! Represents a JOIN between two expressions
24365
- class JoinRef : public TableRef {
24371
+ //! Represents a cross product
24372
+ class EmptyTableRef : public TableRef {
24366
24373
  public:
24367
- JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
24374
+ EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
24368
24375
  }
24369
24376
 
24370
- //! The left hand side of the join
24371
- unique_ptr<TableRef> left;
24372
- //! The right hand side of the join
24373
- unique_ptr<TableRef> right;
24374
- //! The join condition
24375
- unique_ptr<ParsedExpression> condition;
24376
- //! The join type
24377
- JoinType type;
24378
- //! Natural join
24379
- bool is_natural;
24380
- //! The set of USING columns (if any)
24381
- vector<string> using_columns;
24382
-
24383
24377
  public:
24384
24378
  string ToString() const override;
24385
24379
  bool Equals(const TableRef *other_p) const override;
24386
24380
 
24387
24381
  unique_ptr<TableRef> Copy() override;
24388
24382
 
24389
- //! Serializes a blob into a JoinRef
24383
+ //! Serializes a blob into a DummyTableRef
24390
24384
  void Serialize(FieldWriter &serializer) const override;
24391
- //! Deserializes a blob back into a JoinRef
24385
+ //! Deserializes a blob back into a DummyTableRef
24392
24386
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24393
24387
  };
24394
24388
  } // namespace duckdb
24389
+
24395
24390
  //===----------------------------------------------------------------------===//
24396
24391
  // DuckDB
24397
24392
  //
24398
- // duckdb/parser/tableref/crossproductref.hpp
24393
+ // duckdb/parser/tableref/expressionlistref.hpp
24399
24394
  //
24400
24395
  //
24401
24396
  //===----------------------------------------------------------------------===//
@@ -24404,17 +24399,22 @@ public:
24404
24399
 
24405
24400
 
24406
24401
 
24402
+
24403
+
24404
+
24407
24405
  namespace duckdb {
24408
- //! Represents a cross product
24409
- class CrossProductRef : public TableRef {
24406
+ //! Represents an expression list as generated by a VALUES statement
24407
+ class ExpressionListRef : public TableRef {
24410
24408
  public:
24411
- CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
24409
+ ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
24412
24410
  }
24413
24411
 
24414
- //! The left hand side of the cross product
24415
- unique_ptr<TableRef> left;
24416
- //! The right hand side of the cross product
24417
- unique_ptr<TableRef> right;
24412
+ //! Value list, only used for VALUES statement
24413
+ vector<vector<unique_ptr<ParsedExpression>>> values;
24414
+ //! Expected SQL types
24415
+ vector<LogicalType> expected_types;
24416
+ //! The set of expected names
24417
+ vector<string> expected_names;
24418
24418
 
24419
24419
  public:
24420
24420
  string ToString() const override;
@@ -24422,19 +24422,17 @@ public:
24422
24422
 
24423
24423
  unique_ptr<TableRef> Copy() override;
24424
24424
 
24425
- //! Serializes a blob into a CrossProductRef
24425
+ //! Serializes a blob into a ExpressionListRef
24426
24426
  void Serialize(FieldWriter &serializer) const override;
24427
- //! Deserializes a blob back into a CrossProductRef
24427
+ //! Deserializes a blob back into a ExpressionListRef
24428
24428
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24429
24429
  };
24430
24430
  } // namespace duckdb
24431
24431
 
24432
-
24433
-
24434
24432
  //===----------------------------------------------------------------------===//
24435
24433
  // DuckDB
24436
24434
  //
24437
- // duckdb/parser/tableref/expressionlistref.hpp
24435
+ // duckdb/parser/tableref/joinref.hpp
24438
24436
  //
24439
24437
  //
24440
24438
  //===----------------------------------------------------------------------===//
@@ -24446,19 +24444,26 @@ public:
24446
24444
 
24447
24445
 
24448
24446
 
24447
+
24449
24448
  namespace duckdb {
24450
- //! Represents an expression list as generated by a VALUES statement
24451
- class ExpressionListRef : public TableRef {
24449
+ //! Represents a JOIN between two expressions
24450
+ class JoinRef : public TableRef {
24452
24451
  public:
24453
- ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
24452
+ JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
24454
24453
  }
24455
24454
 
24456
- //! Value list, only used for VALUES statement
24457
- vector<vector<unique_ptr<ParsedExpression>>> values;
24458
- //! Expected SQL types
24459
- vector<LogicalType> expected_types;
24460
- //! The set of expected names
24461
- vector<string> expected_names;
24455
+ //! The left hand side of the join
24456
+ unique_ptr<TableRef> left;
24457
+ //! The right hand side of the join
24458
+ unique_ptr<TableRef> right;
24459
+ //! The join condition
24460
+ unique_ptr<ParsedExpression> condition;
24461
+ //! The join type
24462
+ JoinType type;
24463
+ //! Natural join
24464
+ bool is_natural;
24465
+ //! The set of USING columns (if any)
24466
+ vector<string> using_columns;
24462
24467
 
24463
24468
  public:
24464
24469
  string ToString() const override;
@@ -24466,14 +24471,13 @@ public:
24466
24471
 
24467
24472
  unique_ptr<TableRef> Copy() override;
24468
24473
 
24469
- //! Serializes a blob into a ExpressionListRef
24474
+ //! Serializes a blob into a JoinRef
24470
24475
  void Serialize(FieldWriter &serializer) const override;
24471
- //! Deserializes a blob back into a ExpressionListRef
24476
+ //! Deserializes a blob back into a JoinRef
24472
24477
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24473
24478
  };
24474
24479
  } // namespace duckdb
24475
24480
 
24476
-
24477
24481
  //===----------------------------------------------------------------------===//
24478
24482
  // DuckDB
24479
24483
  //