duckdb 0.4.1-dev429.0 → 0.4.1-dev439.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 "bdaf5efab"
15
- #define DUCKDB_VERSION "v0.4.1-dev429"
14
+ #define DUCKDB_SOURCE_ID "dc7a5ccc5"
15
+ #define DUCKDB_VERSION "v0.4.1-dev439"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -23295,7 +23295,7 @@ private:
23295
23295
  //===----------------------------------------------------------------------===//
23296
23296
  // DuckDB
23297
23297
  //
23298
- // duckdb/parser/expression/between_expression.hpp
23298
+ // duckdb/parser/expression/cast_expression.hpp
23299
23299
  //
23300
23300
  //
23301
23301
  //===----------------------------------------------------------------------===//
@@ -23304,21 +23304,25 @@ private:
23304
23304
 
23305
23305
 
23306
23306
 
23307
+
23307
23308
  namespace duckdb {
23308
23309
 
23309
- class BetweenExpression : public ParsedExpression {
23310
+ //! CastExpression represents a type cast from one SQL type to another SQL type
23311
+ class CastExpression : public ParsedExpression {
23310
23312
  public:
23311
- DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
23312
- unique_ptr<ParsedExpression> upper);
23313
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
23313
23314
 
23314
- unique_ptr<ParsedExpression> input;
23315
- unique_ptr<ParsedExpression> lower;
23316
- unique_ptr<ParsedExpression> upper;
23315
+ //! The child of the cast expression
23316
+ unique_ptr<ParsedExpression> child;
23317
+ //! The type to cast to
23318
+ LogicalType cast_type;
23319
+ //! Whether or not this is a try_cast expression
23320
+ bool try_cast;
23317
23321
 
23318
23322
  public:
23319
23323
  string ToString() const override;
23320
23324
 
23321
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
23325
+ static bool Equals(const CastExpression *a, const CastExpression *b);
23322
23326
 
23323
23327
  unique_ptr<ParsedExpression> Copy() const override;
23324
23328
 
@@ -23328,16 +23332,15 @@ public:
23328
23332
  public:
23329
23333
  template <class T, class BASE>
23330
23334
  static string ToString(const T &entry) {
23331
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
23335
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
23336
+ entry.cast_type.ToString() + ")";
23332
23337
  }
23333
23338
  };
23334
23339
  } // namespace duckdb
23335
-
23336
-
23337
23340
  //===----------------------------------------------------------------------===//
23338
23341
  // DuckDB
23339
23342
  //
23340
- // duckdb/parser/expression/case_expression.hpp
23343
+ // duckdb/parser/expression/operator_expression.hpp
23341
23344
  //
23342
23345
  //
23343
23346
  //===----------------------------------------------------------------------===//
@@ -23347,25 +23350,22 @@ public:
23347
23350
 
23348
23351
 
23349
23352
 
23350
- namespace duckdb {
23351
23353
 
23352
- struct CaseCheck {
23353
- unique_ptr<ParsedExpression> when_expr;
23354
- unique_ptr<ParsedExpression> then_expr;
23355
- };
23356
23354
 
23357
- //! The CaseExpression represents a CASE expression in the query
23358
- class CaseExpression : public ParsedExpression {
23355
+ namespace duckdb {
23356
+ //! Represents a built-in operator expression
23357
+ class OperatorExpression : public ParsedExpression {
23359
23358
  public:
23360
- DUCKDB_API CaseExpression();
23359
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
23360
+ unique_ptr<ParsedExpression> right = nullptr);
23361
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23361
23362
 
23362
- vector<CaseCheck> case_checks;
23363
- unique_ptr<ParsedExpression> else_expr;
23363
+ vector<unique_ptr<ParsedExpression>> children;
23364
23364
 
23365
23365
  public:
23366
23366
  string ToString() const override;
23367
23367
 
23368
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
23368
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23369
23369
 
23370
23370
  unique_ptr<ParsedExpression> Copy() const override;
23371
23371
 
@@ -23375,22 +23375,74 @@ public:
23375
23375
  public:
23376
23376
  template <class T, class BASE>
23377
23377
  static string ToString(const T &entry) {
23378
- string case_str = "CASE ";
23379
- for (auto &check : entry.case_checks) {
23380
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
23381
- case_str += " THEN (" + check.then_expr->ToString() + ")";
23378
+ auto op = ExpressionTypeToOperator(entry.type);
23379
+ if (!op.empty()) {
23380
+ // use the operator string to represent the operator
23381
+ D_ASSERT(entry.children.size() == 2);
23382
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23383
+ }
23384
+ switch (entry.type) {
23385
+ case ExpressionType::COMPARE_IN:
23386
+ case ExpressionType::COMPARE_NOT_IN: {
23387
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23388
+ string in_child = entry.children[0]->ToString();
23389
+ string child_list = "(";
23390
+ for (idx_t i = 1; i < entry.children.size(); i++) {
23391
+ if (i > 1) {
23392
+ child_list += ", ";
23393
+ }
23394
+ child_list += entry.children[i]->ToString();
23395
+ }
23396
+ child_list += ")";
23397
+ return "(" + in_child + op_type + child_list + ")";
23398
+ }
23399
+ case ExpressionType::OPERATOR_NOT:
23400
+ case ExpressionType::GROUPING_FUNCTION:
23401
+ case ExpressionType::OPERATOR_COALESCE: {
23402
+ string result = ExpressionTypeToString(entry.type);
23403
+ result += "(";
23404
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23405
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23406
+ result += ")";
23407
+ return result;
23408
+ }
23409
+ case ExpressionType::OPERATOR_IS_NULL:
23410
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
23411
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
23412
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23413
+ case ExpressionType::ARRAY_EXTRACT:
23414
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23415
+ case ExpressionType::ARRAY_SLICE:
23416
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23417
+ entry.children[2]->ToString() + "]";
23418
+ case ExpressionType::STRUCT_EXTRACT: {
23419
+ if (entry.children[1]->type != ExpressionType::VALUE_CONSTANT) {
23420
+ return string();
23421
+ }
23422
+ auto child_string = entry.children[1]->ToString();
23423
+ D_ASSERT(child_string.size() >= 3);
23424
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23425
+ return "(" + entry.children[0]->ToString() + ")." +
23426
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23427
+ }
23428
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
23429
+ string result = "(ARRAY[";
23430
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23431
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
23432
+ result += "])";
23433
+ return result;
23434
+ }
23435
+ default:
23436
+ throw InternalException("Unrecognized operator type");
23382
23437
  }
23383
- case_str += " ELSE " + entry.else_expr->ToString();
23384
- case_str += " END";
23385
- return case_str;
23386
23438
  }
23387
23439
  };
23388
- } // namespace duckdb
23389
23440
 
23441
+ } // namespace duckdb
23390
23442
  //===----------------------------------------------------------------------===//
23391
23443
  // DuckDB
23392
23444
  //
23393
- // duckdb/parser/expression/cast_expression.hpp
23445
+ // duckdb/parser/expression/star_expression.hpp
23394
23446
  //
23395
23447
  //
23396
23448
  //===----------------------------------------------------------------------===//
@@ -23402,41 +23454,33 @@ public:
23402
23454
 
23403
23455
  namespace duckdb {
23404
23456
 
23405
- //! CastExpression represents a type cast from one SQL type to another SQL type
23406
- class CastExpression : public ParsedExpression {
23457
+ //! Represents a * expression in the SELECT clause
23458
+ class StarExpression : public ParsedExpression {
23407
23459
  public:
23408
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
23460
+ StarExpression(string relation_name = string());
23409
23461
 
23410
- //! The child of the cast expression
23411
- unique_ptr<ParsedExpression> child;
23412
- //! The type to cast to
23413
- LogicalType cast_type;
23414
- //! Whether or not this is a try_cast expression
23415
- bool try_cast;
23462
+ //! The relation name in case of tbl.*, or empty if this is a normal *
23463
+ string relation_name;
23464
+ //! List of columns to exclude from the STAR expression
23465
+ case_insensitive_set_t exclude_list;
23466
+ //! List of columns to replace with another expression
23467
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23416
23468
 
23417
23469
  public:
23418
23470
  string ToString() const override;
23419
23471
 
23420
- static bool Equals(const CastExpression *a, const CastExpression *b);
23472
+ static bool Equals(const StarExpression *a, const StarExpression *b);
23421
23473
 
23422
23474
  unique_ptr<ParsedExpression> Copy() const override;
23423
23475
 
23424
23476
  void Serialize(FieldWriter &writer) const override;
23425
23477
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23426
-
23427
- public:
23428
- template <class T, class BASE>
23429
- static string ToString(const T &entry) {
23430
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
23431
- entry.cast_type.ToString() + ")";
23432
- }
23433
23478
  };
23434
23479
  } // namespace duckdb
23435
-
23436
23480
  //===----------------------------------------------------------------------===//
23437
23481
  // DuckDB
23438
23482
  //
23439
- // duckdb/parser/expression/collate_expression.hpp
23483
+ // duckdb/parser/expression/lambda_expression.hpp
23440
23484
  //
23441
23485
  //
23442
23486
  //===----------------------------------------------------------------------===//
@@ -23445,35 +23489,37 @@ public:
23445
23489
 
23446
23490
 
23447
23491
 
23492
+
23448
23493
  namespace duckdb {
23449
23494
 
23450
- //! CollateExpression represents a COLLATE statement
23451
- class CollateExpression : public ParsedExpression {
23495
+ //! LambdaExpression represents either:
23496
+ //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
23497
+ //! 2. An OperatorExpression with the "->" operator
23498
+ //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
23499
+ class LambdaExpression : public ParsedExpression {
23452
23500
  public:
23453
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
23501
+ LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
23454
23502
 
23455
- //! The child of the cast expression
23456
- unique_ptr<ParsedExpression> child;
23457
- //! The collation clause
23458
- string collation;
23503
+ unique_ptr<ParsedExpression> lhs;
23504
+ unique_ptr<ParsedExpression> rhs;
23459
23505
 
23460
23506
  public:
23461
23507
  string ToString() const override;
23462
23508
 
23463
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
23509
+ static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
23510
+ hash_t Hash() const override;
23464
23511
 
23465
23512
  unique_ptr<ParsedExpression> Copy() const override;
23466
23513
 
23467
23514
  void Serialize(FieldWriter &writer) const override;
23468
23515
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23469
23516
  };
23470
- } // namespace duckdb
23471
-
23472
23517
 
23518
+ } // namespace duckdb
23473
23519
  //===----------------------------------------------------------------------===//
23474
23520
  // DuckDB
23475
23521
  //
23476
- // duckdb/parser/expression/comparison_expression.hpp
23522
+ // duckdb/parser/expression/conjunction_expression.hpp
23477
23523
  //
23478
23524
  //
23479
23525
  //===----------------------------------------------------------------------===//
@@ -23482,21 +23528,25 @@ public:
23482
23528
 
23483
23529
 
23484
23530
 
23531
+
23485
23532
  namespace duckdb {
23486
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
23487
- //! and has two children.
23488
- class ComparisonExpression : public ParsedExpression {
23533
+
23534
+ //! Represents a conjunction (AND/OR)
23535
+ class ConjunctionExpression : public ParsedExpression {
23489
23536
  public:
23490
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23491
- unique_ptr<ParsedExpression> right);
23537
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
23538
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23539
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23540
+ unique_ptr<ParsedExpression> right);
23492
23541
 
23493
- unique_ptr<ParsedExpression> left;
23494
- unique_ptr<ParsedExpression> right;
23542
+ vector<unique_ptr<ParsedExpression>> children;
23495
23543
 
23496
23544
  public:
23545
+ void AddExpression(unique_ptr<ParsedExpression> expr);
23546
+
23497
23547
  string ToString() const override;
23498
23548
 
23499
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
23549
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
23500
23550
 
23501
23551
  unique_ptr<ParsedExpression> Copy() const override;
23502
23552
 
@@ -23506,15 +23556,18 @@ public:
23506
23556
  public:
23507
23557
  template <class T, class BASE>
23508
23558
  static string ToString(const T &entry) {
23509
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
23559
+ string result = "(" + entry.children[0]->ToString();
23560
+ for (idx_t i = 1; i < entry.children.size(); i++) {
23561
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
23562
+ }
23563
+ return result + ")";
23510
23564
  }
23511
23565
  };
23512
23566
  } // namespace duckdb
23513
-
23514
23567
  //===----------------------------------------------------------------------===//
23515
23568
  // DuckDB
23516
23569
  //
23517
- // duckdb/parser/expression/conjunction_expression.hpp
23570
+ // duckdb/parser/expression/case_expression.hpp
23518
23571
  //
23519
23572
  //
23520
23573
  //===----------------------------------------------------------------------===//
@@ -23526,22 +23579,23 @@ public:
23526
23579
 
23527
23580
  namespace duckdb {
23528
23581
 
23529
- //! Represents a conjunction (AND/OR)
23530
- class ConjunctionExpression : public ParsedExpression {
23582
+ struct CaseCheck {
23583
+ unique_ptr<ParsedExpression> when_expr;
23584
+ unique_ptr<ParsedExpression> then_expr;
23585
+ };
23586
+
23587
+ //! The CaseExpression represents a CASE expression in the query
23588
+ class CaseExpression : public ParsedExpression {
23531
23589
  public:
23532
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
23533
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23534
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23535
- unique_ptr<ParsedExpression> right);
23590
+ DUCKDB_API CaseExpression();
23536
23591
 
23537
- vector<unique_ptr<ParsedExpression>> children;
23592
+ vector<CaseCheck> case_checks;
23593
+ unique_ptr<ParsedExpression> else_expr;
23538
23594
 
23539
23595
  public:
23540
- void AddExpression(unique_ptr<ParsedExpression> expr);
23541
-
23542
23596
  string ToString() const override;
23543
23597
 
23544
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
23598
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
23545
23599
 
23546
23600
  unique_ptr<ParsedExpression> Copy() const override;
23547
23601
 
@@ -23551,15 +23605,17 @@ public:
23551
23605
  public:
23552
23606
  template <class T, class BASE>
23553
23607
  static string ToString(const T &entry) {
23554
- string result = "(" + entry.children[0]->ToString();
23555
- for (idx_t i = 1; i < entry.children.size(); i++) {
23556
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
23608
+ string case_str = "CASE ";
23609
+ for (auto &check : entry.case_checks) {
23610
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
23611
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
23557
23612
  }
23558
- return result + ")";
23613
+ case_str += " ELSE " + entry.else_expr->ToString();
23614
+ case_str += " END";
23615
+ return case_str;
23559
23616
  }
23560
23617
  };
23561
23618
  } // namespace duckdb
23562
-
23563
23619
  //===----------------------------------------------------------------------===//
23564
23620
  // DuckDB
23565
23621
  //
@@ -23596,11 +23652,10 @@ public:
23596
23652
  };
23597
23653
 
23598
23654
  } // namespace duckdb
23599
-
23600
23655
  //===----------------------------------------------------------------------===//
23601
23656
  // DuckDB
23602
23657
  //
23603
- // duckdb/parser/expression/default_expression.hpp
23658
+ // duckdb/parser/expression/collate_expression.hpp
23604
23659
  //
23605
23660
  //
23606
23661
  //===----------------------------------------------------------------------===//
@@ -23610,29 +23665,72 @@ public:
23610
23665
 
23611
23666
 
23612
23667
  namespace duckdb {
23613
- //! Represents the default value of a column
23614
- class DefaultExpression : public ParsedExpression {
23615
- public:
23616
- DefaultExpression();
23617
23668
 
23669
+ //! CollateExpression represents a COLLATE statement
23670
+ class CollateExpression : public ParsedExpression {
23618
23671
  public:
23619
- bool IsScalar() const override {
23620
- return false;
23621
- }
23672
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
23673
+
23674
+ //! The child of the cast expression
23675
+ unique_ptr<ParsedExpression> child;
23676
+ //! The collation clause
23677
+ string collation;
23622
23678
 
23679
+ public:
23623
23680
  string ToString() const override;
23624
23681
 
23682
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
23683
+
23625
23684
  unique_ptr<ParsedExpression> Copy() const override;
23626
23685
 
23627
23686
  void Serialize(FieldWriter &writer) const override;
23628
23687
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23629
23688
  };
23630
23689
  } // namespace duckdb
23631
-
23632
23690
  //===----------------------------------------------------------------------===//
23633
23691
  // DuckDB
23634
23692
  //
23635
- // duckdb/parser/expression/function_expression.hpp
23693
+ // duckdb/parser/expression/between_expression.hpp
23694
+ //
23695
+ //
23696
+ //===----------------------------------------------------------------------===//
23697
+
23698
+
23699
+
23700
+
23701
+
23702
+ namespace duckdb {
23703
+
23704
+ class BetweenExpression : public ParsedExpression {
23705
+ public:
23706
+ DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
23707
+ unique_ptr<ParsedExpression> upper);
23708
+
23709
+ unique_ptr<ParsedExpression> input;
23710
+ unique_ptr<ParsedExpression> lower;
23711
+ unique_ptr<ParsedExpression> upper;
23712
+
23713
+ public:
23714
+ string ToString() const override;
23715
+
23716
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
23717
+
23718
+ unique_ptr<ParsedExpression> Copy() const override;
23719
+
23720
+ void Serialize(FieldWriter &writer) const override;
23721
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23722
+
23723
+ public:
23724
+ template <class T, class BASE>
23725
+ static string ToString(const T &entry) {
23726
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
23727
+ }
23728
+ };
23729
+ } // namespace duckdb
23730
+ //===----------------------------------------------------------------------===//
23731
+ // DuckDB
23732
+ //
23733
+ // duckdb/parser/expression/function_expression.hpp
23636
23734
  //
23637
23735
  //
23638
23736
  //===----------------------------------------------------------------------===//
@@ -23746,11 +23844,10 @@ public:
23746
23844
  }
23747
23845
  };
23748
23846
  } // namespace duckdb
23749
-
23750
23847
  //===----------------------------------------------------------------------===//
23751
23848
  // DuckDB
23752
23849
  //
23753
- // duckdb/parser/expression/lambda_expression.hpp
23850
+ // duckdb/parser/expression/comparison_expression.hpp
23754
23851
  //
23755
23852
  //
23756
23853
  //===----------------------------------------------------------------------===//
@@ -23759,38 +23856,47 @@ public:
23759
23856
 
23760
23857
 
23761
23858
 
23762
-
23763
23859
  namespace duckdb {
23764
-
23765
- //! LambdaExpression represents either:
23766
- //! 1. A lambda operator that can be used for e.g. mapping an expression to a list
23767
- //! 2. An OperatorExpression with the "->" operator
23768
- //! Lambda expressions are written in the form of "capture -> expr", e.g. "x -> x + 1"
23769
- class LambdaExpression : public ParsedExpression {
23860
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
23861
+ //! and has two children.
23862
+ class ComparisonExpression : public ParsedExpression {
23770
23863
  public:
23771
- LambdaExpression(unique_ptr<ParsedExpression> lhs, unique_ptr<ParsedExpression> rhs);
23864
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
23865
+ unique_ptr<ParsedExpression> right);
23772
23866
 
23773
- unique_ptr<ParsedExpression> lhs;
23774
- unique_ptr<ParsedExpression> rhs;
23867
+ unique_ptr<ParsedExpression> left;
23868
+ unique_ptr<ParsedExpression> right;
23775
23869
 
23776
23870
  public:
23777
23871
  string ToString() const override;
23778
23872
 
23779
- static bool Equals(const LambdaExpression *a, const LambdaExpression *b);
23780
- hash_t Hash() const override;
23873
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
23781
23874
 
23782
23875
  unique_ptr<ParsedExpression> Copy() const override;
23783
23876
 
23784
23877
  void Serialize(FieldWriter &writer) const override;
23785
23878
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23786
- };
23787
23879
 
23880
+ public:
23881
+ template <class T, class BASE>
23882
+ static string ToString(const T &entry) {
23883
+ return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
23884
+ }
23885
+ };
23788
23886
  } // namespace duckdb
23789
23887
 
23888
+
23889
+
23890
+
23891
+
23892
+
23893
+
23894
+
23895
+
23790
23896
  //===----------------------------------------------------------------------===//
23791
23897
  // DuckDB
23792
23898
  //
23793
- // duckdb/parser/expression/operator_expression.hpp
23899
+ // duckdb/parser/expression/default_expression.hpp
23794
23900
  //
23795
23901
  //
23796
23902
  //===----------------------------------------------------------------------===//
@@ -23799,97 +23905,29 @@ public:
23799
23905
 
23800
23906
 
23801
23907
 
23802
-
23803
-
23804
-
23805
23908
  namespace duckdb {
23806
- //! Represents a built-in operator expression
23807
- class OperatorExpression : public ParsedExpression {
23909
+ //! Represents the default value of a column
23910
+ class DefaultExpression : public ParsedExpression {
23808
23911
  public:
23809
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
23810
- unique_ptr<ParsedExpression> right = nullptr);
23811
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
23812
-
23813
- vector<unique_ptr<ParsedExpression>> children;
23912
+ DefaultExpression();
23814
23913
 
23815
23914
  public:
23816
- string ToString() const override;
23915
+ bool IsScalar() const override {
23916
+ return false;
23917
+ }
23817
23918
 
23818
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
23919
+ string ToString() const override;
23819
23920
 
23820
23921
  unique_ptr<ParsedExpression> Copy() const override;
23821
23922
 
23822
23923
  void Serialize(FieldWriter &writer) const override;
23823
23924
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23824
-
23825
- public:
23826
- template <class T, class BASE>
23827
- static string ToString(const T &entry) {
23828
- auto op = ExpressionTypeToOperator(entry.type);
23829
- if (!op.empty()) {
23830
- // use the operator string to represent the operator
23831
- D_ASSERT(entry.children.size() == 2);
23832
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
23833
- }
23834
- switch (entry.type) {
23835
- case ExpressionType::COMPARE_IN:
23836
- case ExpressionType::COMPARE_NOT_IN: {
23837
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
23838
- string in_child = entry.children[0]->ToString();
23839
- string child_list = "(";
23840
- for (idx_t i = 1; i < entry.children.size(); i++) {
23841
- if (i > 1) {
23842
- child_list += ", ";
23843
- }
23844
- child_list += entry.children[i]->ToString();
23845
- }
23846
- child_list += ")";
23847
- return "(" + in_child + op_type + child_list + ")";
23848
- }
23849
- case ExpressionType::OPERATOR_NOT:
23850
- case ExpressionType::GROUPING_FUNCTION:
23851
- case ExpressionType::OPERATOR_COALESCE: {
23852
- string result = ExpressionTypeToString(entry.type);
23853
- result += "(";
23854
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23855
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23856
- result += ")";
23857
- return result;
23858
- }
23859
- case ExpressionType::OPERATOR_IS_NULL:
23860
- return "(" + entry.children[0]->ToString() + " IS NULL)";
23861
- case ExpressionType::OPERATOR_IS_NOT_NULL:
23862
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
23863
- case ExpressionType::ARRAY_EXTRACT:
23864
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
23865
- case ExpressionType::ARRAY_SLICE:
23866
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
23867
- entry.children[2]->ToString() + "]";
23868
- case ExpressionType::STRUCT_EXTRACT: {
23869
- if (entry.children[1]->type != ExpressionType::VALUE_CONSTANT) {
23870
- return string();
23871
- }
23872
- auto child_string = entry.children[1]->ToString();
23873
- D_ASSERT(child_string.size() >= 3);
23874
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
23875
- return "(" + entry.children[0]->ToString() + ")." +
23876
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
23877
- }
23878
- case ExpressionType::ARRAY_CONSTRUCTOR: {
23879
- string result = "(ARRAY[";
23880
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
23881
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23882
- result += "])";
23883
- return result;
23884
- }
23885
- default:
23886
- throw InternalException("Unrecognized operator type");
23887
- }
23888
- }
23889
23925
  };
23890
-
23891
23926
  } // namespace duckdb
23892
23927
 
23928
+
23929
+
23930
+
23893
23931
  //===----------------------------------------------------------------------===//
23894
23932
  // DuckDB
23895
23933
  //
@@ -23964,44 +24002,6 @@ public:
23964
24002
  };
23965
24003
  } // namespace duckdb
23966
24004
 
23967
- //===----------------------------------------------------------------------===//
23968
- // DuckDB
23969
- //
23970
- // duckdb/parser/expression/star_expression.hpp
23971
- //
23972
- //
23973
- //===----------------------------------------------------------------------===//
23974
-
23975
-
23976
-
23977
-
23978
-
23979
-
23980
- namespace duckdb {
23981
-
23982
- //! Represents a * expression in the SELECT clause
23983
- class StarExpression : public ParsedExpression {
23984
- public:
23985
- StarExpression(string relation_name = string());
23986
-
23987
- //! The relation name in case of tbl.*, or empty if this is a normal *
23988
- string relation_name;
23989
- //! List of columns to exclude from the STAR expression
23990
- case_insensitive_set_t exclude_list;
23991
- //! List of columns to replace with another expression
23992
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23993
-
23994
- public:
23995
- string ToString() const override;
23996
-
23997
- static bool Equals(const StarExpression *a, const StarExpression *b);
23998
-
23999
- unique_ptr<ParsedExpression> Copy() const override;
24000
-
24001
- void Serialize(FieldWriter &writer) const override;
24002
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
24003
- };
24004
- } // namespace duckdb
24005
24005
 
24006
24006
  //===----------------------------------------------------------------------===//
24007
24007
  // DuckDB
@@ -24057,7 +24057,7 @@ public:
24057
24057
  //===----------------------------------------------------------------------===//
24058
24058
  // DuckDB
24059
24059
  //
24060
- // duckdb/parser/parsed_data/vacuum_info.hpp
24060
+ // duckdb/parser/parsed_data/create_collation_info.hpp
24061
24061
  //
24062
24062
  //
24063
24063
  //===----------------------------------------------------------------------===//
@@ -24066,20 +24066,32 @@ public:
24066
24066
 
24067
24067
 
24068
24068
 
