duckdb 0.3.5-dev16.0 → 0.3.5-dev26.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.3.5-dev16.0",
4
+ "version": "0.3.5-dev26.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -84973,9 +84973,6 @@ void DateSubFun::RegisterFunction(BuiltinFunctions &set) {
84973
84973
 
84974
84974
 
84975
84975
 
84976
- // TODO date_trunc function should also handle interval data type when it is implemented. See
84977
- // https://www.postgresql.org/docs/9.1/functions-datetime.html
84978
-
84979
84976
  namespace duckdb {
84980
84977
 
84981
84978
  struct DateTrunc {
@@ -85186,6 +85183,101 @@ timestamp_t DateTrunc::MicrosecondOperator::Operation(date_t input) {
85186
85183
  return DayOperator::Operation<date_t, timestamp_t>(input);
85187
85184
  }
85188
85185
 
85186
+ // INTERVAL specialisations
85187
+ template <>
85188
+ interval_t DateTrunc::MillenniumOperator::Operation(interval_t input) {
85189
+ input.days = 0;
85190
+ input.micros = 0;
85191
+ input.months = (input.months / Interval::MONTHS_PER_MILLENIUM) * Interval::MONTHS_PER_MILLENIUM;
85192
+ return input;
85193
+ }
85194
+
85195
+ template <>
85196
+ interval_t DateTrunc::CenturyOperator::Operation(interval_t input) {
85197
+ input.days = 0;
85198
+ input.micros = 0;
85199
+ input.months = (input.months / Interval::MONTHS_PER_CENTURY) * Interval::MONTHS_PER_CENTURY;
85200
+ return input;
85201
+ }
85202
+
85203
+ template <>
85204
+ interval_t DateTrunc::DecadeOperator::Operation(interval_t input) {
85205
+ input.days = 0;
85206
+ input.micros = 0;
85207
+ input.months = (input.months / Interval::MONTHS_PER_DECADE) * Interval::MONTHS_PER_DECADE;
85208
+ return input;
85209
+ }
85210
+
85211
+ template <>
85212
+ interval_t DateTrunc::YearOperator::Operation(interval_t input) {
85213
+ input.days = 0;
85214
+ input.micros = 0;
85215
+ input.months = (input.months / Interval::MONTHS_PER_YEAR) * Interval::MONTHS_PER_YEAR;
85216
+ return input;
85217
+ }
85218
+
85219
+ template <>
85220
+ interval_t DateTrunc::QuarterOperator::Operation(interval_t input) {
85221
+ input.days = 0;
85222
+ input.micros = 0;
85223
+ input.months = (input.months / Interval::MONTHS_PER_QUARTER) * Interval::MONTHS_PER_QUARTER;
85224
+ return input;
85225
+ }
85226
+
85227
+ template <>
85228
+ interval_t DateTrunc::MonthOperator::Operation(interval_t input) {
85229
+ input.days = 0;
85230
+ input.micros = 0;
85231
+ return input;
85232
+ }
85233
+
85234
+ template <>
85235
+ interval_t DateTrunc::WeekOperator::Operation(interval_t input) {
85236
+ input.micros = 0;
85237
+ input.days = (input.days / Interval::DAYS_PER_WEEK) * Interval::DAYS_PER_WEEK;
85238
+ return input;
85239
+ }
85240
+
85241
+ template <>
85242
+ interval_t DateTrunc::ISOYearOperator::Operation(interval_t input) {
85243
+ return YearOperator::Operation<interval_t, interval_t>(input);
85244
+ }
85245
+
85246
+ template <>
85247
+ interval_t DateTrunc::DayOperator::Operation(interval_t input) {
85248
+ input.micros = 0;
85249
+ return input;
85250
+ }
85251
+
85252
+ template <>
85253
+ interval_t DateTrunc::HourOperator::Operation(interval_t input) {
85254
+ input.micros = (input.micros / Interval::MICROS_PER_HOUR) * Interval::MICROS_PER_HOUR;
85255
+ return input;
85256
+ }
85257
+
85258
+ template <>
85259
+ interval_t DateTrunc::MinuteOperator::Operation(interval_t input) {
85260
+ input.micros = (input.micros / Interval::MICROS_PER_MINUTE) * Interval::MICROS_PER_MINUTE;
85261
+ return input;
85262
+ }
85263
+
85264
+ template <>
85265
+ interval_t DateTrunc::SecondOperator::Operation(interval_t input) {
85266
+ input.micros = (input.micros / Interval::MICROS_PER_SEC) * Interval::MICROS_PER_SEC;
85267
+ return input;
85268
+ }
85269
+
85270
+ template <>
85271
+ interval_t DateTrunc::MillisecondOperator::Operation(interval_t input) {
85272
+ input.micros = (input.micros / Interval::MICROS_PER_MSEC) * Interval::MICROS_PER_MSEC;
85273
+ return input;
85274
+ }
85275
+
85276
+ template <>
85277
+ interval_t DateTrunc::MicrosecondOperator::Operation(interval_t input) {
85278
+ return input;
85279
+ }
85280
+
85189
85281
  template <class TA, class TR>
85190
85282
  static TR TruncateElement(DatePartSpecifier type, TA element) {
85191
85283
  switch (type) {
@@ -85289,7 +85381,7 @@ static void DateTruncUnaryExecutor(DatePartSpecifier type, Vector &left, Vector
85289
85381
  }
85290
85382
  }
85291
85383
 
85292
- template <typename T>
85384
+ template <typename TA, typename TR>
85293
85385
  static void DateTruncFunction(DataChunk &args, ExpressionState &state, Vector &result) {
85294
85386
  D_ASSERT(args.ColumnCount() == 2);
85295
85387
  auto &part_arg = args.data[0];
@@ -85302,20 +85394,22 @@ static void DateTruncFunction(DataChunk &args, ExpressionState &state, Vector &r
85302
85394
  ConstantVector::SetNull(result, true);
85303
85395
  } else {
85304
85396
  const auto type = GetDatePartSpecifier(ConstantVector::GetData<string_t>(part_arg)->GetString());
85305
- DateTruncUnaryExecutor<T, timestamp_t>(type, date_arg, result, args.size());
85397
+ DateTruncUnaryExecutor<TA, TR>(type, date_arg, result, args.size());
85306
85398
  }
85307
85399
  } else {
85308
- BinaryExecutor::ExecuteStandard<string_t, T, timestamp_t, DateTruncBinaryOperator>(part_arg, date_arg, result,
85309
- args.size());
85400
+ BinaryExecutor::ExecuteStandard<string_t, TA, TR, DateTruncBinaryOperator>(part_arg, date_arg, result,
85401
+ args.size());
85310
85402
  }
85311
85403
  }
85312
85404
 
85313
85405
  void DateTruncFun::RegisterFunction(BuiltinFunctions &set) {
85314
85406
  ScalarFunctionSet date_trunc("date_trunc");
85315
85407
  date_trunc.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::TIMESTAMP}, LogicalType::TIMESTAMP,
85316
- DateTruncFunction<timestamp_t>));
85317
- date_trunc.AddFunction(
85318
- ScalarFunction({LogicalType::VARCHAR, LogicalType::DATE}, LogicalType::TIMESTAMP, DateTruncFunction<date_t>));
85408
+ DateTruncFunction<timestamp_t, timestamp_t>));
85409
+ date_trunc.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::DATE}, LogicalType::TIMESTAMP,
85410
+ DateTruncFunction<date_t, timestamp_t>));
85411
+ date_trunc.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::INTERVAL}, LogicalType::INTERVAL,
85412
+ DateTruncFunction<interval_t, interval_t>));
85319
85413
  set.AddFunction(date_trunc);
