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