duckdb 0.3.3-dev1425.0 → 0.3.3-dev1434.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 "f9fcdc7d0"
15
- #define DUCKDB_VERSION "v0.3.3-dev1425"
14
+ #define DUCKDB_SOURCE_ID "f063337d9"
15
+ #define DUCKDB_VERSION "v0.3.3-dev1434"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -1242,9 +1242,10 @@ enum class ExceptionFormatValueType : uint8_t {
1242
1242
  };
1243
1243
 
1244
1244
  struct ExceptionFormatValue {
1245
- DUCKDB_API ExceptionFormatValue(double dbl_val); // NOLINT
1246
- DUCKDB_API ExceptionFormatValue(int64_t int_val); // NOLINT
1247
- DUCKDB_API ExceptionFormatValue(string str_val); // NOLINT
1245
+ DUCKDB_API ExceptionFormatValue(double dbl_val); // NOLINT
1246
+ DUCKDB_API ExceptionFormatValue(int64_t int_val); // NOLINT
1247
+ DUCKDB_API ExceptionFormatValue(string str_val); // NOLINT
1248
+ DUCKDB_API ExceptionFormatValue(hugeint_t hg_val); // NOLINT
1248
1249
 
1249
1250
  ExceptionFormatValueType type;
1250
1251
 
@@ -1274,6 +1275,8 @@ template <>
1274
1275
  DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(const char *value);
1275
1276
  template <>
1276
1277
  DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(char *value);
1278
+ template <>
1279
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(hugeint_t value);
1277
1280
 
1278
1281
  } // namespace duckdb
1279
1282
 
@@ -22321,7 +22324,7 @@ private:
22321
22324
  //===----------------------------------------------------------------------===//
22322
22325
  // DuckDB
22323
22326
  //
22324
- // duckdb/parser/expression/lambda_expression.hpp
22327
+ // duckdb/parser/expression/positional_reference_expression.hpp
22325
22328
  //
22326
22329
  //
22327
22330
  //===----------------------------------------------------------------------===//
@@ -22330,37 +22333,32 @@ private:
22330
22333
 
22331
22334
 
22332
22335
 
