duckdb 0.3.5-dev459.0 → 0.3.5-dev503.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 "c2194b45b"
15
- #define DUCKDB_VERSION "v0.3.5-dev459"
14
+ #define DUCKDB_SOURCE_ID "b709cce20"
15
+ #define DUCKDB_VERSION "v0.3.5-dev503"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -622,6 +622,7 @@ using std::vector;
622
622
  }
623
623
 
624
624
 
625
+ #include <limits>
625
626
 
626
627
  namespace duckdb {
627
628
 
@@ -631,7 +632,7 @@ class Value;
631
632
  class TypeCatalogEntry;
632
633
  class Vector;
633
634
  //! Type used to represent dates (days since 1970-01-01)
634
- struct date_t {
635
+ struct date_t { // NOLINT
635
636
  int32_t days;
636
637
 
637
638
  date_t() = default;
@@ -655,10 +656,15 @@ struct date_t {
655
656
  // in-place operators
656
657
  inline date_t &operator+=(const int32_t &days) {this->days += days; return *this;};
657
658
  inline date_t &operator-=(const int32_t &days) {this->days -= days; return *this;};
659
+
660
+ // special values
661
+ static inline date_t infinity() {return date_t(std::numeric_limits<int32_t>::max()); } // NOLINT
662
+ static inline date_t ninfinity() {return date_t(-std::numeric_limits<int32_t>::max()); } // NOLINT
663
+ static inline date_t epoch() {return date_t(0); } // NOLINT
658
664
  };
659
665
 
660
666
  //! Type used to represent time (microseconds)
661
- struct dtime_t {
667
+ struct dtime_t { // NOLINT
662
668
  int64_t micros;
663
669
 
664
670
  dtime_t() = default;
@@ -689,10 +695,13 @@ struct dtime_t {
689
695
  inline dtime_t &operator+=(const int64_t &micros) {this->micros += micros; return *this;};
690
696
  inline dtime_t &operator-=(const int64_t &micros) {this->micros -= micros; return *this;};
691
697
  inline dtime_t &operator+=(const dtime_t &other) {this->micros += other.micros; return *this;};
698
+
699
+ // special values
700
+ static inline dtime_t allballs() {return dtime_t(0); } // NOLINT
692
701
  };
693
702
 
694
703
  //! Type used to represent timestamps (seconds,microseconds,milliseconds or nanoseconds since 1970-01-01)
695
- struct timestamp_t {
704
+ struct timestamp_t { // NOLINT
696
705
  int64_t value;
697
706
 
698
707
  timestamp_t() = default;
@@ -717,6 +726,11 @@ struct timestamp_t {
717
726
  // in-place operators
718
727
  inline timestamp_t &operator+=(const int64_t &value) {this->value += value; return *this;};
719
728
  inline timestamp_t &operator-=(const int64_t &value) {this->value -= value; return *this;};
729
+
730
+ // special values
731
+ static inline timestamp_t infinity() {return timestamp_t(std::numeric_limits<int64_t>::max()); } // NOLINT
732
+ static inline timestamp_t ninfinity() {return timestamp_t(-std::numeric_limits<int64_t>::max()); } // NOLINT
733
+ static inline timestamp_t epoch() {return timestamp_t(0); } // NOLINT
720
734
  };
721
735
 
722
736
  struct interval_t {
@@ -3176,6 +3190,10 @@ template <>
3176
3190
  DUCKDB_API bool Value::IsFinite(float input);
3177
3191
  template <>
3178
3192
  DUCKDB_API bool Value::IsFinite(double input);
3193
+ template <>
3194
+ DUCKDB_API bool Value::IsFinite(date_t input);
3195
+ template <>
3196
+ DUCKDB_API bool Value::IsFinite(timestamp_t input);
3179
3197
 
3180
3198
  } // namespace duckdb
3181
3199
 
@@ -4920,9 +4938,23 @@ public:
4920
4938
 
4921
4939
  namespace duckdb {
4922
4940
 
4941
+ struct TernaryLambdaWrapper {
4942
+ template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
4943
+ static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
4944
+ return fun(a, b, c);
4945
+ }
4946
+ };
4947
+
4948
+ struct TernaryLambdaWrapperWithNulls {
4949
+ template <class FUN, class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE>
4950
+ static inline RESULT_TYPE Operation(FUN fun, A_TYPE a, B_TYPE b, C_TYPE c, ValidityMask &mask, idx_t idx) {
4951
+ return fun(a, b, c, mask, idx);
4952
+ }
4953
+ };
4954
+
4923
4955
  struct TernaryExecutor {
4924
4956
  private:
4925
- template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class FUN>
4957
+ template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
4926
4958
  static inline void ExecuteLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
4927
4959
  RESULT_TYPE *__restrict result_data, idx_t count, const SelectionVector &asel,
4928
4960
  const SelectionVector &bsel, const SelectionVector &csel, ValidityMask &avalidity,
@@ -4934,7 +4966,8 @@ private:
4934
4966
  auto bidx = bsel.get_index(i);
4935
4967
  auto cidx = csel.get_index(i);
4936
4968
  if (avalidity.RowIsValid(aidx) && bvalidity.RowIsValid(bidx) && cvalidity.RowIsValid(cidx)) {
4937
- result_data[i] = fun(adata[aidx], bdata[bidx], cdata[cidx]);
4969
+ result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
4970
+ fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
4938
4971
  } else {
4939
4972
  result_validity.SetInvalid(i);
4940
4973
  }
@@ -4944,15 +4977,15 @@ private:
4944
4977
  auto aidx = asel.get_index(i);
4945
4978
  auto bidx = bsel.get_index(i);
4946
4979
  auto cidx = csel.get_index(i);
4947
- result_data[i] = fun(adata[aidx], bdata[bidx], cdata[cidx]);
4980
+ result_data[i] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
4981
+ fun, adata[aidx], bdata[bidx], cdata[cidx], result_validity, i);
4948
4982
  }
4949
4983
  }
4950
4984
  }
4951
4985
 
4952
4986
  public:
4953
- template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
4954
- class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE)>>
4955
- static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
4987
+ template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class OPWRAPPER, class FUN>
4988
+ static void ExecuteGeneric(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
4956
4989
  if (a.GetVectorType() == VectorType::CONSTANT_VECTOR && b.GetVectorType() == VectorType::CONSTANT_VECTOR &&
4957
4990
  c.GetVectorType() == VectorType::CONSTANT_VECTOR) {
4958
4991
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
@@ -4963,7 +4996,9 @@ public:
4963
4996
  auto bdata = ConstantVector::GetData<B_TYPE>(b);
4964
4997
  auto cdata = ConstantVector::GetData<C_TYPE>(c);
4965
4998
  auto result_data = ConstantVector::GetData<RESULT_TYPE>(result);
4966
- result_data[0] = fun(*adata, *bdata, *cdata);
4999
+ auto &result_validity = ConstantVector::Validity(result);
5000
+ result_data[0] = OPWRAPPER::template Operation<FUN, A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
5001
+ fun, adata[0], bdata[0], cdata[0], result_validity, 0);
4967
5002
  }
4968
5003
  } else {
4969
5004
  result.SetVectorType(VectorType::FLAT_VECTOR);
@@ -4973,13 +5008,26 @@ public:
4973
5008
  b.Orrify(count, bdata);
4974
5009
  c.Orrify(count, cdata);
4975
5010
 
4976
- ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE>(
5011
+ ExecuteLoop<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, OPWRAPPER>(
4977
5012
  (A_TYPE *)adata.data, (B_TYPE *)bdata.data, (C_TYPE *)cdata.data,
4978
5013
  FlatVector::GetData<RESULT_TYPE>(result), count, *adata.sel, *bdata.sel, *cdata.sel, adata.validity,
4979
5014
  bdata.validity, cdata.validity, FlatVector::Validity(result), fun);
4980
5015
  }
4981
5016
  }
4982
5017
 
5018
+ template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
5019
+ class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE)>>
5020
+ static void Execute(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
5021
+ ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapper, FUN>(a, b, c, result, count, fun);
5022
+ }
5023
+
5024
+ template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
5025
+ class FUN = std::function<RESULT_TYPE(A_TYPE, B_TYPE, C_TYPE, ValidityMask &, idx_t)>>
5026
+ static void ExecuteWithNulls(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUN fun) {
5027
+ ExecuteGeneric<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, TernaryLambdaWrapperWithNulls, FUN>(a, b, c, result, count,
5028
+ fun);
5029
+ }
5030
+
4983
5031
  private:
4984
5032
  template <class A_TYPE, class B_TYPE, class C_TYPE, class OP, bool NO_NULL, bool HAS_TRUE_SEL, bool HAS_FALSE_SEL>
4985
5033
  static inline idx_t SelectLoop(A_TYPE *__restrict adata, B_TYPE *__restrict bdata, C_TYPE *__restrict cdata,
@@ -18487,14 +18535,14 @@ public:
18487
18535
  static const int8_t MONTH_PER_DAY_OF_YEAR[365];
18488
18536
  static const int8_t LEAP_MONTH_PER_DAY_OF_YEAR[366];
18489
18537
 
18490
- // min date is 5877642-06-23 (BC) (-2^31)
18538
+ // min date is 5877642-06-25 (BC) (-2^31+2)
18491
18539
  constexpr static const int32_t DATE_MIN_YEAR = -5877641;
18492
18540
  constexpr static const int32_t DATE_MIN_MONTH = 6;
18493
- constexpr static const int32_t DATE_MIN_DAY = 23;
18494
- // max date is 5881580-07-11 (2^31)
18541
+ constexpr static const int32_t DATE_MIN_DAY = 25;
18542
+ // max date is 5881580-07-10 (2^31-2)
18495
18543
  constexpr static const int32_t DATE_MAX_YEAR = 5881580;
18496
18544
  constexpr static const int32_t DATE_MAX_MONTH = 7;
18497
- constexpr static const int32_t DATE_MAX_DAY = 11;
18545
+ constexpr static const int32_t DATE_MAX_DAY = 10;
18498
18546
  constexpr static const int32_t EPOCH_YEAR = 1970;
18499
18547
 
18500
18548
  constexpr static const int32_t YEAR_INTERVAL = 400;
@@ -18527,6 +18575,11 @@ public:
18527
18575
  //! date
18528
18576
  DUCKDB_API static bool IsValid(int32_t year, int32_t month, int32_t day);
18529
18577
 
18578
+ //! Returns true if the specified date is finite
18579
+ static inline bool IsFinite(date_t date) {
18580
+ return date != date_t::infinity() && date != date_t::ninfinity();
18581
+ }
18582
+
18530
18583
  //! The max number of days in a month of a given year
18531
18584
  DUCKDB_API static int32_t MonthDays(int32_t year, int32_t month);
18532
18585
 
@@ -18727,15 +18780,6 @@ public:
18727
18780
 
18728
18781
  namespace duckdb {
18729
18782
 
18730
- struct timestamp_struct {
18731
- int32_t year;
18732
- int8_t month;
18733
- int8_t day;
18734
- int8_t hour;
18735
- int8_t min;
18736
- int8_t sec;
18737
- int16_t msec;
18738
- };
18739
18783
  //! The Timestamp class is a static class that holds helper functions for the Timestamp
18740
18784
  //! type.
18741
18785
  class Timestamp {
@@ -18760,6 +18804,11 @@ public:
18760
18804
  DUCKDB_API static timestamp_t FromDatetime(date_t date, dtime_t time);
18761
18805
  DUCKDB_API static bool TryFromDatetime(date_t date, dtime_t time, timestamp_t &result);
18762
18806
 
18807
+ //! Is the timestamp finite or infinite?
18808
+ static inline bool IsFinite(timestamp_t timestamp) {
18809
+ return timestamp != timestamp_t::infinity() && timestamp != timestamp_t::ninfinity();
18810
+ }
18811
+
18763
18812
  //! Extract the date and time from a given timestamp object
18764
18813
  DUCKDB_API static void Convert(timestamp_t date, date_t &out_date, dtime_t &out_time);
18765
18814
  //! Returns current timestamp