duckdb 0.3.5-dev22.0 → 0.3.5-dev230.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 "339bd4003"
15
- #define DUCKDB_VERSION "v0.3.5-dev22"
14
+ #define DUCKDB_SOURCE_ID "991d06596"
15
+ #define DUCKDB_VERSION "v0.3.5-dev230"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -2789,7 +2789,7 @@ public:
2789
2789
  DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
2790
2790
  //! Create an empty list with the specified child-type
2791
2791
  DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
2792
- //! Creat a map value from a (key, value) pair
2792
+ //! Create a map value from a (key, value) pair
2793
2793
  DUCKDB_API static Value MAP(Value key, Value value);
2794
2794
 
2795
2795
  //! Create a blob Value from a data pointer and a length: no bytes are interpreted
@@ -2882,6 +2882,8 @@ public:
2882
2882
  //! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
2883
2883
  //! function, NULL values are equivalent and floating point values that are close are equivalent.
2884
2884
  DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
2885
+ //! Returns true if the values are not distinct from each other, following SQL semantics for NOT DISTINCT FROM.
2886
+ DUCKDB_API static bool NotDistinctFrom(const Value &lvalue, const Value &rvalue);
2885
2887
 
2886
2888
  friend std::ostream &operator<<(std::ostream &out, const Value &val) {
2887
2889
  out << val.ToString();
@@ -3094,6 +3096,8 @@ template <>
3094
3096
  DUCKDB_API timestamp_t Value::GetValue() const;
3095
3097
  template <>
3096
3098
  DUCKDB_API interval_t Value::GetValue() const;
3099
+ template <>
3100
+ DUCKDB_API Value Value::GetValue() const;
3097
3101
 
3098
3102
  template <>
3099
3103
  DUCKDB_API bool Value::GetValueUnsafe() const;
@@ -5315,195 +5319,6 @@ using std::chrono::system_clock;
5315
5319
  using std::chrono::time_point;
5316
5320
  } // namespace duckdb
5317
5321
 
5318
- //===----------------------------------------------------------------------===//
5319
- // DuckDB
5320
- //
5321
- // duckdb/common/random_engine.hpp
5322
- //
5323
- //
5324
- //===----------------------------------------------------------------------===//
5325
-
5326
-
5327
-
5328
-
5329
- //===----------------------------------------------------------------------===//
5330
- // DuckDB
5331
- //
5332
- // duckdb/common/limits.hpp
5333
- //
5334
- //
5335
- //===----------------------------------------------------------------------===//
5336
-
5337
-
5338
-
5339
-
5340
-
5341
- namespace duckdb {
5342
-
5343
- template <class T>
5344
- struct NumericLimits {
5345
- static T Minimum();
5346
- static T Maximum();
5347
- static bool IsSigned();
5348
- static idx_t Digits();
5349
- };
5350
-
5351
- template <>
5352
- struct NumericLimits<int8_t> {
5353
- static int8_t Minimum();
5354
- static int8_t Maximum();
5355
- static bool IsSigned() {
5356
- return true;
5357
- }
5358
- static idx_t Digits() {
5359
- return 3;
5360
- }
5361
- };
5362
- template <>
5363
- struct NumericLimits<int16_t> {
5364
- static int16_t Minimum();
5365
- static int16_t Maximum();
5366
- static bool IsSigned() {
5367
- return true;
5368
- }
5369
- static idx_t Digits() {
5370
- return 5;
5371
- }
5372
- };
5373
- template <>
5374
- struct NumericLimits<int32_t> {
5375
- static int32_t Minimum();
5376
- static int32_t Maximum();
5377
- static bool IsSigned() {
5378
- return true;
5379
- }
5380
- static idx_t Digits() {
5381
- return 10;
5382
- }
5383
- };
5384
- template <>
5385
- struct NumericLimits<int64_t> {
5386
- static int64_t Minimum();
5387
- static int64_t Maximum();
5388
- static bool IsSigned() {
5389
- return true;
5390
- }
5391
- static idx_t Digits() {
5392
- return 19;
5393
- }
5394
- };
5395
- template <>
5396
- struct NumericLimits<hugeint_t> {
5397
- static hugeint_t Minimum();
5398
- static hugeint_t Maximum();
5399
- static bool IsSigned() {
5400
- return true;
5401
- }
5402
- static idx_t Digits() {
5403
- return 39;
5404
- }
5405
- };
5406
- template <>
5407
- struct NumericLimits<uint8_t> {
5408
- static uint8_t Minimum();
5409
- static uint8_t Maximum();
5410
- static bool IsSigned() {
5411
- return false;
5412
- }
5413
- static idx_t Digits() {
5414
- return 3;
5415
- }
5416
- };
5417
- template <>
5418
- struct NumericLimits<uint16_t> {
5419
- static uint16_t Minimum();
5420
- static uint16_t Maximum();
5421
- static bool IsSigned() {
5422
- return false;
5423
- }
5424
- static idx_t Digits() {
5425
- return 5;
5426
- }
5427
- };
5428
- template <>
5429
- struct NumericLimits<uint32_t> {
5430
- static uint32_t Minimum();
5431
- static uint32_t Maximum();
5432
- static bool IsSigned() {
5433
- return false;
5434
- }
5435
- static idx_t Digits() {
5436
- return 10;
5437
- }
5438
- };
5439
- template <>
5440
- struct NumericLimits<uint64_t> {
5441
- static uint64_t Minimum();
5442
- static uint64_t Maximum();
5443
- static bool IsSigned() {
5444
- return false;
5445
- }
5446
- static idx_t Digits() {
5447
- return 20;
5448
- }
5449
- };
5450
- template <>
5451
- struct NumericLimits<float> {
5452
- static float Minimum();
5453
- static float Maximum();
5454
- static bool IsSigned() {
5455
- return true;
5456
- }
5457
- static idx_t Digits() {
5458
- return 127;
5459
- }
5460
- };
5461
- template <>
5462
- struct NumericLimits<double> {
5463
- static double Minimum();
5464
- static double Maximum();
5465
- static bool IsSigned() {
5466
- return true;
5467
- }
5468
- static idx_t Digits() {
5469
- return 250;
5470
- }
5471
- };
5472
-
5473
- } // namespace duckdb
5474
-
5475
- #include <random>
5476
-
5477
- namespace duckdb {
5478
-
5479
- struct RandomEngine {
5480
- std::mt19937 random_engine;
5481
- RandomEngine(int64_t seed = -1) {
5482
- if (seed < 0) {
5483
- std::random_device rd;
5484
- random_engine.seed(rd());
5485
- } else {
5486
- random_engine.seed(seed);
5487
- }
5488
- }
5489
-
5490
- //! Generate a random number between min and max
5491
- double NextRandom(double min, double max) {
5492
- std::uniform_real_distribution<double> dist(min, max);
5493
- return dist(random_engine);
5494
- }
5495
- //! Generate a random number between 0 and 1
5496
- double NextRandom() {
5497
- return NextRandom(0, 1);
5498
- }
5499
- uint32_t NextRandomInteger() {
5500
- std::uniform_int_distribution<uint32_t> dist(0, NumericLimits<uint32_t>::Maximum());
5501
- return dist(random_engine);
5502
- }
5503
- };
5504
-
5505
- } // namespace duckdb
5506
-
5507
5322
 
5508
5323
  namespace duckdb {
5509
5324
 
@@ -5561,7 +5376,6 @@ private:
5561
5376
 
5562
5377
  } // namespace duckdb
5563
5378
 
5564
-
5565
5379
  //===----------------------------------------------------------------------===//
5566
5380
  // DuckDB
5567
5381
  //
@@ -6137,7 +5951,7 @@ public:
6137
5951
  static bool RequiresQuotes(const string &text);
6138
5952
 
6139
5953
  //! Writes a string that is optionally quoted + escaped so it can be used as an identifier
6140
- static string WriteOptionallyQuoted(const string &text);
5954
+ static string WriteOptionallyQuoted(const string &text, char quote = '"');
6141
5955
  };
6142
5956
 
6143
5957
  } // namespace duckdb
@@ -6390,14 +6204,19 @@ struct PragmaInfo;
6390
6204
  struct FunctionData {
6391
6205
  DUCKDB_API virtual ~FunctionData();
6392
6206
 
6393
- DUCKDB_API virtual unique_ptr<FunctionData> Copy();
6394
- DUCKDB_API virtual bool Equals(FunctionData &other);
6395
- DUCKDB_API static bool Equals(FunctionData *left, FunctionData *right);
6207
+ DUCKDB_API virtual unique_ptr<FunctionData> Copy() const = 0;
6208
+ DUCKDB_API virtual bool Equals(const FunctionData &other) const = 0;
6209
+ DUCKDB_API static bool Equals(const FunctionData *left, const FunctionData *right);
6396
6210
  };
6397
6211
 
6398
6212
  struct TableFunctionData : public FunctionData {
6399
6213
  // used to pass on projections to table functions that support them. NB, can contain COLUMN_IDENTIFIER_ROW_ID
6400
6214
  vector<idx_t> column_ids;
6215
+
6216
+ DUCKDB_API virtual ~TableFunctionData();
6217
+
6218
+ DUCKDB_API unique_ptr<FunctionData> Copy() const override;
6219
+ DUCKDB_API bool Equals(const FunctionData &other) const override;
6401
6220
  };
6402
6221
 
6403
6222
  struct FunctionParameters {
@@ -6427,11 +6246,14 @@ public:
6427
6246
  //! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
6428
6247
  //! returns DConstants::INVALID_INDEX and sets error if none could be found
6429
6248
  DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
6430
- vector<LogicalType> &arguments, string &error);
6249
+ vector<LogicalType> &arguments, string &error, bool &cast_parameters);
6431
6250
  DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
6432
- vector<unique_ptr<Expression>> &arguments, string &error);
6251
+ vector<unique_ptr<Expression>> &arguments, string &error,
6252
+ bool &cast_parameters);
6433
6253
  //! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
6434
6254
  //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
6255
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
6256
+ vector<LogicalType> &arguments, string &error, bool &cast_parameters);
6435
6257
  DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
6436
6258
  vector<LogicalType> &arguments, string &error);
6437
6259
  DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
@@ -6477,10 +6299,6 @@ public:
6477
6299
  public:
6478
6300
  DUCKDB_API string ToString() override;
6479
6301
  DUCKDB_API bool HasNamedParameters();
6480
-
6481
- DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
6482
- named_parameter_map_t &named_parameters,
6483
- vector<unique_ptr<ParsedExpression>> &children);
6484
6302
  };
6485
6303
 
6486
6304
  class BaseScalarFunction : public SimpleFunction {
@@ -6502,7 +6320,8 @@ public:
6502
6320
  DUCKDB_API hash_t Hash() const;
6503
6321
 
6504
6322
  //! Cast a set of expressions to the arguments of this function
6505
- DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
6323
+ DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children,
6324
+ bool cast_parameter_expressions = true);
6506
6325
 
6507
6326
  DUCKDB_API string ToString() override;
6508
6327
  };
@@ -6574,6 +6393,7 @@ namespace duckdb {
6574
6393
  class Expression;
6575
6394
  class ExpressionExecutor;
6576
6395
  struct ExpressionExecutorState;
6396
+ struct FunctionLocalState;
6577
6397
 
6578
6398
  struct ExpressionState {
6579
6399
  ExpressionState(const Expression &expr, ExpressionExecutorState &root);
@@ -6594,13 +6414,13 @@ public:
6594
6414
  };
6595
6415
 
6596
6416
  struct ExecuteFunctionState : public ExpressionState {
6597
- ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root) : ExpressionState(expr, root) {
6598
- }
6417
+ ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root);
6418
+ ~ExecuteFunctionState();
6599
6419
 
6600
- unique_ptr<FunctionData> local_state;
6420
+ unique_ptr<FunctionLocalState> local_state;
6601
6421
 
6602
6422
  public:
6603
- static FunctionData *GetFunctionState(ExpressionState &state) {
6423
+ static FunctionLocalState *GetFunctionState(ExpressionState &state) {
6604
6424
  return ((ExecuteFunctionState &)state).local_state.get();
6605
6425
  }
6606
6426
  };
@@ -6651,61 +6471,206 @@ struct ExpressionExecutorState {
6651
6471
 
6652
6472
 
6653
6473
 
6474
+ //===----------------------------------------------------------------------===//
6475
+ // DuckDB
6476
+ //
6477
+ // duckdb/common/limits.hpp
6478
+ //
6479
+ //
6480
+ //===----------------------------------------------------------------------===//
6654
6481
 
6655
6482
 
6656
6483
 
6657
- namespace duckdb {
6658
6484
 
6659
- //! The Hugeint class contains static operations for the INT128 type
6660
- class Hugeint {
6661
- public:
6662
- //! Convert a string to a hugeint object
6663
- static bool FromString(string str, hugeint_t &result);
6664
- //! Convert a string to a hugeint object
6665
- static bool FromCString(const char *str, idx_t len, hugeint_t &result);
6666
- //! Convert a hugeint object to a string
6667
- static string ToString(hugeint_t input);
6668
6485
 
6669
- static hugeint_t FromString(string str) {
6670
- hugeint_t result;
6671
- FromString(str, result);
6672
- return result;
6673
- }
6486
+ namespace duckdb {
6674
6487
 
6675
- template <class T>
6676
- static bool TryCast(hugeint_t input, T &result);
6488
+ template <class T>
6489
+ struct NumericLimits {
6490
+ static T Minimum();
6491
+ static T Maximum();
6492
+ static bool IsSigned();
6493
+ static idx_t Digits();
6494
+ };
6677
6495
 
6678
- template <class T>
6679
- static T Cast(hugeint_t input) {
6680
- T value;
6681
- TryCast(input, value);
6682
- return value;
6496
+ template <>
6497
+ struct NumericLimits<int8_t> {
6498
+ static int8_t Minimum();
6499
+ static int8_t Maximum();
6500
+ static bool IsSigned() {
6501
+ return true;
6683
6502
  }
6684
-
6685
- template <class T>
6686
- static bool TryConvert(T value, hugeint_t &result);
6687
-
6688
- template <class T>
6689
- static hugeint_t Convert(T value) {
6690
- hugeint_t result;
6691
- if (!TryConvert(value, result)) { // LCOV_EXCL_START
6692
- throw ValueOutOfRangeException(double(value), GetTypeId<T>(), GetTypeId<hugeint_t>());
6693
- } // LCOV_EXCL_STOP
6694
- return result;
6503
+ static idx_t Digits() {
6504
+ return 3;
6695
6505
  }
6696
-
6697
- static void NegateInPlace(hugeint_t &input) {
6698
- input.lower = NumericLimits<uint64_t>::Maximum() - input.lower + 1;
6699
- input.upper = -1 - input.upper + (input.lower == 0);
6506
+ };
6507
+ template <>
6508
+ struct NumericLimits<int16_t> {
6509
+ static int16_t Minimum();
6510
+ static int16_t Maximum();
6511
+ static bool IsSigned() {
6512
+ return true;
6700
6513
  }
6701
- static hugeint_t Negate(hugeint_t input) {
6702
- NegateInPlace(input);
6703
- return input;
6514
+ static idx_t Digits() {
6515
+ return 5;
6704
6516
  }
6705
-
6706
- static bool TryMultiply(hugeint_t lhs, hugeint_t rhs, hugeint_t &result);
6707
-
6708
- static hugeint_t Add(hugeint_t lhs, hugeint_t rhs);
6517
+ };
6518
+ template <>
6519
+ struct NumericLimits<int32_t> {
6520
+ static int32_t Minimum();
6521
+ static int32_t Maximum();
6522
+ static bool IsSigned() {
6523
+ return true;
6524
+ }
6525
+ static idx_t Digits() {
6526
+ return 10;
6527
+ }
6528
+ };
6529
+ template <>
6530
+ struct NumericLimits<int64_t> {
6531
+ static int64_t Minimum();
6532
+ static int64_t Maximum();
6533
+ static bool IsSigned() {
6534
+ return true;
6535
+ }
6536
+ static idx_t Digits() {
6537
+ return 19;
6538
+ }
6539
+ };
6540
+ template <>
6541
+ struct NumericLimits<hugeint_t> {
6542
+ static hugeint_t Minimum();
6543
+ static hugeint_t Maximum();
6544
+ static bool IsSigned() {
6545
+ return true;
6546
+ }
6547
+ static idx_t Digits() {
6548
+ return 39;
6549
+ }
6550
+ };
6551
+ template <>
6552
+ struct NumericLimits<uint8_t> {
6553
+ static uint8_t Minimum();
6554
+ static uint8_t Maximum();
6555
+ static bool IsSigned() {
6556
+ return false;
6557
+ }
6558
+ static idx_t Digits() {
6559
+ return 3;
6560
+ }
6561
+ };
6562
+ template <>
6563
+ struct NumericLimits<uint16_t> {
6564
+ static uint16_t Minimum();
6565
+ static uint16_t Maximum();
6566
+ static bool IsSigned() {
6567
+ return false;
6568
+ }
6569
+ static idx_t Digits() {
6570
+ return 5;
6571
+ }
6572
+ };
6573
+ template <>
6574
+ struct NumericLimits<uint32_t> {
6575
+ static uint32_t Minimum();
6576
+ static uint32_t Maximum();
6577
+ static bool IsSigned() {
6578
+ return false;
6579
+ }
6580
+ static idx_t Digits() {
6581
+ return 10;
6582
+ }
6583
+ };
6584
+ template <>
6585
+ struct NumericLimits<uint64_t> {
6586
+ static uint64_t Minimum();
6587
+ static uint64_t Maximum();
6588
+ static bool IsSigned() {
6589
+ return false;
6590
+ }
6591
+ static idx_t Digits() {
6592
+ return 20;
6593
+ }
6594
+ };
6595
+ template <>
6596
+ struct NumericLimits<float> {
6597
+ static float Minimum();
6598
+ static float Maximum();
6599
+ static bool IsSigned() {
6600
+ return true;
6601
+ }
6602
+ static idx_t Digits() {
6603
+ return 127;
6604
+ }
6605
+ };
6606
+ template <>
6607
+ struct NumericLimits<double> {
6608
+ static double Minimum();
6609
+ static double Maximum();
6610
+ static bool IsSigned() {
6611
+ return true;
6612
+ }
6613
+ static idx_t Digits() {
6614
+ return 250;
6615
+ }
6616
+ };
6617
+
6618
+ } // namespace duckdb
6619
+
6620
+
6621
+
6622
+ namespace duckdb {
6623
+
6624
+ //! The Hugeint class contains static operations for the INT128 type
6625
+ class Hugeint {
6626
+ public:
6627
+ //! Convert a string to a hugeint object
6628
+ static bool FromString(string str, hugeint_t &result);
6629
+ //! Convert a string to a hugeint object
6630
+ static bool FromCString(const char *str, idx_t len, hugeint_t &result);
6631
+ //! Convert a hugeint object to a string
6632
+ static string ToString(hugeint_t input);
6633
+
6634
+ static hugeint_t FromString(string str) {
6635
+ hugeint_t result;
6636
+ FromString(str, result);
6637
+ return result;
6638
+ }
6639
+
6640
+ template <class T>
6641
+ static bool TryCast(hugeint_t input, T &result);
6642
+
6643
+ template <class T>
6644
+ static T Cast(hugeint_t input) {
6645
+ T value;
6646
+ TryCast(input, value);
6647
+ return value;
6648
+ }
6649
+
6650
+ template <class T>
6651
+ static bool TryConvert(T value, hugeint_t &result);
6652
+
6653
+ template <class T>
6654
+ static hugeint_t Convert(T value) {
6655
+ hugeint_t result;
6656
+ if (!TryConvert(value, result)) { // LCOV_EXCL_START
6657
+ throw ValueOutOfRangeException(double(value), GetTypeId<T>(), GetTypeId<hugeint_t>());
6658
+ } // LCOV_EXCL_STOP
6659
+ return result;
6660
+ }
6661
+
6662
+ static void NegateInPlace(hugeint_t &input) {
6663
+ input.lower = NumericLimits<uint64_t>::Maximum() - input.lower + 1;
6664
+ input.upper = -1 - input.upper + (input.lower == 0);
6665
+ }
6666
+ static hugeint_t Negate(hugeint_t input) {
6667
+ NegateInPlace(input);
6668
+ return input;
6669
+ }
6670
+
6671
+ static bool TryMultiply(hugeint_t lhs, hugeint_t rhs, hugeint_t &result);
6672
+
6673
+ static hugeint_t Add(hugeint_t lhs, hugeint_t rhs);
6709
6674
  static hugeint_t Subtract(hugeint_t lhs, hugeint_t rhs);
6710
6675
  static hugeint_t Multiply(hugeint_t lhs, hugeint_t rhs);
6711
6676
  static hugeint_t Divide(hugeint_t lhs, hugeint_t rhs);
@@ -7235,6 +7200,11 @@ public:
7235
7200
 
7236
7201
 
7237
7202
  namespace duckdb {
7203
+
7204
+ struct FunctionLocalState {
7205
+ DUCKDB_API virtual ~FunctionLocalState();
7206
+ };
7207
+
7238
7208
  class BoundFunctionExpression;
7239
7209
  class ScalarFunctionCatalogEntry;
7240
7210
 
@@ -7243,7 +7213,8 @@ typedef std::function<void(DataChunk &, ExpressionState &, Vector &)> scalar_fun
7243
7213
  //! Binds the scalar function and creates the function data
7244
7214
  typedef unique_ptr<FunctionData> (*bind_scalar_function_t)(ClientContext &context, ScalarFunction &bound_function,
7245
7215
  vector<unique_ptr<Expression>> &arguments);
7246
- typedef unique_ptr<FunctionData> (*init_local_state_t)(const BoundFunctionExpression &expr, FunctionData *bind_data);
7216
+ typedef unique_ptr<FunctionLocalState> (*init_local_state_t)(const BoundFunctionExpression &expr,
7217
+ FunctionData *bind_data);
7247
7218
  typedef unique_ptr<BaseStatistics> (*function_statistics_t)(ClientContext &context, BoundFunctionExpression &expr,
7248
7219
  FunctionData *bind_data,
7249
7220
  vector<unique_ptr<BaseStatistics>> &child_stats);
@@ -7285,10 +7256,9 @@ public:
7285
7256
  vector<unique_ptr<Expression>> children,
7286
7257
  string &error, bool is_operator = false);
7287
7258
 
7288
- DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
7289
- ScalarFunction bound_function,
7290
- vector<unique_ptr<Expression>> children,
7291
- bool is_operator = false);
7259
+ DUCKDB_API static unique_ptr<BoundFunctionExpression>
7260
+ BindScalarFunction(ClientContext &context, ScalarFunction bound_function, vector<unique_ptr<Expression>> children,
7261
+ bool is_operator = false, bool cast_parameters = true);
7292
7262
 
7293
7263
  DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
7294
7264
  DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
@@ -7716,13 +7686,13 @@ public:
7716
7686
  }
7717
7687
 
7718
7688
  template <class STATE_TYPE, class OP>
7719
- static void Combine(Vector &source, Vector &target, idx_t count) {
7689
+ static void Combine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
7720
7690
  D_ASSERT(source.GetType().id() == LogicalTypeId::POINTER && target.GetType().id() == LogicalTypeId::POINTER);
7721
7691
  auto sdata = FlatVector::GetData<const STATE_TYPE *>(source);
7722
7692
  auto tdata = FlatVector::GetData<STATE_TYPE *>(target);
7723
7693
 
7724
7694
  for (idx_t i = 0; i < count; i++) {
7725
- OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i]);
7695
+ OP::template Combine<STATE_TYPE, OP>(*sdata[i], tdata[i], bind_data);
7726
7696
  }
7727
7697
  }
7728
7698
 
@@ -8953,8 +8923,8 @@ typedef void (*aggregate_initialize_t)(data_ptr_t state);
8953
8923
  //! The type used for updating hashed aggregate functions
8954
8924
  typedef void (*aggregate_update_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, Vector &state,
8955
8925
  idx_t count);
8956
- //! The type used for combining hashed aggregate states (optional)
8957
- typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, idx_t count);
8926
+ //! The type used for combining hashed aggregate states
8927
+ typedef void (*aggregate_combine_t)(Vector &state, Vector &combined, FunctionData *bind_data, idx_t count);
8958
8928
  //! The type used for finalizing hashed aggregate function payloads
8959
8929
  typedef void (*aggregate_finalize_t)(Vector &state, FunctionData *bind_data, Vector &result, idx_t count, idx_t offset);
8960
8930
  //! The type used for propagating statistics in aggregate functions (optional)
@@ -9058,7 +9028,8 @@ public:
9058
9028
  DUCKDB_API static unique_ptr<BoundAggregateExpression>
9059
9029
  BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
9060
9030
  vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
9061
- bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr);
9031
+ bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr,
9032
+ bool cast_parameters = true);
9062
9033
 
9063
9034
  DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
9064
9035
  vector<unique_ptr<Expression>> &children,
@@ -9164,8 +9135,8 @@ public:
9164
9135
  }
9165
9136
 
9166
9137
  template <class STATE, class OP>
9167
- static void StateCombine(Vector &source, Vector &target, idx_t count) {
9168
- AggregateExecutor::Combine<STATE, OP>(source, target, count);
9138
+ static void StateCombine(Vector &source, Vector &target, FunctionData *bind_data, idx_t count) {
9139
+ AggregateExecutor::Combine<STATE, OP>(source, target, bind_data, count);
9169
9140
  }
9170
9141
 
9171
9142
  template <class STATE, class RESULT_TYPE, class OP>
@@ -13147,9 +13118,6 @@ public:
13147
13118
  static bool ContainsType(const LogicalType &type, LogicalTypeId target);
13148
13119
  static LogicalType ExchangeType(const LogicalType &type, LogicalTypeId target, LogicalType new_type);
13149
13120
 
13150
- static void ResolveParameterType(LogicalType &type);
13151
- static void ResolveParameterType(unique_ptr<Expression> &expr);
13152
-
13153
13121
  //! Bind the given expresion. Unlike Bind(), this does *not* mute the given ParsedExpression.
13154
13122
  //! Exposed to be used from sub-binders that aren't subclasses of ExpressionBinder.
13155
13123
  virtual BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
@@ -13171,7 +13139,6 @@ protected:
13171
13139
  BindResult BindExpression(OperatorExpression &expr, idx_t depth);
13172
13140
  BindResult BindExpression(ParameterExpression &expr, idx_t depth);
13173
13141
  BindResult BindExpression(PositionalReferenceExpression &ref, idx_t depth);
13174
- BindResult BindExpression(StarExpression &expr, idx_t depth);
13175
13142
  BindResult BindExpression(SubqueryExpression &expr, idx_t depth);
13176
13143
 
13177
13144
  protected:
@@ -13483,6 +13450,8 @@ public:
13483
13450
  vector<CorrelatedColumnInfo> correlated_columns;
13484
13451
  //! The set of parameter expressions bound by this binder
13485
13452
  vector<BoundParameterExpression *> *parameters;
13453
+ //! The types of the prepared statement parameters, if any
13454
+ vector<LogicalType> *parameter_types;
13486
13455
  //! Whether or not the bound statement is read-only
13487
13456
  bool read_only;
13488
13457
  //! Whether or not the statement requires a valid transaction to run
@@ -13781,6 +13750,7 @@ public:
13781
13750
 
13782
13751
 
13783
13752
  namespace duckdb {
13753
+
13784
13754
  //! SQLStatement is the base class of any type of SQL statement.
13785
13755
  class SQLStatement {
13786
13756
  public:
@@ -13803,6 +13773,9 @@ protected:
13803
13773
  SQLStatement(const SQLStatement &other) = default;
13804
13774
 
13805
13775
  public:
13776
+ virtual string ToString() const {
13777
+ throw InternalException("ToString not supported for this type of SQLStatement");
13778
+ }
13806
13779
  //! Create a copy of this SelectStatement
13807
13780
  virtual unique_ptr<SQLStatement> Copy() const = 0;
13808
13781
  };
@@ -13907,7 +13880,9 @@ public:
13907
13880
 
13908
13881
  public:
13909
13882
  //! Convert the object to a string
13910
- virtual string ToString() const;
13883
+ virtual string ToString() const = 0;
13884
+ string BaseToString(string result) const;
13885
+ string BaseToString(string result, const vector<string> &column_name_alias) const;
13911
13886
  void Print();
13912
13887
 
13913
13888
  virtual bool Equals(const TableRef *other) const;
@@ -13944,6 +13919,8 @@ protected:
13944
13919
  SelectStatement(const SelectStatement &other);
13945
13920
 
13946
13921
  public:
13922
+ //! Convert the SELECT statement to a string
13923
+ string ToString() const override;
13947
13924
  //! Create a copy of this SelectStatement
13948
13925
  unique_ptr<SQLStatement> Copy() const override;
13949
13926
  //! Serializes a SelectStatement to a stand-alone binary blob
@@ -13995,6 +13972,9 @@ public:
13995
13972
  virtual const vector<unique_ptr<ParsedExpression>> &GetSelectList() const = 0;
13996
13973
 
13997
13974
  public:
13975
+ //! Convert the query node to a string
13976
+ virtual string ToString() const = 0;
13977
+
13998
13978
  virtual bool Equals(const QueryNode *other) const;
13999
13979
 
14000
13980
  //! Create a copy of this QueryNode
@@ -14006,6 +13986,9 @@ public:
14006
13986
  //! Deserializes a blob back into a QueryNode
14007
13987
  DUCKDB_API static unique_ptr<QueryNode> Deserialize(Deserializer &source);
14008
13988
 
13989
+ string CTEToString() const;
13990
+ string ResultModifiersToString() const;
13991
+
14009
13992
  protected:
14010
13993
  //! Copy base QueryNode properties from another expression to this one,
14011
13994
  //! used in Copy method
@@ -17128,7 +17111,6 @@ private:
17128
17111
  } // namespace duckdb
17129
17112
 
17130
17113
 
17131
- #include <random>
17132
17114
 
17133
17115
  //===----------------------------------------------------------------------===//
17134
17116
  // DuckDB
@@ -17214,6 +17196,27 @@ public:
17214
17196
 
17215
17197
  } // namespace duckdb
17216
17198
 
17199
+ //===----------------------------------------------------------------------===//
17200
+ // DuckDB
17201
+ //
17202
+ // duckdb/main/external_dependencies.hpp
17203
+ //
17204
+ //
17205
+ //===----------------------------------------------------------------------===//
17206
+
17207
+
17208
+
17209
+ namespace duckdb {
17210
+
17211
+ enum ExternalDependenciesType { PYTHON_DEPENDENCY };
17212
+ class ExternalDependency {
17213
+ public:
17214
+ explicit ExternalDependency(ExternalDependenciesType type_p) : type(type_p) {};
17215
+ virtual ~ExternalDependency() {};
17216
+ ExternalDependenciesType type;
17217
+ };
17218
+
17219
+ } // namespace duckdb
17217
17220
 
17218
17221
  namespace duckdb {
17219
17222
  class Appender;
@@ -17227,12 +17230,12 @@ class PreparedStatementData;
17227
17230
  class Relation;
17228
17231
  class BufferedFileWriter;
17229
17232
  class QueryProfiler;
17230
- class QueryProfilerHistory;
17231
17233
  class ClientContextLock;
17232
17234
  struct CreateScalarFunctionInfo;
17233
17235
  class ScalarFunctionCatalogEntry;
17234
17236
  struct ActiveQueryContext;
17235
17237
  struct ParserOptions;
17238
+ struct ClientData;
17236
17239
 
17237
17240
  //! The ClientContext holds information relevant to the current client session
17238
17241
  //! during execution
@@ -17245,31 +17248,19 @@ public:
17245
17248
  DUCKDB_API explicit ClientContext(shared_ptr<DatabaseInstance> db);
17246
17249
  DUCKDB_API ~ClientContext();
17247
17250
 
17248
- //! Query profiler
17249
- shared_ptr<QueryProfiler> profiler;
17250
- //! QueryProfiler History
17251
- unique_ptr<QueryProfilerHistory> query_profiler_history;
17252
17251
  //! The database that this client is connected to
17253
17252
  shared_ptr<DatabaseInstance> db;
17254
17253
  //! Data for the currently running transaction
17255
17254
  TransactionContext transaction;
17256
17255
  //! Whether or not the query is interrupted
17257
17256
  atomic<bool> interrupted;
17258
-
17259
- unique_ptr<SchemaCatalogEntry> temporary_objects;
17260
- unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
17261
-
17262
- //! The writer used to log queries (if logging is enabled)
17263
- unique_ptr<BufferedFileWriter> log_query_writer;
17264
- //! The random generator used by random(). Its seed value can be set by setseed().
17265
- std::mt19937 random_engine;
17266
-
17267
- const unique_ptr<CatalogSearchPath> catalog_search_path;
17268
-
17269
- unique_ptr<FileOpener> file_opener;
17257
+ //! External Objects (e.g., Python objects) that views depend of
17258
+ unordered_map<string, vector<shared_ptr<ExternalDependency>>> external_dependencies;
17270
17259
 
17271
17260
  //! The client configuration
17272
17261
  ClientConfig config;
17262
+ //! The set of client-specific data
17263
+ unique_ptr<ClientData> client_data;
17273
17264
 
17274
17265
  public:
17275
17266
  DUCKDB_API Transaction &ActiveTransaction() {
@@ -17398,7 +17389,8 @@ private:
17398
17389
 
17399
17390
  //! Internally prepare a SQL statement. Caller must hold the context_lock.
17400
17391
  shared_ptr<PreparedStatementData> CreatePreparedStatement(ClientContextLock &lock, const string &query,
17401
- unique_ptr<SQLStatement> statement);
17392
+ unique_ptr<SQLStatement> statement,
17393
+ vector<Value> *values = nullptr);
17402
17394
  unique_ptr<PendingQueryResult> PendingStatementInternal(ClientContextLock &lock, const string &query,
17403
17395
  unique_ptr<SQLStatement> statement);
17404
17396
  unique_ptr<QueryResult> RunStatementInternal(ClientContextLock &lock, const string &query,
@@ -17472,6 +17464,7 @@ private:
17472
17464
  } // namespace duckdb
17473
17465
 
17474
17466
 
17467
+
17475
17468
  #include <memory>
17476
17469
 
17477
17470
  namespace duckdb {
@@ -17483,8 +17476,6 @@ class LogicalOperator;
17483
17476
  class QueryNode;
17484
17477
  class TableRef;
17485
17478
 
17486
- class ExtraDependencies {};
17487
-
17488
17479
  class Relation : public std::enable_shared_from_this<Relation> {
17489
17480
  public:
17490
17481
  DUCKDB_API Relation(const std::shared_ptr<ClientContext> &context, RelationType type)
@@ -17499,7 +17490,7 @@ public:
17499
17490
 
17500
17491
  RelationType type;
17501
17492
 
17502
- unique_ptr<ExtraDependencies> extra_dependencies;
17493
+ shared_ptr<ExternalDependency> extra_dependencies;
17503
17494
 
17504
17495
  public:
17505
17496
  DUCKDB_API virtual const vector<ColumnDefinition> &Columns() = 0;
@@ -17599,6 +17590,7 @@ public:
17599
17590
  DUCKDB_API virtual Relation *ChildRelation() {
17600
17591
  return nullptr;
17601
17592
  }
17593
+ DUCKDB_API vector<shared_ptr<ExternalDependency>> GetAllDependencies();
17602
17594
 
17603
17595
  protected:
17604
17596
  DUCKDB_API string RenderWhitespace(idx_t depth);
@@ -21882,6 +21874,8 @@ public:
21882
21874
 
21883
21875
 
21884
21876
 
21877
+ #include <algorithm>
21878
+
21885
21879
  namespace duckdb {
21886
21880
 
21887
21881
  enum class StrTimeSpecifier : uint8_t {
@@ -21929,7 +21923,11 @@ public:
21929
21923
  virtual ~StrTimeFormat() {
21930
21924
  }
21931
21925
 
21932
- static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
21926
+ DUCKDB_API static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
21927
+
21928
+ inline bool HasFormatSpecifier(StrTimeSpecifier s) const {
21929
+ return std::find(specifiers.begin(), specifiers.end(), s) != specifiers.end();
21930
+ }
21933
21931
 
21934
21932
  protected:
21935
21933
  //! The format specifiers
@@ -21945,13 +21943,13 @@ protected:
21945
21943
 
21946
21944
  protected:
21947
21945
  void AddLiteral(string literal);
21948
- virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
21946
+ DUCKDB_API virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
21949
21947
  };
21950
21948
 
21951
21949
  struct StrfTimeFormat : public StrTimeFormat {
21952
- idx_t GetLength(date_t date, dtime_t time);
21950
+ DUCKDB_API idx_t GetLength(date_t date, dtime_t time, int32_t utc_offset, const char *tz_name);
21953
21951
 
21954
- void FormatString(date_t date, int32_t data[7], char *target);
21952
+ DUCKDB_API void FormatString(date_t date, int32_t data[8], const char *tz_name, char *target);
21955
21953
  void FormatString(date_t date, dtime_t time, char *target);
21956
21954
 
21957
21955
  DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
@@ -21964,8 +21962,9 @@ protected:
21964
21962
  vector<bool> is_date_specifier;
21965
21963
 
21966
21964
  protected:
21967
- void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
21968
- static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time);
21965
+ DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
21966
+ static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time, int32_t utc_offset,
21967
+ const char *tz_name);
21969
21968
  char *WriteString(char *target, const string_t &str);
21970
21969
  char *Write2(char *target, uint8_t value);
21971
21970
  char *WritePadded2(char *target, uint32_t value);
@@ -21973,20 +21972,21 @@ protected:
21973
21972
  char *WritePadded(char *target, uint32_t value, size_t padding);
21974
21973
  bool IsDateSpecifier(StrTimeSpecifier specifier);
21975
21974
  char *WriteDateSpecifier(StrTimeSpecifier specifier, date_t date, char *target);
21976
- char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], char *target);
21975
+ char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], const char *tz_name, char *target);
21977
21976
  };