85320
85414
  date_trunc.name = "datetrunc";
85321
85415
  set.AddFunction(date_trunc);
@@ -103872,44 +103966,74 @@ void BaseAppender::AppendValueInternal(T input) {
103872
103966
  throw InvalidInputException("Too many appends for chunk!");
103873
103967
  }
103874
103968
  auto &col = chunk->data[column];
103875
- switch (col.GetType().InternalType()) {
103876
- case PhysicalType::BOOL:
103969
+ switch (col.GetType().id()) {
103970
+ case LogicalTypeId::BOOLEAN:
103877
103971
  AppendValueInternal<T, bool>(col, input);
103878
103972
  break;
103879
- case PhysicalType::UINT8:
103973
+ case LogicalTypeId::UTINYINT:
103880
103974
  AppendValueInternal<T, uint8_t>(col, input);
103881
103975
  break;
103882
- case PhysicalType::INT8:
103976
+ case LogicalTypeId::TINYINT:
103883
103977
  AppendValueInternal<T, int8_t>(col, input);
103884
103978
  break;
103885
- case PhysicalType::UINT16:
103979
+ case LogicalTypeId::USMALLINT:
103886
103980
  AppendValueInternal<T, uint16_t>(col, input);
103887
103981
  break;
103888
- case PhysicalType::INT16:
103982
+ case LogicalTypeId::SMALLINT:
103889
103983
  AppendValueInternal<T, int16_t>(col, input);
103890
103984
  break;
103891
- case PhysicalType::UINT32:
103985
+ case LogicalTypeId::UINTEGER:
103892
103986
  AppendValueInternal<T, uint32_t>(col, input);
103893
103987
  break;
103894
- case PhysicalType::INT32:
103988
+ case LogicalTypeId::INTEGER:
103895
103989
  AppendValueInternal<T, int32_t>(col, input);
103896
103990
  break;
103897
- case PhysicalType::UINT64:
103991
+ case LogicalTypeId::UBIGINT:
103898
103992
  AppendValueInternal<T, uint64_t>(col, input);
103899
103993
  break;
103900
- case PhysicalType::INT64:
103994
+ case LogicalTypeId::BIGINT:
103901
103995
  AppendValueInternal<T, int64_t>(col, input);
103902
103996
  break;
103903
- case PhysicalType::INT128:
103997
+ case LogicalTypeId::HUGEINT:
103904
103998
  AppendValueInternal<T, hugeint_t>(col, input);
103905
103999
  break;
103906
- case PhysicalType::FLOAT:
104000
+ case LogicalTypeId::FLOAT:
103907
104001
  AppendValueInternal<T, float>(col, input);
103908
104002
  break;
103909
- case PhysicalType::DOUBLE:
104003
+ case LogicalTypeId::DOUBLE:
103910
104004
  AppendValueInternal<T, double>(col, input);
103911
104005
  break;
103912
- case PhysicalType::VARCHAR:
104006
+ case LogicalTypeId::DECIMAL:
104007
+ switch (col.GetType().InternalType()) {
104008
+ case PhysicalType::INT8:
104009
+ AppendValueInternal<T, int8_t>(col, input);
104010
+ break;
104011
+ case PhysicalType::INT16:
104012
+ AppendValueInternal<T, int16_t>(col, input);
104013
+ break;
104014
+ case PhysicalType::INT32:
104015
+ AppendValueInternal<T, int32_t>(col, input);
104016
+ break;
104017
+ default:
104018
+ AppendValueInternal<T, int64_t>(col, input);
104019
+ break;
104020
+ }
104021
+ break;
104022
+ case LogicalTypeId::DATE:
104023
+ AppendValueInternal<T, date_t>(col, input);
104024
+ break;
104025
+ case LogicalTypeId::TIMESTAMP:
104026
+ case LogicalTypeId::TIMESTAMP_TZ:
104027
+ AppendValueInternal<T, timestamp_t>(col, input);
104028
+ break;
104029
+ case LogicalTypeId::TIME:
104030
+ case LogicalTypeId::TIME_TZ:
104031
+ AppendValueInternal<T, dtime_t>(col, input);
104032
+ break;
104033
+ case LogicalTypeId::INTERVAL:
104034
+ AppendValueInternal<T, interval_t>(col, input);
104035
+ break;
104036
+ case LogicalTypeId::VARCHAR:
103913
104037
  FlatVector::GetData<string_t>(col)[chunk->size()] = StringCast::Operation<T>(input, col);
103914
104038
  break;
103915
104039
  default:
@@ -103995,17 +104119,17 @@ void BaseAppender::Append(double value) {
103995
104119
 
103996
104120
  template <>
103997
104121
  void BaseAppender::Append(date_t value) {
103998
- AppendValueInternal<int32_t>(value.days);
104122
+ AppendValueInternal<date_t>(value);
103999
104123
  }
104000
104124
 
104001
104125
  template <>
104002
104126
  void BaseAppender::Append(dtime_t value) {
104003
- AppendValueInternal<int64_t>(value.micros);
104127
+ AppendValueInternal<dtime_t>(value);
104004
104128
  }
104005
104129
 
104006
104130
  template <>
104007
104131
  void BaseAppender::Append(timestamp_t value) {
104008
- AppendValueInternal<int64_t>(value.value);
104132
+ AppendValueInternal<timestamp_t>(value);
104009
104133
  }
104010
104134
 
104011
104135
  template <>
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 "67c1e0ee0"
15
- #define DUCKDB_VERSION "v0.3.5-dev16"
14
+ #define DUCKDB_SOURCE_ID "b6daef25a"
15
+ #define DUCKDB_VERSION "v0.3.5-dev26"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //