duckdb 0.3.3-dev1265.0 → 0.3.3-dev1273.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.3-dev1265.0",
4
+ "version": "0.3.3-dev1273.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -84787,12 +84787,13 @@ struct StrfTimeBindData : public FunctionData {
84787
84787
  }
84788
84788
  };
84789
84789
 
84790
+ template <bool REVERSED>
84790
84791
  static unique_ptr<FunctionData> StrfTimeBindFunction(ClientContext &context, ScalarFunction &bound_function,
84791
84792
  vector<unique_ptr<Expression>> &arguments) {
84792
84793
  if (!arguments[1]->IsFoldable()) {
84793
84794
  throw InvalidInputException("strftime format must be a constant");
84794
84795
  }
84795
- Value options_str = ExpressionExecutor::EvaluateScalar(*arguments[1]);
84796
+ Value options_str = ExpressionExecutor::EvaluateScalar(*arguments[REVERSED ? 0 : 1]);
84796
84797
  StrfTimeFormat format;
84797
84798
  if (!options_str.IsNull() && options_str.type().id() == LogicalTypeId::VARCHAR) {
84798
84799
  auto format_string = options_str.GetValue<string>();
@@ -84804,16 +84805,17 @@ static unique_ptr<FunctionData> StrfTimeBindFunction(ClientContext &context, Sca
84804
84805
  return make_unique<StrfTimeBindData>(format);
84805
84806
  }
84806
84807
 
84808
+ template <bool REVERSED>
84807
84809
  static void StrfTimeFunctionDate(DataChunk &args, ExpressionState &state, Vector &result) {
84808
84810
  auto &func_expr = (BoundFunctionExpression &)state.expr;
84809
84811
  auto &info = (StrfTimeBindData &)*func_expr.bind_info;
84810
84812
 
84811
- if (ConstantVector::IsNull(args.data[1])) {
84813
+ if (ConstantVector::IsNull(args.data[REVERSED ? 0 : 1])) {
84812
84814
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
84813
84815
  ConstantVector::SetNull(result, true);
84814
84816
  return;
84815
84817
  }
84816
- UnaryExecutor::Execute<date_t, string_t>(args.data[0], result, args.size(), [&](date_t input) {
84818
+ UnaryExecutor::Execute<date_t, string_t>(args.data[REVERSED ? 1 : 0], result, args.size(), [&](date_t input) {
84817
84819
  dtime_t time(0);
84818
84820
  idx_t len = info.format.GetLength(input, time);
84819
84821
  string_t target = StringVector::EmptyString(result, len);
@@ -84823,36 +84825,44 @@ static void StrfTimeFunctionDate(DataChunk &args, ExpressionState &state, Vector
84823
84825
  });
84824
84826
  }
84825
84827
 
84828
+ template <bool REVERSED>
84826
84829
  static void StrfTimeFunctionTimestamp(DataChunk &args, ExpressionState &state, Vector &result) {
84827
84830
  auto &func_expr = (BoundFunctionExpression &)state.expr;
84828
84831
  auto &info = (StrfTimeBindData &)*func_expr.bind_info;
84829
84832
 
84830
- if (ConstantVector::IsNull(args.data[1])) {
84833
+ if (ConstantVector::IsNull(args.data[REVERSED ? 0 : 1])) {
84831
84834
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
84832
84835
  ConstantVector::SetNull(result, true);
84833
84836
  return;
84834
84837
  }
84835
84838
 
84836
- UnaryExecutor::Execute<timestamp_t, string_t>(args.data[0], result, args.size(), [&](timestamp_t input) {
84837
- date_t date;
84838
- dtime_t time;
84839
- Timestamp::Convert(input, date, time);
84840
- idx_t len = info.format.GetLength(date, time);
84841
- string_t target = StringVector::EmptyString(result, len);
84842
- info.format.FormatString(date, time, target.GetDataWriteable());
84843
- target.Finalize();
84844
- return target;
84845
- });
84839
+ UnaryExecutor::Execute<timestamp_t, string_t>(args.data[REVERSED ? 1 : 0], result, args.size(),
84840
+ [&](timestamp_t input) {
84841
+ date_t date;
84842
+ dtime_t time;
84843
+ Timestamp::Convert(input, date, time);
84844
+ idx_t len = info.format.GetLength(date, time);
84845
+ string_t target = StringVector::EmptyString(result, len);
84846
+ info.format.FormatString(date, time, target.GetDataWriteable());
84847
+ target.Finalize();
84848
+ return target;
84849
+ });
84846
84850
  }
84847
84851
 
84848
84852
  void StrfTimeFun::RegisterFunction(BuiltinFunctions &set) {
84849
84853
  ScalarFunctionSet strftime("strftime");
84850
84854
 
84851
84855
  strftime.AddFunction(ScalarFunction({LogicalType::DATE, LogicalType::VARCHAR}, LogicalType::VARCHAR,
84852
- StrfTimeFunctionDate, false, StrfTimeBindFunction));
84856
+ StrfTimeFunctionDate<false>, false, StrfTimeBindFunction<false>));
84853
84857
 
84854
84858
  strftime.AddFunction(ScalarFunction({LogicalType::TIMESTAMP, LogicalType::VARCHAR}, LogicalType::VARCHAR,
84855
- StrfTimeFunctionTimestamp, false, StrfTimeBindFunction));
84859
+ StrfTimeFunctionTimestamp<false>, false, StrfTimeBindFunction<false>));
84860
+
84861
+ strftime.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::DATE}, LogicalType::VARCHAR,
84862
+ StrfTimeFunctionDate<true>, false, StrfTimeBindFunction<true>));
84863
+
84864
+ strftime.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::TIMESTAMP}, LogicalType::VARCHAR,
84865
+ StrfTimeFunctionTimestamp<true>, false, StrfTimeBindFunction<true>));
84856
84866
 
84857
84867
  set.AddFunction(strftime);
84858
84868
  }
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 "6bc3f4461"
15
- #define DUCKDB_VERSION "v0.3.3-dev1265"
14
+ #define DUCKDB_SOURCE_ID "819936c72"
15
+ #define DUCKDB_VERSION "v0.3.3-dev1273"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //