duckdb 0.5.2-dev754.0 → 0.5.2-dev756.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 "e322d56ff"
15
- #define DUCKDB_VERSION "v0.5.2-dev754"
14
+ #define DUCKDB_SOURCE_ID "1e7f9641b"
15
+ #define DUCKDB_VERSION "v0.5.2-dev756"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -29275,7 +29275,7 @@ private:
29275
29275
  //===----------------------------------------------------------------------===//
29276
29276
  // DuckDB
29277
29277
  //
29278
- // duckdb/parser/expression/default_expression.hpp
29278
+ // duckdb/parser/expression/collate_expression.hpp
29279
29279
  //
29280
29280
  //
29281
29281
  //===----------------------------------------------------------------------===//
@@ -29285,28 +29285,114 @@ private:
29285
29285
 
29286
29286
 
29287
29287
  namespace duckdb {
29288
- //! Represents the default value of a column
29289
- class DefaultExpression : public ParsedExpression {
29288
+
29289
+ //! CollateExpression represents a COLLATE statement
29290
+ class CollateExpression : public ParsedExpression {
29290
29291
  public:
29291
- DefaultExpression();
29292
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
29293
+
29294
+ //! The child of the cast expression
29295
+ unique_ptr<ParsedExpression> child;
29296
+ //! The collation clause
29297
+ string collation;
29292
29298
 
29293
29299
  public:
29294
- bool IsScalar() const override {
29295
- return false;
29300
+ string ToString() const override;
29301
+
29302
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
29303
+
29304
+ unique_ptr<ParsedExpression> Copy() const override;
29305
+
29306
+ void Serialize(FieldWriter &writer) const override;
29307
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29308
+ };
29309
+ } // namespace duckdb
29310
+ //===----------------------------------------------------------------------===//
29311
+ // DuckDB
29312
+ //
29313
+ // duckdb/parser/expression/between_expression.hpp
29314
+ //
29315
+ //
29316
+ //===----------------------------------------------------------------------===//
29317
+
29318
+
29319
+
29320
+
29321
+
29322
+ namespace duckdb {
29323
+
29324
+ class BetweenExpression : public ParsedExpression {
29325
+ public:
29326
+ DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
29327
+ unique_ptr<ParsedExpression> upper);
29328
+
29329
+ unique_ptr<ParsedExpression> input;
29330
+ unique_ptr<ParsedExpression> lower;
29331
+ unique_ptr<ParsedExpression> upper;
29332
+
29333
+ public:
29334
+ string ToString() const override;
29335
+
29336
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
29337
+
29338
+ unique_ptr<ParsedExpression> Copy() const override;
29339
+
29340
+ void Serialize(FieldWriter &writer) const override;
29341
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29342
+
29343
+ public:
29344
+ template <class T, class BASE>
29345
+ static string ToString(const T &entry) {
29346
+ return "(" + entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " +
29347
+ entry.upper->ToString() + ")";
29296
29348
  }
29349
+ };
29350
+ } // namespace duckdb
29351
+ //===----------------------------------------------------------------------===//
29352
+ // DuckDB
29353
+ //
29354
+ // duckdb/parser/expression/comparison_expression.hpp
29355
+ //
29356
+ //
29357
+ //===----------------------------------------------------------------------===//
29358
+
29359
+
29360
+
29361
+
29362
+
29363
+ namespace duckdb {
29364
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
29365
+ //! and has two children.
29366
+ class ComparisonExpression : public ParsedExpression {
29367
+ public:
29368
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29369
+ unique_ptr<ParsedExpression> right);
29370
+
29371
+ unique_ptr<ParsedExpression> left;
29372
+ unique_ptr<ParsedExpression> right;
29297
29373
 
29374
+ public:
29298
29375
  string ToString() const override;
29299
29376
 
29377
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
29378
+
29300
29379
  unique_ptr<ParsedExpression> Copy() const override;
29301
29380
 
29302
29381
  void Serialize(FieldWriter &writer) const override;
29303
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 StringUtil::Format("(%s %s %s)", entry.left->ToString(), ExpressionTypeToOperator(entry.type),
29388
+ entry.right->ToString());
29389
+ }
29304
29390
  };
29305
29391
  } // namespace duckdb
29306
29392
  //===----------------------------------------------------------------------===//
29307
29393
  // DuckDB
29308
29394
  //
29309
- // duckdb/parser/expression/parameter_expression.hpp
29395
+ // duckdb/parser/expression/subquery_expression.hpp
29310
29396
  //
29311
29397
  //
29312
29398
  //===----------------------------------------------------------------------===//
@@ -29315,25 +29401,118 @@ public:
29315
29401
 
29316
29402
 
29317
29403
 