21978
21977
 
21979
21978
  struct StrpTimeFormat : public StrTimeFormat {
21980
21979
  public:
21981
21980
  //! Type-safe parsing argument
21982
21981
  struct ParseResult {
21983
- int32_t data[7];
21982
+ int32_t data[8]; // year, month, day, hour, min, sec, µs, offset
21983
+ string tz;
21984
21984
  string error_message;
21985
21985
  idx_t error_position = DConstants::INVALID_INDEX;
21986
21986
 
21987
21987
  date_t ToDate();
21988
21988
  timestamp_t ToTimestamp();
21989
- string FormatError(string_t input, const string &format_specifier);
21989
+ DUCKDB_API string FormatError(string_t input, const string &format_specifier);
21990
21990
  };
21991
21991
 
21992
21992
  public:
@@ -21996,7 +21996,7 @@ public:
21996
21996
  public:
21997
21997
  DUCKDB_API static ParseResult Parse(const string &format, const string &text);
21998
21998
 
21999
- bool Parse(string_t str, ParseResult &result);
21999
+ DUCKDB_API bool Parse(string_t str, ParseResult &result);
22000
22000
 
22001
22001
  bool TryParseDate(string_t str, date_t &result, string &error_message);
22002
22002
  bool TryParseTimestamp(string_t str, timestamp_t &result, string &error_message);
@@ -22006,7 +22006,7 @@ public:
22006
22006
 
22007
22007
  protected:
22008
22008
  static string FormatStrpTimeError(const string &input, idx_t position);
22009
- void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
22009
+ DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
22010
22010
  int NumericSpecifierWidth(StrTimeSpecifier specifier);
22011
22011
  int32_t TryParseCollection(const char *data, idx_t &pos, idx_t size, const string_t collection[],
22012
22012
  idx_t collection_count);
@@ -22057,13 +22057,10 @@ struct TextSearchShiftArray {
22057
22057
  };
22058
22058
 
22059
22059
  struct BufferedCSVReaderOptions {
22060
- //! The file path of the CSV file to read
22061
- string file_path;
22062
- //! Whether file is compressed or not, and if so which compression type
22063
- //! AUTO_DETECT (default; infer from file extension)
22064
- FileCompressionType compression = FileCompressionType::AUTO_DETECT;
22065
- //! Whether or not to automatically detect dialect and datatypes
22066
- bool auto_detect = false;
22060
+ //===--------------------------------------------------------------------===//
22061
+ // CommonCSVOptions
22062
+ //===--------------------------------------------------------------------===//
22063
+
22067
22064
  //! Whether or not a delimiter was defined by the user
22068
22065
  bool has_delimiter = false;
22069
22066
  //! Delimiter to separate columns within each line
@@ -22080,26 +22077,51 @@ struct BufferedCSVReaderOptions {
22080
22077
  bool has_header = false;
22081
22078
  //! Whether or not the file has a header line
22082
22079
  bool header = false;
22083
- //! Whether or not header names shall be normalized
22084
- bool normalize_names = false;
22085
- //! How many leading rows to skip
22086
- idx_t skip_rows = 0;
22080
+ //! Whether or not we should ignore InvalidInput errors
22081
+ bool ignore_errors = false;
22087
22082
  //! Expected number of columns
22088
22083
  idx_t num_cols = 0;
22084
+ //! Number of samples to buffer
22085
+ idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
22089
22086
  //! Specifies the string that represents a null value
22090
22087
  string null_str;
22088
+ //! Whether file is compressed or not, and if so which compression type
22089
+ //! AUTO_DETECT (default; infer from file extension)
22090
+ FileCompressionType compression = FileCompressionType::AUTO_DETECT;
22091
+
22092
+ //===--------------------------------------------------------------------===//
22093
+ // ReadCSVOptions
22094
+ //===--------------------------------------------------------------------===//
22095
+
22096
+ //! How many leading rows to skip
22097
+ idx_t skip_rows = 0;
22098
+ //! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
22099
+ idx_t maximum_line_size = 2097152;
22100
+ //! Whether or not header names shall be normalized
22101
+ bool normalize_names = false;
22091
22102
  //! True, if column with that index must skip null check
22092
22103
  vector<bool> force_not_null;
22104
+ //! Consider all columns to be of type varchar
22105
+ bool all_varchar = false;
22093
22106
  //! Size of sample chunk used for dialect and type detection
22094
22107
  idx_t sample_chunk_size = STANDARD_VECTOR_SIZE;
22095
22108
  //! Number of sample chunks used for type detection
22096
22109
  idx_t sample_chunks = 10;
22097
- //! Number of samples to buffer
22098
- idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
22099
- //! Consider all columns to be of type varchar
22100
- bool all_varchar = false;
22101
- //! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
22102
- idx_t maximum_line_size = 2097152;
22110
+ //! Whether or not to automatically detect dialect and datatypes
22111
+ bool auto_detect = false;
22112
+ //! The file path of the CSV file to read
22113
+ string file_path;
22114
+ //! Whether or not to include a file name column
22115
+ bool include_file_name = false;
22116
+
22117
+ //===--------------------------------------------------------------------===//
22118
+ // WriteCSVOptions
22119
+ //===--------------------------------------------------------------------===//
22120
+
22121
+ //! The column names of the columns to write
22122
+ vector<string> names;
22123
+ //! True, if column with that index must be quoted
22124
+ vector<bool> force_quote;
22103
22125
 
22104
22126
  //! The date format to use (if any is specified)
22105
22127
  std::map<LogicalTypeId, StrpTimeFormat> date_format = {{LogicalTypeId::DATE, {}}, {LogicalTypeId::TIMESTAMP, {}}};
@@ -22107,6 +22129,16 @@ struct BufferedCSVReaderOptions {
22107
22129
  std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
22108
22130
 
22109
22131
  void SetDelimiter(const string &delimiter);
22132
+ //! Set an option that is supported by both reading and writing functions, called by
22133
+ //! the SetReadOption and SetWriteOption methods
22134
+ bool SetBaseOption(const string &loption, const Value &value);
22135
+
22136
+ //! loption - lowercase string
22137
+ //! set - argument(s) to the option
22138
+ //! expected_names - names expected if the option is "columns"
22139
+ void SetReadOption(const string &loption, const Value &value, vector<string> &expected_names);
22140
+
22141
+ void SetWriteOption(const string &loption, const Value &value);
22110
22142
 
22111
22143
  std::string ToString() const;
22112
22144
  };
@@ -22232,6 +22264,10 @@ private:
22232
22264
  const vector<LogicalType> &requested_types,
22233
22265
  vector<vector<LogicalType>> &best_sql_types_candidates,
22234
22266
  map<LogicalTypeId, vector<string>> &best_format_candidates);
22267
+
22268
+ private:
22269
+ //! Whether or not the current row's columns have overflown sql_types.size()
22270
+ bool error_column_overflow = false;
22235
22271
  };
22236
22272
 
22237
22273
  } // namespace duckdb
@@ -22421,7 +22457,7 @@ public:
22421
22457
  //===----------------------------------------------------------------------===//
22422
22458
  // DuckDB
22423
22459
  //
22424
- // duckdb/parser/expression/collate_expression.hpp
22460
+ // duckdb/parser/expression/star_expression.hpp
22425
22461
  //
22426
22462
  //
22427
22463
  //===----------------------------------------------------------------------===//
@@ -22430,22 +22466,25 @@ public:
22430
22466
 
22431
22467
 
22432
22468
 
22469
+
22433
22470
  namespace duckdb {
22434
22471
 
22435
- //! CollateExpression represents a COLLATE statement
22436
- class CollateExpression : public ParsedExpression {
22472
+ //! Represents a * expression in the SELECT clause
22473
+ class StarExpression : public ParsedExpression {
22437
22474
  public:
22438
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
22475
+ StarExpression(string relation_name = string());
22439
22476
 
22440
- //! The child of the cast expression
22441
- unique_ptr<ParsedExpression> child;
22442
- //! The collation clause
22443
- string collation;
22477
+ //! The relation name in case of tbl.*, or empty if this is a normal *
22478
+ string relation_name;
22479
+ //! List of columns to exclude from the STAR expression
22480
+ case_insensitive_set_t exclude_list;
22481
+ //! List of columns to replace with another expression
22482
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
22444
22483
 
22445
22484
  public:
22446
22485
  string ToString() const override;
22447
22486
 
22448
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
22487
+ static bool Equals(const StarExpression *a, const StarExpression *b);
22449
22488
 
22450
22489
  unique_ptr<ParsedExpression> Copy() const override;
22451
22490
 
@@ -22456,7 +22495,7 @@ public:
22456
22495
  //===----------------------------------------------------------------------===//
22457
22496
  // DuckDB
22458
22497
  //
22459
- // duckdb/parser/expression/between_expression.hpp
22498
+ // duckdb/parser/expression/default_expression.hpp
22460
22499
  //
22461
22500
  //
22462
22501
  //===----------------------------------------------------------------------===//
@@ -22466,20 +22505,53 @@ public:
22466
22505
 
22467
22506
 
22468
22507
  namespace duckdb {
22508
+ //! Represents the default value of a column
22509
+ class DefaultExpression : public ParsedExpression {
22510
+ public:
22511
+ DefaultExpression();
22469
22512
 
22470
- class BetweenExpression : public ParsedExpression {
22471
22513
  public:
22472
- BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22473
- unique_ptr<ParsedExpression> upper);
22514
+ bool IsScalar() const override {
22515
+ return false;
22516
+ }
22474
22517
 
22475
- unique_ptr<ParsedExpression> input;
22476
- unique_ptr<ParsedExpression> lower;
22477
- unique_ptr<ParsedExpression> upper;
22518
+ string ToString() const override;
22519
+
22520
+ unique_ptr<ParsedExpression> Copy() const override;
22521
+
22522
+ void Serialize(FieldWriter &writer) const override;
22523
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22524
+ };
22525
+ } // namespace duckdb
22526
+ //===----------------------------------------------------------------------===//
22527
+ // DuckDB
22528
+ //
22529
+ // duckdb/parser/expression/operator_expression.hpp
22530
+ //
22531
+ //
22532
+ //===----------------------------------------------------------------------===//
22533
+
22534
+
22535
+
22536
+
22537
+
22538
+
22539
+
22540
+
22541
+ namespace duckdb {
22542
+ //! Represents a built-in operator expression
22543
+ class OperatorExpression : public ParsedExpression {
22544
+ public:
22545
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
22546
+ unique_ptr<ParsedExpression> right = nullptr);
22547
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22548
+
22549
+ vector<unique_ptr<ParsedExpression>> children;
22478
22550
 
22479
22551
  public:
22480
22552
  string ToString() const override;
22481
22553
 
22482
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22554
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
22483
22555
 
22484
22556
  unique_ptr<ParsedExpression> Copy() const override;
22485
22557
 
@@ -22489,16 +22561,72 @@ public:
22489
22561
  public:
22490
22562
  template <class T, class BASE>
22491
22563
  static string ToString(const T &entry) {
22492
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
22564
+ auto op = ExpressionTypeToOperator(entry.type);
22565
+ if (!op.empty()) {
22566
+ // use the operator string to represent the operator
22567
+ D_ASSERT(entry.children.size() == 2);
22568
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
22569
+ }
22570
+ switch (entry.type) {
22571
+ case ExpressionType::COMPARE_IN:
22572
+ case ExpressionType::COMPARE_NOT_IN: {
22573
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
22574
+ string in_child = entry.children[0]->ToString();
22575
+ string child_list = "(";
22576
+ for (idx_t i = 1; i < entry.children.size(); i++) {
22577
+ if (i > 1) {
22578
+ child_list += ", ";
22579
+ }
22580
+ child_list += entry.children[i]->ToString();
22581
+ }
22582
+ child_list += ")";
22583
+ return "(" + in_child + op_type + child_list + ")";
22584
+ }
22585
+ case ExpressionType::OPERATOR_NOT:
22586
+ case ExpressionType::GROUPING_FUNCTION:
22587
+ case ExpressionType::OPERATOR_COALESCE: {
22588
+ string result = ExpressionTypeToString(entry.type);
22589
+ result += "(";
22590
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22591
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
22592
+ result += ")";
22593
+ return result;
22594
+ }
22595
+ case ExpressionType::OPERATOR_IS_NULL:
22596
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
22597
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
22598
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
22599
+ case ExpressionType::ARRAY_EXTRACT:
22600
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
22601
+ case ExpressionType::ARRAY_SLICE:
22602
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
22603
+ entry.children[2]->ToString() + "]";
22604
+ case ExpressionType::STRUCT_EXTRACT: {
22605
+ D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
22606
+ auto child_string = entry.children[1]->ToString();
22607
+ D_ASSERT(child_string.size() >= 3);
22608
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
22609
+ return "(" + entry.children[0]->ToString() + ")." +
22610
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
22611
+ }
22612
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
22613
+ string result = "(ARRAY[";
22614
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22615
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
22616
+ result += "])";
22617
+ return result;
22618
+ }
22619
+ default:
22620
+ throw InternalException("Unrecognized operator type");
22621
+ }
22493
22622
  }
22494
22623
  };
22495
- } // namespace duckdb
22496
-
22497
22624
 
22625
+ } // namespace duckdb
22498
22626
  //===----------------------------------------------------------------------===//
22499
22627
  // DuckDB
22500
22628
  //
22501
- // duckdb/parser/expression/case_expression.hpp
22629
+ // duckdb/parser/expression/conjunction_expression.hpp
22502
22630
  //
22503
22631
  //
22504
22632
  //===----------------------------------------------------------------------===//
@@ -22510,23 +22638,22 @@ public:
22510
22638
 
22511
22639
  namespace duckdb {
22512
22640
 
22513
- struct CaseCheck {
22514
- unique_ptr<ParsedExpression> when_expr;
22515
- unique_ptr<ParsedExpression> then_expr;
22516
- };
22517
-
22518
- //! The CaseExpression represents a CASE expression in the query
22519
- class CaseExpression : public ParsedExpression {
22641
+ //! Represents a conjunction (AND/OR)
22642
+ class ConjunctionExpression : public ParsedExpression {
22520
22643
  public:
22521
- DUCKDB_API CaseExpression();
22644
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22645
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22646
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22647
+ unique_ptr<ParsedExpression> right);
22522
22648
 
22523
- vector<CaseCheck> case_checks;
22524
- unique_ptr<ParsedExpression> else_expr;
22649
+ vector<unique_ptr<ParsedExpression>> children;
22525
22650
 
22526
22651
  public:
22652
+ void AddExpression(unique_ptr<ParsedExpression> expr);
22653
+
22527
22654
  string ToString() const override;
22528
22655
 
22529
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
22656
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22530
22657
 
22531
22658
  unique_ptr<ParsedExpression> Copy() const override;
22532
22659
 
@@ -22536,22 +22663,54 @@ public:
22536
22663
  public:
22537
22664
  template <class T, class BASE>
22538
22665
  static string ToString(const T &entry) {
22539
- string case_str = "CASE ";
22540
- for (auto &check : entry.case_checks) {
22541
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
22542
- case_str += " THEN (" + check.then_expr->ToString() + ")";
22666
+ string result = "(" + entry.children[0]->ToString();
22667
+ for (idx_t i = 1; i < entry.children.size(); i++) {
22668
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22543
22669
  }
22544
- case_str += " ELSE " + entry.else_expr->ToString();
22545
- case_str += " END";
22546
- return case_str;
22670
+ return result + ")";
22547
22671
  }
22548
22672
  };
22549
22673
  } // namespace duckdb
22674
+ //===----------------------------------------------------------------------===//
22675
+ // DuckDB
22676
+ //
22677
+ // duckdb/parser/expression/constant_expression.hpp
22678
+ //
22679
+ //
22680
+ //===----------------------------------------------------------------------===//
22681
+
22682
+
22683
+
22684
+
22685
+
22686
+
22687
+ namespace duckdb {
22688
+
22689
+ //! ConstantExpression represents a constant value in the query
22690
+ class ConstantExpression : public ParsedExpression {
22691
+ public:
22692
+ DUCKDB_API explicit ConstantExpression(Value val);
22693
+
22694
+ //! The constant value referenced
22695
+ Value value;
22696
+
22697
+ public:
22698
+ string ToString() const override;
22550
22699
 
22700
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
22701
+ hash_t Hash() const override;
22702
+
22703
+ unique_ptr<ParsedExpression> Copy() const override;
22704
+
22705
+ void Serialize(FieldWriter &writer) const override;
22706
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22707
+ };
22708
+
22709
+ } // namespace duckdb
22551
22710
  //===----------------------------------------------------------------------===//
22552
22711
  // DuckDB
22553
22712
  //
22554
- // duckdb/parser/expression/cast_expression.hpp
22713
+ // duckdb/parser/expression/case_expression.hpp
22555
22714
  //
22556
22715
  //
22557
22716
  //===----------------------------------------------------------------------===//
@@ -22563,22 +22722,23 @@ public:
22563
22722
 
22564
22723
  namespace duckdb {
22565
22724
 
22566
- //! CastExpression represents a type cast from one SQL type to another SQL type
22567
- class CastExpression : public ParsedExpression {
22725
+ struct CaseCheck {
22726
+ unique_ptr<ParsedExpression> when_expr;
22727
+ unique_ptr<ParsedExpression> then_expr;
22728
+ };
22729
+
22730
+ //! The CaseExpression represents a CASE expression in the query
22731
+ class CaseExpression : public ParsedExpression {
22568
22732
  public:
22569
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
22733
+ DUCKDB_API CaseExpression();
22570
22734
 
22571
- //! The child of the cast expression
22572
- unique_ptr<ParsedExpression> child;
22573
- //! The type to cast to
22574
- LogicalType cast_type;
22575
- //! Whether or not this is a try_cast expression
22576
- bool try_cast;
22735
+ vector<CaseCheck> case_checks;
22736
+ unique_ptr<ParsedExpression> else_expr;
22577
22737
 
22578
22738
  public:
22579
22739
  string ToString() const override;
22580
22740
 
22581
- static bool Equals(const CastExpression *a, const CastExpression *b);
22741
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
22582
22742
 
22583
22743
  unique_ptr<ParsedExpression> Copy() const override;
22584
22744
 
@@ -22588,18 +22748,21 @@ public:
22588
22748
  public:
22589
22749
  template <class T, class BASE>
22590
22750
  static string ToString(const T &entry) {
22591
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
22592
- entry.cast_type.ToString() + ")";
22751
+ string case_str = "CASE ";
22752
+ for (auto &check : entry.case_checks) {
22753
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
22754
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
22755
+ }
22756
+ case_str += " ELSE " + entry.else_expr->ToString();
22757
+ case_str += " END";
22758
+ return case_str;
22593
22759
  }
22594
22760
  };
22595
22761
  } // namespace duckdb
22596
-
22597
-
22598
-
22599
22762
  //===----------------------------------------------------------------------===//
22600
22763
  // DuckDB
22601
22764
  //
22602
- // duckdb/parser/expression/comparison_expression.hpp
22765
+ // duckdb/parser/expression/between_expression.hpp
22603
22766
  //
22604
22767
  //
22605
22768
  //===----------------------------------------------------------------------===//
@@ -22609,20 +22772,20 @@ public:
22609
22772
 
22610
22773
 
22611
22774
  namespace duckdb {
22612
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
22613
- //! and has two children.
22614
- class ComparisonExpression : public ParsedExpression {
22775
+
22776
+ class BetweenExpression : public ParsedExpression {
22615
22777
  public:
22616
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22617
- unique_ptr<ParsedExpression> right);
22778
+ BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22779
+ unique_ptr<ParsedExpression> upper);
22618
22780
 
22619
- unique_ptr<ParsedExpression> left;
22620
- unique_ptr<ParsedExpression> right;
22781
+ unique_ptr<ParsedExpression> input;
22782
+ unique_ptr<ParsedExpression> lower;
22783
+ unique_ptr<ParsedExpression> upper;
22621
22784
 
22622
22785
  public:
22623
22786
  string ToString() const override;
22624
22787
 
22625
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
22788
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22626
22789
 
22627
22790
  unique_ptr<ParsedExpression> Copy() const override;
22628
22791
 
@@ -22632,15 +22795,17 @@ public:
22632
22795
  public:
22633
22796
  template <class T, class BASE>
22634
22797
  static string ToString(const T &entry) {
22635
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
22798
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
22636
22799
  }
22637
22800
  };
22638
22801
  } // namespace duckdb
22639
22802
 
22803
+
22804
+
22640
22805
  //===----------------------------------------------------------------------===//
22641
22806
  // DuckDB
22642
22807
  //
22643
- // duckdb/parser/expression/conjunction_expression.hpp
22808
+ // duckdb/parser/expression/cast_expression.hpp
22644
22809
  //
22645
22810
  //
22646
22811
  //===----------------------------------------------------------------------===//
@@ -22652,22 +22817,22 @@ public:
22652
22817
 
22653
22818
  namespace duckdb {
22654
22819
 
22655
- //! Represents a conjunction (AND/OR)
22656
- class ConjunctionExpression : public ParsedExpression {
22820
+ //! CastExpression represents a type cast from one SQL type to another SQL type
22821
+ class CastExpression : public ParsedExpression {
22657
22822
  public:
22658
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22659
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22660
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22661
- unique_ptr<ParsedExpression> right);
22823
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
22662
22824
 
22663
- vector<unique_ptr<ParsedExpression>> children;
22825
+ //! The child of the cast expression
22826
+ unique_ptr<ParsedExpression> child;
22827
+ //! The type to cast to
22828
+ LogicalType cast_type;
22829
+ //! Whether or not this is a try_cast expression
22830
+ bool try_cast;
22664
22831
 
22665
22832
  public:
22666
- void AddExpression(unique_ptr<ParsedExpression> expr);
22667
-
22668
22833
  string ToString() const override;
22669
22834
 
22670
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22835
+ static bool Equals(const CastExpression *a, const CastExpression *b);
22671
22836
 
22672
22837
  unique_ptr<ParsedExpression> Copy() const override;
22673
22838
 
@@ -22677,11 +22842,8 @@ public:
22677
22842
  public:
22678
22843
  template <class T, class BASE>
22679
22844
  static string ToString(const T &entry) {
22680
- string result = entry.children[0]->ToString();
22681
- for (idx_t i = 1; i < entry.children.size(); i++) {
22682
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22683
- }
22684
- return result;
22845
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
22846
+ entry.cast_type.ToString() + ")";
22685
22847
  }
22686
22848
  };
22687
22849
  } // namespace duckdb
@@ -22689,7 +22851,7 @@ public:
22689
22851
  //===----------------------------------------------------------------------===//
22690
22852
  // DuckDB
22691
22853
  //
22692
- // duckdb/parser/expression/constant_expression.hpp
22854
+ // duckdb/parser/expression/collate_expression.hpp
22693
22855
  //
22694
22856
  //
22695
22857
  //===----------------------------------------------------------------------===//
@@ -22698,35 +22860,35 @@ public:
22698
22860
 
22699
22861
 
22700
22862
 
22701
-
22702
22863
  namespace duckdb {
22703
22864
 
22704
- //! ConstantExpression represents a constant value in the query
22705
- class ConstantExpression : public ParsedExpression {
22865
+ //! CollateExpression represents a COLLATE statement
22866
+ class CollateExpression : public ParsedExpression {
22706
22867
  public:
22707
- DUCKDB_API explicit ConstantExpression(Value val);
22868
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
22708
22869
 
22709
- //! The constant value referenced
22710
- Value value;
22870
+ //! The child of the cast expression
22871
+ unique_ptr<ParsedExpression> child;
22872
+ //! The collation clause
22873
+ string collation;
22711
22874
 
22712
22875
  public:
22713
22876
  string ToString() const override;
22714
22877
 
22715
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
22716
- hash_t Hash() const override;
22878
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
22717
22879
 
22718
22880
  unique_ptr<ParsedExpression> Copy() const override;
22719
22881
 
22720
22882
  void Serialize(FieldWriter &writer) const override;
22721
22883
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22722
22884
  };
22723
-
22724
22885
  } // namespace duckdb
22725
22886
 
22887
+
22726
22888
  //===----------------------------------------------------------------------===//
22727
22889
  // DuckDB
22728
22890
  //
22729
- // duckdb/parser/expression/default_expression.hpp
22891
+ // duckdb/parser/expression/comparison_expression.hpp
22730
22892
  //
22731
22893
  //
22732
22894
  //===----------------------------------------------------------------------===//
@@ -22736,25 +22898,37 @@ public:
22736
22898
 
22737
22899
 
22738
22900
  namespace duckdb {
22739
- //! Represents the default value of a column
22740
- class DefaultExpression : public ParsedExpression {
22901
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
22902
+ //! and has two children.
22903
+ class ComparisonExpression : public ParsedExpression {
22741
22904
  public:
22742
- DefaultExpression();
22905
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22906
+ unique_ptr<ParsedExpression> right);
22743
22907
 
22744
- public:
22745
- bool IsScalar() const override {
22746
- return false;
22747
- }
22908
+ unique_ptr<ParsedExpression> left;
22909
+ unique_ptr<ParsedExpression> right;
22748
22910
 
22911
+ public:
22749
22912
  string ToString() const override;
22750
22913
 
22914
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
22915
+
22751
22916
  unique_ptr<ParsedExpression> Copy() const override;
22752
22917
 
22753
22918
  void Serialize(FieldWriter &writer) const override;
22754
22919
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22920
+
22921
+ public:
22922
+ template <class T, class BASE>
22923
+ static string ToString(const T &entry) {
22924
+ return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
22925
+ }
22755
22926
  };
22756
22927
  } // namespace duckdb
22757
22928
 
22929
+
22930
+
22931
+
22758
22932
  //===----------------------------------------------------------------------===//
22759
22933
  // DuckDB
22760
22934
  //
@@ -22817,7 +22991,7 @@ public:
22817
22991
  template <class T, class BASE>
22818
22992
  static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
22819
22993
  bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
22820
- bool export_state = false) {
22994
+ bool export_state = false, bool add_alias = false) {
22821
22995
  if (is_operator) {
22822
22996
  // built-in operator
22823
22997
  D_ASSERT(!distinct);
@@ -22839,8 +23013,11 @@ public:
22839
23013
  if (distinct) {
22840
23014
  result += "DISTINCT ";
22841
23015
  }
22842
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22843
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23016
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
23017
+ return child->alias.empty() || !add_alias
23018
+ ? child->ToString()
23019
+ : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
23020
+ });
22844
23021
  // ordered aggregate
22845
23022
  if (order_bys && !order_bys->orders.empty()) {
22846
23023
  if (entry.children.empty()) {
@@ -22871,106 +23048,6 @@ public:
22871
23048
  } // namespace duckdb
22872
23049
 
22873
23050
 
22874
- //===----------------------------------------------------------------------===//
22875
- // DuckDB
22876
- //
22877
- // duckdb/parser/expression/operator_expression.hpp
22878
- //
22879
- //
22880
- //===----------------------------------------------------------------------===//
22881
-
22882
-
22883
-
22884
-
22885
-
22886
-
22887
-
22888
-
22889
- namespace duckdb {
22890
- //! Represents a built-in operator expression
22891
- class OperatorExpression : public ParsedExpression {
22892
- public:
22893
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
22894
- unique_ptr<ParsedExpression> right = nullptr);
22895
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22896
-
22897
- vector<unique_ptr<ParsedExpression>> children;
22898
-
22899
- public:
22900
- string ToString() const override;
22901
-
22902
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
22903
-
22904
- unique_ptr<ParsedExpression> Copy() const override;
22905
-
22906
- void Serialize(FieldWriter &writer) const override;
22907
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22908
-
22909
- public:
22910
- template <class T, class BASE>
22911
- static string ToString(const T &entry) {
22912
- auto op = ExpressionTypeToOperator(entry.type);
22913
- if (!op.empty()) {
22914
- // use the operator string to represent the operator
22915
- D_ASSERT(entry.children.size() == 2);
22916
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
22917
- }
22918
- switch (entry.type) {
22919
- case ExpressionType::COMPARE_IN:
22920
- case ExpressionType::COMPARE_NOT_IN: {
22921
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
22922
- string in_child = entry.children[0]->ToString();
22923
- string child_list = "(";
22924
- for (idx_t i = 1; i < entry.children.size(); i++) {
22925
- if (i > 1) {
22926
- child_list += ", ";
22927
- }
22928
- child_list += entry.children[i]->ToString();
22929
- }
22930
- child_list += ")";
22931
- return "(" + in_child + op_type + child_list + ")";
22932
- }
22933
- case ExpressionType::OPERATOR_NOT:
22934
- case ExpressionType::GROUPING_FUNCTION:
22935
- case ExpressionType::OPERATOR_COALESCE: {
22936
- string result = ExpressionTypeToString(entry.type);
22937
- result += "(";
22938
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22939
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22940
- result += ")";
22941
- return result;
22942
- }
22943
- case ExpressionType::OPERATOR_IS_NULL:
22944
- return "(" + entry.children[0]->ToString() + " IS NULL)";
22945
- case ExpressionType::OPERATOR_IS_NOT_NULL:
22946
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
22947
- case ExpressionType::ARRAY_EXTRACT:
22948
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
22949
- case ExpressionType::ARRAY_SLICE:
22950
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
22951
- entry.children[2]->ToString() + "]";
22952
- case ExpressionType::STRUCT_EXTRACT: {
22953
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
22954
- auto child_string = entry.children[1]->ToString();
22955
- D_ASSERT(child_string.size() >= 3);
22956
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
22957
- return "(" + entry.children[0]->ToString() + ")." +
22958
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
22959
- }
22960
- case ExpressionType::ARRAY_CONSTRUCTOR: {
22961
- string result = "ARRAY[";
22962
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22963
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22964
- result += "]";
22965
- return result;
22966
- }
22967
- default:
22968
- throw InternalException("Unrecognized operator type");
22969
- }
22970
- }
22971
- };
22972
-
22973
- } // namespace duckdb
22974
23051
 
22975
23052
  //===----------------------------------------------------------------------===//
22976
23053
  // DuckDB
@@ -23033,56 +23110,18 @@ public:
23033
23110
  return false;
23034
23111
  }
23035
23112
 
23036
- string ToString() const override;
23037
-
23038
- static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
23039
- unique_ptr<ParsedExpression> Copy() const override;
23040
- hash_t Hash() const override;
23041
-
23042
- void Serialize(FieldWriter &writer) const override;
23043
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23044
- };
23045
- } // namespace duckdb
23046
-
23047
- //===----------------------------------------------------------------------===//
23048
- // DuckDB
23049
- //
23050
- // duckdb/parser/expression/star_expression.hpp
23051
- //
23052
- //
23053
- //===----------------------------------------------------------------------===//
23054
-
23055
-
23056
-
23057
-
23058
-
23059
-
23060
- namespace duckdb {
23061
-
23062
- //! Represents a * expression in the SELECT clause
23063
- class StarExpression : public ParsedExpression {
23064
- public:
23065
- StarExpression(string relation_name = string());
23066
-
23067
- //! The relation name in case of tbl.*, or empty if this is a normal *
23068
- string relation_name;
23069
- //! List of columns to exclude from the STAR expression
23070
- case_insensitive_set_t exclude_list;
23071
- //! List of columns to replace with another expression
23072
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23073
-
23074
- public:
23075
- string ToString() const override;
23076
-
23077
- static bool Equals(const StarExpression *a, const StarExpression *b);
23113
+ string ToString() const override;
23078
23114
 
23115
+ static bool Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
23079
23116
  unique_ptr<ParsedExpression> Copy() const override;
23117
+ hash_t Hash() const override;
23080
23118
 
23081
23119
  void Serialize(FieldWriter &writer) const override;
23082
23120
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23083
23121
  };
23084
23122
  } // namespace duckdb
23085
23123
 
23124
+
23086
23125
  //===----------------------------------------------------------------------===//
23087
23126
  // DuckDB
23088
23127
  //
@@ -23137,7 +23176,7 @@ public:
23137
23176
  //===----------------------------------------------------------------------===//
23138
23177
  // DuckDB
23139
23178
  //
23140
- // duckdb/parser/parsed_data/create_collation_info.hpp
23179
+ // duckdb/parser/parsed_data/export_table_data.hpp
23141
23180
  //
23142
23181
  //
23143
23182
  //===----------------------------------------------------------------------===//
@@ -23149,112 +23188,24 @@ public:
23149
23188
 
