duckdb 0.5.2-dev802.0 → 0.5.2-dev807.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 "91ed0afb2"
15
- #define DUCKDB_VERSION "v0.5.2-dev802"
14
+ #define DUCKDB_SOURCE_ID "5c017931f"
15
+ #define DUCKDB_VERSION "v0.5.2-dev807"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -29316,124 +29316,7 @@ private:
29316
29316
  //===----------------------------------------------------------------------===//
29317
29317
  // DuckDB
29318
29318
  //
29319
- // duckdb/parser/expression/collate_expression.hpp
29320
- //
29321
- //
29322
- //===----------------------------------------------------------------------===//
29323
-
29324
-
29325
-
29326
-
29327
-
29328
- namespace duckdb {
29329
-
29330
- //! CollateExpression represents a COLLATE statement
29331
- class CollateExpression : public ParsedExpression {
29332
- public:
29333
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
29334
-
29335
- //! The child of the cast expression
29336
- unique_ptr<ParsedExpression> child;
29337
- //! The collation clause
29338
- string collation;
29339
-
29340
- public:
29341
- string ToString() const override;
29342
-
29343
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
29344
-
29345
- unique_ptr<ParsedExpression> Copy() const override;
29346
-
29347
- void Serialize(FieldWriter &writer) const override;
29348
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29349
- };
29350
- } // namespace duckdb
29351
- //===----------------------------------------------------------------------===//
29352
- // DuckDB
29353
- //
29354
- // duckdb/parser/expression/between_expression.hpp
29355
- //
29356
- //
29357
- //===----------------------------------------------------------------------===//
29358
-
29359
-
29360
-
29361
-
29362
-
29363
- namespace duckdb {
29364
-
29365
- class BetweenExpression : public ParsedExpression {
29366
- public:
29367
- DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
29368
- unique_ptr<ParsedExpression> upper);
29369
-
29370
- unique_ptr<ParsedExpression> input;
29371
- unique_ptr<ParsedExpression> lower;
29372
- unique_ptr<ParsedExpression> upper;
29373
-
29374
- public:
29375
- string ToString() const override;
29376
-
29377
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
29378
-
29379
- unique_ptr<ParsedExpression> Copy() const override;
29380
-
29381
- void Serialize(FieldWriter &writer) const override;
29382
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29383
-
29384
- public:
29385
- template <class T, class BASE>
29386
- static string ToString(const T &entry) {
29387
- return "(" + entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " +
29388
- entry.upper->ToString() + ")";
29389
- }
29390
- };
29391
- } // namespace duckdb
29392
- //===----------------------------------------------------------------------===//
29393
- // DuckDB
29394
- //
29395
- // duckdb/parser/expression/comparison_expression.hpp
29396
- //
29397
- //
29398
- //===----------------------------------------------------------------------===//
29399
-
29400
-
29401
-
29402
-
29403
-
29404
- namespace duckdb {
29405
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
29406
- //! and has two children.
29407
- class ComparisonExpression : public ParsedExpression {
29408
- public:
29409
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29410
- unique_ptr<ParsedExpression> right);
29411
-
29412
- unique_ptr<ParsedExpression> left;
29413
- unique_ptr<ParsedExpression> right;
29414
-
29415
- public:
29416
- string ToString() const override;
29417
-
29418
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
29419
-
29420
- unique_ptr<ParsedExpression> Copy() const override;
29421
-
29422
- void Serialize(FieldWriter &writer) const override;
29423
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29424
-
29425
- public:
29426
- template <class T, class BASE>
29427
- static string ToString(const T &entry) {
29428
- return StringUtil::Format("(%s %s %s)", entry.left->ToString(), ExpressionTypeToOperator(entry.type),
29429
- entry.right->ToString());
29430
- }
29431
- };
29432
- } // namespace duckdb
29433
- //===----------------------------------------------------------------------===//
29434
- // DuckDB
29435
- //
29436
- // duckdb/parser/expression/subquery_expression.hpp
29319
+ // duckdb/parser/expression/default_expression.hpp
29437
29320
  //
29438
29321
  //
29439
29322
  //===----------------------------------------------------------------------===//
@@ -29442,95 +29325,29 @@ public:
29442
29325
 
29443
29326
 
29444
29327
 
29445
-
29446
-
29447
29328
  namespace duckdb {
29448
-
29449
- //! Represents a subquery
29450
- class SubqueryExpression : public ParsedExpression {
29329
+ //! Represents the default value of a column
29330
+ class DefaultExpression : public ParsedExpression {
29451
29331
  public:
29452
- SubqueryExpression();
29453
-
29454
- //! The actual subquery
29455
- unique_ptr<SelectStatement> subquery;
29456
- //! The subquery type
29457
- SubqueryType subquery_type;
29458
- //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
29459
- //! subquery)
29460
- unique_ptr<ParsedExpression> child;
29461
- //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
29462
- ExpressionType comparison_type;
29332
+ DefaultExpression();
29463
29333
 
29464
29334
  public:
29465
- bool HasSubquery() const override {
29466
- return true;
29467
- }
29468
29335
  bool IsScalar() const override {
29469
29336
  return false;
29470
29337
  }
29471
29338
 
29472
29339
  string ToString() const override;
29473
29340
 
29474
- static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
29475
-
29476
- unique_ptr<ParsedExpression> Copy() const override;
29477
-
29478
- void Serialize(FieldWriter &writer) const override;
29479
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29480
- };
29481
- } // namespace duckdb
29482
- //===----------------------------------------------------------------------===//
29483
- // DuckDB
29484
- //
29485
- // duckdb/parser/expression/conjunction_expression.hpp
29486
- //
29487
- //
29488
- //===----------------------------------------------------------------------===//
29489
-
29490
-
29491
-
29492
-
29493
-
29494
-
29495
- namespace duckdb {
29496
-
29497
- //! Represents a conjunction (AND/OR)
29498
- class ConjunctionExpression : public ParsedExpression {
29499
- public:
29500
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
29501
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
29502
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29503
- unique_ptr<ParsedExpression> right);
29504
-
29505
- vector<unique_ptr<ParsedExpression>> children;
29506
-
29507
- public:
29508
- void AddExpression(unique_ptr<ParsedExpression> expr);
29509
-
29510
- string ToString() const override;
29511
-
29512
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
29513
-
29514
29341
  unique_ptr<ParsedExpression> Copy() const override;
29515
29342
 
29516
29343
  void Serialize(FieldWriter &writer) const override;
29517
29344
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29518
-
29519
- public:
29520
- template <class T, class BASE>
29521
- static string ToString(const T &entry) {
29522
- string result = "(" + entry.children[0]->ToString();
29523
- for (idx_t i = 1; i < entry.children.size(); i++) {
29524
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
29525
- }
29526
- return result + ")";
29527
- }
29528
29345
  };
29529
29346
  } // namespace duckdb
29530
29347
  //===----------------------------------------------------------------------===//
29531
29348
  // DuckDB
29532
29349
  //
29533
- // duckdb/parser/expression/positional_reference_expression.hpp
29350
+ // duckdb/parser/expression/parameter_expression.hpp
29534
29351
  //
29535
29352
  //
29536
29353
  //===----------------------------------------------------------------------===//
@@ -29540,70 +29357,29 @@ public:
29540
29357
 
29541
29358
 
29542
29359
  namespace duckdb {
29543
- class PositionalReferenceExpression : public ParsedExpression {
29360
+ class ParameterExpression : public ParsedExpression {
29544
29361
  public:
29545
- DUCKDB_API PositionalReferenceExpression(idx_t index);
29362
+ ParameterExpression();
29546
29363
 
29547
- idx_t index;
29364
+ idx_t parameter_nr;
29548
29365
 
29549
29366
  public:
29550
29367
  bool IsScalar() const override {
29551
- return false;
29368
+ return true;
29369
+ }
29370
+ bool HasParameter() const override {
29371
+ return true;
29552
29372
  }
29553
29373
 
29554
29374
  string ToString() const override;
29555
29375
 
29556
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
29557
- unique_ptr<ParsedExpression> Copy() const override;
29558
- hash_t Hash() const override;
29559
-
29560
- void Serialize(FieldWriter &writer) const override;
29561
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29562
- };
29563
- } // namespace duckdb
29564
- //===----------------------------------------------------------------------===//
29565
- // DuckDB
29566
- //
29567
- // duckdb/parser/expression/cast_expression.hpp
29568
- //
29569
- //
29570
- //===----------------------------------------------------------------------===//
29571
-
29572
-
29573
-
29574
-
29575
-
29576
-
29577
- namespace duckdb {
29578
-
29579
- //! CastExpression represents a type cast from one SQL type to another SQL type
29580
- class CastExpression : public ParsedExpression {
29581
- public:
29582
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
29583
-
29584
- //! The child of the cast expression
29585
- unique_ptr<ParsedExpression> child;
29586
- //! The type to cast to
29587
- LogicalType cast_type;
29588
- //! Whether or not this is a try_cast expression
29589
- bool try_cast;
29590
-
29591
- public:
29592
- string ToString() const override;
29593
-
29594
- static bool Equals(const CastExpression *a, const CastExpression *b);
29376
+ static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
29595
29377
 
29596
29378
  unique_ptr<ParsedExpression> Copy() const override;
29379
+ hash_t Hash() const override;
29597
29380
 
29598
29381
  void Serialize(FieldWriter &writer) const override;
29599
29382
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29600
-
29601
- public:
29602
- template <class T, class BASE>
29603
- static string ToString(const T &entry) {
29604
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
29605
- entry.cast_type.ToString() + ")";
29606
- }
29607
29383
  };
29608
29384
  } // namespace duckdb
29609
29385
  //===----------------------------------------------------------------------===//
@@ -29726,7 +29502,7 @@ public:
29726
29502
  //===----------------------------------------------------------------------===//
29727
29503
  // DuckDB
29728
29504
  //
29729
- // duckdb/parser/expression/star_expression.hpp
29505
+ // duckdb/parser/expression/comparison_expression.hpp
29730
29506
  //
29731
29507
  //
29732
29508
  //===----------------------------------------------------------------------===//
@@ -29735,102 +29511,21 @@ public:
29735
29511
 
29736
29512
 
29737
29513
 
29738
-
29739
29514
  namespace duckdb {
29740
-
29741
- //! Represents a * expression in the SELECT clause
29742
- class StarExpression : public ParsedExpression {
29743
- public:
29744
- StarExpression(string relation_name = string());
29745
-
29746
- //! The relation name in case of tbl.*, or empty if this is a normal *
29747
- string relation_name;
29748
- //! List of columns to exclude from the STAR expression
29749
- case_insensitive_set_t exclude_list;
29750
- //! List of columns to replace with another expression
29751
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
29752
-
29753
- public:
29754
- string ToString() const override;
29755
-
29756
- static bool Equals(const StarExpression *a, const StarExpression *b);
29757
-
29758
- unique_ptr<ParsedExpression> Copy() const override;
29759
-
29760
- void Serialize(FieldWriter &writer) const override;
29761
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29762
- };
29763
- } // namespace duckdb
29764
- //===----------------------------------------------------------------------===//
29765
- // DuckDB
29766
- //
29767
- // duckdb/parser/expression/parameter_expression.hpp
29768
- //
29769
- //
29770
- //===----------------------------------------------------------------------===//
29771
-
29772
-
29773
-
29774
-
29775
-
29776
- namespace duckdb {
29777
- class ParameterExpression : public ParsedExpression {
29778
- public:
29779
- ParameterExpression();
29780
-
29781
- idx_t parameter_nr;
29782
-
29783
- public:
29784
- bool IsScalar() const override {
29785
- return true;
29786
- }
29787
- bool HasParameter() const override {
29788
- return true;
29789
- }
29790
-
29791
- string ToString() const override;
29792
-
29793
- static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
29794
-
29795
- unique_ptr<ParsedExpression> Copy() const override;
29796
- hash_t Hash() const override;
29797
-
29798
- void Serialize(FieldWriter &writer) const override;
29799
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29800
- };
29801
- } // namespace duckdb
29802
- //===----------------------------------------------------------------------===//
29803
- // DuckDB
29804
- //
29805
- // duckdb/parser/expression/case_expression.hpp
29806
- //
29807
- //
29808
- //===----------------------------------------------------------------------===//
29809
-
29810
-
29811
-
29812
-
29813
-
29814
-
29815
- namespace duckdb {
29816
-
29817
- struct CaseCheck {
29818
- unique_ptr<ParsedExpression> when_expr;
29819
- unique_ptr<ParsedExpression> then_expr;
29820
- };
29821
-
29822
- //! The CaseExpression represents a CASE expression in the query
29823
- class CaseExpression : public ParsedExpression {
29515
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
29516
+ //! and has two children.
29517
+ class ComparisonExpression : public ParsedExpression {
29824
29518
  public:
29825
- DUCKDB_API CaseExpression();
29519
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29520
+ unique_ptr<ParsedExpression> right);
29826
29521
 
29827
- vector<CaseCheck> case_checks;
29828
- unique_ptr<ParsedExpression> else_expr;
29522
+ unique_ptr<ParsedExpression> left;
29523
+ unique_ptr<ParsedExpression> right;
29829
29524
 
29830
29525
  public:
29831
29526
  string ToString() const override;
29832
29527
 
29833
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
29528
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
29834
29529
 
29835
29530
  unique_ptr<ParsedExpression> Copy() const override;
29836
29531
 
@@ -29840,21 +29535,15 @@ public:
29840
29535
  public:
29841
29536
  template <class T, class BASE>
29842
29537
  static string ToString(const T &entry) {
29843
- string case_str = "CASE ";
29844
- for (auto &check : entry.case_checks) {
29845
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
29846
- case_str += " THEN (" + check.then_expr->ToString() + ")";
29847
- }
29848
- case_str += " ELSE " + entry.else_expr->ToString();
29849
- case_str += " END";
29850
- return case_str;
29538
+ return StringUtil::Format("(%s %s %s)", entry.left->ToString(), ExpressionTypeToOperator(entry.type),
29539
+ entry.right->ToString());
29851
29540
  }
29852
29541
  };
29853
29542
  } // namespace duckdb
29854
29543
  //===----------------------------------------------------------------------===//
29855
29544
  // DuckDB
29856
29545
  //
29857
- // duckdb/parser/expression/constant_expression.hpp
29546
+ // duckdb/parser/expression/star_expression.hpp
29858
29547
  //
29859
29548
  //
29860
29549
  //===----------------------------------------------------------------------===//
@@ -29866,51 +29555,22 @@ public:
29866
29555
 
29867
29556
  namespace duckdb {
29868
29557
 
29869
- //! ConstantExpression represents a constant value in the query
29870
- class ConstantExpression : public ParsedExpression {
29558
+ //! Represents a * expression in the SELECT clause
29559
+ class StarExpression : public ParsedExpression {
29871
29560
  public:
29872
- DUCKDB_API explicit ConstantExpression(Value val);
29561
+ StarExpression(string relation_name = string());
29873
29562
 
29874
- //! The constant value referenced
29875
- Value value;
29563
+ //! The relation name in case of tbl.*, or empty if this is a normal *
29564
+ string relation_name;
29565
+ //! List of columns to exclude from the STAR expression
29566
+ case_insensitive_set_t exclude_list;
29567
+ //! List of columns to replace with another expression
29568
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
29876
29569
 
29877
29570
  public:
29878
29571
  string ToString() const override;
29879
29572
 
29880
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
29881
- hash_t Hash() const override;
29882
-
29883
- unique_ptr<ParsedExpression> Copy() const override;
29884
-
29885
- void Serialize(FieldWriter &writer) const override;
29886
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29887
- };
29888
-
29889
- } // namespace duckdb
29890
- //===----------------------------------------------------------------------===//
29891
- // DuckDB
29892
- //
29893
- // duckdb/parser/expression/default_expression.hpp
29894
- //
29895
- //
29896
- //===----------------------------------------------------------------------===//
29897
-
29898
-
29899
-
29900
-
29901
-
29902
- namespace duckdb {
29903
- //! Represents the default value of a column
29904
- class DefaultExpression : public ParsedExpression {
29905
- public:
29906
- DefaultExpression();
29907
-
29908
- public:
29909
- bool IsScalar() const override {
29910
- return false;
29911
- }
29912
-
29913
- string ToString() const override;
29573
+ static bool Equals(const StarExpression *a, const StarExpression *b);
29914
29574
 
29915
29575
  unique_ptr<ParsedExpression> Copy() const override;
29916
29576
 
@@ -30028,39 +29688,92 @@ public:
30028
29688
  };
30029
29689
 
30030
29690
  } // namespace duckdb
29691
+ //===----------------------------------------------------------------------===//
29692
+ // DuckDB
29693
+ //
29694
+ // duckdb/parser/expression/positional_reference_expression.hpp
29695
+ //
29696
+ //
29697
+ //===----------------------------------------------------------------------===//
29698
+
30031
29699
 
30032
29700
 
30033
29701
 
30034
29702
 
29703
+ namespace duckdb {
29704
+ class PositionalReferenceExpression : public ParsedExpression {
29705
+ public:
29706
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
29707
+
29708
+ idx_t index;
30035
29709
 
29710
+ public:
29711
+ bool IsScalar() const override {
29712
+ return false;
29713
+ }
30036
29714
 
29715
+ string ToString() const override;
30037
29716
 
29717
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
29718
+ unique_ptr<ParsedExpression> Copy() const override;
29719
+ hash_t Hash() const override;
30038
29720
 
29721
+ void Serialize(FieldWriter &writer) const override;
29722
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29723
+ };
29724
+ } // namespace duckdb
29725
+ //===----------------------------------------------------------------------===//
29726
+ // DuckDB
29727
+ //
29728
+ // duckdb/parser/expression/conjunction_expression.hpp
29729
+ //
29730
+ //
29731
+ //===----------------------------------------------------------------------===//
30039
29732
 
30040
29733
 
30041
29734
 
30042
29735
 
30043
29736
 
30044
29737
 
29738
+ namespace duckdb {
30045
29739
 
29740
+ //! Represents a conjunction (AND/OR)
29741
+ class ConjunctionExpression : public ParsedExpression {
29742
+ public:
29743
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
29744
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
29745
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29746
+ unique_ptr<ParsedExpression> right);
30046
29747
 
29748
+ vector<unique_ptr<ParsedExpression>> children;
30047
29749
 
29750
+ public:
29751
+ void AddExpression(unique_ptr<ParsedExpression> expr);
30048
29752
 
30049
- //===----------------------------------------------------------------------===//
30050
- // DuckDB
30051
- //
30052
- // duckdb/parser/parsed_data/create_macro_info.hpp
30053
- //
30054
- //
30055
- //===----------------------------------------------------------------------===//
29753
+ string ToString() const override;
30056
29754
 
29755
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
30057
29756
 
29757
+ unique_ptr<ParsedExpression> Copy() const override;
30058
29758
 
29759
+ void Serialize(FieldWriter &writer) const override;
29760
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30059
29761
 
29762
+ public:
29763
+ template <class T, class BASE>
29764
+ static string ToString(const T &entry) {
29765
+ string result = "(" + entry.children[0]->ToString();
29766
+ for (idx_t i = 1; i < entry.children.size(); i++) {
29767
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
29768
+ }
29769
+ return result + ")";
29770
+ }
29771
+ };
29772
+ } // namespace duckdb
30060
29773
  //===----------------------------------------------------------------------===//
30061
29774
  // DuckDB
30062
29775
  //
30063
- // duckdb/function/macro_function.hpp
29776
+ // duckdb/parser/expression/between_expression.hpp
30064
29777
  //
30065
29778
  //
30066
29779
  //===----------------------------------------------------------------------===//
@@ -30069,67 +29782,270 @@ public:
30069
29782
 
30070
29783
 
30071
29784
 
30072
-
30073
-
30074
-
30075
-
30076
-
30077
29785
  namespace duckdb {
30078
29786
 
30079
- enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
30080
-
30081
- class MacroFunction {
29787
+ class BetweenExpression : public ParsedExpression {
30082
29788
  public:
30083
- MacroFunction(MacroType type);
29789
+ DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
29790
+ unique_ptr<ParsedExpression> upper);
30084
29791
 
30085
- //! The type
30086
- MacroType type;
30087
- //! The positional parameters
30088
- vector<unique_ptr<ParsedExpression>> parameters;
30089
- //! The default parameters and their associated values
30090
- unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
29792
+ unique_ptr<ParsedExpression> input;
29793
+ unique_ptr<ParsedExpression> lower;
29794
+ unique_ptr<ParsedExpression> upper;
30091
29795
 
30092
29796
  public:
30093
- virtual ~MacroFunction() {
30094
- }
29797
+ string ToString() const override;
30095
29798
 
30096
- void CopyProperties(MacroFunction &other);
29799
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
30097
29800
 
30098
- virtual unique_ptr<MacroFunction> Copy() = 0;
29801
+ unique_ptr<ParsedExpression> Copy() const override;
30099
29802
 
30100
- static string ValidateArguments(MacroFunction &macro_function, const string &name,
30101
- FunctionExpression &function_expr,
30102
- vector<unique_ptr<ParsedExpression>> &positionals,
30103
- unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
29803
+ void Serialize(FieldWriter &writer) const override;
29804
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30104
29805
 
30105
- virtual string ToSQL(const string &schema, const string &name);
29806
+ public:
29807
+ template <class T, class BASE>
29808
+ static string ToString(const T &entry) {
29809
+ return "(" + entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " +
29810
+ entry.upper->ToString() + ")";
29811
+ }
30106
29812
  };
30107
-
30108
29813
  } // namespace duckdb
29814
+ //===----------------------------------------------------------------------===//
29815
+ // DuckDB
29816
+ //
29817
+ // duckdb/parser/expression/cast_expression.hpp
29818
+ //
29819
+ //
29820
+ //===----------------------------------------------------------------------===//
29821
+
29822
+
29823
+
29824
+
30109
29825
 
30110
29826
 
30111
29827
  namespace duckdb {
30112
29828
 
30113
- struct CreateMacroInfo : public CreateFunctionInfo {
30114
- CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
30115
- }
29829
+ //! CastExpression represents a type cast from one SQL type to another SQL type
29830
+ class CastExpression : public ParsedExpression {
29831
+ public:
29832
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
30116
29833
 
30117
- CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
29834
+ //! The child of the cast expression
29835
+ unique_ptr<ParsedExpression> child;
29836
+ //! The type to cast to
29837
+ LogicalType cast_type;
29838
+ //! Whether or not this is a try_cast expression
29839
+ bool try_cast;
29840
+
29841
+ public:
29842
+ string ToString() const override;
29843
+
29844
+ static bool Equals(const CastExpression *a, const CastExpression *b);
29845
+
29846
+ unique_ptr<ParsedExpression> Copy() const override;
29847
+
29848
+ void Serialize(FieldWriter &writer) const override;
29849
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29850
+
29851
+ public:
29852
+ template <class T, class BASE>
29853
+ static string ToString(const T &entry) {
29854
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
29855
+ entry.cast_type.ToString() + ")";
30118
29856
  }
29857
+ };
29858
+ } // namespace duckdb
30119
29859
 
30120
- unique_ptr<MacroFunction> function;
30121
29860
 
29861
+ //===----------------------------------------------------------------------===//
29862
+ // DuckDB
29863
+ //
29864
+ // duckdb/parser/expression/case_expression.hpp
29865
+ //
29866
+ //
29867
+ //===----------------------------------------------------------------------===//
29868
+
29869
+
29870
+
29871
+
29872
+
29873
+
29874
+ namespace duckdb {
29875
+
29876
+ struct CaseCheck {
29877
+ unique_ptr<ParsedExpression> when_expr;
29878
+ unique_ptr<ParsedExpression> then_expr;
29879
+ };
29880
+
29881
+ //! The CaseExpression represents a CASE expression in the query
29882
+ class CaseExpression : public ParsedExpression {
30122
29883
  public:
30123
- unique_ptr<CreateInfo> Copy() const override {
30124
- auto result = make_unique<CreateMacroInfo>();
30125
- result->function = function->Copy();
30126
- result->name = name;
30127
- CopyProperties(*result);
30128
- return move(result);
29884
+ DUCKDB_API CaseExpression();
29885
+
29886
+ vector<CaseCheck> case_checks;
29887
+ unique_ptr<ParsedExpression> else_expr;
29888
+
29889
+ public:
29890
+ string ToString() const override;
29891
+
29892
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
29893
+
29894
+ unique_ptr<ParsedExpression> Copy() const override;
29895
+
29896
+ void Serialize(FieldWriter &writer) const override;
29897
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29898
+
29899
+ public:
29900
+ template <class T, class BASE>
29901
+ static string ToString(const T &entry) {
29902
+ string case_str = "CASE ";
29903
+ for (auto &check : entry.case_checks) {
29904
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
29905
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
29906
+ }
29907
+ case_str += " ELSE " + entry.else_expr->ToString();
29908
+ case_str += " END";
29909
+ return case_str;
30129
29910
  }
30130
29911
  };
29912
+ } // namespace duckdb
29913
+
29914
+
29915
+ //===----------------------------------------------------------------------===//
29916
+ // DuckDB
29917
+ //
29918
+ // duckdb/parser/expression/collate_expression.hpp
29919
+ //
29920
+ //
29921
+ //===----------------------------------------------------------------------===//
29922
+
29923
+
29924
+
29925
+
29926
+
29927
+ namespace duckdb {
29928
+
29929
+ //! CollateExpression represents a COLLATE statement
29930
+ class CollateExpression : public ParsedExpression {
29931
+ public:
29932
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
29933
+
29934
+ //! The child of the cast expression
29935
+ unique_ptr<ParsedExpression> child;
29936
+ //! The collation clause
29937
+ string collation;
29938
+
29939
+ public:
29940
+ string ToString() const override;
29941
+
29942
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
29943
+
29944
+ unique_ptr<ParsedExpression> Copy() const override;
29945
+
29946
+ void Serialize(FieldWriter &writer) const override;
29947
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29948
+ };
29949
+ } // namespace duckdb
29950
+
29951
+
29952
+
29953
+
29954
+ //===----------------------------------------------------------------------===//
29955
+ // DuckDB
29956
+ //
29957
+ // duckdb/parser/expression/constant_expression.hpp
29958
+ //
29959
+ //
29960
+ //===----------------------------------------------------------------------===//
29961
+
29962
+
29963
+
29964
+
29965
+
29966
+
29967
+ namespace duckdb {
29968
+
29969
+ //! ConstantExpression represents a constant value in the query
29970
+ class ConstantExpression : public ParsedExpression {
29971
+ public:
29972
+ DUCKDB_API explicit ConstantExpression(Value val);
29973
+
29974
+ //! The constant value referenced
29975
+ Value value;
29976
+
29977
+ public:
29978
+ string ToString() const override;
29979
+
29980
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
29981
+ hash_t Hash() const override;
29982
+
29983
+ unique_ptr<ParsedExpression> Copy() const override;
29984
+
29985
+ void Serialize(FieldWriter &writer) const override;
29986
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29987
+ };
29988
+
29989
+ } // namespace duckdb
29990
+
29991
+
29992
+
29993
+
29994
+
29995
+
29996
+
29997
+
29998
+ //===----------------------------------------------------------------------===//
29999
+ // DuckDB
30000
+ //
30001
+ // duckdb/parser/expression/subquery_expression.hpp
30002
+ //
30003
+ //
30004
+ //===----------------------------------------------------------------------===//
30005
+
30006
+
30007
+
30008
+
30009
+
30010
+
30011
+
30012
+ namespace duckdb {
30131
30013
 
30014
+ //! Represents a subquery
30015
+ class SubqueryExpression : public ParsedExpression {
30016
+ public:
30017
+ SubqueryExpression();
30018
+
30019
+ //! The actual subquery
30020
+ unique_ptr<SelectStatement> subquery;
30021
+ //! The subquery type
30022
+ SubqueryType subquery_type;
30023
+ //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
30024
+ //! subquery)
30025
+ unique_ptr<ParsedExpression> child;
30026
+ //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
30027
+ ExpressionType comparison_type;
30028
+
30029
+ public:
30030
+ bool HasSubquery() const override {
30031
+ return true;
30032
+ }
30033
+ bool IsScalar() const override {
30034
+ return false;
30035
+ }
30036
+
30037
+ string ToString() const override;
30038
+
30039
+ static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
30040
+
30041
+ unique_ptr<ParsedExpression> Copy() const override;
30042
+
30043
+ void Serialize(FieldWriter &writer) const override;
30044
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30045
+ };
30132
30046
  } // namespace duckdb
30047
+
30048
+
30133
30049
  //===----------------------------------------------------------------------===//
30134
30050
  // DuckDB
30135
30051
  //
@@ -30170,7 +30086,45 @@ struct BoundExportData : public ParseInfo {
30170
30086
  //===----------------------------------------------------------------------===//
30171
30087
  // DuckDB
30172
30088
  //
30173
- // duckdb/parser/parsed_data/drop_info.hpp
30089
+ // duckdb/parser/parsed_data/transaction_info.hpp
30090
+ //
30091
+ //
30092
+ //===----------------------------------------------------------------------===//
30093
+
30094
+
30095
+
30096
+
30097
+
30098
+ namespace duckdb {
30099
+
30100
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
30101
+
30102
+ struct TransactionInfo : public ParseInfo {
30103
+ explicit TransactionInfo(TransactionType type) : type(type) {
30104
+ }
30105
+
30106
+ //! The type of transaction statement
30107
+ TransactionType type;
30108
+ };
30109
+
30110
+ } // namespace duckdb
30111
+ //===----------------------------------------------------------------------===//
30112
+ // DuckDB
30113
+ //
30114
+ // duckdb/parser/parsed_data/create_index_info.hpp
30115
+ //
30116
+ //
30117
+ //===----------------------------------------------------------------------===//
30118
+
30119
+
30120
+
30121
+
30122
+
30123
+
30124
+ //===----------------------------------------------------------------------===//
30125
+ // DuckDB
30126
+ //
30127
+ // duckdb/parser/tableref/basetableref.hpp
30174
30128
  //
30175
30129
  //
30176
30130
  //===----------------------------------------------------------------------===//
@@ -30181,40 +30135,74 @@ struct BoundExportData : public ParseInfo {
30181
30135
 
30182
30136
 
30183
30137
  namespace duckdb {
30138
+ //! Represents a TableReference to a base table in the schema
30139
+ class BaseTableRef : public TableRef {
30140
+ public:
30141
+ BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
30142
+ }
30184
30143
 
30185
- struct DropInfo : public ParseInfo {
30186
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
30144
+ //! Schema name
30145
+ string schema_name;
30146
+ //! Table name
30147
+ string table_name;
30148
+ //! Aliases for the column names
30149
+ vector<string> column_name_alias;
30150
+
30151
+ public:
30152
+ string ToString() const override;
30153
+ bool Equals(const TableRef *other_p) const override;
30154
+
30155
+ unique_ptr<TableRef> Copy() override;
30156
+
30157
+ //! Serializes a blob into a BaseTableRef
30158
+ void Serialize(FieldWriter &serializer) const override;
30159
+ //! Deserializes a blob back into a BaseTableRef
30160
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
30161
+ };
30162
+ } // namespace duckdb
30163
+
30164
+
30165
+
30166
+
30167
+ namespace duckdb {
30168
+
30169
+ struct CreateIndexInfo : public CreateInfo {
30170
+ CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
30187
30171
  }
30188
30172
 
30189
- //! The catalog type to drop
30190
- CatalogType type;
30191
- //! Schema name to drop from, if any
30192
- string schema;
30193
- //! Element name to drop
30194
- string name;
30195
- //! Ignore if the entry does not exist instead of failing
30196
- bool if_exists = false;
30197
- //! Cascade drop (drop all dependents instead of throwing an error if there
30198
- //! are any)
30199
- bool cascade = false;
30173
+ //! Index Type (e.g., B+-tree, Skip-List, ...)
30174
+ IndexType index_type;
30175
+ //! Name of the Index
30176
+ string index_name;
30177
+ //! Index Constraint Type
30178
+ IndexConstraintType constraint_type;
30179
+ //! The table to create the index on
30180
+ unique_ptr<BaseTableRef> table;
30181
+ //! Set of expressions to index by
30182
+ vector<unique_ptr<ParsedExpression>> expressions;
30183
+ vector<unique_ptr<ParsedExpression>> parsed_expressions;
30184
+
30185
+ //! Types used for the CREATE INDEX scan
30186
+ vector<LogicalType> scan_types;
30187
+ //! The names of the columns, used for the CREATE INDEX scan
30188
+ vector<string> names;
30189
+ //! Column IDs needed for index creation
30190
+ vector<column_t> column_ids;
30191
+
30192
+ protected:
30193
+ void SerializeInternal(Serializer &serializer) const override;
30200
30194
 
30201
30195
  public:
30202
- unique_ptr<DropInfo> Copy() const {
30203
- auto result = make_unique<DropInfo>();
30204
- result->type = type;
30205
- result->schema = schema;
30206
- result->name = name;
30207
- result->if_exists = if_exists;
30208
- result->cascade = cascade;
30209
- return result;
30210
- }
30196
+ unique_ptr<CreateInfo> Copy() const override;
30197
+
30198
+ static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
30211
30199
  };
30212
30200
 
30213
30201
  } // namespace duckdb
30214
30202
  //===----------------------------------------------------------------------===//
30215
30203
  // DuckDB
30216
30204
  //
30217
- // duckdb/parser/parsed_data/transaction_info.hpp
30205
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
30218
30206
  //
30219
30207
  //
30220
30208
  //===----------------------------------------------------------------------===//
@@ -30223,16 +30211,32 @@ public:
30223
30211
 
30224
30212
 
30225
30213
 
30214
+
30226
30215
  namespace duckdb {
30227
30216
 
30228
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
30217
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
30218
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
30219
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
30220
+ name = function.name;
30221
+ functions.AddFunction(move(function));
30222
+ }
30229
30223
 
30230
- struct TransactionInfo : public ParseInfo {
30231
- explicit TransactionInfo(TransactionType type) : type(type) {
30224
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
30225
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
30226
+ name = functions.name;
30227
+ for (auto &func : functions.functions) {
30228
+ func.name = functions.name;
30229
+ }
30232
30230
  }
30233
30231
 
30234
- //! The type of transaction statement
30235
- TransactionType type;
30232
+ AggregateFunctionSet functions;
30233
+
30234
+ public:
30235
+ unique_ptr<CreateInfo> Copy() const override {
30236
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
30237
+ CopyProperties(*result);
30238
+ return move(result);
30239
+ }
30236
30240
  };
30237
30241
 
30238
30242
  } // namespace duckdb
@@ -30332,51 +30336,6 @@ protected:
30332
30336
  }
30333
30337
  };
30334
30338
 
30335
- } // namespace duckdb
30336
- //===----------------------------------------------------------------------===//
30337
- // DuckDB
30338
- //
30339
- // duckdb/parser/parsed_data/create_type_info.hpp
30340
- //
30341
- //
30342
- //===----------------------------------------------------------------------===//
30343
-
30344
-
30345
-
30346
-
30347
-
30348
-
30349
-
30350
-
30351
- namespace duckdb {
30352
-
30353
- struct CreateTypeInfo : public CreateInfo {
30354
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
30355
- }
30356
- CreateTypeInfo(string name_p, LogicalType type_p)
30357
- : CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
30358
- }
30359
-
30360
- //! Name of the Type
30361
- string name;
30362
- //! Logical Type
30363
- LogicalType type;
30364
-
30365
- public:
30366
- unique_ptr<CreateInfo> Copy() const override {
30367
- auto result = make_unique<CreateTypeInfo>();
30368
- CopyProperties(*result);
30369
- result->name = name;
30370
- result->type = type;
30371
- return move(result);
30372
- }
30373
-
30374
- protected:
30375
- void SerializeInternal(Serializer &) const override {
30376
- throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
30377
- }
30378
- };
30379
-
30380
30339
  } // namespace duckdb
