duckdb 0.3.2-dev706.0 → 0.3.2-dev733.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/statement.cpp CHANGED
@@ -135,6 +135,10 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
135
135
 
136
136
  for (duckdb::idx_t col_idx = 0; col_idx < chunk.ColumnCount(); col_idx++) {
137
137
  Napi::Value value;
138
+ // set up a new Napi::Object for some data types, e.g. INTERVAL
139
+ Napi::Object object_value;
140
+
141
+ bool is_object_value {false};
138
142
 
139
143
  auto dval = chunk.GetValue(col_idx, row_idx);
140
144
  if (dval.is_null) {
@@ -159,6 +163,13 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
159
163
  case duckdb::LogicalTypeId::HUGEINT: {
160
164
  value = Napi::Number::New(env, dval.GetValue<double>());
161
165
  } break;
166
+ case duckdb::LogicalTypeId::INTERVAL: {
167
+ is_object_value = true;
168
+ object_value = Napi::Object::New(env);
169
+ object_value.Set("months", dval.value_.interval.months);
170
+ object_value.Set("days", dval.value_.interval.days);
171
+ object_value.Set("micros", dval.value_.interval.micros);
172
+ } break;
162
173
  #if (NAPI_VERSION > 4)
163
174
  case duckdb::LogicalTypeId::DATE: {
164
175
  const auto scale = duckdb::Interval::SECS_PER_DAY * duckdb::Interval::MSECS_PER_SEC;
@@ -185,7 +196,11 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
185
196
  .ThrowAsJavaScriptException();
186
197
  return env.Null();
187
198
  }
188
- row_result.Set(node_names[col_idx], value);
199
+ if (is_object_value == true) {
200
+ row_result.Set(node_names[col_idx], object_value);
201
+ } else {
202
+ row_result.Set(node_names[col_idx], value);
203
+ }
189
204
  }
190
205
  result.Set(row_idx, row_result);
191
206
  }
@@ -20,4 +20,18 @@ describe("data type support", function () {
20
20
  done();
21
21
  });
22
22
  });
23
+ it("supports INTERVAL values", function (done) {
24
+ db.prepare(`SELECT
25
+ INTERVAL 1 MINUTE as minutes,
26
+ INTERVAL 5 DAY as days,
27
+ INTERVAL 4 MONTH as months,
28
+ INTERVAL 4 MONTH + INTERVAL 5 DAY + INTERVAL 1 MINUTE as combined;`).each((err, row) => {
29
+ assert(err === null);
30
+ assert.deepEqual(row.minutes, { months: 0, days: 0, micros: 60 * 1000 * 1000});
31
+ assert.deepEqual(row.days, { months: 0, days: 5, micros: 0});
32
+ assert.deepEqual(row.months, {months: 4, days: 0, micros: 0});
33
+ assert.deepEqual(row.combined, {months: 4, days: 5, micros: 60 * 1000 * 1000});
34
+ done();
35
+ });
36
+ });
23
37
  });
@@ -0,0 +1,16 @@
1
+ var sqlite3 = require('..');
2
+ var assert = require('assert');
3
+ var helper = require('./support/helper');
4
+
5
+ describe('can query parquet', function() {
6
+ var db;
7
+
8
+ before(function(done) {
9
+ db = new sqlite3.Database(':memory:', done);
10
+ });
11
+
12
+ it('should be able to read parquet files', function(done) {
13
+ db.run("select * from parquet_scan('../../data/parquet-testing/userdata1.parquet')", done);
14
+ });
15
+
16
+ });