duckdb 0.3.3-dev823.0 → 0.3.3-dev835.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 "c46907009"
15
- #define DUCKDB_VERSION "v0.3.3-dev823"
14
+ #define DUCKDB_SOURCE_ID "4f0ed531f"
15
+ #define DUCKDB_VERSION "v0.3.3-dev835"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -21365,7 +21365,7 @@ private:
21365
21365
  //===----------------------------------------------------------------------===//
21366
21366
  // DuckDB
21367
21367
  //
21368
- // duckdb/parser/expression/lambda_expression.hpp
21368
+ // duckdb/parser/expression/subquery_expression.hpp
21369
21369
  //
21370
21370
  //
21371
21371
  //===----------------------------------------------------------------------===//
@@ -21375,36 +21375,46 @@ private:
21375
21375
 
21376
21376
 
21377
21377
 
21378
+
21378
21379
  namespace duckdb {
21379
21380
 
21380
- //! LambdaExpression represents either:
21381
- //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
21382
- //! 2. An OperatorExpression with the "->" operator
21383
- //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
21384
- class LambdaExpression : public ParsedExpression {
21381
+ //! Represents a subquery
21382
+ class SubqueryExpression : public ParsedExpression {
21385
21383
  public:
21386
- LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
21384
+ SubqueryExpression();
21387
21385
 
21388
- unique_ptr<ParsedExpression> lhs;
21389
- unique_ptr<ParsedExpression> rhs;
21386
+ //! The actual subquery
21387
+ unique_ptr<SelectStatement> subquery;
21388
+ //! The subquery type
21389
+ SubqueryType subquery_type;
21390
+ //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
21391
+ //! subquery)
21392
+ unique_ptr<ParsedExpression> child;
21393
+ //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
21394
+ ExpressionType comparison_type;
21390
21395
 
21391
21396
  public:
21397
+ bool HasSubquery() const override {
21398
+ return true;
21399
+ }
21400
+ bool IsScalar() const override {
21401
+ return false;
21402
+ }
21403
+
21392
21404
  string ToString() const override;
21393
21405
 
21394
- static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
21395
- hash_t Hash() const override;
21406
+ static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
21396
21407
 
21397
21408
  unique_ptr<ParsedExpression> Copy() const override;
21398
21409
 
21399
21410
  void Serialize(FieldWriter &writer) const override;
21400
21411
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21401
21412
  };
21402
-
21403
21413
  } // namespace duckdb
21404
21414
  //===----------------------------------------------------------------------===//
21405
21415
  // DuckDB
21406
21416
  //
21407
- // duckdb/parser/expression/case_expression.hpp
21417
+ // duckdb/parser/expression/lambda_expression.hpp
21408
21418
  //
21409
21419
  //
21410
21420
  //===----------------------------------------------------------------------===//
@@ -21416,42 +21426,29 @@ public:
21416
21426
 
21417
21427
  namespace duckdb {
21418
21428
 
21419
- struct CaseCheck {
21420
- unique_ptr<ParsedExpression> when_expr;
21421
- unique_ptr<ParsedExpression> then_expr;
21422
- };
21423
-
21424
- //! The CaseExpression represents a CASE expression in the query
21425
- class CaseExpression : public ParsedExpression {
21429
+ //! LambdaExpression represents either:
21430
+ //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
21431
+ //! 2. An OperatorExpression with the "->" operator
21432
+ //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
21433
+ class LambdaExpression : public ParsedExpression {
21426
21434
  public:
21427
- DUCKDB_API CaseExpression();
21435
+ LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
21428
21436
 
21429
- vector<CaseCheck> case_checks;
21430
- unique_ptr<ParsedExpression> else_expr;
21437
+ unique_ptr<ParsedExpression> lhs;
21438
+ unique_ptr<ParsedExpression> rhs;
21431
21439
 
21432
21440
  public:
21433
21441
  string ToString() const override;
21434
21442
 
21435
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
21443
+ static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
21444
+ hash_t Hash() const override;
21436
21445
 
21437
21446
  unique_ptr<ParsedExpression> Copy() const override;
21438
21447
 
21439
21448
  void Serialize(FieldWriter &writer) const override;
21440
21449
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21441
-
21442
- public:
21443
- template <class T, class BASE>
21444
- static string ToString(const T &entry) {
21445
- string case_str = "CASE ";
21446
- for (auto &check : entry.case_checks) {
21447
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
21448
- case_str += " THEN (" + check.then_expr->ToString() + ")";
21449
- }
21450
- case_str += " ELSE " + entry.else_expr->ToString();
21451
- case_str += " END";
21452
- return case_str;
21453
- }
21454
21450
  };
21451
+
21455
21452
  } // namespace duckdb
21456
21453
  //===----------------------------------------------------------------------===//
21457
21454
  // DuckDB
@@ -21504,7 +21501,7 @@ public:
21504
21501
  //===----------------------------------------------------------------------===//
21505
21502
  // DuckDB
21506
21503
  //
21507
- // duckdb/parser/expression/function_expression.hpp
21504
+ // duckdb/parser/expression/between_expression.hpp
21508
21505
  //
21509
21506
  //
21510
21507
  //===----------------------------------------------------------------------===//
@@ -21513,112 +21510,40 @@ public:
21513
21510
 
21514
21511
 
21515
21512
 
21516
-
21517
-
21518
21513
  namespace duckdb {
21519
- //! Represents a function call
21520
- class FunctionExpression : public ParsedExpression {
21514
+
21515
+ class BetweenExpression : public ParsedExpression {
21521
21516
  public:
21522
- DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
21523
- vector<unique_ptr<ParsedExpression>> children,
21524
- unique_ptr<ParsedExpression> filter = nullptr,
21525
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
21526
- bool is_operator = false, bool export_state = false);
21527
- DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
21528
- unique_ptr<ParsedExpression> filter = nullptr,
21529
- unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
21530
- bool is_operator = false, bool export_state = false);
21517
+ BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
21518
+ unique_ptr<ParsedExpression> upper);
21531
21519
 
21532
- //! Schema of the function
21533
- string schema;
21534
- //! Function name
21535
- string function_name;
21536
- //! Whether or not the function is an operator, only used for rendering
21537
- bool is_operator;
21538
- //! List of arguments to the function
21539
- vector<unique_ptr<ParsedExpression>> children;
21540
- //! Whether or not the aggregate function is distinct, only used for aggregates
21541
- bool distinct;
21542
- //! Expression representing a filter, only used for aggregates
21543
- unique_ptr<ParsedExpression> filter;
21544
- //! Modifier representing an ORDER BY, only used for aggregates
21545
- unique_ptr<OrderModifier> order_bys;
21546
- //! whether this function should export its state or not
21547
- bool export_state;
21520
+ unique_ptr<ParsedExpression> input;
21521
+ unique_ptr<ParsedExpression> lower;
21522
+ unique_ptr<ParsedExpression> upper;
21548
21523
 
21549
21524
  public:
21550
21525
  string ToString() const override;
21551
21526
 
21552
- unique_ptr<ParsedExpression> Copy() const override;
21527
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
21553
21528
 
21554
- static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
21555
- hash_t Hash() const override;
21529
+ unique_ptr<ParsedExpression> Copy() const override;
21556
21530
 
21557
21531
  void Serialize(FieldWriter &writer) const override;
21558
21532
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21559
21533
 
21560
- void Verify() const override;
21561
-
21562
21534
  public:
21563
21535
  template <class T, class BASE>
21564
- static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
21565
- bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
21566
- bool export_state = false) {
21567
- if (is_operator) {
21568
- // built-in operator
21569
- D_ASSERT(!distinct);
21570
- if (entry.children.size() == 1) {
21571
- if (StringUtil::Contains(function_name, "__postfix")) {
21572
- return "(" + entry.children[0]->ToString() + ")" +
21573
- StringUtil::Replace(function_name, "__postfix", "");
21574
- } else {
21575
- return function_name + "(" + entry.children[0]->ToString() + ")";
21576
- }
21577
- } else if (entry.children.size() == 2) {
21578
- return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
21579
- ")";
21580
- }
21581
- }
21582
- // standard function call
21583
- string result = schema.empty() ? function_name : schema + "." + function_name;
21584
- result += "(";
21585
- if (distinct) {
21586
- result += "DISTINCT ";
21587
- }
21588
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
21589
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
21590
- // ordered aggregate
21591
- if (order_bys && !order_bys->orders.empty()) {
21592
- if (entry.children.empty()) {
21593
- result += ") WITHIN GROUP (";
21594
- }
21595
- result += " ORDER BY ";
21596
- for (idx_t i = 0; i < order_bys->orders.size(); i++) {
21597
- if (i > 0) {
21598
- result += ", ";
21599
- }
21600
- result += order_bys->orders[i].ToString();
21601
- }
21602
- }
21603
- result += ")";
21604
-
21605
- // filtered aggregate
21606
- if (filter) {
21607
- result += " FILTER (WHERE " + filter->ToString() + ")";
21608
- }
21609
-
21610
- if (export_state) {
21611
- result += " EXPORT_STATE";
21612
- }
21613
-
21614
- return result;
21536
+ static string ToString(const T &entry) {
21537
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
21615
21538
  }
21616
21539
  };
21617
21540
  } // namespace duckdb
21541
+
21542
+
21618
21543
  //===----------------------------------------------------------------------===//
21619
21544
  // DuckDB
21620
21545
  //
21621
- // duckdb/parser/expression/default_expression.hpp
21546
+ // duckdb/parser/expression/case_expression.hpp
21622
21547
  //
21623
21548
  //
21624
21549
  //===----------------------------------------------------------------------===//
@@ -21627,29 +21552,51 @@ public:
21627
21552
 
21628
21553
 
21629
21554
 
21555
+
21630
21556
  namespace duckdb {
21631
- //! Represents the default value of a column
21632
- class DefaultExpression : public ParsedExpression {
21633
- public:
21634
- DefaultExpression();
21635
21557
 
21558
+ struct CaseCheck {
21559
+ unique_ptr<ParsedExpression> when_expr;
21560
+ unique_ptr<ParsedExpression> then_expr;
21561
+ };
21562
+
21563
+ //! The CaseExpression represents a CASE expression in the query
21564
+ class CaseExpression : public ParsedExpression {
21636
21565
  public:
21637
- bool IsScalar() const override {
21638
- return false;
21639
- }
21566
+ DUCKDB_API CaseExpression();
21567
+
21568
+ vector<CaseCheck> case_checks;
21569
+ unique_ptr<ParsedExpression> else_expr;
21640
21570
 
21571
+ public:
21641
21572
  string ToString() const override;
21642
21573
 
21574
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
21575
+
21643
21576
  unique_ptr<ParsedExpression> Copy() const override;
21644
21577
 
21645
21578
  void Serialize(FieldWriter &writer) const override;
21646
21579
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21580
+
21581
+ public:
21582
+ template <class T, class BASE>
21583
+ static string ToString(const T &entry) {
21584
+ string case_str = "CASE ";
21585
+ for (auto &check : entry.case_checks) {
21586
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
21587
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
21588
+ }
21589
+ case_str += " ELSE " + entry.else_expr->ToString();
21590
+ case_str += " END";
21591
+ return case_str;
21592
+ }
21647
21593
  };
21648
21594
  } // namespace duckdb
21595
+
21649
21596
  //===----------------------------------------------------------------------===//
21650
21597
  // DuckDB
21651
21598
  //
21652
- // duckdb/parser/expression/comparison_expression.hpp
21599
+ // duckdb/parser/expression/cast_expression.hpp
21653
21600
  //
21654
21601
  //
21655
21602
  //===----------------------------------------------------------------------===//
@@ -21658,21 +21605,25 @@ public:
21658
21605
 
21659
21606
 
21660
21607
 
21608
+
21661
21609
  namespace duckdb {
21662
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
21663
- //! and has two children.
21664
- class ComparisonExpression : public ParsedExpression {
21610
+
21611
+ //! CastExpression represents a type cast from one SQL type to another SQL type
21612
+ class CastExpression : public ParsedExpression {
21665
21613
  public:
21666
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
21667
- unique_ptr<ParsedExpression> right);
21614
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
21668
21615
 
21669
- unique_ptr<ParsedExpression> left;
21670
- unique_ptr<ParsedExpression> right;
21616
+ //! The child of the cast expression
21617
+ unique_ptr<ParsedExpression> child;
21618
+ //! The type to cast to
21619
+ LogicalType cast_type;
21620
+ //! Whether or not this is a try_cast expression
21621
+ bool try_cast;
21671
21622
 
21672
21623
  public:
21673
21624
  string ToString() const override;
21674
21625
 
21675
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
21626
+ static bool Equals(const CastExpression *a, const CastExpression *b);
21676
21627
 
21677
21628
  unique_ptr<ParsedExpression> Copy() const override;
21678
21629
 
@@ -21682,14 +21633,16 @@ public:
21682
21633
  public:
21683
21634
  template <class T, class BASE>
21684
21635
  static string ToString(const T &entry) {
21685
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
21636
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
21637
+ entry.cast_type.ToString() + ")";
21686
21638
  }
21687
21639
  };
21688
21640
  } // namespace duckdb
21641
+
21689
21642
  //===----------------------------------------------------------------------===//
21690
21643
  // DuckDB
21691
21644
  //
21692
- // duckdb/parser/expression/constant_expression.hpp
21645
+ // duckdb/parser/expression/collate_expression.hpp
21693
21646
  //
21694
21647
  //
21695
21648
  //===----------------------------------------------------------------------===//
@@ -21698,34 +21651,35 @@ public:
21698
21651
 
21699
21652
 
21700
21653
 
21701
-
21702
21654
  namespace duckdb {
21703
21655
 
21704
- //! ConstantExpression represents a constant value in the query
21705
- class ConstantExpression : public ParsedExpression {
21656
+ //! CollateExpression represents a COLLATE statement
21657
+ class CollateExpression : public ParsedExpression {
21706
21658
  public:
21707
- DUCKDB_API explicit ConstantExpression(Value val);
21659
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
21708
21660
 
21709
- //! The constant value referenced
21710
- Value value;
21661
+ //! The child of the cast expression
21662
+ unique_ptr<ParsedExpression> child;
21663
+ //! The collation clause
21664
+ string collation;
21711
21665
 
21712
21666
  public:
21713
21667
  string ToString() const override;
21714
21668
 
21715
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
21716
- hash_t Hash() const override;
21669
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
21717
21670
 
21718
21671
  unique_ptr<ParsedExpression> Copy() const override;
21719
21672
 
21720
21673
  void Serialize(FieldWriter &writer) const override;
21721
21674
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21722
21675
  };
21723
-
21724
21676
  } // namespace duckdb
21677
+
21678
+
21725
21679
  //===----------------------------------------------------------------------===//
21726
21680
  // DuckDB
21727
21681
  //
21728
- // duckdb/parser/expression/operator_expression.hpp
21682
+ // duckdb/parser/expression/comparison_expression.hpp
21729
21683
  //
21730
21684
  //
21731
21685
  //===----------------------------------------------------------------------===//
@@ -21734,23 +21688,21 @@ public:
21734
21688
 
21735
21689
 
21736
21690
 
21737
-
21738
-
21739
-
21740
21691
  namespace duckdb {
21741
- //! Represents a built-in operator expression
21742
- class OperatorExpression : public ParsedExpression {
21692
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
21693
+ //! and has two children.
21694
+ class ComparisonExpression : public ParsedExpression {
21743
21695
  public:
21744
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
21745
- unique_ptr<ParsedExpression> right = nullptr);
21746
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
21696
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
21697
+ unique_ptr<ParsedExpression> right);
21747
21698
 
21748
- vector<unique_ptr<ParsedExpression>> children;
21699
+ unique_ptr<ParsedExpression> left;
21700
+ unique_ptr<ParsedExpression> right;
21749
21701
 
21750
21702
  public:
21751
21703
  string ToString() const override;
21752
21704
 
21753
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
21705
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
21754
21706
 
21755
21707
  unique_ptr<ParsedExpression> Copy() const override;
21756
21708
 
@@ -21760,72 +21712,16 @@ public:
21760
21712
  public:
21761
21713
  template <class T, class BASE>
21762
21714
  static string ToString(const T &entry) {
21763
- auto op = ExpressionTypeToOperator(entry.type);
21764
- if (!op.empty()) {
21765
- // use the operator string to represent the operator
21766
- D_ASSERT(entry.children.size() == 2);
21767
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
21768
- }
21769
- switch (entry.type) {
21770
- case ExpressionType::COMPARE_IN:
21771
- case ExpressionType::COMPARE_NOT_IN: {
21772
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
21773
- string in_child = entry.children[0]->ToString();
21774
- string child_list = "(";
21775
- for (idx_t i = 1; i < entry.children.size(); i++) {
21776
- if (i > 1) {
21777
- child_list += ", ";
21778
- }
21779
- child_list += entry.children[i]->ToString();
21780
- }
21781
- child_list += ")";
21782
- return "(" + in_child + op_type + child_list + ")";
21783
- }
21784
- case ExpressionType::OPERATOR_NOT:
21785
- case ExpressionType::GROUPING_FUNCTION:
21786
- case ExpressionType::OPERATOR_COALESCE: {
21787
- string result = ExpressionTypeToString(entry.type);
21788
- result += "(";
21789
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
21790
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
21791
- result += ")";
21792
- return result;
21793
- }
21794
- case ExpressionType::OPERATOR_IS_NULL:
21795
- return "(" + entry.children[0]->ToString() + " IS NULL)";
21796
- case ExpressionType::OPERATOR_IS_NOT_NULL:
21797
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
21798
- case ExpressionType::ARRAY_EXTRACT:
21799
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
21800
- case ExpressionType::ARRAY_SLICE:
21801
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
21802
- entry.children[2]->ToString() + "]";
21803
- case ExpressionType::STRUCT_EXTRACT: {
21804
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
21805
- auto child_string = entry.children[1]->ToString();
21806
- D_ASSERT(child_string.size() >= 3);
21807
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
21808
- return "(" + entry.children[0]->ToString() + ")." +
21809
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
21810
- }
21811
- case ExpressionType::ARRAY_CONSTRUCTOR: {
21812
- string result = "ARRAY[";
21813
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
21814
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
21815
- result += "]";
21816
- return result;
21817
- }
21818
- default:
21819
- throw InternalException("Unrecognized operator type");
21820
- }
21715
+ return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
21821
21716
  }
21822
21717
  };
21823
-
21824
21718
  } // namespace duckdb
21719
+
21720
+
21825
21721
  //===----------------------------------------------------------------------===//
21826
21722
  // DuckDB
21827
21723
  //
21828
- // duckdb/parser/expression/between_expression.hpp
21724
+ // duckdb/parser/expression/constant_expression.hpp
21829
21725
  //
21830
21726
  //
21831
21727
  //===----------------------------------------------------------------------===//
@@ -21834,38 +21730,35 @@ public:
21834
21730
 
21835
21731
 
21836
21732
 
21733
+
21837
21734
  namespace duckdb {
21838
21735
 
21839
- class BetweenExpression : public ParsedExpression {
21736
+ //! ConstantExpression represents a constant value in the query
21737
+ class ConstantExpression : public ParsedExpression {
21840
21738
  public:
21841
- BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
21842
- unique_ptr<ParsedExpression> upper);
21739
+ DUCKDB_API explicit ConstantExpression(Value val);
21843
21740
 
21844
- unique_ptr<ParsedExpression> input;
21845
- unique_ptr<ParsedExpression> lower;
21846
- unique_ptr<ParsedExpression> upper;
21741
+ //! The constant value referenced
21742
+ Value value;
21847
21743
 
21848
21744
  public:
21849
21745
  string ToString() const override;
21850
21746
 
21851
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
21747
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
21748
+ hash_t Hash() const override;
21852
21749
 
21853
21750
  unique_ptr<ParsedExpression> Copy() const override;
21854
21751
 
21855
21752
  void Serialize(FieldWriter &writer) const override;
21856
21753
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21857
-
21858
- public:
21859
- template <class T, class BASE>
21860
- static string ToString(const T &entry) {
21861
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
21862
- }
21863
21754
  };
21755
+
21864
21756
  } // namespace duckdb
21757
+
21865
21758
  //===----------------------------------------------------------------------===//
21866
21759
  // DuckDB
21867
21760
  //
21868
- // duckdb/parser/expression/positional_reference_expression.hpp
21761
+ // duckdb/parser/expression/default_expression.hpp
21869
21762
  //
21870
21763
  //
21871
21764
  //===----------------------------------------------------------------------===//
@@ -21875,11 +21768,10 @@ public:
21875
21768
 
21876
21769
 
21877
21770
  namespace duckdb {
21878
- class PositionalReferenceExpression : public ParsedExpression {
21771
+ //! Represents the default value of a column
21772
+ class DefaultExpression : public ParsedExpression {
21879
21773
  public:
21880
- DUCKDB_API PositionalReferenceExpression(idx_t index);
21881
-
21882
- idx_t index;
21774
+ DefaultExpression();
21883
21775
 
21884
21776
  public:
21885
21777
  bool IsScalar() const override {
@@ -21888,21 +21780,17 @@ public:
21888
21780
 
21889
21781
  string ToString() const override;
21890
21782
 
21891
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
21892
21783
  unique_ptr<ParsedExpression> Copy() const override;
21893
- hash_t Hash() const override;
21894
21784
 
21895
21785
  void Serialize(FieldWriter &writer) const override;
21896
21786
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21897
21787
  };
21898
21788
  } // namespace duckdb
21899
21789
 
21900
-
21901
-
21902
21790
  //===----------------------------------------------------------------------===//
21903
21791
  // DuckDB
21904
21792
  //
21905
- // duckdb/parser/expression/cast_expression.hpp
21793
+ // duckdb/parser/expression/function_expression.hpp
21906
21794
  //
21907
21795
  //
21908
21796
  //===----------------------------------------------------------------------===//
@@ -21912,43 +21800,113 @@ public:
21912
21800
 
21913
21801
 
21914
21802
 
21915
- namespace duckdb {
21916
21803
 
21917
- //! CastExpression represents a type cast from one SQL type to another SQL type
21918
- class CastExpression : public ParsedExpression {
21804
+ namespace duckdb {
21805
+ //! Represents a function call
21806
+ class FunctionExpression : public ParsedExpression {
21919
21807
  public:
21920
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
21808
+ DUCKDB_API FunctionExpression(string schema_name, const string &function_name,
21809
+ vector<unique_ptr<ParsedExpression>> children,
21810
+ unique_ptr<ParsedExpression> filter = nullptr,
21811
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
21812
+ bool is_operator = false, bool export_state = false);
21813
+ DUCKDB_API FunctionExpression(const string &function_name, vector<unique_ptr<ParsedExpression>> children,
21814
+ unique_ptr<ParsedExpression> filter = nullptr,
21815
+ unique_ptr<OrderModifier> order_bys = nullptr, bool distinct = false,
21816
+ bool is_operator = false, bool export_state = false);
21921
21817
 
21922
- //! The child of the cast expression
21923
- unique_ptr<ParsedExpression> child;
21924
- //! The type to cast to
21925
- LogicalType cast_type;
21926
- //! Whether or not this is a try_cast expression
21927
- bool try_cast;
21818
+ //! Schema of the function
21819
+ string schema;
21820
+ //! Function name
21821
+ string function_name;
21822
+ //! Whether or not the function is an operator, only used for rendering
21823
+ bool is_operator;
21824
+ //! List of arguments to the function
21825
+ vector<unique_ptr<ParsedExpression>> children;
21826
+ //! Whether or not the aggregate function is distinct, only used for aggregates
21827
+ bool distinct;
21828
+ //! Expression representing a filter, only used for aggregates
21829
+ unique_ptr<ParsedExpression> filter;
21830
+ //! Modifier representing an ORDER BY, only used for aggregates
21831
+ unique_ptr<OrderModifier> order_bys;
21832
+ //! whether this function should export its state or not
21833
+ bool export_state;
21928
21834
 
21929
21835
  public:
21930
21836
  string ToString() const override;
21931
21837
 
21932
- static bool Equals(const CastExpression *a, const CastExpression *b);
21933
-
21934
21838
  unique_ptr<ParsedExpression> Copy() const override;
21935
21839
 
21840
+ static bool Equals(const FunctionExpression *a, const FunctionExpression *b);
21841
+ hash_t Hash() const override;
21842
+
21936
21843
  void Serialize(FieldWriter &writer) const override;
21937
21844
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21938
21845
 
21846
+ void Verify() const override;
21847
+
21939
21848
  public:
21940
21849
  template <class T, class BASE>
21941
- static string ToString(const T &entry) {
21942
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
21943
- entry.cast_type.ToString() + ")";
21850
+ static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
21851
+ bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
21852
+ bool export_state = false) {
21853
+ if (is_operator) {
21854
+ // built-in operator
21855
+ D_ASSERT(!distinct);
21856
+ if (entry.children.size() == 1) {
21857
+ if (StringUtil::Contains(function_name, "__postfix")) {
21858
+ return "(" + entry.children[0]->ToString() + ")" +
21859
+ StringUtil::Replace(function_name, "__postfix", "");
21860
+ } else {
21861
+ return function_name + "(" + entry.children[0]->ToString() + ")";
21862
+ }
21863
+ } else if (entry.children.size() == 2) {
21864
+ return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
21865
+ ")";
21866
+ }
21867
+ }
21868
+ // standard function call
21869
+ string result = schema.empty() ? function_name : schema + "." + function_name;
21870
+ result += "(";
21871
+ if (distinct) {
21872
+ result += "DISTINCT ";
21873
+ }
21874
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
21875
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
21876
+ // ordered aggregate
21877
+ if (order_bys && !order_bys->orders.empty()) {
21878
+ if (entry.children.empty()) {
21879
+ result += ") WITHIN GROUP (";
21880
+ }
21881
+ result += " ORDER BY ";
21882
+ for (idx_t i = 0; i < order_bys->orders.size(); i++) {
21883
+ if (i > 0) {
21884
+ result += ", ";
21885
+ }
21886
+ result += order_bys->orders[i].ToString();
21887
+ }
21888
+ }
21889
+ result += ")";
21890
+
21891
+ // filtered aggregate
21892
+ if (filter) {
21893
+ result += " FILTER (WHERE " + filter->ToString() + ")";
21894
+ }
21895
+
21896
+ if (export_state) {
21897
+ result += " EXPORT_STATE";
21898
+ }
21899
+
21900
+ return result;
21944
21901
  }
21945
21902
  };
21946
21903
  } // namespace duckdb
21947
21904
 
21905
+
21948
21906
  //===----------------------------------------------------------------------===//
21949
21907
  // DuckDB
21950
21908
  //
21951
- // duckdb/parser/expression/collate_expression.hpp
21909
+ // duckdb/parser/expression/operator_expression.hpp
21952
21910
  //
21953
21911
  //
21954
21912
  //===----------------------------------------------------------------------===//
@@ -21957,37 +21915,94 @@ public:
21957
21915
 
21958
21916
 
21959
21917
 
21960
- namespace duckdb {
21961
21918
 
21962
- //! CollateExpression represents a COLLATE statement
21963
- class CollateExpression : public ParsedExpression {
21919
+
21920
+
21921
+ namespace duckdb {
21922
+ //! Represents a built-in operator expression
21923
+ class OperatorExpression : public ParsedExpression {
21964
21924
  public:
21965
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
21925
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
21926
+ unique_ptr<ParsedExpression> right = nullptr);
21927
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
21966
21928
 
21967
- //! The child of the cast expression
21968
- unique_ptr<ParsedExpression> child;
21969
- //! The collation clause
21970
- string collation;
21929
+ vector<unique_ptr<ParsedExpression>> children;
21971
21930
 
21972
21931
  public:
21973
21932
  string ToString() const override;
21974
21933
 
21975
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
21934
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
21976
21935
 
21977
21936
  unique_ptr<ParsedExpression> Copy() const override;
21978
21937
 
21979
21938
  void Serialize(FieldWriter &writer) const override;
21980
21939
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
21940
+
21941
+ public:
21942
+ template <class T, class BASE>
21943
+ static string ToString(const T &entry) {
21944
+ auto op = ExpressionTypeToOperator(entry.type);
21945
+ if (!op.empty()) {
21946
+ // use the operator string to represent the operator
21947
+ D_ASSERT(entry.children.size() == 2);
21948
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
21949
+ }
21950
+ switch (entry.type) {
21951
+ case ExpressionType::COMPARE_IN:
21952
+ case ExpressionType::COMPARE_NOT_IN: {
21953
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
21954
+ string in_child = entry.children[0]->ToString();
21955
+ string child_list = "(";
21956
+ for (idx_t i = 1; i < entry.children.size(); i++) {
21957
+ if (i > 1) {
21958
+ child_list += ", ";
21959
+ }
21960
+ child_list += entry.children[i]->ToString();
21961
+ }
21962
+ child_list += ")";
21963
+ return "(" + in_child + op_type + child_list + ")";
21964
+ }
21965
+ case ExpressionType::OPERATOR_NOT:
21966
+ case ExpressionType::GROUPING_FUNCTION:
21967
+ case ExpressionType::OPERATOR_COALESCE: {
21968
+ string result = ExpressionTypeToString(entry.type);
21969
+ result += "(";
21970
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
21971
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
21972
+ result += ")";
21973
+ return result;
21974
+ }
21975
+ case ExpressionType::OPERATOR_IS_NULL:
21976
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
21977
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
21978
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
21979
+ case ExpressionType::ARRAY_EXTRACT:
21980
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
21981
+ case ExpressionType::ARRAY_SLICE:
21982
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
21983
+ entry.children[2]->ToString() + "]";
21984
+ case ExpressionType::STRUCT_EXTRACT: {
21985
+ D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
21986
+ auto child_string = entry.children[1]->ToString();
21987
+ D_ASSERT(child_string.size() >= 3);
21988
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
21989
+ return "(" + entry.children[0]->ToString() + ")." +
21990
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
21991
+ }
21992
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
21993
+ string result = "ARRAY[";
21994
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
21995
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
21996
+ result += "]";
21997
+ return result;
21998
+ }
21999
+ default:
22000
+ throw InternalException("Unrecognized operator type");
22001
+ }
22002
+ }
21981
22003
  };
21982
- } // namespace duckdb
21983
-
21984
-
21985
-
21986
-
21987
-
21988
-
21989
-
21990
22004
 
22005
+ } // namespace duckdb
21991
22006
 
21992
22007
  //===----------------------------------------------------------------------===//
21993
22008
  // DuckDB
@@ -22026,11 +22041,10 @@ public:
22026
22041
  };
22027
22042
  } // namespace duckdb
22028
22043
 
22029
-
22030
22044
  //===----------------------------------------------------------------------===//
22031
22045
  // DuckDB
22032
22046
  //
22033
- // duckdb/parser/expression/star_expression.hpp
22047
+ // duckdb/parser/expression/positional_reference_expression.hpp
22034
22048
  //
22035
22049
  //
22036
22050
  //===----------------------------------------------------------------------===//
@@ -22039,27 +22053,23 @@ public:
22039
22053
 
22040
22054
 
22041
22055
 
22042
-
22043
22056
  namespace duckdb {
22044
-
22045
- //! Represents a * expression in the SELECT clause
22046
- class StarExpression : public ParsedExpression {
22057
+ class PositionalReferenceExpression : public ParsedExpression {
22047
22058
  public:
22048
- StarExpression(string relation_name = string());
22059
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
22049
22060
 
22050
- //! The relation name in case of tbl.*, or empty if this is a normal *
22051
- string relation_name;
22052
- //! List of columns to exclude from the STAR expression
22053
- case_insensitive_set_t exclude_list;
22054
- //! List of columns to replace with another expression
22055
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
22061
+ idx_t index;
22056
22062
 
22057
22063
  public:
22058
- string ToString() const override;
22064
+ bool IsScalar() const override {
22065
+ return false;
22066
+ }
22059
22067
 
22060
- static bool Equals(const StarExpression *a, const StarExpression *b);
22068
+ string ToString() const override;
22061
22069
 
22070
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
22062
22071
  unique_ptr<ParsedExpression> Copy() const override;
22072
+ hash_t Hash() const override;
22063
22073
 
22064
22074
  void Serialize(FieldWriter &writer) const override;
22065
22075
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
@@ -22069,7 +22079,7 @@ public:
22069
22079
  //===----------------------------------------------------------------------===//
22070
22080
  // DuckDB
22071
22081
  //
22072
- // duckdb/parser/expression/subquery_expression.hpp
22082
+ // duckdb/parser/expression/star_expression.hpp
22073
22083
  //
22074
22084
  //
22075
22085
  //===----------------------------------------------------------------------===//
@@ -22079,35 +22089,24 @@ public:
22079
22089
 
22080
22090
 
22081
22091
 
22082
-
22083
22092
  namespace duckdb {
22084
22093
 
22085
- //! Represents a subquery
22086
- class SubqueryExpression : public ParsedExpression {
22094
+ //! Represents a * expression in the SELECT clause
22095
+ class StarExpression : public ParsedExpression {
22087
22096
  public:
22088
- SubqueryExpression();
22097
+ StarExpression(string relation_name = string());
22089
22098
 
22090
- //! The actual subquery
22091
- unique_ptr<SelectStatement> subquery;
22092
- //! The subquery type
22093
- SubqueryType subquery_type;
22094
- //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
22095
- //! subquery)
22096
- unique_ptr<ParsedExpression> child;
22097
- //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
22098
- ExpressionType comparison_type;
22099
+ //! The relation name in case of tbl.*, or empty if this is a normal *
22100
+ string relation_name;
22101
+ //! List of columns to exclude from the STAR expression
22102
+ case_insensitive_set_t exclude_list;
22103
+ //! List of columns to replace with another expression
22104
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
22099
22105
 
22100
22106
  public:
22101
- bool HasSubquery() const override {
22102
- return true;
22103
- }
22104
- bool IsScalar() const override {
22105
- return false;
22106
- }
22107
-
22108
22107
  string ToString() const override;
22109
22108
 
22110
- static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
22109
+ static bool Equals(const StarExpression *a, const StarExpression *b);
22111
22110
 
22112
22111
  unique_ptr<ParsedExpression> Copy() const override;
22113
22112
 
@@ -22117,10 +22116,11 @@ public:
22117
22116
  } // namespace duckdb
22118
22117
 
22119
22118
 
22119
+
22120
22120
  //===----------------------------------------------------------------------===//
22121
22121
  // DuckDB
22122
22122
  //
22123
- // duckdb/parser/parsed_data/create_collation_info.hpp
22123
+ // duckdb/parser/parsed_data/export_table_data.hpp
22124
22124
  //
22125
22125
  //
22126
22126
  //===----------------------------------------------------------------------===//
@@ -22132,37 +22132,26 @@ public:
22132
22132
 
22133
22133
  namespace duckdb {
22134
22134
 
22135
- struct CreateCollationInfo : public CreateInfo {
22136
- CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
22137
- : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
22138
- not_required_for_equality(not_required_for_equality_p) {
22139
- this->name = move(name_p);
22140
- }
22135
+ struct ExportedTableData {
22136
+ //! Name of the exported table
22137
+ string table_name;
22141
22138
 
22142
- //! The name of the collation
22143
- string name;
22144
- //! The collation function to push in case collation is required
22145
- ScalarFunction function;
22146
- //! Whether or not the collation can be combined with other collations.
22147
- bool combinable;
22148
- //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
22149
- //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
22150
- //! speeds up processing.
22151
- bool not_required_for_equality;
22139
+ //! Name of the schema
22140
+ string schema_name;
22152
22141
 
22153
- public:
22154
- unique_ptr<CreateInfo> Copy() const override {
22155
- auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
22156
- CopyProperties(*result);
22157
- return move(result);
22158
- }
22142
+ //! Path to be exported
22143
+ string file_path;
22144
+ };
22145
+
22146
+ struct BoundExportData : public ParseInfo {
22147
+ unordered_map<TableCatalogEntry *, ExportedTableData> data;
22159
22148
  };
22160
22149
 
22161
22150
  } // namespace duckdb
22162
22151
  //===----------------------------------------------------------------------===//
22163
22152
  // DuckDB
22164
22153
  //
22165
- // duckdb/parser/parsed_data/vacuum_info.hpp
22154
+ // duckdb/parser/parsed_data/create_type_info.hpp
22166
22155
  //
22167
22156
  //
22168
22157
  //===----------------------------------------------------------------------===//
@@ -22171,56 +22160,28 @@ public:
22171
22160
 
22172
22161
 
22173
22162
 
22174
- namespace duckdb {
22175
-
22176
- enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
22177
-
22178
- struct LoadInfo : public ParseInfo {
22179
- std::string filename;
22180
- LoadType load_type;
22181
-
22182
- public:
22183
- unique_ptr<LoadInfo> Copy() const {
22184
- auto result = make_unique<LoadInfo>();
22185
- result->filename = filename;
22186
- result->load_type = load_type;
22187
- return result;
22188
- }
22189
- };
22190
-
22191
- } // namespace duckdb
22192
- //===----------------------------------------------------------------------===//
22193
- // DuckDB
22194
- //
22195
- // duckdb/parser/parsed_data/show_select_info.hpp
22196
- //
22197
- //
22198
- //===----------------------------------------------------------------------===//
22199
-
22200
22163
 
22201
22164
 
22202
22165
 
22166
+ namespace duckdb {
22203
22167
 
22168
+ struct CreateTypeInfo : public CreateInfo {
22204
22169
 
22205
- namespace duckdb {
22170
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
22171
+ }
22206
22172
 
22207
- struct ShowSelectInfo : public ParseInfo {
22208
- //! Types of projected columns
22209
- vector<LogicalType> types;
22210
- //! The QueryNode of select query
22211
- unique_ptr<QueryNode> query;
22212
- //! Aliases of projected columns
22213
- vector<string> aliases;
22214
- //! Whether or not we are requesting a summary or a describe
22215
- bool is_summary;
22173
+ //! Name of the Type
22174
+ string name;
22175
+ //! Logical Type
22176
+ LogicalType type;
22216
22177
 
22217
- unique_ptr<ShowSelectInfo> Copy() {
22218
- auto result = make_unique<ShowSelectInfo>();
22219
- result->types = types;
22220
- result->query = query->Copy();
22221
- result->aliases = aliases;
22222
- result->is_summary = is_summary;
22223
- return result;
22178
+ public:
22179
+ unique_ptr<CreateInfo> Copy() const override {
22180
+ auto result = make_unique<CreateTypeInfo>();
22181
+ CopyProperties(*result);
22182
+ result->name = name;
22183
+ result->type = type;
22184
+ return move(result);
22224
22185
  }
22225
22186
  };
22226
22187
 
@@ -22269,7 +22230,7 @@ public:
22269
22230
  //===----------------------------------------------------------------------===//
22270
22231
  // DuckDB
22271
22232
  //
22272
- // duckdb/parser/parsed_data/create_type_info.hpp
22233
+ // duckdb/parser/parsed_data/transaction_info.hpp
22273
22234
  //
22274
22235
  //
22275
22236
  //===----------------------------------------------------------------------===//
@@ -22278,36 +22239,23 @@ public:
22278
22239
 
22279
22240
 
22280
22241
 
22281
-
22282
-
22283
-
22284
22242
  namespace duckdb {
22285
22243
 
22286
- struct CreateTypeInfo : public CreateInfo {
22244
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
22287
22245
 
22288
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
22246
+ struct TransactionInfo : public ParseInfo {
22247
+ explicit TransactionInfo(TransactionType type) : type(type) {
22289
22248
  }
22290
22249
 
22291
- //! Name of the Type
22292
- string name;
22293
- //! Logical Type
22294
- LogicalType type;
22295
-
22296
- public:
22297
- unique_ptr<CreateInfo> Copy() const override {
22298
- auto result = make_unique<CreateTypeInfo>();
22299
- CopyProperties(*result);
22300
- result->name = name;
22301
- result->type = type;
22302
- return move(result);
22303
- }
22250
+ //! The type of transaction statement
22251
+ TransactionType type;
22304
22252
  };
22305
22253
 
22306
22254
  } // namespace duckdb
22307
22255
  //===----------------------------------------------------------------------===//
22308
22256
  // DuckDB
22309
22257
  //
22310
- // duckdb/parser/parsed_data/vacuum_info.hpp
22258
+ // duckdb/parser/parsed_data/show_select_info.hpp
22311
22259
  //
22312
22260
  //
22313
22261
  //===----------------------------------------------------------------------===//
@@ -22316,17 +22264,34 @@ public:
22316
22264
 
22317
22265
 
22318
22266
 
22267
+
22319
22268
  namespace duckdb {
22320
22269
 
22321
- struct VacuumInfo : public ParseInfo {
22322
- // nothing for now
22270
+ struct ShowSelectInfo : public ParseInfo {
22271
+ //! Types of projected columns
22272
+ vector<LogicalType> types;
22273
+ //! The QueryNode of select query
22274
+ unique_ptr<QueryNode> query;
22275
+ //! Aliases of projected columns
22276
+ vector<string> aliases;
22277
+ //! Whether or not we are requesting a summary or a describe
22278
+ bool is_summary;
22279
+
22280
+ unique_ptr<ShowSelectInfo> Copy() {
22281
+ auto result = make_unique<ShowSelectInfo>();
22282
+ result->types = types;
22283
+ result->query = query->Copy();
22284
+ result->aliases = aliases;
22285
+ result->is_summary = is_summary;
22286
+ return result;
22287
+ }
22323
22288
  };
22324
22289
 
22325
22290
  } // namespace duckdb
22326
22291
  //===----------------------------------------------------------------------===//
22327
22292
  // DuckDB
22328
22293
  //
22329
- // duckdb/parser/parsed_data/drop_info.hpp
22294
+ // duckdb/parser/parsed_data/vacuum_info.hpp
22330
22295
  //
22331
22296
  //
22332
22297
  //===----------------------------------------------------------------------===//
@@ -22335,42 +22300,17 @@ struct VacuumInfo : public ParseInfo {
22335
22300
 
22336
22301
 
22337
22302
 
22338
-
22339
22303
  namespace duckdb {
22340
22304
 
22341
- struct DropInfo : public ParseInfo {
22342
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
22343
- }
22344
-
22345
- //! The catalog type to drop
22346
- CatalogType type;
22347
- //! Schema name to drop from, if any
22348
- string schema;
22349
- //! Element name to drop
22350
- string name;
22351
- //! Ignore if the entry does not exist instead of failing
22352
- bool if_exists = false;
22353
- //! Cascade drop (drop all dependents instead of throwing an error if there
22354
- //! are any)
22355
- bool cascade = false;
22356
-
22357
- public:
22358
- unique_ptr<DropInfo> Copy() const {
22359
- auto result = make_unique<DropInfo>();
22360
- result->type = type;
22361
- result->schema = schema;
22362
- result->name = name;
22363
- result->if_exists = if_exists;
22364
- result->cascade = cascade;
22365
- return result;
22366
- }
22305
+ struct VacuumInfo : public ParseInfo {
22306
+ // nothing for now
22367
22307
  };
22368
22308
 
22369
22309
  } // namespace duckdb
22370
22310
  //===----------------------------------------------------------------------===//
22371
22311
  // DuckDB
22372
22312
  //
22373
- // duckdb/parser/parsed_data/transaction_info.hpp
22313
+ // duckdb/parser/parsed_data/vacuum_info.hpp
22374
22314
  //
22375
22315
  //
22376
22316
  //===----------------------------------------------------------------------===//
@@ -22381,14 +22321,19 @@ public:
22381
22321
 
22382
22322
  namespace duckdb {
22383
22323
 
22384
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
22324
+ enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
22325
+
22326
+ struct LoadInfo : public ParseInfo {
22327
+ std::string filename;
22328
+ LoadType load_type;
22385
22329
 
22386
- struct TransactionInfo : public ParseInfo {
22387
- explicit TransactionInfo(TransactionType type) : type(type) {
22330
+ public:
22331
+ unique_ptr<LoadInfo> Copy() const {
22332
+ auto result = make_unique<LoadInfo>();
22333
+ result->filename = filename;
22334
+ result->load_type = load_type;
22335
+ return result;
22388
22336
  }
22389
-
22390
- //! The type of transaction statement
22391
- TransactionType type;
22392
22337
  };
22393
22338
 
22394
22339
  } // namespace duckdb
@@ -22462,33 +22407,6 @@ public:
22462
22407
  }
22463
22408
  };
22464
22409
 
22465
- } // namespace duckdb
22466
- //===----------------------------------------------------------------------===//
22467
- // DuckDB
22468
- //
22469
- // duckdb/parser/parsed_data/create_schema_info.hpp
22470
- //
22471
- //
22472
- //===----------------------------------------------------------------------===//
22473
-
22474
-
22475
-
22476
-
22477
-
22478
- namespace duckdb {
22479
-
22480
- struct CreateSchemaInfo : public CreateInfo {
22481
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
22482
- }
22483
-
22484
- public:
22485
- unique_ptr<CreateInfo> Copy() const override {
22486
- auto result = make_unique<CreateSchemaInfo>();
22487
- CopyProperties(*result);
22488
- return move(result);
22489
- }
22490
- };
22491
-
22492
22410
  } // namespace duckdb
22493
22411
  //===----------------------------------------------------------------------===//
22494
22412
  // DuckDB
@@ -22581,7 +22499,7 @@ public:
22581
22499
  //===----------------------------------------------------------------------===//
22582
22500
  // DuckDB
22583
22501
  //
22584
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
22502
+ // duckdb/parser/parsed_data/drop_info.hpp
22585
22503
  //
22586
22504
  //
22587
22505
  //===----------------------------------------------------------------------===//
@@ -22593,61 +22511,34 @@ public:
22593
22511
 
22594
22512
  namespace duckdb {
22595
22513
 
22596
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
22597
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
22598
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
22599
- functions.push_back(move(function));
22600
- this->name = function.name;
22601
- }
22602
- CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
22603
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
22604
- this->name = name;
22605
- for (auto &function : functions) {
22606
- function.name = name;
22607
- }
22514
+ struct DropInfo : public ParseInfo {
22515
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
22608
22516
  }
22609
22517
 
22610
- vector<PragmaFunction> functions;
22518
+ //! The catalog type to drop
22519
+ CatalogType type;
22520
+ //! Schema name to drop from, if any
22521
+ string schema;
22522
+ //! Element name to drop
22523
+ string name;
22524
+ //! Ignore if the entry does not exist instead of failing
22525
+ bool if_exists = false;
22526
+ //! Cascade drop (drop all dependents instead of throwing an error if there
22527
+ //! are any)
22528
+ bool cascade = false;
22611
22529
 
22612
22530
  public:
22613
- unique_ptr<CreateInfo> Copy() const override {
22614
- auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
22615
- CopyProperties(*result);
22616
- return move(result);
22531
+ unique_ptr<DropInfo> Copy() const {
22532
+ auto result = make_unique<DropInfo>();
22533
+ result->type = type;
22534
+ result->schema = schema;
22535
+ result->name = name;
22536
+ result->if_exists = if_exists;
22537
+ result->cascade = cascade;
22538
+ return result;
22617
22539
  }
22618
22540
  };
22619
22541
 
22620
- } // namespace duckdb
22621
- //===----------------------------------------------------------------------===//
22622
- // DuckDB
22623
- //
22624
- // duckdb/parser/parsed_data/export_table_data.hpp
22625
- //
22626
- //
22627
- //===----------------------------------------------------------------------===//
22628
-
22629
-
22630
-
22631
-
22632
-
22633
-
22634
- namespace duckdb {
22635
-
22636
- struct ExportedTableData {
22637
- //! Name of the exported table
22638
- string table_name;
22639
-
22640
- //! Name of the schema
22641
- string schema_name;
22642
-
22643
- //! Path to be exported
22644
- string file_path;
22645
- };
22646
-
22647
- struct BoundExportData : public ParseInfo {
22648
- unordered_map<TableCatalogEntry *, ExportedTableData> data;
22649
- };
22650
-
22651
22542
  } // namespace duckdb
22652
22543
  //===----------------------------------------------------------------------===//
22653
22544
  // DuckDB
@@ -22695,7 +22586,7 @@ public:
22695
22586
  //===----------------------------------------------------------------------===//
22696
22587
  // DuckDB
22697
22588
  //
22698
- // duckdb/parser/tableref/table_function_ref.hpp
22589
+ // duckdb/parser/parsed_data/create_schema_info.hpp
22699
22590
  //
22700
22591
  //
22701
22592
  //===----------------------------------------------------------------------===//
@@ -22704,34 +22595,102 @@ public:
22704
22595
 
22705
22596
 
22706
22597
 
22598
+ namespace duckdb {
22599
+
22600
+ struct CreateSchemaInfo : public CreateInfo {
22601
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
22602
+ }
22603
+
22604
+ public:
22605
+ unique_ptr<CreateInfo> Copy() const override {
22606
+ auto result = make_unique<CreateSchemaInfo>();
22607
+ CopyProperties(*result);
22608
+ return move(result);
22609
+ }
22610
+ };
22611
+
22612
+ } // namespace duckdb
22613
+ //===----------------------------------------------------------------------===//
22614
+ // DuckDB
22615
+ //
22616
+ // duckdb/parser/parsed_data/create_collation_info.hpp
22617
+ //
22618
+ //
22619
+ //===----------------------------------------------------------------------===//
22620
+
22621
+
22622
+
22707
22623
 
22708
22624
 
22709
22625
 
22710
22626
  namespace duckdb {
22711
- //! Represents a Table producing function
22712
- class TableFunctionRef : public TableRef {
22627
+
22628
+ struct CreateCollationInfo : public CreateInfo {
22629
+ CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
22630
+ : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
22631
+ not_required_for_equality(not_required_for_equality_p) {
22632
+ this->name = move(name_p);
22633
+ }
22634
+
22635
+ //! The name of the collation
22636
+ string name;
22637
+ //! The collation function to push in case collation is required
22638
+ ScalarFunction function;
22639
+ //! Whether or not the collation can be combined with other collations.
22640
+ bool combinable;
22641
+ //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
22642
+ //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
22643
+ //! speeds up processing.
22644
+ bool not_required_for_equality;
22645
+
22713
22646
  public:
22714
- TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
22647
+ unique_ptr<CreateInfo> Copy() const override {
22648
+ auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
22649
+ CopyProperties(*result);
22650
+ return move(result);
22715
22651
  }
22652
+ };
22716
22653
 
22717
- unique_ptr<ParsedExpression> function;
22718
- vector<string> column_name_alias;
22654
+ } // namespace duckdb
22655
+ //===----------------------------------------------------------------------===//
22656
+ // DuckDB
22657
+ //
22658
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
22659
+ //
22660
+ //
22661
+ //===----------------------------------------------------------------------===//
22719
22662
 
22720
- // if the function takes a subquery as argument its in here
22721
- unique_ptr<SelectStatement> subquery;
22722
22663
 
22723
- public:
22724
- string ToString() const override;
22725
22664
 
22726
- bool Equals(const TableRef *other_p) const override;
22727
22665
 
22728
- unique_ptr<TableRef> Copy() override;
22729
22666
 
22730
- //! Serializes a blob into a BaseTableRef
22731
- void Serialize(FieldWriter &serializer) const override;
22732
- //! Deserializes a blob back into a BaseTableRef
22733
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
22667
+
22668
+ namespace duckdb {
22669
+
22670
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
22671
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
22672
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
22673
+ functions.push_back(move(function));
22674
+ this->name = function.name;
22675
+ }
22676
+ CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
22677
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
22678
+ this->name = name;
22679
+ for (auto &function : functions) {
22680
+ function.name = name;
22681
+ }
22682
+ }
22683
+
22684
+ vector<PragmaFunction> functions;
22685
+
22686
+ public:
22687
+ unique_ptr<CreateInfo> Copy() const override {
22688
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
22689
+ CopyProperties(*result);
22690
+ return move(result);
22691
+ }
22734
22692
  };
22693
+
22735
22694
  } // namespace duckdb
22736
22695
  //===----------------------------------------------------------------------===//
22737
22696
  // DuckDB
@@ -22768,6 +22727,8 @@ public:
22768
22727
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
22769
22728
  };
22770
22729
  } // namespace duckdb
22730
+
22731
+
22771
22732
  //===----------------------------------------------------------------------===//
22772
22733
  // DuckDB
22773
22734
  //
@@ -22799,8 +22760,6 @@ public:
22799
22760
  };
22800
22761
  } // namespace duckdb
22801
22762
 
22802
-
22803
-
22804
22763
  //===----------------------------------------------------------------------===//
22805
22764
  // DuckDB
22806
22765
  //
@@ -22926,4 +22885,45 @@ public:
22926
22885
  };
22927
22886
  } // namespace duckdb
22928
22887
 
22888
+ //===----------------------------------------------------------------------===//
22889
+ // DuckDB
22890
+ //
22891
+ // duckdb/parser/tableref/table_function_ref.hpp
22892
+ //
22893
+ //
22894
+ //===----------------------------------------------------------------------===//
22895
+
22896
+
22897
+
22898
+
22899
+
22900
+
22901
+
22902
+
22903
+ namespace duckdb {
22904
+ //! Represents a Table producing function
22905
+ class TableFunctionRef : public TableRef {
22906
+ public:
22907
+ TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
22908
+ }
22909
+
22910
+ unique_ptr<ParsedExpression> function;
22911
+ vector<string> column_name_alias;
22912
+
22913
+ // if the function takes a subquery as argument its in here
22914
+ unique_ptr<SelectStatement> subquery;
22915
+
22916
+ public:
22917
+ string ToString() const override;
22918
+
22919
+ bool Equals(const TableRef *other_p) const override;
22920
+
22921
+ unique_ptr<TableRef> Copy() override;
22922
+
22923
+ //! Serializes a blob into a BaseTableRef
22924
+ void Serialize(FieldWriter &serializer) const override;
22925
+ //! Deserializes a blob back into a BaseTableRef
22926
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
22927
+ };
22928
+ } // namespace duckdb
22929
22929