29404
+
29405
+
29318
29406
  namespace duckdb {
29319
- class ParameterExpression : public ParsedExpression {
29407
+
29408
+ //! Represents a subquery
29409
+ class SubqueryExpression : public ParsedExpression {
29320
29410
  public:
29321
- ParameterExpression();
29411
+ SubqueryExpression();
29322
29412
 
29323
- idx_t parameter_nr;
29413
+ //! The actual subquery
29414
+ unique_ptr<SelectStatement> subquery;
29415
+ //! The subquery type
29416
+ SubqueryType subquery_type;
29417
+ //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
29418
+ //! subquery)
29419
+ unique_ptr<ParsedExpression> child;
29420
+ //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
29421
+ ExpressionType comparison_type;
29324
29422
 
29325
29423
  public:
29326
- bool IsScalar() const override {
29424
+ bool HasSubquery() const override {
29327
29425
  return true;
29328
29426
  }
29329
- bool HasParameter() const override {
29330
- return true;
29427
+ bool IsScalar() const override {
29428
+ return false;
29331
29429
  }
29332
29430
 
29333
29431
  string ToString() const override;
29334
29432
 
29335
- static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
29433
+ static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
29434
+
29435
+ unique_ptr<ParsedExpression> Copy() const override;
29336
29436
 
29437
+ void Serialize(FieldWriter &writer) const override;
29438
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29439
+ };
29440
+ } // namespace duckdb
29441
+ //===----------------------------------------------------------------------===//
29442
+ // DuckDB
29443
+ //
29444
+ // duckdb/parser/expression/conjunction_expression.hpp
29445
+ //
29446
+ //
29447
+ //===----------------------------------------------------------------------===//
29448
+
29449
+
29450
+
29451
+
29452
+
29453
+
29454
+ namespace duckdb {
29455
+
29456
+ //! Represents a conjunction (AND/OR)
29457
+ class ConjunctionExpression : public ParsedExpression {
29458
+ public:
29459
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
29460
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
29461
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29462
+ unique_ptr<ParsedExpression> right);
29463
+
29464
+ vector<unique_ptr<ParsedExpression>> children;
29465
+
29466
+ public:
29467
+ void AddExpression(unique_ptr<ParsedExpression> expr);
29468
+
29469
+ string ToString() const override;
29470
+
29471
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
29472
+
29473
+ unique_ptr<ParsedExpression> Copy() const override;
29474
+
29475
+ void Serialize(FieldWriter &writer) const override;
29476
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29477
+
29478
+ public:
29479
+ template <class T, class BASE>
29480
+ static string ToString(const T &entry) {
29481
+ string result = "(" + entry.children[0]->ToString();
29482
+ for (idx_t i = 1; i < entry.children.size(); i++) {
29483
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
29484
+ }
29485
+ return result + ")";
29486
+ }
29487
+ };
29488
+ } // namespace duckdb
29489
+ //===----------------------------------------------------------------------===//
29490
+ // DuckDB
29491
+ //
29492
+ // duckdb/parser/expression/positional_reference_expression.hpp
29493
+ //
29494
+ //
29495
+ //===----------------------------------------------------------------------===//
29496
+
29497
+
29498
+
29499
+
29500
+
29501
+ namespace duckdb {
29502
+ class PositionalReferenceExpression : public ParsedExpression {
29503
+ public:
29504
+ DUCKDB_API PositionalReferenceExpression(idx_t index);
29505
+
29506
+ idx_t index;
29507
+
29508
+ public:
29509
+ bool IsScalar() const override {
29510
+ return false;
29511
+ }
29512
+
29513
+ string ToString() const override;
29514
+
29515
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
29337
29516
  unique_ptr<ParsedExpression> Copy() const override;
29338
29517
  hash_t Hash() const override;
29339
29518
 
@@ -29344,6 +29523,51 @@ public:
29344
29523
  //===----------------------------------------------------------------------===//
29345
29524
  // DuckDB
29346
29525
  //
29526
+ // duckdb/parser/expression/cast_expression.hpp
29527
+ //
29528
+ //
29529
+ //===----------------------------------------------------------------------===//
29530
+
29531
+
29532
+
29533
+
29534
+
29535
+
29536
+ namespace duckdb {
29537
+
29538
+ //! CastExpression represents a type cast from one SQL type to another SQL type
29539
+ class CastExpression : public ParsedExpression {
29540
+ public:
29541
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
29542
+
29543
+ //! The child of the cast expression
29544
+ unique_ptr<ParsedExpression> child;
29545
+ //! The type to cast to
29546
+ LogicalType cast_type;
29547
+ //! Whether or not this is a try_cast expression
29548
+ bool try_cast;
29549
+
29550
+ public:
29551
+ string ToString() const override;
29552
+
29553
+ static bool Equals(const CastExpression *a, const CastExpression *b);
29554
+
29555
+ unique_ptr<ParsedExpression> Copy() const override;
29556
+
29557
+ void Serialize(FieldWriter &writer) const override;
29558
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29559
+
29560
+ public:
29561
+ template <class T, class BASE>
29562
+ static string ToString(const T &entry) {
29563
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
29564
+ entry.cast_type.ToString() + ")";
29565
+ }
29566
+ };
29567
+ } // namespace duckdb
29568
+ //===----------------------------------------------------------------------===//
29569
+ // DuckDB
29570
+ //
29347
29571
  // duckdb/parser/expression/function_expression.hpp
29348
29572
  //
29349
29573
  //
@@ -29461,7 +29685,7 @@ public:
29461
29685
  //===----------------------------------------------------------------------===//
29462
29686
  // DuckDB
29463
29687
  //
29464
- // duckdb/parser/expression/comparison_expression.hpp
29688
+ // duckdb/parser/expression/star_expression.hpp
29465
29689
  //
29466
29690
  //
29467
29691
  //===----------------------------------------------------------------------===//
@@ -29470,21 +29694,102 @@ public:
29470
29694
 
29471
29695
 
29472
29696
 
29697
+
29473
29698
  namespace duckdb {
29474
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
29475
- //! and has two children.
29476
- class ComparisonExpression : public ParsedExpression {
29699
+
29700
+ //! Represents a * expression in the SELECT clause
29701
+ class StarExpression : public ParsedExpression {
29477
29702
  public:
29478
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29479
- unique_ptr<ParsedExpression> right);
29703
+ StarExpression(string relation_name = string());
29480
29704
 
29481
- unique_ptr<ParsedExpression> left;
29482
- unique_ptr<ParsedExpression> right;
29705
+ //! The relation name in case of tbl.*, or empty if this is a normal *
29706
+ string relation_name;
29707
+ //! List of columns to exclude from the STAR expression
29708
+ case_insensitive_set_t exclude_list;
29709
+ //! List of columns to replace with another expression
29710
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
29483
29711
 
29484
29712
  public:
29485
29713
  string ToString() const override;
29486
29714
 
29487
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
29715
+ static bool Equals(const StarExpression *a, const StarExpression *b);
29716
+
29717
+ unique_ptr<ParsedExpression> Copy() const override;
29718
+
29719
+ void Serialize(FieldWriter &writer) const override;
29720
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29721
+ };
29722
+ } // namespace duckdb
29723
+ //===----------------------------------------------------------------------===//
29724
+ // DuckDB
29725
+ //
29726
+ // duckdb/parser/expression/parameter_expression.hpp
29727
+ //
29728
+ //
29729
+ //===----------------------------------------------------------------------===//
29730
+
29731
+
29732
+
29733
+
29734
+
29735
+ namespace duckdb {
29736
+ class ParameterExpression : public ParsedExpression {
29737
+ public:
29738
+ ParameterExpression();
29739
+
29740
+ idx_t parameter_nr;
29741
+
29742
+ public:
29743
+ bool IsScalar() const override {
29744
+ return true;
29745
+ }
29746
+ bool HasParameter() const override {
29747
+ return true;
29748
+ }
29749
+
29750
+ string ToString() const override;
29751
+
29752
+ static bool Equals(const ParameterExpression *a, const ParameterExpression *b);
29753
+
29754
+ unique_ptr<ParsedExpression> Copy() const override;
29755
+ hash_t Hash() const override;
29756
+
29757
+ void Serialize(FieldWriter &writer) const override;
29758
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29759
+ };
29760
+ } // namespace duckdb
29761
+ //===----------------------------------------------------------------------===//
29762
+ // DuckDB
29763
+ //
29764
+ // duckdb/parser/expression/case_expression.hpp
29765
+ //
29766
+ //
29767
+ //===----------------------------------------------------------------------===//
29768
+
29769
+
29770
+
29771
+
29772
+
29773
+
29774
+ namespace duckdb {
29775
+
29776
+ struct CaseCheck {
29777
+ unique_ptr<ParsedExpression> when_expr;
29778
+ unique_ptr<ParsedExpression> then_expr;
29779
+ };
29780
+
29781
+ //! The CaseExpression represents a CASE expression in the query
29782
+ class CaseExpression : public ParsedExpression {
29783
+ public:
29784
+ DUCKDB_API CaseExpression();
29785
+
29786
+ vector<CaseCheck> case_checks;
29787
+ unique_ptr<ParsedExpression> else_expr;
29788
+
29789
+ public:
29790
+ string ToString() const override;
29791
+
29792
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
29488
29793
 
29489
29794
  unique_ptr<ParsedExpression> Copy() const override;
29490
29795
 
@@ -29494,15 +29799,21 @@ public:
29494
29799
  public:
29495
29800
  template <class T, class BASE>
29496
29801
  static string ToString(const T &entry) {
29497
- return StringUtil::Format("(%s %s %s)", entry.left->ToString(), ExpressionTypeToOperator(entry.type),
29498
- entry.right->ToString());
29802
+ string case_str = "CASE ";
29803
+ for (auto &check : entry.case_checks) {
29804
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
29805
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
29806
+ }
29807
+ case_str += " ELSE " + entry.else_expr->ToString();
29808
+ case_str += " END";
29809
+ return case_str;
29499
29810
  }
29500
29811
  };
29501
29812
  } // namespace duckdb
29502
29813
  //===----------------------------------------------------------------------===//
29503
29814
  // DuckDB
29504
29815
  //
29505
- // duckdb/parser/expression/star_expression.hpp
29816
+ // duckdb/parser/expression/constant_expression.hpp
29506
29817
  //
29507
29818
  //
29508
29819
  //===----------------------------------------------------------------------===//
@@ -29514,22 +29825,51 @@ public:
29514
29825
 
29515
29826
  namespace duckdb {
29516
29827
 
29517
- //! Represents a * expression in the SELECT clause
29518
- class StarExpression : public ParsedExpression {
29828
+ //! ConstantExpression represents a constant value in the query
29829
+ class ConstantExpression : public ParsedExpression {
29519
29830
  public:
29520
- StarExpression(string relation_name = string());
29831
+ DUCKDB_API explicit ConstantExpression(Value val);
29521
29832
 
29522
- //! The relation name in case of tbl.*, or empty if this is a normal *
29523
- string relation_name;
29524
- //! List of columns to exclude from the STAR expression
29525
- case_insensitive_set_t exclude_list;
29526
- //! List of columns to replace with another expression
29527
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
29833
+ //! The constant value referenced
29834
+ Value value;
29528
29835
 
29529
29836
  public:
29530
29837
  string ToString() const override;
29531
29838
 
29532
- static bool Equals(const StarExpression *a, const StarExpression *b);
29839
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
29840
+ hash_t Hash() const override;
29841
+
29842
+ unique_ptr<ParsedExpression> Copy() const override;
29843
+
29844
+ void Serialize(FieldWriter &writer) const override;
29845
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29846
+ };
29847
+
29848
+ } // namespace duckdb
29849
+ //===----------------------------------------------------------------------===//
29850
+ // DuckDB
29851
+ //
29852
+ // duckdb/parser/expression/default_expression.hpp
29853
+ //
29854
+ //
29855
+ //===----------------------------------------------------------------------===//
29856
+
29857
+
29858
+
29859
+
29860
+
29861
+ namespace duckdb {
29862
+ //! Represents the default value of a column
29863
+ class DefaultExpression : public ParsedExpression {
29864
+ public:
29865
+ DefaultExpression();
29866
+
29867
+ public:
29868
+ bool IsScalar() const override {
29869
+ return false;
29870
+ }
29871
+
29872
+ string ToString() const override;
29533
29873
 
29534
29874
  unique_ptr<ParsedExpression> Copy() const override;
29535
29875
 
@@ -29647,92 +29987,39 @@ public:
29647
29987
  };
29648
29988
 
29649
29989
  } // namespace duckdb
29650
- //===----------------------------------------------------------------------===//
29651
- // DuckDB
29652
- //
29653
- // duckdb/parser/expression/positional_reference_expression.hpp
29654
- //
29655
- //
29656
- //===----------------------------------------------------------------------===//
29657
-
29658
29990
 
29659
29991
 
29660
29992
 
29661
29993
 
29662
- namespace duckdb {
29663
- class PositionalReferenceExpression : public ParsedExpression {
29664
- public:
29665
- DUCKDB_API PositionalReferenceExpression(idx_t index);
29666
-
29667
- idx_t index;
29668
29994
 
29669
- public:
29670
- bool IsScalar() const override {
29671
- return false;
29672
- }
29673
29995
 
29674
- string ToString() const override;
29675
29996
 
29676
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
29677
- unique_ptr<ParsedExpression> Copy() const override;
29678
- hash_t Hash() const override;
29679
29997
 
29680
- void Serialize(FieldWriter &writer) const override;
29681
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29682
- };
29683
- } // namespace duckdb
29684
- //===----------------------------------------------------------------------===//
29685
- // DuckDB
29686
- //
29687
- // duckdb/parser/expression/conjunction_expression.hpp
29688
- //
29689
- //
29690
- //===----------------------------------------------------------------------===//
29691
29998
 
29692
29999
 
29693
30000
 
29694
30001
 
29695
30002
 
29696
30003
 
29697
- namespace duckdb {
29698
30004
 
29699
- //! Represents a conjunction (AND/OR)
29700
- class ConjunctionExpression : public ParsedExpression {
29701
- public:
29702
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
29703
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
29704
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
29705
- unique_ptr<ParsedExpression> right);
29706
30005
 
29707
- vector<unique_ptr<ParsedExpression>> children;
29708
30006
 
29709
- public:
29710
- void AddExpression(unique_ptr<ParsedExpression> expr);
29711
30007
 
29712
- string ToString() const override;
30008
+ //===----------------------------------------------------------------------===//
30009
+ // DuckDB
30010
+ //
30011
+ // duckdb/parser/parsed_data/create_macro_info.hpp
30012
+ //
30013
+ //
30014
+ //===----------------------------------------------------------------------===//
29713
30015
 
29714
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
29715
30016
 
29716
- unique_ptr<ParsedExpression> Copy() const override;
29717
30017
 
29718
- void Serialize(FieldWriter &writer) const override;
29719
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29720
30018
 
29721
- public:
29722
- template <class T, class BASE>
29723
- static string ToString(const T &entry) {
29724
- string result = "(" + entry.children[0]->ToString();
29725
- for (idx_t i = 1; i < entry.children.size(); i++) {
29726
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
29727
- }
29728
- return result + ")";
29729
- }
29730
- };
29731
- } // namespace duckdb
29732
30019
  //===----------------------------------------------------------------------===//
29733
30020
  // DuckDB
29734
30021
  //
29735
- // duckdb/parser/expression/between_expression.hpp
30022
+ // duckdb/function/macro_function.hpp
29736
30023
  //
29737
30024
  //
29738
30025
  //===----------------------------------------------------------------------===//
@@ -29741,270 +30028,67 @@ public:
29741
30028
 
29742
30029
 
29743
30030
 
30031
+
30032
+
30033
+
30034
+
30035
+
29744
30036
  namespace duckdb {
29745
30037
 
29746
- class BetweenExpression : public ParsedExpression {
30038
+ enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
30039
+
30040
+ class MacroFunction {
29747
30041
  public:
29748
- DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
29749
- unique_ptr<ParsedExpression> upper);
30042
+ MacroFunction(MacroType type);
29750
30043
 
29751
- unique_ptr<ParsedExpression> input;
29752
- unique_ptr<ParsedExpression> lower;
29753
- unique_ptr<ParsedExpression> upper;
30044
+ //! The type
30045
+ MacroType type;
30046
+ //! The positional parameters
30047
+ vector<unique_ptr<ParsedExpression>> parameters;
30048
+ //! The default parameters and their associated values
30049
+ unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
29754
30050
 
29755
30051
  public:
29756
- string ToString() const override;
29757
-
29758
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
30052
+ virtual ~MacroFunction() {
30053
+ }
29759
30054
 
29760
- unique_ptr<ParsedExpression> Copy() const override;
30055
+ void CopyProperties(MacroFunction &other);
29761
30056
 
29762
- void Serialize(FieldWriter &writer) const override;
29763
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30057
+ virtual unique_ptr<MacroFunction> Copy() = 0;
29764
30058
 
29765
- public:
29766
- template <class T, class BASE>
29767
- static string ToString(const T &entry) {
29768
- return "(" + entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " +
29769
- entry.upper->ToString() + ")";
29770
- }
29771
- };
29772
- } // namespace duckdb
29773
- //===----------------------------------------------------------------------===//
29774
- // DuckDB
29775
- //
29776
- // duckdb/parser/expression/cast_expression.hpp
29777
- //
29778
- //
29779
- //===----------------------------------------------------------------------===//
29780
-
29781
-
29782
-
29783
-
29784
-
29785
-
29786
- namespace duckdb {
29787
-
29788
- //! CastExpression represents a type cast from one SQL type to another SQL type
29789
- class CastExpression : public ParsedExpression {
29790
- public:
29791
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
29792
-
29793
- //! The child of the cast expression
29794
- unique_ptr<ParsedExpression> child;
29795
- //! The type to cast to
29796
- LogicalType cast_type;
29797
- //! Whether or not this is a try_cast expression
29798
- bool try_cast;
29799
-
29800
- public:
29801
- string ToString() const override;
29802
-
29803
- static bool Equals(const CastExpression *a, const CastExpression *b);
29804
-
29805
- unique_ptr<ParsedExpression> Copy() const override;
29806
-
29807
- void Serialize(FieldWriter &writer) const override;
29808
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29809
-
29810
- public:
29811
- template <class T, class BASE>
29812
- static string ToString(const T &entry) {
29813
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
29814
- entry.cast_type.ToString() + ")";
29815
- }
29816
- };
29817
- } // namespace duckdb
29818
-
29819
-
29820
- //===----------------------------------------------------------------------===//
29821
- // DuckDB
29822
- //
29823
- // duckdb/parser/expression/case_expression.hpp
29824
- //
29825
- //
29826
- //===----------------------------------------------------------------------===//
29827
-
29828
-
29829
-
29830
-
29831
-
29832
-
29833
- namespace duckdb {
29834
-
29835
- struct CaseCheck {
29836
- unique_ptr<ParsedExpression> when_expr;
29837
- unique_ptr<ParsedExpression> then_expr;
29838
- };
29839
-
29840
- //! The CaseExpression represents a CASE expression in the query
29841
- class CaseExpression : public ParsedExpression {
29842
- public:
29843
- DUCKDB_API CaseExpression();
29844
-
29845
- vector<CaseCheck> case_checks;
29846
- unique_ptr<ParsedExpression> else_expr;
29847
-
29848
- public:
29849
- string ToString() const override;
29850
-
29851
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
29852
-
29853
- unique_ptr<ParsedExpression> Copy() const override;
29854
-
29855
- void Serialize(FieldWriter &writer) const override;
29856
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30059
+ static string ValidateArguments(MacroFunction &macro_function, const string &name,
30060
+ FunctionExpression &function_expr,
30061
+ vector<unique_ptr<ParsedExpression>> &positionals,
30062
+ unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
29857
30063
 
29858
- public:
29859
- template <class T, class BASE>
29860
- static string ToString(const T &entry) {
29861
- string case_str = "CASE ";
29862
- for (auto &check : entry.case_checks) {
29863
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
29864
- case_str += " THEN (" + check.then_expr->ToString() + ")";
29865
- }
29866
- case_str += " ELSE " + entry.else_expr->ToString();
29867
- case_str += " END";
29868
- return case_str;
29869
- }
30064
+ virtual string ToSQL(const string &schema, const string &name);
29870
30065
  };
29871
- } // namespace duckdb
29872
-
29873
-
29874
- //===----------------------------------------------------------------------===//
29875
- // DuckDB
29876
- //
29877
- // duckdb/parser/expression/collate_expression.hpp
29878
- //
29879
- //
29880
- //===----------------------------------------------------------------------===//
29881
30066
 
29882
-
29883
-
29884
-
29885
-
29886
- namespace duckdb {
29887
-
29888
- //! CollateExpression represents a COLLATE statement
29889
- class CollateExpression : public ParsedExpression {
29890
- public:
29891
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
29892
-
29893
- //! The child of the cast expression
29894
- unique_ptr<ParsedExpression> child;
29895
- //! The collation clause
29896
- string collation;
29897
-
29898
- public:
29899
- string ToString() const override;
29900
-
29901
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
29902
-
29903
- unique_ptr<ParsedExpression> Copy() const override;
29904
-
29905
- void Serialize(FieldWriter &writer) const override;
29906
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29907
- };
29908
30067
  } // namespace duckdb
29909
30068
 
29910
30069
 
29911
-
29912
-
29913
- //===----------------------------------------------------------------------===//
29914
- // DuckDB
29915
- //
29916
- // duckdb/parser/expression/constant_expression.hpp
29917
- //
29918
- //
29919
- //===----------------------------------------------------------------------===//
29920
-
29921
-
29922
-
29923
-
29924
-
29925
-
29926
30070
  namespace duckdb {
29927
30071
 
29928
- //! ConstantExpression represents a constant value in the query
29929
- class ConstantExpression : public ParsedExpression {
29930
- public:
29931
- DUCKDB_API explicit ConstantExpression(Value val);
29932
-
29933
- //! The constant value referenced
29934
- Value value;
29935
-
29936
- public:
29937
- string ToString() const override;
29938
-
29939
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
29940
- hash_t Hash() const override;
29941
-
29942
- unique_ptr<ParsedExpression> Copy() const override;
29943
-
29944
- void Serialize(FieldWriter &writer) const override;
29945
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
29946
- };
29947
-
29948
- } // namespace duckdb
29949
-
29950
-
29951
-
29952
-
29953
-
29954
-
29955
-
29956
-
29957
- //===----------------------------------------------------------------------===//
29958
- // DuckDB
29959
- //
29960
- // duckdb/parser/expression/subquery_expression.hpp
29961
- //
29962
- //
29963
- //===----------------------------------------------------------------------===//
29964
-
29965
-
29966
-
29967
-
29968
-
29969
-
29970
-
29971
- namespace duckdb {
30072
+ struct CreateMacroInfo : public CreateFunctionInfo {
30073
+ CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
30074
+ }
29972
30075
 
29973
- //! Represents a subquery
29974
- class SubqueryExpression : public ParsedExpression {
29975
- public:
29976
- SubqueryExpression();
30076
+ CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
30077
+ }
29977
30078
 
29978
- //! The actual subquery
29979
- unique_ptr<SelectStatement> subquery;
29980
- //! The subquery type
29981
- SubqueryType subquery_type;
29982
- //! the child expression to compare with (in case of IN, ANY, ALL operators, empty for EXISTS queries and scalar
29983
- //! subquery)
29984
- unique_ptr<ParsedExpression> child;
29985
- //! The comparison type of the child expression with the subquery (in case of ANY, ALL operators), empty otherwise
29986
- ExpressionType comparison_type;
30079
+ unique_ptr<MacroFunction> function;
29987
30080
 
29988
30081
  public:
29989
- bool HasSubquery() const override {
29990
- return true;
29991
- }
29992
- bool IsScalar() const override {
29993
- return false;
30082
+ unique_ptr<CreateInfo> Copy() const override {
30083
+ auto result = make_unique<CreateMacroInfo>();
30084
+ result->function = function->Copy();
30085
+ result->name = name;
30086
+ CopyProperties(*result);
30087
+ return move(result);
29994
30088
  }
29995
-
29996
- string ToString() const override;
29997
-
29998
- static bool Equals(const SubqueryExpression *a, const SubqueryExpression *b);
29999
-
30000
- unique_ptr<ParsedExpression> Copy() const override;
30001
-
30002
- void Serialize(FieldWriter &writer) const override;
30003
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
30004
30089
  };
30005
- } // namespace duckdb
30006
-
30007
30090
 
30091
+ } // namespace duckdb
30008
30092
  //===----------------------------------------------------------------------===//
30009
30093
  // DuckDB
30010
30094
  //
@@ -30045,45 +30129,7 @@ struct BoundExportData : public ParseInfo {
30045
30129
  //===----------------------------------------------------------------------===//
30046
30130
  // DuckDB
30047
30131
  //
30048
- // duckdb/parser/parsed_data/transaction_info.hpp
30049
- //
30050
- //
30051
- //===----------------------------------------------------------------------===//
30052
-
30053
-
30054
-
30055
-
30056
-
30057
- namespace duckdb {
30058
-
30059
- enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
30060
-
30061
- struct TransactionInfo : public ParseInfo {
30062
- explicit TransactionInfo(TransactionType type) : type(type) {
30063
- }
30064
-
30065
- //! The type of transaction statement
30066
- TransactionType type;
30067
- };
30068
-
30069
- } // namespace duckdb
30070
- //===----------------------------------------------------------------------===//
30071
- // DuckDB
30072
- //
30073
- // duckdb/parser/parsed_data/create_index_info.hpp
30074
- //
30075
- //
30076
- //===----------------------------------------------------------------------===//
30077
-
30078
-
30079
-
30080
-
30081
-
30082
-
30083
- //===----------------------------------------------------------------------===//
30084
- // DuckDB
30085
- //
30086
- // duckdb/parser/tableref/basetableref.hpp
30132
+ // duckdb/parser/parsed_data/drop_info.hpp
30087
30133
  //
30088
30134
  //
30089
30135
  //===----------------------------------------------------------------------===//
@@ -30094,74 +30140,40 @@ struct TransactionInfo : public ParseInfo {
30094
30140
 
30095
30141
 
30096
30142
  namespace duckdb {
30097
- //! Represents a TableReference to a base table in the schema
30098
- class BaseTableRef : public TableRef {
30099
- public:
30100
- BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
30101
- }
30102
-
30103
- //! Schema name
30104
- string schema_name;
30105
- //! Table name
30106
- string table_name;
30107
- //! Aliases for the column names
30108
- vector<string> column_name_alias;
30109
30143
 
30110
- public:
30111
- string ToString() const override;
30112
- bool Equals(const TableRef *other_p) const override;
30113
-
30114
- unique_ptr<TableRef> Copy() override;
30115
-
30116
- //! Serializes a blob into a BaseTableRef
30117
- void Serialize(FieldWriter &serializer) const override;
30118
- //! Deserializes a blob back into a BaseTableRef
30119
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
30120
- };
30121
- } // namespace duckdb
30122
-
30123
-
30124
-
30125
-
30126
- namespace duckdb {
30127
-
30128
- struct CreateIndexInfo : public CreateInfo {
30129
- CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
30144
+ struct DropInfo : public ParseInfo {
30145
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
30130
30146
  }
30131
30147
 
30132
- //! Index Type (e.g., B+-tree, Skip-List, ...)
30133
- IndexType index_type;
30134
- //! Name of the Index
30135
- string index_name;
30136
- //! Index Constraint Type
30137
- IndexConstraintType constraint_type;
30138
- //! The table to create the index on
30139
- unique_ptr<BaseTableRef> table;
30140
- //! Set of expressions to index by
30141
- vector<unique_ptr<ParsedExpression>> expressions;
30142
- vector<unique_ptr<ParsedExpression>> parsed_expressions;
30143
-
30144
- //! Types used for the CREATE INDEX scan
30145
- vector<LogicalType> scan_types;
30146
- //! The names of the columns, used for the CREATE INDEX scan
30147
- vector<string> names;
30148
- //! Column IDs needed for index creation
30149
- vector<column_t> column_ids;
30150
-
30151
- protected:
30152
- void SerializeInternal(Serializer &serializer) const override;
30153
-
30154
- public:
30155
- unique_ptr<CreateInfo> Copy() const override;
30148
+ //! The catalog type to drop
30149
+ CatalogType type;
30150
+ //! Schema name to drop from, if any
30151
+ string schema;
30152
+ //! Element name to drop
30153
+ string name;
30154
+ //! Ignore if the entry does not exist instead of failing
30155
+ bool if_exists = false;
30156
+ //! Cascade drop (drop all dependents instead of throwing an error if there
30157
+ //! are any)
30158
+ bool cascade = false;
30156
30159
 
30157
- static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
30160
+ public:
30161
+ unique_ptr<DropInfo> Copy() const {
30162
+ auto result = make_unique<DropInfo>();
30163
+ result->type = type;
30164
+ result->schema = schema;
30165
+ result->name = name;
30166
+ result->if_exists = if_exists;
30167
+ result->cascade = cascade;
30168
+ return result;
30169
+ }
30158
30170
  };
30159
30171
 
30160
30172
  } // namespace duckdb
30161
30173
  //===----------------------------------------------------------------------===//
30162
30174
  // DuckDB
30163
30175
  //
30164
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
30176
+ // duckdb/parser/parsed_data/transaction_info.hpp
30165
30177
  //
30166
30178
  //
30167
30179
  //===----------------------------------------------------------------------===//
@@ -30170,32 +30182,16 @@ public:
30170
30182
 
30171
30183
 
30172
30184
 
30173
-
30174
30185
  namespace duckdb {
30175
30186
 
30176
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
30177
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
30178
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
30179
- name = function.name;
30180
- functions.AddFunction(move(function));
30181
- }
30187
+ enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
30182
30188
 
30183
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
30184
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
30185
- name = functions.name;
30186
- for (auto &func : functions.functions) {
30187
- func.name = functions.name;
30188
- }
30189
+ struct TransactionInfo : public ParseInfo {
30190
+ explicit TransactionInfo(TransactionType type) : type(type) {
30189
30191
  }
30190
30192
 
30191
- AggregateFunctionSet functions;
30192
-
30193
- public:
30194
- unique_ptr<CreateInfo> Copy() const override {
30195
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
30196
- CopyProperties(*result);
30197
- return move(result);
30198
- }
30193
+ //! The type of transaction statement
30194
+ TransactionType type;
30199
30195
  };
30200
30196
 
30201
30197
  } // namespace duckdb
@@ -30295,6 +30291,51 @@ protected:
30295
30291
  }
30296
30292
  };
30297
30293
 
30294
+ } // namespace duckdb
30295
+ //===----------------------------------------------------------------------===//
30296
+ // DuckDB
30297
+ //
30298
+ // duckdb/parser/parsed_data/create_type_info.hpp
30299
+ //
30300
+ //
30301
+ //===----------------------------------------------------------------------===//
30302
+
30303
+
30304
+
30305
+
30306
+
30307
+
30308
+
30309
+
30310
+ namespace duckdb {
30311
+
30312
+ struct CreateTypeInfo : public CreateInfo {
30313
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
30314
+ }
30315
+ CreateTypeInfo(string name_p, LogicalType type_p)
30316
+ : CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
30317
+ }
30318
+
30319
+ //! Name of the Type
30320
+ string name;
30321
+ //! Logical Type
30322
+ LogicalType type;
30323
+
30324
+ public:
30325
+ unique_ptr<CreateInfo> Copy() const override {
30326
+ auto result = make_unique<CreateTypeInfo>();
30327
+ CopyProperties(*result);
30328
+ result->name = name;
30329
+ result->type = type;
30330
+ return move(result);
30331
+ }
30332
+
30333
+ protected:
30334
+ void SerializeInternal(Serializer &) const override {
30335
+ throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
30336
+ }
30337
+ };
30338
+
30298
30339
  } // namespace duckdb
