duckdb 0.3.5-dev4.0 → 0.3.5-dev401.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 "65f8e86f7"
15
- #define DUCKDB_VERSION "v0.3.5-dev4"
14
+ #define DUCKDB_SOURCE_ID "39a5294f3"
15
+ #define DUCKDB_VERSION "v0.3.5-dev401"
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
  //
@@ -6074,7 +5888,7 @@ public:
6074
5888
  //! Convert the Expression to a String
6075
5889
  virtual string ToString() const = 0;
6076
5890
  //! Print the expression to stdout
6077
- void Print();
5891
+ void Print() const;
6078
5892
 
6079
5893
  //! Creates a hash value of this expression. It is important that if two expressions are identical (i.e.
6080
5894
  //! Expression::Equals() returns true), that their hash value is identical as well.
@@ -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,60 +6471,205 @@ 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;
6516
+ }
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;
6704
6660
  }
6705
6661
 
6706
- static bool TryMultiply(hugeint_t lhs, hugeint_t rhs, hugeint_t &result);
6707
-
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
+
6708
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);
@@ -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>
@@ -9748,7 +9719,32 @@ enum class StatementType : uint8_t {
9748
9719
  };
9749
9720
 
9750
9721
  string StatementTypeToString(StatementType type);
9751
- bool StatementTypeReturnChanges(StatementType type);
9722
+
9723
+ enum class StatementReturnType : uint8_t {
9724
+ QUERY_RESULT, // the statement returns a query result (e.g. for display to the user)
9725
+ CHANGED_ROWS, // the statement returns a single row containing the number of changed rows (e.g. an insert stmt)
9726
+ NOTHING // the statement returns nothing
9727
+ };
9728
+
9729
+ //! A struct containing various properties of a SQL statement
9730
+ struct StatementProperties {
9731
+ StatementProperties()
9732
+ : read_only(true), requires_valid_transaction(true), allow_stream_result(false), bound_all_parameters(true),
9733
+ return_type(StatementReturnType::QUERY_RESULT) {
9734
+ }
9735
+
9736
+ //! Whether or not the statement is a read-only statement, or whether it can result in changes to the database
9737
+ bool read_only;
9738
+ //! Whether or not the statement requires a valid transaction. Almost all statements require this, with the
9739
+ //! exception of
9740
+ bool requires_valid_transaction;
9741
+ //! Whether or not the result can be streamed to the client
9742
+ bool allow_stream_result;
9743
+ //! Whether or not all parameters have successfully had their types determined
9744
+ bool bound_all_parameters;
9745
+ //! What type of data the statement returns
9746
+ StatementReturnType return_type;
9747
+ };
9752
9748
 
9753
9749
  } // namespace duckdb
9754
9750
 
@@ -9763,11 +9759,9 @@ enum class QueryResultType : uint8_t { MATERIALIZED_RESULT, STREAM_RESULT, PENDI
9763
9759
 
9764
9760
  class BaseQueryResult {
9765
9761
  public:
9766
- //! Creates a successful empty query result
9767
- DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type);
9768
9762
  //! Creates a successful query result with the specified names and types
9769
- DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type, vector<LogicalType> types,
9770
- vector<string> names);
9763
+ DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
9764
+ vector<LogicalType> types, vector<string> names);
9771
9765
  //! Creates an unsuccessful query result with error condition
9772
9766
  DUCKDB_API BaseQueryResult(QueryResultType type, string error);
9773
9767
  DUCKDB_API virtual ~BaseQueryResult();
@@ -9776,6 +9770,8 @@ public:
9776
9770
  QueryResultType type;
9777
9771
  //! The type of the statement that created this result
9778
9772
  StatementType statement_type;
9773
+ //! Properties of the statement
9774
+ StatementProperties properties;
9779
9775
  //! The SQL types of the result
9780
9776
  vector<LogicalType> types;
9781
9777
  //! The names of the result
@@ -9796,11 +9792,9 @@ public:
9796
9792
  //! incrementally fetch data from the database.
9797
9793
  class QueryResult : public BaseQueryResult {
9798
9794
  public:
9799
- //! Creates a successful empty query result
9800
- DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type);
9801
9795
  //! Creates a successful query result with the specified names and types
9802
- DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type, vector<LogicalType> types,
9803
- vector<string> names);
9796
+ DUCKDB_API QueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties,
9797
+ vector<LogicalType> types, vector<string> names);
9804
9798
  //! Creates an unsuccessful query result with error condition
9805
9799
  DUCKDB_API QueryResult(QueryResultType type, string error);
9806
9800
  DUCKDB_API virtual ~QueryResult() override;
