duckdb 0.5.1-dev29.0 → 0.5.1-dev291.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 "9bf9c4b8f"
15
- #define DUCKDB_VERSION "v0.5.1-dev29"
14
+ #define DUCKDB_SOURCE_ID "7c111322d"
15
+ #define DUCKDB_VERSION "v0.5.1-dev291"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -670,7 +670,7 @@ struct date_t { // NOLINT
670
670
 
671
671
  //! Type used to represent time (microseconds)
672
672
  struct dtime_t { // NOLINT
673
- int64_t micros;
673
+ int64_t micros;
674
674
 
675
675
  dtime_t() = default;
676
676
  explicit inline dtime_t(int64_t micros_p) : micros(micros_p) {}
@@ -705,9 +705,11 @@ struct dtime_t { // NOLINT
705
705
  static inline dtime_t allballs() {return dtime_t(0); } // NOLINT
706
706
  };
707
707
 
708
+ struct dtime_tz_t : public dtime_t {};
709
+
708
710
  //! Type used to represent timestamps (seconds,microseconds,milliseconds or nanoseconds since 1970-01-01)
709
711
  struct timestamp_t { // NOLINT
710
- int64_t value;
712
+ int64_t value;
711
713
 
712
714
  timestamp_t() = default;
713
715
  explicit inline timestamp_t(int64_t value_p) : value(value_p) {}
@@ -738,6 +740,11 @@ struct timestamp_t { // NOLINT
738
740
  static inline timestamp_t epoch() {return timestamp_t(0); } // NOLINT
739
741
  };
740
742
 
743
+ struct timestamp_tz_t : public timestamp_t {};
744
+ struct timestamp_ns_t : public timestamp_t {};
745
+ struct timestamp_ms_t : public timestamp_t {};
746
+ struct timestamp_sec_t : public timestamp_t {};
747
+
741
748
  struct interval_t {
742
749
  int32_t months;
743
750
  int32_t days;
@@ -1021,6 +1028,10 @@ struct LogicalType {
1021
1028
  inline const ExtraTypeInfo *AuxInfo() const {
1022
1029
  return type_info_.get();
1023
1030
  }
1031
+ inline void CopyAuxInfo(const LogicalType& other) {
1032
+ type_info_ = other.type_info_;
1033
+ }
1034
+ bool EqualTypeInfo(const LogicalType& rhs) const;
1024
1035
 
1025
1036
  // copy assignment
1026
1037
  inline LogicalType& operator=(const LogicalType &other) {
@@ -1047,6 +1058,16 @@ struct LogicalType {
1047
1058
  //! Deserializes a blob back into an LogicalType
1048
1059
  DUCKDB_API static LogicalType Deserialize(Deserializer &source);
1049
1060
 
1061
+ DUCKDB_API static bool TypeIsTimestamp(LogicalTypeId id) {
1062
+ return (id == LogicalTypeId::TIMESTAMP ||
1063
+ id == LogicalTypeId::TIMESTAMP_MS ||
1064
+ id == LogicalTypeId::TIMESTAMP_NS ||
1065
+ id == LogicalTypeId::TIMESTAMP_SEC ||
1066
+ id == LogicalTypeId::TIMESTAMP_TZ);
1067
+ }
1068
+ DUCKDB_API static bool TypeIsTimestamp(const LogicalType& type) {
1069
+ return TypeIsTimestamp(type.id());
1070
+ }
1050
1071
  DUCKDB_API string ToString() const;
1051
1072
  DUCKDB_API bool IsIntegral() const;
1052
1073
  DUCKDB_API bool IsNumeric() const;
@@ -1263,6 +1284,87 @@ struct aggregate_state_t {
1263
1284
 
1264
1285
  } // namespace duckdb
1265
1286
 
1287
+ namespace std {
1288
+
1289
+ //! Date
1290
+ template <>
1291
+ struct hash<duckdb::date_t>
1292
+ {
1293
+ std::size_t operator()(const duckdb::date_t& k) const
1294
+ {
1295
+ using std::hash;
1296
+ return hash<int32_t>()((int32_t)k);
1297
+ }
1298
+ };
1299
+
1300
+ //! Time
1301
+ template <>
1302
+ struct hash<duckdb::dtime_t>
1303
+ {
1304
+ std::size_t operator()(const duckdb::dtime_t& k) const
1305
+ {
1306
+ using std::hash;
1307
+ return hash<int64_t>()((int64_t)k);
1308
+ }
1309
+ };
1310
+ template <>
1311
+ struct hash<duckdb::dtime_tz_t>
1312
+ {
1313
+ std::size_t operator()(const duckdb::dtime_tz_t& k) const
1314
+ {
1315
+ using std::hash;
1316
+ return hash<int64_t>()((int64_t)k);
1317
+ }
1318
+ };
1319
+
1320
+ //! Timestamp
1321
+ template <>
1322
+ struct hash<duckdb::timestamp_t>
1323
+ {
1324
+ std::size_t operator()(const duckdb::timestamp_t& k) const
1325
+ {
1326
+ using std::hash;
1327
+ return hash<int64_t>()((int64_t)k);
1328
+ }
1329
+ };
1330
+ template <>
1331
+ struct hash<duckdb::timestamp_ms_t>
1332
+ {
1333
+ std::size_t operator()(const duckdb::timestamp_ms_t& k) const
1334
+ {
1335
+ using std::hash;
1336
+ return hash<int64_t>()((int64_t)k);
1337
+ }
1338
+ };
1339
+ template <>
1340
+ struct hash<duckdb::timestamp_ns_t>
1341
+ {
1342
+ std::size_t operator()(const duckdb::timestamp_ns_t& k) const
1343
+ {
1344
+ using std::hash;
1345
+ return hash<int64_t>()((int64_t)k);
1346
+ }
1347
+ };
1348
+ template <>
1349
+ struct hash<duckdb::timestamp_sec_t>
1350
+ {
1351
+ std::size_t operator()(const duckdb::timestamp_sec_t& k) const
1352
+ {
1353
+ using std::hash;
1354
+ return hash<int64_t>()((int64_t)k);
1355
+ }
1356
+ };
1357
+ template <>
1358
+ struct hash<duckdb::timestamp_tz_t>
1359
+ {
1360
+ std::size_t operator()(const duckdb::timestamp_tz_t& k) const
1361
+ {
1362
+ using std::hash;
1363
+ return hash<int64_t>()((int64_t)k);
1364
+ }
1365
+ };
1366
+ }
1367
+
1266
1368
 
1267
1369
  namespace duckdb {
1268
1370
 
@@ -3161,8 +3263,18 @@ Value DUCKDB_API Value::CreateValue(date_t value);
3161
3263
  template <>
3162
3264
  Value DUCKDB_API Value::CreateValue(dtime_t value);
3163
3265
  template <>
3266
+ Value DUCKDB_API Value::CreateValue(dtime_tz_t value);
3267
+ template <>
3164
3268
  Value DUCKDB_API Value::CreateValue(timestamp_t value);
3165
3269
  template <>
3270
+ Value DUCKDB_API Value::CreateValue(timestamp_sec_t value);
3271
+ template <>
3272
+ Value DUCKDB_API Value::CreateValue(timestamp_ms_t value);
3273
+ template <>
3274
+ Value DUCKDB_API Value::CreateValue(timestamp_ns_t value);
3275
+ template <>
3276
+ Value DUCKDB_API Value::CreateValue(timestamp_tz_t value);
3277
+ template <>
3166
3278
  Value DUCKDB_API Value::CreateValue(const char *value);
3167
3279
  template <>
3168
3280
  Value DUCKDB_API Value::CreateValue(string value);
@@ -4303,6 +4415,13 @@ struct StringVector {
4303
4415
  DUCKDB_API static void AddHeapReference(Vector &vector, Vector &other);
4304
4416
  };
4305
4417
 
4418
+ struct MapVector {
4419
+ DUCKDB_API static const Vector &GetKeys(const Vector &vector);
4420
+ DUCKDB_API static const Vector &GetValues(const Vector &vector);
4421
+ DUCKDB_API static Vector &GetKeys(Vector &vector);
4422
+ DUCKDB_API static Vector &GetValues(Vector &vector);
4423
+ };
4424
+
4306
4425
  struct StructVector {
4307
4426
  DUCKDB_API static const vector<unique_ptr<Vector>> &GetEntries(const Vector &vector);
4308
4427
  DUCKDB_API static vector<unique_ptr<Vector>> &GetEntries(Vector &vector);
@@ -9819,10 +9938,13 @@ public:
9819
9938
  //! Returns a reference to the column of the specified name. Throws an
9820
9939
  //! exception if the column does not exist.
9821
9940
  ColumnDefinition &GetColumn(const string &name);
9822
- //! Returns a list of types of the table
9941
+ //! Returns a list of types of the table, excluding generated columns
9823
9942
  vector<LogicalType> GetTypes();
9824
9943
  string ToSQL() override;
9825
9944
 
9945
+ //! Get statistics of a column (physical or virtual) within the table
9946
+ unique_ptr<BaseStatistics> GetStatistics(ClientContext &context, column_t column_id);
9947
+
9826
9948
  //! Serialize the meta information of the TableCatalogEntry a serializer
9827
9949
  virtual void Serialize(Serializer &serializer);
9828
9950
  //! Deserializes to a CreateTableInfo
@@ -12844,6 +12966,7 @@ public:
12844
12966
 
12845
12967
  //! Push a new error
12846
12968
  void PushError(PreservedError exception);
12969
+
12847
12970
  //! True if an error has been thrown
12848
12971
  bool HasError();
12849
12972
  //! Throw the exception that was pushed using PushError.
@@ -12891,13 +13014,13 @@ private:
12891
13014
 
12892
13015
  void VerifyPipeline(Pipeline &pipeline);
12893
13016
  void VerifyPipelines();
12894
- void ThrowExceptionInternal();
12895
13017
 
12896
13018
  private:
12897
13019
  PhysicalOperator *physical_plan;
12898
13020
  unique_ptr<PhysicalOperator> owned_plan;
12899
13021
 
12900
13022
  mutex executor_lock;
13023
+ mutex error_lock;
12901
13024
  //! The pipelines of the current query
12902
13025
  vector<shared_ptr<Pipeline>> pipelines;
12903
13026
  //! The root pipeline of the query
@@ -12919,6 +13042,8 @@ private:
12919
13042
  atomic<idx_t> completed_pipelines;
12920
13043
  //! The total amount of pipelines in the query
12921
13044
  idx_t total_pipelines;
13045
+ //! Whether or not execution is cancelled
13046
+ bool cancelled;
12922
13047
 
12923
13048
  //! The adjacent union pipelines of each pipeline
12924
13049
  //! Union pipelines have the same sink, but can be run concurrently along with this pipeline
@@ -22639,6 +22764,11 @@ public:
22639
22764
  void CommitAppend(transaction_t commit_id, idx_t start, idx_t end) override;
22640
22765
 
22641
22766
  void Append(idx_t start, idx_t end, transaction_t commit_id);
22767
+ //! Performs a delete in the ChunkVectorInfo - returns how many tuples were actually deleted
22768
+ //! The number of rows that were actually deleted might be lower than the input count
22769
+ //! In case we delete rows that were already deleted
22770
+ //! Note that "rows" is written to to reflect the row ids that were actually deleted
22771
+ //! i.e. after calling this function, rows will hold [0..actual_delete_count] row ids of the actually deleted tuples
22642
22772
  idx_t Delete(Transaction &transaction, row_t rows[], idx_t count);
22643
22773
  void CommitDelete(transaction_t commit_id, row_t rows[], idx_t count);
22644
22774
 
@@ -24185,7 +24315,7 @@ public:
24185
24315
  DataTable(ClientContext &context, DataTable &parent, idx_t changed_idx, const LogicalType &target_type,
24186
24316
  vector<column_t> bound_columns, Expression &cast_expr);
24187
24317
  //! Constructs a DataTable as a delta on an existing data table but with one column added new constraint
24188
- DataTable(ClientContext &context, DataTable &parent, unique_ptr<Constraint> constraint);
24318
+ DataTable(ClientContext &context, DataTable &parent, unique_ptr<BoundConstraint> constraint);
24189
24319
 
24190
24320
  shared_ptr<DataTableInfo> info;
24191
24321
 
@@ -24270,7 +24400,9 @@ public:
24270
24400
  this->is_root = true;
24271
24401
  }
24272
24402
 
24403
+ //! Get statistics of a physical column within the table
24273
24404
  unique_ptr<BaseStatistics> GetStatistics(ClientContext &context, column_t column_id);
24405
+ //! Sets statistics of a physical column within the table
24274
24406
  void SetStatistics(column_t column_id, const std::function<void(BaseStatistics &)> &set_fun);
24275
24407
 
24276
24408
  //! Checkpoint the table to the specified table data writer
@@ -24288,7 +24420,7 @@ public:
24288
24420
 
24289
24421
  private:
24290
24422
  //! Verify the new added constraints against current persistent&local data
24291
- void VerifyNewConstraint(ClientContext &context, DataTable &parent, const Constraint *constraint);
24423
+ void VerifyNewConstraint(ClientContext &context, DataTable &parent, const BoundConstraint *constraint);
24292
24424
  //! Verify constraints with a chunk from the Append containing all columns of the table
24293
24425
  void VerifyAppendConstraints(TableCatalogEntry &table, ClientContext &context, DataChunk &chunk);
24294
24426
  //! Verify constraints with a chunk from the Update containing only the specified column_ids
@@ -26866,12 +26998,16 @@ class HivePartitioning {
26866
26998
  public:
26867
26999
  //! Parse a filename that follows the hive partitioning scheme
26868
27000
  DUCKDB_API static std::map<string, string> Parse(string &filename);
27001
+ DUCKDB_API static std::map<string, string> Parse(string &filename, duckdb_re2::RE2 &regex);
26869
27002
  //! Prunes a list of filenames based on a set of filters, can be used by TableFunctions in the
26870
27003
  //! pushdown_complex_filter function to skip files with filename-based filters. Also removes the filters that always
26871
27004
  //! evaluate to true.
26872
27005
  DUCKDB_API static void ApplyFiltersToFileList(vector<string> &files, vector<unique_ptr<Expression>> &filters,
26873
27006
  unordered_map<string, column_t> &column_map, idx_t table_index,
26874
27007
  bool hive_enabled, bool filename_enabled);
27008
+
27009
+ //! Returns the compiled regex pattern to match hive partitions
27010
+ DUCKDB_API static const string REGEX_STRING;
26875
27011
  };
26876
27012
 
26877
27013
  } // namespace duckdb
@@ -27089,8 +27225,8 @@ public:
27089
27225
  return function_name + "(" + entry.children[0]->ToString() + ")";
27090
27226
  }
27091
27227
  } else if (entry.children.size() == 2) {
27092
- return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
27093
- ")";
27228
+ return StringUtil::Format("(%s) %s (%s)", entry.children[0]->ToString(), function_name,
27229
+ entry.children[1]->ToString());
27094
27230
  }
27095
27231
  }
27096
27232
  // standard function call
@@ -27469,7 +27605,8 @@ public:
27469
27605
  public:
27470
27606
  template <class T, class BASE>
27471
27607
  static string ToString(const T &entry) {
27472
- return entry.left->ToString() + " " + ExpressionTypeToOperator(entry.type) + " " + entry.right->ToString();
27608
+ return StringUtil::Format("(%s) %s (%s)", entry.left->ToString(), ExpressionTypeToOperator(entry.type),
27609
+ entry.right->ToString());
27473
27610
  }
27474
27611
  };
27475
27612
  } // namespace duckdb