duckdb 0.3.5-dev1285.0 → 0.3.5-dev1323.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 "2c3c08da3"
15
- #define DUCKDB_VERSION "v0.3.5-dev1285"
14
+ #define DUCKDB_SOURCE_ID "5d9d00b2a"
15
+ #define DUCKDB_VERSION "v0.3.5-dev1323"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -2194,9 +2194,8 @@ namespace duckdb {
2194
2194
  class VectorBuffer;
2195
2195
 
2196
2196
  struct SelectionData {
2197
- explicit SelectionData(idx_t count) {
2198
- owned_data = unique_ptr<sel_t[]>(new sel_t[count]);
2199
- }
2197
+ explicit SelectionData(idx_t count);
2198
+
2200
2199
  unique_ptr<sel_t[]> owned_data;
2201
2200
  };
2202
2201
 
@@ -3557,6 +3556,7 @@ class VectorStructBuffer : public VectorBuffer {
3557
3556
  public:
3558
3557
  VectorStructBuffer();
3559
3558
  VectorStructBuffer(const LogicalType &struct_type, idx_t capacity = STANDARD_VECTOR_SIZE);
3559
+ VectorStructBuffer(Vector &other, const SelectionVector &sel, idx_t count);
3560
3560
  ~VectorStructBuffer() override;
3561
3561
 
3562
3562
  public:
@@ -3718,7 +3718,7 @@ public:
3718
3718
  //! Verify that the Vector is in a consistent, not corrupt state. DEBUG
3719
3719
  //! FUNCTION ONLY!
3720
3720
  DUCKDB_API void Verify(idx_t count);
3721
- DUCKDB_API void Verify(const SelectionVector &sel, idx_t count);
3721
+ DUCKDB_API static void Verify(Vector &vector, const SelectionVector &sel, idx_t count);
3722
3722
  DUCKDB_API void UTFVerify(idx_t count);
3723
3723
  DUCKDB_API void UTFVerify(const SelectionVector &sel, idx_t count);
3724
3724
 
@@ -3761,6 +3761,10 @@ public:
3761
3761
  // Setters
3762
3762
  DUCKDB_API void SetVectorType(VectorType vector_type);
3763
3763
 
3764
+ private:
3765
+ //! Returns the [index] element of the Vector as a Value.
3766
+ DUCKDB_API static Value GetValue(const Vector &v, idx_t index);
3767
+
3764
3768
  protected:
3765
3769
  //! The vector type specifies how the data of the vector is physically stored (i.e. if it is a single repeated
3766
3770
  //! constant, if it is compressed)
@@ -22944,7 +22948,7 @@ private:
22944
22948
  //===----------------------------------------------------------------------===//
22945
22949
  // DuckDB
22946
22950
  //
22947
- // duckdb/parser/expression/comparison_expression.hpp
22951
+ // duckdb/parser/expression/conjunction_expression.hpp
22948
22952
  //
22949
22953
  //
22950
22954
  //===----------------------------------------------------------------------===//
@@ -22953,21 +22957,25 @@ private:
22953
22957
 
22954
22958
 
22955
22959
 
22960
+
22956
22961
  namespace duckdb {
22957
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
22958
- //! and has two children.
22959
- class ComparisonExpression : public ParsedExpression {
22962
+
22963
+ //! Represents a conjunction (AND/OR)
22964
+ class ConjunctionExpression : public ParsedExpression {
22960
22965
  public:
22961
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22962
- unique_ptr<ParsedExpression> right);
22966
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22967
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22968
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22969
+ unique_ptr<ParsedExpression> right);
22963
22970
 
22964
- unique_ptr<ParsedExpression> left;
22965
- unique_ptr<ParsedExpression> right;
22971
+ vector<unique_ptr<ParsedExpression>> children;
22966
22972
 
22967
22973
  public:
22974
+ void AddExpression(unique_ptr<ParsedExpression> expr);
22975
+
22968
22976
  string ToString() const override;
22969
22977
 
22970
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
22978
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22971
22979
 
22972
22980
  unique_ptr<ParsedExpression> Copy() const override;
22973
22981
 
@@ -22977,14 +22985,18 @@ public:
22977
22985
  public:
22978
22986
  template <class T, class BASE>
22979
22987
  static string ToString(const T &entry) {
22980
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
22988
+ string result = "(" + entry.children[0]->ToString();
22989
+ for (idx_t i = 1; i < entry.children.size(); i++) {
22990
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22991
+ }
22992
+ return result + ")";
22981
22993
  }
22982
22994
  };
22983
22995
  } // namespace duckdb
22984
22996
  //===----------------------------------------------------------------------===//
22985
22997
  // DuckDB
22986
22998
  //
22987
- // duckdb/parser/expression/default_expression.hpp
22999
+ // duckdb/parser/expression/positional_reference_expression.hpp
22988
23000
  //
22989
23001
  //
22990
23002
  //===----------------------------------------------------------------------===//
@@ -22994,10 +23006,11 @@ public:
22994
23006
 
22995
23007
 
22996
23008
  namespace duckdb {
22997
- //! Represents the default value of a column
22998
- class DefaultExpression : public ParsedExpression {
23009
+ class PositionalReferenceExpression : public ParsedExpression {
22999
23010
  public:
23000
- DefaultExpression();
23011
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
23012
+
23013
+ idx_t index;
23001
23014
 
23002
23015
  public:
23003
23016
  bool IsScalar() const override {
@@ -23006,7 +23019,9 @@ public:
23006
23019
 
23007
23020
  string ToString() const override;
23008
23021
 
23022
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
23009
23023
  unique_ptr<ParsedExpression> Copy() const override;
23024
+ hash_t Hash() const override;
23010
23025
 
23011
23026
  void Serialize(FieldWriter &writer) const override;
23012
23027
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
@@ -23015,7 +23030,7 @@ public:
23015
23030
  //===----------------------------------------------------------------------===//
23016
23031
  // DuckDB
23017
23032
  //
23018
- // duckdb/parser/expression/case_expression.hpp
23033
+ // duckdb/parser/expression/star_expression.hpp
23019
23034
  //
23020
23035
  //
23021
23036
  //===----------------------------------------------------------------------===//
@@ -23027,47 +23042,33 @@ public:
23027
23042
 
23028
23043
  namespace duckdb {
23029
23044
 
23030
- struct CaseCheck {
23031
- unique_ptr<ParsedExpression> when_expr;
23032
- unique_ptr<ParsedExpression> then_expr;
23033
- };
23034
-
23035
- //! The CaseExpression represents a CASE expression in the query
23036
- class CaseExpression : public ParsedExpression {
23045
+ //! Represents a * expression in the SELECT clause
23046
+ class StarExpression : public ParsedExpression {
23037
23047
  public:
23038
- DUCKDB_API CaseExpression();
23048
+ StarExpression(string relation_name = string());
23039
23049
 
23040
- vector<CaseCheck> case_checks;
23041
- unique_ptr<ParsedExpression> else_expr;
23050
+ //! The relation name in case of tbl.*, or empty if this is a normal *
23051
+ string relation_name;
23052
+ //! List of columns to exclude from the STAR expression
23053
+ case_insensitive_set_t exclude_list;
23054
+ //! List of columns to replace with another expression
23055
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23042
23056
 
23043
23057
  public:
23044
23058
  string ToString() const override;
23045
23059
 
23046
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
23060
+ static bool Equals(const StarExpression *a, const StarExpression *b);
23047
23061
 
23048
23062
  unique_ptr<ParsedExpression> Copy() const override;
23049
23063
 
23050
23064
  void Serialize(FieldWriter &writer) const override;
23051
23065
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23052
-
23053
- public:
23054
- template <class T, class BASE>
23055
- static string ToString(const T &entry) {
23056
- string case_str = "CASE ";
23057
- for (auto &check : entry.case_checks) {
23058
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
23059
- case_str += " THEN (" + check.then_expr->ToString() + ")";
23060
- }
23061
- case_str += " ELSE " + entry.else_expr->ToString();
23062
- case_str += " END";
23063
- return case_str;
23064
- }
23065
23066
  };
23066
23067
  } // namespace duckdb
23067
23068
  //===----------------------------------------------------------------------===//
23068
23069
  // DuckDB
23069
23070
  //
23070
- // duckdb/parser/expression/positional_reference_expression.hpp
23071
+ // duckdb/parser/expression/operator_expression.hpp
23071
23072
  //
23072
23073
  //
23073
23074
  //===----------------------------------------------------------------------===//
@@ -23076,32 +23077,98 @@ public:
23076
23077
 
23077
23078
 
23078
23079
 
23080
+
23081
+
23082
+
23079
23083
  namespace duckdb {
23080
- class PositionalReferenceExpression : public ParsedExpression {
23084
+ //! Represents a built-in operator expression
23085
+ class OperatorExpression : public ParsedExpression {
23081
23086
  public:
23082
- DUCKDB_API PositionalReferenceExpression(idx_t index);
23087
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
23088
+ unique_ptr<ParsedExpression> right = nullptr);
23089
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23083
23090
 
23084
- idx_t index;
23091
+ vector<unique_ptr<ParsedExpression>> children;
23085
23092
 
23086
23093
  public:
23087
- bool IsScalar() const override {
23088
- return false;
23089
- }
23090
-
23091
23094
  string ToString() const override;
23092
23095
 
23093
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
23096
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23097
+
23094
23098
  unique_ptr<ParsedExpression> Copy() const override;
23095
- hash_t Hash() const override;
23096
23099
 
23097
23100
  void Serialize(FieldWriter &writer) const override;
23098
23101
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23102
+
23103
+ public:
23104
+ template <class T, class BASE>
23105
+ static string ToString(const T &entry) {
23106
+ auto op = ExpressionTypeToOperator(entry.type);
23107
+ if (!op.empty()) {
23108
+ // use the operator string to represent the operator
23109
+ D_ASSERT(entry.children.size() == 2);
23110
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23111
+ }
23112
+ switch (entry.type) {
23113
+ case ExpressionType::COMPARE_IN:
23114
+ case ExpressionType::COMPARE_NOT_IN: {
23115
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23116
+ string in_child = entry.children[0]->ToString();
23117
+ string child_list = "(";
23118
+ for (idx_t i = 1; i < entry.children.size(); i++) {
23119
+ if (i > 1) {
23120
+ child_list += ", ";
23121
+ }
23122
+ child_list += entry.children[i]->ToString();
23123
+ }
23124
+ child_list += ")";
23125
+ return "(" + in_child + op_type + child_list + ")";
23126
+ }
23127
+ case ExpressionType::OPERATOR_NOT:
23128
+ case ExpressionType::GROUPING_FUNCTION:
23129
+ case ExpressionType::OPERATOR_COALESCE: {
23130
+ string result = ExpressionTypeToString(entry.type);
23131
+ result += "(";
23132
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23133
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23134
+ result += ")";
23135
+ return result;
23136
+ }
23137
+ case ExpressionType::OPERATOR_IS_NULL:
23138
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
23139
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
23140
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23141
+ case ExpressionType::ARRAY_EXTRACT:
23142
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23143
+ case ExpressionType::ARRAY_SLICE:
23144
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23145
+ entry.children[2]->ToString() + "]";
23146
+ case ExpressionType::STRUCT_EXTRACT: {
23147
+ D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
23148
+ auto child_string = entry.children[1]->ToString();
23149
+ D_ASSERT(child_string.size() >= 3);
23150
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23151
+ return "(" + entry.children[0]->ToString() + ")." +
23152
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23153
+ }
23154
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
23155
+ string result = "(ARRAY[";
23156
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23157
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23158
+ result += "])";
23159
+ return result;
23160
+ }
23161
+ default:
23162
+ throw InternalException("Unrecognized operator type");
23163
+ }
23164
+ }
23099
23165
  };
23166
+
23100
23167
  } // namespace duckdb
23101
23168
  //===----------------------------------------------------------------------===//
23102
23169
  // DuckDB
23103
23170
  //
23104
- // duckdb/parser/expression/conjunction_expression.hpp
23171
+ // duckdb/parser/expression/constant_expression.hpp
23105
23172
  //
23106
23173
  //
23107
23174
  //===----------------------------------------------------------------------===//
@@ -23113,38 +23180,26 @@ public:
23113
23180
 
23114
23181
  namespace duckdb {
23115
23182
 
23116
- //! Represents a conjunction (AND/OR)
23117
- class ConjunctionExpression : public ParsedExpression {
23183
+ //! ConstantExpression represents a constant value in the query
23184
+ class ConstantExpression : public ParsedExpression {
23118
23185
  public:
23119
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
23120
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23121
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23122
- unique_ptr<ParsedExpression> right);
23186
+ DUCKDB_API explicit ConstantExpression(Value val);
23123
23187
 
23124
- vector<unique_ptr<ParsedExpression>> children;
23188
+ //! The constant value referenced
23189
+ Value value;
23125
23190
 
23126
23191
  public:
23127
- void AddExpression(unique_ptr<ParsedExpression> expr);
23128
-
23129
23192
  string ToString() const override;
23130
23193
 
23131
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
23194
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
23195
+ hash_t Hash() const override;
23132
23196
 
23133
23197
  unique_ptr<ParsedExpression> Copy() const override;
23134
23198
 
23135
23199
  void Serialize(FieldWriter &writer) const override;
23136
23200
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23137
-
23138
- public:
23139
- template <class T, class BASE>
23140
- static string ToString(const T &entry) {
23141
- string result = "(" + entry.children[0]->ToString();
23142
- for (idx_t i = 1; i < entry.children.size(); i++) {
23143
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
23144
- }
23145
- return result + ")";
23146
- }
23147
23201
  };
23202
+
23148
23203
  } // namespace duckdb
23149
23204
  //===----------------------------------------------------------------------===//
23150
23205
  // DuckDB
@@ -23198,7 +23253,7 @@ public:
23198
23253
  //===----------------------------------------------------------------------===//
23199
23254
  // DuckDB
23200
23255
  //
23201
- // duckdb/parser/expression/cast_expression.hpp
23256
+ // duckdb/parser/expression/parameter_expression.hpp
23202
23257
  //
23203
23258
  //
23204
23259
  //===----------------------------------------------------------------------===//
@@ -23207,43 +23262,34 @@ public:
23207
23262
 
23208
23263
 
23209
23264
 
23210
-
23211
23265
  namespace duckdb {
23212
-
23213
- //! CastExpression represents a type cast from one SQL type to another SQL type
23214
- class CastExpression : public ParsedExpression {
23266
+ class ParameterExpression : public ParsedExpression {
23215
23267
  public:
23216
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
23268
+ ParameterExpression();
23217
23269
 
23218
- //! The child of the cast expression
23219
- unique_ptr<ParsedExpression> child;
23220
- //! The type to cast to
23221
- LogicalType cast_type;
23222
- //! Whether or not this is a try_cast expression
23223
- bool try_cast;
23270
+ idx_t parameter_nr;
23224
23271
 
23225
23272
  public:
23226
- string ToString() const override;
23273
+ bool IsScalar() const override {
23274
+ return true;
23275
+ }
23276
+ bool HasParameter() const override {
23277
+ return true;
23278
+ }
23227
23279
 
23228
- static bool Equals(const CastExpression *a, const CastExpression *b);
23280
+ string ToString() const override;
23229
23281
 
23230
23282
  unique_ptr<ParsedExpression> Copy() const override;
23283
+ hash_t Hash() const override;
23231
23284
 
23232
23285
  void Serialize(FieldWriter &writer) const override;
23233
23286
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23234
-
23235
- public:
23236
- template <class T, class BASE>
23237
- static string ToString(const T &entry) {
23238
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
23239
- entry.cast_type.ToString() + ")";
23240
- }
23241
23287
  };
23242
23288
  } // namespace duckdb
23243
23289
  //===----------------------------------------------------------------------===//
23244
23290
  // DuckDB
23245
23291
  //
23246
- // duckdb/parser/expression/lambda_expression.hpp
23292
+ // duckdb/parser/expression/between_expression.hpp
23247
23293
  //
23248
23294
  //
23249
23295
  //===----------------------------------------------------------------------===//
@@ -23252,37 +23298,38 @@ public:
23252
23298
 
23253
23299
 
23254
23300
 
23255
-
23256
23301
  namespace duckdb {
23257
23302
 
23258
- //! LambdaExpression represents either:
23259
- //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
23260
- //! 2. An OperatorExpression with the "->" operator
23261
- //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
23262
- class LambdaExpression : public ParsedExpression {
23303
+ class BetweenExpression : public ParsedExpression {
23263
23304
  public:
23264
- LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
23305
+ DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
23306
+ unique_ptr<ParsedExpression> upper);
23265
23307
 
23266
- unique_ptr<ParsedExpression> lhs;
23267
- unique_ptr<ParsedExpression> rhs;
23308
+ unique_ptr<ParsedExpression> input;
23309
+ unique_ptr<ParsedExpression> lower;
23310
+ unique_ptr<ParsedExpression> upper;
23268
23311
 
23269
23312
  public:
23270
23313
  string ToString() const override;
23271
23314
 
23272
- static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
23273
- hash_t Hash() const override;
23315
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
23274
23316
 
23275
23317
  unique_ptr<ParsedExpression> Copy() const override;
23276
23318
 
23277
23319
  void Serialize(FieldWriter &writer) const override;
23278
23320
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23279
- };
23280
23321
 
23322
+ public:
23323
+ template <class T, class BASE>
23324
+ static string ToString(const T &entry) {
23325
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
23326
+ }
23327
+ };
23281
23328
  } // namespace duckdb
23282
23329
  //===----------------------------------------------------------------------===//
23283
23330
  // DuckDB
23284
23331
  //
23285
- // duckdb/parser/expression/function_expression.hpp
23332
+ // duckdb/parser/expression/default_expression.hpp
23286
23333
  //
23287
23334
  //
23288
23335
  //===----------------------------------------------------------------------===//
@@ -23291,115 +23338,31 @@ public:
23291
23338
 
23292
23339
 
23293
23340
 
23294
-
23295
-
23296
23341
  namespace duckdb {
23297
- //! Represents a function call
23298
- class FunctionExpression : public ParsedExpression {
23342
+ //! Represents the default value of a column
23343
+ class DefaultExpression : public ParsedExpression {
23299
23344
  public:
23300
- DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
23301
- vector<unique_ptr<ParsedExpression>> children,
23302
- unique_ptr<ParsedExpression> filter = nullptr,
23303
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
23304
- bool is_operator = false, bool export_state = false);
23305
- DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
23306
- unique_ptr<ParsedExpression> filter = nullptr,
23307
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
23308
- bool is_operator = false, bool export_state = false);
23309
-
23310
- //! Schema of the function
23311
- string schema;
23312
- //! Function name
23313
- string function_name;
23314
- //! Whether or not the function is an operator, only used for rendering
23315
- bool is_operator;
23316
- //! List of arguments to the function
23317
- vector<unique_ptr<ParsedExpression>> children;
23318
- //! Whether or not the aggregate function is distinct, only used for aggregates
23319
- bool distinct;
23320
- //! Expression representing a filter, only used for aggregates
23321
- unique_ptr<ParsedExpression> filter;
23322
- //! Modifier representing an ORDER BY, only used for aggregates
23323
- unique_ptr<OrderModifier> order_bys;
23324
- //! whether this function should export its state or not
23325
- bool export_state;
23345
+ DefaultExpression();
23326
23346
 
23327
23347
  public:
23348
+ bool IsScalar() const override {
23349
+ return false;
23350
+ }
23351
+
23328
23352
  string ToString() const override;
23329
23353
 
23330
23354
  unique_ptr<ParsedExpression> Copy() const override;
23331
23355
 
23332
- static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
23333
- hash_t Hash() const override;
23334
-
23335
23356
  void Serialize(FieldWriter &writer) const override;
23336
23357
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23337
-
23338
- void Verify() const override;
23339
-
23340
- public:
23341
- template <class T, class BASE>
23342
- static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
23343
- bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
23344
- bool export_state = false, bool add_alias = false) {
23345
- if (is_operator) {
23346
- // built-in operator
23347
- D_ASSERT(!distinct);
23348
- if (entry.children.size() == 1) {
23349
- if (StringUtil::Contains(function_name, "__postfix")) {
23350
- return "(" + entry.children[0]->ToString() + ")" +
23351
- StringUtil::Replace(function_name, "__postfix", "");
23352
- } else {
23353
- return function_name + "(" + entry.children[0]->ToString() + ")";
23354
- }
23355
- } else if (entry.children.size() == 2) {
23356
- return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
23357
- ")";
23358
- }
23359
- }
23360
- // standard function call
23361
- string result = schema.empty() ? function_name : schema + "." + function_name;
23362
- result += "(";
23363
- if (distinct) {
23364
- result += "DISTINCT ";
23365
- }
23366
- result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
23367
- return child->alias.empty() || !add_alias
23368
- ? child->ToString()
23369
- : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
23370
- });
23371
- // ordered aggregate
23372
- if (order_bys && !order_bys->orders.empty()) {
23373
- if (entry.children.empty()) {
23374
- result += ") WITHIN GROUP (";
23375
- }
23376
- result += " ORDER BY ";
23377
- for (idx_t i = 0; i < order_bys->orders.size(); i++) {
23378
- if (i > 0) {
23379
- result += ", ";
23380
- }
23381
- result += order_bys->orders[i].ToString();
23382
- }
23383
- }
23384
- result += ")";
23385
-
23386
- // filtered aggregate
23387
- if (filter) {
23388
- result += " FILTER (WHERE " + filter->ToString() + ")";
23389
- }
23390
-
23391
- if (export_state) {
23392
- result += " EXPORT_STATE";
23393
- }
23394
-
23395
- return result;
23396
- }
23397
23358
  };
23398
23359
  } // namespace duckdb
23360
+
23361
+
23399
23362
  //===----------------------------------------------------------------------===//
23400
23363
  // DuckDB
23401
23364
  //
23402
- // duckdb/parser/expression/star_expression.hpp
23365
+ // duckdb/parser/expression/case_expression.hpp
23403
23366
  //
23404
23367
  //
23405
23368
  //===----------------------------------------------------------------------===//
@@ -23411,69 +23374,48 @@ public:
23411
23374
 
23412
23375
  namespace duckdb {
23413
23376
 
23414
- //! Represents a * expression in the SELECT clause
23415
- class StarExpression : public ParsedExpression {
23377
+ struct CaseCheck {
23378
+ unique_ptr<ParsedExpression> when_expr;
23379
+ unique_ptr<ParsedExpression> then_expr;
23380
+ };
23381
+
23382
+ //! The CaseExpression represents a CASE expression in the query
23383
+ class CaseExpression : public ParsedExpression {
23416
23384
  public:
23417
- StarExpression(string relation_name = string());
23385
+ DUCKDB_API CaseExpression();
23418
23386
 
23419
- //! The relation name in case of tbl.*, or empty if this is a normal *
23420
- string relation_name;
23421
- //! List of columns to exclude from the STAR expression
23422
- case_insensitive_set_t exclude_list;
23423
- //! List of columns to replace with another expression
23424
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23387
+ vector<CaseCheck> case_checks;
23388
+ unique_ptr<ParsedExpression> else_expr;
23425
23389
 
23426
23390
  public:
23427
23391
  string ToString() const override;
23428
23392
 
23429
- static bool Equals(const StarExpression *a, const StarExpression *b);
23393
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
23430
23394
 
23431
23395
  unique_ptr<ParsedExpression> Copy() const override;
23432
23396
 
23433
23397
  void Serialize(FieldWriter &writer) const override;
23434
23398
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23435
- };
23436
- } // namespace duckdb
23437
- //===----------------------------------------------------------------------===//
23438
- // DuckDB
23439
- //
23440
- // duckdb/parser/expression/parameter_expression.hpp
23441
- //
23442
- //
23443
- //===----------------------------------------------------------------------===//
23444
-
23445
-
23446
-
23447
-
23448
-
23449
- namespace duckdb {
23450
- class ParameterExpression : public ParsedExpression {
23451
- public:
23452
- ParameterExpression();
23453
-
23454
- idx_t parameter_nr;
23455
23399
 
23456
23400
  public:
23457
- bool IsScalar() const override {
23458
- return true;
23459
- }
23460
- bool HasParameter() const override {
23461
- return true;
23401
+ template <class T, class BASE>
23402
+ static string ToString(const T &entry) {
23403
+ string case_str = "CASE ";
23404
+ for (auto &check : entry.case_checks) {
23405
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
23406
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
23407
+ }
23408
+ case_str += " ELSE " + entry.else_expr->ToString();
23409
+ case_str += " END";
23410
+ return case_str;
23462
23411
  }
23463
-
23464
- string ToString() const override;
23465
-
23466
- unique_ptr<ParsedExpression> Copy() const override;
23467
- hash_t Hash() const override;
23468
-
23469
- void Serialize(FieldWriter &writer) const override;
23470
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23471
23412
  };
23472
23413
  } // namespace duckdb
23414
+
23473
23415
  //===----------------------------------------------------------------------===//
23474
23416
  // DuckDB
23475
23417
  //
23476
- // duckdb/parser/expression/between_expression.hpp
23418
+ // duckdb/parser/expression/cast_expression.hpp
23477
23419
  //
23478
23420
  //
23479
23421
  //===----------------------------------------------------------------------===//
@@ -23482,21 +23424,25 @@ public:
23482
23424
 
23483
23425
 
23484
23426
 
23427
+
23485
23428
  namespace duckdb {
23486
23429
 
23487
- class BetweenExpression : public ParsedExpression {
23430
+ //! CastExpression represents a type cast from one SQL type to another SQL type
23431
+ class CastExpression : public ParsedExpression {
23488
23432
  public:
23489
- DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
23490
- unique_ptr<ParsedExpression> upper);
23433
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
23491
23434
 
23492
- unique_ptr<ParsedExpression> input;
23493
- unique_ptr<ParsedExpression> lower;
23494
- unique_ptr<ParsedExpression> upper;
23435
+ //! The child of the cast expression
23436
+ unique_ptr<ParsedExpression> child;
23437
+ //! The type to cast to
23438
+ LogicalType cast_type;
23439
+ //! Whether or not this is a try_cast expression
23440
+ bool try_cast;
23495
23441
 
23496
23442
  public:
23497
23443
  string ToString() const override;
23498
23444
 
23499
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
23445
+ static bool Equals(const CastExpression *a, const CastExpression *b);
23500
23446
 
23501
23447
  unique_ptr<ParsedExpression> Copy() const override;
23502
23448
 
@@ -23506,14 +23452,12 @@ public:
23506
23452
  public:
23507
23453
  template <class T, class BASE>
23508
23454
  static string ToString(const T &entry) {
23509
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
23455
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
23456
+ entry.cast_type.ToString() + ")";
23510
23457
  }
23511
23458
  };
23512
23459
  } // namespace duckdb
23513
23460
 
23514
-
23515
-
23516
-
23517
23461
  //===----------------------------------------------------------------------===//
23518
23462
  // DuckDB
23519
23463
  //
@@ -23551,12 +23495,10 @@ public:
23551
23495
  } // namespace duckdb
23552
23496
 
23553
23497
 
23554
-
23555
-
23556
23498
  //===----------------------------------------------------------------------===//
23557
23499
  // DuckDB
23558
23500
  //
23559
- // duckdb/parser/expression/constant_expression.hpp
23501
+ // duckdb/parser/expression/comparison_expression.hpp
23560
23502
  //
23561
23503
  //
23562
23504
  //===----------------------------------------------------------------------===//
@@ -23565,29 +23507,33 @@ public:
23565
23507
 
23566
23508
 
23567
23509
 
23568
-
23569
23510
  namespace duckdb {
23570
-
23571
- //! ConstantExpression represents a constant value in the query
23572
- class ConstantExpression : public ParsedExpression {
23511
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
23512
+ //! and has two children.
23513
+ class ComparisonExpression : public ParsedExpression {
23573
23514
  public:
23574
- DUCKDB_API explicit ConstantExpression(Value val);
23515
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23516
+ unique_ptr<ParsedExpression> right);
23575
23517
 
23576
- //! The constant value referenced
23577
- Value value;
23518
+ unique_ptr<ParsedExpression> left;
23519
+ unique_ptr<ParsedExpression> right;
23578
23520
 
23579
23521
  public:
23580
23522
  string ToString() const override;
23581
23523
 
23582
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
23583
- hash_t Hash() const override;
23524
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
23584
23525
 
23585
23526
  unique_ptr<ParsedExpression> Copy() const override;
23586
23527
 
23587
23528
  void Serialize(FieldWriter &writer) const override;
23588
23529
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23589
- };
23590
23530
 
23531
+ public:
23532
+ template <class T, class BASE>
23533
+ static string ToString(const T &entry) {
23534
+ return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
23535
+ }
23536
+ };
23591
23537
  } // namespace duckdb
23592
23538
 
23593
23539
 
@@ -23596,7 +23542,7 @@ public:
23596
23542
  //===----------------------------------------------------------------------===//
23597
23543
  // DuckDB
23598
23544
  //
23599
- // duckdb/parser/expression/operator_expression.hpp
23545
+ // duckdb/parser/expression/function_expression.hpp
23600
23546
  //
23601
23547
  //
23602
23548
  //===----------------------------------------------------------------------===//
@@ -23607,102 +23553,114 @@ public:
23607
23553
 
23608
23554
 
23609
23555
 
23610
-
23611
23556
  namespace duckdb {
23612
- //! Represents a built-in operator expression
23613
- class OperatorExpression : public ParsedExpression {
23557
+ //! Represents a function call
23558
+ class FunctionExpression : public ParsedExpression {
23614
23559
  public:
23615
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
23616
- unique_ptr<ParsedExpression> right = nullptr);
23617
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23560
+ DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
23561
+ vector<unique_ptr<ParsedExpression>> children,
23562
+ unique_ptr<ParsedExpression> filter = nullptr,
23563
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
23564
+ bool is_operator = false, bool export_state = false);
23565
+ DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
23566
+ unique_ptr<ParsedExpression> filter = nullptr,
23567
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
23568
+ bool is_operator = false, bool export_state = false);
23618
23569
 
23570
+ //! Schema of the function
23571
+ string schema;
23572
+ //! Function name
23573
+ string function_name;
23574
+ //! Whether or not the function is an operator, only used for rendering
23575
+ bool is_operator;
23576
+ //! List of arguments to the function
23619
23577
  vector<unique_ptr<ParsedExpression>> children;
23578
+ //! Whether or not the aggregate function is distinct, only used for aggregates
23579
+ bool distinct;
23580
+ //! Expression representing a filter, only used for aggregates
23581
+ unique_ptr<ParsedExpression> filter;
23582
+ //! Modifier representing an ORDER BY, only used for aggregates
23583
+ unique_ptr<OrderModifier> order_bys;
23584
+ //! whether this function should export its state or not
23585
+ bool export_state;
23620
23586
 
23621
23587
  public:
23622
23588
  string ToString() const override;
23623
23589
 
23624
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23625
-
23626
23590
  unique_ptr<ParsedExpression> Copy() const override;
23627
23591
 
23592
+ static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
23593
+ hash_t Hash() const override;
23594
+
23628
23595
  void Serialize(FieldWriter &writer) const override;
23629
23596
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23630
23597
 
23598
+ void Verify() const override;
23599
+
23631
23600
  public:
23632
23601
  template <class T, class BASE>
23633
- static string ToString(const T &entry) {
23634
- auto op = ExpressionTypeToOperator(entry.type);
23635
- if (!op.empty()) {
23636
- // use the operator string to represent the operator
23637
- D_ASSERT(entry.children.size() == 2);
23638
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23639
- }
23640
- switch (entry.type) {
23641
- case ExpressionType::COMPARE_IN:
23642
- case ExpressionType::COMPARE_NOT_IN: {
23643
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23644
- string in_child = entry.children[0]->ToString();
23645
- string child_list = "(";
23646
- for (idx_t i = 1; i < entry.children.size(); i++) {
23647
- if (i > 1) {
23648
- child_list += ", ";
23602
+ static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
23603
+ bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
23604
+ bool export_state = false, bool add_alias = false) {
23605
+ if (is_operator) {
23606
+ // built-in operator
23607
+ D_ASSERT(!distinct);
23608
+ if (entry.children.size() == 1) {
23609
+ if (StringUtil::Contains(function_name, "__postfix")) {
23610
+ return "(" + entry.children[0]->ToString() + ")" +
23611
+ StringUtil::Replace(function_name, "__postfix", "");
23612
+ } else {
23613
+ return function_name + "(" + entry.children[0]->ToString() + ")";
23649
23614
  }
23650
- child_list += entry.children[i]->ToString();
23615
+ } else if (entry.children.size() == 2) {
23616
+ return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
23617
+ ")";
23651
23618
  }
23652
- child_list += ")";
23653
- return "(" + in_child + op_type + child_list + ")";
23654
23619
  }
23655
- case ExpressionType::OPERATOR_NOT:
23656
- case ExpressionType::GROUPING_FUNCTION:
23657
- case ExpressionType::OPERATOR_COALESCE: {
23658
- string result = ExpressionTypeToString(entry.type);
23659
- result += "(";
23660
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23661
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23662
- result += ")";
23663
- return result;
23620
+ // standard function call
23621
+ string result = schema.empty() ? function_name : schema + "." + function_name;
23622
+ result += "(";
23623
+ if (distinct) {
23624
+ result += "DISTINCT ";
23664
23625
  }
23665
- case ExpressionType::OPERATOR_IS_NULL:
23666
- return "(" + entry.children[0]->ToString() + " IS NULL)";
23667
- case ExpressionType::OPERATOR_IS_NOT_NULL:
23668
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23669
- case ExpressionType::ARRAY_EXTRACT:
23670
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23671
- case ExpressionType::ARRAY_SLICE:
23672
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23673
- entry.children[2]->ToString() + "]";
23674
- case ExpressionType::STRUCT_EXTRACT: {
23675
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
23676
- auto child_string = entry.children[1]->ToString();
23677
- D_ASSERT(child_string.size() >= 3);
23678
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23679
- return "(" + entry.children[0]->ToString() + ")." +
23680
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23626
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
23627
+ return child->alias.empty() || !add_alias
23628
+ ? child->ToString()
23629
+ : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
23630
+ });
23631
+ // ordered aggregate
23632
+ if (order_bys && !order_bys->orders.empty()) {
23633
+ if (entry.children.empty()) {
23634
+ result += ") WITHIN GROUP (";
23635
+ }
23636
+ result += " ORDER BY ";
23637
+ for (idx_t i = 0; i < order_bys->orders.size(); i++) {
23638
+ if (i > 0) {
23639
+ result += ", ";
23640
+ }
23641
+ result += order_bys->orders[i].ToString();
23642
+ }
23681
23643
  }
23682
- case ExpressionType::ARRAY_CONSTRUCTOR: {
23683
- string result = "(ARRAY[";
23684
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23685
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23686
- result += "])";
23687
- return result;
23644
+ result += ")";
23645
+
23646
+ // filtered aggregate
23647
+ if (filter) {
23648
+ result += " FILTER (WHERE " + filter->ToString() + ")";
23688
23649
  }
23689
- default:
23690
- throw InternalException("Unrecognized operator type");
23650
+
23651
+ if (export_state) {
23652
+ result += " EXPORT_STATE";
23691
23653
  }
23654
+
23655
+ return result;
23692
23656
  }
23693
23657
  };
23694
-
23695
23658
  } // namespace duckdb
23696
23659
 
23697
-
23698
-
23699
-
23700
-
23701
-
23702
23660
  //===----------------------------------------------------------------------===//
23703
23661
  // DuckDB
23704
23662
  //
23705
- // duckdb/parser/parsed_data/create_view_info.hpp
23663
+ // duckdb/parser/expression/lambda_expression.hpp
23706
23664
  //
23707
23665
  //
23708
23666
  //===----------------------------------------------------------------------===//
@@ -23714,38 +23672,41 @@ public:
23714
23672
 
23715
23673
  namespace duckdb {
23716
23674
 
23717
- struct CreateViewInfo : public CreateInfo {
23718
- CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
23719
- }
23720
- CreateViewInfo(string schema, string view_name)
23721
- : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
23722
- }
23675
+ //! LambdaExpression represents either:
23676
+ //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
23677
+ //! 2. An OperatorExpression with the "->" operator
23678
+ //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
23679
+ class LambdaExpression : public ParsedExpression {
23680
+ public:
23681
+ LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
23723
23682
 
23724
- //! Table name to insert to
23725
- string view_name;
23726
- //! Aliases of the view
23727
- vector<string> aliases;
23728
- //! Return types
23729
- vector<LogicalType> types;
23730
- //! The SelectStatement of the view
23731
- unique_ptr<SelectStatement> query;
23683
+ unique_ptr<ParsedExpression> lhs;
23684
+ unique_ptr<ParsedExpression> rhs;
23732
23685
 
23733
23686
  public:
23734
- unique_ptr<CreateInfo> Copy() const override {
23735
- auto result = make_unique<CreateViewInfo>(schema, view_name);
23736
- CopyProperties(*result);
23737
- result->aliases = aliases;
23738
- result->types = types;
23739
- result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
23740
- return move(result);
23741
- }
23687
+ string ToString() const override;
23688
+
23689
+ static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
23690
+ hash_t Hash() const override;
23691
+
23692
+ unique_ptr<ParsedExpression> Copy() const override;
23693
+
23694
+ void Serialize(FieldWriter &writer) const override;
23695
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23742
23696
  };
23743
23697
 
23744
23698
  } // namespace duckdb
23699
+
23700
+
23701
+
23702
+
23703
+
23704
+
23705
+
23745
23706
  //===----------------------------------------------------------------------===//
23746
23707
  // DuckDB
23747
23708
  //
23748
- // duckdb/parser/parsed_data/transaction_info.hpp
23709
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23749
23710
  //
23750
23711
  //
23751
23712
  //===----------------------------------------------------------------------===//
@@ -23756,14 +23717,19 @@ public:
23756
23717
 
23757
23718
  namespace duckdb {
23758
23719
 
23759
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
23720
+ enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23721
+
23722
+ struct LoadInfo : public ParseInfo {
23723
+ std::string filename;
23724
+ LoadType load_type;
23760
23725
 
23761
- struct TransactionInfo : public ParseInfo {
23762
- explicit TransactionInfo(TransactionType type) : type(type) {
23726
+ public:
23727
+ unique_ptr<LoadInfo> Copy() const {
23728
+ auto result = make_unique<LoadInfo>();
23729
+ result->filename = filename;
23730
+ result->load_type = load_type;
23731
+ return result;
23763
23732
  }
23764
-
23765
- //! The type of transaction statement
23766
- TransactionType type;
23767
23733
  };
23768
23734
 
23769
23735
  } // namespace duckdb
@@ -23810,7 +23776,7 @@ public:
23810
23776
  //===----------------------------------------------------------------------===//
23811
23777
  // DuckDB
23812
23778
  //
23813
- // duckdb/parser/parsed_data/create_schema_info.hpp
23779
+ // duckdb/parser/parsed_data/drop_info.hpp
23814
23780
  //
23815
23781
  //
23816
23782
  //===----------------------------------------------------------------------===//
@@ -23819,18 +23785,60 @@ public:
23819
23785
 
23820
23786
 
23821
23787
 
23788
+
23822
23789
  namespace duckdb {
23823
23790
 
23824
- struct CreateSchemaInfo : public CreateInfo {
23825
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
23791
+ struct DropInfo : public ParseInfo {
23792
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23826
23793
  }
23827
23794
 
23795
+ //! The catalog type to drop
23796
+ CatalogType type;
23797
+ //! Schema name to drop from, if any
23798
+ string schema;
23799
+ //! Element name to drop
23800
+ string name;
23801
+ //! Ignore if the entry does not exist instead of failing
23802
+ bool if_exists = false;
23803
+ //! Cascade drop (drop all dependents instead of throwing an error if there
23804
+ //! are any)
23805
+ bool cascade = false;
23806
+
23828
23807
  public:
23829
- unique_ptr<CreateInfo> Copy() const override {
23830
- auto result = make_unique<CreateSchemaInfo>();
23831
- CopyProperties(*result);
23832
- return move(result);
23808
+ unique_ptr<DropInfo> Copy() const {
23809
+ auto result = make_unique<DropInfo>();
23810
+ result->type = type;
23811
+ result->schema = schema;
23812
+ result->name = name;
23813
+ result->if_exists = if_exists;
23814
+ result->cascade = cascade;
23815
+ return result;
23816
+ }
23817
+ };
23818
+
23819
+ } // namespace duckdb
23820
+ //===----------------------------------------------------------------------===//
23821
+ // DuckDB
23822
+ //
23823
+ // duckdb/parser/parsed_data/transaction_info.hpp
23824
+ //
23825
+ //
23826
+ //===----------------------------------------------------------------------===//
23827
+
23828
+
23829
+
23830
+
23831
+
23832
+ namespace duckdb {
23833
+
23834
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
23835
+
23836
+ struct TransactionInfo : public ParseInfo {
23837
+ explicit TransactionInfo(TransactionType type) : type(type) {
23833
23838
  }
23839
+
23840
+ //! The type of transaction statement
23841
+ TransactionType type;
23834
23842
  };
23835
23843
 
23836
23844
  } // namespace duckdb
@@ -23921,7 +23929,7 @@ public:
23921
23929
  //===----------------------------------------------------------------------===//
23922
23930
  // DuckDB
23923
23931
  //
23924
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23932
+ // duckdb/parser/parsed_data/show_select_info.hpp
23925
23933
  //
23926
23934
  //
23927
23935
  //===----------------------------------------------------------------------===//
@@ -23933,36 +23941,63 @@ public:
23933
23941
 
23934
23942
  namespace duckdb {
23935
23943
 
23936
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23937
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
23938
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23939
- this->name = function.name;
23940
- functions.AddFunction(move(function));
23941
- }
23944
+ struct ShowSelectInfo : public ParseInfo {
23945
+ //! Types of projected columns
23946
+ vector<LogicalType> types;
23947
+ //! The QueryNode of select query
23948
+ unique_ptr<QueryNode> query;
23949
+ //! Aliases of projected columns
23950
+ vector<string> aliases;
23951
+ //! Whether or not we are requesting a summary or a describe
23952
+ bool is_summary;
23942
23953
 
23943
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23944
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23945
- this->name = functions.name;
23946
- for (auto &func : functions.functions) {
23947
- func.name = functions.name;
23948
- }
23954
+ unique_ptr<ShowSelectInfo> Copy() {
23955
+ auto result = make_unique<ShowSelectInfo>();
23956
+ result->types = types;
23957
+ result->query = query->Copy();
23958
+ result->aliases = aliases;
23959
+ result->is_summary = is_summary;
23960
+ return result;
23949
23961
  }
23962
+ };
23950
23963
 
23951
- AggregateFunctionSet functions;
23964
+ } // namespace duckdb
23965
+ //===----------------------------------------------------------------------===//
23966
+ // DuckDB
23967
+ //
23968
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23969
+ //
23970
+ //
23971
+ //===----------------------------------------------------------------------===//
23952
23972
 
23953
- public:
23954
- unique_ptr<CreateInfo> Copy() const override {
23955
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23956
- CopyProperties(*result);
23957
- return move(result);
23958
- }
23973
+
23974
+
23975
+
23976
+
23977
+ namespace duckdb {
23978
+
23979
+ struct VacuumInfo : public ParseInfo {
23980
+ // nothing for now
23959
23981
  };
23960
23982
 
23961
23983
  } // namespace duckdb
23962
23984
  //===----------------------------------------------------------------------===//
23963
23985
  // DuckDB
23964
23986
  //
23965
- // duckdb/parser/parsed_data/show_select_info.hpp
23987
+ // duckdb/parser/parsed_data/create_index_info.hpp
23988
+ //
23989
+ //
23990
+ //===----------------------------------------------------------------------===//
23991
+
23992
+
23993
+
23994
+
23995
+
23996
+
23997
+ //===----------------------------------------------------------------------===//
23998
+ // DuckDB
23999
+ //
24000
+ // duckdb/parser/tableref/basetableref.hpp
23966
24001
  //
23967
24002
  //
23968
24003
  //===----------------------------------------------------------------------===//
@@ -23973,24 +24008,63 @@ public:
23973
24008
 
23974
24009
 
23975
24010
  namespace duckdb {
24011
+ //! Represents a TableReference to a base table in the schema
24012
+ class BaseTableRef : public TableRef {
24013
+ public:
24014
+ BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
24015
+ }
23976
24016
 
23977
- struct ShowSelectInfo : public ParseInfo {
23978
- //! Types of projected columns
23979
- vector<LogicalType> types;
23980
- //! The QueryNode of select query
23981
- unique_ptr<QueryNode> query;
23982
- //! Aliases of projected columns
23983
- vector<string> aliases;
23984
- //! Whether or not we are requesting a summary or a describe
23985
- bool is_summary;
24017
+ //! Schema name
24018
+ string schema_name;
24019
+ //! Table name
24020
+ string table_name;
24021
+ //! Aliases for the column names
24022
+ vector<string> column_name_alias;
23986
24023
 
23987
- unique_ptr<ShowSelectInfo> Copy() {
23988
- auto result = make_unique<ShowSelectInfo>();
23989
- result->types = types;
23990
- result->query = query->Copy();
23991
- result->aliases = aliases;
23992
- result->is_summary = is_summary;
23993
- return result;
24024
+ public:
24025
+ string ToString() const override;
24026
+ bool Equals(const TableRef *other_p) const override;
24027
+
24028
+ unique_ptr<TableRef> Copy() override;
24029
+
24030
+ //! Serializes a blob into a BaseTableRef
24031
+ void Serialize(FieldWriter &serializer) const override;
24032
+ //! Deserializes a blob back into a BaseTableRef
24033
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
24034
+ };
24035
+ } // namespace duckdb
24036
+
24037
+
24038
+
24039
+ namespace duckdb {
24040
+
24041
+ struct CreateIndexInfo : public CreateInfo {
24042
+ CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
24043
+ }
24044
+
24045
+ //! Index Type (e.g., B+-tree, Skip-List, ...)
24046
+ IndexType index_type;
24047
+ //! Name of the Index
24048
+ string index_name;
24049
+ //! If it is an unique index
24050
+ bool unique = false;
24051
+ //! The table to create the index on
24052
+ unique_ptr<BaseTableRef> table;
24053
+ //! Set of expressions to index by
24054
+ vector<unique_ptr<ParsedExpression>> expressions;
24055
+
24056
+ public:
24057
+ unique_ptr<CreateInfo> Copy() const override {
24058
+ auto result = make_unique<CreateIndexInfo>();
24059
+ CopyProperties(*result);
24060
+ result->index_type = index_type;
24061
+ result->index_name = index_name;
24062
+ result->unique = unique;
24063
+ result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
24064
+ for (auto &expr : expressions) {
24065
+ result->expressions.push_back(expr->Copy());
24066
+ }
24067
+ return move(result);
23994
24068
  }
23995
24069
  };
23996
24070
 
@@ -24034,7 +24108,7 @@ struct BoundExportData : public ParseInfo {
24034
24108
  //===----------------------------------------------------------------------===//
24035
24109
  // DuckDB
24036
24110
  //
24037
- // duckdb/parser/parsed_data/drop_info.hpp
24111
+ // duckdb/parser/parsed_data/create_schema_info.hpp
24038
24112
  //
24039
24113
  //
24040
24114
  //===----------------------------------------------------------------------===//
@@ -24043,34 +24117,17 @@ struct BoundExportData : public ParseInfo {
24043
24117
 
24044
24118
 
24045
24119
 
24046
-
24047
24120
  namespace duckdb {
24048
24121
 
24049
- struct DropInfo : public ParseInfo {
24050
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
24122
+ struct CreateSchemaInfo : public CreateInfo {
24123
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
24051
24124
  }
24052
24125
 
24053
- //! The catalog type to drop
24054
- CatalogType type;
24055
- //! Schema name to drop from, if any
24056
- string schema;
24057
- //! Element name to drop
24058
- string name;
24059
- //! Ignore if the entry does not exist instead of failing
24060
- bool if_exists = false;
24061
- //! Cascade drop (drop all dependents instead of throwing an error if there
24062
- //! are any)
24063
- bool cascade = false;
24064
-
24065
24126
  public:
24066
- unique_ptr<DropInfo> Copy() const {
24067
- auto result = make_unique<DropInfo>();
24068
- result->type = type;
24069
- result->schema = schema;
24070
- result->name = name;
24071
- result->if_exists = if_exists;
24072
- result->cascade = cascade;
24073
- return result;
24127
+ unique_ptr<CreateInfo> Copy() const override {
24128
+ auto result = make_unique<CreateSchemaInfo>();
24129
+ CopyProperties(*result);
24130
+ return move(result);
24074
24131
  }
24075
24132
  };
24076
24133
 
@@ -24078,20 +24135,7 @@ public:
24078
24135
  //===----------------------------------------------------------------------===//
24079
24136
  // DuckDB
24080
24137
  //
24081
- // duckdb/parser/parsed_data/create_index_info.hpp
24082
- //
24083
- //
24084
- //===----------------------------------------------------------------------===//
24085
-
24086
-
24087
-
24088
-
24089
-
24090
-
24091
- //===----------------------------------------------------------------------===//
24092
- // DuckDB
24093
- //
24094
- // duckdb/parser/tableref/basetableref.hpp
24138
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
24095
24139
  //
24096
24140
  //
24097
24141
  //===----------------------------------------------------------------------===//
@@ -24102,62 +24146,28 @@ public:
24102
24146
 
24103
24147
 
24104
24148
  namespace duckdb {
24105
- //! Represents a TableReference to a base table in the schema
24106
- class BaseTableRef : public TableRef {
24107
- public:
24108
- BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
24109
- }
24110
-
24111
- //! Schema name
24112
- string schema_name;
24113
- //! Table name
24114
- string table_name;
24115
- //! Aliases for the column names
24116
- vector<string> column_name_alias;
24117
-
24118
- public:
24119
- string ToString() const override;
24120
- bool Equals(const TableRef *other_p) const override;
24121
24149
 
24122
- unique_ptr<TableRef> Copy() override;
24123
-
24124
- //! Serializes a blob into a BaseTableRef
24125
- void Serialize(FieldWriter &serializer) const override;
24126
- //! Deserializes a blob back into a BaseTableRef
24127
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
24128
- };
24129
- } // namespace duckdb
24130
-
24131
-
24132
-
24133
- namespace duckdb {
24150
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
24151
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
24152
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
24153
+ this->name = function.name;
24154
+ functions.AddFunction(move(function));
24155
+ }
24134
24156
 
24135
- struct CreateIndexInfo : public CreateInfo {
24136
- CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
24157
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
24158
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
24159
+ this->name = functions.name;
24160
+ for (auto &func : functions.functions) {
24161
+ func.name = functions.name;
24162
+ }
24137
24163
  }
24138
24164
 
24139
- //! Index Type (e.g., B+-tree, Skip-List, ...)
24140
- IndexType index_type;
24141
- //! Name of the Index
24142
- string index_name;
24143
- //! If it is an unique index
24144
- bool unique = false;
24145
- //! The table to create the index on
24146
- unique_ptr<BaseTableRef> table;
24147
- //! Set of expressions to index by
24148
- vector<unique_ptr<ParsedExpression>> expressions;
24165
+ AggregateFunctionSet functions;
24149
24166
 
24150
24167
  public:
24151
24168
  unique_ptr<CreateInfo> Copy() const override {
24152
- auto result = make_unique<CreateIndexInfo>();
24169
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
24153
24170
  CopyProperties(*result);
24154
- result->index_type = index_type;
24155
- result->index_name = index_name;
24156
- result->unique = unique;
24157
- result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
24158
- for (auto &expr : expressions) {
24159
- result->expressions.push_back(expr->Copy());
24160
- }
24161
24171
  return move(result);
24162
24172
  }
24163
24173
  };
@@ -24166,7 +24176,7 @@ public:
24166
24176
  //===----------------------------------------------------------------------===//
24167
24177
  // DuckDB
24168
24178
  //
24169
- // duckdb/parser/parsed_data/vacuum_info.hpp
24179
+ // duckdb/parser/parsed_data/create_type_info.hpp
24170
24180
  //
24171
24181
  //
24172
24182
  //===----------------------------------------------------------------------===//
@@ -24175,10 +24185,29 @@ public:
24175
24185
 
24176
24186
 
24177
24187
 
24188
+
24189
+
24190
+
24178
24191
  namespace duckdb {
24179
24192
 
24180
- struct VacuumInfo : public ParseInfo {
24181
- // nothing for now
24193
+ struct CreateTypeInfo : public CreateInfo {
24194
+
24195
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
24196
+ }
24197
+
24198
+ //! Name of the Type
24199
+ string name;
24200
+ //! Logical Type
24201
+ LogicalType type;
24202
+
24203
+ public:
24204
+ unique_ptr<CreateInfo> Copy() const override {
24205
+ auto result = make_unique<CreateTypeInfo>();
24206
+ CopyProperties(*result);
24207
+ result->name = name;
24208
+ result->type = type;
24209
+ return move(result);
24210
+ }
24182
24211
  };
24183
24212
 
24184
24213
  } // namespace duckdb
@@ -24227,37 +24256,7 @@ public:
24227
24256
  //===----------------------------------------------------------------------===//
24228
24257
  // DuckDB
24229
24258
  //
24230
- // duckdb/parser/parsed_data/vacuum_info.hpp
24231
- //
24232
- //
24233
- //===----------------------------------------------------------------------===//
24234
-
24235
-
24236
-
24237
-
24238
-
24239
- namespace duckdb {
24240
-
24241
- enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
24242
-
24243
- struct LoadInfo : public ParseInfo {
24244
- std::string filename;
24245
- LoadType load_type;
24246
-
24247
- public:
24248
- unique_ptr<LoadInfo> Copy() const {
24249
- auto result = make_unique<LoadInfo>();
24250
- result->filename = filename;
24251
- result->load_type = load_type;
24252
- return result;
24253
- }
24254
- };
24255
-
24256
- } // namespace duckdb
24257
- //===----------------------------------------------------------------------===//
24258
- // DuckDB
24259
- //
24260
- // duckdb/parser/parsed_data/create_type_info.hpp
24259
+ // duckdb/parser/parsed_data/create_view_info.hpp
24261
24260
  //
24262
24261
  //
24263
24262
  //===----------------------------------------------------------------------===//
@@ -24267,26 +24266,31 @@ public:
24267
24266
 
24268
24267
 
24269
24268
 
24270
-
24271
-
24272
24269
  namespace duckdb {
24273
24270
 
24274
- struct CreateTypeInfo : public CreateInfo {
24275
-
24276
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
24271
+ struct CreateViewInfo : public CreateInfo {
24272
+ CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
24273
+ }
24274
+ CreateViewInfo(string schema, string view_name)
24275
+ : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
24277
24276
  }
24278
24277
 
24279
- //! Name of the Type
24280
- string name;
24281
- //! Logical Type
24282
- LogicalType type;
24278
+ //! Table name to insert to
24279
+ string view_name;
24280
+ //! Aliases of the view
24281
+ vector<string> aliases;
24282
+ //! Return types
24283
+ vector<LogicalType> types;
24284
+ //! The SelectStatement of the view
24285
+ unique_ptr<SelectStatement> query;
24283
24286
 
24284
24287
  public:
24285
24288
  unique_ptr<CreateInfo> Copy() const override {
24286
- auto result = make_unique<CreateTypeInfo>();
24289
+ auto result = make_unique<CreateViewInfo>(schema, view_name);
24287
24290
  CopyProperties(*result);
24288
- result->name = name;
24289
- result->type = type;
24291
+ result->aliases = aliases;
24292
+ result->types = types;
24293
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
24290
24294
  return move(result);
24291
24295
  }
24292
24296
  };
@@ -24295,7 +24299,7 @@ public:
24295
24299
  //===----------------------------------------------------------------------===//
24296
24300
  // DuckDB
24297
24301
  //
24298
- // duckdb/parser/tableref/subqueryref.hpp
24302
+ // duckdb/parser/tableref/emptytableref.hpp
24299
24303
  //
24300
24304
  //
24301
24305
  //===----------------------------------------------------------------------===//
@@ -24304,17 +24308,12 @@ public:
24304
24308
 
24305
24309
 
24306
24310
 
24307
-
24308
24311
  namespace duckdb {
24309
- //! Represents a subquery
24310
- class SubqueryRef : public TableRef {
24312
+ //! Represents a cross product
24313
+ class EmptyTableRef : public TableRef {
24311
24314
  public:
24312
- explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
24313
-
24314
- //! The subquery
24315
- unique_ptr<SelectStatement> subquery;
24316
- //! Aliases for the column names
24317
- vector<string> column_name_alias;
24315
+ EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
24316
+ }
24318
24317
 
24319
24318
  public:
24320
24319
  string ToString() const override;
@@ -24322,16 +24321,16 @@ public:
24322
24321
 
24323
24322
  unique_ptr<TableRef> Copy() override;
24324
24323
 
24325
- //! Serializes a blob into a SubqueryRef
24324
+ //! Serializes a blob into a DummyTableRef
24326
24325
  void Serialize(FieldWriter &serializer) const override;
24327
- //! Deserializes a blob back into a SubqueryRef
24326
+ //! Deserializes a blob back into a DummyTableRef
24328
24327
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24329
24328
  };
24330
24329
  } // namespace duckdb
24331
24330
  //===----------------------------------------------------------------------===//
24332
24331
  // DuckDB
24333
24332
  //
24334
- // duckdb/parser/tableref/expressionlistref.hpp
24333
+ // duckdb/parser/tableref/joinref.hpp
24335
24334
  //
24336
24335
  //
24337
24336
  //===----------------------------------------------------------------------===//
@@ -24343,19 +24342,26 @@ public:
24343
24342
 
24344
24343
 
24345
24344
 
24345
+
24346
24346
  namespace duckdb {
24347
- //! Represents an expression list as generated by a VALUES statement
24348
- class ExpressionListRef : public TableRef {
24347
+ //! Represents a JOIN between two expressions
24348
+ class JoinRef : public TableRef {
24349
24349
  public:
24350
- ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
24350
+ JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
24351
24351
  }
24352
24352
 
24353
- //! Value list, only used for VALUES statement
24354
- vector<vector<unique_ptr<ParsedExpression>>> values;
24355
- //! Expected SQL types
24356
- vector<LogicalType> expected_types;
24357
- //! The set of expected names
24358
- vector<string> expected_names;
24353
+ //! The left hand side of the join
24354
+ unique_ptr<TableRef> left;
24355
+ //! The right hand side of the join
24356
+ unique_ptr<TableRef> right;
24357
+ //! The join condition
24358
+ unique_ptr<ParsedExpression> condition;
24359
+ //! The join type
24360
+ JoinType type;
24361
+ //! Natural join
24362
+ bool is_natural;
24363
+ //! The set of USING columns (if any)
24364
+ vector<string> using_columns;
24359
24365
 
24360
24366
  public:
24361
24367
  string ToString() const override;
@@ -24363,13 +24369,12 @@ public:
24363
24369
 
24364
24370
  unique_ptr<TableRef> Copy() override;
24365
24371
 
24366
- //! Serializes a blob into a ExpressionListRef
24372
+ //! Serializes a blob into a JoinRef
24367
24373
  void Serialize(FieldWriter &serializer) const override;
24368
- //! Deserializes a blob back into a ExpressionListRef
24374
+ //! Deserializes a blob back into a JoinRef
24369
24375
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24370
24376
  };
24371
24377
  } // namespace duckdb
24372
-
24373
24378
  //===----------------------------------------------------------------------===//
24374
24379
  // DuckDB
24375
24380
  //
@@ -24407,10 +24412,12 @@ public:
24407
24412
  };
24408
24413
  } // namespace duckdb
24409
24414
 
24415
+
24416
+
24410
24417
  //===----------------------------------------------------------------------===//
24411
24418
  // DuckDB
24412
24419
  //
24413
- // duckdb/parser/tableref/emptytableref.hpp
24420
+ // duckdb/parser/tableref/expressionlistref.hpp
24414
24421
  //
24415
24422
  //
24416
24423
  //===----------------------------------------------------------------------===//
@@ -24419,22 +24426,32 @@ public:
24419
24426
 
24420
24427
 
24421
24428
 
24429
+
24430
+
24431
+
24422
24432
  namespace duckdb {
24423
- //! Represents a cross product
24424
- class EmptyTableRef : public TableRef {
24433
+ //! Represents an expression list as generated by a VALUES statement
24434
+ class ExpressionListRef : public TableRef {
24425
24435
  public:
24426
- EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
24436
+ ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
24427
24437
  }
24428
24438
 
24439
+ //! Value list, only used for VALUES statement
24440
+ vector<vector<unique_ptr<ParsedExpression>>> values;
24441
+ //! Expected SQL types
24442
+ vector<LogicalType> expected_types;
24443
+ //! The set of expected names
24444
+ vector<string> expected_names;
24445
+
24429
24446
  public:
24430
24447
  string ToString() const override;
24431
24448
  bool Equals(const TableRef *other_p) const override;
24432
24449
 
24433
24450
  unique_ptr<TableRef> Copy() override;
24434
24451
 
24435
- //! Serializes a blob into a DummyTableRef
24452
+ //! Serializes a blob into a ExpressionListRef
24436
24453
  void Serialize(FieldWriter &serializer) const override;
24437
- //! Deserializes a blob back into a DummyTableRef
24454
+ //! Deserializes a blob back into a ExpressionListRef
24438
24455
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24439
24456
  };
24440
24457
  } // namespace duckdb
@@ -24443,7 +24460,7 @@ public:
24443
24460
  //===----------------------------------------------------------------------===//
24444
24461
  // DuckDB
24445
24462
  //
24446
- // duckdb/parser/tableref/joinref.hpp
24463
+ // duckdb/parser/tableref/subqueryref.hpp
24447
24464
  //
24448
24465
  //
24449
24466
  //===----------------------------------------------------------------------===//
@@ -24453,28 +24470,16 @@ public:
24453
24470
 
24454
24471
 
24455
24472
 
24456
-
24457
-
24458
-
24459
24473
  namespace duckdb {
24460
- //! Represents a JOIN between two expressions
24461
- class JoinRef : public TableRef {
24474
+ //! Represents a subquery
24475
+ class SubqueryRef : public TableRef {
24462
24476
  public:
24463
- JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
24464
- }
24477
+ explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
24465
24478
 
24466
- //! The left hand side of the join
24467
- unique_ptr<TableRef> left;
24468
- //! The right hand side of the join
24469
- unique_ptr<TableRef> right;
24470
- //! The join condition
24471
- unique_ptr<ParsedExpression> condition;
24472
- //! The join type
24473
- JoinType type;
24474
- //! Natural join
24475
- bool is_natural;
24476
- //! The set of USING columns (if any)
24477
- vector<string> using_columns;
24479
+ //! The subquery
24480
+ unique_ptr<SelectStatement> subquery;
24481
+ //! Aliases for the column names
24482
+ vector<string> column_name_alias;
24478
24483
 
24479
24484
  public:
24480
24485
  string ToString() const override;
@@ -24482,14 +24487,13 @@ public:
24482
24487
 
24483
24488
  unique_ptr<TableRef> Copy() override;
24484
24489
 
24485
- //! Serializes a blob into a JoinRef
24490
+ //! Serializes a blob into a SubqueryRef
24486
24491
  void Serialize(FieldWriter &serializer) const override;
24487
- //! Deserializes a blob back into a JoinRef
24492
+ //! Deserializes a blob back into a SubqueryRef
24488
24493
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24489
24494
  };
24490
24495
  } // namespace duckdb
24491
24496
 
24492
-
24493
24497
  //===----------------------------------------------------------------------===//
24494
24498
  // DuckDB
24495
24499
  //