22333
-
22334
22336
  namespace duckdb {
22335
-
22336
- //! LambdaExpression represents either:
22337
- //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
22338
- //! 2. An OperatorExpression with the "->" operator
22339
- //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
22340
- class LambdaExpression : public ParsedExpression {
22337
+ class PositionalReferenceExpression : public ParsedExpression {
22341
22338
  public:
22342
- LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
22339
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
22343
22340
 
22344
- unique_ptr<ParsedExpression> lhs;
22345
- unique_ptr<ParsedExpression> rhs;
22341
+ idx_t index;
22346
22342
 
22347
22343
  public:
22348
- string ToString() const override;
22344
+ bool IsScalar() const override {
22345
+ return false;
22346
+ }
22349
22347
 
22350
- static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
22351
- hash_t Hash() const override;
22348
+ string ToString() const override;
22352
22349
 
22350
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
22353
22351
  unique_ptr<ParsedExpression> Copy() const override;
22352
+ hash_t Hash() const override;
22354
22353
 
22355
22354
  void Serialize(FieldWriter &writer) const override;
22356
22355
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22357
22356
  };
22358
-
22359
22357
  } // namespace duckdb
22360
22358
  //===----------------------------------------------------------------------===//
22361
22359
  // DuckDB
22362
22360
  //
22363
- // duckdb/parser/expression/case_expression.hpp
22361
+ // duckdb/parser/expression/conjunction_expression.hpp
22364
22362
  //
22365
22363
  //
22366
22364
  //===----------------------------------------------------------------------===//
@@ -22372,23 +22370,22 @@ public:
22372
22370
 
22373
22371
  namespace duckdb {
22374
22372
 
22375
- struct CaseCheck {
22376
- unique_ptr<ParsedExpression> when_expr;
22377
- unique_ptr<ParsedExpression> then_expr;
22378
- };
22379
-
22380
- //! The CaseExpression represents a CASE expression in the query
22381
- class CaseExpression : public ParsedExpression {
22373
+ //! Represents a conjunction (AND/OR)
22374
+ class ConjunctionExpression : public ParsedExpression {
22382
22375
  public:
22383
- DUCKDB_API CaseExpression();
22376
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22377
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22378
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22379
+ unique_ptr<ParsedExpression> right);
22384
22380
 
22385
- vector<CaseCheck> case_checks;
22386
- unique_ptr<ParsedExpression> else_expr;
22381
+ vector<unique_ptr<ParsedExpression>> children;
22387
22382
 
22388
22383
  public:
22384
+ void AddExpression(unique_ptr<ParsedExpression> expr);
22385
+
22389
22386
  string ToString() const override;
22390
22387
 
22391
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
22388
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22392
22389
 
22393
22390
  unique_ptr<ParsedExpression> Copy() const override;
22394
22391
 
@@ -22398,21 +22395,18 @@ public:
22398
22395
  public:
22399
22396
  template <class T, class BASE>
22400
22397
  static string ToString(const T &entry) {
22401
- string case_str = "CASE ";
22402
- for (auto &check : entry.case_checks) {
22403
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
22404
- case_str += " THEN (" + check.then_expr->ToString() + ")";
22398
+ string result = entry.children[0]->ToString();
22399
+ for (idx_t i = 1; i < entry.children.size(); i++) {
22400
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22405
22401
  }
22406
- case_str += " ELSE " + entry.else_expr->ToString();
22407
- case_str += " END";
22408
- return case_str;
22402
+ return result;
22409
22403
  }
22410
22404
  };
22411
22405
  } // namespace duckdb
22412
22406
  //===----------------------------------------------------------------------===//
22413
22407
  // DuckDB
22414
22408
  //
22415
- // duckdb/parser/expression/conjunction_expression.hpp
22409
+ // duckdb/parser/expression/parameter_expression.hpp
22416
22410
  //
22417
22411
  //
22418
22412
  //===----------------------------------------------------------------------===//
@@ -22421,46 +22415,34 @@ public:
22421
22415
 
22422
22416
 
22423
22417
 
22424
-
22425
22418
  namespace duckdb {
22426
-
22427
- //! Represents a conjunction (AND/OR)
22428
- class ConjunctionExpression : public ParsedExpression {
22419
+ class ParameterExpression : public ParsedExpression {
22429
22420
  public:
22430
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22431
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22432
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22433
- unique_ptr<ParsedExpression> right);
22421
+ ParameterExpression();
22434
22422
 
22435
- vector<unique_ptr<ParsedExpression>> children;
22423
+ idx_t parameter_nr;
22436
22424
 
22437
22425
  public:
22438
- void AddExpression(unique_ptr<ParsedExpression> expr);
22426
+ bool IsScalar() const override {
22427
+ return true;
22428
+ }
22429
+ bool HasParameter() const override {
22430
+ return true;
22431
+ }
22439
22432
 
22440
22433
  string ToString() const override;
22441
22434
 
22442
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22443
-
22444
22435
  unique_ptr<ParsedExpression> Copy() const override;
22436
+ hash_t Hash() const override;
22445
22437
 
22446
22438
  void Serialize(FieldWriter &writer) const override;
22447
22439
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22448
-
22449
- public:
22450
- template <class T, class BASE>
22451
- static string ToString(const T &entry) {
22452
- string result = entry.children[0]->ToString();
22453
- for (idx_t i = 1; i < entry.children.size(); i++) {
22454
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22455
- }
22456
- return result;
22457
- }
22458
22440
  };
22459
22441
  } // namespace duckdb
22460
22442
  //===----------------------------------------------------------------------===//
22461
22443
  // DuckDB
22462
22444
  //
22463
- // duckdb/parser/expression/function_expression.hpp
22445
+ // duckdb/parser/expression/cast_expression.hpp
22464
22446
  //
22465
22447
  //
22466
22448
  //===----------------------------------------------------------------------===//
@@ -22470,111 +22452,42 @@ public:
22470
22452
 
22471
22453
 
22472
22454
 
22473
-
22474
22455
  namespace duckdb {
22475
- //! Represents a function call
22476
- class FunctionExpression : public ParsedExpression {
22456
+
22457
+ //! CastExpression represents a type cast from one SQL type to another SQL type
22458
+ class CastExpression : public ParsedExpression {
22477
22459
  public:
22478
- DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
22479
- vector<unique_ptr<ParsedExpression>> children,
22480
- unique_ptr<ParsedExpression> filter = nullptr,
22481
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
22482
- bool is_operator = false, bool export_state = false);
22483
- DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
22484
- unique_ptr<ParsedExpression> filter = nullptr,
22485
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
22486
- bool is_operator = false, bool export_state = false);
22460
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
22487
22461
 
22488
- //! Schema of the function
22489
- string schema;
22490
- //! Function name
22491
- string function_name;
22492
- //! Whether or not the function is an operator, only used for rendering
22493
- bool is_operator;
22494
- //! List of arguments to the function
22495
- vector<unique_ptr<ParsedExpression>> children;
22496
- //! Whether or not the aggregate function is distinct, only used for aggregates
22497
- bool distinct;
22498
- //! Expression representing a filter, only used for aggregates
22499
- unique_ptr<ParsedExpression> filter;
22500
- //! Modifier representing an ORDER BY, only used for aggregates
22501
- unique_ptr<OrderModifier> order_bys;
22502
- //! whether this function should export its state or not
22503
- bool export_state;
22462
+ //! The child of the cast expression
22463
+ unique_ptr<ParsedExpression> child;
22464
+ //! The type to cast to
22465
+ LogicalType cast_type;
22466
+ //! Whether or not this is a try_cast expression
22467
+ bool try_cast;
22504
22468
 
22505
22469
  public:
22506
22470
  string ToString() const override;
22507
22471
 
22508
- unique_ptr<ParsedExpression> Copy() const override;
22472
+ static bool Equals(const CastExpression *a, const CastExpression *b);
22509
22473
 
22510
- static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
22511
- hash_t Hash() const override;
22474
+ unique_ptr<ParsedExpression> Copy() const override;
22512
22475
 
22513
22476
  void Serialize(FieldWriter &writer) const override;
22514
22477
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22515
22478
 
22516
- void Verify() const override;
22517
-
22518
22479
  public:
22519
22480
  template <class T, class BASE>
22520
- static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
22521
- bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
22522
- bool export_state = false) {
22523
- if (is_operator) {
22524
- // built-in operator
22525
- D_ASSERT(!distinct);
22526
- if (entry.children.size() == 1) {
22527
- if (StringUtil::Contains(function_name, "__postfix")) {
22528
- return "(" + entry.children[0]->ToString() + ")" +
22529
- StringUtil::Replace(function_name, "__postfix", "");
22530
- } else {
22531
- return function_name + "(" + entry.children[0]->ToString() + ")";
22532
- }
22533
- } else if (entry.children.size() == 2) {
22534
- return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
22535
- ")";
22536
- }
22537
- }
22538
- // standard function call
22539
- string result = schema.empty() ? function_name : schema + "." + function_name;
22540
- result += "(";
22541
- if (distinct) {
22542
- result += "DISTINCT ";
22543
- }
22544
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22545
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22546
- // ordered aggregate
22547
- if (order_bys && !order_bys->orders.empty()) {
22548
- if (entry.children.empty()) {
22549
- result += ") WITHIN GROUP (";
22550
- }
22551
- result += " ORDER BY ";
22552
- for (idx_t i = 0; i < order_bys->orders.size(); i++) {
22553
- if (i > 0) {
22554
- result += ", ";
22555
- }
22556
- result += order_bys->orders[i].ToString();
22557
- }
22558
- }
22559
- result += ")";
22560
-
22561
- // filtered aggregate
22562
- if (filter) {
22563
- result += " FILTER (WHERE " + filter->ToString() + ")";
22564
- }
22565
-
22566
- if (export_state) {
22567
- result += " EXPORT_STATE";
22568
- }
22569
-
22570
- return result;
22481
+ static string ToString(const T &entry) {
22482
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
22483
+ entry.cast_type.ToString() + ")";
22571
22484
  }
22572
22485
  };
22573
22486
  } // namespace duckdb
22574
22487
  //===----------------------------------------------------------------------===//
22575
22488
  // DuckDB
22576
22489
  //
22577
- // duckdb/parser/expression/default_expression.hpp
22490
+ // duckdb/parser/expression/between_expression.hpp
22578
22491
  //
22579
22492
  //
22580
22493
  //===----------------------------------------------------------------------===//
@@ -22584,22 +22497,31 @@ public:
22584
22497
 
22585
22498
 
22586
22499
  namespace duckdb {
22587
- //! Represents the default value of a column
22588
- class DefaultExpression : public ParsedExpression {
22589
- public:
22590
- DefaultExpression();
22591
22500
 
22501
+ class BetweenExpression : public ParsedExpression {
22592
22502
  public:
22593
- bool IsScalar() const override {
22594
- return false;
22595
- }
22503
+ BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22504
+ unique_ptr<ParsedExpression> upper);
22505
+
22506
+ unique_ptr<ParsedExpression> input;
22507
+ unique_ptr<ParsedExpression> lower;
22508
+ unique_ptr<ParsedExpression> upper;
22596
22509
 
22510
+ public:
22597
22511
  string ToString() const override;
22598
22512
 
22513
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22514
+
22599
22515
  unique_ptr<ParsedExpression> Copy() const override;
22600
22516
 
22601
22517
  void Serialize(FieldWriter &writer) const override;
22602
22518
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22519
+
22520
+ public:
22521
+ template <class T, class BASE>
22522
+ static string ToString(const T &entry) {
22523
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
22524
+ }
22603
22525
  };
22604
22526
  } // namespace duckdb
22605
22527
  //===----------------------------------------------------------------------===//
@@ -22681,7 +22603,7 @@ public:
22681
22603
  //===----------------------------------------------------------------------===//
22682
22604
  // DuckDB
22683
22605
  //
22684
- // duckdb/parser/expression/operator_expression.hpp
22606
+ // duckdb/parser/expression/collate_expression.hpp
22685
22607
  //
22686
22608
  //
22687
22609
  //===----------------------------------------------------------------------===//
@@ -22690,101 +22612,37 @@ public:
22690
22612
 
22691
22613
 
22692
22614
 
22693
-
22694
-
22695
-
22696
22615
  namespace duckdb {
22697
- //! Represents a built-in operator expression
22698
- class OperatorExpression : public ParsedExpression {
22616
+
22617
+ //! CollateExpression represents a COLLATE statement
22618
+ class CollateExpression : public ParsedExpression {
22699
22619
  public:
22700
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
22701
- unique_ptr<ParsedExpression> right = nullptr);
22702
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22620
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
22703
22621
 
22704
- vector<unique_ptr<ParsedExpression>> children;
22622
+ //! The child of the cast expression
22623
+ unique_ptr<ParsedExpression> child;
22624
+ //! The collation clause
22625
+ string collation;
22705
22626
 
22706
22627
  public:
22707
22628
  string ToString() const override;
22708
22629
 
22709
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
22630
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
22710
22631
 
22711
22632
  unique_ptr<ParsedExpression> Copy() const override;
22712
22633
 
22713
22634
  void Serialize(FieldWriter &writer) const override;
22714
22635
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22636
+ };
22637
+ } // namespace duckdb
22638
+ //===----------------------------------------------------------------------===//
22639
+ // DuckDB
22640
+ //
22641
+ // duckdb/parser/expression/star_expression.hpp
22642
+ //
22643
+ //
22644
+ //===----------------------------------------------------------------------===//
22715
22645
 
22716
- public:
22717
- template <class T, class BASE>
22718
- static string ToString(const T &entry) {
22719
- auto op = ExpressionTypeToOperator(entry.type);
22720
- if (!op.empty()) {
22721
- // use the operator string to represent the operator
22722
- D_ASSERT(entry.children.size() == 2);
22723
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
22724
- }
22725
- switch (entry.type) {
22726
- case ExpressionType::COMPARE_IN:
22727
- case ExpressionType::COMPARE_NOT_IN: {
22728
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
22729
- string in_child = entry.children[0]->ToString();
22730
- string child_list = "(";
22731
- for (idx_t i = 1; i < entry.children.size(); i++) {
22732
- if (i > 1) {
22733
- child_list += ", ";
22734
- }
22735
- child_list += entry.children[i]->ToString();
22736
- }
22737
- child_list += ")";
22738
- return "(" + in_child + op_type + child_list + ")";
22739
- }
22740
- case ExpressionType::OPERATOR_NOT:
22741
- case ExpressionType::GROUPING_FUNCTION:
22742
- case ExpressionType::OPERATOR_COALESCE: {
22743
- string result = ExpressionTypeToString(entry.type);
22744
- result += "(";
22745
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22746
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22747
- result += ")";
22748
- return result;
22749
- }
22750
- case ExpressionType::OPERATOR_IS_NULL:
22751
- return "(" + entry.children[0]->ToString() + " IS NULL)";
22752
- case ExpressionType::OPERATOR_IS_NOT_NULL:
22753
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
22754
- case ExpressionType::ARRAY_EXTRACT:
22755
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
22756
- case ExpressionType::ARRAY_SLICE:
22757
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
22758
- entry.children[2]->ToString() + "]";
22759
- case ExpressionType::STRUCT_EXTRACT: {
22760
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
22761
- auto child_string = entry.children[1]->ToString();
22762
- D_ASSERT(child_string.size() >= 3);
22763
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
22764
- return "(" + entry.children[0]->ToString() + ")." +
22765
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
22766
- }
22767
- case ExpressionType::ARRAY_CONSTRUCTOR: {
22768
- string result = "ARRAY[";
22769
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22770
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22771
- result += "]";
22772
- return result;
22773
- }
22774
- default:
22775
- throw InternalException("Unrecognized operator type");
22776
- }
22777
- }
22778
- };
22779
-
22780
- } // namespace duckdb
22781
- //===----------------------------------------------------------------------===//
22782
- // DuckDB
22783
- //
22784
- // duckdb/parser/expression/between_expression.hpp
22785
- //
22786
- //
22787
- //===----------------------------------------------------------------------===//
22788
22646
 
22789
22647
 
22790
22648
 
@@ -22792,36 +22650,33 @@ public:
22792
22650
 
22793
22651
  namespace duckdb {
22794
22652
 
22795
- class BetweenExpression : public ParsedExpression {
22653
+ //! Represents a * expression in the SELECT clause
22654
+ class StarExpression : public ParsedExpression {
22796
22655
  public:
22797
- BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22798
- unique_ptr<ParsedExpression> upper);
22656
+ StarExpression(string relation_name = string());
22799
22657
 
22800
- unique_ptr<ParsedExpression> input;
22801
- unique_ptr<ParsedExpression> lower;
22802
- unique_ptr<ParsedExpression> upper;
22658
+ //! The relation name in case of tbl.*, or empty if this is a normal *
22659
+ string relation_name;
22660
+ //! List of columns to exclude from the STAR expression
22661
+ case_insensitive_set_t exclude_list;
22662
+ //! List of columns to replace with another expression
22663
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
22803
22664
 
22804
22665
  public:
22805
22666
  string ToString() const override;
22806
22667
 
22807
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22668
+ static bool Equals(const StarExpression *a, const StarExpression *b);
22808
22669
 
22809
22670
  unique_ptr<ParsedExpression> Copy() const override;
22810
22671
 
22811
22672
  void Serialize(FieldWriter &writer) const override;
22812
22673
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22813
-
22814
- public:
22815
- template <class T, class BASE>
22816
- static string ToString(const T &entry) {
22817
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
22818
- }
22819
22674
  };
22820
22675
  } // namespace duckdb
22821
22676
  //===----------------------------------------------------------------------===//
22822
22677
  // DuckDB
22823
22678
  //
22824
- // duckdb/parser/expression/positional_reference_expression.hpp
22679
+ // duckdb/parser/expression/lambda_expression.hpp
22825
22680
  //
22826
22681
  //
22827
22682
  //===----------------------------------------------------------------------===//
@@ -22830,35 +22685,37 @@ public:
22830
22685
 
22831
22686
 
22832
22687
 
22688
+
22833
22689
  namespace duckdb {
22834
- class PositionalReferenceExpression : public ParsedExpression {
22690
+
22691
+ //! LambdaExpression represents either:
22692
+ //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
22693
+ //! 2. An OperatorExpression with the "->" operator
22694
+ //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
22695
+ class LambdaExpression : public ParsedExpression {
22835
22696
  public:
22836
- DUCKDB_API PositionalReferenceExpression(idx_t index);
22697
+ LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
22837
22698
 
22838
- idx_t index;
22699
+ unique_ptr<ParsedExpression> lhs;
22700
+ unique_ptr<ParsedExpression> rhs;
22839
22701
 
22840
22702
  public:
22841
- bool IsScalar() const override {
22842
- return false;
22843
- }
22844
-
22845
22703
  string ToString() const override;
22846
22704
 
22847
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
22848
- unique_ptr<ParsedExpression> Copy() const override;
22705
+ static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
22849
22706
  hash_t Hash() const override;
22850
22707
 
22708
+ unique_ptr<ParsedExpression> Copy() const override;
22709
+
22851
22710
  void Serialize(FieldWriter &writer) const override;
22852
22711
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22853
22712
  };
22854
- } // namespace duckdb
22855
-
22856
-
22857
22713
 
22714
+ } // namespace duckdb
22858
22715
  //===----------------------------------------------------------------------===//
22859
22716
  // DuckDB
22860
22717
  //
22861
- // duckdb/parser/expression/cast_expression.hpp
22718
+ // duckdb/parser/expression/subquery_expression.hpp
22862
22719
  //
22863
22720
  //
22864
22721
  //===----------------------------------------------------------------------===//
@@ -22868,43 +22725,48 @@ public:
22868
22725
 
22869
22726
 
22870
22727
 
22728
+
22871
22729
  namespace duckdb {
22872
22730
 
22873
- //! CastExpression represents a type cast from one SQL type to another SQL type
22874
- class CastExpression : public ParsedExpression {
22731
+ //! Represents a subquery
22732
+ class SubqueryExpression : public ParsedExpression {
22875
22733
  public:
22876
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
22734
+ SubqueryExpression();
22877
22735
 
22878
- //! The child of the cast expression
22736
+ //! The actual subquery
22737
+ unique_ptr<SelectStatement> subquery;
22738
+ //! The subquery type
22739
+ SubqueryType subquery_type;
22740
+ //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
22741
+ //! subquery)
22879
22742
  unique_ptr<ParsedExpression> child;
22880
- //! The type to cast to
22881
- LogicalType cast_type;
22882
- //! Whether or not this is a try_cast expression
22883
- bool try_cast;
22743
+ //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
22744
+ ExpressionType comparison_type;
22884
22745
 
22885
22746
  public:
22747
+ bool HasSubquery() const override {
22748
+ return true;
22749
+ }
22750
+ bool IsScalar() const override {
22751
+ return false;
22752
+ }
22753
+
22886
22754
  string ToString() const override;
22887
22755
 
22888
- static bool Equals(const CastExpression *a, const CastExpression *b);
22756
+ static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
22889
22757
 
22890
22758
  unique_ptr<ParsedExpression> Copy() const override;
22891
22759
 
22892
22760
  void Serialize(FieldWriter &writer) const override;
22893
22761
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22894
-
22895
- public:
22896
- template <class T, class BASE>
22897
- static string ToString(const T &entry) {
22898
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
22899
- entry.cast_type.ToString() + ")";
22900
- }
22901
22762
  };
22902
22763
  } // namespace duckdb
22903
22764
 
22765
+
22904
22766
  //===----------------------------------------------------------------------===//
22905
22767
  // DuckDB
22906
22768
  //
22907
- // duckdb/parser/expression/collate_expression.hpp
22769
+ // duckdb/parser/expression/case_expression.hpp
22908
22770
  //
22909
22771
  //
22910
22772
  //===----------------------------------------------------------------------===//
@@ -22913,27 +22775,44 @@ public:
22913
22775
 
22914
22776
 
22915
22777
 
22778
+
22916
22779
  namespace duckdb {
22917
22780
 
22918
- //! CollateExpression represents a COLLATE statement
22919
- class CollateExpression : public ParsedExpression {
22781
+ struct CaseCheck {
22782
+ unique_ptr<ParsedExpression> when_expr;
22783
+ unique_ptr<ParsedExpression> then_expr;
22784
+ };
22785
+
22786
+ //! The CaseExpression represents a CASE expression in the query
22787
+ class CaseExpression : public ParsedExpression {
22920
22788
  public:
22921
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
22789
+ DUCKDB_API CaseExpression();
22922
22790
 
22923
- //! The child of the cast expression
22924
- unique_ptr<ParsedExpression> child;
22925
- //! The collation clause
22926
- string collation;
22791
+ vector<CaseCheck> case_checks;
22792
+ unique_ptr<ParsedExpression> else_expr;
22927
22793
 
22928
22794
  public:
22929
22795
  string ToString() const override;
22930
22796
 
22931
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
22797
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
22932
22798
 
22933
22799
  unique_ptr<ParsedExpression> Copy() const override;
22934
22800
 
22935
22801
  void Serialize(FieldWriter &writer) const override;
22936
22802
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22803
+
22804
+ public:
22805
+ template <class T, class BASE>
22806
+ static string ToString(const T &entry) {
22807
+ string case_str = "CASE ";
22808
+ for (auto &check : entry.case_checks) {
22809
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
22810
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
22811
+ }
22812
+ case_str += " ELSE " + entry.else_expr->ToString();
22813
+ case_str += " END";
22814
+ return case_str;
22815
+ }
22937
22816
  };
22938
22817
  } // namespace duckdb
22939
22818
 
@@ -22943,12 +22822,10 @@ public:
22943
22822
 
22944
22823
 
22945
22824
 
22946
-
22947
-
22948
22825
  //===----------------------------------------------------------------------===//
22949
22826
  // DuckDB
22950
22827
  //
22951
- // duckdb/parser/expression/parameter_expression.hpp
22828
+ // duckdb/parser/expression/default_expression.hpp
22952
22829
  //
22953
22830
  //
22954
22831
  //===----------------------------------------------------------------------===//
@@ -22958,35 +22835,29 @@ public:
22958
22835
 
22959
22836
 
22960
22837
  namespace duckdb {
22961
- class ParameterExpression : public ParsedExpression {
22838
+ //! Represents the default value of a column
22839
+ class DefaultExpression : public ParsedExpression {
22962
22840
  public:
22963
- ParameterExpression();
22964
-
22965
- idx_t parameter_nr;
22841
+ DefaultExpression();
22966
22842
 
22967
22843
  public:
22968
22844
  bool IsScalar() const override {
22969
- return true;
22970
- }
22971
- bool HasParameter() const override {
22972
- return true;
22845
+ return false;
22973
22846
  }
22974
22847
 
22975
22848
  string ToString() const override;
22976
22849
 
22977
22850
  unique_ptr<ParsedExpression> Copy() const override;
22978
- hash_t Hash() const override;
22979
22851
 
22980
22852
  void Serialize(FieldWriter &writer) const override;
22981
22853
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22982
22854
  };
22983
22855
  } // namespace duckdb
22984
22856
 
22985
-
22986
22857
  //===----------------------------------------------------------------------===//
22987
22858
  // DuckDB
22988
22859
  //
22989
- // duckdb/parser/expression/star_expression.hpp
22860
+ // duckdb/parser/expression/function_expression.hpp
22990
22861
  //
22991
22862
  //
22992
22863
  //===----------------------------------------------------------------------===//
@@ -22996,36 +22867,113 @@ public:
22996
22867
 
22997
22868
 
22998
22869
 
22999
- namespace duckdb {
23000
22870
 
23001
- //! Represents a * expression in the SELECT clause
23002
- class StarExpression : public ParsedExpression {
22871
+ namespace duckdb {
22872
+ //! Represents a function call
22873
+ class FunctionExpression : public ParsedExpression {
23003
22874
  public:
23004
- StarExpression(string relation_name = string());
22875
+ DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
22876
+ vector<unique_ptr<ParsedExpression>> children,
22877
+ unique_ptr<ParsedExpression> filter = nullptr,
22878
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
22879
+ bool is_operator = false, bool export_state = false);
22880
+ DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
22881
+ unique_ptr<ParsedExpression> filter = nullptr,
22882
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
22883
+ bool is_operator = false, bool export_state = false);
23005
22884
 
23006
- //! The relation name in case of tbl.*, or empty if this is a normal *
23007
- string relation_name;
23008
- //! List of columns to exclude from the STAR expression
23009
- case_insensitive_set_t exclude_list;
23010
- //! List of columns to replace with another expression
23011
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
22885
+ //! Schema of the function
22886
+ string schema;
22887
+ //! Function name
22888
+ string function_name;
22889
+ //! Whether or not the function is an operator, only used for rendering
22890
+ bool is_operator;
22891
+ //! List of arguments to the function
22892
+ vector<unique_ptr<ParsedExpression>> children;
22893
+ //! Whether or not the aggregate function is distinct, only used for aggregates
22894
+ bool distinct;
22895
+ //! Expression representing a filter, only used for aggregates
22896
+ unique_ptr<ParsedExpression> filter;
22897
+ //! Modifier representing an ORDER BY, only used for aggregates
22898
+ unique_ptr<OrderModifier> order_bys;
22899
+ //! whether this function should export its state or not
22900
+ bool export_state;
23012
22901
 
23013
22902
  public:
23014
22903
  string ToString() const override;
23015
22904
 
23016
- static bool Equals(const StarExpression *a, const StarExpression *b);
23017
-
23018
22905
  unique_ptr<ParsedExpression> Copy() const override;
23019
22906
 
22907
+ static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
22908
+ hash_t Hash() const override;
22909
+
23020
22910
  void Serialize(FieldWriter &writer) const override;
23021
22911
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22912
+
22913
+ void Verify() const override;
22914
+
22915
+ public:
22916
+ template <class T, class BASE>
22917
+ static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
22918
+ bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
22919
+ bool export_state = false) {
22920
+ if (is_operator) {
22921
+ // built-in operator
22922
+ D_ASSERT(!distinct);
22923
+ if (entry.children.size() == 1) {
22924
+ if (StringUtil::Contains(function_name, "__postfix")) {
22925
+ return "(" + entry.children[0]->ToString() + ")" +
22926
+ StringUtil::Replace(function_name, "__postfix", "");
22927
+ } else {
22928
+ return function_name + "(" + entry.children[0]->ToString() + ")";
22929
+ }
22930
+ } else if (entry.children.size() == 2) {
22931
+ return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
22932
+ ")";
22933
+ }
22934
+ }
22935
+ // standard function call
22936
+ string result = schema.empty() ? function_name : schema + "." + function_name;
22937
+ result += "(";
22938
+ if (distinct) {
22939
+ result += "DISTINCT ";
22940
+ }
22941
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22942
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
22943
+ // ordered aggregate
22944
+ if (order_bys && !order_bys->orders.empty()) {
22945
+ if (entry.children.empty()) {
22946
+ result += ") WITHIN GROUP (";
22947
+ }
22948
+ result += " ORDER BY ";
22949
+ for (idx_t i = 0; i < order_bys->orders.size(); i++) {
22950
+ if (i > 0) {
22951
+ result += ", ";
22952
+ }
22953
+ result += order_bys->orders[i].ToString();
22954
+ }
22955
+ }
22956
+ result += ")";
22957
+
22958
+ // filtered aggregate
22959
+ if (filter) {
22960
+ result += " FILTER (WHERE " + filter->ToString() + ")";
22961
+ }
22962
+
22963
+ if (export_state) {
22964
+ result += " EXPORT_STATE";
22965
+ }
22966
+
22967
+ return result;
22968
+ }
23022
22969
  };
23023
22970
  } // namespace duckdb
23024
22971
 
22972
+
23025
22973
  //===----------------------------------------------------------------------===//
23026
22974
  // DuckDB
23027
22975
  //
23028
- // duckdb/parser/expression/subquery_expression.hpp
22976
+ // duckdb/parser/expression/operator_expression.hpp
23029
22977
  //
23030
22978
  //
23031
22979
  //===----------------------------------------------------------------------===//
@@ -23036,43 +22984,98 @@ public:
23036
22984
 
23037
22985
 
23038
22986
 
23039
- namespace duckdb {
23040
22987
 
23041
- //! Represents a subquery
23042
- class SubqueryExpression : public ParsedExpression {
22988
+ namespace duckdb {
22989
+ //! Represents a built-in operator expression
22990
+ class OperatorExpression : public ParsedExpression {
23043
22991
  public:
23044
- SubqueryExpression();
22992
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
22993
+ unique_ptr<ParsedExpression> right = nullptr);
22994
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23045
22995
 
23046
- //! The actual subquery
23047
- unique_ptr<SelectStatement> subquery;
23048
- //! The subquery type
23049
- SubqueryType subquery_type;
23050
- //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
23051
- //! subquery)
23052
- unique_ptr<ParsedExpression> child;
23053
- //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
23054
- ExpressionType comparison_type;
22996
+ vector<unique_ptr<ParsedExpression>> children;
23055
22997
 
23056
22998
  public:
23057
- bool HasSubquery() const override {
23058
- return true;
23059
- }
23060
- bool IsScalar() const override {
23061
- return false;
23062
- }
23063
-
23064
22999
  string ToString() const override;
23065
23000
 
23066
- static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
23001
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23067
23002
 
23068
23003
  unique_ptr<ParsedExpression> Copy() const override;
23069
23004
 
23070
23005
  void Serialize(FieldWriter &writer) const override;
23071
23006
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23007
+
23008
+ public:
23009
+ template <class T, class BASE>
23010
+ static string ToString(const T &entry) {
23011
+ auto op = ExpressionTypeToOperator(entry.type);
23012
+ if (!op.empty()) {
23013
+ // use the operator string to represent the operator
23014
+ D_ASSERT(entry.children.size() == 2);
23015
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23016
+ }
23017
+ switch (entry.type) {
23018
+ case ExpressionType::COMPARE_IN:
23019
+ case ExpressionType::COMPARE_NOT_IN: {
23020
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23021
+ string in_child = entry.children[0]->ToString();
23022
+ string child_list = "(";
23023
+ for (idx_t i = 1; i < entry.children.size(); i++) {
23024
+ if (i > 1) {
23025
+ child_list += ", ";
23026
+ }
23027
+ child_list += entry.children[i]->ToString();
23028
+ }
23029
+ child_list += ")";
23030
+ return "(" + in_child + op_type + child_list + ")";
23031
+ }
23032
+ case ExpressionType::OPERATOR_NOT:
23033
+ case ExpressionType::GROUPING_FUNCTION:
23034
+ case ExpressionType::OPERATOR_COALESCE: {
23035
+ string result = ExpressionTypeToString(entry.type);
23036
+ result += "(";
23037
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23038
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23039
+ result += ")";
23040
+ return result;
23041
+ }
23042
+ case ExpressionType::OPERATOR_IS_NULL:
23043
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
23044
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
23045
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23046
+ case ExpressionType::ARRAY_EXTRACT:
23047
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23048
+ case ExpressionType::ARRAY_SLICE:
23049
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23050
+ entry.children[2]->ToString() + "]";
23051
+ case ExpressionType::STRUCT_EXTRACT: {
23052
+ D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
23053
+ auto child_string = entry.children[1]->ToString();
23054
+ D_ASSERT(child_string.size() >= 3);
23055
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23056
+ return "(" + entry.children[0]->ToString() + ")." +
23057
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23058
+ }
23059
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
23060
+ string result = "ARRAY[";
23061
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23062
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23063
+ result += "]";
23064
+ return result;
23065
+ }
23066
+ default:
23067
+ throw InternalException("Unrecognized operator type");
23068
+ }
23069
+ }
23072
23070
  };
23071
+
23073
23072
  } // namespace duckdb
23074
23073
 
23075
23074
 
23075
+
23076
+
23077
+
23078
+
23076
23079
  //===----------------------------------------------------------------------===//
23077
23080
  // DuckDB
23078
23081
  //
@@ -23138,44 +23141,8 @@ struct LoadInfo : public ParseInfo {
23138
23141
  public:
23139
23142
  unique_ptr<LoadInfo> Copy() const {
23140
23143
  auto result = make_unique<LoadInfo>();
23141
- result->filename = filename;
23142
- result->load_type = load_type;
23143
- return result;
23144
- }
23145
- };
23146
-
23147
- } // namespace duckdb
23148
- //===----------------------------------------------------------------------===//
23149
- // DuckDB
23150
- //
23151
- // duckdb/parser/parsed_data/show_select_info.hpp
23152
- //
23153
- //
23154
- //===----------------------------------------------------------------------===//
23155
-
23156
-
23157
-
23158
-
23159
-
23160
-
23161
- namespace duckdb {
23162
-
23163
- struct ShowSelectInfo : public ParseInfo {
23164
- //! Types of projected columns
23165
- vector<LogicalType> types;
23166
- //! The QueryNode of select query
23167
- unique_ptr<QueryNode> query;
23168
- //! Aliases of projected columns
23169
- vector<string> aliases;
23170
- //! Whether or not we are requesting a summary or a describe
23171
- bool is_summary;
23172
-
23173
- unique_ptr<ShowSelectInfo> Copy() {
23174
- auto result = make_unique<ShowSelectInfo>();
23175
- result->types = types;
23176
- result->query = query->Copy();
23177
- result->aliases = aliases;
23178
- result->is_summary = is_summary;
23144
+ result->filename = filename;
23145
+ result->load_type = load_type;
23179
23146
  return result;
23180
23147
  }
23181
23148
  };
@@ -23184,7 +23151,7 @@ struct ShowSelectInfo : public ParseInfo {
23184
23151
  //===----------------------------------------------------------------------===//
23185
23152
  // DuckDB
23186
23153
  //
23187
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23154
+ // duckdb/parser/parsed_data/create_index_info.hpp
23188
23155
  //
23189
23156
  //
23190
23157
  //===----------------------------------------------------------------------===//
@@ -23194,38 +23161,10 @@ struct ShowSelectInfo : public ParseInfo {
23194
23161
 
23195
23162
 
23196
23163
 
23197
- namespace duckdb {
23198
-
23199
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23200
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
23201
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23202
- this->name = function.name;
23203
- functions.AddFunction(move(function));
23204
- }
23205
-
23206
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23207
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23208
- this->name = functions.name;
23209
- for (auto &func : functions.functions) {
23210
- func.name = functions.name;
23211
- }
23212
- }
23213
-
23214
- AggregateFunctionSet functions;
23215
-
23216
- public:
23217
- unique_ptr<CreateInfo> Copy() const override {
23218
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23219
- CopyProperties(*result);
23220
- return move(result);
23221
- }
23222
- };
23223
-
23224
- } // namespace duckdb
23225
23164
  //===----------------------------------------------------------------------===//
23226
23165
  // DuckDB
23227
23166
  //
23228
- // duckdb/parser/parsed_data/create_type_info.hpp
23167
+ // duckdb/parser/tableref/basetableref.hpp
23229
23168
  //
23230
23169
  //
23231
23170
  //===----------------------------------------------------------------------===//
@@ -23235,26 +23174,63 @@ public:
23235
23174
 
23236
23175
 
23237
23176
 
23177
+ namespace duckdb {
23178
+ //! Represents a TableReference to a base table in the schema
23179
+ class BaseTableRef : public TableRef {
23180
+ public:
23181
+ BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
23182
+ }
23238
23183
 
23184
+ //! Schema name
23185
+ string schema_name;
23186
+ //! Table name
23187
+ string table_name;
23188
+ //! Aliases for the column names
23189
+ vector<string> column_name_alias;
23239
23190
 
23240
- namespace duckdb {
23191
+ public:
23192
+ string ToString() const override;
23193
+ bool Equals(const TableRef *other_p) const override;
23241
23194
 
23242
- struct CreateTypeInfo : public CreateInfo {
23195
+ unique_ptr<TableRef> Copy() override;
23243
23196
 
23244
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23197
+ //! Serializes a blob into a BaseTableRef
23198
+ void Serialize(FieldWriter &serializer) const override;
23199
+ //! Deserializes a blob back into a BaseTableRef
23200
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
23201
+ };
23202
+ } // namespace duckdb
23203
+
23204
+
23205
+
23206
+ namespace duckdb {
23207
+
23208
+ struct CreateIndexInfo : public CreateInfo {
23209
+ CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
23245
23210
  }
23246
23211
 
23247
- //! Name of the Type
23248
- string name;
23249
- //! Logical Type
23250
- LogicalType type;
23212
+ //! Index Type (e.g., B+-tree, Skip-List, ...)
23213
+ IndexType index_type;
23214
+ //! Name of the Index
23215
+ string index_name;
23216
+ //! If it is an unique index
23217
+ bool unique = false;
23218
+ //! The table to create the index on
23219
+ unique_ptr<BaseTableRef> table;
23220
+ //! Set of expressions to index by
23221
+ vector<unique_ptr<ParsedExpression>> expressions;
23251
23222
 
23252
23223
  public:
23253
23224
  unique_ptr<CreateInfo> Copy() const override {
23254
- auto result = make_unique<CreateTypeInfo>();
23225
+ auto result = make_unique<CreateIndexInfo>();
23255
23226
  CopyProperties(*result);
23256
- result->name = name;
23257
- result->type = type;
23227
+ result->index_type = index_type;
23228
+ result->index_name = index_name;
23229
+ result->unique = unique;
23230
+ result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
23231
+ for (auto &expr : expressions) {
23232
+ result->expressions.push_back(expr->Copy());
23233
+ }
23258
23234
  return move(result);
23259
23235
  }
23260
23236
  };
@@ -23263,7 +23239,7 @@ public:
23263
23239
  //===----------------------------------------------------------------------===//
23264
23240
  // DuckDB
23265
23241
  //
23266
- // duckdb/parser/parsed_data/vacuum_info.hpp
23242
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23267
23243
  //
23268
23244
  //
23269
23245
  //===----------------------------------------------------------------------===//
@@ -23272,17 +23248,38 @@ public:
23272
23248
 
23273
23249
 
23274
23250
 
23251
+
23275
23252
  namespace duckdb {
23276
23253
 
23277
- struct VacuumInfo : public ParseInfo {
23278
- // nothing for now
23254
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23255
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
23256
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23257
+ functions.push_back(move(function));
23258
+ this->name = function.name;
23259
+ }
23260
+ CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23261
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23262
+ this->name = name;
23263
+ for (auto &function : functions) {
23264
+ function.name = name;
23265
+ }
23266
+ }
23267
+
23268
+ vector<PragmaFunction> functions;
23269
+
23270
+ public:
23271
+ unique_ptr<CreateInfo> Copy() const override {
23272
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23273
+ CopyProperties(*result);
23274
+ return move(result);
23275
+ }
23279
23276
  };
23280
23277
 
23281
23278
  } // namespace duckdb
23282
23279
  //===----------------------------------------------------------------------===//
23283
23280
  // DuckDB
23284
23281
  //
23285
- // duckdb/parser/parsed_data/drop_info.hpp
23282
+ // duckdb/parser/parsed_data/export_table_data.hpp
23286
23283
  //
23287
23284
  //
23288
23285
  //===----------------------------------------------------------------------===//
@@ -23294,39 +23291,31 @@ struct VacuumInfo : public ParseInfo {
23294
23291
 
23295
23292
  namespace duckdb {
23296
23293
 
23297
- struct DropInfo : public ParseInfo {
23298
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23299
- }
23294
+ struct ExportedTableData {
23295
+ //! Name of the exported table
23296
+ string table_name;
23300
23297
 
23301
- //! The catalog type to drop
23302
- CatalogType type;
23303
- //! Schema name to drop from, if any
23304
- string schema;
23305
- //! Element name to drop
23306
- string name;
23307
- //! Ignore if the entry does not exist instead of failing
23308
- bool if_exists = false;
23309
- //! Cascade drop (drop all dependents instead of throwing an error if there
23310
- //! are any)
23311
- bool cascade = false;
23298
+ //! Name of the schema
23299
+ string schema_name;
23312
23300
 
23313
- public:
23314
- unique_ptr<DropInfo> Copy() const {
23315
- auto result = make_unique<DropInfo>();
23316
- result->type = type;
23317
- result->schema = schema;
23318
- result->name = name;
23319
- result->if_exists = if_exists;
23320
- result->cascade = cascade;
23321
- return result;
23322
- }
23301
+ //! Path to be exported
23302
+ string file_path;
23303
+ };
23304
+
23305
+ struct ExportedTableInfo {
23306
+ TableCatalogEntry *entry;
23307
+ ExportedTableData table_data;
23308
+ };
23309
+
23310
+ struct BoundExportData : public ParseInfo {
23311
+ std::vector<ExportedTableInfo> data;
23323
23312
  };
23324
23313
 
23325
23314
  } // namespace duckdb
23326
23315
  //===----------------------------------------------------------------------===//
23327
23316
  // DuckDB
23328
23317
  //
23329
- // duckdb/parser/parsed_data/transaction_info.hpp
23318
+ // duckdb/parser/parsed_data/create_type_info.hpp
23330
23319
  //
23331
23320
  //
23332
23321
  //===----------------------------------------------------------------------===//
@@ -23335,16 +23324,29 @@ public:
23335
23324
 
23336
23325
 
23337
23326
 
23327
+
23328
+
23329
+
23338
23330
  namespace duckdb {
23339
23331
 
23340
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
23332
+ struct CreateTypeInfo : public CreateInfo {
23341
23333
 
23342
- struct TransactionInfo : public ParseInfo {
23343
- explicit TransactionInfo(TransactionType type) : type(type) {
23334
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23344
23335
  }
23345
23336
 
23346
- //! The type of transaction statement
23347
- TransactionType type;
23337
+ //! Name of the Type
23338
+ string name;
23339
+ //! Logical Type
23340
+ LogicalType type;
23341
+
23342
+ public:
23343
+ unique_ptr<CreateInfo> Copy() const override {
23344
+ auto result = make_unique<CreateTypeInfo>();
23345
+ CopyProperties(*result);
23346
+ result->name = name;
23347
+ result->type = type;
23348
+ return move(result);
23349
+ }
23348
23350
  };
23349
23351
 
23350
23352
  } // namespace duckdb
@@ -23462,20 +23464,7 @@ public:
23462
23464
  //===----------------------------------------------------------------------===//
23463
23465
  // DuckDB
23464
23466
  //
23465
- // duckdb/parser/parsed_data/create_index_info.hpp
23466
- //
23467
- //
23468
- //===----------------------------------------------------------------------===//
23469
-
23470
-
23471
-
23472
-
23473
-
23474
-
23475
- //===----------------------------------------------------------------------===//
23476
- // DuckDB
23477
- //
23478
- // duckdb/parser/tableref/basetableref.hpp
23467
+ // duckdb/parser/parsed_data/show_select_info.hpp
23479
23468
  //
23480
23469
  //
23481
23470
  //===----------------------------------------------------------------------===//
@@ -23486,63 +23475,24 @@ public:
23486
23475
 
23487
23476
 
23488
23477
  namespace duckdb {
23489
- //! Represents a TableReference to a base table in the schema
23490
- class BaseTableRef : public TableRef {
23491
- public:
23492
- BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
23493
- }
23494
-
23495
- //! Schema name
23496
- string schema_name;
23497
- //! Table name
23498
- string table_name;
23499
- //! Aliases for the column names
23500
- vector<string> column_name_alias;
23501
-
23502
- public:
23503
- string ToString() const override;
23504
- bool Equals(const TableRef *other_p) const override;
23505
-
23506
- unique_ptr<TableRef> Copy() override;
23507
-
23508
- //! Serializes a blob into a BaseTableRef
23509
- void Serialize(FieldWriter &serializer) const override;
23510
- //! Deserializes a blob back into a BaseTableRef
23511
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
23512
- };
23513
- } // namespace duckdb
23514
-
23515
-
23516
-
23517
- namespace duckdb {
23518
-
23519
- struct CreateIndexInfo : public CreateInfo {
23520
- CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
23521
- }
23522
-
23523
- //! Index Type (e.g., B+-tree, Skip-List, ...)
23524
- IndexType index_type;
23525
- //! Name of the Index
23526
- string index_name;
23527
- //! If it is an unique index
23528
- bool unique = false;
23529
- //! The table to create the index on
23530
- unique_ptr<BaseTableRef> table;
23531
- //! Set of expressions to index by
23532
- vector<unique_ptr<ParsedExpression>> expressions;
23533
23478
 
23534
- public:
23535
- unique_ptr<CreateInfo> Copy() const override {
23536
- auto result = make_unique<CreateIndexInfo>();
23537
- CopyProperties(*result);
23538
- result->index_type = index_type;
23539
- result->index_name = index_name;
23540
- result->unique = unique;
23541
- result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
23542
- for (auto &expr : expressions) {
23543
- result->expressions.push_back(expr->Copy());
23544
- }
23545
- return move(result);
23479
+ struct ShowSelectInfo : public ParseInfo {
23480
+ //! Types of projected columns
23481
+ vector<LogicalType> types;
23482
+ //! The QueryNode of select query
23483
+ unique_ptr<QueryNode> query;
23484
+ //! Aliases of projected columns
23485
+ vector<string> aliases;
23486
+ //! Whether or not we are requesting a summary or a describe
23487
+ bool is_summary;
23488
+
23489
+ unique_ptr<ShowSelectInfo> Copy() {
23490
+ auto result = make_unique<ShowSelectInfo>();
23491
+ result->types = types;
23492
+ result->query = query->Copy();
23493
+ result->aliases = aliases;
23494
+ result->is_summary = is_summary;
23495
+ return result;
23546
23496
  }
23547
23497
  };
23548
23498
 
@@ -23550,7 +23500,7 @@ public:
23550
23500
  //===----------------------------------------------------------------------===//
23551
23501
  // DuckDB
23552
23502
  //
23553
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23503
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23554
23504
  //
23555
23505
  //
23556
23506
  //===----------------------------------------------------------------------===//
@@ -23562,25 +23512,26 @@ public:
23562
23512
 
23563
23513
  namespace duckdb {
23564
23514
 
23565
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23566
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
23567
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23568
- functions.push_back(move(function));
23515
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23516
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
23517
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23569
23518
  this->name = function.name;
23519
+ functions.AddFunction(move(function));
23570
23520
  }
23571
- CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23572
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23573
- this->name = name;
23574
- for (auto &function : functions) {
23575
- function.name = name;
23521
+
23522
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23523
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23524
+ this->name = functions.name;
23525
+ for (auto &func : functions.functions) {
23526
+ func.name = functions.name;
23576
23527
  }
23577
23528
  }
23578
23529
 
23579
- vector<PragmaFunction> functions;
23530
+ AggregateFunctionSet functions;
23580
23531
 
23581
23532
  public:
23582
23533
  unique_ptr<CreateInfo> Copy() const override {
23583
- auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23534
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23584
23535
  CopyProperties(*result);
23585
23536
  return move(result);
23586
23537
  }
@@ -23590,7 +23541,7 @@ public:
23590
23541
  //===----------------------------------------------------------------------===//
23591
23542
  // DuckDB
23592
23543
  //
23593
- // duckdb/parser/parsed_data/export_table_data.hpp
23544
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23594
23545
  //
23595
23546
  //
23596
23547
  //===----------------------------------------------------------------------===//
@@ -23599,27 +23550,54 @@ public:
23599
23550
 
23600
23551
 
23601
23552
 
23602
-
23603
23553
  namespace duckdb {
23604
23554
 
23605
- struct ExportedTableData {
23606
- //! Name of the exported table
23607
- string table_name;
23555
+ struct VacuumInfo : public ParseInfo {
23556
+ // nothing for now
23557
+ };
23608
23558
 
23609
- //! Name of the schema
23610
- string schema_name;
23559
+ } // namespace duckdb
23560
+ //===----------------------------------------------------------------------===//
23561
+ // DuckDB
23562
+ //
23563
+ // duckdb/parser/parsed_data/drop_info.hpp
23564
+ //
23565
+ //
23566
+ //===----------------------------------------------------------------------===//
23611
23567
 
23612
- //! Path to be exported
23613
- string file_path;
23614
- };
23615
23568
 
23616
- struct ExportedTableInfo {
23617
- TableCatalogEntry *entry;
23618
- ExportedTableData table_data;
23619
- };
23620
23569
 
23621
- struct BoundExportData : public ParseInfo {
23622
- std::vector<ExportedTableInfo> data;
23570
+
23571
+
23572
+
23573
+ namespace duckdb {
23574
+
23575
+ struct DropInfo : public ParseInfo {
23576
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23577
+ }
23578
+
23579
+ //! The catalog type to drop
23580
+ CatalogType type;
23581
+ //! Schema name to drop from, if any
23582
+ string schema;
23583
+ //! Element name to drop
23584
+ string name;
23585
+ //! Ignore if the entry does not exist instead of failing
23586
+ bool if_exists = false;
23587
+ //! Cascade drop (drop all dependents instead of throwing an error if there
23588
+ //! are any)
23589
+ bool cascade = false;
23590
+
23591
+ public:
23592
+ unique_ptr<DropInfo> Copy() const {
23593
+ auto result = make_unique<DropInfo>();
23594
+ result->type = type;
23595
+ result->schema = schema;
23596
+ result->name = name;
23597
+ result->if_exists = if_exists;
23598
+ result->cascade = cascade;
23599
+ return result;
23600
+ }
23623
23601
  };
23624
23602
 
23625
23603
  } // namespace duckdb
@@ -23669,7 +23647,7 @@ public:
23669
23647
  //===----------------------------------------------------------------------===//
23670
23648
  // DuckDB
23671
23649
  //
23672
- // duckdb/parser/tableref/table_function_ref.hpp
23650
+ // duckdb/parser/parsed_data/transaction_info.hpp
23673
23651
  //
23674
23652
  //
23675
23653
  //===----------------------------------------------------------------------===//
@@ -23678,39 +23656,23 @@ public:
23678
23656
 
23679
23657
 
23680
23658
 
23681
-
23682
-
23683
-
23684
23659
  namespace duckdb {
23685
- //! Represents a Table producing function
23686
- class TableFunctionRef : public TableRef {
23687
- public:
23688
- TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
23689
- }
23690
-
23691
- unique_ptr<ParsedExpression> function;
23692
- vector<string> column_name_alias;
23693
-
23694
- // if the function takes a subquery as argument its in here
23695
- unique_ptr<SelectStatement> subquery;
23696
-
23697
- public:
23698
- string ToString() const override;
23699
23660
 
23700
- bool Equals(const TableRef *other_p) const override;
23661
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
23701
23662
 
23702
- unique_ptr<TableRef> Copy() override;
23663
+ struct TransactionInfo : public ParseInfo {
23664
+ explicit TransactionInfo(TransactionType type) : type(type) {
23665
+ }
23703
23666
 
23704
- //! Serializes a blob into a BaseTableRef
23705
- void Serialize(FieldWriter &serializer) const override;
23706
- //! Deserializes a blob back into a BaseTableRef
23707
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
23667
+ //! The type of transaction statement
23668
+ TransactionType type;
23708
23669
  };
23670
+
23709
23671
  } // namespace duckdb
23710
23672
  //===----------------------------------------------------------------------===//
23711
23673
  // DuckDB
23712
23674
  //
23713
- // duckdb/parser/tableref/crossproductref.hpp
23675
+ // duckdb/parser/tableref/joinref.hpp
23714
23676
  //
23715
23677
  //
23716
23678
  //===----------------------------------------------------------------------===//
@@ -23719,26 +23681,38 @@ public:
23719
23681
 
23720
23682
 
23721
23683
 
23684
+
23685
+
23686
+
23687
+
23722
23688
  namespace duckdb {
23723
- //! Represents a cross product
23724
- class CrossProductRef : public TableRef {
23689
+ //! Represents a JOIN between two expressions
23690
+ class JoinRef : public TableRef {
23725
23691
  public:
23726
- CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
23692
+ JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
23727
23693
  }
23728
23694
 
23729
- //! The left hand side of the cross product
23695
+ //! The left hand side of the join
23730
23696
  unique_ptr<TableRef> left;
23731
- //! The right hand side of the cross product
23697
+ //! The right hand side of the join
23732
23698
  unique_ptr<TableRef> right;
23699
+ //! The join condition
23700
+ unique_ptr<ParsedExpression> condition;
23701
+ //! The join type
23702
+ JoinType type;
23703
+ //! Natural join
23704
+ bool is_natural;
23705
+ //! The set of USING columns (if any)
23706
+ vector<string> using_columns;
23733
23707
 
23734
23708
  public:
23735
23709
  bool Equals(const TableRef *other_p) const override;
23736
23710
 
23737
23711
  unique_ptr<TableRef> Copy() override;
23738
23712
 
23739
- //! Serializes a blob into a CrossProductRef
23713
+ //! Serializes a blob into a JoinRef
23740
23714
  void Serialize(FieldWriter &serializer) const override;
23741
- //! Deserializes a blob back into a CrossProductRef
23715
+ //! Deserializes a blob back into a JoinRef
23742
23716
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23743
23717
  };
23744
23718
  } // namespace duckdb
@@ -23772,9 +23746,6 @@ public:
23772
23746
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23773
23747
  };
23774
23748
  } // namespace duckdb
23775
-
23776
-
23777
-
23778
23749
  //===----------------------------------------------------------------------===//
23779
23750
  // DuckDB
23780
23751
  //
@@ -23815,11 +23786,10 @@ public:
23815
23786
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23816
23787
  };
23817
23788
  } // namespace duckdb
23818
-
23819
23789
  //===----------------------------------------------------------------------===//
23820
23790
  // DuckDB
23821
23791
  //
23822
- // duckdb/parser/tableref/joinref.hpp
23792
+ // duckdb/parser/tableref/subqueryref.hpp
23823
23793
  //
23824
23794
  //
23825
23795
  //===----------------------------------------------------------------------===//
@@ -23829,37 +23799,66 @@ public:
23829
23799
 
23830
23800
 
23831
23801
 
23802
+ namespace duckdb {
23803
+ //! Represents a subquery
23804
+ class SubqueryRef : public TableRef {
23805
+ public:
23806
+ explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
23807
+
23808
+ //! The subquery
23809
+ unique_ptr<SelectStatement> subquery;
23810
+ //! Aliases for the column names
23811
+ vector<string> column_name_alias;
23812
+
23813
+ public:
23814
+ bool Equals(const TableRef *other_p) const override;
23815
+
23816
+ unique_ptr<TableRef> Copy() override;
23817
+
23818
+ //! Serializes a blob into a SubqueryRef
23819
+ void Serialize(FieldWriter &serializer) const override;
23820
+ //! Deserializes a blob back into a SubqueryRef
23821
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
23822
+ };
23823
+ } // namespace duckdb
23824
+ //===----------------------------------------------------------------------===//
23825
+ // DuckDB
23826
+ //
23827
+ // duckdb/parser/tableref/table_function_ref.hpp
23828
+ //
23829
+ //
23830
+ //===----------------------------------------------------------------------===//
23831
+
23832
+
23833
+
23834
+
23835
+
23832
23836
 