24069
+
24069
24070
  namespace duckdb {
24070
24071
 
24071
- enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
24072
+ struct CreateCollationInfo : public CreateInfo {
24073
+ CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
24074
+ : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
24075
+ not_required_for_equality(not_required_for_equality_p) {
24076
+ this->name = move(name_p);
24077
+ }
24072
24078
 
24073
- struct LoadInfo : public ParseInfo {
24074
- std::string filename;
24075
- LoadType load_type;
24079
+ //! The name of the collation
24080
+ string name;
24081
+ //! The collation function to push in case collation is required
24082
+ ScalarFunction function;
24083
+ //! Whether or not the collation can be combined with other collations.
24084
+ bool combinable;
24085
+ //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
24086
+ //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
24087
+ //! speeds up processing.
24088
+ bool not_required_for_equality;
24076
24089
 
24077
24090
  public:
24078
- unique_ptr<LoadInfo> Copy() const {
24079
- auto result = make_unique<LoadInfo>();
24080
- result->filename = filename;
24081
- result->load_type = load_type;
24082
- return result;
24091
+ unique_ptr<CreateInfo> Copy() const override {
24092
+ auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
24093
+ CopyProperties(*result);
24094
+ return move(result);
24083
24095
  }
24084
24096
  };
24085
24097
 
@@ -24087,7 +24099,7 @@ public:
24087
24099
  //===----------------------------------------------------------------------===//
24088
24100
  // DuckDB
24089
24101
  //
24090
- // duckdb/parser/parsed_data/create_type_info.hpp
24102
+ // duckdb/parser/parsed_data/vacuum_info.hpp
24091
24103
  //
24092
24104
  //
24093
24105
  //===----------------------------------------------------------------------===//
@@ -24096,52 +24108,20 @@ public:
24096
24108
 
24097
24109
 
24098
24110
 
24111
+ namespace duckdb {
24099
24112
 
24113
+ struct VacuumInfo : public ParseInfo {
24114
+ // nothing for now
24115
+ };
24100
24116
 
24101
-
24102
- namespace duckdb {
24103
-
24104
- struct CreateTypeInfo : public CreateInfo {
24105
-
24106
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
24107
- }
24108
-
24109
- //! Name of the Type
24110
- string name;
24111
- //! Logical Type
24112
- LogicalType type;
24113
-
24114
- public:
24115
- unique_ptr<CreateInfo> Copy() const override {
24116
- auto result = make_unique<CreateTypeInfo>();
24117
- CopyProperties(*result);
24118
- result->name = name;
24119
- result->type = type;
24120
- return move(result);
24121
- }
24122
- };
24123
-
24124
- } // namespace duckdb
24125
- //===----------------------------------------------------------------------===//
24126
- // DuckDB
24127
- //
24128
- // duckdb/parser/parsed_data/create_index_info.hpp
24129
- //
24130
- //
24131
- //===----------------------------------------------------------------------===//
24132
-
24133
-
24134
-
24135
-
24136
-
24137
-
24138
- //===----------------------------------------------------------------------===//
24139
- // DuckDB
24140
- //
24141
- // duckdb/parser/tableref/basetableref.hpp
24142
- //
24143
- //
24144
- //===----------------------------------------------------------------------===//
24117
+ } // namespace duckdb
24118
+ //===----------------------------------------------------------------------===//
24119
+ // DuckDB
24120
+ //
24121
+ // duckdb/parser/parsed_data/export_table_data.hpp
24122
+ //
24123
+ //
24124
+ //===----------------------------------------------------------------------===//
24145
24125
 
24146
24126
 
24147
24127
 
@@ -24149,71 +24129,32 @@ public:
24149
24129
 
24150
24130
 
24151
24131
  namespace duckdb {
24152
- //! Represents a TableReference to a base table in the schema
24153
- class BaseTableRef : public TableRef {
24154
- public:
24155
- BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
24156
- }
24157
24132
 
24158
- //! Schema name
24159
- string schema_name;
24160
- //! Table name
24133
+ struct ExportedTableData {
24134
+ //! Name of the exported table
24161
24135
  string table_name;
24162
- //! Aliases for the column names
24163
- vector<string> column_name_alias;
24164
-
24165
- public:
24166
- string ToString() const override;
24167
- bool Equals(const TableRef *other_p) const override;
24168
24136
 
24169
- unique_ptr<TableRef> Copy() override;
24137
+ //! Name of the schema
24138
+ string schema_name;
24170
24139
 
24171
- //! Serializes a blob into a BaseTableRef
24172
- void Serialize(FieldWriter &serializer) const override;
24173
- //! Deserializes a blob back into a BaseTableRef
24174
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
24140
+ //! Path to be exported
24141
+ string file_path;
24175
24142
  };
24176
- } // namespace duckdb
24177
-
24178
-
24179
-
24180
- namespace duckdb {
24181
24143
 
24182
- struct CreateIndexInfo : public CreateInfo {
24183
- CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
24184
- }
24185
-
24186
- //! Index Type (e.g., B+-tree, Skip-List, ...)
24187
- IndexType index_type;
24188
- //! Name of the Index
24189
- string index_name;
24190
- //! If it is an unique index
24191
- bool unique = false;
24192
- //! The table to create the index on
24193
- unique_ptr<BaseTableRef> table;
24194
- //! Set of expressions to index by
24195
- vector<unique_ptr<ParsedExpression>> expressions;
24144
+ struct ExportedTableInfo {
24145
+ TableCatalogEntry *entry;
24146
+ ExportedTableData table_data;
24147
+ };
24196
24148
 
24197
- public:
24198
- unique_ptr<CreateInfo> Copy() const override {
24199
- auto result = make_unique<CreateIndexInfo>();
24200
- CopyProperties(*result);
24201
- result->index_type = index_type;
24202
- result->index_name = index_name;
24203
- result->unique = unique;
24204
- result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
24205
- for (auto &expr : expressions) {
24206
- result->expressions.push_back(expr->Copy());
24207
- }
24208
- return move(result);
24209
- }
24149
+ struct BoundExportData : public ParseInfo {
24150
+ std::vector<ExportedTableInfo> data;
24210
24151
  };
24211
24152
 
24212
24153
  } // namespace duckdb
24213
24154
  //===----------------------------------------------------------------------===//
24214
24155
  // DuckDB
24215
24156
  //
24216
- // duckdb/parser/parsed_data/transaction_info.hpp
24157
+ // duckdb/parser/parsed_data/create_type_info.hpp
24217
24158
  //
24218
24159
  //
24219
24160
  //===----------------------------------------------------------------------===//
@@ -24222,54 +24163,27 @@ public:
24222
24163
 
24223
24164
 
24224
24165
 
24225
- namespace duckdb {
24226
-
24227
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
24228
-
24229
- struct TransactionInfo : public ParseInfo {
24230
- explicit TransactionInfo(TransactionType type) : type(type) {
24231
- }
24232
-
24233
- //! The type of transaction statement
24234
- TransactionType type;
24235
- };
24236
-
24237
- } // namespace duckdb
24238
- //===----------------------------------------------------------------------===//
24239
- // DuckDB
24240
- //
24241
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
24242
- //
24243
- //
24244
- //===----------------------------------------------------------------------===//
24245
-
24246
-
24247
-
24248
24166
 
24249
24167
 
24250
24168
 
24251
24169
  namespace duckdb {
24252
24170
 
24253
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
24254
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
24255
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
24256
- functions.push_back(move(function));
24257
- this->name = function.name;
24258
- }
24259
- CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
24260
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
24261
- this->name = name;
24262
- for (auto &function : functions) {
24263
- function.name = name;
24264
- }
24171
+ struct CreateTypeInfo : public CreateInfo {
24172
+
24173
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
24265
24174
  }
24266
24175
 
24267
- vector<PragmaFunction> functions;
24176
+ //! Name of the Type
24177
+ string name;
24178
+ //! Logical Type
24179
+ LogicalType type;
24268
24180
 
24269
24181
  public:
24270
24182
  unique_ptr<CreateInfo> Copy() const override {
24271
- auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
24183
+ auto result = make_unique<CreateTypeInfo>();
24272
24184
  CopyProperties(*result);
24185
+ result->name = name;
24186
+ result->type = type;
24273
24187
  return move(result);
24274
24188
  }
24275
24189
  };
@@ -24289,50 +24203,17 @@ public:
24289
24203
 
24290
24204
  namespace duckdb {
24291
24205
 
24292
- struct VacuumInfo : public ParseInfo {
24293
- // nothing for now
24294
- };
24295
-
24296
- } // namespace duckdb
24297
- //===----------------------------------------------------------------------===//
24298
- // DuckDB
24299
- //
24300
- // duckdb/parser/parsed_data/drop_info.hpp
24301
- //
24302
- //
24303
- //===----------------------------------------------------------------------===//
24304
-
24305
-
24306
-
24307
-
24308
-
24309
-
24310
- namespace duckdb {
24311
-
24312
- struct DropInfo : public ParseInfo {
24313
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
24314
- }
24206
+ enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
24315
24207
 
24316
- //! The catalog type to drop
24317
- CatalogType type;
24318
- //! Schema name to drop from, if any
24319
- string schema;
24320
- //! Element name to drop
24321
- string name;
24322
- //! Ignore if the entry does not exist instead of failing
24323
- bool if_exists = false;
24324
- //! Cascade drop (drop all dependents instead of throwing an error if there
24325
- //! are any)
24326
- bool cascade = false;
24208
+ struct LoadInfo : public ParseInfo {
24209
+ std::string filename;
24210
+ LoadType load_type;
24327
24211
 
24328
24212
  public:
24329
- unique_ptr<DropInfo> Copy() const {
24330
- auto result = make_unique<DropInfo>();
24331
- result->type = type;
24332
- result->schema = schema;
24333
- result->name = name;
24334
- result->if_exists = if_exists;
24335
- result->cascade = cascade;
24213
+ unique_ptr<LoadInfo> Copy() const {
24214
+ auto result = make_unique<LoadInfo>();
24215
+ result->filename = filename;
24216
+ result->load_type = load_type;
24336
24217
  return result;
24337
24218
  }
24338
24219
  };
@@ -24418,7 +24299,7 @@ struct ShowSelectInfo : public ParseInfo {
24418
24299
  //===----------------------------------------------------------------------===//
24419
24300
  // DuckDB
24420
24301
  //
24421
- // duckdb/parser/parsed_data/export_table_data.hpp
24302
+ // duckdb/parser/parsed_data/create_view_info.hpp
24422
24303
  //
24423
24304
  //
24424
24305
  //===----------------------------------------------------------------------===//
@@ -24430,24 +24311,31 @@ struct ShowSelectInfo : public ParseInfo {
24430
24311
 
24431
24312
  namespace duckdb {
24432
24313
 
24433
- struct ExportedTableData {
24434
- //! Name of the exported table
24435
- string table_name;
24436
-
24437
- //! Name of the schema
24438
- string schema_name;
24439
-
24440
- //! Path to be exported
24441
- string file_path;
24442
- };
24314
+ struct CreateViewInfo : public CreateInfo {
24315
+ CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
24316
+ }
24317
+ CreateViewInfo(string schema, string view_name)
24318
+ : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
24319
+ }
24443
24320
 
24444
- struct ExportedTableInfo {
24445
- TableCatalogEntry *entry;
24446
- ExportedTableData table_data;
24447
- };
24321
+ //! Table name to insert to
24322
+ string view_name;
24323
+ //! Aliases of the view
24324
+ vector<string> aliases;
24325
+ //! Return types
24326
+ vector<LogicalType> types;
24327
+ //! The SelectStatement of the view
24328
+ unique_ptr<SelectStatement> query;
24448
24329
 
24449
- struct BoundExportData : public ParseInfo {
24450
- std::vector<ExportedTableInfo> data;
24330
+ public:
24331
+ unique_ptr<CreateInfo> Copy() const override {
24332
+ auto result = make_unique<CreateViewInfo>(schema, view_name);
24333
+ CopyProperties(*result);
24334
+ result->aliases = aliases;
24335
+ result->types = types;
24336
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
24337
+ return move(result);
24338
+ }
24451
24339
  };
24452
24340
 
24453
24341
  } // namespace duckdb
@@ -24513,23 +24401,111 @@ public:
24513
24401
  } // namespace duckdb
24514
24402
 
24515
24403
 
24516
- namespace duckdb {
24404
+ namespace duckdb {
24405
+
24406
+ struct CreateMacroInfo : public CreateFunctionInfo {
24407
+ CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
24408
+ }
24409
+
24410
+ CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
24411
+ }
24412
+
24413
+ unique_ptr<MacroFunction> function;
24414
+
24415
+ public:
24416
+ unique_ptr<CreateInfo> Copy() const override {
24417
+ auto result = make_unique<CreateMacroInfo>();
24418
+ result->function = function->Copy();
24419
+ result->name = name;
24420
+ CopyProperties(*result);
24421
+ return move(result);
24422
+ }
24423
+ };
24424
+
24425
+ } // namespace duckdb
24426
+ //===----------------------------------------------------------------------===//
24427
+ // DuckDB
24428
+ //
24429
+ // duckdb/parser/parsed_data/create_index_info.hpp
24430
+ //
24431
+ //
24432
+ //===----------------------------------------------------------------------===//
24433
+
24434
+
24435
+
24436
+
24437
+
24438
+
24439
+ //===----------------------------------------------------------------------===//
24440
+ // DuckDB
24441
+ //
24442
+ // duckdb/parser/tableref/basetableref.hpp
24443
+ //
24444
+ //
24445
+ //===----------------------------------------------------------------------===//
24446
+
24447
+
24448
+
24449
+
24450
+
24451
+
24452
+ namespace duckdb {
24453
+ //! Represents a TableReference to a base table in the schema
24454
+ class BaseTableRef : public TableRef {
24455
+ public:
24456
+ BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
24457
+ }
24458
+
24459
+ //! Schema name
24460
+ string schema_name;
24461
+ //! Table name
24462
+ string table_name;
24463
+ //! Aliases for the column names
24464
+ vector<string> column_name_alias;
24465
+
24466
+ public:
24467
+ string ToString() const override;
24468
+ bool Equals(const TableRef *other_p) const override;
24469
+
24470
+ unique_ptr<TableRef> Copy() override;
24471
+
24472
+ //! Serializes a blob into a BaseTableRef
24473
+ void Serialize(FieldWriter &serializer) const override;
24474
+ //! Deserializes a blob back into a BaseTableRef
24475
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
24476
+ };
24477
+ } // namespace duckdb
24478
+
24479
+
24517
24480
 
24518
- struct CreateMacroInfo : public CreateFunctionInfo {
24519
- CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
24520
- }
24481
+ namespace duckdb {
24521
24482
 
24522
- CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
24483
+ struct CreateIndexInfo : public CreateInfo {
24484
+ CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
24523
24485
  }
24524
24486
 
24525
- unique_ptr<MacroFunction> function;
24487
+ //! Index Type (e.g., B+-tree, Skip-List, ...)
24488
+ IndexType index_type;
24489
+ //! Name of the Index
24490
+ string index_name;
24491
+ //! If it is an unique index
24492
+ bool unique = false;
24493
+ //! The table to create the index on
24494
+ unique_ptr<BaseTableRef> table;
24495
+ //! Set of expressions to index by
24496
+ vector<unique_ptr<ParsedExpression>> expressions;
24526
24497
 
24527
24498
  public:
24528
24499
  unique_ptr<CreateInfo> Copy() const override {
24529
- auto result = make_unique<CreateMacroInfo>();
24530
- result->function = function->Copy();
24531
- result->name = name;
24500
+ auto result = make_unique<CreateIndexInfo>();
24532
24501
  CopyProperties(*result);
24502
+ result->index_type = index_type;
24503
+ result->index_name = index_name;
24504
+ result->unique = unique;
24505
+ result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
24506
+ for (auto &expr : expressions) {
24507
+ result->expressions.push_back(expr->Copy());
24508
+ }
24533
24509
  return move(result);
24534
24510
  }
24535
24511
  };
@@ -24538,7 +24514,7 @@ public:
24538
24514
  //===----------------------------------------------------------------------===//
24539
24515
  // DuckDB
24540
24516
  //
24541
- // duckdb/parser/parsed_data/create_view_info.hpp
24517
+ // duckdb/parser/parsed_data/create_schema_info.hpp
24542
24518
  //
24543
24519
  //
24544
24520
  //===----------------------------------------------------------------------===//
@@ -24547,32 +24523,16 @@ public:
24547
24523
 
24548
24524
 
24549
24525
 
24550
-
24551
24526
  namespace duckdb {
24552
24527
 
24553
- struct CreateViewInfo : public CreateInfo {
24554
- CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
24555
- }
24556
- CreateViewInfo(string schema, string view_name)
24557
- : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
24528
+ struct CreateSchemaInfo : public CreateInfo {
24529
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
24558
24530
  }
24559
24531
 
24560
- //! Table name to insert to
24561
- string view_name;
24562
- //! Aliases of the view
24563
- vector<string> aliases;
24564
- //! Return types
24565
- vector<LogicalType> types;
24566
- //! The SelectStatement of the view
24567
- unique_ptr<SelectStatement> query;
24568
-
24569
24532
  public:
24570
24533
  unique_ptr<CreateInfo> Copy() const override {
24571
- auto result = make_unique<CreateViewInfo>(schema, view_name);
24534
+ auto result = make_unique<CreateSchemaInfo>();
24572
24535
  CopyProperties(*result);
24573
- result->aliases = aliases;
24574
- result->types = types;
24575
- result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
24576
24536
  return move(result);
24577
24537
  }
24578
24538
  };
@@ -24581,7 +24541,7 @@ public:
24581
24541
  //===----------------------------------------------------------------------===//
24582
24542
  // DuckDB
24583
24543
  //
24584
- // duckdb/parser/parsed_data/create_collation_info.hpp
24544
+ // duckdb/parser/parsed_data/transaction_info.hpp
24585
24545
  //
24586
24546
  //
24587
24547
  //===----------------------------------------------------------------------===//
@@ -24590,40 +24550,23 @@ public:
24590
24550
 
24591
24551
 
24592
24552
 
24593
-
24594
24553
  namespace duckdb {
24595
24554
 
24596
- struct CreateCollationInfo : public CreateInfo {
24597
- CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
24598
- : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
24599
- not_required_for_equality(not_required_for_equality_p) {
24600
- this->name = move(name_p);
24601
- }
24602
-
24603
- //! The name of the collation
24604
- string name;
24605
- //! The collation function to push in case collation is required
24606
- ScalarFunction function;
24607
- //! Whether or not the collation can be combined with other collations.
24608
- bool combinable;
24609
- //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
24610
- //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
24611
- //! speeds up processing.
24612
- bool not_required_for_equality;
24555
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
24613
24556
 
24614
- public:
24615
- unique_ptr<CreateInfo> Copy() const override {
24616
- auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
24617
- CopyProperties(*result);
24618
- return move(result);
24557
+ struct TransactionInfo : public ParseInfo {
24558
+ explicit TransactionInfo(TransactionType type) : type(type) {
24619
24559
  }
24560
+
24561
+ //! The type of transaction statement
24562
+ TransactionType type;
24620
24563
  };
24621
24564
 
24622
24565
  } // namespace duckdb
24623
24566
  //===----------------------------------------------------------------------===//
24624
24567
  // DuckDB
24625
24568
  //
24626
- // duckdb/parser/parsed_data/create_schema_info.hpp
24569
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
24627
24570
  //
24628
24571
  //
24629
24572
  //===----------------------------------------------------------------------===//
@@ -24632,26 +24575,38 @@ public:
24632
24575
 
24633
24576
 
24634
24577
 
24578
+
24635
24579
  namespace duckdb {
24636
24580
 
24637
- struct CreateSchemaInfo : public CreateInfo {
24638
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
24581
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
24582
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
24583
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
24584
+ functions.push_back(move(function));
24585
+ this->name = function.name;
24586
+ }
24587
+ CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
24588
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
24589
+ this->name = name;
24590
+ for (auto &function : functions) {
24591
+ function.name = name;
24592
+ }
24639
24593
  }
24640
24594
 
24595
+ vector<PragmaFunction> functions;
24596
+
24641
24597
  public:
24642
24598
  unique_ptr<CreateInfo> Copy() const override {
24643
- auto result = make_unique<CreateSchemaInfo>();
24599
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
24644
24600
  CopyProperties(*result);
24645
24601
  return move(result);
24646
24602
  }
24647
24603
  };
24648
24604
 
24649
24605
  } // namespace duckdb
24650
-
24651
24606
  //===----------------------------------------------------------------------===//
24652
24607
  // DuckDB
24653
24608
  //
24654
- // duckdb/parser/tableref/crossproductref.hpp
24609
+ // duckdb/parser/parsed_data/drop_info.hpp
24655
24610
  //
24656
24611
  //
24657
24612
  //===----------------------------------------------------------------------===//
@@ -24660,63 +24615,38 @@ public:
24660
24615
 
24661
24616
 
24662
24617
 
24663
- namespace duckdb {
24664
- //! Represents a cross product
24665
- class CrossProductRef : public TableRef {
24666
- public:
24667
- CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
24668
- }
24669
-
24670
- //! The left hand side of the cross product
24671
- unique_ptr<TableRef> left;
24672
- //! The right hand side of the cross product
24673
- unique_ptr<TableRef> right;
24674
-
24675
- public:
24676
- string ToString() const override;
24677
- bool Equals(const TableRef *other_p) const override;
24678
-
24679
- unique_ptr<TableRef> Copy() override;
24680
-
24681
- //! Serializes a blob into a CrossProductRef
24682
- void Serialize(FieldWriter &serializer) const override;
24683
- //! Deserializes a blob back into a CrossProductRef
24684
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
24685
- };
24686
- } // namespace duckdb
24687
-
24688
- //===----------------------------------------------------------------------===//
24689
- // DuckDB
24690
- //
24691
- // duckdb/parser/tableref/emptytableref.hpp
24692
- //
24693
- //
24694
- //===----------------------------------------------------------------------===//
24695
-
24696
24618
 
