duckdb 0.5.2-dev566.0 → 0.5.2-dev577.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.5.2-dev566.0",
4
+ "version": "0.5.2-dev577.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -46552,7 +46552,11 @@ static_assert(sizeof(timestamp_t) == sizeof(int64_t), "timestamp_t was padded");
46552
46552
  // T may be a space
46553
46553
  // Z is optional
46554
46554
  // ISO 8601
46555
- bool Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result) {
46555
+ static inline bool CharacterIsTimeZone(char c) {
46556
+ return StringUtil::CharacterIsAlpha(c) || StringUtil::CharacterIsDigit(c) || c == '_' || c == '/';
46557
+ }
46558
+
46559
+ bool Timestamp::TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, string_t &tz) {
46556
46560
  idx_t pos;
46557
46561
  date_t date;
46558
46562
  dtime_t time;
@@ -46584,12 +46588,25 @@ bool Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_t &res
46584
46588
  }
46585
46589
  if (pos < len) {
46586
46590
  // skip a "Z" at the end (as per the ISO8601 specs)
46591
+ int hour_offset, minute_offset;
46587
46592
  if (str[pos] == 'Z') {
46588
46593
  pos++;
46589
- }
46590
- int hour_offset, minute_offset;
46591
- if (Timestamp::TryParseUTCOffset(str, pos, len, hour_offset, minute_offset)) {
46594
+ } else if (Timestamp::TryParseUTCOffset(str, pos, len, hour_offset, minute_offset)) {
46592
46595
  result -= hour_offset * Interval::MICROS_PER_HOUR + minute_offset * Interval::MICROS_PER_MINUTE;
46596
+ } else {
46597
+ // Parse a time zone: / [A-Za-z0-9/_]+/
46598
+ if (str[pos++] != ' ') {
46599
+ return false;
46600
+ }
46601
+ auto tz_name = str + pos;
46602
+ for (; pos < len && CharacterIsTimeZone(str[pos]); ++pos) {
46603
+ continue;
46604
+ }
46605
+ auto tz_len = str + pos - tz_name;
46606
+ if (tz_len) {
46607
+ tz = string_t(tz_name, tz_len);
46608
+ }
46609
+ // Note that the caller must reinterpret the instant we return to the given time zone
46593
46610
  }
46594
46611
 
46595
46612
  // skip any spaces at the end
@@ -46603,9 +46620,14 @@ bool Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_t &res
46603
46620
  return true;
46604
46621
  }
46605
46622
 
46623
+ bool Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result) {
46624
+ string_t tz(nullptr, 0);
46625
+ return TryConvertTimestampTZ(str, len, result, tz) && !tz.GetSize();
46626
+ }
46627
+
46606
46628
  string Timestamp::ConversionError(const string &str) {
46607
46629
  return StringUtil::Format("timestamp field value out of range: \"%s\", "
46608
- "expected format is (YYYY-MM-DD HH:MM:SS[.MS])",
46630
+ "expected format is (YYYY-MM-DD HH:MM:SS[.US][±HH:MM| ZONE])",
46609
46631
  str);
46610
46632
  }
46611
46633
 
@@ -102278,7 +102300,12 @@ idx_t StrfTimeFormat::GetSpecifierLength(StrTimeSpecifier specifier, date_t date
102278
102300
  return Date::MONTH_NAMES[Date::ExtractMonth(date) - 1].GetSize();
102279
102301
  case StrTimeSpecifier::YEAR_DECIMAL: {
102280
102302
  auto year = Date::ExtractYear(date);
102281
- return NumericHelper::SignedLength<int32_t, uint32_t>(year);
102303
+ // Be consistent with WriteStandardSpecifier
102304
+ if (0 <= year && year <= 9999) {
102305
+ return 4;
102306
+ } else {
102307
+ return NumericHelper::SignedLength<int32_t, uint32_t>(year);
102308
+ }
102282
102309
  }
102283
102310
  case StrTimeSpecifier::MONTH_DECIMAL: {
102284
102311
  idx_t len = 1;
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 "e8b2612d6"
15
- #define DUCKDB_VERSION "v0.5.2-dev566"
14
+ #define DUCKDB_SOURCE_ID "e6e62d5a8"
15
+ #define DUCKDB_VERSION "v0.5.2-dev577"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -15008,6 +15008,7 @@ struct CastParameters {
15008
15008
  typedef bool (*cast_function_t)(Vector &source, Vector &result, idx_t count, CastParameters &parameters);
15009
15009
 
15010
15010
  struct BoundCastInfo {
15011
+ DUCKDB_API
15011
15012
  BoundCastInfo(cast_function_t function,
15012
15013
  unique_ptr<BoundCastData> cast_data = nullptr); // NOLINT: allow explicit cast from cast_function_t
15013
15014
 
@@ -24973,8 +24974,11 @@ public:
24973
24974
  constexpr static const int32_t MIN_DAY = 22;
24974
24975
 
24975
24976
  public:
24976
- //! Convert a string in the format "YYYY-MM-DD hh:mm:ss" to a timestamp object
24977
+ //! Convert a string in the format "YYYY-MM-DD hh:mm:ss[.f][-+TH[:tm]]" to a timestamp object
24977
24978
  DUCKDB_API static timestamp_t FromString(const string &str);
24979
+ //! Convert a string where the offset can also be a time zone string: / [A_Za-z0-9/_]+/
24980
+ //! If the tz is not empty, the result is still an instant, but the parts can be extracted and applied to the TZ
24981
+ DUCKDB_API static bool TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, string_t &tz);
24978
24982
  DUCKDB_API static bool TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result);
24979
24983
  DUCKDB_API static timestamp_t FromCString(const char *str, idx_t len);
24980
24984
  //! Convert a date object to a string in the format "YYYY-MM-DD hh:mm:ss"