30381
30340
  //===----------------------------------------------------------------------===//
30382
30341
  // DuckDB
@@ -30417,7 +30376,7 @@ struct ShowSelectInfo : public ParseInfo {
30417
30376
  //===----------------------------------------------------------------------===//
30418
30377
  // DuckDB
30419
30378
  //
30420
- // duckdb/parser/parsed_data/create_index_info.hpp
30379
+ // duckdb/parser/parsed_data/alter_function_info.hpp
30421
30380
  //
30422
30381
  //
30423
30382
  //===----------------------------------------------------------------------===//
@@ -30427,10 +30386,55 @@ struct ShowSelectInfo : public ParseInfo {
30427
30386
 
30428
30387
 
30429
30388
 
30389
+
30390
+ namespace duckdb {
30391
+
30392
+ //===--------------------------------------------------------------------===//
30393
+ // Alter Table
30394
+ //===--------------------------------------------------------------------===//
30395
+ enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
30396
+
30397
+ struct AlterFunctionInfo : public AlterInfo {
30398
+ AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
30399
+ virtual ~AlterFunctionInfo() override;
30400
+
30401
+ AlterFunctionType alter_function_type;
30402
+
30403
+ public:
30404
+ CatalogType GetCatalogType() const override;
30405
+ void Serialize(FieldWriter &writer) const override;
30406
+ static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
30407
+ };
30408
+
30409
+ //===--------------------------------------------------------------------===//
30410
+ // AddFunctionOverloadInfo
30411
+ //===--------------------------------------------------------------------===//
30412
+ struct AddFunctionOverloadInfo : public AlterFunctionInfo {
30413
+ AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
30414
+ ~AddFunctionOverloadInfo() override;
30415
+
30416
+ ScalarFunctionSet new_overloads;
30417
+
30418
+ public:
30419
+ unique_ptr<AlterInfo> Copy() const override;
30420
+ };
30421
+
30422
+ } // namespace duckdb
30423
+ //===----------------------------------------------------------------------===//
30424
+ // DuckDB
30425
+ //
30426
+ // duckdb/parser/parsed_data/create_macro_info.hpp
30427
+ //
30428
+ //
30429
+ //===----------------------------------------------------------------------===//
30430
+
30431
+
30432
+
30433
+
30430
30434
  //===----------------------------------------------------------------------===//
30431
30435
  // DuckDB
30432
30436
  //
30433
- // duckdb/parser/tableref/basetableref.hpp
30437
+ // duckdb/function/macro_function.hpp
30434
30438
  //
30435
30439
  //
30436
30440
  //===----------------------------------------------------------------------===//
@@ -30440,75 +30444,114 @@ struct ShowSelectInfo : public ParseInfo {
30440
30444
 
30441
30445
 
30442
30446
 
30447
+
30448
+
30449
+
30450
+
30443
30451
  namespace duckdb {
30444
- //! Represents a TableReference to a base table in the schema
30445
- class BaseTableRef : public TableRef {
30452
+
30453
+ enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
30454
+
30455
+ class MacroFunction {
30446
30456
  public:
30447
- BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
30448
- }
30457
+ MacroFunction(MacroType type);
30449
30458
 
30450
- //! Schema name
30451
- string schema_name;
30452
- //! Table name
30453
- string table_name;
30454
- //! Aliases for the column names
30455
- vector<string> column_name_alias;
30459
+ //! The type
30460
+ MacroType type;
30461
+ //! The positional parameters
30462
+ vector<unique_ptr<ParsedExpression>> parameters;
30463
+ //! The default parameters and their associated values
30464
+ unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
30456
30465
 
30457
30466
  public:
30458
- string ToString() const override;
30459
- bool Equals(const TableRef *other_p) const override;
30467
+ virtual ~MacroFunction() {
30468
+ }
30460
30469
 
30461
- unique_ptr<TableRef> Copy() override;
30470
+ void CopyProperties(MacroFunction &other);
30462
30471
 
30463
- //! Serializes a blob into a BaseTableRef
30464
- void Serialize(FieldWriter &serializer) const override;
30465
- //! Deserializes a blob back into a BaseTableRef
30466
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
30472
+ virtual unique_ptr<MacroFunction> Copy() = 0;
30473
+
30474
+ static string ValidateArguments(MacroFunction &macro_function, const string &name,
30475
+ FunctionExpression &function_expr,
30476
+ vector<unique_ptr<ParsedExpression>> &positionals,
30477
+ unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
30478
+
30479
+ virtual string ToSQL(const string &schema, const string &name);
30467
30480
  };
30481
+
30468
30482
  } // namespace duckdb
30469
30483
 
30470
30484
 
30485
+ namespace duckdb {
30471
30486
 
30487
+ struct CreateMacroInfo : public CreateFunctionInfo {
30488
+ CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
30489
+ }
30472
30490
 
30473
- namespace duckdb {
30491
+ CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
30492
+ }
30474
30493
 
30475
- struct CreateIndexInfo : public CreateInfo {
30476
- CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
30494
+ unique_ptr<MacroFunction> function;
30495
+
30496
+ public:
30497
+ unique_ptr<CreateInfo> Copy() const override {
30498
+ auto result = make_unique<CreateMacroInfo>();
30499
+ result->function = function->Copy();
30500
+ result->name = name;
30501
+ CopyProperties(*result);
30502
+ return move(result);
30477
30503
  }
30504
+ };
30478
30505
 
30479
- //! Index Type (e.g., B+-tree, Skip-List, ...)
30480
- IndexType index_type;
30481
- //! Name of the Index
30482
- string index_name;
30483
- //! Index Constraint Type
30484
- IndexConstraintType constraint_type;
30485
- //! The table to create the index on
30486
- unique_ptr<BaseTableRef> table;
30487
- //! Set of expressions to index by
30488
- vector<unique_ptr<ParsedExpression>> expressions;
30489
- vector<unique_ptr<ParsedExpression>> parsed_expressions;
30506
+ } // namespace duckdb
30507
+ //===----------------------------------------------------------------------===//
30508
+ // DuckDB
30509
+ //
30510
+ // duckdb/parser/parsed_data/drop_info.hpp
30511
+ //
30512
+ //
30513
+ //===----------------------------------------------------------------------===//
30490
30514
 
30491
- //! Types used for the CREATE INDEX scan
30492
- vector<LogicalType> scan_types;
30493
- //! The names of the columns, used for the CREATE INDEX scan
30494
- vector<string> names;
30495
- //! Column IDs needed for index creation
30496
- vector<column_t> column_ids;
30497
30515
 
30498
- protected:
30499
- void SerializeInternal(Serializer &serializer) const override;
30516
+
30517
+
30518
+
30519
+
30520
+ namespace duckdb {
30521
+
30522
+ struct DropInfo : public ParseInfo {
30523
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
30524
+ }
30525
+
30526
+ //! The catalog type to drop
30527
+ CatalogType type;
30528
+ //! Schema name to drop from, if any
30529
+ string schema;
30530
+ //! Element name to drop
30531
+ string name;
30532
+ //! Ignore if the entry does not exist instead of failing
30533
+ bool if_exists = false;
30534
+ //! Cascade drop (drop all dependents instead of throwing an error if there
30535
+ //! are any)
30536
+ bool cascade = false;
30500
30537
 
30501
30538
  public:
30502
- unique_ptr<CreateInfo> Copy() const override;
30503
-
30504
- static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
30539
+ unique_ptr<DropInfo> Copy() const {
30540
+ auto result = make_unique<DropInfo>();
30541
+ result->type = type;
30542
+ result->schema = schema;
30543
+ result->name = name;
30544
+ result->if_exists = if_exists;
30545
+ result->cascade = cascade;
30546
+ return result;
30547
+ }
30505
30548
  };
30506
30549
 
30507
30550
  } // namespace duckdb
30508
30551
  //===----------------------------------------------------------------------===//
30509
30552
  // DuckDB
30510
30553
  //
30511
- // duckdb/parser/parsed_data/alter_function_info.hpp
30554
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
30512
30555
  //
30513
30556
  //
30514
30557
  //===----------------------------------------------------------------------===//
@@ -30521,34 +30564,25 @@ public:
30521
30564
 
30522
30565
  namespace duckdb {
30523
30566
 
30524
- //===--------------------------------------------------------------------===//
30525
- // Alter Table
30526
- //===--------------------------------------------------------------------===//
30527
- enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
30528
-
30529
- struct AlterFunctionInfo : public AlterInfo {
30530
- AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
30531
- virtual ~AlterFunctionInfo() override;
30532
-
30533
- AlterFunctionType alter_function_type;
30534
-
30535
- public:
30536
- CatalogType GetCatalogType() const override;
30537
- void Serialize(FieldWriter &writer) const override;
30538
- static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
30539
- };
30540
-
30541
- //===--------------------------------------------------------------------===//
30542
- // AddFunctionOverloadInfo
30543
- //===--------------------------------------------------------------------===//
30544
- struct AddFunctionOverloadInfo : public AlterFunctionInfo {
30545
- AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
30546
- ~AddFunctionOverloadInfo() override;
30567
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
30568
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
30569
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(function.name) {
30570
+ name = function.name;
30571
+ functions.AddFunction(move(function));
30572
+ }
30573
+ CreatePragmaFunctionInfo(string name, PragmaFunctionSet functions_)
30574
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(functions_) {
30575
+ this->name = name;
30576
+ }
30547
30577
 
30548
- ScalarFunctionSet new_overloads;
30578
+ PragmaFunctionSet functions;
30549
30579
 
30550
30580
  public:
30551
- unique_ptr<AlterInfo> Copy() const override;
30581
+ unique_ptr<CreateInfo> Copy() const override {
30582
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions.name, functions);
30583
+ CopyProperties(*result);
30584
+ return move(result);
30585
+ }
30552
30586
  };
30553
30587
 
30554
30588
  } // namespace duckdb
@@ -30653,85 +30687,6 @@ public:
30653
30687
  vector<string> columns;
30654
30688
  };
30655
30689
 
30656
- } // namespace duckdb
30657
- //===----------------------------------------------------------------------===//
30658
- // DuckDB
30659
- //
30660
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
30661
- //
30662
- //
30663
- //===----------------------------------------------------------------------===//
30664
-
30665
-
30666
-
30667
-
30668
-
30669
-
30670
-
30671
- namespace duckdb {
30672
-
30673
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
30674
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
30675
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(function.name) {
30676
- name = function.name;
30677
- functions.AddFunction(move(function));
30678
- }
30679
- CreatePragmaFunctionInfo(string name, PragmaFunctionSet functions_)
30680
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(functions_) {
30681
- this->name = name;
30682
- }
30683
-
30684
- PragmaFunctionSet functions;
30685
-
30686
- public:
30687
- unique_ptr<CreateInfo> Copy() const override {
30688
- auto result = make_unique<CreatePragmaFunctionInfo>(functions.name, functions);
30689
- CopyProperties(*result);
30690
- return move(result);
30691
- }
30692
- };
30693
-
30694
- } // namespace duckdb
30695
- //===----------------------------------------------------------------------===//
30696
- // DuckDB
30697
- //
30698
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
30699
- //
30700
- //
30701
- //===----------------------------------------------------------------------===//
30702
-
30703
-
30704
-
30705
-
30706
-
30707
-
30708
- namespace duckdb {
30709
-
30710
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
30711
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
30712
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
30713
- name = function.name;
30714
- functions.AddFunction(move(function));
30715
- }
30716
-
30717
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
30718
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
30719
- name = functions.name;
30720
- for (auto &func : functions.functions) {
30721
- func.name = functions.name;
30722
- }
30723
- }
30724
-
30725
- AggregateFunctionSet functions;
30726
-
30727
- public:
30728
- unique_ptr<CreateInfo> Copy() const override {
30729
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
30730
- CopyProperties(*result);
30731
- return move(result);
30732
- }
30733
- };
30734
-
30735
30690
  } // namespace duckdb