30299
30340
  //===----------------------------------------------------------------------===//
30300
30341
  // DuckDB
@@ -30335,7 +30376,7 @@ struct ShowSelectInfo : public ParseInfo {
30335
30376
  //===----------------------------------------------------------------------===//
30336
30377
  // DuckDB
30337
30378
  //
30338
- // duckdb/parser/parsed_data/alter_function_info.hpp
30379
+ // duckdb/parser/parsed_data/create_index_info.hpp
30339
30380
  //
30340
30381
  //
30341
30382
  //===----------------------------------------------------------------------===//
@@ -30345,55 +30386,10 @@ struct ShowSelectInfo : public ParseInfo {
30345
30386
 
30346
30387
 
30347
30388
 
30348
-
30349
- namespace duckdb {
30350
-
30351
- //===--------------------------------------------------------------------===//
30352
- // Alter Table
30353
- //===--------------------------------------------------------------------===//
30354
- enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
30355
-
30356
- struct AlterFunctionInfo : public AlterInfo {
30357
- AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
30358
- virtual ~AlterFunctionInfo() override;
30359
-
30360
- AlterFunctionType alter_function_type;
30361
-
30362
- public:
30363
- CatalogType GetCatalogType() const override;
30364
- void Serialize(FieldWriter &writer) const override;
30365
- static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
30366
- };
30367
-
30368
- //===--------------------------------------------------------------------===//
30369
- // AddFunctionOverloadInfo
30370
- //===--------------------------------------------------------------------===//
30371
- struct AddFunctionOverloadInfo : public AlterFunctionInfo {
30372
- AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
30373
- ~AddFunctionOverloadInfo() override;
30374
-
30375
- ScalarFunctionSet new_overloads;
30376
-
30377
- public:
30378
- unique_ptr<AlterInfo> Copy() const override;
30379
- };
30380
-
30381
- } // namespace duckdb
30382
- //===----------------------------------------------------------------------===//
30383
- // DuckDB
30384
- //
30385
- // duckdb/parser/parsed_data/create_macro_info.hpp
30386
- //
30387
- //
30388
- //===----------------------------------------------------------------------===//
30389
-
30390
-
30391
-
30392
-
30393
30389
  //===----------------------------------------------------------------------===//
30394
30390
  // DuckDB
30395
30391
  //
30396
- // duckdb/function/macro_function.hpp
30392
+ // duckdb/parser/tableref/basetableref.hpp
30397
30393
  //
30398
30394
  //
30399
30395
  //===----------------------------------------------------------------------===//
@@ -30403,114 +30399,75 @@ public:
30403
30399
 
30404
30400
 
30405
30401
 
30406
-
30407
-
30408
-
30409
-
30410
30402
  namespace duckdb {
30411
-
30412
- enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO = 2 };
30413
-
30414
- class MacroFunction {
30415
- public:
30416
- MacroFunction(MacroType type);
30417
-
30418
- //! The type
30419
- MacroType type;
30420
- //! The positional parameters
30421
- vector<unique_ptr<ParsedExpression>> parameters;
30422
- //! The default parameters and their associated values
30423
- unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
30424
-
30403
+ //! Represents a TableReference to a base table in the schema
30404
+ class BaseTableRef : public TableRef {
30425
30405
  public:
30426
- virtual ~MacroFunction() {
30406
+ BaseTableRef() : TableRef(TableReferenceType::BASE_TABLE), schema_name(INVALID_SCHEMA) {
30427
30407
  }
30428
30408
 
30429
- void CopyProperties(MacroFunction &other);
30430
-
30431
- virtual unique_ptr<MacroFunction> Copy() = 0;
30432
-
30433
- static string ValidateArguments(MacroFunction &macro_function, const string &name,
30434
- FunctionExpression &function_expr,
30435
- vector<unique_ptr<ParsedExpression>> &positionals,
30436
- unordered_map<string, unique_ptr<ParsedExpression>> &defaults);
30437
-
30438
- virtual string ToSQL(const string &schema, const string &name);
30439
- };
30440
-
30441
- } // namespace duckdb
30442
-
30443
-
30444
- namespace duckdb {
30445
-
30446
- struct CreateMacroInfo : public CreateFunctionInfo {
30447
- CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
30448
- }
30409
+ //! Schema name
30410
+ string schema_name;
30411
+ //! Table name
30412
+ string table_name;
30413
+ //! Aliases for the column names
30414
+ vector<string> column_name_alias;
30449
30415
 
30450
- CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
30451
- }
30416
+ public:
30417
+ string ToString() const override;
30418
+ bool Equals(const TableRef *other_p) const override;
30452
30419
 
30453
- unique_ptr<MacroFunction> function;
30420
+ unique_ptr<TableRef> Copy() override;
30454
30421
 
30455
- public:
30456
- unique_ptr<CreateInfo> Copy() const override {
30457
- auto result = make_unique<CreateMacroInfo>();
30458
- result->function = function->Copy();
30459
- result->name = name;
30460
- CopyProperties(*result);
30461
- return move(result);
30462
- }
30422
+ //! Serializes a blob into a BaseTableRef
30423
+ void Serialize(FieldWriter &serializer) const override;
30424
+ //! Deserializes a blob back into a BaseTableRef
30425
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
30463
30426
  };
30464
-
30465
30427
  } // namespace duckdb
30466
- //===----------------------------------------------------------------------===//
30467
- // DuckDB
30468
- //
30469
- // duckdb/parser/parsed_data/drop_info.hpp
30470
- //
30471
- //
30472
- //===----------------------------------------------------------------------===//
30473
-
30474
-
30475
30428
 
30476
30429
 
30477
30430
 
30478
30431
 
30479
30432
  namespace duckdb {
30480
30433
 
30481
- struct DropInfo : public ParseInfo {
30482
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
30434
+ struct CreateIndexInfo : public CreateInfo {
30435
+ CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY) {
30483
30436
  }
30484
30437
 
30485
- //! The catalog type to drop
30486
- CatalogType type;
30487
- //! Schema name to drop from, if any
30488
- string schema;
30489
- //! Element name to drop
30490
- string name;
30491
- //! Ignore if the entry does not exist instead of failing
30492
- bool if_exists = false;
30493
- //! Cascade drop (drop all dependents instead of throwing an error if there
30494
- //! are any)
30495
- bool cascade = false;
30438
+ //! Index Type (e.g., B+-tree, Skip-List, ...)
30439
+ IndexType index_type;
30440
+ //! Name of the Index
30441
+ string index_name;
30442
+ //! Index Constraint Type
30443
+ IndexConstraintType constraint_type;
30444
+ //! The table to create the index on
30445
+ unique_ptr<BaseTableRef> table;
30446
+ //! Set of expressions to index by
30447
+ vector<unique_ptr<ParsedExpression>> expressions;
30448
+ vector<unique_ptr<ParsedExpression>> parsed_expressions;
30449
+
30450
+ //! Types used for the CREATE INDEX scan
30451
+ vector<LogicalType> scan_types;
30452
+ //! The names of the columns, used for the CREATE INDEX scan
30453
+ vector<string> names;
30454
+ //! Column IDs needed for index creation
30455
+ vector<column_t> column_ids;
30456
+
30457
+ protected:
30458
+ void SerializeInternal(Serializer &serializer) const override;
30496
30459
 
30497
30460
  public:
30498
- unique_ptr<DropInfo> Copy() const {
30499
- auto result = make_unique<DropInfo>();
30500
- result->type = type;
30501
- result->schema = schema;
30502
- result->name = name;
30503
- result->if_exists = if_exists;
30504
- result->cascade = cascade;
30505
- return result;
30506
- }
30461
+ unique_ptr<CreateInfo> Copy() const override;
30462
+
30463
+ static unique_ptr<CreateIndexInfo> Deserialize(Deserializer &deserializer);
30507
30464
  };
30508
30465
 
30509
30466
  } // namespace duckdb
30510
30467
  //===----------------------------------------------------------------------===//
30511
30468
  // DuckDB
30512
30469
  //
30513
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
30470
+ // duckdb/parser/parsed_data/alter_function_info.hpp
30514
30471
  //
30515
30472
  //
30516
30473
  //===----------------------------------------------------------------------===//
@@ -30520,27 +30477,37 @@ public:
30520
30477
 
30521
30478
 
30522
30479
 
30480
+
30523
30481
  namespace duckdb {
30524
30482
 
30525
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
30526
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
30527
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(function.name) {
30528
- name = function.name;
30529
- functions.AddFunction(move(function));
30530
- }
30531
- CreatePragmaFunctionInfo(string name, PragmaFunctionSet functions_)
30532
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(functions_) {
30533
- this->name = name;
30534
- }
30483
+ //===--------------------------------------------------------------------===//
30484
+ // Alter Table
30485
+ //===--------------------------------------------------------------------===//
30486
+ enum class AlterFunctionType : uint8_t { INVALID = 0, ADD_FUNCTION_OVERLOADS = 1 };
30535
30487
 
30536
- PragmaFunctionSet functions;
30488
+ struct AlterFunctionInfo : public AlterInfo {
30489
+ AlterFunctionInfo(AlterFunctionType type, string schema, string name, bool if_exists);
30490
+ virtual ~AlterFunctionInfo() override;
30491
+
30492
+ AlterFunctionType alter_function_type;
30537
30493
 
30538
30494
  public:
30539
- unique_ptr<CreateInfo> Copy() const override {
30540
- auto result = make_unique<CreatePragmaFunctionInfo>(functions.name, functions);
30541
- CopyProperties(*result);
30542
- return move(result);
30543
- }
30495
+ CatalogType GetCatalogType() const override;
30496
+ void Serialize(FieldWriter &writer) const override;
30497
+ static unique_ptr<AlterInfo> Deserialize(FieldReader &reader);
30498
+ };
30499
+
30500
+ //===--------------------------------------------------------------------===//
30501
+ // AddFunctionOverloadInfo
30502
+ //===--------------------------------------------------------------------===//
30503
+ struct AddFunctionOverloadInfo : public AlterFunctionInfo {
30504
+ AddFunctionOverloadInfo(string schema, string name, bool if_exists, ScalarFunctionSet new_overloads);
30505
+ ~AddFunctionOverloadInfo() override;
30506
+
30507
+ ScalarFunctionSet new_overloads;
30508
+
30509
+ public:
30510
+ unique_ptr<AlterInfo> Copy() const override;
30544
30511
  };
30545
30512
 
30546
30513
  } // namespace duckdb
@@ -30645,6 +30612,84 @@ public:
30645
30612
  vector<string> columns;
30646
30613
  };