23833
23837
 
23834
23838
 
23835
23839
  namespace duckdb {
23836
- //! Represents a JOIN between two expressions
23837
- class JoinRef : public TableRef {
23840
+ //! Represents a Table producing function
23841
+ class TableFunctionRef : public TableRef {
23838
23842
  public:
23839
- JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
23843
+ TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
23840
23844
  }
23841
23845
 
23842
- //! The left hand side of the join
23843
- unique_ptr<TableRef> left;
23844
- //! The right hand side of the join
23845
- unique_ptr<TableRef> right;
23846
- //! The join condition
23847
- unique_ptr<ParsedExpression> condition;
23848
- //! The join type
23849
- JoinType type;
23850
- //! Natural join
23851
- bool is_natural;
23852
- //! The set of USING columns (if any)
23853
- vector<string> using_columns;
23846
+ unique_ptr<ParsedExpression> function;
23847
+ vector<string> column_name_alias;
23848
+
23849
+ // if the function takes a subquery as argument its in here
23850
+ unique_ptr<SelectStatement> subquery;
23854
23851
 
23855
23852
  public:
23853
+ string ToString() const override;
23854
+
23856
23855
  bool Equals(const TableRef *other_p) const override;
23857
23856
 
23858
23857
  unique_ptr<TableRef> Copy() override;
23859
23858
 
23860
- //! Serializes a blob into a JoinRef
23859
+ //! Serializes a blob into a BaseTableRef
23861
23860
  void Serialize(FieldWriter &serializer) const override;
23862
- //! Deserializes a blob back into a JoinRef
23861
+ //! Deserializes a blob back into a BaseTableRef
23863
23862
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23864
23863
  };
23865
23864
  } // namespace duckdb
