@duckdb/node-api 1.4.1-r.4 → 1.4.2-r.1
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/lib/DuckDBClientContext.d.ts +6 -0
- package/lib/DuckDBClientContext.js +17 -0
- package/lib/DuckDBConnection.d.ts +3 -0
- package/lib/DuckDBConnection.js +16 -0
- package/lib/DuckDBLogicalType.js +6 -0
- package/lib/DuckDBPreparedStatement.d.ts +4 -0
- package/lib/DuckDBPreparedStatement.js +12 -0
- package/lib/DuckDBType.d.ts +19 -1
- package/lib/DuckDBType.js +34 -1
- package/lib/DuckDBTypeId.d.ts +4 -1
- package/lib/DuckDBTypeId.js +3 -0
- package/lib/DuckDBVector.d.ts +15 -2
- package/lib/DuckDBVector.js +54 -3
- package/lib/JSDuckDBValueConverter.js +3 -0
- package/lib/JsonDuckDBValueConverter.js +3 -0
- package/lib/createValue.js +9 -0
- package/lib/duckdb.d.ts +1 -0
- package/lib/duckdb.js +1 -0
- package/lib/typeForValue.js +3 -0
- package/lib/values/DuckDBTimeNSValue.d.ts +9 -0
- package/lib/values/DuckDBTimeNSValue.js +20 -0
- package/lib/values/DuckDBValue.d.ts +2 -1
- package/lib/values/index.d.ts +1 -0
- package/lib/values/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DuckDBClientContext = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
|
+
class DuckDBClientContext {
|
|
9
|
+
client_context;
|
|
10
|
+
constructor(client_context) {
|
|
11
|
+
this.client_context = client_context;
|
|
12
|
+
}
|
|
13
|
+
get connectionId() {
|
|
14
|
+
return node_bindings_1.default.client_context_get_connection_id(this.client_context);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.DuckDBClientContext = DuckDBClientContext;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import duckdb from '@duckdb/node-bindings';
|
|
2
2
|
import { DuckDBAppender } from './DuckDBAppender';
|
|
3
|
+
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
4
|
import { DuckDBExtractedStatements } from './DuckDBExtractedStatements';
|
|
4
5
|
import { DuckDBInstance } from './DuckDBInstance';
|
|
5
6
|
import { DuckDBMaterializedResult } from './DuckDBMaterializedResult';
|
|
@@ -18,6 +19,7 @@ export declare class DuckDBConnection {
|
|
|
18
19
|
/** Same as disconnectSync. */
|
|
19
20
|
closeSync(): void;
|
|
20
21
|
disconnectSync(): void;
|
|
22
|
+
get clientContext(): DuckDBClientContext;
|
|
21
23
|
interrupt(): void;
|
|
22
24
|
get progress(): duckdb.QueryProgress;
|
|
23
25
|
run(sql: string, values?: DuckDBValue[] | Record<string, DuckDBValue>, types?: DuckDBType[] | Record<string, DuckDBType | undefined>): Promise<DuckDBMaterializedResult>;
|
|
@@ -34,6 +36,7 @@ export declare class DuckDBConnection {
|
|
|
34
36
|
private createPrepared;
|
|
35
37
|
extractStatements(sql: string): Promise<DuckDBExtractedStatements>;
|
|
36
38
|
private runUntilLast;
|
|
39
|
+
getTableNames(query: string, qualified: boolean): readonly string[];
|
|
37
40
|
createAppender(table: string, schema?: string | null, catalog?: string | null): Promise<DuckDBAppender>;
|
|
38
41
|
registerScalarFunction(scalarFunction: DuckDBScalarFunction): void;
|
|
39
42
|
}
|
package/lib/DuckDBConnection.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DuckDBConnection = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
8
|
const DuckDBAppender_1 = require("./DuckDBAppender");
|
|
9
|
+
const DuckDBClientContext_1 = require("./DuckDBClientContext");
|
|
9
10
|
const DuckDBExtractedStatements_1 = require("./DuckDBExtractedStatements");
|
|
10
11
|
const DuckDBInstance_1 = require("./DuckDBInstance");
|
|
11
12
|
const DuckDBMaterializedResult_1 = require("./DuckDBMaterializedResult");
|
|
@@ -33,6 +34,9 @@ class DuckDBConnection {
|
|
|
33
34
|
this.preparedStatements.destroySync();
|
|
34
35
|
node_bindings_1.default.disconnect_sync(this.connection);
|
|
35
36
|
}
|
|
37
|
+
get clientContext() {
|
|
38
|
+
return new DuckDBClientContext_1.DuckDBClientContext(node_bindings_1.default.connection_get_client_context(this.connection));
|
|
39
|
+
}
|
|
36
40
|
interrupt() {
|
|
37
41
|
node_bindings_1.default.interrupt(this.connection);
|
|
38
42
|
}
|
|
@@ -149,6 +153,18 @@ class DuckDBConnection {
|
|
|
149
153
|
}
|
|
150
154
|
return extractedStatements.prepare(statementCount - 1);
|
|
151
155
|
}
|
|
156
|
+
getTableNames(query, qualified) {
|
|
157
|
+
const names = [];
|
|
158
|
+
const list_value = node_bindings_1.default.get_table_names(this.connection, query, qualified);
|
|
159
|
+
const count = node_bindings_1.default.get_list_size(list_value);
|
|
160
|
+
for (let i = 0; i < count; i++) {
|
|
161
|
+
const varchar_value = node_bindings_1.default.get_list_child(list_value, i);
|
|
162
|
+
const name = node_bindings_1.default.get_varchar(varchar_value);
|
|
163
|
+
names.push(name);
|
|
164
|
+
}
|
|
165
|
+
names.sort();
|
|
166
|
+
return names;
|
|
167
|
+
}
|
|
152
168
|
async createAppender(table, schema, catalog) {
|
|
153
169
|
return new DuckDBAppender_1.DuckDBAppender(node_bindings_1.default.appender_create_ext(this.connection, catalog ?? null, schema ?? null, table));
|
|
154
170
|
}
|
package/lib/DuckDBLogicalType.js
CHANGED
|
@@ -159,6 +159,12 @@ class DuckDBLogicalType {
|
|
|
159
159
|
return DuckDBType_1.DuckDBBigNumType.create(alias);
|
|
160
160
|
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
161
161
|
return DuckDBType_1.DuckDBSQLNullType.create(alias);
|
|
162
|
+
case DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL:
|
|
163
|
+
return DuckDBType_1.DuckDBStringLiteralType.create(alias);
|
|
164
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL:
|
|
165
|
+
return DuckDBType_1.DuckDBIntegerLiteralType.create(alias);
|
|
166
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME_NS:
|
|
167
|
+
return DuckDBType_1.DuckDBTimeNSType.create(alias);
|
|
162
168
|
default:
|
|
163
169
|
throw new Error(`Unexpected type id: ${this.typeId}`);
|
|
164
170
|
}
|
|
@@ -16,6 +16,10 @@ export declare class DuckDBPreparedStatement {
|
|
|
16
16
|
parameterName(parameterIndex: number): string;
|
|
17
17
|
parameterTypeId(parameterIndex: number): DuckDBTypeId;
|
|
18
18
|
parameterType(parameterIndex: number): DuckDBType;
|
|
19
|
+
get columnCount(): number;
|
|
20
|
+
columnName(columnIndex: number): string;
|
|
21
|
+
columnTypeId(columnIndex: number): DuckDBTypeId;
|
|
22
|
+
columnType(columnIndex: number): DuckDBType;
|
|
19
23
|
clearBindings(): void;
|
|
20
24
|
parameterIndex(parameterName: string): number;
|
|
21
25
|
bindBoolean(parameterIndex: number, value: boolean): void;
|
|
@@ -37,6 +37,18 @@ class DuckDBPreparedStatement {
|
|
|
37
37
|
parameterType(parameterIndex) {
|
|
38
38
|
return DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.param_logical_type(this.prepared_statement, parameterIndex)).asType();
|
|
39
39
|
}
|
|
40
|
+
get columnCount() {
|
|
41
|
+
return node_bindings_1.default.prepared_statement_column_count(this.prepared_statement);
|
|
42
|
+
}
|
|
43
|
+
columnName(columnIndex) {
|
|
44
|
+
return node_bindings_1.default.prepared_statement_column_name(this.prepared_statement, columnIndex);
|
|
45
|
+
}
|
|
46
|
+
columnTypeId(columnIndex) {
|
|
47
|
+
return node_bindings_1.default.prepared_statement_column_type(this.prepared_statement, columnIndex);
|
|
48
|
+
}
|
|
49
|
+
columnType(columnIndex) {
|
|
50
|
+
return DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.prepared_statement_column_logical_type(this.prepared_statement, columnIndex)).asType();
|
|
51
|
+
}
|
|
40
52
|
clearBindings() {
|
|
41
53
|
node_bindings_1.default.clear_bindings(this.prepared_statement);
|
|
42
54
|
}
|
package/lib/DuckDBType.d.ts
CHANGED
|
@@ -352,4 +352,22 @@ export declare class DuckDBSQLNullType extends BaseDuckDBType<DuckDBTypeId.SQLNU
|
|
|
352
352
|
static create(alias?: string): DuckDBSQLNullType;
|
|
353
353
|
}
|
|
354
354
|
export declare const SQLNULL: DuckDBSQLNullType;
|
|
355
|
-
export
|
|
355
|
+
export declare class DuckDBStringLiteralType extends BaseDuckDBType<DuckDBTypeId.STRING_LITERAL> {
|
|
356
|
+
constructor(alias?: string);
|
|
357
|
+
static readonly instance: DuckDBStringLiteralType;
|
|
358
|
+
static create(alias?: string): DuckDBStringLiteralType;
|
|
359
|
+
}
|
|
360
|
+
export declare const STRING_LITERAL: DuckDBStringLiteralType;
|
|
361
|
+
export declare class DuckDBIntegerLiteralType extends BaseDuckDBType<DuckDBTypeId.INTEGER_LITERAL> {
|
|
362
|
+
constructor(alias?: string);
|
|
363
|
+
static readonly instance: DuckDBIntegerLiteralType;
|
|
364
|
+
static create(alias?: string): DuckDBIntegerLiteralType;
|
|
365
|
+
}
|
|
366
|
+
export declare const INTEGER_LITERAL: DuckDBIntegerLiteralType;
|
|
367
|
+
export declare class DuckDBTimeNSType extends BaseDuckDBType<DuckDBTypeId.TIME_NS> {
|
|
368
|
+
constructor(alias?: string);
|
|
369
|
+
static readonly instance: DuckDBTimeNSType;
|
|
370
|
+
static create(alias?: string): DuckDBTimeNSType;
|
|
371
|
+
}
|
|
372
|
+
export declare const TIME_NS: DuckDBTimeNSType;
|
|
373
|
+
export type DuckDBType = DuckDBBooleanType | DuckDBTinyIntType | DuckDBSmallIntType | DuckDBIntegerType | DuckDBBigIntType | DuckDBUTinyIntType | DuckDBUSmallIntType | DuckDBUIntegerType | DuckDBUBigIntType | DuckDBFloatType | DuckDBDoubleType | DuckDBTimestampType | DuckDBDateType | DuckDBTimeType | DuckDBIntervalType | DuckDBHugeIntType | DuckDBUHugeIntType | DuckDBVarCharType | DuckDBBlobType | DuckDBDecimalType | DuckDBTimestampSecondsType | DuckDBTimestampMillisecondsType | DuckDBTimestampNanosecondsType | DuckDBEnumType | DuckDBListType | DuckDBStructType | DuckDBMapType | DuckDBArrayType | DuckDBUUIDType | DuckDBUnionType | DuckDBBitType | DuckDBTimeTZType | DuckDBTimestampTZType | DuckDBAnyType | DuckDBBigNumType | DuckDBSQLNullType | DuckDBStringLiteralType | DuckDBIntegerLiteralType | DuckDBTimeNSType;
|
package/lib/DuckDBType.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DuckDBStructType = exports.DuckDBListType = exports.DuckDBEnumType = exports.TIMESTAMP_NS = exports.DuckDBTimestampNanosecondsType = exports.TIMESTAMP_MS = exports.DuckDBTimestampMillisecondsType = exports.TIMESTAMP_S = exports.DuckDBTimestampSecondsType = exports.DuckDBDecimalType = exports.BLOB = exports.DuckDBBlobType = exports.VARCHAR = exports.DuckDBVarCharType = exports.UHUGEINT = exports.DuckDBUHugeIntType = exports.HUGEINT = exports.DuckDBHugeIntType = exports.INTERVAL = exports.DuckDBIntervalType = exports.TIME = exports.DuckDBTimeType = exports.DATE = exports.DuckDBDateType = exports.DuckDBTimestampMicrosecondsType = exports.TIMESTAMP = exports.DuckDBTimestampType = exports.DOUBLE = exports.DuckDBDoubleType = exports.FLOAT = exports.DuckDBFloatType = exports.UBIGINT = exports.DuckDBUBigIntType = exports.UINTEGER = exports.DuckDBUIntegerType = exports.USMALLINT = exports.DuckDBUSmallIntType = exports.UTINYINT = exports.DuckDBUTinyIntType = exports.BIGINT = exports.DuckDBBigIntType = exports.INTEGER = exports.DuckDBIntegerType = exports.SMALLINT = exports.DuckDBSmallIntType = exports.TINYINT = exports.DuckDBTinyIntType = exports.BOOLEAN = exports.DuckDBBooleanType = exports.BaseDuckDBType = void 0;
|
|
7
|
-
exports.SQLNULL = exports.DuckDBSQLNullType = exports.BIGNUM = exports.DuckDBBigNumType = exports.ANY = exports.DuckDBAnyType = exports.TIMESTAMPTZ = exports.DuckDBTimestampTZType = exports.TIMETZ = exports.DuckDBTimeTZType = exports.BIT = exports.DuckDBBitType = exports.DuckDBUnionType = exports.UUID = exports.DuckDBUUIDType = exports.DuckDBArrayType = exports.DuckDBMapType = void 0;
|
|
7
|
+
exports.TIME_NS = exports.DuckDBTimeNSType = exports.INTEGER_LITERAL = exports.DuckDBIntegerLiteralType = exports.STRING_LITERAL = exports.DuckDBStringLiteralType = exports.SQLNULL = exports.DuckDBSQLNullType = exports.BIGNUM = exports.DuckDBBigNumType = exports.ANY = exports.DuckDBAnyType = exports.TIMESTAMPTZ = exports.DuckDBTimestampTZType = exports.TIMETZ = exports.DuckDBTimeTZType = exports.BIT = exports.DuckDBBitType = exports.DuckDBUnionType = exports.UUID = exports.DuckDBUUIDType = exports.DuckDBArrayType = exports.DuckDBMapType = void 0;
|
|
8
8
|
exports.DECIMAL = DECIMAL;
|
|
9
9
|
exports.ENUM8 = ENUM8;
|
|
10
10
|
exports.ENUM16 = ENUM16;
|
|
@@ -895,3 +895,36 @@ class DuckDBSQLNullType extends BaseDuckDBType {
|
|
|
895
895
|
}
|
|
896
896
|
exports.DuckDBSQLNullType = DuckDBSQLNullType;
|
|
897
897
|
exports.SQLNULL = DuckDBSQLNullType.instance;
|
|
898
|
+
class DuckDBStringLiteralType extends BaseDuckDBType {
|
|
899
|
+
constructor(alias) {
|
|
900
|
+
super(DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL, alias);
|
|
901
|
+
}
|
|
902
|
+
static instance = new DuckDBStringLiteralType();
|
|
903
|
+
static create(alias) {
|
|
904
|
+
return alias ? new DuckDBStringLiteralType(alias) : DuckDBStringLiteralType.instance;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
exports.DuckDBStringLiteralType = DuckDBStringLiteralType;
|
|
908
|
+
exports.STRING_LITERAL = DuckDBStringLiteralType.instance;
|
|
909
|
+
class DuckDBIntegerLiteralType extends BaseDuckDBType {
|
|
910
|
+
constructor(alias) {
|
|
911
|
+
super(DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL, alias);
|
|
912
|
+
}
|
|
913
|
+
static instance = new DuckDBIntegerLiteralType();
|
|
914
|
+
static create(alias) {
|
|
915
|
+
return alias ? new DuckDBIntegerLiteralType(alias) : DuckDBIntegerLiteralType.instance;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
exports.DuckDBIntegerLiteralType = DuckDBIntegerLiteralType;
|
|
919
|
+
exports.INTEGER_LITERAL = DuckDBIntegerLiteralType.instance;
|
|
920
|
+
class DuckDBTimeNSType extends BaseDuckDBType {
|
|
921
|
+
constructor(alias) {
|
|
922
|
+
super(DuckDBTypeId_1.DuckDBTypeId.TIME_NS, alias);
|
|
923
|
+
}
|
|
924
|
+
static instance = new DuckDBTimeNSType();
|
|
925
|
+
static create(alias) {
|
|
926
|
+
return alias ? new DuckDBTimeNSType(alias) : DuckDBTimeNSType.instance;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
exports.DuckDBTimeNSType = DuckDBTimeNSType;
|
|
930
|
+
exports.TIME_NS = DuckDBTimeNSType.instance;
|
package/lib/DuckDBTypeId.d.ts
CHANGED
package/lib/DuckDBTypeId.js
CHANGED
|
@@ -41,4 +41,7 @@ var DuckDBTypeId;
|
|
|
41
41
|
DuckDBTypeId[DuckDBTypeId["ANY"] = 34] = "ANY";
|
|
42
42
|
DuckDBTypeId[DuckDBTypeId["BIGNUM"] = 35] = "BIGNUM";
|
|
43
43
|
DuckDBTypeId[DuckDBTypeId["SQLNULL"] = 36] = "SQLNULL";
|
|
44
|
+
DuckDBTypeId[DuckDBTypeId["STRING_LITERAL"] = 37] = "STRING_LITERAL";
|
|
45
|
+
DuckDBTypeId[DuckDBTypeId["INTEGER_LITERAL"] = 38] = "INTEGER_LITERAL";
|
|
46
|
+
DuckDBTypeId[DuckDBTypeId["TIME_NS"] = 39] = "TIME_NS";
|
|
44
47
|
})(DuckDBTypeId || (exports.DuckDBTypeId = DuckDBTypeId = {}));
|
package/lib/DuckDBVector.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import duckdb from '@duckdb/node-bindings';
|
|
2
|
-
import { DuckDBArrayType, DuckDBBigIntType, DuckDBBigNumType, DuckDBBitType, DuckDBBlobType, DuckDBBooleanType, DuckDBDateType, DuckDBDecimalType, DuckDBDoubleType, DuckDBEnumType, DuckDBFloatType, DuckDBHugeIntType, DuckDBIntegerType, DuckDBIntervalType, DuckDBListType, DuckDBMapType, DuckDBSmallIntType, DuckDBStructType, DuckDBTimeTZType, DuckDBTimeType, DuckDBTimestampMillisecondsType, DuckDBTimestampNanosecondsType, DuckDBTimestampSecondsType, DuckDBTimestampTZType, DuckDBTimestampType, DuckDBTinyIntType, DuckDBType, DuckDBUBigIntType, DuckDBUHugeIntType, DuckDBUIntegerType, DuckDBUSmallIntType, DuckDBUTinyIntType, DuckDBUUIDType, DuckDBUnionType, DuckDBVarCharType } from './DuckDBType';
|
|
3
|
-
import { DuckDBArrayValue, DuckDBBitValue, DuckDBBlobValue, DuckDBDateValue, DuckDBDecimalValue, DuckDBIntervalValue, DuckDBListValue, DuckDBMapValue, DuckDBStructValue, DuckDBTimeTZValue, DuckDBTimeValue, DuckDBTimestampMillisecondsValue, DuckDBTimestampNanosecondsValue, DuckDBTimestampSecondsValue, DuckDBTimestampTZValue, DuckDBTimestampValue, DuckDBUUIDValue, DuckDBUnionValue, DuckDBValue } from './values';
|
|
2
|
+
import { DuckDBArrayType, DuckDBBigIntType, DuckDBBigNumType, DuckDBBitType, DuckDBBlobType, DuckDBBooleanType, DuckDBDateType, DuckDBDecimalType, DuckDBDoubleType, DuckDBEnumType, DuckDBFloatType, DuckDBHugeIntType, DuckDBIntegerType, DuckDBIntervalType, DuckDBListType, DuckDBMapType, DuckDBSmallIntType, DuckDBStructType, DuckDBTimeNSType, DuckDBTimeTZType, DuckDBTimeType, DuckDBTimestampMillisecondsType, DuckDBTimestampNanosecondsType, DuckDBTimestampSecondsType, DuckDBTimestampTZType, DuckDBTimestampType, DuckDBTinyIntType, DuckDBType, DuckDBUBigIntType, DuckDBUHugeIntType, DuckDBUIntegerType, DuckDBUSmallIntType, DuckDBUTinyIntType, DuckDBUUIDType, DuckDBUnionType, DuckDBVarCharType } from './DuckDBType';
|
|
3
|
+
import { DuckDBArrayValue, DuckDBBitValue, DuckDBBlobValue, DuckDBDateValue, DuckDBDecimalValue, DuckDBIntervalValue, DuckDBListValue, DuckDBMapValue, DuckDBStructValue, DuckDBTimeNSValue, DuckDBTimeTZValue, DuckDBTimeValue, DuckDBTimestampMillisecondsValue, DuckDBTimestampNanosecondsValue, DuckDBTimestampSecondsValue, DuckDBTimestampTZValue, DuckDBTimestampValue, DuckDBUUIDValue, DuckDBUnionValue, DuckDBValue } from './values';
|
|
4
4
|
declare class DuckDBValidity {
|
|
5
5
|
private data;
|
|
6
6
|
private readonly offset;
|
|
@@ -580,4 +580,17 @@ export declare class DuckDBBigNumVector extends DuckDBVector<bigint> {
|
|
|
580
580
|
flush(): void;
|
|
581
581
|
slice(offset: number, length: number): DuckDBBigNumVector;
|
|
582
582
|
}
|
|
583
|
+
export declare class DuckDBTimeNSVector extends DuckDBVector<DuckDBTimeNSValue> {
|
|
584
|
+
private readonly items;
|
|
585
|
+
private readonly validity;
|
|
586
|
+
private readonly vector;
|
|
587
|
+
constructor(items: BigInt64Array, validity: DuckDBValidity, vector: duckdb.Vector);
|
|
588
|
+
static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBTimeNSVector;
|
|
589
|
+
get type(): DuckDBTimeNSType;
|
|
590
|
+
get itemCount(): number;
|
|
591
|
+
getItem(itemIndex: number): DuckDBTimeNSValue | null;
|
|
592
|
+
setItem(itemIndex: number, value: DuckDBTimeNSValue | null): void;
|
|
593
|
+
flush(): void;
|
|
594
|
+
slice(offset: number, length: number): DuckDBTimeNSVector;
|
|
595
|
+
}
|
|
583
596
|
export {};
|
package/lib/DuckDBVector.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DuckDBBigNumVector = exports.DuckDBTimestampTZVector = exports.DuckDBTimeTZVector = exports.DuckDBBitVector = exports.DuckDBUnionVector = exports.DuckDBUUIDVector = exports.DuckDBArrayVector = exports.DuckDBMapVector = exports.DuckDBStructVector = exports.DuckDBListVector = exports.DuckDBEnum32Vector = exports.DuckDBEnum16Vector = exports.DuckDBEnum8Vector = exports.DuckDBTimestampNanosecondsVector = exports.DuckDBTimestampMillisecondsVector = exports.DuckDBTimestampSecondsVector = exports.DuckDBDecimal128Vector = exports.DuckDBDecimal64Vector = exports.DuckDBDecimal32Vector = exports.DuckDBDecimal16Vector = exports.DuckDBBlobVector = exports.DuckDBVarCharVector = exports.DuckDBUHugeIntVector = exports.DuckDBHugeIntVector = exports.DuckDBIntervalVector = exports.DuckDBTimeVector = exports.DuckDBDateVector = exports.DuckDBTimestampVector = exports.DuckDBDoubleVector = exports.DuckDBFloatVector = exports.DuckDBUBigIntVector = exports.DuckDBUIntegerVector = exports.DuckDBUSmallIntVector = exports.DuckDBUTinyIntVector = exports.DuckDBBigIntVector = exports.DuckDBIntegerVector = exports.DuckDBSmallIntVector = exports.DuckDBTinyIntVector = exports.DuckDBBooleanVector = exports.DuckDBVector = void 0;
|
|
6
|
+
exports.DuckDBTimeNSVector = exports.DuckDBBigNumVector = exports.DuckDBTimestampTZVector = exports.DuckDBTimeTZVector = exports.DuckDBBitVector = exports.DuckDBUnionVector = exports.DuckDBUUIDVector = exports.DuckDBArrayVector = exports.DuckDBMapVector = exports.DuckDBStructVector = exports.DuckDBListVector = exports.DuckDBEnum32Vector = exports.DuckDBEnum16Vector = exports.DuckDBEnum8Vector = exports.DuckDBTimestampNanosecondsVector = exports.DuckDBTimestampMillisecondsVector = exports.DuckDBTimestampSecondsVector = exports.DuckDBDecimal128Vector = exports.DuckDBDecimal64Vector = exports.DuckDBDecimal32Vector = exports.DuckDBDecimal16Vector = exports.DuckDBBlobVector = exports.DuckDBVarCharVector = exports.DuckDBUHugeIntVector = exports.DuckDBHugeIntVector = exports.DuckDBIntervalVector = exports.DuckDBTimeVector = exports.DuckDBDateVector = exports.DuckDBTimestampVector = exports.DuckDBDoubleVector = exports.DuckDBFloatVector = exports.DuckDBUBigIntVector = exports.DuckDBUIntegerVector = exports.DuckDBUSmallIntVector = exports.DuckDBUTinyIntVector = exports.DuckDBBigIntVector = exports.DuckDBIntegerVector = exports.DuckDBSmallIntVector = exports.DuckDBTinyIntVector = exports.DuckDBBooleanVector = exports.DuckDBVector = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const DuckDBLogicalType_1 = require("./DuckDBLogicalType");
|
|
@@ -438,6 +438,12 @@ class DuckDBVector {
|
|
|
438
438
|
return DuckDBBigNumVector.fromRawVector(vector, itemCount);
|
|
439
439
|
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
440
440
|
throw new Error(`Invalid vector type: SQLNULL`);
|
|
441
|
+
case DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL:
|
|
442
|
+
throw new Error(`Invalid vector type: STRING_LITERAL`);
|
|
443
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL:
|
|
444
|
+
throw new Error(`Invalid vector type: INTEGER_LITERAL`);
|
|
445
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME_NS:
|
|
446
|
+
return DuckDBTimeNSVector.fromRawVector(vector, itemCount);
|
|
441
447
|
default:
|
|
442
448
|
throw new Error(`Invalid type id: ${vectorType.typeId}`);
|
|
443
449
|
}
|
|
@@ -1852,8 +1858,8 @@ class DuckDBListVector extends DuckDBVector {
|
|
|
1852
1858
|
this.validity = validity;
|
|
1853
1859
|
this.vector = vector;
|
|
1854
1860
|
this.childData = childData;
|
|
1855
|
-
this.itemOffset = itemOffset
|
|
1856
|
-
|
|
1861
|
+
this.itemOffset = itemOffset;
|
|
1862
|
+
this._itemCount = itemCount;
|
|
1857
1863
|
this.itemCache = [];
|
|
1858
1864
|
}
|
|
1859
1865
|
static fromRawVector(listType, vector, itemCount) {
|
|
@@ -2472,3 +2478,48 @@ class DuckDBBigNumVector extends DuckDBVector {
|
|
|
2472
2478
|
}
|
|
2473
2479
|
}
|
|
2474
2480
|
exports.DuckDBBigNumVector = DuckDBBigNumVector;
|
|
2481
|
+
class DuckDBTimeNSVector extends DuckDBVector {
|
|
2482
|
+
items;
|
|
2483
|
+
validity;
|
|
2484
|
+
vector;
|
|
2485
|
+
constructor(items, validity, vector) {
|
|
2486
|
+
super();
|
|
2487
|
+
this.items = items;
|
|
2488
|
+
this.validity = validity;
|
|
2489
|
+
this.vector = vector;
|
|
2490
|
+
}
|
|
2491
|
+
static fromRawVector(vector, itemCount) {
|
|
2492
|
+
const data = vectorData(vector, itemCount * BigInt64Array.BYTES_PER_ELEMENT);
|
|
2493
|
+
const items = new BigInt64Array(data.buffer, data.byteOffset, itemCount);
|
|
2494
|
+
const validity = DuckDBValidity.fromVector(vector, itemCount);
|
|
2495
|
+
return new DuckDBTimeNSVector(items, validity, vector);
|
|
2496
|
+
}
|
|
2497
|
+
get type() {
|
|
2498
|
+
return DuckDBType_1.DuckDBTimeNSType.instance;
|
|
2499
|
+
}
|
|
2500
|
+
get itemCount() {
|
|
2501
|
+
return this.items.length;
|
|
2502
|
+
}
|
|
2503
|
+
getItem(itemIndex) {
|
|
2504
|
+
return this.validity.itemValid(itemIndex)
|
|
2505
|
+
? new values_1.DuckDBTimeNSValue(this.items[itemIndex])
|
|
2506
|
+
: null;
|
|
2507
|
+
}
|
|
2508
|
+
setItem(itemIndex, value) {
|
|
2509
|
+
if (value != null) {
|
|
2510
|
+
this.items[itemIndex] = value.nanos;
|
|
2511
|
+
this.validity.setItemValid(itemIndex, true);
|
|
2512
|
+
}
|
|
2513
|
+
else {
|
|
2514
|
+
this.validity.setItemValid(itemIndex, false);
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
flush() {
|
|
2518
|
+
node_bindings_1.default.copy_data_to_vector(this.vector, 0, this.items.buffer, this.items.byteOffset, this.items.byteLength);
|
|
2519
|
+
this.validity.flush(this.vector);
|
|
2520
|
+
}
|
|
2521
|
+
slice(offset, length) {
|
|
2522
|
+
return new DuckDBTimeNSVector(this.items.slice(offset, offset + length), this.validity.slice(offset, length), this.vector);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
exports.DuckDBTimeNSVector = DuckDBTimeNSVector;
|
|
@@ -42,5 +42,8 @@ const JSConvertersByTypeId = {
|
|
|
42
42
|
[DuckDBTypeId_1.DuckDBTypeId.ANY]: DuckDBValueConverters_1.unsupportedConverter,
|
|
43
43
|
[DuckDBTypeId_1.DuckDBTypeId.BIGNUM]: DuckDBValueConverters_1.bigintFromBigIntValue,
|
|
44
44
|
[DuckDBTypeId_1.DuckDBTypeId.SQLNULL]: DuckDBValueConverters_1.nullConverter,
|
|
45
|
+
[DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL]: DuckDBValueConverters_1.unsupportedConverter,
|
|
46
|
+
[DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL]: DuckDBValueConverters_1.unsupportedConverter,
|
|
47
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIME_NS]: DuckDBValueConverters_1.bigintFromTimeValue,
|
|
45
48
|
};
|
|
46
49
|
exports.JSDuckDBValueConverter = (0, createDuckDBValueConverter_1.createDuckDBValueConverter)(JSConvertersByTypeId);
|
|
@@ -42,5 +42,8 @@ const JsonConvertersByTypeId = {
|
|
|
42
42
|
[DuckDBTypeId_1.DuckDBTypeId.ANY]: DuckDBValueConverters_1.unsupportedConverter,
|
|
43
43
|
[DuckDBTypeId_1.DuckDBTypeId.BIGNUM]: DuckDBValueConverters_1.stringFromValue,
|
|
44
44
|
[DuckDBTypeId_1.DuckDBTypeId.SQLNULL]: DuckDBValueConverters_1.nullConverter,
|
|
45
|
+
[DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL]: DuckDBValueConverters_1.unsupportedConverter,
|
|
46
|
+
[DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL]: DuckDBValueConverters_1.unsupportedConverter,
|
|
47
|
+
[DuckDBTypeId_1.DuckDBTypeId.TIME_NS]: DuckDBValueConverters_1.stringFromValue,
|
|
45
48
|
};
|
|
46
49
|
exports.JsonDuckDBValueConverter = (0, createDuckDBValueConverter_1.createDuckDBValueConverter)(JsonConvertersByTypeId);
|
package/lib/createValue.js
CHANGED
|
@@ -207,6 +207,15 @@ function createValue(type, input) {
|
|
|
207
207
|
throw new Error(`input is not a bigint`);
|
|
208
208
|
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
209
209
|
return node_bindings_1.default.create_null_value();
|
|
210
|
+
case DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL:
|
|
211
|
+
throw new Error(`Cannot create values of type STRING_LITERAL.`);
|
|
212
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL:
|
|
213
|
+
throw new Error(`Cannot create values of type INTEGER_LITERAL.`);
|
|
214
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME_NS:
|
|
215
|
+
if (input instanceof values_1.DuckDBTimeNSValue) {
|
|
216
|
+
return node_bindings_1.default.create_time_ns(input);
|
|
217
|
+
}
|
|
218
|
+
throw new Error(`input is not a DuckDBTimeNSValue`);
|
|
210
219
|
default:
|
|
211
220
|
throw new Error(`unrecognized type id ${typeId}`);
|
|
212
221
|
}
|
package/lib/duckdb.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { double_to_hugeint, double_to_uhugeint, hugeint_to_double, uhugeint_to_d
|
|
|
2
2
|
export * from './configurationOptionDescriptions';
|
|
3
3
|
export * from './createDuckDBValueConverter';
|
|
4
4
|
export * from './DuckDBAppender';
|
|
5
|
+
export * from './DuckDBClientContext';
|
|
5
6
|
export * from './DuckDBConnection';
|
|
6
7
|
export * from './DuckDBDataChunk';
|
|
7
8
|
export * from './DuckDBExtractedStatements';
|
package/lib/duckdb.js
CHANGED
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "uhugeint_to_double", { enumerable: true, get: fu
|
|
|
23
23
|
__exportStar(require("./configurationOptionDescriptions"), exports);
|
|
24
24
|
__exportStar(require("./createDuckDBValueConverter"), exports);
|
|
25
25
|
__exportStar(require("./DuckDBAppender"), exports);
|
|
26
|
+
__exportStar(require("./DuckDBClientContext"), exports);
|
|
26
27
|
__exportStar(require("./DuckDBConnection"), exports);
|
|
27
28
|
__exportStar(require("./DuckDBDataChunk"), exports);
|
|
28
29
|
__exportStar(require("./DuckDBExtractedStatements"), exports);
|
package/lib/typeForValue.js
CHANGED
|
@@ -75,6 +75,9 @@ function typeForValue(value) {
|
|
|
75
75
|
else if (value instanceof values_1.DuckDBTimeValue) {
|
|
76
76
|
return DuckDBType_1.TIME;
|
|
77
77
|
}
|
|
78
|
+
else if (value instanceof values_1.DuckDBTimeNSValue) {
|
|
79
|
+
return DuckDBType_1.TIME_NS;
|
|
80
|
+
}
|
|
78
81
|
else if (value instanceof values_1.DuckDBUnionValue) {
|
|
79
82
|
return (0, DuckDBType_1.UNION)({ [value.tag]: typeForValue(value.value) });
|
|
80
83
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TimeNS } from '@duckdb/node-bindings';
|
|
2
|
+
export declare class DuckDBTimeNSValue implements TimeNS {
|
|
3
|
+
readonly nanos: bigint;
|
|
4
|
+
constructor(nanos: bigint);
|
|
5
|
+
toString(): string;
|
|
6
|
+
static readonly Max: DuckDBTimeNSValue;
|
|
7
|
+
static readonly Min: DuckDBTimeNSValue;
|
|
8
|
+
}
|
|
9
|
+
export declare function timeNSValue(nanos: bigint): DuckDBTimeNSValue;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DuckDBTimeNSValue = void 0;
|
|
4
|
+
exports.timeNSValue = timeNSValue;
|
|
5
|
+
const dateTimeStringConversion_1 = require("../conversion/dateTimeStringConversion");
|
|
6
|
+
class DuckDBTimeNSValue {
|
|
7
|
+
nanos;
|
|
8
|
+
constructor(nanos) {
|
|
9
|
+
this.nanos = nanos;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return (0, dateTimeStringConversion_1.getDuckDBTimeStringFromNanosecondsInDay)(this.nanos);
|
|
13
|
+
}
|
|
14
|
+
static Max = new DuckDBTimeNSValue(24n * 60n * 60n * 1000n * 1000n * 1000n);
|
|
15
|
+
static Min = new DuckDBTimeNSValue(0n);
|
|
16
|
+
}
|
|
17
|
+
exports.DuckDBTimeNSValue = DuckDBTimeNSValue;
|
|
18
|
+
function timeNSValue(nanos) {
|
|
19
|
+
return new DuckDBTimeNSValue(nanos);
|
|
20
|
+
}
|
|
@@ -7,6 +7,7 @@ import { DuckDBIntervalValue } from './DuckDBIntervalValue';
|
|
|
7
7
|
import { DuckDBListValue } from './DuckDBListValue';
|
|
8
8
|
import { DuckDBMapValue } from './DuckDBMapValue';
|
|
9
9
|
import { DuckDBStructValue } from './DuckDBStructValue';
|
|
10
|
+
import { DuckDBTimeNSValue } from './DuckDBTimeNSValue';
|
|
10
11
|
import { DuckDBTimestampMillisecondsValue } from './DuckDBTimestampMillisecondsValue';
|
|
11
12
|
import { DuckDBTimestampNanosecondsValue } from './DuckDBTimestampNanosecondsValue';
|
|
12
13
|
import { DuckDBTimestampSecondsValue } from './DuckDBTimestampSecondsValue';
|
|
@@ -16,4 +17,4 @@ import { DuckDBTimeTZValue } from './DuckDBTimeTZValue';
|
|
|
16
17
|
import { DuckDBTimeValue } from './DuckDBTimeValue';
|
|
17
18
|
import { DuckDBUnionValue } from './DuckDBUnionValue';
|
|
18
19
|
import { DuckDBUUIDValue } from './DuckDBUUIDValue';
|
|
19
|
-
export type DuckDBValue = null | boolean | number | bigint | string | DuckDBArrayValue | DuckDBBitValue | DuckDBBlobValue | DuckDBDateValue | DuckDBDecimalValue | DuckDBIntervalValue | DuckDBListValue | DuckDBMapValue | DuckDBStructValue | DuckDBTimestampMillisecondsValue | DuckDBTimestampNanosecondsValue | DuckDBTimestampSecondsValue | DuckDBTimestampTZValue | DuckDBTimestampValue | DuckDBTimeTZValue | DuckDBTimeValue | DuckDBUnionValue | DuckDBUUIDValue;
|
|
20
|
+
export type DuckDBValue = null | boolean | number | bigint | string | DuckDBArrayValue | DuckDBBitValue | DuckDBBlobValue | DuckDBDateValue | DuckDBDecimalValue | DuckDBIntervalValue | DuckDBListValue | DuckDBMapValue | DuckDBStructValue | DuckDBTimestampMillisecondsValue | DuckDBTimestampNanosecondsValue | DuckDBTimestampSecondsValue | DuckDBTimestampTZValue | DuckDBTimestampValue | DuckDBTimeTZValue | DuckDBTimeValue | DuckDBTimeNSValue | DuckDBUnionValue | DuckDBUUIDValue;
|
package/lib/values/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './DuckDBIntervalValue';
|
|
|
7
7
|
export * from './DuckDBListValue';
|
|
8
8
|
export * from './DuckDBMapValue';
|
|
9
9
|
export * from './DuckDBStructValue';
|
|
10
|
+
export * from './DuckDBTimeNSValue';
|
|
10
11
|
export * from './DuckDBTimestampMillisecondsValue';
|
|
11
12
|
export * from './DuckDBTimestampNanosecondsValue';
|
|
12
13
|
export * from './DuckDBTimestampSecondsValue';
|
package/lib/values/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __exportStar(require("./DuckDBIntervalValue"), exports);
|
|
|
23
23
|
__exportStar(require("./DuckDBListValue"), exports);
|
|
24
24
|
__exportStar(require("./DuckDBMapValue"), exports);
|
|
25
25
|
__exportStar(require("./DuckDBStructValue"), exports);
|
|
26
|
+
__exportStar(require("./DuckDBTimeNSValue"), exports);
|
|
26
27
|
__exportStar(require("./DuckDBTimestampMillisecondsValue"), exports);
|
|
27
28
|
__exportStar(require("./DuckDBTimestampNanosecondsValue"), exports);
|
|
28
29
|
__exportStar(require("./DuckDBTimestampSecondsValue"), exports);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckdb/node-api",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2-r.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@duckdb/node-bindings": "1.4.
|
|
8
|
+
"@duckdb/node-bindings": "1.4.2-r.1"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|