duckdb 0.3.2-dev589.0 → 0.3.2-dev599.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 +3 -3
- package/src/duckdb.cpp +75 -5
- package/src/duckdb.hpp +2 -2
- package/src/statement.cpp +3 -0
- package/test/data_type_support.test.js +23 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "duckdb",
|
|
3
3
|
"main": "./lib/duckdb.js",
|
|
4
|
-
"version": "0.3.2-
|
|
4
|
+
"version": "0.3.2-dev599.0",
|
|
5
5
|
"description": "DuckDB node.js API",
|
|
6
6
|
"gypfile": true,
|
|
7
7
|
"dependencies": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"test": "test"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"aws-sdk": "^2.790.0",
|
|
29
|
+
"mocha": "^8.3.0"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
package/src/duckdb.cpp
CHANGED
|
@@ -24064,7 +24064,7 @@ void Printer::FinishProgressBarPrint(const char *pbstr, int pbwidth) {
|
|
|
24064
24064
|
bool Printer::IsTerminal() {
|
|
24065
24065
|
#ifndef DUCKDB_DISABLE_PRINT
|
|
24066
24066
|
#ifdef DUCKDB_WINDOWS
|
|
24067
|
-
return GetFileType(
|
|
24067
|
+
return GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_CHAR;
|
|
24068
24068
|
#else
|
|
24069
24069
|
throw InternalException("IsTerminal is only implemented for Windows");
|
|
24070
24070
|
#endif
|
|
@@ -35179,7 +35179,9 @@ enum class DatePartSpecifier : uint8_t {
|
|
|
35179
35179
|
WEEK,
|
|
35180
35180
|
QUARTER,
|
|
35181
35181
|
DOY,
|
|
35182
|
-
YEARWEEK
|
|
35182
|
+
YEARWEEK,
|
|
35183
|
+
ERA,
|
|
35184
|
+
OFFSET
|
|
35183
35185
|
};
|
|
35184
35186
|
|
|
35185
35187
|
DUCKDB_API bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
|
|
@@ -79428,7 +79430,7 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
79428
79430
|
result = DatePartSpecifier::YEAR;
|
|
79429
79431
|
} else if (specifier == "month" || specifier == "mon" || specifier == "months" || specifier == "mons") {
|
|
79430
79432
|
result = DatePartSpecifier::MONTH;
|
|
79431
|
-
} else if (specifier == "day" || specifier == "days" || specifier == "d") {
|
|
79433
|
+
} else if (specifier == "day" || specifier == "days" || specifier == "d" || specifier == "dayofmonth") {
|
|
79432
79434
|
result = DatePartSpecifier::DAY;
|
|
79433
79435
|
} else if (specifier == "decade" || specifier == "decades") {
|
|
79434
79436
|
result = DatePartSpecifier::DECADE;
|
|
@@ -79450,13 +79452,13 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
79450
79452
|
} else if (specifier == "epoch") {
|
|
79451
79453
|
// seconds since 1970-01-01
|
|
79452
79454
|
result = DatePartSpecifier::EPOCH;
|
|
79453
|
-
} else if (specifier == "dow" || specifier == "dayofweek") {
|
|
79455
|
+
} else if (specifier == "dow" || specifier == "dayofweek" || specifier == "weekday") {
|
|
79454
79456
|
// day of the week (Sunday = 0, Saturday = 6)
|
|
79455
79457
|
result = DatePartSpecifier::DOW;
|
|
79456
79458
|
} else if (specifier == "isodow") {
|
|
79457
79459
|
// isodow (Monday = 1, Sunday = 7)
|
|
79458
79460
|
result = DatePartSpecifier::ISODOW;
|
|
79459
|
-
} else if (specifier == "week" || specifier == "weeks" || specifier == "w") {
|
|
79461
|
+
} else if (specifier == "week" || specifier == "weeks" || specifier == "w" || specifier == "weekofyear") {
|
|
79460
79462
|
// week number
|
|
79461
79463
|
result = DatePartSpecifier::WEEK;
|
|
79462
79464
|
} else if (specifier == "doy" || specifier == "dayofyear") {
|
|
@@ -79468,6 +79470,10 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
79468
79470
|
} else if (specifier == "yearweek") {
|
|
79469
79471
|
// Combined year and week YYYYWW
|
|
79470
79472
|
result = DatePartSpecifier::YEARWEEK;
|
|
79473
|
+
} else if (specifier == "era") {
|
|
79474
|
+
result = DatePartSpecifier::ERA;
|
|
79475
|
+
} else if (specifier == "offset") {
|
|
79476
|
+
result = DatePartSpecifier::OFFSET;
|
|
79471
79477
|
} else {
|
|
79472
79478
|
return false;
|
|
79473
79479
|
}
|
|
@@ -79786,6 +79792,35 @@ struct DatePart {
|
|
|
79786
79792
|
return PropagateDatePartStatistics<T, EpochOperator>(child_stats);
|
|
79787
79793
|
}
|
|
79788
79794
|
};
|
|
79795
|
+
|
|
79796
|
+
struct EraOperator {
|
|
79797
|
+
template <class TA, class TR>
|
|
79798
|
+
static inline TR Operation(TA input) {
|
|
79799
|
+
return Date::ExtractYear(input) > 0 ? 1 : 0;
|
|
79800
|
+
}
|
|
79801
|
+
|
|
79802
|
+
template <class T>
|
|
79803
|
+
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, BoundFunctionExpression &expr,
|
|
79804
|
+
FunctionData *bind_data,
|
|
79805
|
+
vector<unique_ptr<BaseStatistics>> &child_stats) {
|
|
79806
|
+
return PropagateSimpleDatePartStatistics<0, 1>(child_stats);
|
|
79807
|
+
}
|
|
79808
|
+
};
|
|
79809
|
+
|
|
79810
|
+
struct OffsetOperator {
|
|
79811
|
+
template <class TA, class TR>
|
|
79812
|
+
static inline TR Operation(TA input) {
|
|
79813
|
+
// Regular timestamps are UTC.
|
|
79814
|
+
return 0;
|
|
79815
|
+
}
|
|
79816
|
+
|
|
79817
|
+
template <class T>
|
|
79818
|
+
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, BoundFunctionExpression &expr,
|
|
79819
|
+
FunctionData *bind_data,
|
|
79820
|
+
vector<unique_ptr<BaseStatistics>> &child_stats) {
|
|
79821
|
+
return PropagateSimpleDatePartStatistics<0, 0>(child_stats);
|
|
79822
|
+
}
|
|
79823
|
+
};
|
|
79789
79824
|
};
|
|
79790
79825
|
|
|
79791
79826
|
template <>
|
|
@@ -80060,6 +80095,36 @@ DatePart::EpochOperator::PropagateStatistics<dtime_t>(ClientContext &context, Bo
|
|
|
80060
80095
|
return PropagateSimpleDatePartStatistics<0, 86400>(child_stats);
|
|
80061
80096
|
}
|
|
80062
80097
|
|
|
80098
|
+
template <>
|
|
80099
|
+
int64_t DatePart::EraOperator::Operation(timestamp_t input) {
|
|
80100
|
+
return EraOperator::Operation<date_t, int64_t>(Timestamp::GetDate(input));
|
|
80101
|
+
}
|
|
80102
|
+
|
|
80103
|
+
template <>
|
|
80104
|
+
int64_t DatePart::EraOperator::Operation(interval_t input) {
|
|
80105
|
+
throw NotImplementedException("interval units \"era\" not recognized");
|
|
80106
|
+
}
|
|
80107
|
+
|
|
80108
|
+
template <>
|
|
80109
|
+
int64_t DatePart::EraOperator::Operation(dtime_t input) {
|
|
80110
|
+
throw NotImplementedException("\"time\" units \"era\" not recognized");
|
|
80111
|
+
}
|
|
80112
|
+
|
|
80113
|
+
template <>
|
|
80114
|
+
int64_t DatePart::OffsetOperator::Operation(timestamp_t input) {
|
|
80115
|
+
return 0;
|
|
80116
|
+
}
|
|
80117
|
+
|
|
80118
|
+
template <>
|
|
80119
|
+
int64_t DatePart::OffsetOperator::Operation(interval_t input) {
|
|
80120
|
+
return 0;
|
|
80121
|
+
}
|
|
80122
|
+
|
|
80123
|
+
template <>
|
|
80124
|
+
int64_t DatePart::OffsetOperator::Operation(dtime_t input) {
|
|
80125
|
+
return 0;
|
|
80126
|
+
}
|
|
80127
|
+
|
|
80063
80128
|
template <class T>
|
|
80064
80129
|
static int64_t ExtractElement(DatePartSpecifier type, T element) {
|
|
80065
80130
|
switch (type) {
|
|
@@ -80099,6 +80164,10 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
|
|
|
80099
80164
|
return DatePart::MinutesOperator::template Operation<T, int64_t>(element);
|
|
80100
80165
|
case DatePartSpecifier::HOUR:
|
|
80101
80166
|
return DatePart::HoursOperator::template Operation<T, int64_t>(element);
|
|
80167
|
+
case DatePartSpecifier::ERA:
|
|
80168
|
+
return DatePart::EraOperator::template Operation<T, int64_t>(element);
|
|
80169
|
+
case DatePartSpecifier::OFFSET:
|
|
80170
|
+
return DatePart::OffsetOperator::template Operation<T, int64_t>(element);
|
|
80102
80171
|
default:
|
|
80103
80172
|
throw NotImplementedException("Specifier type not implemented for DATEPART");
|
|
80104
80173
|
}
|
|
@@ -80212,6 +80281,7 @@ void DatePartFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
80212
80281
|
AddDatePartOperator<DatePart::ISODayOfWeekOperator>(set, "isodow");
|
|
80213
80282
|
AddDatePartOperator<DatePart::DayOfYearOperator>(set, "dayofyear");
|
|
80214
80283
|
AddDatePartOperator<DatePart::WeekOperator>(set, "week");
|
|
80284
|
+
AddDatePartOperator<DatePart::EraOperator>(set, "era");
|
|
80215
80285
|
AddTimePartOperator<DatePart::EpochOperator>(set, "epoch");
|
|
80216
80286
|
AddTimePartOperator<DatePart::MicrosecondsOperator>(set, "microsecond");
|
|
80217
80287
|
AddTimePartOperator<DatePart::MillisecondsOperator>(set, "millisecond");
|
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.3.2-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "e7d62425f"
|
|
14
|
+
#define DUCKDB_VERSION "0.3.2-dev599"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
package/src/statement.cpp
CHANGED
|
@@ -171,6 +171,9 @@ static Napi::Value convert_chunk(Napi::Env &env, std::vector<std::string> names,
|
|
|
171
171
|
case duckdb::LogicalTypeId::VARCHAR: {
|
|
172
172
|
value = Napi::String::New(env, dval.str_value);
|
|
173
173
|
} break;
|
|
174
|
+
case duckdb::LogicalTypeId::BOOLEAN: {
|
|
175
|
+
value = Napi::Boolean::New(env, dval.value_.boolean);
|
|
176
|
+
} break;
|
|
174
177
|
case duckdb::LogicalTypeId::BLOB: {
|
|
175
178
|
value = Napi::Buffer<char>::Copy(env, dval.str_value.c_str(), dval.str_value.length());
|
|
176
179
|
} break;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var sqlite3 = require("..");
|
|
2
|
+
var assert = require("assert");
|
|
3
|
+
|
|
4
|
+
describe("data type support", function () {
|
|
5
|
+
let db;
|
|
6
|
+
before(function (done) {
|
|
7
|
+
db = new sqlite3.Database(":memory:", done);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("supports BOOLEAN values", function (done) {
|
|
11
|
+
db.run("CREATE TABLE boolean_table (i BOOLEAN)");
|
|
12
|
+
const stmt = db.prepare("INSERT INTO boolean_table VALUES (?)");
|
|
13
|
+
const values = [true, false];
|
|
14
|
+
values.forEach((bool) => {
|
|
15
|
+
stmt.run(bool);
|
|
16
|
+
});
|
|
17
|
+
db.prepare("SELECT i from boolean_table;").all((err, res) => {
|
|
18
|
+
assert(err === null);
|
|
19
|
+
assert(res.every((v, i) => v.i === values[i]));
|
|
20
|
+
done();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|