@@ -9916,10 +9910,9 @@ namespace duckdb {
9916
9910
 
9917
9911
  class MaterializedQueryResult : public QueryResult {
9918
9912
  public:
9919
- //! Creates an empty successful query result
9920
- DUCKDB_API explicit MaterializedQueryResult(StatementType statement_type);
9921
9913
  //! Creates a successful query result with the specified names and types
9922
- DUCKDB_API MaterializedQueryResult(StatementType statement_type, vector<LogicalType> types, vector<string> names);
9914
+ DUCKDB_API MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
9915
+ vector<LogicalType> types, vector<string> names);
9923
9916
  //! Creates an unsuccessful query result with error condition
9924
9917
  DUCKDB_API explicit MaterializedQueryResult(string error);
9925
9918
 
@@ -10352,9 +10345,12 @@ public:
10352
10345
 
10353
10346
 
10354
10347
 
10348
+
10349
+
10355
10350
  #include <functional>
10356
10351
 
10357
10352
  namespace duckdb {
10353
+
10358
10354
  class BaseStatistics;
10359
10355
  class LogicalGet;
10360
10356
  struct ParallelState;
@@ -10397,10 +10393,14 @@ typedef unique_ptr<FunctionOperatorData> (*table_function_init_t)(ClientContext
10397
10393
  typedef unique_ptr<BaseStatistics> (*table_statistics_t)(ClientContext &context, const FunctionData *bind_data,
10398
10394
  column_t column_index);
10399
10395
  typedef void (*table_function_t)(ClientContext &context, const FunctionData *bind_data,
10400
- FunctionOperatorData *operator_state, DataChunk *input, DataChunk &output);
10396
+ FunctionOperatorData *operator_state, DataChunk &output);
10397
+
10398
+ typedef OperatorResultType (*table_in_out_function_t)(ClientContext &context, const FunctionData *bind_data,
10399
+ FunctionOperatorData *operator_state, DataChunk &input,
10400
+ DataChunk &output);
10401
10401
 
10402
10402
  typedef void (*table_function_parallel_t)(ClientContext &context, const FunctionData *bind_data,
10403
- FunctionOperatorData *operator_state, DataChunk *input, DataChunk &output,
10403
+ FunctionOperatorData *operator_state, DataChunk &output,
10404
10404
  ParallelState *parallel_state);
10405
10405
 
10406
10406
  typedef void (*table_function_cleanup_t)(ClientContext &context, const FunctionData *bind_data,
@@ -10439,7 +10439,8 @@ public:
10439
10439
  table_function_parallel_t parallel_function = nullptr,
10440
10440
  table_function_init_parallel_t parallel_init = nullptr,
10441
10441
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
10442
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
10442
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr,
10443
+ table_in_out_function_t in_out_function = nullptr);
10443
10444
  DUCKDB_API
10444
10445
  TableFunction(const vector<LogicalType> &arguments, table_function_t function, table_function_bind_t bind = nullptr,
10445
10446
  table_function_init_t init = nullptr, table_statistics_t statistics = nullptr,
@@ -10451,7 +10452,8 @@ public:
10451
10452
  table_function_parallel_t parallel_function = nullptr,
10452
10453
  table_function_init_parallel_t parallel_init = nullptr,
10453
10454
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
10454
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
10455
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr,
10456
+ table_in_out_function_t in_out_function = nullptr);
10455
10457
  DUCKDB_API TableFunction();
10456
10458
 
10457
10459
  //! Bind function
@@ -10464,6 +10466,8 @@ public:
10464
10466
  table_function_init_t init;
10465
10467
  //! The main function
10466
10468
  table_function_t function;
10469
+ //! The table in-out function (if this is an in-out function)
10470
+ table_in_out_function_t in_out_function;
10467
10471
  //! (Optional) statistics function
10468
10472
  //! Returns the statistics of a specified column
10469
10473
  table_statistics_t statistics;
@@ -10611,11 +10615,11 @@ struct ProducerToken {
10611
10615
 
10612
10616
  //! The TaskScheduler is responsible for managing tasks and threads
10613
10617
  class TaskScheduler {
10614
- // timeout for semaphore wait, default 50ms
10615
- constexpr static int64_t TASK_TIMEOUT_USECS = 50000;
10618
+ // timeout for semaphore wait, default 5ms
10619
+ constexpr static int64_t TASK_TIMEOUT_USECS = 5000;
10616
10620
 
10617
10621
  public:
10618
- TaskScheduler();
10622
+ TaskScheduler(DatabaseInstance &db);
10619
10623
  ~TaskScheduler();
10620
10624
 
10621
10625
  static TaskScheduler &GetScheduler(ClientContext &context);
@@ -10628,6 +10632,8 @@ public:
10628
10632
  bool GetTaskFromProducer(ProducerToken &token, unique_ptr<Task> &task);
10629
10633
  //! Run tasks forever until "marker" is set to false, "marker" must remain valid until the thread is joined
10630
10634
  void ExecuteForever(atomic<bool> *marker);
10635
+ //! Run tasks until `max_tasks` have been completed, or until there are no more tasks available
10636
+ void ExecuteTasks(idx_t max_tasks);
10631
10637
 
10632
10638
  //! Sets the amount of active threads executing tasks for the system; n-1 background threads will be launched.
10633
10639
  //! The main thread will also be used for execution
@@ -10638,6 +10644,8 @@ public:
10638
10644
  private:
10639
10645
  void SetThreadsInternal(int32_t n);
10640
10646
 
10647
+ private:
10648
+ DatabaseInstance &db;
10641
10649
  //! The task queue
10642
10650
  unique_ptr<ConcurrentQueue> queue;
10643
10651
  //! The active background threads of the task scheduler
@@ -10968,6 +10976,8 @@ public:
10968
10976
  idx_t ColumnCount();
10969
10977
  //! Returns the statement type of the underlying prepared statement object
10970
10978
  StatementType GetStatementType();
10979
+ //! Returns the underlying statement properties
10980
+ StatementProperties GetStatementProperties();
10971
10981
  //! Returns the result SQL types of the prepared statement
10972
10982
  const vector<LogicalType> &GetTypes();
10973
10983
  //! Returns the result names of the prepared statement
@@ -13147,9 +13157,6 @@ public:
13147
13157
  static bool ContainsType(const LogicalType &type, LogicalTypeId target);
13148
13158
  static LogicalType ExchangeType(const LogicalType &type, LogicalTypeId target, LogicalType new_type);
13149
13159
 
13150
- static void ResolveParameterType(LogicalType &type);
13151
- static void ResolveParameterType(unique_ptr<Expression> &expr);
13152
-
13153
13160
  //! Bind the given expresion. Unlike Bind(), this does *not* mute the given ParsedExpression.
13154
13161
  //! Exposed to be used from sub-binders that aren't subclasses of ExpressionBinder.
13155
13162
  virtual BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
@@ -13171,7 +13178,6 @@ protected:
13171
13178
  BindResult BindExpression(OperatorExpression &expr, idx_t depth);
13172
13179
  BindResult BindExpression(ParameterExpression &expr, idx_t depth);
13173
13180
  BindResult BindExpression(PositionalReferenceExpression &ref, idx_t depth);
13174
- BindResult BindExpression(StarExpression &expr, idx_t depth);
13175
13181
  BindResult BindExpression(SubqueryExpression &expr, idx_t depth);
13176
13182
 
13177
13183
  protected:
@@ -13421,7 +13427,6 @@ private:
13421
13427
 
13422
13428
 
13423
13429
 
13424
- //#include "duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp"
13425
13430
 
13426
13431
  namespace duckdb {
13427
13432
  class BoundResultModifier;
@@ -13483,12 +13488,10 @@ public:
13483
13488
  vector<CorrelatedColumnInfo> correlated_columns;
13484
13489
  //! The set of parameter expressions bound by this binder
13485
13490
  vector<BoundParameterExpression *> *parameters;
13486
- //! Whether or not the bound statement is read-only
13487
- bool read_only;
13488
- //! Whether or not the statement requires a valid transaction to run
13489
- bool requires_valid_transaction;
13490
- //! Whether or not the statement can be streamed to the client
13491
- bool allow_stream_result;
13491
+ //! The types of the prepared statement parameters, if any
13492
+ vector<LogicalType> *parameter_types;
13493
+ //! Statement properties
13494
+ StatementProperties properties;
13492
13495
  //! The alias for the currently processing subquery, if it exists
13493
13496
  string alias;
13494
13497
  //! Macro parameter bindings (if any)
@@ -13641,9 +13644,12 @@ private:
13641
13644
  unique_ptr<BoundTableRef> Bind(EmptyTableRef &ref);
13642
13645
  unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
13643
13646
 
13644
- bool BindFunctionParameters(vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
13645
- vector<Value> &parameters, named_parameter_map_t &named_parameters,
13646
- unique_ptr<BoundSubqueryRef> &subquery, string &error);
13647
+ bool BindTableFunctionParameters(TableFunctionCatalogEntry &table_function,
13648
+ vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
13649
+ vector<Value> &parameters, named_parameter_map_t &named_parameters,
13650
+ unique_ptr<BoundSubqueryRef> &subquery, string &error);
13651
+ bool BindTableInTableOutFunction(vector<unique_ptr<ParsedExpression>> &expressions,
13652
+ unique_ptr<BoundSubqueryRef> &subquery, string &error);
13647
13653
 
13648
13654
  unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
13649
13655
  unique_ptr<LogicalOperator> CreatePlan(BoundCrossProductRef &ref);
@@ -13781,6 +13787,7 @@ public:
13781
13787
 
13782
13788
 
13783
13789
  namespace duckdb {
13790
+
13784
13791
  //! SQLStatement is the base class of any type of SQL statement.
13785
13792
  class SQLStatement {
13786
13793
  public:
@@ -13803,6 +13810,9 @@ protected:
13803
13810
  SQLStatement(const SQLStatement &other) = default;
13804
13811
 
13805
13812
  public:
13813
+ virtual string ToString() const {
13814
+ throw InternalException("ToString not supported for this type of SQLStatement");
13815
+ }
13806
13816
  //! Create a copy of this SelectStatement
13807
13817
  virtual unique_ptr<SQLStatement> Copy() const = 0;
13808
13818
  };
@@ -13907,7 +13917,9 @@ public:
13907
13917
 
13908
13918
  public:
13909
13919
  //! Convert the object to a string
13910
- virtual string ToString() const;
13920
+ virtual string ToString() const = 0;
13921
+ string BaseToString(string result) const;
13922
+ string BaseToString(string result, const vector<string> &column_name_alias) const;
13911
13923
  void Print();
13912
13924
 
13913
13925
  virtual bool Equals(const TableRef *other) const;
@@ -13944,6 +13956,8 @@ protected:
13944
13956
  SelectStatement(const SelectStatement &other);
13945
13957
 
13946
13958
  public:
13959
+ //! Convert the SELECT statement to a string
13960
+ string ToString() const override;
13947
13961
  //! Create a copy of this SelectStatement
13948
13962
  unique_ptr<SQLStatement> Copy() const override;
13949
13963
  //! Serializes a SelectStatement to a stand-alone binary blob
@@ -13995,6 +14009,9 @@ public:
13995
14009
  virtual const vector<unique_ptr<ParsedExpression>> &GetSelectList() const = 0;
13996
14010
 
13997
14011
  public:
14012
+ //! Convert the query node to a string
14013
+ virtual string ToString() const = 0;
14014
+
13998
14015
  virtual bool Equals(const QueryNode *other) const;
13999
14016
 
14000
14017
  //! Create a copy of this QueryNode
@@ -14006,6 +14023,9 @@ public:
14006
14023
  //! Deserializes a blob back into a QueryNode
14007
14024
  DUCKDB_API static unique_ptr<QueryNode> Deserialize(Deserializer &source);
14008
14025
 
14026
+ string CTEToString() const;
14027
+ string ResultModifiersToString() const;
14028
+
14009
14029
  protected:
14010
14030
  //! Copy base QueryNode properties from another expression to this one,
14011
14031
  //! used in Copy method
@@ -15975,6 +15995,24 @@ This should not be used with `DUCKDB_TYPE_DECIMAL`.
15975
15995
  */
15976
15996
  DUCKDB_API duckdb_logical_type duckdb_create_logical_type(duckdb_type type);
15977
15997
 
15998
+ /*!
15999
+ Creates a list type from its child type.
16000
+ The resulting type should be destroyed with `duckdb_destroy_logical_type`.
16001
+
16002
+ * type: The child type of list type to create.
16003
+ * returns: The logical type.
16004
+ */
16005
+ DUCKDB_API duckdb_logical_type duckdb_create_list_type(duckdb_logical_type type);
16006
+
16007
+ /*!
16008
+ Creates a map type from its key type and value type.
16009
+ The resulting type should be destroyed with `duckdb_destroy_logical_type`.
16010
+
16011
+ * type: The key type and value type of map type to create.
16012
+ * returns: The logical type.
16013
+ */
16014
+ DUCKDB_API duckdb_logical_type duckdb_create_map_type(duckdb_logical_type key_type, duckdb_logical_type value_type);
16015
+
15978
16016
  /*!
15979
16017
  Creates a `duckdb_logical_type` of type decimal with the specified width and scale
15980
16018
  The resulting type should be destroyed with `duckdb_destroy_logical_type`.
@@ -16054,6 +16092,26 @@ The result must be freed with `duckdb_destroy_logical_type`
16054
16092
  */
16055
16093
  DUCKDB_API duckdb_logical_type duckdb_list_type_child_type(duckdb_logical_type type);
16056
16094
 
16095
+ /*!
16096
+ Retrieves the key type of the given map type.
16097
+
16098
+ The result must be freed with `duckdb_destroy_logical_type`
16099
+
16100
+ * type: The logical type object
16101
+ * returns: The key type of the map type. Must be destroyed with `duckdb_destroy_logical_type`.
16102
+ */
16103
+ DUCKDB_API duckdb_logical_type duckdb_map_type_key_type(duckdb_logical_type type);
16104
+
16105
+ /*!
16106
+ Retrieves the value type of the given map type.
16107
+
16108
+ The result must be freed with `duckdb_destroy_logical_type`
16109
+
16110
+ * type: The logical type object
16111
+ * returns: The value type of the map type. Must be destroyed with `duckdb_destroy_logical_type`.
16112
+ */
16113
+ DUCKDB_API duckdb_logical_type duckdb_map_type_value_type(duckdb_logical_type type);
16114
+
16057
16115
  /*!
16058
16116
  Returns the number of children of a struct type.
16059
16117
 
@@ -16858,6 +16916,19 @@ Closes the result and de-allocates all memory allocated for the arrow result.
16858
16916
  */
16859
16917
  DUCKDB_API void duckdb_destroy_arrow(duckdb_arrow *result);
16860
16918
 
16919
+ //===--------------------------------------------------------------------===//
16920
+ // Threading Information
16921
+ //===--------------------------------------------------------------------===//
16922
+ /*!
16923
+ Execute DuckDB tasks on this thread.
16924
+
16925
+ Will return after `max_tasks` have been executed, or if there are no more tasks present.
16926
+
16927
+ * database: The database object to execute tasks for
16928
+ * max_tasks: The maximum amount of tasks to execute
16929
+ */
16930
+ DUCKDB_API void duckdb_execute_tasks(duckdb_database database, idx_t max_tasks);
16931
+
16861
16932
  #ifdef __cplusplus
16862
16933
  }
16863
16934
  #endif
@@ -16976,8 +17047,8 @@ class StreamQueryResult : public QueryResult {
16976
17047
  public:
16977
17048
  //! Create a successful StreamQueryResult. StreamQueryResults should always be successful initially (it makes no
16978
17049
  //! sense to stream an error).
16979
- DUCKDB_API StreamQueryResult(StatementType statement_type, shared_ptr<ClientContext> context,
16980
- vector<LogicalType> types, vector<string> names);
17050
+ DUCKDB_API StreamQueryResult(StatementType statement_type, StatementProperties properties,
17051
+ shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names);
16981
17052
  DUCKDB_API ~StreamQueryResult() override;
16982
17053
 
16983
17054
  public:
@@ -17090,7 +17161,6 @@ private:
17090
17161
  } // namespace duckdb
17091
17162
 
17092
17163
 
17093
- #include <random>
17094
17164
 
17095
17165
  //===----------------------------------------------------------------------===//
17096
17166
  // DuckDB
@@ -17149,6 +17219,8 @@ struct ClientConfig {
17149
17219
  //! Preserve identifier case while parsing.
17150
17220
  //! If false, all unquoted identifiers are lower-cased (e.g. "MyTable" -> "mytable").
17151
17221
  bool preserve_identifier_case = true;
17222
+ //! The maximum expression depth limit in the parser
17223
+ idx_t max_expression_depth = 1000;
17152
17224
 
17153
17225
  // Whether or not aggressive query verification is enabled
17154
17226
  bool query_verification_enabled = false;
@@ -17176,6 +17248,27 @@ public:
17176
17248
 
17177
17249
  } // namespace duckdb
17178
17250
 
17251
+ //===----------------------------------------------------------------------===//
17252
+ // DuckDB
17253
+ //
17254
+ // duckdb/main/external_dependencies.hpp
17255
+ //
17256
+ //
17257
+ //===----------------------------------------------------------------------===//
17258
+
17259
+
17260
+
17261
+ namespace duckdb {
17262
+
17263
+ enum ExternalDependenciesType { PYTHON_DEPENDENCY };
17264
+ class ExternalDependency {
17265
+ public:
17266
+ explicit ExternalDependency(ExternalDependenciesType type_p) : type(type_p) {};
17267
+ virtual ~ExternalDependency() {};
17268
+ ExternalDependenciesType type;
17269
+ };
17270
+
17271
+ } // namespace duckdb
17179
17272
 
17180
17273
  namespace duckdb {
17181
17274
  class Appender;
@@ -17189,12 +17282,12 @@ class PreparedStatementData;
17189
17282
  class Relation;
17190
17283
  class BufferedFileWriter;
17191
17284
  class QueryProfiler;
17192
- class QueryProfilerHistory;
17193
17285
  class ClientContextLock;
17194
17286
  struct CreateScalarFunctionInfo;
17195
17287
  class ScalarFunctionCatalogEntry;
17196
17288
  struct ActiveQueryContext;
17197
17289
  struct ParserOptions;
17290
+ struct ClientData;
17198
17291
 
17199
17292
  //! The ClientContext holds information relevant to the current client session
17200
17293
  //! during execution
@@ -17207,31 +17300,19 @@ public:
17207
17300
  DUCKDB_API explicit ClientContext(shared_ptr<DatabaseInstance> db);
17208
17301
  DUCKDB_API ~ClientContext();
17209
17302
 
17210
- //! Query profiler
17211
- shared_ptr<QueryProfiler> profiler;
17212
- //! QueryProfiler History
17213
- unique_ptr<QueryProfilerHistory> query_profiler_history;
17214
17303
  //! The database that this client is connected to
17215
17304
  shared_ptr<DatabaseInstance> db;
17216
17305
  //! Data for the currently running transaction
17217
17306
  TransactionContext transaction;
17218
17307
  //! Whether or not the query is interrupted
17219
17308
  atomic<bool> interrupted;
17220
-
17221
- unique_ptr<SchemaCatalogEntry> temporary_objects;
17222
- unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
17223
-
17224
- //! The writer used to log queries (if logging is enabled)
17225
- unique_ptr<BufferedFileWriter> log_query_writer;
17226
- //! The random generator used by random(). Its seed value can be set by setseed().
17227
- std::mt19937 random_engine;
17228
-
17229
- const unique_ptr<CatalogSearchPath> catalog_search_path;
17230
-
17231
- unique_ptr<FileOpener> file_opener;
17309
+ //! External Objects (e.g., Python objects) that views depend of
17310
+ unordered_map<string, vector<shared_ptr<ExternalDependency>>> external_dependencies;
17232
17311
 
17233
17312
  //! The client configuration
17234
17313
  ClientConfig config;
17314
+ //! The set of client-specific data
17315
+ unique_ptr<ClientData> client_data;
17235
17316
 
17236
17317
  public:
17237
17318
  DUCKDB_API Transaction &ActiveTransaction() {
@@ -17360,7 +17441,8 @@ private:
17360
17441
 
17361
17442
  //! Internally prepare a SQL statement. Caller must hold the context_lock.
17362
17443
  shared_ptr<PreparedStatementData> CreatePreparedStatement(ClientContextLock &lock, const string &query,
17363
- unique_ptr<SQLStatement> statement);
17444
+ unique_ptr<SQLStatement> statement,
17445
+ vector<Value> *values = nullptr);
17364
17446
  unique_ptr<PendingQueryResult> PendingStatementInternal(ClientContextLock &lock, const string &query,
17365
17447
  unique_ptr<SQLStatement> statement);
17366
17448
  unique_ptr<QueryResult> RunStatementInternal(ClientContextLock &lock, const string &query,
@@ -17434,6 +17516,7 @@ private:
17434
17516
  } // namespace duckdb
17435
17517
 
17436
17518
 
17519
+
17437
17520
  #include <memory>
17438
17521
 
17439
17522
  namespace duckdb {
@@ -17445,8 +17528,6 @@ class LogicalOperator;
17445
17528
  class QueryNode;
17446
17529
  class TableRef;
17447
17530
 
17448
- class ExtraDependencies {};
17449
-
17450
17531
  class Relation : public std::enable_shared_from_this<Relation> {
17451
17532
  public:
17452
17533
  DUCKDB_API Relation(const std::shared_ptr<ClientContext> &context, RelationType type)
@@ -17461,7 +17542,7 @@ public:
17461
17542
 
17462
17543
  RelationType type;
17463
17544
 
17464
- unique_ptr<ExtraDependencies> extra_dependencies;
17545
+ shared_ptr<ExternalDependency> extra_dependencies;
17465
17546
 
17466
17547
  public:
17467
17548
  DUCKDB_API virtual const vector<ColumnDefinition> &Columns() = 0;
@@ -17561,6 +17642,7 @@ public:
17561
17642
  DUCKDB_API virtual Relation *ChildRelation() {
17562
17643
  return nullptr;
17563
17644
  }
17645
+ DUCKDB_API vector<shared_ptr<ExternalDependency>> GetAllDependencies();
17564
17646
 
17565
17647
  protected:
17566
17648
  DUCKDB_API string RenderWhitespace(idx_t depth);
@@ -18097,6 +18179,8 @@ public:
18097
18179
  idx_t maximum_memory = (idx_t)-1;
18098
18180
  //! The maximum amount of CPU threads used by the database system. Default: all available.
18099
18181
  idx_t maximum_threads = (idx_t)-1;
18182
+ //! The number of external threads that work on DuckDB tasks. Default: none.
18183
+ idx_t external_threads = 0;
18100
18184
  //! Whether or not to create and use a temporary directory to store intermediates that do not fit in memory
18101
18185
  bool use_temporary_directory = true;
18102
18186
  //! Directory to store temporary structures that do not fit in memory
@@ -21312,6 +21396,7 @@ namespace duckdb {
21312
21396
 
21313
21397
  struct ParserOptions {
21314
21398
  bool preserve_identifier_case = true;
21399
+ idx_t max_expression_depth = 1000;
21315
21400
  };
21316
21401
 
21317
21402
  //! The parser is responsible for parsing the query and converting it into a set
@@ -21844,6 +21929,8 @@ public:
21844
21929
 
21845
21930
 
21846
21931
 
21932
+ #include <algorithm>
21933
+
21847
21934
  namespace duckdb {
21848
21935
 
21849
21936
  enum class StrTimeSpecifier : uint8_t {
@@ -21891,7 +21978,11 @@ public:
21891
21978
  virtual ~StrTimeFormat() {
21892
21979
  }
21893
21980
 
21894
- static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
21981
+ DUCKDB_API static string ParseFormatSpecifier(const string &format_string, StrTimeFormat &format);
21982
+
21983
+ inline bool HasFormatSpecifier(StrTimeSpecifier s) const {
21984
+ return std::find(specifiers.begin(), specifiers.end(), s) != specifiers.end();
21985
+ }
21895
21986
 
21896
21987
  protected:
21897
21988
  //! The format specifiers
@@ -21907,13 +21998,13 @@ protected:
21907
21998
 
21908
21999
  protected:
21909
22000
  void AddLiteral(string literal);
21910
- virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
22001
+ DUCKDB_API virtual void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier);
21911
22002
  };
21912
22003
 
21913
22004
  struct StrfTimeFormat : public StrTimeFormat {
21914
- idx_t GetLength(date_t date, dtime_t time);
22005
+ DUCKDB_API idx_t GetLength(date_t date, dtime_t time, int32_t utc_offset, const char *tz_name);
21915
22006
 
21916
- void FormatString(date_t date, int32_t data[7], char *target);
22007
+ DUCKDB_API void FormatString(date_t date, int32_t data[8], const char *tz_name, char *target);
21917
22008
  void FormatString(date_t date, dtime_t time, char *target);
21918
22009
 
21919
22010
  DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
@@ -21926,8 +22017,9 @@ protected:
21926
22017
  vector<bool> is_date_specifier;
21927
22018
 
21928
22019
  protected:
21929
- void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
21930
- static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time);
22020
+ DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
22021
+ static idx_t GetSpecifierLength(StrTimeSpecifier specifier, date_t date, dtime_t time, int32_t utc_offset,
22022
+ const char *tz_name);
21931
22023
  char *WriteString(char *target, const string_t &str);
21932
22024
  char *Write2(char *target, uint8_t value);
21933
22025
  char *WritePadded2(char *target, uint32_t value);
@@ -21935,20 +22027,21 @@ protected:
21935
22027
  char *WritePadded(char *target, uint32_t value, size_t padding);
21936
22028
  bool IsDateSpecifier(StrTimeSpecifier specifier);
21937
22029
  char *WriteDateSpecifier(StrTimeSpecifier specifier, date_t date, char *target);
21938
- char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], char *target);
22030
+ char *WriteStandardSpecifier(StrTimeSpecifier specifier, int32_t data[], const char *tz_name, char *target);
21939
22031
  };
21940
22032
 
21941
22033
  struct StrpTimeFormat : public StrTimeFormat {
21942
22034
  public:
21943
22035
  //! Type-safe parsing argument
21944
22036
  struct ParseResult {
21945
- int32_t data[7];
22037
+ int32_t data[8]; // year, month, day, hour, min, sec, µs, offset
22038
+ string tz;
21946
22039
  string error_message;
21947
22040
  idx_t error_position = DConstants::INVALID_INDEX;
21948
22041
 
21949
22042
  date_t ToDate();
21950
22043
  timestamp_t ToTimestamp();
21951
- string FormatError(string_t input, const string &format_specifier);
22044
+ DUCKDB_API string FormatError(string_t input, const string &format_specifier);
21952
22045
  };
21953
22046
 
21954
22047
  public:
@@ -21958,7 +22051,7 @@ public:
21958
22051
  public:
21959
22052
  DUCKDB_API static ParseResult Parse(const string &format, const string &text);
21960
22053
 
21961
- bool Parse(string_t str, ParseResult &result);
22054
+ DUCKDB_API bool Parse(string_t str, ParseResult &result);
21962
22055
 
21963
22056
  bool TryParseDate(string_t str, date_t &result, string &error_message);
21964
22057
  bool TryParseTimestamp(string_t str, timestamp_t &result, string &error_message);
@@ -21968,7 +22061,7 @@ public:
21968
22061
 
21969
22062
  protected:
21970
22063
  static string FormatStrpTimeError(const string &input, idx_t position);
21971
- void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
22064
+ DUCKDB_API void AddFormatSpecifier(string preceding_literal, StrTimeSpecifier specifier) override;
21972
22065
  int NumericSpecifierWidth(StrTimeSpecifier specifier);
21973
22066
  int32_t TryParseCollection(const char *data, idx_t &pos, idx_t size, const string_t collection[],
21974
22067
  idx_t collection_count);
@@ -22019,15 +22112,12 @@ struct TextSearchShiftArray {
22019
22112
  };
22020
22113
 
22021
22114
  struct BufferedCSVReaderOptions {
22022
- //! The file path of the CSV file to read
22023
- string file_path;
22024
- //! Whether file is compressed or not, and if so which compression type
22025
- //! AUTO_DETECT (default; infer from file extension)
22026
- FileCompressionType compression = FileCompressionType::AUTO_DETECT;
22027
- //! Whether or not to automatically detect dialect and datatypes
22028
- bool auto_detect = false;
22029
- //! Whether or not a delimiter was defined by the user
22030
- bool has_delimiter = false;
22115
+ //===--------------------------------------------------------------------===//
22116
+ // CommonCSVOptions
22117
+ //===--------------------------------------------------------------------===//
22118
+
22119
+ //! Whether or not a delimiter was defined by the user
22120
+ bool has_delimiter = false;
22031
22121
  //! Delimiter to separate columns within each line
22032
22122
  string delimiter = ",";
22033
22123
  //! Whether or not a quote sign was defined by the user
@@ -22042,26 +22132,51 @@ struct BufferedCSVReaderOptions {
22042
22132
  bool has_header = false;
22043
22133
  //! Whether or not the file has a header line
22044
22134
  bool header = false;
22045
- //! Whether or not header names shall be normalized
22046
- bool normalize_names = false;
22047
- //! How many leading rows to skip
22048
- idx_t skip_rows = 0;
22135
+ //! Whether or not we should ignore InvalidInput errors
22136
+ bool ignore_errors = false;
22049
22137
  //! Expected number of columns
22050
22138
  idx_t num_cols = 0;
22139
+ //! Number of samples to buffer
22140
+ idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
22051
22141
  //! Specifies the string that represents a null value
22052
22142
  string null_str;
22143
+ //! Whether file is compressed or not, and if so which compression type
22144
+ //! AUTO_DETECT (default; infer from file extension)
22145
+ FileCompressionType compression = FileCompressionType::AUTO_DETECT;
22146
+
22147
+ //===--------------------------------------------------------------------===//
22148
+ // ReadCSVOptions
22149
+ //===--------------------------------------------------------------------===//
22150
+
22151
+ //! How many leading rows to skip
22152
+ idx_t skip_rows = 0;
22153
+ //! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
22154
+ idx_t maximum_line_size = 2097152;
22155
+ //! Whether or not header names shall be normalized
22156
+ bool normalize_names = false;
22053
22157
  //! True, if column with that index must skip null check
22054
22158
  vector<bool> force_not_null;
22159
+ //! Consider all columns to be of type varchar
22160
+ bool all_varchar = false;
22055
22161
  //! Size of sample chunk used for dialect and type detection
22056
22162
  idx_t sample_chunk_size = STANDARD_VECTOR_SIZE;
22057
22163
  //! Number of sample chunks used for type detection
22058
22164
  idx_t sample_chunks = 10;
22059
- //! Number of samples to buffer
22060
- idx_t buffer_size = STANDARD_VECTOR_SIZE * 100;
22061
- //! Consider all columns to be of type varchar
22062
- bool all_varchar = false;
22063
- //! Maximum CSV line size: specified because if we reach this amount, we likely have wrong delimiters (default: 2MB)
22064
- idx_t maximum_line_size = 2097152;
22165
+ //! Whether or not to automatically detect dialect and datatypes
22166
+ bool auto_detect = false;
22167
+ //! The file path of the CSV file to read
22168
+ string file_path;
22169
+ //! Whether or not to include a file name column
22170
+ bool include_file_name = false;
22171
+
22172
+ //===--------------------------------------------------------------------===//
22173
+ // WriteCSVOptions
22174
+ //===--------------------------------------------------------------------===//
22175
+
22176
+ //! The column names of the columns to write
22177
+ vector<string> names;
22178
+ //! True, if column with that index must be quoted
22179
+ vector<bool> force_quote;
22065
22180
 
22066
22181
  //! The date format to use (if any is specified)
22067
22182
  std::map<LogicalTypeId, StrpTimeFormat> date_format = {{LogicalTypeId::DATE, {}}, {LogicalTypeId::TIMESTAMP, {}}};
@@ -22069,6 +22184,16 @@ struct BufferedCSVReaderOptions {
22069
22184
  std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
22070
22185
 
22071
22186
  void SetDelimiter(const string &delimiter);
22187
+ //! Set an option that is supported by both reading and writing functions, called by
22188
+ //! the SetReadOption and SetWriteOption methods
22189
+ bool SetBaseOption(const string &loption, const Value &value);
22190
+
22191
+ //! loption - lowercase string
22192
+ //! set - argument(s) to the option
22193
+ //! expected_names - names expected if the option is "columns"
22194
+ void SetReadOption(const string &loption, const Value &value, vector<string> &expected_names);
22195
+
22196
+ void SetWriteOption(const string &loption, const Value &value);
22072
22197
 
22073
22198
  std::string ToString() const;
22074
22199
  };
@@ -22194,6 +22319,10 @@ private:
22194
22319
  const vector<LogicalType> &requested_types,
22195
22320
  vector<vector<LogicalType>> &best_sql_types_candidates,
22196
22321
  map<LogicalTypeId, vector<string>> &best_format_candidates);
22322
+
22323
+ private:
22324
+ //! Whether or not the current row's columns have overflown sql_types.size()
22325
+ bool error_column_overflow = false;
22197
22326
  };
22198
22327
 
22199
22328
  } // namespace duckdb
@@ -22383,7 +22512,7 @@ public:
22383
22512
  //===----------------------------------------------------------------------===//
22384
22513
  // DuckDB
22385
22514
  //
22386
- // duckdb/parser/expression/collate_expression.hpp
22515
+ // duckdb/parser/expression/star_expression.hpp
22387
22516
  //
22388
22517
  //
22389
22518
  //===----------------------------------------------------------------------===//
@@ -22392,22 +22521,25 @@ public:
22392
22521
 
22393
22522
 
22394
22523
 
22524
+
22395
22525
  namespace duckdb {
22396
22526
 
22397
- //! CollateExpression represents a COLLATE statement
22398
- class CollateExpression : public ParsedExpression {
22527
+ //! Represents a * expression in the SELECT clause
22528
+ class StarExpression : public ParsedExpression {
22399
22529
  public:
22400
- CollateExpression(string collation, unique_ptr<ParsedExpression> child);
22530
+ StarExpression(string relation_name = string());
22401
22531
 
22402
- //! The child of the cast expression
22403
- unique_ptr<ParsedExpression> child;
22404
- //! The collation clause
22405
- string collation;
22532
+ //! The relation name in case of tbl.*, or empty if this is a normal *
22533
+ string relation_name;
22534
+ //! List of columns to exclude from the STAR expression
22535
+ case_insensitive_set_t exclude_list;
22536
+ //! List of columns to replace with another expression
22537
+ case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
22406
22538
 
22407
22539
  public:
22408
22540
  string ToString() const override;
22409
22541
 
22410
- static bool Equals(const CollateExpression *a, const CollateExpression *b);
22542
+ static bool Equals(const StarExpression *a, const StarExpression *b);
22411
22543
 
22412
22544
  unique_ptr<ParsedExpression> Copy() const override;
22413
22545
 
@@ -22418,7 +22550,7 @@ public:
22418
22550
  //===----------------------------------------------------------------------===//
22419
22551
  // DuckDB
22420
22552
  //
22421
- // duckdb/parser/expression/between_expression.hpp
22553
+ // duckdb/parser/expression/default_expression.hpp
22422
22554
  //
22423
22555
  //
22424
22556
  //===----------------------------------------------------------------------===//
@@ -22428,39 +22560,28 @@ public:
22428
22560
 
22429
22561
 
22430
22562
  namespace duckdb {
22431
-
22432
- class BetweenExpression : public ParsedExpression {
22563
+ //! Represents the default value of a column
22564
+ class DefaultExpression : public ParsedExpression {
22433
22565
  public:
22434
- BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22435
- unique_ptr<ParsedExpression> upper);
22436
-
22437
- unique_ptr<ParsedExpression> input;
22438
- unique_ptr<ParsedExpression> lower;
22439
- unique_ptr<ParsedExpression> upper;
22566
+ DefaultExpression();
22440
22567
 
22441
22568
  public:
22442
- string ToString() const override;
22569
+ bool IsScalar() const override {
22570
+ return false;
22571
+ }
22443
22572
 
22444
- static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22573
+ string ToString() const override;
22445
22574
 
22446
22575
  unique_ptr<ParsedExpression> Copy() const override;
22447
22576
 
22448
22577
  void Serialize(FieldWriter &writer) const override;
22449
22578
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22450
-
22451
- public:
22452
- template <class T, class BASE>
22453
- static string ToString(const T &entry) {
22454
- return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
22455
- }
22456
22579
  };
22457
22580
  } // namespace duckdb
22458
-
22459
-
22460
22581
  //===----------------------------------------------------------------------===//
22461
22582
  // DuckDB
22462
22583
  //
22463
- // duckdb/parser/expression/case_expression.hpp
22584
+ // duckdb/parser/expression/operator_expression.hpp
22464
22585
  //
22465
22586
  //
22466
22587
  //===----------------------------------------------------------------------===//
@@ -22470,25 +22591,22 @@ public:
22470
22591
 
22471
22592
 
22472
22593
 
22473
- namespace duckdb {
22474
22594
 
22475
- struct CaseCheck {
22476
- unique_ptr<ParsedExpression> when_expr;
22477
- unique_ptr<ParsedExpression> then_expr;
22478
- };
22479
22595
 
22480
- //! The CaseExpression represents a CASE expression in the query
22481
- class CaseExpression : public ParsedExpression {
22596
+ namespace duckdb {
22597
+ //! Represents a built-in operator expression
22598
+ class OperatorExpression : public ParsedExpression {
22482
22599
  public:
22483
- DUCKDB_API CaseExpression();
22600
+ DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
22601
+ unique_ptr<ParsedExpression> right = nullptr);
22602
+ DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22484
22603
 
22485
- vector<CaseCheck> case_checks;
22486
- unique_ptr<ParsedExpression> else_expr;
22604
+ vector<unique_ptr<ParsedExpression>> children;
22487
22605
 
22488
22606
  public:
22489
22607
  string ToString() const override;
22490
22608
 
22491
- static bool Equals(const CaseExpression *a, const CaseExpression *b);
22609
+ static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
22492
22610
 
22493
22611
  unique_ptr<ParsedExpression> Copy() const override;
22494
22612
 
@@ -22498,22 +22616,72 @@ public:
22498
22616
  public:
22499
22617
  template <class T, class BASE>
22500
22618
  static string ToString(const T &entry) {
22501
- string case_str = "CASE ";
22502
- for (auto &check : entry.case_checks) {
22503
- case_str += " WHEN (" + check.when_expr->ToString() + ")";
22504
- case_str += " THEN (" + check.then_expr->ToString() + ")";
22619
+ auto op = ExpressionTypeToOperator(entry.type);
22620
+ if (!op.empty()) {
22621
+ // use the operator string to represent the operator
22622
+ D_ASSERT(entry.children.size() == 2);
22623
+ return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
22624
+ }
22625
+ switch (entry.type) {
22626
+ case ExpressionType::COMPARE_IN:
22627
+ case ExpressionType::COMPARE_NOT_IN: {
22628
+ string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
22629
+ string in_child = entry.children[0]->ToString();
22630
+ string child_list = "(";
22631
+ for (idx_t i = 1; i < entry.children.size(); i++) {
22632
+ if (i > 1) {
22633
+ child_list += ", ";
22634
+ }
22635
+ child_list += entry.children[i]->ToString();
22636
+ }
22637
+ child_list += ")";
22638
+ return "(" + in_child + op_type + child_list + ")";
22639
+ }
22640
+ case ExpressionType::OPERATOR_NOT:
22641
+ case ExpressionType::GROUPING_FUNCTION:
22642
+ case ExpressionType::OPERATOR_COALESCE: {
22643
+ string result = ExpressionTypeToString(entry.type);
22644
+ result += "(";
22645
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22646
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
22647
+ result += ")";
22648
+ return result;
22649
+ }
22650
+ case ExpressionType::OPERATOR_IS_NULL:
22651
+ return "(" + entry.children[0]->ToString() + " IS NULL)";
22652
+ case ExpressionType::OPERATOR_IS_NOT_NULL:
22653
+ return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
22654
+ case ExpressionType::ARRAY_EXTRACT:
22655
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
22656
+ case ExpressionType::ARRAY_SLICE:
22657
+ return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
22658
+ entry.children[2]->ToString() + "]";
22659
+ case ExpressionType::STRUCT_EXTRACT: {
22660
+ D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
22661
+ auto child_string = entry.children[1]->ToString();
22662
+ D_ASSERT(child_string.size() >= 3);
22663
+ D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
22664
+ return "(" + entry.children[0]->ToString() + ")." +
22665
+ KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
22666
+ }
22667
+ case ExpressionType::ARRAY_CONSTRUCTOR: {
22668
+ string result = "(ARRAY[";
22669
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22670
+ [](const unique_ptr<BASE> &child) { return child->ToString(); });
22671
+ result += "])";
22672
+ return result;
22673
+ }
22674
+ default:
22675
+ throw InternalException("Unrecognized operator type");
22505
22676
  }
22506
- case_str += " ELSE " + entry.else_expr->ToString();
22507
- case_str += " END";
22508
- return case_str;
22509
22677
  }
22510
22678
  };
22511
- } // namespace duckdb
22512
22679
 
22680
+ } // namespace duckdb
22513
22681
  //===----------------------------------------------------------------------===//
22514
22682
  // DuckDB
22515
22683
  //
22516
- // duckdb/parser/expression/cast_expression.hpp
22684
+ // duckdb/parser/expression/conjunction_expression.hpp
22517
22685
  //
22518
22686
  //
22519
22687
  //===----------------------------------------------------------------------===//
@@ -22525,22 +22693,22 @@ public:
22525
22693
 
22526
22694
  namespace duckdb {
22527
22695
 
22528
- //! CastExpression represents a type cast from one SQL type to another SQL type
22529
- class CastExpression : public ParsedExpression {
22696
+ //! Represents a conjunction (AND/OR)
22697
+ class ConjunctionExpression : public ParsedExpression {
22530
22698
  public:
22531
- DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
22699
+ DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22700
+ DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22701
+ DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22702
+ unique_ptr<ParsedExpression> right);
22532
22703
 
22533
- //! The child of the cast expression
22534
- unique_ptr<ParsedExpression> child;
22535
- //! The type to cast to
22536
- LogicalType cast_type;
22537
- //! Whether or not this is a try_cast expression
22538
- bool try_cast;
22704
+ vector<unique_ptr<ParsedExpression>> children;
22539
22705
 
22540
22706
  public:
22707
+ void AddExpression(unique_ptr<ParsedExpression> expr);
22708
+
22541
22709
  string ToString() const override;
22542
22710
 
22543
- static bool Equals(const CastExpression *a, const CastExpression *b);
22711
+ static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22544
22712
 
22545
22713
  unique_ptr<ParsedExpression> Copy() const override;
22546
22714
 
@@ -22550,18 +22718,18 @@ public:
22550
22718
  public:
22551
22719
  template <class T, class BASE>
22552
22720
  static string ToString(const T &entry) {
22553
- return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
22554
- entry.cast_type.ToString() + ")";
22721
+ string result = "(" + entry.children[0]->ToString();
22722
+ for (idx_t i = 1; i < entry.children.size(); i++) {
22723
+ result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22724
+ }
22725
+ return result + ")";
22555
22726
  }
22556
22727
  };
22557
22728
  } // namespace duckdb
22558
-
22559
-
22560
-
22561
22729
  //===----------------------------------------------------------------------===//
22562
22730
  // DuckDB
22563
22731
  //
22564
- // duckdb/parser/expression/comparison_expression.hpp
22732
+ // duckdb/parser/expression/constant_expression.hpp
22565
22733
  //
22566
22734
  //
22567
22735
  //===----------------------------------------------------------------------===//
@@ -22570,39 +22738,34 @@ public:
22570
22738
 
22571
22739
 
22572
22740
 
22741
+
22573
22742
  namespace duckdb {
22574
- //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
22575
- //! and has two children.
22576
- class ComparisonExpression : public ParsedExpression {
22743
+
22744
+ //! ConstantExpression represents a constant value in the query
22745
+ class ConstantExpression : public ParsedExpression {
22577
22746
  public:
22578
- DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22579
- unique_ptr<ParsedExpression> right);
22747
+ DUCKDB_API explicit ConstantExpression(Value val);
22580
22748
 
22581
- unique_ptr<ParsedExpression> left;
22582
- unique_ptr<ParsedExpression> right;
22749
+ //! The constant value referenced
22750
+ Value value;
22583
22751
 
22584
22752
  public:
22585
22753
  string ToString() const override;
22586
22754
 
22587
- static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
22755
+ static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
22756
+ hash_t Hash() const override;
22588
22757
 
22589
22758
  unique_ptr<ParsedExpression> Copy() const override;
22590
22759
 
22591
22760
  void Serialize(FieldWriter &writer) const override;
22592
22761
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22593
-
22594
- public:
22595
- template <class T, class BASE>
22596
- static string ToString(const T &entry) {
22597
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
22598
- }
22599
22762
  };
22600
- } // namespace duckdb
22601
22763
 
22764
+ } // namespace duckdb
22602
22765
  //===----------------------------------------------------------------------===//
22603
22766
  // DuckDB
22604
22767
  //
22605
- // duckdb/parser/expression/conjunction_expression.hpp
22768
+ // duckdb/parser/expression/case_expression.hpp
22606
22769
  //
22607
22770
  //
22608
22771
  //===----------------------------------------------------------------------===//
@@ -22614,22 +22777,23 @@ public:
22614
22777
 
22615
22778
  namespace duckdb {
22616
22779
 
22617
- //! Represents a conjunction (AND/OR)
22618
- class ConjunctionExpression : public ParsedExpression {
22780
+ struct CaseCheck {
22781
+ unique_ptr<ParsedExpression> when_expr;
22782
+ unique_ptr<ParsedExpression> then_expr;
22783
+ };
22784
+
22785
+ //! The CaseExpression represents a CASE expression in the query
22786
+ class CaseExpression : public ParsedExpression {
22619
22787
  public:
22620
- DUCKDB_API explicit ConjunctionExpression(ExpressionType type);
22621
- DUCKDB_API ConjunctionExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22622
- DUCKDB_API ConjunctionExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22623
- unique_ptr<ParsedExpression> right);
22788
+ DUCKDB_API CaseExpression();
22624
22789
 
22625
- vector<unique_ptr<ParsedExpression>> children;
22790
+ vector<CaseCheck> case_checks;
22791
+ unique_ptr<ParsedExpression> else_expr;
22626
22792
 
22627
22793
  public:
22628
- void AddExpression(unique_ptr<ParsedExpression> expr);
22629
-
22630
22794
  string ToString() const override;
22631
22795
 
22632
- static bool Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
22796
+ static bool Equals(const CaseExpression *a, const CaseExpression *b);
22633
22797
 
22634
22798
  unique_ptr<ParsedExpression> Copy() const override;
22635
22799
 
@@ -22639,19 +22803,64 @@ public:
22639
22803
  public:
22640
22804
  template <class T, class BASE>
22641
22805
  static string ToString(const T &entry) {
22642
- string result = entry.children[0]->ToString();
22643
- for (idx_t i = 1; i < entry.children.size(); i++) {
22644
- result += " " + ExpressionTypeToOperator(entry.type) + " " + entry.children[i]->ToString();
22806
+ string case_str = "CASE ";
22807
+ for (auto &check : entry.case_checks) {
22808
+ case_str += " WHEN (" + check.when_expr->ToString() + ")";
22809
+ case_str += " THEN (" + check.then_expr->ToString() + ")";
22645
22810
  }
22646
- return result;
22811
+ case_str += " ELSE " + entry.else_expr->ToString();
22812
+ case_str += " END";
22813
+ return case_str;
22814
+ }
22815
+ };
22816
+ } // namespace duckdb
22817
+ //===----------------------------------------------------------------------===//
22818
+ // DuckDB
22819
+ //
22820
+ // duckdb/parser/expression/between_expression.hpp
22821
+ //
22822
+ //
22823
+ //===----------------------------------------------------------------------===//
22824
+
22825
+
22826
+
22827
+
22828
+
22829
+ namespace duckdb {
22830
+
22831
+ class BetweenExpression : public ParsedExpression {
22832
+ public:
22833
+ DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
22834
+ unique_ptr<ParsedExpression> upper);
22835
+
22836
+ unique_ptr<ParsedExpression> input;
22837
+ unique_ptr<ParsedExpression> lower;
22838
+ unique_ptr<ParsedExpression> upper;
22839
+
22840
+ public:
22841
+ string ToString() const override;
22842
+
22843
+ static bool Equals(const BetweenExpression *a, const BetweenExpression *b);
22844
+
22845
+ unique_ptr<ParsedExpression> Copy() const override;
22846
+
22847
+ void Serialize(FieldWriter &writer) const override;
22848
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22849
+
22850
+ public:
22851
+ template <class T, class BASE>
22852
+ static string ToString(const T &entry) {
22853
+ return entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " + entry.upper->ToString();
22647
22854
  }
22648
22855
  };
22649
22856
  } // namespace duckdb
22650
22857
 
22858
+
22859
+
22651
22860
  //===----------------------------------------------------------------------===//
22652
22861
  // DuckDB
22653
22862
  //
22654
- // duckdb/parser/expression/constant_expression.hpp
22863
+ // duckdb/parser/expression/cast_expression.hpp
22655
22864
  //
22656
22865
  //
22657
22866
  //===----------------------------------------------------------------------===//
@@ -22663,32 +22872,41 @@ public:
22663
22872
 
22664
22873
  namespace duckdb {
22665
22874
 
22666
- //! ConstantExpression represents a constant value in the query
22667
- class ConstantExpression : public ParsedExpression {
22875
+ //! CastExpression represents a type cast from one SQL type to another SQL type
22876
+ class CastExpression : public ParsedExpression {
22668
22877
  public:
22669
- DUCKDB_API explicit ConstantExpression(Value val);
22878
+ DUCKDB_API CastExpression(LogicalType target, unique_ptr<ParsedExpression> child, bool try_cast = false);
22670
22879
 
22671
- //! The constant value referenced
22672
- Value value;
22880
+ //! The child of the cast expression
22881
+ unique_ptr<ParsedExpression> child;
22882
+ //! The type to cast to
22883
+ LogicalType cast_type;
22884
+ //! Whether or not this is a try_cast expression
22885
+ bool try_cast;
22673
22886
 
22674
22887
  public:
22675
22888
  string ToString() const override;
22676
22889
 
22677
- static bool Equals(const ConstantExpression *a, const ConstantExpression *b);
22678
- hash_t Hash() const override;
22890
+ static bool Equals(const CastExpression *a, const CastExpression *b);
22679
22891
 
22680
22892
  unique_ptr<ParsedExpression> Copy() const override;
22681
22893
 
22682
22894
  void Serialize(FieldWriter &writer) const override;
22683
22895
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22684
- };
22685
22896
 
22897
+ public:
22898
+ template <class T, class BASE>
22899
+ static string ToString(const T &entry) {
22900
+ return (entry.try_cast ? "TRY_CAST(" : "CAST(") + entry.child->ToString() + " AS " +
22901
+ entry.cast_type.ToString() + ")";
22902
+ }
22903
+ };
22686
22904
  } // namespace duckdb
22687
22905
 
22688
22906
  //===----------------------------------------------------------------------===//
22689
22907
  // DuckDB
22690
22908
  //
22691
- // duckdb/parser/expression/default_expression.hpp
22909
+ // duckdb/parser/expression/collate_expression.hpp
22692
22910
  //
22693
22911
  //
22694
22912
  //===----------------------------------------------------------------------===//
@@ -22698,25 +22916,74 @@ public:
22698
22916
 
22699
22917
 
22700
22918
  namespace duckdb {
22701
- //! Represents the default value of a column
22702
- class DefaultExpression : public ParsedExpression {
22919
+
22920
+ //! CollateExpression represents a COLLATE statement
22921
+ class CollateExpression : public ParsedExpression {
22703
22922
  public:
22704
- DefaultExpression();
22923
+ CollateExpression(string collation, unique_ptr<ParsedExpression> child);
22924
+
22925
+ //! The child of the cast expression
22926
+ unique_ptr<ParsedExpression> child;
22927
+ //! The collation clause
22928
+ string collation;
22705
22929
 
22706
22930
  public:
22707
- bool IsScalar() const override {
22708
- return false;
22709
- }
22931
+ string ToString() const override;
22932
+
22933
+ static bool Equals(const CollateExpression *a, const CollateExpression *b);
22934
+
22935
+ unique_ptr<ParsedExpression> Copy() const override;
22936
+
22937
+ void Serialize(FieldWriter &writer) const override;
22938
+ static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22939
+ };
22940
+ } // namespace duckdb
22941
+
22942
+
22943
+ //===----------------------------------------------------------------------===//
22944
+ // DuckDB
22945
+ //
22946
+ // duckdb/parser/expression/comparison_expression.hpp
22947
+ //
22948
+ //
22949
+ //===----------------------------------------------------------------------===//
22950
+
22951
+
22952
+
22953
+
22954
+
22955
+ namespace duckdb {
22956
+ //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean
22957
+ //! and has two children.
22958
+ class ComparisonExpression : public ParsedExpression {
22959
+ public:
22960
+ DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left,
22961
+ unique_ptr<ParsedExpression> right);
22962
+
22963
+ unique_ptr<ParsedExpression> left;
22964
+ unique_ptr<ParsedExpression> right;
22710
22965
 
22966
+ public:
22711
22967
  string ToString() const override;
22712
22968
 
22969
+ static bool Equals(const ComparisonExpression *a, const ComparisonExpression *b);
22970
+
22713
22971
  unique_ptr<ParsedExpression> Copy() const override;
22714
22972
 
22715
22973
  void Serialize(FieldWriter &writer) const override;
22716
22974
  static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22975
+
22976
+ public:
22977
+ template <class T, class BASE>
22978
+ static string ToString(const T &entry) {
22979
+ return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
22980
+ }
22717
22981
  };
22718
22982
  } // namespace duckdb
22719
22983
 
22984
+
22985
+
22986
+
22720
22987
  //===----------------------------------------------------------------------===//
22721
22988
  // DuckDB
22722
22989
  //
@@ -22779,7 +23046,7 @@ public:
22779
23046
  template <class T, class BASE>
22780
23047
  static string ToString(const T &entry, const string &schema, const string &function_name, bool is_operator = false,
22781
23048
  bool distinct = false, BASE *filter = nullptr, OrderModifier *order_bys = nullptr,
22782
- bool export_state = false) {
23049
+ bool export_state = false, bool add_alias = false) {
22783
23050
  if (is_operator) {
22784
23051
  // built-in operator
22785
23052
  D_ASSERT(!distinct);
@@ -22801,8 +23068,11 @@ public:
22801
23068
  if (distinct) {
22802
23069
  result += "DISTINCT ";
22803
23070
  }
22804
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22805
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
23071
+ result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
23072
+ return child->alias.empty() || !add_alias
23073
+ ? child->ToString()
23074
+ : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
23075
+ });
22806
23076
  // ordered aggregate
22807
23077
  if (order_bys && !order_bys->orders.empty()) {
22808
23078
  if (entry.children.empty()) {
@@ -22833,106 +23103,6 @@ public:
22833
23103
  } // namespace duckdb
22834
23104
 
22835
23105
 
22836
- //===----------------------------------------------------------------------===//
22837
- // DuckDB
22838
- //
22839
- // duckdb/parser/expression/operator_expression.hpp
22840
- //
22841
- //
22842
- //===----------------------------------------------------------------------===//
22843
-
22844
-
22845
-
22846
-
22847
-
22848
-
22849
-
22850
-
22851
- namespace duckdb {
22852
- //! Represents a built-in operator expression
22853
- class OperatorExpression : public ParsedExpression {
22854
- public:
22855
- DUCKDB_API explicit OperatorExpression(ExpressionType type, unique_ptr<ParsedExpression> left = nullptr,
22856
- unique_ptr<ParsedExpression> right = nullptr);
22857
- DUCKDB_API OperatorExpression(ExpressionType type, vector<unique_ptr<ParsedExpression>> children);
22858
-
22859
- vector<unique_ptr<ParsedExpression>> children;
22860
-
22861
- public:
22862
- string ToString() const override;
22863
-
22864
- static bool Equals(const OperatorExpression *a, const OperatorExpression *b);
22865
-
22866
- unique_ptr<ParsedExpression> Copy() const override;
22867
-
22868
- void Serialize(FieldWriter &writer) const override;
22869
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
22870
-
22871
- public:
22872
- template <class T, class BASE>
22873
- static string ToString(const T &entry) {
22874
- auto op = ExpressionTypeToOperator(entry.type);
22875
- if (!op.empty()) {
22876
- // use the operator string to represent the operator
22877
- D_ASSERT(entry.children.size() == 2);
22878
- return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
22879
- }
22880
- switch (entry.type) {
22881
- case ExpressionType::COMPARE_IN:
22882
- case ExpressionType::COMPARE_NOT_IN: {
22883
- string op_type = entry.type == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
22884
- string in_child = entry.children[0]->ToString();
22885
- string child_list = "(";
22886
- for (idx_t i = 1; i < entry.children.size(); i++) {
22887
- if (i > 1) {
22888
- child_list += ", ";
22889
- }
22890
- child_list += entry.children[i]->ToString();
22891
- }
22892
- child_list += ")";
22893
- return "(" + in_child + op_type + child_list + ")";
22894
- }
22895
- case ExpressionType::OPERATOR_NOT:
22896
- case ExpressionType::GROUPING_FUNCTION:
22897
- case ExpressionType::OPERATOR_COALESCE: {
22898
- string result = ExpressionTypeToString(entry.type);
22899
- result += "(";
22900
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22901
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22902
- result += ")";
22903
- return result;
22904
- }
22905
- case ExpressionType::OPERATOR_IS_NULL:
22906
- return "(" + entry.children[0]->ToString() + " IS NULL)";
22907
- case ExpressionType::OPERATOR_IS_NOT_NULL:
22908
- return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
22909
- case ExpressionType::ARRAY_EXTRACT:
22910
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
22911
- case ExpressionType::ARRAY_SLICE:
22912
- return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + ":" +
22913
- entry.children[2]->ToString() + "]";
22914
- case ExpressionType::STRUCT_EXTRACT: {
22915
- D_ASSERT(entry.children[1]->type == ExpressionType::VALUE_CONSTANT);
22916
- auto child_string = entry.children[1]->ToString();
22917
- D_ASSERT(child_string.size() >= 3);
22918
- D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
22919
- return "(" + entry.children[0]->ToString() + ")." +
22920
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
22921
- }
22922
- case ExpressionType::ARRAY_CONSTRUCTOR: {
22923
- string result = "ARRAY[";
22924
- result += StringUtil::Join(entry.children, entry.children.size(), ", ",
22925
- [](const unique_ptr<BASE> &child) { return child->ToString(); });
22926
- result += "]";
22927
- return result;
22928
- }
22929
- default:
22930
- throw InternalException("Unrecognized operator type");
22931
- }
22932
- }
22933
- };
22934
-
22935
- } // namespace duckdb
22936
23106
 
22937
23107
  //===----------------------------------------------------------------------===//
22938
23108
  // DuckDB
@@ -23006,10 +23176,11 @@ public:
23006
23176
  };
23007
23177
  } // namespace duckdb
23008
23178
 
23179
+
23009
23180
  //===----------------------------------------------------------------------===//
23010
23181
  // DuckDB
23011
23182
  //
23012
- // duckdb/parser/expression/star_expression.hpp
23183
+ // duckdb/parser/expression/subquery_expression.hpp
23013
23184
  //
23014
23185
  //
23015
23186
  //===----------------------------------------------------------------------===//
@@ -23019,52 +23190,13 @@ public:
23019
23190
 
23020
23191
 
23021
23192
 
23193
+
23022
23194
  namespace duckdb {
23023
23195
 
23024
- //! Represents a * expression in the SELECT clause
23025
- class StarExpression : public ParsedExpression {
23196
+ //! Represents a subquery
23197
+ class SubqueryExpression : public ParsedExpression {
23026
23198
  public:
23027
- StarExpression(string relation_name = string());
23028
-
23029
- //! The relation name in case of tbl.*, or empty if this is a normal *
23030
- string relation_name;
23031
- //! List of columns to exclude from the STAR expression
23032
- case_insensitive_set_t exclude_list;
23033
- //! List of columns to replace with another expression
23034
- case_insensitive_map_t<unique_ptr<ParsedExpression>> replace_list;
23035
-
23036
- public:
23037
- string ToString() const override;
23038
-
23039
- static bool Equals(const StarExpression *a, const StarExpression *b);
23040
-
23041
- unique_ptr<ParsedExpression> Copy() const override;
23042
-
23043
- void Serialize(FieldWriter &writer) const override;
23044
- static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
23045
- };
23046
- } // namespace duckdb
23047
-
23048
- //===----------------------------------------------------------------------===//
23049
- // DuckDB
23050
- //
23051
- // duckdb/parser/expression/subquery_expression.hpp
23052
- //
23053
- //
23054
- //===----------------------------------------------------------------------===//
23055
-
23056
-
23057
-
23058
-
23059
-
23060
-
23061
-
23062
- namespace duckdb {
23063
-
23064
- //! Represents a subquery
23065
- class SubqueryExpression : public ParsedExpression {
23066
- public:
23067
- SubqueryExpression();
23199
+ SubqueryExpression();
23068
23200
 
23069
23201
  //! The actual subquery
23070
23202
  unique_ptr<SelectStatement> subquery;
@@ -23099,7 +23231,7 @@ public:
23099
23231
  //===----------------------------------------------------------------------===//
23100
23232
  // DuckDB
23101
23233
  //
23102
- // duckdb/parser/parsed_data/create_collation_info.hpp
23234
+ // duckdb/parser/parsed_data/export_table_data.hpp
23103
23235
  //
23104
23236
  //
23105
23237
  //===----------------------------------------------------------------------===//
@@ -23111,112 +23243,24 @@ public:
23111
23243
 
23112
23244
  namespace duckdb {
23113
23245
 
23114
- struct CreateCollationInfo : public CreateInfo {
23115
- CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
23116
- : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
23117
- not_required_for_equality(not_required_for_equality_p) {
23118
- this->name = move(name_p);
23119
- }
23120
-
23121
- //! The name of the collation
23122
- string name;
23123
- //! The collation function to push in case collation is required
23124
- ScalarFunction function;
23125
- //! Whether or not the collation can be combined with other collations.
23126
- bool combinable;
23127
- //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
23128
- //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
23129
- //! speeds up processing.
23130
- bool not_required_for_equality;
23131
-
23132
- public:
23133
- unique_ptr<CreateInfo> Copy() const override {
23134
- auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
23135
- CopyProperties(*result);
23136
- return move(result);
23137
- }
23138
- };
23139
-
23140
- } // namespace duckdb
23141
- //===----------------------------------------------------------------------===//
23142
- // DuckDB
23143
- //
23144
- // duckdb/parser/parsed_data/create_schema_info.hpp
23145
- //
23146
- //
23147
- //===----------------------------------------------------------------------===//
23148
-
23149
-
23150
-
23151
-
23152
-
23153
- namespace duckdb {
23246
+ struct ExportedTableData {
23247
+ //! Name of the exported table
23248
+ string table_name;
23154
23249
 
23155
- struct CreateSchemaInfo : public CreateInfo {
23156
- CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
23157
- }
23250
+ //! Name of the schema
23251
+ string schema_name;
23158
23252
 
23159
- public:
23160
- unique_ptr<CreateInfo> Copy() const override {
23161
- auto result = make_unique<CreateSchemaInfo>();
23162
- CopyProperties(*result);
23163
- return move(result);
23164
- }
23253
+ //! Path to be exported
23254
+ string file_path;
23165
23255
  };
23166
23256
 
23167
- } // namespace duckdb
23168
- //===----------------------------------------------------------------------===//
23169
- // DuckDB
23170
- //
23171
- // duckdb/parser/parsed_data/show_select_info.hpp
23172
- //
23173
- //
23174
- //===----------------------------------------------------------------------===//
23175
-
23176
-
23177
-
23178
-
23179
-
23180
-
23181
- namespace duckdb {
23182
-
23183
- struct ShowSelectInfo : public ParseInfo {
23184
- //! Types of projected columns
23185
- vector<LogicalType> types;
23186
- //! The QueryNode of select query
23187
- unique_ptr<QueryNode> query;
23188
- //! Aliases of projected columns
23189
- vector<string> aliases;
23190
- //! Whether or not we are requesting a summary or a describe
23191
- bool is_summary;
23192
-
23193
- unique_ptr<ShowSelectInfo> Copy() {
23194
- auto result = make_unique<ShowSelectInfo>();
23195
- result->types = types;
23196
- result->query = query->Copy();
23197
- result->aliases = aliases;
23198
- result->is_summary = is_summary;
23199
- return result;
23200
- }
23257
+ struct ExportedTableInfo {
23258
+ TableCatalogEntry *entry;
23259
+ ExportedTableData table_data;
23201
23260
  };
23202
23261
 
23203
- } // namespace duckdb
23204
- //===----------------------------------------------------------------------===//
23205
- // DuckDB
23206
- //
23207
- // duckdb/parser/parsed_data/vacuum_info.hpp
23208
- //
23209
- //
23210
- //===----------------------------------------------------------------------===//
23211
-
23212
-
23213
-
23214
-
23215
-
23216
- namespace duckdb {
23217
-
23218
- struct VacuumInfo : public ParseInfo {
23219
- // nothing for now
23262
+ struct BoundExportData : public ParseInfo {
23263
+ std::vector<ExportedTableInfo> data;
23220
23264
  };
23221
23265
 
23222
23266
  } // namespace duckdb
@@ -23307,6 +23351,129 @@ public:
23307
23351
  }
23308
23352
  };
23309
23353
 
23354
+ } // namespace duckdb
23355
+ //===----------------------------------------------------------------------===//
23356
+ // DuckDB
23357
+ //
23358
+ // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23359
+ //
23360
+ //
23361
+ //===----------------------------------------------------------------------===//
23362
+
23363
+
23364
+
23365
+
23366
+
23367
+
23368
+ namespace duckdb {
23369
+
23370
+ struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23371
+ explicit CreateAggregateFunctionInfo(AggregateFunction function)
23372
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23373
+ this->name = function.name;
23374
+ functions.AddFunction(move(function));
23375
+ }
23376
+
23377
+ explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23378
+ : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23379
+ this->name = functions.name;
23380
+ for (auto &func : functions.functions) {
23381
+ func.name = functions.name;
23382
+ }
23383
+ }
23384
+
23385
+ AggregateFunctionSet functions;
23386
+
23387
+ public:
23388
+ unique_ptr<CreateInfo> Copy() const override {
23389
+ auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23390
+ CopyProperties(*result);
23391
+ return move(result);
23392
+ }
23393
+ };
23394
+
23395
+ } // namespace duckdb
23396
+ //===----------------------------------------------------------------------===//
23397
+ // DuckDB
23398
+ //
23399
+ // duckdb/parser/parsed_data/create_collation_info.hpp
23400
+ //
23401
+ //
23402
+ //===----------------------------------------------------------------------===//
23403
+
23404
+
23405
+
23406
+
23407
+
23408
+
23409
+ namespace duckdb {
23410
+
23411
+ struct CreateCollationInfo : public CreateInfo {
23412
+ CreateCollationInfo(string name_p, ScalarFunction function_p, bool combinable_p, bool not_required_for_equality_p)
23413
+ : CreateInfo(CatalogType::COLLATION_ENTRY), function(move(function_p)), combinable(combinable_p),
23414
+ not_required_for_equality(not_required_for_equality_p) {
23415
+ this->name = move(name_p);
23416
+ }
23417
+
23418
+ //! The name of the collation
23419
+ string name;
23420
+ //! The collation function to push in case collation is required
23421
+ ScalarFunction function;
23422
+ //! Whether or not the collation can be combined with other collations.
23423
+ bool combinable;
23424
+ //! Whether or not the collation is required for equality comparisons or not. For many collations a binary
23425
+ //! comparison for equality comparisons is correct, allowing us to skip the collation in these cases which greatly
23426
+ //! speeds up processing.
23427
+ bool not_required_for_equality;
23428
+
23429
+ public:
23430
+ unique_ptr<CreateInfo> Copy() const override {
23431
+ auto result = make_unique<CreateCollationInfo>(name, function, combinable, not_required_for_equality);
23432
+ CopyProperties(*result);
23433
+ return move(result);
23434
+ }
23435
+ };
23436
+
23437
+ } // namespace duckdb
23438
+ //===----------------------------------------------------------------------===//
23439
+ // DuckDB
23440
+ //
23441
+ // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23442
+ //
23443
+ //
23444
+ //===----------------------------------------------------------------------===//
23445
+
23446
+
23447
+
23448
+
23449
+
23450
+
23451
+ namespace duckdb {
23452
+
23453
+ struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23454
+ explicit CreatePragmaFunctionInfo(PragmaFunction function)
23455
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23456
+ functions.push_back(move(function));
23457
+ this->name = function.name;
23458
+ }
23459
+ CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23460
+ : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23461
+ this->name = name;
23462
+ for (auto &function : functions) {
23463
+ function.name = name;
23464
+ }
23465
+ }
23466
+
23467
+ vector<PragmaFunction> functions;
23468
+
23469
+ public:
23470
+ unique_ptr<CreateInfo> Copy() const override {
23471
+ auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23472
+ CopyProperties(*result);
23473
+ return move(result);
23474
+ }
23475
+ };
23476
+
23310
23477
  } // namespace duckdb
23311
23478
  //===----------------------------------------------------------------------===//
23312
23479
  // DuckDB
@@ -23336,7 +23503,7 @@ struct TransactionInfo : public ParseInfo {
23336
23503
  //===----------------------------------------------------------------------===//
23337
23504
  // DuckDB
23338
23505
  //
23339
- // duckdb/parser/parsed_data/create_type_info.hpp
23506
+ // duckdb/parser/parsed_data/drop_info.hpp
23340
23507
  //
23341
23508
  //
23342
23509
  //===----------------------------------------------------------------------===//
@@ -23346,27 +23513,33 @@ struct TransactionInfo : public ParseInfo {
23346
23513
 
23347
23514
 
23348
23515
 
23349
-
23350
-
23351
23516
  namespace duckdb {
23352
23517
 
23353
- struct CreateTypeInfo : public CreateInfo {
23354
-
23355
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23518
+ struct DropInfo : public ParseInfo {
23519
+ DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23356
23520
  }
23357
23521
 
23358
- //! Name of the Type
23522
+ //! The catalog type to drop
23523
+ CatalogType type;
23524
+ //! Schema name to drop from, if any
23525
+ string schema;
23526
+ //! Element name to drop
23359
23527
  string name;
23360
- //! Logical Type
23361
- LogicalType type;
23528
+ //! Ignore if the entry does not exist instead of failing
23529
+ bool if_exists = false;
23530
+ //! Cascade drop (drop all dependents instead of throwing an error if there
23531
+ //! are any)
23532
+ bool cascade = false;
23362
23533
 
23363
23534
  public:
23364
- unique_ptr<CreateInfo> Copy() const override {
23365
- auto result = make_unique<CreateTypeInfo>();
23366
- CopyProperties(*result);
23367
- result->name = name;
23535
+ unique_ptr<DropInfo> Copy() const {
23536
+ auto result = make_unique<DropInfo>();
23368
23537
  result->type = type;
23369
- return move(result);
23538
+ result->schema = schema;
23539
+ result->name = name;
23540
+ result->if_exists = if_exists;
23541
+ result->cascade = cascade;
23542
+ return result;
23370
23543
  }
23371
23544
  };
23372
23545
 
@@ -23374,7 +23547,7 @@ public:
23374
23547
  //===----------------------------------------------------------------------===//
23375
23548
  // DuckDB
23376
23549
  //
23377
- // duckdb/parser/parsed_data/create_view_info.hpp
23550
+ // duckdb/parser/parsed_data/create_schema_info.hpp
23378
23551
  //
23379
23552
  //
23380
23553
  //===----------------------------------------------------------------------===//
@@ -23383,32 +23556,16 @@ public:
23383
23556
 
23384
23557
 
23385
23558
 
23386
-
23387
23559
  namespace duckdb {
23388
23560
 
23389
- struct CreateViewInfo : public CreateInfo {
23390
- CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
23391
- }
23392
- CreateViewInfo(string schema, string view_name)
23393
- : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
23561
+ struct CreateSchemaInfo : public CreateInfo {
23562
+ CreateSchemaInfo() : CreateInfo(CatalogType::SCHEMA_ENTRY) {
23394
23563
  }
23395
23564
 
23396
- //! Table name to insert to
23397
- string view_name;
23398
- //! Aliases of the view
23399
- vector<string> aliases;
23400
- //! Return types
23401
- vector<LogicalType> types;
23402
- //! The SelectStatement of the view
23403
- unique_ptr<SelectStatement> query;
23404
-
23405
23565
  public:
23406
23566
  unique_ptr<CreateInfo> Copy() const override {
23407
- auto result = make_unique<CreateViewInfo>(schema, view_name);
23567
+ auto result = make_unique<CreateSchemaInfo>();
23408
23568
  CopyProperties(*result);
23409
- result->aliases = aliases;
23410
- result->types = types;
23411
- result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
23412
23569
  return move(result);
23413
23570
  }
23414
23571
  };
@@ -23501,7 +23658,7 @@ public:
23501
23658
  //===----------------------------------------------------------------------===//
23502
23659
  // DuckDB
23503
23660
  //
23504
- // duckdb/parser/parsed_data/export_table_data.hpp
23661
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23505
23662
  //
23506
23663
  //
23507
23664
  //===----------------------------------------------------------------------===//
@@ -23510,34 +23667,28 @@ public:
23510
23667
 
23511
23668
 
23512
23669
 
23513
-
23514
23670
  namespace duckdb {
23515
23671
 
23516
- struct ExportedTableData {
23517
- //! Name of the exported table
23518
- string table_name;
23519
-
23520
- //! Name of the schema
23521
- string schema_name;
23522
-
23523
- //! Path to be exported
23524
- string file_path;
23525
- };
23672
+ enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23526
23673
 
23527
- struct ExportedTableInfo {
23528
- TableCatalogEntry *entry;
23529
- ExportedTableData table_data;
23530
- };
23674
+ struct LoadInfo : public ParseInfo {
23675
+ std::string filename;
23676
+ LoadType load_type;
23531
23677
 
23532
- struct BoundExportData : public ParseInfo {
23533
- std::vector<ExportedTableInfo> data;
23678
+ public:
23679
+ unique_ptr<LoadInfo> Copy() const {
23680
+ auto result = make_unique<LoadInfo>();
23681
+ result->filename = filename;
23682
+ result->load_type = load_type;
23683
+ return result;
23684
+ }
23534
23685
  };
23535
23686
 
23536
23687
  } // namespace duckdb
23537
23688
  //===----------------------------------------------------------------------===//
23538
23689
  // DuckDB
23539
23690
  //
23540
- // duckdb/parser/parsed_data/vacuum_info.hpp
23691
+ // duckdb/parser/parsed_data/create_type_info.hpp
23541
23692
  //
23542
23693
  //
23543
23694
  //===----------------------------------------------------------------------===//
@@ -23546,20 +23697,28 @@ struct BoundExportData : public ParseInfo {
23546
23697
 
23547
23698
 
23548
23699
 
23700
+
23701
+
23702
+
23549
23703
  namespace duckdb {
23550
23704
 
23551
- enum class LoadType { LOAD, INSTALL, FORCE_INSTALL };
23705
+ struct CreateTypeInfo : public CreateInfo {
23552
23706
 
23553
- struct LoadInfo : public ParseInfo {
23554
- std::string filename;
23555
- LoadType load_type;
23707
+ CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
23708
+ }
23709
+
23710
+ //! Name of the Type
23711
+ string name;
23712
+ //! Logical Type
23713
+ LogicalType type;
23556
23714
 
23557
23715
  public:
23558
- unique_ptr<LoadInfo> Copy() const {
23559
- auto result = make_unique<LoadInfo>();
23560
- result->filename = filename;
23561
- result->load_type = load_type;
23562
- return result;
23716
+ unique_ptr<CreateInfo> Copy() const override {
23717
+ auto result = make_unique<CreateTypeInfo>();
23718
+ CopyProperties(*result);
23719
+ result->name = name;
23720
+ result->type = type;
23721
+ return move(result);
23563
23722
  }
23564
23723
  };
23565
23724
 
@@ -23567,7 +23726,7 @@ public:
23567
23726
  //===----------------------------------------------------------------------===//
23568
23727
  // DuckDB
23569
23728
  //
23570
- // duckdb/parser/parsed_data/create_aggregate_function_info.hpp
23729
+ // duckdb/parser/parsed_data/create_view_info.hpp
23571
23730
  //
23572
23731
  //
23573
23732
  //===----------------------------------------------------------------------===//
@@ -23579,27 +23738,29 @@ public:
23579
23738
 
23580
23739
  namespace duckdb {
23581
23740
 
23582
- struct CreateAggregateFunctionInfo : public CreateFunctionInfo {
23583
- explicit CreateAggregateFunctionInfo(AggregateFunction function)
23584
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(function.name) {
23585
- this->name = function.name;
23586
- functions.AddFunction(move(function));
23741
+ struct CreateViewInfo : public CreateInfo {
23742
+ CreateViewInfo() : CreateInfo(CatalogType::VIEW_ENTRY, INVALID_SCHEMA) {
23587
23743
  }
23588
-
23589
- explicit CreateAggregateFunctionInfo(AggregateFunctionSet set)
23590
- : CreateFunctionInfo(CatalogType::AGGREGATE_FUNCTION_ENTRY), functions(move(set)) {
23591
- this->name = functions.name;
23592
- for (auto &func : functions.functions) {
23593
- func.name = functions.name;
23594
- }
23744
+ CreateViewInfo(string schema, string view_name)
23745
+ : CreateInfo(CatalogType::VIEW_ENTRY, schema), view_name(view_name) {
23595
23746
  }
23596
23747
 
23597
- AggregateFunctionSet functions;
23748
+ //! Table name to insert to
23749
+ string view_name;
23750
+ //! Aliases of the view
23751
+ vector<string> aliases;
23752
+ //! Return types
23753
+ vector<LogicalType> types;
23754
+ //! The SelectStatement of the view
23755
+ unique_ptr<SelectStatement> query;
23598
23756
 
23599
23757
  public:
23600
23758
  unique_ptr<CreateInfo> Copy() const override {
23601
- auto result = make_unique<CreateAggregateFunctionInfo>(functions);
23759
+ auto result = make_unique<CreateViewInfo>(schema, view_name);
23602
23760
  CopyProperties(*result);
23761
+ result->aliases = aliases;
23762
+ result->types = types;
23763
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
23603
23764
  return move(result);
23604
23765
  }
23605
23766
  };
@@ -23608,7 +23769,7 @@ public:
23608
23769
  //===----------------------------------------------------------------------===//
23609
23770
  // DuckDB
23610
23771
  //
23611
- // duckdb/parser/parsed_data/drop_info.hpp
23772
+ // duckdb/parser/parsed_data/vacuum_info.hpp
23612
23773
  //
23613
23774
  //
23614
23775
  //===----------------------------------------------------------------------===//
@@ -23617,42 +23778,17 @@ public:
23617
23778
 
23618
23779
 
23619
23780
 
23620
-
23621
23781
  namespace duckdb {
23622
23782
 
23623
- struct DropInfo : public ParseInfo {
23624
- DropInfo() : schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
23625
- }
23626
-
23627
- //! The catalog type to drop
23628
- CatalogType type;
23629
- //! Schema name to drop from, if any
23630
- string schema;
23631
- //! Element name to drop
23632
- string name;
23633
- //! Ignore if the entry does not exist instead of failing
23634
- bool if_exists = false;
23635
- //! Cascade drop (drop all dependents instead of throwing an error if there
23636
- //! are any)
23637
- bool cascade = false;
23638
-
23639
- public:
23640
- unique_ptr<DropInfo> Copy() const {
23641
- auto result = make_unique<DropInfo>();
23642
- result->type = type;
23643
- result->schema = schema;
23644
- result->name = name;
23645
- result->if_exists = if_exists;
23646
- result->cascade = cascade;
23647
- return result;
23648
- }
23783
+ struct VacuumInfo : public ParseInfo {
23784
+ // nothing for now
23649
23785
  };
23650
23786
 
23651
23787
  } // namespace duckdb
23652
23788
  //===----------------------------------------------------------------------===//
23653
23789
  // DuckDB
23654
23790
  //
23655
- // duckdb/parser/parsed_data/create_pragma_function_info.hpp
23791
+ // duckdb/parser/parsed_data/show_select_info.hpp
23656
23792
  //
23657
23793
  //
23658
23794
  //===----------------------------------------------------------------------===//
@@ -23664,27 +23800,23 @@ public:
23664
23800
 
23665
23801
  namespace duckdb {
23666
23802
 
23667
- struct CreatePragmaFunctionInfo : public CreateFunctionInfo {
23668
- explicit CreatePragmaFunctionInfo(PragmaFunction function)
23669
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY) {
23670
- functions.push_back(move(function));
23671
- this->name = function.name;
23672
- }
23673
- CreatePragmaFunctionInfo(string name, vector<PragmaFunction> functions_)
23674
- : CreateFunctionInfo(CatalogType::PRAGMA_FUNCTION_ENTRY), functions(move(functions_)) {
23675
- this->name = name;
23676
- for (auto &function : functions) {
23677
- function.name = name;
23678
- }
23679
- }
23680
-
23681
- vector<PragmaFunction> functions;
23803
+ struct ShowSelectInfo : public ParseInfo {
23804
+ //! Types of projected columns
23805
+ vector<LogicalType> types;
23806
+ //! The QueryNode of select query
23807
+ unique_ptr<QueryNode> query;
23808
+ //! Aliases of projected columns
23809
+ vector<string> aliases;
23810
+ //! Whether or not we are requesting a summary or a describe
23811
+ bool is_summary;
23682
23812
 
23683
- public:
23684
- unique_ptr<CreateInfo> Copy() const override {
23685
- auto result = make_unique<CreatePragmaFunctionInfo>(functions[0].name, functions);
23686
- CopyProperties(*result);
23687
- return move(result);
23813
+ unique_ptr<ShowSelectInfo> Copy() {
23814
+ auto result = make_unique<ShowSelectInfo>();
23815
+ result->types = types;
23816
+ result->query = query->Copy();
23817
+ result->aliases = aliases;
23818
+ result->is_summary = is_summary;
23819
+ return result;
23688
23820
  }
23689
23821
  };
23690
23822
 
@@ -23692,7 +23824,7 @@ public:
23692
23824
  //===----------------------------------------------------------------------===//
23693
23825
  // DuckDB
23694
23826
  //
23695
- // duckdb/parser/tableref/expressionlistref.hpp
23827
+ // duckdb/parser/tableref/emptytableref.hpp
23696
23828
  //
23697
23829
  //
23698
23830
  //===----------------------------------------------------------------------===//
@@ -23701,35 +23833,25 @@ public:
23701
23833
 
23702
23834
 
23703
23835
 
23704
-
23705
-
23706
-
23707
23836
  namespace duckdb {
23708
- //! Represents an expression list as generated by a VALUES statement
23709
- class ExpressionListRef : public TableRef {
23837
+ //! Represents a cross product
23838
+ class EmptyTableRef : public TableRef {
23710
23839
  public:
23711
- ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
23840
+ EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
23712
23841
  }
23713
23842
 
23714
- //! Value list, only used for VALUES statement
23715
- vector<vector<unique_ptr<ParsedExpression>>> values;
23716
- //! Expected SQL types
23717
- vector<LogicalType> expected_types;
23718
- //! The set of expected names
23719
- vector<string> expected_names;
23720
-
23721
23843
  public:
23844
+ string ToString() const override;
23722
23845
  bool Equals(const TableRef *other_p) const override;
23723
23846
 
23724
23847
  unique_ptr<TableRef> Copy() override;
23725
23848
 
23726
- //! Serializes a blob into a ExpressionListRef
23849
+ //! Serializes a blob into a DummyTableRef
23727
23850
  void Serialize(FieldWriter &serializer) const override;
23728
- //! Deserializes a blob back into a ExpressionListRef
23851
+ //! Deserializes a blob back into a DummyTableRef
23729
23852
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23730
23853
  };
23731
23854
  } // namespace duckdb
23732
-
23733
23855
  //===----------------------------------------------------------------------===//
23734
23856
  // DuckDB
23735
23857
  //
@@ -23755,6 +23877,7 @@ public:
23755
23877
  unique_ptr<TableRef> right;
23756
23878
 
23757
23879
  public:
23880
+ string ToString() const override;
23758
23881
  bool Equals(const TableRef *other_p) const override;
23759
23882
 
23760
23883
  unique_ptr<TableRef> Copy() override;
@@ -23766,10 +23889,12 @@ public:
23766
23889
  };
23767
23890
  } // namespace duckdb
23768
23891
 
23892
+
23893
+
23769
23894
  //===----------------------------------------------------------------------===//
23770
23895
  // DuckDB
23771
23896
  //
23772
- // duckdb/parser/tableref/emptytableref.hpp
23897
+ // duckdb/parser/tableref/expressionlistref.hpp
23773
23898
  //
23774
23899
  //
23775
23900
  //===----------------------------------------------------------------------===//
@@ -23778,26 +23903,36 @@ public:
23778
23903
 
23779
23904
 
23780
23905
 
23906
+
23907
+
23908
+
23781
23909
  namespace duckdb {
23782
- //! Represents a cross product
23783
- class EmptyTableRef : public TableRef {
23910
+ //! Represents an expression list as generated by a VALUES statement
23911
+ class ExpressionListRef : public TableRef {
23784
23912
  public:
23785
- EmptyTableRef() : TableRef(TableReferenceType::EMPTY) {
23913
+ ExpressionListRef() : TableRef(TableReferenceType::EXPRESSION_LIST) {
23786
23914
  }
23787
23915
 
23916
+ //! Value list, only used for VALUES statement
23917
+ vector<vector<unique_ptr<ParsedExpression>>> values;
23918
+ //! Expected SQL types
23919
+ vector<LogicalType> expected_types;
23920
+ //! The set of expected names
23921
+ vector<string> expected_names;
23922
+
23788
23923
  public:
23924
+ string ToString() const override;
23789
23925
  bool Equals(const TableRef *other_p) const override;
23790
23926
 
23791
23927
  unique_ptr<TableRef> Copy() override;
23792
23928
 
23793
- //! Serializes a blob into a DummyTableRef
23929
+ //! Serializes a blob into a ExpressionListRef
23794
23930
  void Serialize(FieldWriter &serializer) const override;
23795
- //! Deserializes a blob back into a DummyTableRef
23931
+ //! Deserializes a blob back into a ExpressionListRef
23796
23932
  static unique_ptr<TableRef> Deserialize(FieldReader &source);
23797
23933
  };
23798
23934
  } // namespace duckdb
23799
23935
 
23800
-
23801
23936
  //===----------------------------------------------------------------------===//
23802
23937
  // DuckDB
23803
23938
  //
@@ -23835,6 +23970,7 @@ public:
23835
23970
  vector<string> using_columns;
23836
23971
 
23837
23972
  public:
23973
+ string ToString() const override;
23838
23974
  bool Equals(const TableRef *other_p) const override;
23839
23975
 
23840
23976
  unique_ptr<TableRef> Copy() override;
@@ -23871,6 +24007,7 @@ public:
23871
24007
  vector<string> column_name_alias;
23872
24008
 
23873
24009
  public:
24010
+ string ToString() const override;
23874
24011
  bool Equals(const TableRef *other_p) const override;
23875
24012
 
23876
24013
  unique_ptr<TableRef> Copy() override;
@@ -23901,8 +24038,7 @@ namespace duckdb {
23901
24038
  //! Represents a Table producing function
23902
24039
  class TableFunctionRef : public TableRef {
23903
24040
  public:
23904
- TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
23905
- }
24041
+ DUCKDB_API TableFunctionRef();
23906
24042
 
23907
24043
  unique_ptr<ParsedExpression> function;
23908
24044
  vector<string> column_name_alias;