30736
30691
  //===----------------------------------------------------------------------===//
30737
30692
  // DuckDB
@@ -30820,7 +30775,7 @@ protected:
30820
30775
  //===----------------------------------------------------------------------===//
30821
30776
  // DuckDB
30822
30777
  //
30823
- // duckdb/parser/tableref/crossproductref.hpp
30778
+ // duckdb/parser/parsed_data/create_type_info.hpp
30824
30779
  //
30825
30780
  //
30826
30781
  //===----------------------------------------------------------------------===//
@@ -30829,29 +30784,38 @@ protected:
30829
30784
 
30830
30785
 
30831
30786
 
30787
+
30788
+
30789
+
30832
30790
  namespace duckdb {
30833
- //! Represents a cross product
30834
- class CrossProductRef : public TableRef {
30835
- public:
30836
- CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
30791
+
30792
+ struct CreateTypeInfo : public CreateInfo {
30793
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
30794
+ }
30795
+ CreateTypeInfo(string name_p, LogicalType type_p)
30796
+ : CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
30837
30797
  }
30838
30798
 
30839
- //! The left hand side of the cross product
30840
- unique_ptr<TableRef> left;
30841
- //! The right hand side of the cross product
30842
- unique_ptr<TableRef> right;
30799
+ //! Name of the Type
30800
+ string name;
30801
+ //! Logical Type
30802
+ LogicalType type;
30843
30803
 
30844
30804
  public:
30845
- string ToString() const override;
30846
- bool Equals(const TableRef *other_p) const override;
30847
-
30848
- unique_ptr<TableRef> Copy() override;
30805
+ unique_ptr<CreateInfo> Copy() const override {
30806
+ auto result = make_unique<CreateTypeInfo>();
30807
+ CopyProperties(*result);
30808
+ result->name = name;
30809
+ result->type = type;
30810
+ return move(result);
30811
+ }
30849
30812
 
30850
- //! Serializes a blob into a CrossProductRef
30851
- void Serialize(FieldWriter &serializer) const override;
30852
- //! Deserializes a blob back into a CrossProductRef
30853
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
30813
+ protected:
30814
+ void SerializeInternal(Serializer &) const override {
30815
+ throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
30816
+ }
30854
30817
  };
30818
+
30855
30819
  } // namespace duckdb
30856
30820
  //===----------------------------------------------------------------------===//
30857
30821
  // DuckDB
@@ -30892,6 +30856,54 @@ public:
30892
30856
  //===----------------------------------------------------------------------===//
30893
30857
  // DuckDB
30894
30858
  //
30859
+ // duckdb/parser/tableref/joinref.hpp
30860
+ //
30861
+ //
30862
+ //===----------------------------------------------------------------------===//
30863
+
30864
+
30865
+
30866
+
30867
+
30868
+
30869
+
30870
+
30871
+
30872
+ namespace duckdb {
30873
+ //! Represents a JOIN between two expressions
30874
+ class JoinRef : public TableRef {
30875
+ public:
30876
+ JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
30877
+ }
30878
+
30879
+ //! The left hand side of the join
30880
+ unique_ptr<TableRef> left;
30881
+ //! The right hand side of the join
30882
+ unique_ptr<TableRef> right;
30883
+ //! The join condition
30884
+ unique_ptr<ParsedExpression> condition;
30885
+ //! The join type
30886
+ JoinType type;
30887
+ //! Natural join
30888
+ bool is_natural;
30889
+ //! The set of USING columns (if any)
30890
+ vector<string> using_columns;
30891
+
30892
+ public:
30893
+ string ToString() const override;
30894
+ bool Equals(const TableRef *other_p) const override;
30895
+
30896
+ unique_ptr<TableRef> Copy() override;
30897
+
30898
+ //! Serializes a blob into a JoinRef
30899
+ void Serialize(FieldWriter &serializer) const override;
30900
+ //! Deserializes a blob back into a JoinRef
30901
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
30902
+ };
30903
+ } // namespace duckdb
30904
+ //===----------------------------------------------------------------------===//
30905
+ // DuckDB
30906
+ //
30895
30907
  // duckdb/parser/tableref/table_function_ref.hpp