30647
30614
 
30615
+ } // namespace duckdb
30616
+ //===----------------------------------------------------------------------===//
30617
+ // DuckDB
30618
+ //
30619
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
30620
+ //
30621
+ //
30622
+ //===----------------------------------------------------------------------===//
30623
+
30624
+
30625
+
30626
+
30627
+
30628
+
30629
+ namespace duckdb {
30630
+
30631
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
30632
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
30633
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(function.name) {
30634
+ name = function.name;
30635
+ functions.AddFunction(move(function));
30636
+ }
30637
+ CreatePragmaFunctionInfo(string name, PragmaFunctionSet functions_)
30638
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(functions_) {
30639
+ this->name = name;
30640
+ }
30641
+
30642
+ PragmaFunctionSet functions;
30643
+
30644
+ public:
30645
+ unique_ptr<CreateInfo> Copy() const override {
30646
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions.name, functions);
30647
+ CopyProperties(*result);
30648
+ return move(result);
30649
+ }
30650
+ };
30651
+
30652
+ } // namespace duckdb
30653
+ //===----------------------------------------------------------------------===//
30654
+ // DuckDB
30655
+ //
30656
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
30657
+ //
30658
+ //
30659
+ //===----------------------------------------------------------------------===//
30660
+
30661
+
30662
+
30663
+
30664
+
30665
+
30666
+ namespace duckdb {
30667
+
30668
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
30669
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
30670
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
30671
+ name = function.name;
30672
+ functions.AddFunction(move(function));
30673
+ }
30674
+
30675
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
30676
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
30677
+ name = functions.name;
30678
+ for (auto &func : functions.functions) {
30679
+ func.name = functions.name;
30680
+ }
30681
+ }
30682
+
30683
+ AggregateFunctionSet functions;
30684
+
30685
+ public:
30686
+ unique_ptr<CreateInfo> Copy() const override {
30687
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
30688
+ CopyProperties(*result);
30689
+ return move(result);
30690
+ }
30691
+ };
30692
+
30648
30693
  } // namespace duckdb