24619
+ namespace duckdb {
24697
24620
 
24621
+ struct DropInfo : public ParseInfo {
24622
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
24623
+ }
24698
24624
 
24625
+ //! The catalog type to drop
24626
+ CatalogType type;
24627
+ //! Schema name to drop from, if any
24628
+ string schema;
24629
+ //! Element name to drop
24630
+ string name;
24631
+ //! Ignore if the entry does not exist instead of failing
24632
+ bool if_exists = false;
24633
+ //! Cascade drop (drop all dependents instead of throwing an error if there
24634
+ //! are any)
24635
+ bool cascade = false;
24699
24636
 
24700
- namespace duckdb {
24701
- //! Represents a cross product
24702
- class EmptyTableRef : public TableRef {
24703
24637
  public:
24704
- EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
24638
+ unique_ptr<DropInfo> Copy() const {
24639
+ auto result = make_unique<DropInfo>();
24640
+ result->type = type;
24641
+ result->schema = schema;
24642
+ result->name = name;
24643
+ result->if_exists = if_exists;
24644
+ result->cascade = cascade;
24645
+ return result;
24705
24646
  }
24706
-
24707
- public:
24708
- string ToString() const override;
24709
- bool Equals(const TableRef *other_p) const override;
24710
-
24711
- unique_ptr<TableRef> Copy() override;
24712
-
24713
- //! Serializes a blob into a DummyTableRef
24714
- void Serialize(FieldWriter &serializer) const override;
24715
- //! Deserializes a blob back into a DummyTableRef
24716
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
24717
24647
  };
24718
- } // namespace duckdb
24719
24648
 
24649
+ } // namespace duckdb
24720
24650
  //===----------------------------------------------------------------------===//
24721
24651
  // DuckDB
24722
24652
  //
@@ -24758,7 +24688,6 @@ public:
24758
24688
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24759
24689
  };
24760
24690
  } // namespace duckdb
24761
-
24762
24691
  //===----------------------------------------------------------------------===//
24763
24692
  // DuckDB
24764
24693
  //
@@ -24807,7 +24736,6 @@ public:
24807
24736
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24808
24737
  };
24809
24738
  } // namespace duckdb
24810
-
24811
24739
  //===----------------------------------------------------------------------===//
24812
24740
  // DuckDB
24813
24741
  //
@@ -24844,7 +24772,37 @@ public:
24844
24772
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24845
24773
  };
24846
24774
  } // namespace duckdb
24775
+ //===----------------------------------------------------------------------===//
24776
+ // DuckDB
24777
+ //
24778
+ // duckdb/parser/tableref/emptytableref.hpp
24779
+ //
24780
+ //
24781
+ //===----------------------------------------------------------------------===//
24782
+
24847
24783
 
24784
+
24785
+
24786
+
24787
+ namespace duckdb {
24788
+ //! Represents a cross product
24789
+ class EmptyTableRef : public TableRef {
24790
+ public:
24791
+ EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
24792
+ }
24793
+
24794
+ public:
24795
+ string ToString() const override;
24796
+ bool Equals(const TableRef *other_p) const override;
24797
+
24798
+ unique_ptr<TableRef> Copy() override;
24799
+
24800
+ //! Serializes a blob into a DummyTableRef
24801
+ void Serialize(FieldWriter &serializer) const override;
24802
+ //! Deserializes a blob back into a DummyTableRef
24803
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
24804
+ };
24805
+ } // namespace duckdb
24848
24806
  //===----------------------------------------------------------------------===//