23150
23189
  namespace duckdb {
23151
23190
 
23152
- struct CreateCollationInfo : public CreateInfo {
23153
- CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
23154
- : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
23155
- not_required_for_equality(not_required_for_equality_p) {
23156
- this->name = move(name_p);
23157
- }
23158
-
23159
- //! The name of the collation
23160
- string name;
23161
- //! The collation function to push in case collation is required
23162
- ScalarFunction function;
23163
- //! Whether or not the collation can be combined with other collations.
23164
- bool combinable;
23165
- //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
23166
- //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
23167
- //! speeds up processing.
23168
- bool not_required_for_equality;
23169
-
23170
- public:
23171
- unique_ptr<CreateInfo> Copy() const override {
23172
- auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
23173
- CopyProperties(*result);
23174
- return move(result);
23175
- }
23176
- };
23177
-
23178
- } // namespace duckdb
23179
- //===----------------------------------------------------------------------===//
23180
- // DuckDB
23181
- //
23182
- // duckdb/parser/parsed_data/create_schema_info.hpp
23183
- //
23184
- //
23185
- //===----------------------------------------------------------------------===//
23186
-
23187
-
23188
-
23189
-
23190
-
23191
- namespace duckdb {
23191
+ struct ExportedTableData {
23192
+ //! Name of the exported table
23193
+ string table_name;
23192
23194
 
23193
- struct CreateSchemaInfo : public CreateInfo {
23194
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
23195
- }
23195
+ //! Name of the schema
23196
+ string schema_name;
23196
23197
 
23197
- public:
23198
- unique_ptr<CreateInfo> Copy() const override {
23199
- auto result = make_unique<CreateSchemaInfo>();
23200
- CopyProperties(*result);
23201
- return move(result);
23202
- }
23198
+ //! Path to be exported
23199
+ string file_path;
23203
23200
  };
23204
23201
 
23205
- } // namespace duckdb
23206
- //===----------------------------------------------------------------------===//
23207
- // DuckDB
23208
- //
23209
- // duckdb/parser/parsed_data/show_select_info.hpp
23210
- //
23211
- //
23212
- //===----------------------------------------------------------------------===//
23213
-
23214
-
23215
-
23216
-
23217
-
23218
-
23219
- namespace duckdb {
23220
-
23221
- struct ShowSelectInfo : public ParseInfo {
23222
- //! Types of projected columns
23223
- vector<LogicalType> types;
23224
- //! The QueryNode of select query
23225
- unique_ptr<QueryNode> query;
23226
- //! Aliases of projected columns
23227
- vector<string> aliases;
23228
- //! Whether or not we are requesting a summary or a describe
23229
- bool is_summary;
23230
-
23231
- unique_ptr<ShowSelectInfo> Copy() {
23232
- auto result = make_unique<ShowSelectInfo>();
23233
- result->types = types;
23234
- result->query = query->Copy();
23235
- result->aliases = aliases;
23236
- result->is_summary = is_summary;
23237
- return result;
23238
- }
23202
+ struct ExportedTableInfo {
23203
+ TableCatalogEntry *entry;
23204
+ ExportedTableData table_data;
23239
23205
  };
23240
23206
 
23241
- } // namespace duckdb
23242
- //===----------------------------------------------------------------------===//
23243
- // DuckDB
23244
- //
23245
- // duckdb/parser/parsed_data/vacuum_info.hpp
23246
- //
23247
- //
23248
- //===----------------------------------------------------------------------===//
23249
-
23250
-
23251
-
23252
-
23253
-
23254
- namespace duckdb {
23255
-
23256
- struct VacuumInfo : public ParseInfo {
23257
- // nothing for now
23207
+ struct BoundExportData : public ParseInfo {
23208
+ std::vector<ExportedTableInfo> data;
23258
23209
  };
23259
23210
 
23260
23211
  } // namespace duckdb
@@ -23345,6 +23296,129 @@ public:
23345
23296
  }
23346
23297
  };
23347
23298
 
23299
+ } // namespace duckdb
23300
+ //===----------------------------------------------------------------------===//
23301
+ // DuckDB
23302
+ //
23303
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23304
+ //
23305
+ //
23306
+ //===----------------------------------------------------------------------===//
23307
+
23308
+
23309
+
23310
+
23311
+
23312
+
23313
+ namespace duckdb {
23314
+
23315
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23316
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
23317
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23318
+ this->name = function.name;
23319
+ functions.AddFunction(move(function));
23320
+ }
23321
+
23322
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23323
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23324
+ this->name = functions.name;
23325
+ for (auto &func : functions.functions) {
23326
+ func.name = functions.name;
23327
+ }
23328
+ }
23329
+
23330
+ AggregateFunctionSet functions;
23331
+
23332
+ public:
23333
+ unique_ptr<CreateInfo> Copy() const override {
23334
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23335
+ CopyProperties(*result);
23336
+ return move(result);
23337
+ }
23338
+ };
23339
+
23340
+ } // namespace duckdb
23341
+ //===----------------------------------------------------------------------===//
23342
+ // DuckDB
23343
+ //
23344
+ // duckdb/parser/parsed_data/create_collation_info.hpp
23345
+ //
23346
+ //
23347
+ //===----------------------------------------------------------------------===//
23348
+
23349
+
23350
+
23351
+
23352
+
23353
+
23354
+ namespace duckdb {
23355
+
23356
+ struct CreateCollationInfo : public CreateInfo {
23357
+ CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
23358
+ : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
23359
+ not_required_for_equality(not_required_for_equality_p) {
23360
+ this->name = move(name_p);
23361
+ }
23362
+
23363
+ //! The name of the collation
23364
+ string name;
23365
+ //! The collation function to push in case collation is required
23366
+ ScalarFunction function;
23367
+ //! Whether or not the collation can be combined with other collations.
23368
+ bool combinable;
23369
+ //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
23370
+ //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
23371
+ //! speeds up processing.
23372
+ bool not_required_for_equality;
23373
+
23374
+ public:
23375
+ unique_ptr<CreateInfo> Copy() const override {
23376
+ auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
23377
+ CopyProperties(*result);
23378
+ return move(result);
23379
+ }
23380
+ };
23381
+
23382
+ } // namespace duckdb
23383
+ //===----------------------------------------------------------------------===//
23384
+ // DuckDB
23385
+ //
23386
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23387
+ //
23388
+ //
23389
+ //===----------------------------------------------------------------------===//
23390
+
23391
+
23392
+
23393
+
23394
+
23395
+
23396
+ namespace duckdb {
23397
+
23398
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23399
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
23400
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23401
+ functions.push_back(move(function));
23402
+ this->name = function.name;
23403
+ }
23404
+ CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23405
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23406
+ this->name = name;
23407
+ for (auto &function : functions) {
23408
+ function.name = name;
23409
+ }
23410
+ }
23411
+
23412
+ vector<PragmaFunction> functions;
23413
+
23414
+ public:
23415
+ unique_ptr<CreateInfo> Copy() const override {
23416
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23417
+ CopyProperties(*result);
23418
+ return move(result);
23419
+ }
23420
+ };
23421
+
23348
23422
  } // namespace duckdb
23349
23423
  //===----------------------------------------------------------------------===//
23350
23424
  // DuckDB