30649
30694
  //===----------------------------------------------------------------------===//
30650
30695
  // DuckDB
@@ -30733,7 +30778,7 @@ protected:
30733
30778
  //===----------------------------------------------------------------------===//
30734
30779
  // DuckDB
30735
30780
  //
30736
- // duckdb/parser/parsed_data/create_type_info.hpp
30781
+ // duckdb/parser/tableref/crossproductref.hpp
30737
30782
  //
30738
30783
  //
30739
30784
  //===----------------------------------------------------------------------===//
@@ -30742,38 +30787,29 @@ protected:
30742
30787
 
30743
30788
 
30744
30789
 
30745
-
30746
-
30747
-
30748
30790
  namespace duckdb {
30749
-
30750
- struct CreateTypeInfo : public CreateInfo {
30751
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
30752
- }
30753
- CreateTypeInfo(string name_p, LogicalType type_p)
30754
- : CreateInfo(CatalogType::TYPE_ENTRY), name(move(name_p)), type(move(type_p)) {
30791
+ //! Represents a cross product
30792
+ class CrossProductRef : public TableRef {
30793
+ public:
30794
+ CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
30755
30795
  }
30756
30796
 
30757
- //! Name of the Type
30758
- string name;
30759
- //! Logical Type
30760
- LogicalType type;
30797
+ //! The left hand side of the cross product
30798
+ unique_ptr<TableRef> left;
30799
+ //! The right hand side of the cross product
30800
+ unique_ptr<TableRef> right;
30761
30801
 
30762
30802
  public:
30763
- unique_ptr<CreateInfo> Copy() const override {
30764
- auto result = make_unique<CreateTypeInfo>();
30765
- CopyProperties(*result);
30766
- result->name = name;
30767
- result->type = type;
30768
- return move(result);
30769
- }
30803
+ string ToString() const override;
30804
+ bool Equals(const TableRef *other_p) const override;
30770
30805
 
30771
- protected:
30772
- void SerializeInternal(Serializer &) const override {
30773
- throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
30774
- }
30775
- };
30806
+ unique_ptr<TableRef> Copy() override;
30776
30807
 
30808
+ //! Serializes a blob into a CrossProductRef
30809
+ void Serialize(FieldWriter &serializer) const override;
30810
+ //! Deserializes a blob back into a CrossProductRef
30811
+ static unique_ptr<TableRef> Deserialize(FieldReader &source);
30812
+ };
30777
30813
  } // namespace duckdb
30778
30814
  //===----------------------------------------------------------------------===//
30779
30815
  // DuckDB
@@ -30814,54 +30850,6 @@ public:
30814
30850
  //===----------------------------------------------------------------------===//
30815
30851
  // DuckDB
30816
30852
  //
30817
- // duckdb/parser/tableref/joinref.hpp
30818
- //
30819
- //
30820
- //===----------------------------------------------------------------------===//
30821
-
30822
-
30823
-
30824
-
30825
-
30826
-
30827
-
30828
-
30829
-
30830
- namespace duckdb {
30831
- //! Represents a JOIN between two expressions
30832
- class JoinRef : public TableRef {
30833
- public:
30834
- JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
30835
- }
30836
-
30837
- //! The left hand side of the join
30838
- unique_ptr<TableRef> left;
30839
- //! The right hand side of the join
30840
- unique_ptr<TableRef> right;
30841
- //! The join condition
30842
- unique_ptr<ParsedExpression> condition;
30843
- //! The join type
30844
- JoinType type;
30845
- //! Natural join
30846
- bool is_natural;
30847
- //! The set of USING columns (if any)
30848
- vector<string> using_columns;
30849
-
30850
- public:
30851
- string ToString() const override;
30852
- bool Equals(const TableRef *other_p) const override;
30853
-
30854
- unique_ptr<TableRef> Copy() override;
30855
-
30856
- //! Serializes a blob into a JoinRef
30857
- void Serialize(FieldWriter &serializer) const override;
30858
- //! Deserializes a blob back into a JoinRef
30859
- static unique_ptr<TableRef> Deserialize(FieldReader &source);
30860
- };
30861
- } // namespace duckdb
30862
- //===----------------------------------------------------------------------===//
30863
- // DuckDB
30864
- //
30865
30853
  // duckdb/parser/tableref/table_function_ref.hpp
