duckdb 0.3.3-dev1265.0 → 0.3.3-dev1279.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-dev1279.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
  }
@@ -164356,6 +164366,7 @@ void WriteOverflowStringsToDisk::AllocateNewBlock(block_id_t new_block_id) {
164356
164366
 
164357
164367
 
164358
164368
 
164369
+
164359
164370
 
164360
164371
 
164361
164372
  namespace duckdb {
@@ -164505,38 +164516,41 @@ void CheckpointManager::WriteSchema(SchemaCatalogEntry &schema) {
164505
164516
  }
164506
164517
  });
164507
164518
 
164519
+ FieldWriter writer(*metadata_writer);
164520
+ writer.WriteField<uint32_t>(custom_types.size());
164521
+ writer.WriteField<uint32_t>(sequences.size());
164522
+ writer.WriteField<uint32_t>(tables.size());
164523
+ writer.WriteField<uint32_t>(views.size());
164524
+ writer.WriteField<uint32_t>(macros.size());
164525
+ writer.WriteField<uint32_t>(table_macros.size());
164526
+ writer.Finalize();
164527
+
164508
164528
  // write the custom_types
164509
- metadata_writer->Write<uint32_t>(custom_types.size());
164510
164529
  for (auto &custom_type : custom_types) {
164511
164530
  WriteType(*custom_type);
164512
164531
  }
164513
164532
 
164514
164533
  // write the sequences
164515
- metadata_writer->Write<uint32_t>(sequences.size());
164516
164534
  for (auto &seq : sequences) {
164517
164535
  WriteSequence(*seq);
164518
164536
  }
164519
164537
  // reorder tables because of foreign key constraint
164520
164538
  ReorderTableEntries(tables);
164521
164539
  // now write the tables
164522
- metadata_writer->Write<uint32_t>(tables.size());
164523
164540
  for (auto &table : tables) {
164524
164541
  WriteTable(*table);
164525
164542
  }
164526
164543
  // now write the views
164527
- metadata_writer->Write<uint32_t>(views.size());
164528
164544
  for (auto &view : views) {
164529
164545
  WriteView(*view);
164530
164546
  }
164531
164547
 
164532
164548
  // finally write the macro's
164533
- metadata_writer->Write<uint32_t>(macros.size());
164534
164549
  for (auto &macro : macros) {
164535
164550
  WriteMacro(*macro);
164536
164551
  }
164537
164552
 
164538
164553
  // finally write the macro's
164539
- metadata_writer->Write<uint32_t>(table_macros.size());
164540
164554
  for (auto &macro : table_macros) {
164541
164555
  WriteTableMacro(*macro);
164542
164556
  }
@@ -164551,35 +164565,39 @@ void CheckpointManager::ReadSchema(ClientContext &context, MetaBlockReader &read
164551
164565
  info->on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
164552
164566
  catalog.CreateSchema(context, info.get());
164553
164567
 
164568
+ // first read all the counts
164569
+ FieldReader field_reader(reader);
164570
+ uint32_t enum_count = field_reader.ReadRequired<uint32_t>();
164571
+ uint32_t seq_count = field_reader.ReadRequired<uint32_t>();
164572
+ uint32_t table_count = field_reader.ReadRequired<uint32_t>();
164573
+ uint32_t view_count = field_reader.ReadRequired<uint32_t>();
164574
+ uint32_t macro_count = field_reader.ReadRequired<uint32_t>();
164575
+ uint32_t table_macro_count = field_reader.ReadRequired<uint32_t>();
164576
+ field_reader.Finalize();
164577
+
164554
164578
  // now read the enums
164555
- uint32_t enum_count = reader.Read<uint32_t>();
164556
164579
  for (uint32_t i = 0; i < enum_count; i++) {
164557
164580
  ReadType(context, reader);
164558
164581
  }
164559
164582
 
164560
164583
  // read the sequences
164561
- uint32_t seq_count = reader.Read<uint32_t>();
164562
164584
  for (uint32_t i = 0; i < seq_count; i++) {
164563
164585
  ReadSequence(context, reader);
164564
164586
  }
164565
164587
  // read the table count and recreate the tables
164566
- uint32_t table_count = reader.Read<uint32_t>();
164567
164588
  for (uint32_t i = 0; i < table_count; i++) {
164568
164589
  ReadTable(context, reader);
164569
164590
  }
164570
164591
  // now read the views
164571
- uint32_t view_count = reader.Read<uint32_t>();
164572
164592
  for (uint32_t i = 0; i < view_count; i++) {
164573
164593
  ReadView(context, reader);
164574
164594
  }
164575
164595
 
164576
164596
  // finally read the macro's
164577
- uint32_t macro_count = reader.Read<uint32_t>();
164578
164597
  for (uint32_t i = 0; i < macro_count; i++) {
164579
164598
  ReadMacro(context, reader);
164580
164599
  }
164581
164600
 
164582
- uint32_t table_macro_count = reader.Read<uint32_t>();
164583
164601
  for (uint32_t i = 0; i < table_macro_count; i++) {
164584
164602
  ReadTableMacro(context, reader);
164585
164603
  }
@@ -172960,7 +172978,7 @@ string ValidityStatistics::ToString() const {
172960
172978
 
172961
172979
  namespace duckdb {
172962
172980
 
172963
- const uint64_t VERSION_NUMBER = 32;
172981
+ const uint64_t VERSION_NUMBER = 33;
172964
172982
 
172965
172983
  } // namespace duckdb
172966
172984
 
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 "f1278198b"
15
+ #define DUCKDB_VERSION "v0.3.3-dev1279"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -5504,10 +5504,9 @@ class CycleCounter {
5504
5504
  friend struct ExpressionInfo;
5505
5505
  friend struct ExpressionRootInfo;
5506
5506
  static constexpr int SAMPLING_RATE = 50;
5507
- static constexpr int SAMPLING_VARIANCE = 100;
5508
5507
 
5509
5508
  public:
5510
- CycleCounter() : random(-1) {
5509
+ CycleCounter() {
5511
5510
  }
5512
5511
  // Next_sample determines if a sample needs to be taken, if so start the profiler
5513
5512
  void BeginSample() {
@@ -5522,7 +5521,7 @@ public:
5522
5521
  time += Tick() - tmp;
5523
5522
  }
5524
5523
  if (current_count >= next_sample) {
5525
- next_sample = SAMPLING_RATE + random.NextRandomInteger() % SAMPLING_VARIANCE;
5524
+ next_sample = SAMPLING_RATE;
5526
5525
  ++sample_count;
5527
5526
  sample_tuples_count += chunk_size;
5528
5527
  current_count = 0;
@@ -5548,8 +5547,6 @@ private:
5548
5547
  uint64_t sample_tuples_count = 0;
5549
5548
  //! Count the number of ALL tuples
5550
5549
  uint64_t tuples_count = 0;
5551
- //! the random number generator used for sampling
5552
- RandomEngine random;
5553
5550
  };
5554
5551
 
5555
5552
  } // namespace duckdb