@@ -23374,7 +23448,7 @@ struct TransactionInfo : public ParseInfo {
23374
23448
  //===----------------------------------------------------------------------===//
23375
23449
  // DuckDB
23376
23450
  //
23377
- // duckdb/parser/parsed_data/create_type_info.hpp
23451
+ // duckdb/parser/parsed_data/drop_info.hpp
23378
23452
  //
23379
23453
  //
23380
23454
  //===----------------------------------------------------------------------===//
@@ -23384,27 +23458,33 @@ struct TransactionInfo : public ParseInfo {
23384
23458
 
23385
23459
 
23386
23460
 
23387
-
23388
-
23389
23461
  namespace duckdb {
23390
23462
 
23391
- struct CreateTypeInfo : public CreateInfo {
23392
-
23393
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23463
+ struct DropInfo : public ParseInfo {
23464
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23394
23465
  }
23395
23466
 
23396
- //! Name of the Type
23467
+ //! The catalog type to drop
23468
+ CatalogType type;
23469
+ //! Schema name to drop from, if any
23470
+ string schema;
23471
+ //! Element name to drop
23397
23472
  string name;
23398
- //! Logical Type
23399
- LogicalType type;
23473
+ //! Ignore if the entry does not exist instead of failing
23474
+ bool if_exists = false;
23475
+ //! Cascade drop (drop all dependents instead of throwing an error if there
23476
+ //! are any)
23477
+ bool cascade = false;
23400
23478
 
23401
23479
  public:
23402
- unique_ptr<CreateInfo> Copy() const override {
23403
- auto result = make_unique<CreateTypeInfo>();
23404
- CopyProperties(*result);
23405
- result->name = name;
23480
+ unique_ptr<DropInfo> Copy() const {
23481
+ auto result = make_unique<DropInfo>();
23406
23482
  result->type = type;
23407
- return move(result);
23483
+ result->schema = schema;
23484
+ result->name = name;
23485
+ result->if_exists = if_exists;
23486
+ result->cascade = cascade;
23487
+ return result;
23408
23488
  }
23409
23489
  };
23410
23490
 
@@ -23412,7 +23492,7 @@ public:
23412
23492
  //===----------------------------------------------------------------------===//
23413
23493
  // DuckDB
23414
23494
  //
23415
- // duckdb/parser/parsed_data/create_view_info.hpp
23495
+ // duckdb/parser/parsed_data/create_schema_info.hpp
23416
23496
  //
23417
23497
  //
23418
23498
  //===----------------------------------------------------------------------===//
@@ -23421,32 +23501,16 @@ public:
23421
23501
 
23422
23502
 
23423
23503
 
23424
-
23425
23504
  namespace duckdb {
23426
23505
 
23427
- struct CreateViewInfo : public CreateInfo {
23428
- CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
23429
- }
23430
- CreateViewInfo(string schema, string view_name)
23431
- : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
23506
+ struct CreateSchemaInfo : public CreateInfo {
23507
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
23432
23508
  }
23433
23509
 
23434
- //! Table name to insert to
23435
- string view_name;
23436
- //! Aliases of the view
23437
- vector<string> aliases;
23438
- //! Return types
23439
- vector<LogicalType> types;
23440
- //! The SelectStatement of the view
23441
- unique_ptr<SelectStatement> query;
23442
-
23443
23510
  public:
23444
23511
  unique_ptr<CreateInfo> Copy() const override {
23445
- auto result = make_unique<CreateViewInfo>(schema, view_name);
23512
+ auto result = make_unique<CreateSchemaInfo>();
23446
23513
  CopyProperties(*result);
23447
- result->aliases = aliases;
23448
- result->types = types;
23449
- result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
23450
23514
  return move(result);
23451
23515
  }
23452
23516
  };
@@ -23539,7 +23603,7 @@ public:
23539
23603
  //===----------------------------------------------------------------------===//
23540
23604
  // DuckDB
23541
23605
  //
23542
- // duckdb/parser/parsed_data/export_table_data.hpp
23606
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23543
23607
  //
23544
23608
  //
23545
23609
  //===----------------------------------------------------------------------===//
@@ -23548,34 +23612,28 @@ public:
23548
23612
 
23549
23613
 
23550
23614
 
23551
-
23552
23615
  namespace duckdb {
23553
23616
 
23554
- struct ExportedTableData {
23555
- //! Name of the exported table
23556
- string table_name;
23557
-
23558
- //! Name of the schema
23559
- string schema_name;
23560
-
23561
- //! Path to be exported
23562
- string file_path;
23563
- };
23617
+ enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23564
23618
 
23565
- struct ExportedTableInfo {
23566
- TableCatalogEntry *entry;
23567
- ExportedTableData table_data;
23568
- };
23619
+ struct LoadInfo : public ParseInfo {
23620
+ std::string filename;
23621
+ LoadType load_type;
23569
23622
 
23570
- struct BoundExportData : public ParseInfo {
23571
- std::vector<ExportedTableInfo> data;
23623
+ public:
23624
+ unique_ptr<LoadInfo> Copy() const {
23625
+ auto result = make_unique<LoadInfo>();
23626
+ result->filename = filename;
23627
+ result->load_type = load_type;
23628
+ return result;
23629
+ }
23572
23630
  };
23573
23631
 
23574
23632
  } // namespace duckdb
23575
23633
  //===----------------------------------------------------------------------===//
23576
23634
  // DuckDB
23577
23635
  //
23578
- // duckdb/parser/parsed_data/vacuum_info.hpp
23636
+ // duckdb/parser/parsed_data/create_type_info.hpp
23579
23637
  //
23580
23638
  //
23581
23639
  //===----------------------------------------------------------------------===//
@@ -23584,20 +23642,28 @@ struct BoundExportData : public ParseInfo {
23584
23642
 
23585
23643
 
23586
23644
 
23645
+
23646
+
23647
+
23587
23648
  namespace duckdb {
23588
23649
 
23589
- enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23650
+ struct CreateTypeInfo : public CreateInfo {
23590
23651
 
23591
- struct LoadInfo : public ParseInfo {
23592
- std::string filename;
23593
- LoadType load_type;
23652
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23653
+ }
23654
+
23655
+ //! Name of the Type
23656
+ string name;
23657
+ //! Logical Type
23658
+ LogicalType type;
23594
23659
 
23595
23660
  public:
23596
- unique_ptr<LoadInfo> Copy() const {
23597
- auto result = make_unique<LoadInfo>();
23598
- result->filename = filename;
23599
- result->load_type = load_type;
23600
- return result;
23661
+ unique_ptr<CreateInfo> Copy() const override {
23662
+ auto result = make_unique<CreateTypeInfo>();
23663
+ CopyProperties(*result);
23664
+ result->name = name;
23665
+ result->type = type;
23666
+ return move(result);
23601
23667
  }
23602
23668
  };
23603
23669
 
@@ -23605,7 +23671,7 @@ public:
23605
23671
  //===----------------------------------------------------------------------===//
23606
23672
  // DuckDB
23607
23673
  //
23608
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23674
+ // duckdb/parser/parsed_data/create_view_info.hpp
23609
23675
  //
23610
23676
  //
23611
23677
  //===----------------------------------------------------------------------===//
@@ -23617,27 +23683,29 @@ public:
23617
23683
 
23618
23684
  namespace duckdb {
23619
23685
 
23620
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23621
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
23622
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23623
- this->name = function.name;
23624
- functions.AddFunction(move(function));
23686
+ struct CreateViewInfo : public CreateInfo {
23687
+ CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
23625
23688
  }
23626
-
23627
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23628
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23629
- this->name = functions.name;
23630
- for (auto &func : functions.functions) {
23631
- func.name = functions.name;
23632
- }
23689
+ CreateViewInfo(string schema, string view_name)
23690
+ : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
23633
23691
  }
23634
23692
 
23635
- AggregateFunctionSet functions;
23693
+ //! Table name to insert to
23694
+ string view_name;
23695
+ //! Aliases of the view
23696
+ vector<string> aliases;
23697
+ //! Return types
23698
+ vector<LogicalType> types;
23699
+ //! The SelectStatement of the view
23700
+ unique_ptr<SelectStatement> query;
23636
23701
 
23637
23702
  public:
23638
23703
  unique_ptr<CreateInfo> Copy() const override {
23639
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23704
+ auto result = make_unique<CreateViewInfo>(schema, view_name);
23640
23705
  CopyProperties(*result);
23706
+ result->aliases = aliases;
23707
+ result->types = types;
23708
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
23641
23709
  return move(result);
23642
23710
  }
23643
23711
  };
@@ -23646,7 +23714,7 @@ public:
23646
23714
  //===----------------------------------------------------------------------===//
23647
23715
  // DuckDB
23648
23716
  //
23649
- // duckdb/parser/parsed_data/drop_info.hpp
23717
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23650
23718
  //
23651
23719
  //
23652
23720
  //===----------------------------------------------------------------------===//
@@ -23655,42 +23723,17 @@ public:
23655
23723
 
23656
23724
 
23657
23725
 
23658
-
23659
23726
  namespace duckdb {
23660
23727
 
23661
- struct DropInfo : public ParseInfo {
23662
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23663
- }
23664
-
23665
- //! The catalog type to drop
23666
- CatalogType type;
23667
- //! Schema name to drop from, if any
23668
- string schema;
23669
- //! Element name to drop
23670
- string name;
23671
- //! Ignore if the entry does not exist instead of failing
23672
- bool if_exists = false;
23673
- //! Cascade drop (drop all dependents instead of throwing an error if there
23674
- //! are any)
23675
- bool cascade = false;
23676
-
23677
- public:
23678
- unique_ptr<DropInfo> Copy() const {
23679
- auto result = make_unique<DropInfo>();
23680
- result->type = type;
23681
- result->schema = schema;
23682
- result->name = name;
23683
- result->if_exists = if_exists;
23684
- result->cascade = cascade;
23685
- return result;
23686
- }
23728
+ struct VacuumInfo : public ParseInfo {
23729
+ // nothing for now
23687
23730
  };
23688
23731
 
23689
23732
  } // namespace duckdb
23690
23733
  //===----------------------------------------------------------------------===//
23691
23734
  // DuckDB
23692
23735
  //
23693
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23736
+ // duckdb/parser/parsed_data/show_select_info.hpp
23694
23737
  //
23695
23738
  //
23696
23739
  //===----------------------------------------------------------------------===//
@@ -23702,27 +23745,23 @@ public:
23702
23745
 
23703
23746
  namespace duckdb {
23704
23747
 
23705
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23706
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
23707
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23708
- functions.push_back(move(function));
23709
- this->name = function.name;
23710
- }
23711
- CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23712
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23713
- this->name = name;
23714
- for (auto &function : functions) {
23715
- function.name = name;
23716
- }
23717
- }
23718
-
23719
- vector<PragmaFunction> functions;
23748
+ struct ShowSelectInfo : public ParseInfo {
23749
+ //! Types of projected columns
23750
+ vector<LogicalType> types;
23751
+ //! The QueryNode of select query
23752
+ unique_ptr<QueryNode> query;
23753
+ //! Aliases of projected columns
23754
+ vector<string> aliases;
23755
+ //! Whether or not we are requesting a summary or a describe
23756
+ bool is_summary;
23720
23757
 
23721
- public:
23722
- unique_ptr<CreateInfo> Copy() const override {
23723
- auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23724
- CopyProperties(*result);
23725
- return move(result);
23758
+ unique_ptr<ShowSelectInfo> Copy() {
23759
+ auto result = make_unique<ShowSelectInfo>();
23760
+ result->types = types;
23761
+ result->query = query->Copy();
23762
+ result->aliases = aliases;
23763
+ result->is_summary = is_summary;
23764
+ return result;
23726
23765
  }
23727
23766
  };
23728
23767
 
@@ -23730,7 +23769,7 @@ public:
23730
23769
  //===----------------------------------------------------------------------===//
23731
23770
  // DuckDB
23732
23771
  //
23733
- // duckdb/parser/tableref/expressionlistref.hpp
23772
+ // duckdb/parser/tableref/emptytableref.hpp
23734
23773
  //
23735
23774
  //
23736
23775
  //===----------------------------------------------------------------------===//
@@ -23739,35 +23778,25 @@ public:
23739
23778
 
23740
23779
 
23741
23780
 
23742
-
23743
-
23744
-
23745
23781
  namespace duckdb {
23746
- //! Represents an expression list as generated by a VALUES statement
23747
- class ExpressionListRef : public TableRef {
23782
+ //! Represents a cross product
23783
+ class EmptyTableRef : public TableRef {
23748
23784
  public:
23749
- ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
23785
+ EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
23750
23786
  }
23751
23787
 
23752
- //! Value list, only used for VALUES statement
23753
- vector<vector<unique_ptr<ParsedExpression>>> values;
23754
- //! Expected SQL types
23755
- vector<LogicalType> expected_types;
23756
- //! The set of expected names
23757
- vector<string> expected_names;
23758
-
23759
23788
  public:
23789
+ string ToString() const override;
23760
23790
  bool Equals(const TableRef *other_p) const override;
23761
23791
 
23762
23792
  unique_ptr<TableRef> Copy() override;
23763
23793
 
23764
- //! Serializes a blob into a ExpressionListRef
23794
+ //! Serializes a blob into a DummyTableRef
23765
23795
  void Serialize(FieldWriter &serializer) const override;
23766
- //! Deserializes a blob back into a ExpressionListRef
23796
+ //! Deserializes a blob back into a DummyTableRef
23767
23797
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23768
23798
  };
23769
23799
  } // namespace duckdb
23770
-
23771
23800
  //===----------------------------------------------------------------------===//
23772
23801
  // DuckDB
23773
23802
  //
@@ -23793,6 +23822,7 @@ public:
23793
23822
  unique_ptr<TableRef> right;
23794
23823
 
23795
23824
  public:
23825
+ string ToString() const override;
23796
23826
  bool Equals(const TableRef *other_p) const override;
23797
23827
 
23798
23828
  unique_ptr<TableRef> Copy() override;
@@ -23804,10 +23834,12 @@ public:
23804
23834
  };
23805
23835
  } // namespace duckdb
23806
23836
 
23837
+
23838
+
23807
23839
  //===----------------------------------------------------------------------===//
23808
23840
  // DuckDB
23809
23841
  //
23810
- // duckdb/parser/tableref/emptytableref.hpp
23842
+ // duckdb/parser/tableref/expressionlistref.hpp
23811
23843
  //
23812
23844
  //
23813
23845
  //===----------------------------------------------------------------------===//
@@ -23816,26 +23848,36 @@ public:
23816
23848
 
23817
23849
 
23818
23850
 
23851
+
23852
+
23853
+
23819
23854
  namespace duckdb {
23820
- //! Represents a cross product
23821
- class EmptyTableRef : public TableRef {
23855
+ //! Represents an expression list as generated by a VALUES statement
23856
+ class ExpressionListRef : public TableRef {
23822
23857
  public:
23823
- EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
23858
+ ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
23824
23859
  }
23825
23860
 
23861
+ //! Value list, only used for VALUES statement
23862
+ vector<vector<unique_ptr<ParsedExpression>>> values;
23863
+ //! Expected SQL types
23864
+ vector<LogicalType> expected_types;
23865
+ //! The set of expected names
23866
+ vector<string> expected_names;
23867
+
23826
23868
  public:
23869
+ string ToString() const override;
23827
23870
  bool Equals(const TableRef *other_p) const override;
23828
23871
 
23829
23872
  unique_ptr<TableRef> Copy() override;
23830
23873
 
23831
- //! Serializes a blob into a DummyTableRef
23874
+ //! Serializes a blob into a ExpressionListRef
23832
23875
  void Serialize(FieldWriter &serializer) const override;
23833
- //! Deserializes a blob back into a DummyTableRef
23876
+ //! Deserializes a blob back into a ExpressionListRef
23834
23877
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23835
23878
  };
23836
23879
  } // namespace duckdb
23837
23880
 
23838
-
23839
23881
  //===----------------------------------------------------------------------===//
23840
23882
  // DuckDB
23841
23883
  //
@@ -23873,6 +23915,7 @@ public:
23873
23915
  vector<string> using_columns;
23874
23916
 
23875
23917
  public:
23918
+ string ToString() const override;
23876
23919
  bool Equals(const TableRef *other_p) const override;
23877
23920
 
23878
23921
  unique_ptr<TableRef> Copy() override;
@@ -23909,6 +23952,7 @@ public:
23909
23952
  vector<string> column_name_alias;
23910
23953
 
23911
23954
  public:
23955
+ string ToString() const override;
23912
23956
  bool Equals(const TableRef *other_p) const override;
23913
23957
 
23914
23958
  unique_ptr<TableRef> Copy() override;
@@ -23939,8 +23983,7 @@ namespace duckdb {
23939
23983
  //! Represents a Table producing function
23940
23984
  class TableFunctionRef : public TableRef {
23941
23985
  public:
23942
- TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
23943
- }
23986
+ DUCKDB_API TableFunctionRef();
23944
23987
 
23945
23988
  unique_ptr<ParsedExpression> function;
23946
23989
  vector<string> column_name_alias;