@@ -23867,7 +23866,7 @@ public:
23867
23866
  //===----------------------------------------------------------------------===//
23868
23867
  // DuckDB
23869
23868
  //
23870
- // duckdb/parser/tableref/subqueryref.hpp
23869
+ // duckdb/parser/tableref/crossproductref.hpp
23871
23870
  //
23872
23871
  //
23873
23872
  //===----------------------------------------------------------------------===//
@@ -23876,28 +23875,32 @@ public:
23876
23875
 
23877
23876
 
23878
23877
 
23879
-
23880
23878
  namespace duckdb {
23881
- //! Represents a subquery
23882
- class SubqueryRef : public TableRef {
23879
+ //! Represents a cross product
23880
+ class CrossProductRef : public TableRef {
23883
23881
  public:
23884
- explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
23882
+ CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
23883
+ }
23885
23884
 
23886
- //! The subquery
23887
- unique_ptr<SelectStatement> subquery;
23888
- //! Aliases for the column names
23889
- vector<string> column_name_alias;
23885
+ //! The left hand side of the cross product
23886
+ unique_ptr<TableRef> left;
23887
+ //! The right hand side of the cross product
23888
+ unique_ptr<TableRef> right;
23890
23889
 
23891
23890
  public:
23892
23891
  bool Equals(const TableRef *other_p) const override;
23893
23892
 
23894
23893
  unique_ptr<TableRef> Copy() override;
23895
23894
 
23896
- //! Serializes a blob into a SubqueryRef
23895
+ //! Serializes a blob into a CrossProductRef
23897
23896
  void Serialize(FieldWriter &serializer) const override;
23898
- //! Deserializes a blob back into a SubqueryRef
23897
+ //! Deserializes a blob back into a CrossProductRef
23899
23898
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23900
23899
  };
23901
23900
  } // namespace duckdb
23902
23901
 
23903
23902
 
23903
+
23904
+
23905
+
23906
+