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