30896
30908
  //
30897
30909
  //
@@ -30936,7 +30948,7 @@ public:
30936
30948
  //===----------------------------------------------------------------------===//
30937
30949
  // DuckDB
30938
30950
  //
30939
- // duckdb/parser/tableref/joinref.hpp
30951
+ // duckdb/parser/tableref/crossproductref.hpp
30940
30952
  //
30941
30953
  //
30942
30954
  //===----------------------------------------------------------------------===//
@@ -30945,29 +30957,17 @@ public:
30945
30957
 
30946
30958
 
30947
30959
 
30948
-
30949
-
30950
-
30951
-
30952
30960
  namespace duckdb {
30953
- //! Represents a JOIN between two expressions
30954
- class JoinRef : public TableRef {
30961
+ //! Represents a cross product
30962
+ class CrossProductRef : public TableRef {
30955
30963
  public:
30956
- JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
30964
+ CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
30957
30965
  }
30958
30966
 
30959
- //! The left hand side of the join
30967
+ //! The left hand side of the cross product
30960
30968
  unique_ptr<TableRef> left;
30961
- //! The right hand side of the join
30969
+ //! The right hand side of the cross product
30962
30970
  unique_ptr<TableRef> right;
30963
- //! The join condition
30964
- unique_ptr<ParsedExpression> condition;
30965
- //! The join type
30966
- JoinType type;
30967
- //! Natural join
30968
- bool is_natural;
30969
- //! The set of USING columns (if any)
30970
- vector<string> using_columns;
30971
30971
 
30972
30972
  public:
30973
30973
  string ToString() const override;
@@ -30975,9 +30975,9 @@ public:
30975
30975
 
30976
30976
  unique_ptr<TableRef> Copy() override;
30977
30977
 
30978
- //! Serializes a blob into a JoinRef
30978
+ //! Serializes a blob into a CrossProductRef
30979
30979
  void Serialize(FieldWriter &serializer) const override;
30980
- //! Deserializes a blob back into a JoinRef
30980
+ //! Deserializes a blob back into a CrossProductRef
30981
30981
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
30982
30982
  };
30983
30983
  } // namespace duckdb