24849
24807
  // DuckDB
24850
24808
  //
@@ -24889,4 +24847,46 @@ public:
24889
24847
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
24890
24848
  };
24891
24849
  } // namespace duckdb
24850
+ //===----------------------------------------------------------------------===//
24851
+ // DuckDB
24852
+ //
24853
+ // duckdb/parser/tableref/crossproductref.hpp
24854
+ //
24855
+ //
24856
+ //===----------------------------------------------------------------------===//
24857
+
24858
+
24859
+
24860
+
24861
+
24862
+ namespace duckdb {
24863
+ //! Represents a cross product
24864
+ class CrossProductRef : public TableRef {
24865
+ public:
24866
+ CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
24867
+ }
24868
+
24869
+ //! The left hand side of the cross product
24870
+ unique_ptr<TableRef> left;
24871
+ //! The right hand side of the cross product
24872
+ unique_ptr<TableRef> right;
24873
+
24874
+ public:
24875
+ string ToString() const override;
24876
+ bool Equals(const TableRef *other_p) const override;
24877
+
24878
+ unique_ptr<TableRef> Copy() override;
24879
+
24880
+ //! Serializes a blob into a CrossProductRef
24881
+ void Serialize(FieldWriter &serializer) const override;
24882
+ //! Deserializes a blob back into a CrossProductRef
24883
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
24884
+ };
24885
+ } // namespace duckdb
24886
+
24887
+
24888
+
24889
+
24890
+
24891
+
24892
24892