30866
30854
  //
30867
30855
  //
@@ -30906,7 +30894,7 @@ public:
30906
30894
  //===----------------------------------------------------------------------===//
30907
30895
  // DuckDB
30908
30896
  //
30909
- // duckdb/parser/tableref/crossproductref.hpp
30897
+ // duckdb/parser/tableref/joinref.hpp
30910
30898
  //
30911
30899
  //
30912
30900
  //===----------------------------------------------------------------------===//
@@ -30915,17 +30903,29 @@ public:
30915
30903
 
30916
30904
 
30917
30905
 
30906
+
30907
+
30908
+
30909
+
30918
30910
  namespace duckdb {
30919
- //! Represents a cross product
30920
- class CrossProductRef : public TableRef {
30911
+ //! Represents a JOIN between two expressions
30912
+ class JoinRef : public TableRef {
30921
30913
  public:
30922
- CrossProductRef() : TableRef(TableReferenceType::CROSS_PRODUCT) {
30914
+ JoinRef() : TableRef(TableReferenceType::JOIN), is_natural(false) {
30923
30915
  }
30924
30916
 
30925
- //! The left hand side of the cross product
30917
+ //! The left hand side of the join
30926
30918
  unique_ptr<TableRef> left;
30927
- //! The right hand side of the cross product
30919
+ //! The right hand side of the join
30928
30920
  unique_ptr<TableRef> right;
30921
+ //! The join condition
30922
+ unique_ptr<ParsedExpression> condition;
30923
+ //! The join type
30924
+ JoinType type;
30925
+ //! Natural join
30926
+ bool is_natural;
30927
+ //! The set of USING columns (if any)
30928
+ vector<string> using_columns;
30929
30929
 
30930
30930
  public:
30931
30931
  string ToString() const override;
@@ -30933,9 +30933,9 @@ public:
30933
30933
 
30934
30934
  unique_ptr<TableRef> Copy() override;
30935
30935
 
30936
- //! Serializes a blob into a CrossProductRef
30936
+ //! Serializes a blob into a JoinRef
30937
30937
  void Serialize(FieldWriter &serializer) const override;
30938
- //! Deserializes a blob back into a CrossProductRef
30938
+ //! Deserializes a blob back into a JoinRef
30939
30939
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
30940
30940
  };
30941
30941
  } // namespace duckdb