New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@duckdb/node-api

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@duckdb/node-api - npm Package Compare versions

Comparing version 1.1.2-alpha.2 to 1.1.2-alpha.3

lib/conversion/dateTimeStringConversion.d.ts

13

lib/DuckDBAppender.d.ts
import duckdb from '@duckdb/node-bindings';
import { DuckDBDataChunk } from './DuckDBDataChunk';
import { DuckDBType } from './DuckDBType';
import { Date_, Interval, Time, Timestamp } from './DuckDBValue';
import { DuckDBDataChunk } from './DuckDBDataChunk';
import { DuckDBDateValue, DuckDBIntervalValue, DuckDBTimestampValue, DuckDBTimeValue } from './values';
export declare class DuckDBAppender {
private readonly appender;
constructor(appender: duckdb.Appender);
dispose(): void;
close(): void;

@@ -28,6 +27,6 @@ flush(): void;

appendDouble(value: number): void;
appendDate(value: Date_): void;
appendTime(value: Time): void;
appendTimestamp(value: Timestamp): void;
appendInterval(value: Interval): void;
appendDate(value: DuckDBDateValue): void;
appendTime(value: DuckDBTimeValue): void;
appendTimestamp(value: DuckDBTimestampValue): void;
appendInterval(value: DuckDBIntervalValue): void;
appendVarchar(value: string): void;

@@ -34,0 +33,0 @@ appendBlob(value: Uint8Array): void;

@@ -14,5 +14,2 @@ "use strict";

}
dispose() {
node_bindings_1.default.appender_destroy(this.appender);
}
close() {

@@ -28,3 +25,3 @@ node_bindings_1.default.appender_close(this.appender);

columnType(columnIndex) {
return DuckDBLogicalType_1.DuckDBLogicalType.consumeAsType(node_bindings_1.default.appender_column_type(this.appender, columnIndex));
return DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.appender_column_type(this.appender, columnIndex)).asType();
}

@@ -31,0 +28,0 @@ endRow() {

@@ -11,3 +11,2 @@ import duckdb from '@duckdb/node-bindings';

static create(instance: DuckDBInstance): Promise<DuckDBConnection>;
dispose(): Promise<void>;
interrupt(): void;

@@ -14,0 +13,0 @@ get progress(): duckdb.QueryProgress;

@@ -20,5 +20,2 @@ "use strict";

}
dispose() {
return node_bindings_1.default.disconnect(this.connection);
}
interrupt() {

@@ -39,8 +36,3 @@ node_bindings_1.default.interrupt(this.connection);

if (statement_count === 0) {
try {
throw new Error(`Failed to extract statements: ${node_bindings_1.default.extract_statements_error(extracted_statements)}`);
}
finally {
node_bindings_1.default.destroy_extracted(extracted_statements);
}
throw new Error(`Failed to extract statements: ${node_bindings_1.default.extract_statements_error(extracted_statements)}`);
}

@@ -47,0 +39,0 @@ return new DuckDBExtractedStatements_1.DuckDBExtractedStatements(this.connection, extracted_statements, statement_count);

import duckdb from '@duckdb/node-bindings';
import { DuckDBVector } from './DuckDBVector';
import { DuckDBValue } from './values';
export declare class DuckDBDataChunk {

@@ -7,8 +8,10 @@ readonly chunk: duckdb.DataChunk;

static create(logical_types: duckdb.LogicalType[]): DuckDBDataChunk;
dispose(): void;
reset(): void;
get columnCount(): number;
getColumn(columnIndex: number): DuckDBVector<any>;
getColumnVector(columnIndex: number): DuckDBVector;
getColumnValues(columnIndex: number): DuckDBValue[];
getColumns(): DuckDBValue[][];
getRows(): DuckDBValue[][];
get rowCount(): number;
set rowCount(count: number);
}

@@ -17,5 +17,2 @@ "use strict";

}
dispose() {
node_bindings_1.default.destroy_data_chunk(this.chunk);
}
reset() {

@@ -27,6 +24,34 @@ node_bindings_1.default.data_chunk_reset(this.chunk);

}
getColumn(columnIndex) {
getColumnVector(columnIndex) {
// TODO: cache vectors?
return DuckDBVector_1.DuckDBVector.create(node_bindings_1.default.data_chunk_get_vector(this.chunk, columnIndex), this.rowCount);
}
getColumnValues(columnIndex) {
return this.getColumnVector(columnIndex).toArray();
}
getColumns() {
const columns = [];
const columnCount = this.columnCount;
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
columns.push(this.getColumnValues(columnIndex));
}
return columns;
}
getRows() {
const rows = [];
const vectors = [];
const columnCount = this.columnCount;
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
vectors.push(this.getColumnVector(columnIndex));
}
const rowCount = this.rowCount;
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
const row = [];
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
row.push(vectors[columnIndex].getItem(rowIndex));
}
rows.push(row);
}
return rows;
}
get rowCount() {

@@ -33,0 +58,0 @@ return node_bindings_1.default.data_chunk_get_size(this.chunk);

@@ -8,5 +8,4 @@ import duckdb from '@duckdb/node-bindings';

constructor(connection: duckdb.Connection, extracted_statements: duckdb.ExtractedStatements, statement_count: number);
dispose(): void;
get count(): number;
prepare(index: number): Promise<DuckDBPreparedStatement>;
}

@@ -18,5 +18,2 @@ "use strict";

}
dispose() {
node_bindings_1.default.destroy_extracted(this.extracted_statements);
}
get count() {

@@ -23,0 +20,0 @@ return this.statement_count;

@@ -7,4 +7,3 @@ import duckdb from '@duckdb/node-bindings';

static create(path?: string, options?: Record<string, string>): Promise<DuckDBInstance>;
dispose(): Promise<void>;
connect(): Promise<DuckDBConnection>;
}

@@ -17,12 +17,7 @@ "use strict";

const config = node_bindings_1.default.create_config();
try {
for (const optionName in options) {
const optionValue = String(options[optionName]);
node_bindings_1.default.set_config(config, optionName, optionValue);
}
return new DuckDBInstance(await node_bindings_1.default.open(path, config));
for (const optionName in options) {
const optionValue = String(options[optionName]);
node_bindings_1.default.set_config(config, optionName, optionValue);
}
finally {
node_bindings_1.default.destroy_config(config);
}
return new DuckDBInstance(await node_bindings_1.default.open(path, config));
}

@@ -33,5 +28,2 @@ else {

}
dispose() {
return node_bindings_1.default.close(this.db);
}
async connect() {

@@ -38,0 +30,0 @@ return new DuckDBConnection_1.DuckDBConnection(await node_bindings_1.default.connect(this.db));

import duckdb from '@duckdb/node-bindings';
import { DuckDBDecimalType, DuckDBEnumType, DuckDBListType, DuckDBMapType, DuckDBStructType, DuckDBType, DuckDBUnionType } from './DuckDBType';
import { DuckDBArrayType, DuckDBDecimalType, DuckDBEnumType, DuckDBListType, DuckDBMapType, DuckDBStructType, DuckDBType, DuckDBUnionType } from './DuckDBType';
import { DuckDBTypeId } from './DuckDBTypeId';

@@ -7,3 +7,2 @@ export declare class DuckDBLogicalType {

protected constructor(logical_type: duckdb.LogicalType);
static consumeAsType(logical_type: duckdb.LogicalType): DuckDBType;
static create(logical_type: duckdb.LogicalType): DuckDBLogicalType;

@@ -13,9 +12,8 @@ static createDecimal(width: number, scale: number): DuckDBDecimalLogicalType;

static createList(valueType: DuckDBLogicalType): DuckDBListLogicalType;
static createStruct(entries: readonly DuckDBLogicalStructEntry[]): DuckDBStructLogicalType;
static createStruct(entryNames: readonly string[], entryLogicalTypes: readonly DuckDBLogicalType[]): DuckDBStructLogicalType;
static createMap(keyType: DuckDBLogicalType, valueType: DuckDBLogicalType): DuckDBMapLogicalType;
static createArray(valueType: DuckDBLogicalType, length: number): DuckDBArrayLogicalType;
static createUnion(alternatives: readonly DuckDBLogicalUnionAlternative[]): DuckDBUnionLogicalType;
dispose(): void;
static createUnion(memberTags: readonly string[], memberLogicalTypes: readonly DuckDBLogicalType[]): DuckDBUnionLogicalType;
get typeId(): DuckDBTypeId;
get alias(): string | null;
get alias(): string | undefined;
set alias(newAlias: string);

@@ -41,11 +39,10 @@ asType(): DuckDBType;

}
export interface DuckDBLogicalStructEntry {
readonly name: string;
readonly valueType: DuckDBLogicalType;
}
export declare class DuckDBStructLogicalType extends DuckDBLogicalType {
get entryCount(): number;
entryName(index: number): string;
entryValueType(index: number): DuckDBLogicalType;
entries(): readonly DuckDBLogicalStructEntry[];
entryLogicalType(index: number): DuckDBLogicalType;
entryType(index: number): DuckDBType;
entryNames(): string[];
entryLogicalTypes(): DuckDBLogicalType[];
entryTypes(): DuckDBType[];
asType(): DuckDBStructType;

@@ -61,14 +58,13 @@ }

get length(): number;
asType(): DuckDBListType;
asType(): DuckDBArrayType;
}
export interface DuckDBLogicalUnionAlternative {
readonly tag: string;
readonly valueType: DuckDBLogicalType;
}
export declare class DuckDBUnionLogicalType extends DuckDBLogicalType {
get alternativeCount(): number;
alternativeTag(index: number): string;
alternativeValueType(index: number): DuckDBLogicalType;
alternatives(): readonly DuckDBLogicalUnionAlternative[];
get memberCount(): number;
memberTag(index: number): string;
memberLogicalType(index: number): DuckDBLogicalType;
memberType(index: number): DuckDBType;
memberTags(): string[];
memberLogicalTypes(): DuckDBLogicalType[];
memberTypes(): DuckDBType[];
asType(): DuckDBUnionType;
}

@@ -15,8 +15,2 @@ "use strict";

}
static consumeAsType(logical_type) {
const logicalType = DuckDBLogicalType.create(logical_type);
const type = logicalType.asType();
logicalType.dispose();
return type;
}
static create(logical_type) {

@@ -51,8 +45,13 @@ switch (node_bindings_1.default.get_type_id(logical_type)) {

}
static createStruct(entries) {
static createStruct(entryNames, entryLogicalTypes) {
const length = entryNames.length;
if (length !== entryLogicalTypes.length) {
throw new Error(`Could not create struct: \
entryNames length (${entryNames.length}) does not match entryLogicalTypes length (${entryLogicalTypes.length})`);
}
const member_types = [];
const member_names = [];
for (const entry of entries) {
member_types.push(entry.valueType.logical_type);
member_names.push(entry.name);
for (let i = 0; i < length; i++) {
member_types.push(entryLogicalTypes[i].logical_type);
member_names.push(entryNames[i]);
}

@@ -67,14 +66,16 @@ return new DuckDBStructLogicalType(node_bindings_1.default.create_struct_type(member_types, member_names));

}
static createUnion(alternatives) {
static createUnion(memberTags, memberLogicalTypes) {
const length = memberTags.length;
if (length !== memberLogicalTypes.length) {
throw new Error(`Could not create union: \
memberTags length (${memberTags.length}) does not match memberLogicalTypes length (${memberLogicalTypes.length})`);
}
const member_types = [];
const member_names = [];
for (const alternative of alternatives) {
member_types.push(alternative.valueType.logical_type);
member_names.push(alternative.tag);
for (let i = 0; i < length; i++) {
member_types.push(memberLogicalTypes[i].logical_type);
member_names.push(memberTags[i]);
}
return new DuckDBUnionLogicalType(node_bindings_1.default.create_union_type(member_types, member_names));
}
dispose() {
node_bindings_1.default.destroy_logical_type(this.logical_type);
}
get typeId() {

@@ -84,3 +85,3 @@ return node_bindings_1.default.get_type_id(this.logical_type);

get alias() {
return node_bindings_1.default.logical_type_get_alias(this.logical_type);
return node_bindings_1.default.logical_type_get_alias(this.logical_type) || undefined;
}

@@ -91,49 +92,50 @@ set alias(newAlias) {

asType() {
const alias = this.alias;
switch (this.typeId) {
case DuckDBTypeId_1.DuckDBTypeId.BOOLEAN:
return DuckDBType_1.DuckDBBooleanType.instance;
return DuckDBType_1.DuckDBBooleanType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TINYINT:
return DuckDBType_1.DuckDBTinyIntType.instance;
return DuckDBType_1.DuckDBTinyIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.SMALLINT:
return DuckDBType_1.DuckDBSmallIntType.instance;
return DuckDBType_1.DuckDBSmallIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.INTEGER:
return DuckDBType_1.DuckDBIntegerType.instance;
return DuckDBType_1.DuckDBIntegerType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.BIGINT:
return DuckDBType_1.DuckDBBigIntType.instance;
return DuckDBType_1.DuckDBBigIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.UTINYINT:
return DuckDBType_1.DuckDBUTinyIntType.instance;
return DuckDBType_1.DuckDBUTinyIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.USMALLINT:
return DuckDBType_1.DuckDBUSmallIntType.instance;
return DuckDBType_1.DuckDBUSmallIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.UINTEGER:
return DuckDBType_1.DuckDBUIntegerType.instance;
return DuckDBType_1.DuckDBUIntegerType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.UBIGINT:
return DuckDBType_1.DuckDBUBigIntType.instance;
return DuckDBType_1.DuckDBUBigIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.FLOAT:
return DuckDBType_1.DuckDBFloatType.instance;
return DuckDBType_1.DuckDBFloatType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.DOUBLE:
return DuckDBType_1.DuckDBDoubleType.instance;
return DuckDBType_1.DuckDBDoubleType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP:
return DuckDBType_1.DuckDBTimestampType.instance;
return DuckDBType_1.DuckDBTimestampType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.DATE:
return DuckDBType_1.DuckDBDateType.instance;
return DuckDBType_1.DuckDBDateType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TIME:
return DuckDBType_1.DuckDBTimeType.instance;
return DuckDBType_1.DuckDBTimeType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.INTERVAL:
return DuckDBType_1.DuckDBIntervalType.instance;
return DuckDBType_1.DuckDBIntervalType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.HUGEINT:
return DuckDBType_1.DuckDBHugeIntType.instance;
return DuckDBType_1.DuckDBHugeIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.UHUGEINT:
return DuckDBType_1.DuckDBUHugeIntType.instance;
return DuckDBType_1.DuckDBUHugeIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.VARCHAR:
return DuckDBType_1.DuckDBVarCharType.instance;
return DuckDBType_1.DuckDBVarCharType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.BLOB:
return DuckDBType_1.DuckDBBlobType.instance;
return DuckDBType_1.DuckDBBlobType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.DECIMAL:
throw new Error('Expected override');
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S:
return DuckDBType_1.DuckDBTimestampSecondsType.instance;
return DuckDBType_1.DuckDBTimestampSecondsType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS:
return DuckDBType_1.DuckDBTimestampMillisecondsType.instance;
return DuckDBType_1.DuckDBTimestampMillisecondsType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS:
return DuckDBType_1.DuckDBTimestampNanosecondsType.instance;
return DuckDBType_1.DuckDBTimestampNanosecondsType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.ENUM:

@@ -150,17 +152,17 @@ throw new Error('Expected override');

case DuckDBTypeId_1.DuckDBTypeId.UUID:
return DuckDBType_1.DuckDBUUIDType.instance;
return DuckDBType_1.DuckDBUUIDType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.UNION:
throw new Error('Expected override');
case DuckDBTypeId_1.DuckDBTypeId.BIT:
return DuckDBType_1.DuckDBBitType.instance;
return DuckDBType_1.DuckDBBitType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TIME_TZ:
return DuckDBType_1.DuckDBTimeTZType.instance;
return DuckDBType_1.DuckDBTimeTZType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ:
return DuckDBType_1.DuckDBTimestampTZType.instance;
return DuckDBType_1.DuckDBTimestampTZType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.ANY:
return DuckDBType_1.DuckDBAnyType.instance;
return DuckDBType_1.DuckDBAnyType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.VARINT:
return DuckDBType_1.DuckDBVarIntType.instance;
return DuckDBType_1.DuckDBVarIntType.create(alias);
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
return DuckDBType_1.DuckDBSQLNullType.instance;
return DuckDBType_1.DuckDBSQLNullType.create(alias);
default:

@@ -183,3 +185,3 @@ throw new Error(`Unexpected type id: ${this.typeId}`);

asType() {
return new DuckDBType_1.DuckDBDecimalType(this.width, this.scale);
return new DuckDBType_1.DuckDBDecimalType(this.width, this.scale, this.alias);
}

@@ -207,3 +209,3 @@ }

asType() {
return new DuckDBType_1.DuckDBEnumType(this.values(), this.internalTypeId);
return new DuckDBType_1.DuckDBEnumType(this.values(), this.internalTypeId, this.alias);
}

@@ -217,3 +219,3 @@ }

asType() {
return new DuckDBType_1.DuckDBListType(this.valueType.asType());
return new DuckDBType_1.DuckDBListType(this.valueType.asType(), this.alias);
}

@@ -229,20 +231,34 @@ }

}
entryValueType(index) {
entryLogicalType(index) {
return DuckDBLogicalType.create(node_bindings_1.default.struct_type_child_type(this.logical_type, index));
}
entries() {
const entries = [];
entryType(index) {
return this.entryLogicalType(index).asType();
}
entryNames() {
const names = [];
const count = this.entryCount;
for (let i = 0; i < count; i++) {
const name = this.entryName(i);
const valueType = this.entryValueType(i);
entries.push({ name, valueType });
names.push(this.entryName(i));
}
return entries;
return names;
}
entryLogicalTypes() {
const valueTypes = [];
const count = this.entryCount;
for (let i = 0; i < count; i++) {
valueTypes.push(this.entryLogicalType(i));
}
return valueTypes;
}
entryTypes() {
const valueTypes = [];
const count = this.entryCount;
for (let i = 0; i < count; i++) {
valueTypes.push(this.entryType(i));
}
return valueTypes;
}
asType() {
return new DuckDBType_1.DuckDBStructType(this.entries().map(({ name, valueType }) => ({
name,
valueType: valueType.asType(),
})));
return new DuckDBType_1.DuckDBStructType(this.entryNames(), this.entryTypes(), this.alias);
}

@@ -259,3 +275,3 @@ }

asType() {
return new DuckDBType_1.DuckDBMapType(this.keyType.asType(), this.valueType.asType());
return new DuckDBType_1.DuckDBMapType(this.keyType.asType(), this.valueType.asType(), this.alias);
}

@@ -272,3 +288,3 @@ }

asType() {
return new DuckDBType_1.DuckDBArrayType(this.valueType.asType(), this.length);
return new DuckDBType_1.DuckDBArrayType(this.valueType.asType(), this.length, this.alias);
}

@@ -278,28 +294,42 @@ }

class DuckDBUnionLogicalType extends DuckDBLogicalType {
get alternativeCount() {
get memberCount() {
return node_bindings_1.default.union_type_member_count(this.logical_type);
}
alternativeTag(index) {
memberTag(index) {
return node_bindings_1.default.union_type_member_name(this.logical_type, index);
}
alternativeValueType(index) {
memberLogicalType(index) {
return DuckDBLogicalType.create(node_bindings_1.default.union_type_member_type(this.logical_type, index));
}
alternatives() {
const alternatives = [];
const count = this.alternativeCount;
memberType(index) {
return this.memberLogicalType(index).asType();
}
memberTags() {
const tags = [];
const count = this.memberCount;
for (let i = 0; i < count; i++) {
const tag = this.alternativeTag(i);
const valueType = this.alternativeValueType(i);
alternatives.push({ tag, valueType });
tags.push(this.memberTag(i));
}
return alternatives;
return tags;
}
memberLogicalTypes() {
const valueTypes = [];
const count = this.memberCount;
for (let i = 0; i < count; i++) {
valueTypes.push(this.memberLogicalType(i));
}
return valueTypes;
}
memberTypes() {
const valueTypes = [];
const count = this.memberCount;
for (let i = 0; i < count; i++) {
valueTypes.push(this.memberType(i));
}
return valueTypes;
}
asType() {
return new DuckDBType_1.DuckDBUnionType(this.alternatives().map(({ tag, valueType }) => ({
tag,
valueType: valueType.asType(),
})));
return new DuckDBType_1.DuckDBUnionType(this.memberTags(), this.memberTypes(), this.alias);
}
}
exports.DuckDBUnionLogicalType = DuckDBUnionLogicalType;

@@ -11,5 +11,4 @@ import duckdb from '@duckdb/node-bindings';

constructor(pending_result: duckdb.PendingResult);
dispose(): void;
runTask(): DuckDBPendingResultState;
getResult(): Promise<DuckDBResult>;
}

@@ -21,5 +21,2 @@ "use strict";

}
dispose() {
node_bindings_1.default.destroy_pending(this.pending_result);
}
runTask() {

@@ -26,0 +23,0 @@ const pending_state = node_bindings_1.default.pending_execute_task(this.pending_result);

@@ -5,8 +5,7 @@ import duckdb from '@duckdb/node-bindings';

import { DuckDBTypeId } from './DuckDBTypeId';
import { Date_, Decimal, Interval, Time, Timestamp } from './DuckDBValue';
import { StatementType } from './enums';
import { DuckDBDateValue, DuckDBDecimalValue, DuckDBIntervalValue, DuckDBTimestampValue, DuckDBTimeValue } from './values';
export declare class DuckDBPreparedStatement {
private readonly prepared_statement;
constructor(prepared_statement: duckdb.PreparedStatement);
dispose(): void;
get statementType(): StatementType;

@@ -29,9 +28,9 @@ get parameterCount(): number;

bindUHugeInt(parameterIndex: number, value: bigint): void;
bindDecimal(parameterIndex: number, value: Decimal): void;
bindDecimal(parameterIndex: number, value: DuckDBDecimalValue): void;
bindFloat(parameterIndex: number, value: number): void;
bindDouble(parameterIndex: number, value: number): void;
bindDate(parameterIndex: number, value: Date_): void;
bindTime(parameterIndex: number, value: Time): void;
bindTimestamp(parameterIndex: number, value: Timestamp): void;
bindInterval(parameterIndex: number, value: Interval): void;
bindDate(parameterIndex: number, value: DuckDBDateValue): void;
bindTime(parameterIndex: number, value: DuckDBTimeValue): void;
bindTimestamp(parameterIndex: number, value: DuckDBTimestampValue): void;
bindInterval(parameterIndex: number, value: DuckDBIntervalValue): void;
bindVarchar(parameterIndex: number, value: string): void;

@@ -38,0 +37,0 @@ bindBlob(parameterIndex: number, value: Uint8Array): void;

@@ -15,5 +15,2 @@ "use strict";

}
dispose() {
node_bindings_1.default.destroy_prepare(this.prepared_statement);
}
get statementType() {

@@ -20,0 +17,0 @@ return node_bindings_1.default.prepared_statement_type(this.prepared_statement);

@@ -10,3 +10,2 @@ import duckdb from '@duckdb/node-bindings';

constructor(result: duckdb.Result);
dispose(): void;
get returnType(): ResultReturnType;

@@ -16,7 +15,10 @@ get statementType(): StatementType;

columnName(columnIndex: number): string;
columnNames(): string[];
columnTypeId(columnIndex: number): DuckDBTypeId;
columnLogicalType(columnIndex: number): DuckDBLogicalType;
columnType(columnIndex: number): DuckDBType;
columnTypes(): DuckDBType[];
get rowsChanged(): number;
fetchChunk(): Promise<DuckDBDataChunk>;
fetchAllChunks(): Promise<DuckDBDataChunk[]>;
}

@@ -15,5 +15,2 @@ "use strict";

}
dispose() {
node_bindings_1.default.destroy_result(this.result);
}
get returnType() {

@@ -31,2 +28,10 @@ return node_bindings_1.default.result_return_type(this.result);

}
columnNames() {
const columnNames = [];
const columnCount = this.columnCount;
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
columnNames.push(this.columnName(columnIndex));
}
return columnNames;
}
columnTypeId(columnIndex) {

@@ -39,4 +44,12 @@ return node_bindings_1.default.column_type(this.result, columnIndex);

columnType(columnIndex) {
return DuckDBLogicalType_1.DuckDBLogicalType.consumeAsType(node_bindings_1.default.column_logical_type(this.result, columnIndex));
return DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.column_logical_type(this.result, columnIndex)).asType();
}
columnTypes() {
const columnTypes = [];
const columnCount = this.columnCount;
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
columnTypes.push(this.columnType(columnIndex));
}
return columnTypes;
}
get rowsChanged() {

@@ -48,3 +61,13 @@ return node_bindings_1.default.rows_changed(this.result);

}
async fetchAllChunks() {
const chunks = [];
while (true) {
const chunk = await this.fetchChunk();
if (chunk.rowCount === 0) {
return chunks;
}
chunks.push(chunk);
}
}
}
exports.DuckDBResult = DuckDBResult;
import { DuckDBTypeId } from './DuckDBTypeId';
export declare abstract class BaseDuckDBType {
readonly typeId: DuckDBTypeId;
protected constructor(typeId: DuckDBTypeId);
export declare abstract class BaseDuckDBType<T extends DuckDBTypeId> {
readonly typeId: T;
readonly alias?: string;
protected constructor(typeId: T, alias?: string);
toString(): string;
}
export declare class DuckDBBooleanType extends BaseDuckDBType {
private constructor();
export declare class DuckDBBooleanType extends BaseDuckDBType<DuckDBTypeId.BOOLEAN> {
constructor(alias?: string);
static readonly instance: DuckDBBooleanType;
static create(alias?: string): DuckDBBooleanType;
}
export declare class DuckDBTinyIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTinyIntType extends BaseDuckDBType<DuckDBTypeId.TINYINT> {
constructor(alias?: string);
static readonly instance: DuckDBTinyIntType;
static create(alias?: string): DuckDBTinyIntType;
static readonly Max: number;
static readonly Min: number;
}
export declare class DuckDBSmallIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBSmallIntType extends BaseDuckDBType<DuckDBTypeId.SMALLINT> {
constructor(alias?: string);
static readonly instance: DuckDBSmallIntType;
static create(alias?: string): DuckDBSmallIntType;
static readonly Max: number;
static readonly Min: number;
}
export declare class DuckDBIntegerType extends BaseDuckDBType {
private constructor();
export declare class DuckDBIntegerType extends BaseDuckDBType<DuckDBTypeId.INTEGER> {
constructor(alias?: string);
static readonly instance: DuckDBIntegerType;
static create(alias?: string): DuckDBIntegerType;
static readonly Max: number;
static readonly Min: number;
}
export declare class DuckDBBigIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBBigIntType extends BaseDuckDBType<DuckDBTypeId.BIGINT> {
constructor(alias?: string);
static readonly instance: DuckDBBigIntType;
static create(alias?: string): DuckDBBigIntType;
static readonly Max: bigint;
static readonly Min: bigint;
}
export declare class DuckDBUTinyIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBUTinyIntType extends BaseDuckDBType<DuckDBTypeId.UTINYINT> {
constructor(alias?: string);
static readonly instance: DuckDBUTinyIntType;
static create(alias?: string): DuckDBUTinyIntType;
static readonly Max: number;
static readonly Min = 0;
}
export declare class DuckDBUSmallIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBUSmallIntType extends BaseDuckDBType<DuckDBTypeId.USMALLINT> {
constructor(alias?: string);
static readonly instance: DuckDBUSmallIntType;
static create(alias?: string): DuckDBUSmallIntType;
static readonly Max: number;
static readonly Min = 0;
}
export declare class DuckDBUIntegerType extends BaseDuckDBType {
private constructor();
export declare class DuckDBUIntegerType extends BaseDuckDBType<DuckDBTypeId.UINTEGER> {
constructor(alias?: string);
static readonly instance: DuckDBUIntegerType;
static create(alias?: string): DuckDBUIntegerType;
static readonly Max: number;
static readonly Min = 0;
}
export declare class DuckDBUBigIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBUBigIntType extends BaseDuckDBType<DuckDBTypeId.UBIGINT> {
constructor(alias?: string);
static readonly instance: DuckDBUBigIntType;
static create(alias?: string): DuckDBUBigIntType;
static readonly Max: bigint;
static readonly Min = 0n;
}
export declare class DuckDBFloatType extends BaseDuckDBType {
private constructor();
export declare class DuckDBFloatType extends BaseDuckDBType<DuckDBTypeId.FLOAT> {
constructor(alias?: string);
static readonly instance: DuckDBFloatType;
static create(alias?: string): DuckDBFloatType;
static readonly Min: number;
static readonly Max: number;
}
export declare class DuckDBDoubleType extends BaseDuckDBType {
private constructor();
export declare class DuckDBDoubleType extends BaseDuckDBType<DuckDBTypeId.DOUBLE> {
constructor(alias?: string);
static readonly instance: DuckDBDoubleType;
static create(alias?: string): DuckDBDoubleType;
static readonly Min: number;
static readonly Max: number;
}
export declare class DuckDBTimestampType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimestampType extends BaseDuckDBType<DuckDBTypeId.TIMESTAMP> {
constructor(alias?: string);
static readonly instance: DuckDBTimestampType;
static create(alias?: string): DuckDBTimestampType;
}
export type DuckDBTimestampMicrosecondsType = DuckDBTimestampType;
export declare class DuckDBDateType extends BaseDuckDBType {
private constructor();
export declare const DuckDBTimestampMicrosecondsType: typeof DuckDBTimestampType;
export declare class DuckDBDateType extends BaseDuckDBType<DuckDBTypeId.DATE> {
constructor(alias?: string);
static readonly instance: DuckDBDateType;
static create(alias?: string): DuckDBDateType;
}
export declare class DuckDBTimeType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimeType extends BaseDuckDBType<DuckDBTypeId.TIME> {
constructor(alias?: string);
static readonly instance: DuckDBTimeType;
static create(alias?: string): DuckDBTimeType;
}
export declare class DuckDBIntervalType extends BaseDuckDBType {
private constructor();
export declare class DuckDBIntervalType extends BaseDuckDBType<DuckDBTypeId.INTERVAL> {
constructor(alias?: string);
static readonly instance: DuckDBIntervalType;
static create(alias?: string): DuckDBIntervalType;
}
export declare class DuckDBHugeIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBHugeIntType extends BaseDuckDBType<DuckDBTypeId.HUGEINT> {
constructor(alias?: string);
static readonly instance: DuckDBHugeIntType;
static create(alias?: string): DuckDBHugeIntType;
static readonly Max: bigint;
static readonly Min: bigint;
}
export declare class DuckDBUHugeIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBUHugeIntType extends BaseDuckDBType<DuckDBTypeId.UHUGEINT> {
constructor(alias?: string);
static readonly instance: DuckDBUHugeIntType;
static create(alias?: string): DuckDBUHugeIntType;
static readonly Max: bigint;
static readonly Min = 0n;
}
export declare class DuckDBVarCharType extends BaseDuckDBType {
private constructor();
export declare class DuckDBVarCharType extends BaseDuckDBType<DuckDBTypeId.VARCHAR> {
constructor(alias?: string);
static readonly instance: DuckDBVarCharType;
static create(alias?: string): DuckDBVarCharType;
}
export declare class DuckDBBlobType extends BaseDuckDBType {
private constructor();
export declare class DuckDBBlobType extends BaseDuckDBType<DuckDBTypeId.BLOB> {
constructor(alias?: string);
static readonly instance: DuckDBBlobType;
static create(alias?: string): DuckDBBlobType;
}
export declare class DuckDBDecimalType extends BaseDuckDBType {
export declare class DuckDBDecimalType extends BaseDuckDBType<DuckDBTypeId.DECIMAL> {
readonly width: number;
readonly scale: number;
constructor(width: number, scale: number);
constructor(width: number, scale: number, alias?: string);
toString(): string;
static readonly default: DuckDBDecimalType;
}
export declare class DuckDBTimestampSecondsType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimestampSecondsType extends BaseDuckDBType<DuckDBTypeId.TIMESTAMP_S> {
constructor(alias?: string);
static readonly instance: DuckDBTimestampSecondsType;
static create(alias?: string): DuckDBTimestampSecondsType;
}
export declare class DuckDBTimestampMillisecondsType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimestampMillisecondsType extends BaseDuckDBType<DuckDBTypeId.TIMESTAMP_MS> {
constructor(alias?: string);
static readonly instance: DuckDBTimestampMillisecondsType;
static create(alias?: string): DuckDBTimestampMillisecondsType;
}
export declare class DuckDBTimestampNanosecondsType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimestampNanosecondsType extends BaseDuckDBType<DuckDBTypeId.TIMESTAMP_NS> {
constructor(alias?: string);
static readonly instance: DuckDBTimestampNanosecondsType;
static create(alias?: string): DuckDBTimestampNanosecondsType;
}
export declare class DuckDBEnumType extends BaseDuckDBType {
export declare class DuckDBEnumType extends BaseDuckDBType<DuckDBTypeId.ENUM> {
readonly values: readonly string[];
readonly internalTypeId: DuckDBTypeId;
constructor(values: readonly string[], internalTypeId: DuckDBTypeId);
constructor(values: readonly string[], internalTypeId: DuckDBTypeId, alias?: string);
toString(): string;
}
export declare class DuckDBListType extends BaseDuckDBType {
export declare class DuckDBListType extends BaseDuckDBType<DuckDBTypeId.LIST> {
readonly valueType: DuckDBType;
constructor(valueType: DuckDBType);
constructor(valueType: DuckDBType, alias?: string);
toString(): string;
}
export interface DuckDBStructEntryType {
readonly name: string;
readonly valueType: DuckDBType;
export declare class DuckDBStructType extends BaseDuckDBType<DuckDBTypeId.STRUCT> {
readonly entryNames: readonly string[];
readonly entryTypes: readonly DuckDBType[];
constructor(entryNames: readonly string[], entryTypes: readonly DuckDBType[], alias?: string);
get entryCount(): number;
toString(): string;
}
export declare class DuckDBStructType extends BaseDuckDBType {
readonly entries: readonly DuckDBStructEntryType[];
constructor(entries: readonly DuckDBStructEntryType[]);
}
export declare class DuckDBMapType extends BaseDuckDBType {
export declare class DuckDBMapType extends BaseDuckDBType<DuckDBTypeId.MAP> {
readonly keyType: DuckDBType;
readonly valueType: DuckDBType;
constructor(keyType: DuckDBType, valueType: DuckDBType);
constructor(keyType: DuckDBType, valueType: DuckDBType, alias?: string);
toString(): string;
}
export declare class DuckDBArrayType extends BaseDuckDBType {
export declare class DuckDBArrayType extends BaseDuckDBType<DuckDBTypeId.ARRAY> {
readonly valueType: DuckDBType;
readonly length: number;
constructor(valueType: DuckDBType, length: number);
constructor(valueType: DuckDBType, length: number, alias?: string);
toString(): string;
}
export declare class DuckDBUUIDType extends BaseDuckDBType {
private constructor();
export declare class DuckDBUUIDType extends BaseDuckDBType<DuckDBTypeId.UUID> {
constructor(alias?: string);
static readonly instance: DuckDBUUIDType;
static create(alias?: string): DuckDBUUIDType;
}
export interface DuckDBUnionAlternativeType {
readonly tag: string;
readonly valueType: DuckDBType;
export declare class DuckDBUnionType extends BaseDuckDBType<DuckDBTypeId.UNION> {
readonly memberTags: readonly string[];
readonly memberTypes: readonly DuckDBType[];
constructor(memberTags: readonly string[], memberTypes: readonly DuckDBType[], alias?: string);
get memberCount(): number;
toString(): string;
}
export declare class DuckDBUnionType extends BaseDuckDBType {
readonly alternatives: readonly DuckDBUnionAlternativeType[];
constructor(alternatives: readonly DuckDBUnionAlternativeType[]);
}
export declare class DuckDBBitType extends BaseDuckDBType {
private constructor();
export declare class DuckDBBitType extends BaseDuckDBType<DuckDBTypeId.BIT> {
constructor(alias?: string);
static readonly instance: DuckDBBitType;
static create(alias?: string): DuckDBBitType;
}
export declare class DuckDBTimeTZType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimeTZType extends BaseDuckDBType<DuckDBTypeId.TIME_TZ> {
constructor(alias?: string);
toString(): string;
static readonly instance: DuckDBTimeTZType;
static create(alias?: string): DuckDBTimeTZType;
}
export declare class DuckDBTimestampTZType extends BaseDuckDBType {
private constructor();
export declare class DuckDBTimestampTZType extends BaseDuckDBType<DuckDBTypeId.TIMESTAMP_TZ> {
constructor(alias?: string);
toString(): string;
static readonly instance: DuckDBTimestampTZType;
static create(alias?: string): DuckDBTimestampTZType;
}
export declare class DuckDBAnyType extends BaseDuckDBType {
private constructor();
export declare class DuckDBAnyType extends BaseDuckDBType<DuckDBTypeId.ANY> {
constructor(alias?: string);
static readonly instance: DuckDBAnyType;
static create(alias?: string): DuckDBAnyType;
}
export declare class DuckDBVarIntType extends BaseDuckDBType {
private constructor();
export declare class DuckDBVarIntType extends BaseDuckDBType<DuckDBTypeId.VARINT> {
constructor(alias?: string);
static readonly instance: DuckDBVarIntType;
static create(alias?: string): DuckDBVarIntType;
static readonly Max: bigint;
static readonly Min: bigint;
}
export declare class DuckDBSQLNullType extends BaseDuckDBType {
private constructor();
export declare class DuckDBSQLNullType extends BaseDuckDBType<DuckDBTypeId.SQLNULL> {
constructor(alias?: string);
static readonly instance: DuckDBSQLNullType;
static create(alias?: string): DuckDBSQLNullType;
}
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 | DuckDBVarIntType | DuckDBSQLNullType;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DuckDBSQLNullType = exports.DuckDBVarIntType = exports.DuckDBAnyType = exports.DuckDBTimestampTZType = exports.DuckDBTimeTZType = exports.DuckDBBitType = exports.DuckDBUnionType = exports.DuckDBUUIDType = exports.DuckDBArrayType = exports.DuckDBMapType = exports.DuckDBStructType = exports.DuckDBListType = exports.DuckDBEnumType = exports.DuckDBTimestampNanosecondsType = exports.DuckDBTimestampMillisecondsType = exports.DuckDBTimestampSecondsType = exports.DuckDBDecimalType = exports.DuckDBBlobType = exports.DuckDBVarCharType = exports.DuckDBUHugeIntType = exports.DuckDBHugeIntType = exports.DuckDBIntervalType = exports.DuckDBTimeType = exports.DuckDBDateType = exports.DuckDBTimestampType = exports.DuckDBDoubleType = exports.DuckDBFloatType = exports.DuckDBUBigIntType = exports.DuckDBUIntegerType = exports.DuckDBUSmallIntType = exports.DuckDBUTinyIntType = exports.DuckDBBigIntType = exports.DuckDBIntegerType = exports.DuckDBSmallIntType = exports.DuckDBTinyIntType = exports.DuckDBBooleanType = exports.BaseDuckDBType = void 0;
exports.DuckDBSQLNullType = exports.DuckDBVarIntType = exports.DuckDBAnyType = exports.DuckDBTimestampTZType = exports.DuckDBTimeTZType = exports.DuckDBBitType = exports.DuckDBUnionType = exports.DuckDBUUIDType = exports.DuckDBArrayType = exports.DuckDBMapType = exports.DuckDBStructType = exports.DuckDBListType = exports.DuckDBEnumType = exports.DuckDBTimestampNanosecondsType = exports.DuckDBTimestampMillisecondsType = exports.DuckDBTimestampSecondsType = exports.DuckDBDecimalType = exports.DuckDBBlobType = exports.DuckDBVarCharType = exports.DuckDBUHugeIntType = exports.DuckDBHugeIntType = exports.DuckDBIntervalType = exports.DuckDBTimeType = exports.DuckDBDateType = exports.DuckDBTimestampMicrosecondsType = exports.DuckDBTimestampType = exports.DuckDBDoubleType = exports.DuckDBFloatType = exports.DuckDBUBigIntType = exports.DuckDBUIntegerType = exports.DuckDBUSmallIntType = exports.DuckDBUTinyIntType = exports.DuckDBBigIntType = exports.DuckDBIntegerType = exports.DuckDBSmallIntType = exports.DuckDBTinyIntType = exports.DuckDBBooleanType = exports.BaseDuckDBType = void 0;
const DuckDBTypeId_1 = require("./DuckDBTypeId");
const sql_1 = require("./sql");
class BaseDuckDBType {
typeId;
constructor(typeId) {
alias;
constructor(typeId, alias) {
this.typeId = typeId;
this.alias = alias;
}
toString() {
return DuckDBTypeId_1.DuckDBTypeId[this.typeId];
}
}
exports.BaseDuckDBType = BaseDuckDBType;
class DuckDBBooleanType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.BOOLEAN);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.BOOLEAN, alias);
}
static instance = new DuckDBBooleanType();
static create(alias) {
return alias ? new DuckDBBooleanType(alias) : DuckDBBooleanType.instance;
}
}
exports.DuckDBBooleanType = DuckDBBooleanType;
class DuckDBTinyIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TINYINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TINYINT, alias);
}
static instance = new DuckDBTinyIntType();
static create(alias) {
return alias ? new DuckDBTinyIntType(alias) : DuckDBTinyIntType.instance;
}
static Max = 2 ** 7 - 1;
static Min = -(2 ** 7);
}
exports.DuckDBTinyIntType = DuckDBTinyIntType;
class DuckDBSmallIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.SMALLINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.SMALLINT, alias);
}
static instance = new DuckDBSmallIntType();
static create(alias) {
return alias ? new DuckDBSmallIntType(alias) : DuckDBSmallIntType.instance;
}
static Max = 2 ** 15 - 1;
static Min = -(2 ** 15);
}
exports.DuckDBSmallIntType = DuckDBSmallIntType;
class DuckDBIntegerType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.INTEGER);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.INTEGER, alias);
}
static instance = new DuckDBIntegerType();
static create(alias) {
return alias ? new DuckDBIntegerType(alias) : DuckDBIntegerType.instance;
}
static Max = 2 ** 31 - 1;
static Min = -(2 ** 31);
}
exports.DuckDBIntegerType = DuckDBIntegerType;
class DuckDBBigIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.BIGINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.BIGINT, alias);
}
static instance = new DuckDBBigIntType();
static create(alias) {
return alias ? new DuckDBBigIntType(alias) : DuckDBBigIntType.instance;
}
static Max = 2n ** 63n - 1n;
static Min = -(2n ** 63n);
}
exports.DuckDBBigIntType = DuckDBBigIntType;
class DuckDBUTinyIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.UTINYINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.UTINYINT, alias);
}
static instance = new DuckDBUTinyIntType();
static create(alias) {
return alias ? new DuckDBUTinyIntType(alias) : DuckDBUTinyIntType.instance;
}
static Max = 2 ** 8 - 1;
static Min = 0;
}
exports.DuckDBUTinyIntType = DuckDBUTinyIntType;
class DuckDBUSmallIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.USMALLINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.USMALLINT, alias);
}
static instance = new DuckDBUSmallIntType();
static create(alias) {
return alias ? new DuckDBUSmallIntType(alias) : DuckDBUSmallIntType.instance;
}
static Max = 2 ** 16 - 1;
static Min = 0;
}
exports.DuckDBUSmallIntType = DuckDBUSmallIntType;
class DuckDBUIntegerType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.UINTEGER);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.UINTEGER, alias);
}
static instance = new DuckDBUIntegerType();
static create(alias) {
return alias ? new DuckDBUIntegerType(alias) : DuckDBUIntegerType.instance;
}
static Max = 2 ** 32 - 1;
static Min = 0;
}
exports.DuckDBUIntegerType = DuckDBUIntegerType;
class DuckDBUBigIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.UBIGINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.UBIGINT, alias);
}
static instance = new DuckDBUBigIntType();
static create(alias) {
return alias ? new DuckDBUBigIntType(alias) : DuckDBUBigIntType.instance;
}
static Max = 2n ** 64n - 1n;
static Min = 0n;
}
exports.DuckDBUBigIntType = DuckDBUBigIntType;
class DuckDBFloatType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.FLOAT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.FLOAT, alias);
}
static instance = new DuckDBFloatType();
static create(alias) {
return alias ? new DuckDBFloatType(alias) : DuckDBFloatType.instance;
}
static Min = Math.fround(-3.4028235e+38);
static Max = Math.fround(3.4028235e+38);
}
exports.DuckDBFloatType = DuckDBFloatType;
class DuckDBDoubleType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.DOUBLE);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.DOUBLE, alias);
}
static instance = new DuckDBDoubleType();
static create(alias) {
return alias ? new DuckDBDoubleType(alias) : DuckDBDoubleType.instance;
}
static Min = -Number.MAX_VALUE;
static Max = Number.MAX_VALUE;
}
exports.DuckDBDoubleType = DuckDBDoubleType;
class DuckDBTimestampType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP, alias);
}
static instance = new DuckDBTimestampType();
static create(alias) {
return alias ? new DuckDBTimestampType(alias) : DuckDBTimestampType.instance;
}
}
exports.DuckDBTimestampType = DuckDBTimestampType;
exports.DuckDBTimestampMicrosecondsType = DuckDBTimestampType;
class DuckDBDateType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.DATE);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.DATE, alias);
}
static instance = new DuckDBDateType();
static create(alias) {
return alias ? new DuckDBDateType(alias) : DuckDBDateType.instance;
}
}
exports.DuckDBDateType = DuckDBDateType;
class DuckDBTimeType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIME);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIME, alias);
}
static instance = new DuckDBTimeType();
static create(alias) {
return alias ? new DuckDBTimeType(alias) : DuckDBTimeType.instance;
}
}
exports.DuckDBTimeType = DuckDBTimeType;
class DuckDBIntervalType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.INTERVAL);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.INTERVAL, alias);
}
static instance = new DuckDBIntervalType();
static create(alias) {
return alias ? new DuckDBIntervalType(alias) : DuckDBIntervalType.instance;
}
}
exports.DuckDBIntervalType = DuckDBIntervalType;
class DuckDBHugeIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.HUGEINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.HUGEINT, alias);
}
static instance = new DuckDBHugeIntType();
static create(alias) {
return alias ? new DuckDBHugeIntType(alias) : DuckDBHugeIntType.instance;
}
static Max = 2n ** 127n - 1n;
static Min = -(2n ** 127n);
}
exports.DuckDBHugeIntType = DuckDBHugeIntType;
class DuckDBUHugeIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.UHUGEINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.UHUGEINT, alias);
}
static instance = new DuckDBUHugeIntType();
static create(alias) {
return alias ? new DuckDBUHugeIntType(alias) : DuckDBUHugeIntType.instance;
}
static Max = 2n ** 128n - 1n;
static Min = 0n;
}
exports.DuckDBUHugeIntType = DuckDBUHugeIntType;
class DuckDBVarCharType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.VARCHAR);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.VARCHAR, alias);
}
static instance = new DuckDBVarCharType();
static create(alias) {
return alias ? new DuckDBVarCharType(alias) : DuckDBVarCharType.instance;
}
}
exports.DuckDBVarCharType = DuckDBVarCharType;
class DuckDBBlobType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.BLOB);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.BLOB, alias);
}
static instance = new DuckDBBlobType();
static create(alias) {
return alias ? new DuckDBBlobType(alias) : DuckDBBlobType.instance;
}
}

@@ -148,7 +236,10 @@ exports.DuckDBBlobType = DuckDBBlobType;

scale;
constructor(width, scale) {
super(DuckDBTypeId_1.DuckDBTypeId.DECIMAL);
constructor(width, scale, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.DECIMAL, alias);
this.width = width;
this.scale = scale;
}
toString() {
return `DECIMAL(${this.width},${this.scale})`;
}
static default = new DuckDBDecimalType(18, 3);

@@ -158,20 +249,29 @@ }

class DuckDBTimestampSecondsType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S, alias);
}
static instance = new DuckDBTimestampSecondsType();
static create(alias) {
return alias ? new DuckDBTimestampSecondsType(alias) : DuckDBTimestampSecondsType.instance;
}
}
exports.DuckDBTimestampSecondsType = DuckDBTimestampSecondsType;
class DuckDBTimestampMillisecondsType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS, alias);
}
static instance = new DuckDBTimestampMillisecondsType();
static create(alias) {
return alias ? new DuckDBTimestampMillisecondsType(alias) : DuckDBTimestampMillisecondsType.instance;
}
}
exports.DuckDBTimestampMillisecondsType = DuckDBTimestampMillisecondsType;
class DuckDBTimestampNanosecondsType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS, alias);
}
static instance = new DuckDBTimestampNanosecondsType();
static create(alias) {
return alias ? new DuckDBTimestampNanosecondsType(alias) : DuckDBTimestampNanosecondsType.instance;
}
}

@@ -182,7 +282,10 @@ exports.DuckDBTimestampNanosecondsType = DuckDBTimestampNanosecondsType;

internalTypeId;
constructor(values, internalTypeId) {
super(DuckDBTypeId_1.DuckDBTypeId.ENUM);
constructor(values, internalTypeId, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.ENUM, alias);
this.values = values;
this.internalTypeId = internalTypeId;
}
toString() {
return `ENUM(${this.values.map(sql_1.quotedString).join(', ')})`;
}
}

@@ -192,14 +295,33 @@ exports.DuckDBEnumType = DuckDBEnumType;

valueType;
constructor(valueType) {
super(DuckDBTypeId_1.DuckDBTypeId.LIST);
constructor(valueType, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.LIST, alias);
this.valueType = valueType;
}
toString() {
return `${this.valueType}[]`;
}
}
exports.DuckDBListType = DuckDBListType;
class DuckDBStructType extends BaseDuckDBType {
entries;
constructor(entries) {
super(DuckDBTypeId_1.DuckDBTypeId.STRUCT);
this.entries = entries;
entryNames;
entryTypes;
constructor(entryNames, entryTypes, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.STRUCT, alias);
if (entryNames.length !== entryTypes.length) {
throw new Error(`Could not create DuckDBStructType: \
entryNames length (${entryNames.length}) does not match entryTypes length (${entryTypes.length})`);
}
this.entryNames = entryNames;
this.entryTypes = entryTypes;
}
get entryCount() {
return this.entryNames.length;
}
toString() {
const parts = [];
for (let i = 0; i < this.entryNames.length; i++) {
parts.push(`${(0, sql_1.quotedIdentifier)(this.entryNames[i])} ${this.entryTypes[i]}`);
}
return `STRUCT(${parts.join(', ')})`;
}
}

@@ -210,7 +332,10 @@ exports.DuckDBStructType = DuckDBStructType;

valueType;
constructor(keyType, valueType) {
super(DuckDBTypeId_1.DuckDBTypeId.MAP);
constructor(keyType, valueType, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.MAP, alias);
this.keyType = keyType;
this.valueType = valueType;
}
toString() {
return `MAP(${this.keyType}, ${this.valueType})`;
}
}

@@ -221,65 +346,113 @@ exports.DuckDBMapType = DuckDBMapType;

length;
constructor(valueType, length) {
super(DuckDBTypeId_1.DuckDBTypeId.ARRAY);
constructor(valueType, length, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.ARRAY, alias);
this.valueType = valueType;
this.length = length;
}
toString() {
return `${this.valueType}[${this.length}]`;
}
}
exports.DuckDBArrayType = DuckDBArrayType;
class DuckDBUUIDType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.UUID);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.UUID, alias);
}
static instance = new DuckDBUUIDType();
static create(alias) {
return alias ? new DuckDBUUIDType(alias) : DuckDBUUIDType.instance;
}
}
exports.DuckDBUUIDType = DuckDBUUIDType;
class DuckDBUnionType extends BaseDuckDBType {
alternatives;
constructor(alternatives) {
super(DuckDBTypeId_1.DuckDBTypeId.UNION);
this.alternatives = alternatives;
memberTags;
memberTypes;
constructor(memberTags, memberTypes, alias) {
super(DuckDBTypeId_1.DuckDBTypeId.UNION, alias);
if (memberTags.length !== memberTypes.length) {
throw new Error(`Could not create DuckDBUnionType: \
tags length (${memberTags.length}) does not match valueTypes length (${memberTypes.length})`);
}
this.memberTags = memberTags;
this.memberTypes = memberTypes;
}
get memberCount() {
return this.memberTags.length;
}
toString() {
const parts = [];
for (let i = 0; i < this.memberTags.length; i++) {
parts.push(`${(0, sql_1.quotedIdentifier)(this.memberTags[i])} ${this.memberTypes[i]}`);
}
return `UNION(${parts.join(', ')})`;
}
}
exports.DuckDBUnionType = DuckDBUnionType;
class DuckDBBitType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.BIT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.BIT, alias);
}
static instance = new DuckDBBitType();
static create(alias) {
return alias ? new DuckDBBitType(alias) : DuckDBBitType.instance;
}
}
exports.DuckDBBitType = DuckDBBitType;
class DuckDBTimeTZType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIME_TZ);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIME_TZ, alias);
}
toString() {
return "TIME WITH TIME ZONE";
}
static instance = new DuckDBTimeTZType();
static create(alias) {
return alias ? new DuckDBTimeTZType(alias) : DuckDBTimeTZType.instance;
}
}
exports.DuckDBTimeTZType = DuckDBTimeTZType;
class DuckDBTimestampTZType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ, alias);
}
toString() {
return "TIMESTAMP WITH TIME ZONE";
}
static instance = new DuckDBTimestampTZType();
static create(alias) {
return alias ? new DuckDBTimestampTZType(alias) : DuckDBTimestampTZType.instance;
}
}
exports.DuckDBTimestampTZType = DuckDBTimestampTZType;
class DuckDBAnyType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.ANY);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.ANY, alias);
}
static instance = new DuckDBAnyType();
static create(alias) {
return alias ? new DuckDBAnyType(alias) : DuckDBAnyType.instance;
}
}
exports.DuckDBAnyType = DuckDBAnyType;
class DuckDBVarIntType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.VARINT);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.VARINT, alias);
}
static instance = new DuckDBVarIntType();
static create(alias) {
return alias ? new DuckDBVarIntType(alias) : DuckDBVarIntType.instance;
}
static Max = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
static Min = -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
}
exports.DuckDBVarIntType = DuckDBVarIntType;
class DuckDBSQLNullType extends BaseDuckDBType {
constructor() {
super(DuckDBTypeId_1.DuckDBTypeId.SQLNULL);
constructor(alias) {
super(DuckDBTypeId_1.DuckDBTypeId.SQLNULL, alias);
}
static instance = new DuckDBSQLNullType();
static create(alias) {
return alias ? new DuckDBSQLNullType(alias) : DuckDBSQLNullType.instance;
}
}
exports.DuckDBSQLNullType = DuckDBSQLNullType;
import duckdb from '@duckdb/node-bindings';
import { DuckDBArrayType, DuckDBBigIntType, DuckDBBitType, DuckDBBlobType, DuckDBBooleanType, DuckDBDateType, DuckDBDecimalType, DuckDBDoubleType, DuckDBEnumType, DuckDBFloatType, DuckDBHugeIntType, DuckDBIntegerType, DuckDBListType, DuckDBMapType, DuckDBSmallIntType, DuckDBStructType, DuckDBTimeTZType, DuckDBTimeType, DuckDBTimestampMillisecondsType, DuckDBTimestampNanosecondsType, DuckDBTimestampSecondsType, DuckDBTimestampType, DuckDBTinyIntType, DuckDBType, DuckDBUBigIntType, DuckDBUHugeIntType, DuckDBUIntegerType, DuckDBUSmallIntType, DuckDBUTinyIntType, DuckDBUUIDType, DuckDBUnionType, DuckDBVarCharType, DuckDBVarIntType } from './DuckDBType';
export declare class DuckDBSmallDecimal {
readonly scaledValue: number;
readonly type: DuckDBDecimalType;
constructor(scaledValue: number, type: DuckDBDecimalType);
}
export declare class DuckDBLargeDecimal {
readonly scaledValue: bigint;
readonly type: DuckDBDecimalType;
constructor(scaledValue: bigint, type: DuckDBDecimalType);
}
import { DuckDBArrayType, DuckDBBigIntType, 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, DuckDBVarIntType } from './DuckDBType';
import { DuckDBArrayValue, DuckDBBitValue, DuckDBBlobValue, DuckDBDateValue, DuckDBDecimalValue, DuckDBIntervalValue, DuckDBListValue, DuckDBMapValue, DuckDBStructValue, DuckDBTimeTZValue, DuckDBTimeValue, DuckDBTimestampMillisecondsValue, DuckDBTimestampNanosecondsValue, DuckDBTimestampSecondsValue, DuckDBTimestampTZValue, DuckDBTimestampValue, DuckDBUUIDValue, DuckDBUnionValue, DuckDBValue } from './values';
declare class DuckDBValidity {

@@ -21,9 +12,10 @@ private readonly data;

}
export declare abstract class DuckDBVector<T> {
export declare abstract class DuckDBVector<TValue extends DuckDBValue = DuckDBValue> {
static standardSize(): number;
static create(vector: duckdb.Vector, itemCount: number, knownType?: DuckDBType): DuckDBVector<any>;
static create(vector: duckdb.Vector, itemCount: number, knownType?: DuckDBType): DuckDBVector;
abstract get type(): DuckDBType;
abstract get itemCount(): number;
abstract getItem(itemIndex: number): T | null;
abstract slice(offset: number, length: number): DuckDBVector<T>;
abstract getItem(itemIndex: number): TValue | null;
abstract slice(offset: number, length: number): DuckDBVector<TValue>;
toArray(): (TValue | null)[];
}

@@ -141,3 +133,3 @@ export declare class DuckDBBooleanVector extends DuckDBVector<boolean> {

}
export declare class DuckDBTimestampVector extends DuckDBVector<bigint> {
export declare class DuckDBTimestampVector extends DuckDBVector<DuckDBTimestampValue> {
private readonly items;

@@ -149,6 +141,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBTimestampValue | null;
slice(offset: number, length: number): DuckDBTimestampVector;
}
export declare class DuckDBDateVector extends DuckDBVector<number> {
export declare class DuckDBDateVector extends DuckDBVector<DuckDBDateValue> {
private readonly items;

@@ -160,6 +152,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): number | null;
getItem(itemIndex: number): DuckDBDateValue | null;
slice(offset: number, length: number): DuckDBDateVector;
}
export declare class DuckDBTimeVector extends DuckDBVector<bigint> {
export declare class DuckDBTimeVector extends DuckDBVector<DuckDBTimeValue> {
private readonly items;

@@ -171,12 +163,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBTimeValue | null;
slice(offset: number, length: number): DuckDBTimeVector;
}
export declare class DuckDBInterval {
readonly months: number;
readonly days: number;
readonly micros: bigint;
constructor(months: number, days: number, micros: bigint);
}
export declare class DuckDBIntervalVector extends DuckDBVector<DuckDBInterval> {
export declare class DuckDBIntervalVector extends DuckDBVector<DuckDBIntervalValue> {
private readonly dataView;

@@ -187,5 +173,5 @@ private readonly validity;

static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBIntervalVector;
get type(): DuckDBHugeIntType;
get type(): DuckDBIntervalType;
get itemCount(): number;
getItem(itemIndex: number): DuckDBInterval | null;
getItem(itemIndex: number): DuckDBIntervalValue | null;
slice(offset: number, length: number): DuckDBIntervalVector;

@@ -202,2 +188,3 @@ }

getItem(itemIndex: number): bigint | null;
getDouble(itemIndex: number): number | null;
slice(offset: number, length: number): DuckDBHugeIntVector;

@@ -214,2 +201,3 @@ }

getItem(itemIndex: number): bigint | null;
getDouble(itemIndex: number): number | null;
slice(offset: number, length: number): DuckDBUHugeIntVector;

@@ -228,3 +216,3 @@ }

}
export declare class DuckDBBlobVector extends DuckDBVector<Uint8Array> {
export declare class DuckDBBlobVector extends DuckDBVector<DuckDBBlobValue> {
private readonly dataView;

@@ -237,6 +225,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): Uint8Array | null;
getItem(itemIndex: number): DuckDBBlobValue | null;
slice(offset: number, length: number): DuckDBBlobVector;
}
export declare class DuckDBDecimal2Vector extends DuckDBVector<DuckDBSmallDecimal> {
export declare class DuckDBDecimal2Vector extends DuckDBVector<DuckDBDecimalValue> {
private readonly decimalType;

@@ -250,7 +238,7 @@ private readonly dataView;

get itemCount(): number;
getItem(itemIndex: number): DuckDBSmallDecimal | null;
getItem(itemIndex: number): DuckDBDecimalValue | null;
getScaledValue(itemIndex: number): number | null;
slice(offset: number, length: number): DuckDBDecimal2Vector;
}
export declare class DuckDBDecimal4Vector extends DuckDBVector<DuckDBSmallDecimal> {
export declare class DuckDBDecimal4Vector extends DuckDBVector<DuckDBDecimalValue> {
private readonly decimalType;

@@ -264,7 +252,7 @@ private readonly dataView;

get itemCount(): number;
getItem(itemIndex: number): DuckDBSmallDecimal | null;
getItem(itemIndex: number): DuckDBDecimalValue | null;
getScaledValue(itemIndex: number): number | null;
slice(offset: number, length: number): DuckDBDecimal4Vector;
}
export declare class DuckDBDecimal8Vector extends DuckDBVector<DuckDBLargeDecimal> {
export declare class DuckDBDecimal8Vector extends DuckDBVector<DuckDBDecimalValue> {
private readonly decimalType;

@@ -278,7 +266,7 @@ private readonly dataView;

get itemCount(): number;
getItem(itemIndex: number): DuckDBLargeDecimal | null;
getItem(itemIndex: number): DuckDBDecimalValue | null;
getScaledValue(itemIndex: number): bigint | null;
slice(offset: number, length: number): DuckDBDecimal8Vector;
}
export declare class DuckDBDecimal16Vector extends DuckDBVector<DuckDBLargeDecimal> {
export declare class DuckDBDecimal16Vector extends DuckDBVector<DuckDBDecimalValue> {
private readonly decimalType;

@@ -292,7 +280,7 @@ private readonly dataView;

get itemCount(): number;
getItem(itemIndex: number): DuckDBLargeDecimal | null;
getItem(itemIndex: number): DuckDBDecimalValue | null;
getScaledValue(itemIndex: number): bigint | null;
slice(offset: number, length: number): DuckDBDecimal16Vector;
}
export declare class DuckDBTimestampSecondsVector extends DuckDBVector<bigint> {
export declare class DuckDBTimestampSecondsVector extends DuckDBVector<DuckDBTimestampSecondsValue> {
private readonly items;

@@ -304,6 +292,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBTimestampSecondsValue | null;
slice(offset: number, length: number): DuckDBTimestampSecondsVector;
}
export declare class DuckDBTimestampMillisecondsVector extends DuckDBVector<bigint> {
export declare class DuckDBTimestampMillisecondsVector extends DuckDBVector<DuckDBTimestampMillisecondsValue> {
private readonly items;

@@ -315,6 +303,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBTimestampMillisecondsValue | null;
slice(offset: number, length: number): DuckDBTimestampMillisecondsVector;
}
export declare class DuckDBTimestampNanosecondsVector extends DuckDBVector<bigint> {
export declare class DuckDBTimestampNanosecondsVector extends DuckDBVector<DuckDBTimestampNanosecondsValue> {
private readonly items;

@@ -326,3 +314,3 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBTimestampNanosecondsValue | null;
slice(offset: number, length: number): DuckDBTimestampNanosecondsVector;

@@ -363,3 +351,3 @@ }

}
export declare class DuckDBListVector<TValue = any> extends DuckDBVector<DuckDBVector<TValue>> {
export declare class DuckDBListVector extends DuckDBVector<DuckDBListValue> {
private readonly listType;

@@ -370,14 +358,11 @@ private readonly entryData;

private readonly _itemCount;
constructor(listType: DuckDBListType, entryData: BigUint64Array, validity: DuckDBValidity, childData: DuckDBVector<TValue>, itemCount: number);
constructor(listType: DuckDBListType, entryData: BigUint64Array, validity: DuckDBValidity, childData: DuckDBVector, itemCount: number);
static fromRawVector(listType: DuckDBListType, vector: duckdb.Vector, itemCount: number): DuckDBListVector;
get type(): DuckDBListType;
get itemCount(): number;
getItem(itemIndex: number): DuckDBVector<TValue> | null;
slice(offset: number, length: number): DuckDBListVector<TValue>;
getItemVector(itemIndex: number): DuckDBVector | null;
getItem(itemIndex: number): DuckDBListValue | null;
slice(offset: number, length: number): DuckDBListVector;
}
export interface DuckDBStructEntry {
readonly name: string;
readonly value: any;
}
export declare class DuckDBStructVector extends DuckDBVector<readonly DuckDBStructEntry[]> {
export declare class DuckDBStructVector extends DuckDBVector<DuckDBStructValue> {
private readonly structType;

@@ -387,15 +372,11 @@ private readonly _itemCount;

private readonly validity;
constructor(structType: DuckDBStructType, itemCount: number, entryVectors: readonly DuckDBVector<any>[], validity: DuckDBValidity);
constructor(structType: DuckDBStructType, itemCount: number, entryVectors: readonly DuckDBVector[], validity: DuckDBValidity);
static fromRawVector(structType: DuckDBStructType, vector: duckdb.Vector, itemCount: number): DuckDBStructVector;
get type(): DuckDBStructType;
get itemCount(): number;
getItem(itemIndex: number): readonly DuckDBStructEntry[] | null;
getItemValue(itemIndex: number, entryIndex: number): any | null;
getItem(itemIndex: number): DuckDBStructValue | null;
getItemValue(itemIndex: number, entryIndex: number): DuckDBValue | null;
slice(offset: number, length: number): DuckDBStructVector;
}
export interface DuckDBMapEntry {
readonly key: any;
readonly value: any;
}
export declare class DuckDBMapVector extends DuckDBVector<readonly DuckDBMapEntry[]> {
export declare class DuckDBMapVector extends DuckDBVector<DuckDBMapValue> {
private readonly mapType;

@@ -405,8 +386,8 @@ private readonly listVector;

static fromRawVector(mapType: DuckDBMapType, vector: duckdb.Vector, itemCount: number): DuckDBMapVector;
get type(): DuckDBType;
get type(): DuckDBMapType;
get itemCount(): number;
getItem(itemIndex: number): readonly DuckDBMapEntry[] | null;
getItem(itemIndex: number): DuckDBMapValue | null;
slice(offset: number, length: number): DuckDBMapVector;
}
export declare class DuckDBArrayVector<TValue = any> extends DuckDBVector<DuckDBVector<TValue>> {
export declare class DuckDBArrayVector extends DuckDBVector<DuckDBArrayValue> {
private readonly arrayType;

@@ -416,3 +397,3 @@ private readonly validity;

private readonly _itemCount;
constructor(arrayType: DuckDBArrayType, validity: DuckDBValidity, childData: DuckDBVector<TValue>, itemCount: number);
constructor(arrayType: DuckDBArrayType, validity: DuckDBValidity, childData: DuckDBVector, itemCount: number);
static fromRawVector(arrayType: DuckDBArrayType, vector: duckdb.Vector, itemCount: number): DuckDBArrayVector;

@@ -422,6 +403,6 @@ private static itemSize;

get itemCount(): number;
getItem(itemIndex: number): DuckDBVector<TValue> | null;
slice(offset: number, length: number): DuckDBArrayVector<TValue>;
getItem(itemIndex: number): DuckDBArrayValue | null;
slice(offset: number, length: number): DuckDBArrayVector;
}
export declare class DuckDBUUIDVector extends DuckDBVector<bigint> {
export declare class DuckDBUUIDVector extends DuckDBVector<DuckDBUUIDValue> {
private readonly dataView;

@@ -434,10 +415,6 @@ private readonly validity;

get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBUUIDValue | null;
slice(offset: number, length: number): DuckDBUUIDVector;
}
export interface DuckDBUnionAlternative {
readonly tag: string;
readonly value: any;
}
export declare class DuckDBUnionVector extends DuckDBVector<DuckDBUnionAlternative> {
export declare class DuckDBUnionVector extends DuckDBVector<DuckDBUnionValue> {
private readonly unionType;

@@ -449,15 +426,5 @@ private readonly structVector;

get itemCount(): number;
getItem(itemIndex: number): DuckDBUnionAlternative | null;
getItem(itemIndex: number): DuckDBUnionValue | null;
slice(offset: number, length: number): DuckDBUnionVector;
}
export declare class DuckDBBitValue {
private readonly data;
constructor(data: Uint8Array);
static fromString(str: string): DuckDBBitValue;
private padding;
length(): number;
getBool(index: number): boolean;
getBit(index: number): 0 | 1;
toString(): string;
}
export declare class DuckDBBitVector extends DuckDBVector<DuckDBBitValue> {

@@ -474,13 +441,2 @@ private readonly dataView;

}
export declare class DuckDBTimeTZValue {
/** Ranges from 0 to 86400000000 (= 24 * 60 * 60 * 1000 * 1000) */
readonly microseconds: number;
/** In seconds, ranges from -57599 to 57599 (= 16 * 60 * 60 - 1) */
readonly offset: number;
constructor(microseconds: number, offset: number);
static TIME_BITS: number;
static OFFSET_BITS: number;
static MAX_OFFSET: number;
static fromBits(bits: bigint): DuckDBTimeTZValue;
}
export declare class DuckDBTimeTZVector extends DuckDBVector<DuckDBTimeTZValue> {

@@ -496,3 +452,3 @@ private readonly items;

}
export declare class DuckDBTimestampTZVector extends DuckDBVector<bigint> {
export declare class DuckDBTimestampTZVector extends DuckDBVector<DuckDBTimestampTZValue> {
private readonly items;

@@ -502,5 +458,5 @@ private readonly validity;

static fromRawVector(vector: duckdb.Vector, itemCount: number): DuckDBTimestampTZVector;
get type(): DuckDBTimestampType;
get type(): DuckDBTimestampTZType;
get itemCount(): number;
getItem(itemIndex: number): bigint | null;
getItem(itemIndex: number): DuckDBTimestampTZValue | null;
slice(offset: number, length: number): DuckDBTimestampTZVector;

@@ -507,0 +463,0 @@ }

@@ -1,2 +0,2 @@

export * from './configurationOptionDescriptions';
export { hugeint_to_double, double_to_hugeint, uhugeint_to_double, double_to_uhugeint, } from '@duckdb/node-bindings';
export * from './DuckDBAppender';

@@ -13,5 +13,7 @@ export * from './DuckDBConnection';

export * from './DuckDBTypeId';
export * from './DuckDBValue';
export * from './DuckDBVector';
export * from './configurationOptionDescriptions';
export * from './enums';
export * from './sql';
export * from './values';
export * from './version';

@@ -17,3 +17,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./configurationOptionDescriptions"), exports);
exports.double_to_uhugeint = exports.uhugeint_to_double = exports.double_to_hugeint = exports.hugeint_to_double = void 0;
var node_bindings_1 = require("@duckdb/node-bindings");
Object.defineProperty(exports, "hugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.hugeint_to_double; } });
Object.defineProperty(exports, "double_to_hugeint", { enumerable: true, get: function () { return node_bindings_1.double_to_hugeint; } });
Object.defineProperty(exports, "uhugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.uhugeint_to_double; } });
Object.defineProperty(exports, "double_to_uhugeint", { enumerable: true, get: function () { return node_bindings_1.double_to_uhugeint; } });
__exportStar(require("./DuckDBAppender"), exports);

@@ -30,5 +35,7 @@ __exportStar(require("./DuckDBConnection"), exports);

__exportStar(require("./DuckDBTypeId"), exports);
__exportStar(require("./DuckDBValue"), exports);
__exportStar(require("./DuckDBVector"), exports);
__exportStar(require("./configurationOptionDescriptions"), exports);
__exportStar(require("./enums"), exports);
__exportStar(require("./sql"), exports);
__exportStar(require("./values"), exports);
__exportStar(require("./version"), exports);
{
"name": "@duckdb/node-api",
"version": "1.1.2-alpha.2",
"version": "1.1.2-alpha.3",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"dependencies": {
"@duckdb/node-bindings": "1.1.2-alpha.2"
"@duckdb/node-bindings": "1.1.2-alpha.3"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -19,3 +19,2 @@ # DuckDB Node API

Some features are not yet complete:
- Friendlier APIs for consuming advanced data types and values, especially converting them to strings.
- Appending and binding advanced data types. (Additional DuckDB C API support needed.)

@@ -72,7 +71,2 @@ - Writing to data chunk vectors. (Directly writing to binary buffers is challenging to support using the Node Addon API.)

Dispose:
```ts
await instance.dispose();
```
### Connect

@@ -84,7 +78,2 @@

Dispose:
```ts
await connection.dispose();
```
### Run SQL

@@ -96,7 +85,2 @@

Dispose:
```ts
result.dispose();
```
### Parameterize SQL

@@ -111,8 +95,2 @@

Dispose:
```ts
result.dispose();
prepared.dispose();
```
### Inspect Result

@@ -122,18 +100,17 @@

```ts
const columnNames = [];
const columnTypes = [];
const columnCount = result.columnCount;
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
const columnName = result.columnName(columnIndex);
const columnType = result.columnType(columnIndex);
columnNames.push(columnName);
columnTypes.push(columnType);
}
const columnNames = result.columnNames();
const columnTypes = result.columnTypes();
```
Fetch data chunks:
Fetch all chunks:
```ts
const chunks = await result.fetchAllChunks();
```
Fetch one chunk at a time:
```ts
const chunks = [];
while (true) {
const chunk = await result.fetchChunk();
// Last chunk will have zero rows.
if (chunk.rowCount === 0) {

@@ -146,9 +123,19 @@ break;

Read column data:
Read chunk data (column-major):
```ts
const columns = chunk.getColumns(); // array of columns, each as an array of values
```
Read chunk data (row-major):
```ts
const columns = chunk.getRows(); // array of rows, each as an array of values
```
Read chunk data (one value at a time)
```ts
const columns = [];
const columnCount = result.columnCount;
const columnCount = chunk.columnCount;
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
const columnValues = [];
const columnVector = chunk.getColumn(columnIndex);
const columnVector = chunk.getColumnVector(columnIndex);
const itemCount = columnVector.itemCount;

@@ -163,7 +150,2 @@ for (let itemIndex = 0; itemIndex < itemCount; itemIndex++) {

Dispose data chunk:
```ts
chunk.dispose();
```
### Inspect Data Types

@@ -174,30 +156,47 @@

function typeToString(dataType) {
switch (dataType.typeId) {
case DuckDBTypeId.ARRAY:
return `${typeToString(dataType.valueType)}[${dataType.length}]`;
case DuckDBTypeId.DECIMAL:
return `DECIMAL(${dataType.width},${dataType.scale})`;
case DuckDBTypeId.ENUM:
return `ENUM(${dataType.values.map(
value => `'${value.replace(`'`, `''`)}'`
).join(', ')})`;
case DuckDBTypeId.LIST:
return `${typeToString(dataType.valueType)}[]`;
case DuckDBTypeId.MAP:
return `MAP(${typeToString(dataType.keyType)}, ${typeToString(dataType.valueType)})`;
case DuckDBTypeId.STRUCT:
return `STRUCT(${dataType.entries.map(
entry => `"${entry.name.replace(`"`, `""`)}" ${typeToString(entry.valueType)}`
).join(', ')})`;
case DuckDBTypeId.UNION:
return `UNION(${dataType.alternatives.map(
alt => `"${alt.tag.replace(`"`, `""`)}" ${typeToString(alt.valueType)}`
).join(', ')})`;
default:
return DuckDBTypeId[dataType.typeId];
}
if (columnType.typeId === DuckDBTypeId.ARRAY) {
const arrayValueType = columnType.valueType;
const arrayLength = columnType.length;
}
if (columnType.typeId === DuckDBTypeId.DECIMAL) {
const decimalWidth = columnType.width;
const decimalScale = columnType.scale;
}
if (columnType.typeId === DuckDBTypeId.ENUM) {
const enumValues = columnType.values;
}
if (columnType.typeId === DuckDBTypeId.LIST) {
const listValueType = columnType.valueType;
}
if (columnType.typeId === DuckDBTypeId.MAP) {
const mapKeyType = columnType.keyType;
const mapValueType = columnType.valueType;
}
if (columnType.typeId === DuckDBTypeId.STRUCT) {
const structEntryNames = columnType.names;
const structEntryTypes = columnType.valueTypes;
}
if (columnType.typeId === DuckDBTypeId.UNION) {
const unionMemberTags = columnType.memberTags;
const unionMemberTypes = columnType.memberTypes;
}
// For the JSON type (https://duckdb.org/docs/data/json/json_type)
if (columnType.alias === 'JSON') {
const json = JSON.parse(columnValue);
}
```
Every type implements toString, matching DuckDB's type-to-string conversion.
```ts
const typeString = columnType.toString();
```
### Inspect Data Values

@@ -208,46 +207,106 @@

function valueToString(value, dataType) {
switch (dataType.typeId) {
case DuckDBTypeId.ARRAY:
return value
? `[${Array.from({ length: dataType.length }).map(
(_, i) => valueToString(value.getItem(i), dataType.valueType)
).join(', ')}]`
: 'null';
case DuckDBTypeId.DECIMAL:
return JSON.stringify(value, replacer);
case DuckDBTypeId.INTERVAL:
return JSON.stringify(value, replacer);
case DuckDBTypeId.LIST:
return value
? `[${Array.from({ length: value.itemCount }).map(
(_, i) => valueToString(value.getItem(i), dataType.valueType)
).join(', ')}]`
: 'null';
case DuckDBTypeId.MAP:
return value
? `{ ${value.map(
(entry) => `${valueToString(entry.key, dataType.keyType)}=${valueToString(entry.value, dataType.valueType)}`
).join(', ')} }`
: 'null';
case DuckDBTypeId.STRUCT:
return value
? `{ ${value.map(
(entry, i) => `'${entry.name.replace(`'`, `''`)}': ${valueToString(entry.value, dataType.entries[i].valueType)}`
).join(', ')} }`
: 'null';
case DuckDBTypeId.TIME_TZ:
return JSON.stringify(value, replacer);
case DuckDBTypeId.UNION:
return value
? valueToString(value.value, dataType.alternatives.find((alt) => alt.tag === value.tag).valueType)
: 'null';
default:
return String(value);
}
if (columnType.typeId === DuckDBTypeId.ARRAY) {
const arrayItems = columnValue.items; // array of values
const arrayString = columnValue.toString();
}
function replacer(key, value) {
return typeof value === "bigint" ? { $bigint: value.toString() } : value;
if (columnType.typeId === DuckDBTypeId.BIT) {
const bools = columnValue.toBools(); // array of booleans
const bits = columnValue.toBits(); // arrary of 0s and 1s
const bitString = columnValue.toString(); // string of '0's and '1's
}
if (columnType.typeId === DuckDBTypeId.BLOB) {
const blobBytes = columnValue.bytes; // Uint8Array
const blobString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.DATE) {
const dateDays = columnValue.days;
const dateString = columnValue.toString();
const { year, month, day } = columnValue.toParts();
}
if (columnType.typeId === DuckDBTypeId.DECIMAL) {
const decimalWidth = columnValue.width;
const decimalScale = columnValue.scale;
const decimalValue = columnValue.value; // bigint (Scaled-up value. Represented number is value/(10^scale).)
const decimalString = columnValue.toString();
const decimalDouble = columnValue.toDouble();
}
if (columnType.typeId === DuckDBTypeId.INTERVAL) {
const intervalMonths = columnValue.months;
const intervalDays = columnValue.days;
const intervalMicros = columnValue.micros; // bigint
const intervalString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.LIST) {
const listItems = columnValue.items; // array of values
const listString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.MAP) {
const mapEntries = columnValue.entries; // array of { key, value }
const mapString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.STRUCT) {
const structEntries = columnValue.entries; // { name1: value1, name2: value2, ... }
const structString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.TIMESTAMP_MS) {
const timestampMillis = columnValue.milliseconds; // bigint
const timestampMillisString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.TIMESTAMP_NS) {
const timestampNanos = columnValue.nanoseconds; // bigint
const timestampNanosString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.TIMESTAMP_S) {
const timestampSecs = columnValue.seconds; // bigint
const timestampSecsString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.TIMESTAMP_TZ) {
const timestampTZMicros = columnValue.micros; // bigint
const timestampTZString = columnValue.toString();
const { date: { year, month, day }, time: { hour, min, sec, micros } } = columnValue.toParts();
}
if (columnType.typeId === DuckDBTypeId.TIMESTAMP) {
const timestampMicros = columnValue.micros; // bigint
const timestampString = columnValue.toString();
const { date: { year, month, day }, time: { hour, min, sec, micros } } = columnValue.toParts();
}
if (columnType.typeId === DuckDBTypeId.TIME_TZ) {
const timeTZMicros = columnValue.micros; // bigint
const timeTZOffset = columnValue.offset;
const timeTZString = columnValue.toString();
const { time: { hour, min, sec, micros }, offset } = columnValue.toParts();
}
if (columnType.typeId === DuckDBTypeId.TIME) {
const timeMicros = columnValue.micros; // bigint
const timeString = columnValue.toString();
const { hour, min, sec, micros } = columnValue.toParts();
}
if (columnType.typeId === DuckDBTypeId.UNION) {
const unionTag = columnValue.tag;
const unionValue = columnValue.value;
const unionValueString = columnValue.toString();
}
if (columnType.typeId === DuckDBTypeId.UUID) {
const uuidHugeint = columnValue.hugeint; // bigint
const uuidString = columnValue.toString();
}
// other values are represented as null, boolean, number, bigint, or string
```

@@ -258,21 +317,21 @@

```ts
const createTableResult = await connection.run(`create or replace table target_table(i integer, v varchar)`);
createTableResult.dispose();
await connection.run(`create or replace table target_table(i integer, v varchar)`);
const appender = await connection.createAppender('main', 'target_table');
try {
appender.appendInteger(42);
appender.appendVarchar('duck');
appender.endRow();
appender.appendInteger(123);
appender.appendVarchar('mallard');
appender.endRow();
appender.flush();
appender.appendInteger(17);
appender.appendVarchar('goose');
appender.endRow();
appender.close(); // also flushes
} finally {
appender.dispose();
}
appender.appendInteger(42);
appender.appendVarchar('duck');
appender.endRow();
appender.appendInteger(123);
appender.appendVarchar('mallard');
appender.endRow();
appender.flush();
appender.appendInteger(17);
appender.appendVarchar('goose');
appender.endRow();
appender.close(); // also flushes
```

@@ -289,24 +348,15 @@

const parameterValues = [10, 7];
try {
const statementCount = extractedStatements.count;
for (let statementIndex = 0; statementIndex < statementCount; statementIndex++) {
const prepared = await extractedStatements.prepare(statementIndex);
try {
let parameterCount = prepared.parameterCount;
for (let parameterIndex = 1; parameterIndex <= parameterCount; parameterIndex++) {
prepared.bindInteger(parameterIndex, parameterValues.shift());
}
const result = await prepared.run();
// ...
result.dispose();
} finally {
prepared.dispose();
}
const statementCount = extractedStatements.count;
for (let statementIndex = 0; statementIndex < statementCount; statementIndex++) {
const prepared = await extractedStatements.prepare(statementIndex);
let parameterCount = prepared.parameterCount;
for (let parameterIndex = 1; parameterIndex <= parameterCount; parameterIndex++) {
prepared.bindInteger(parameterIndex, parameterValues.shift());
}
} finally {
extractedStatements.dispose();
const result = await prepared.run();
// ...
}
```
### Control Evaluation
### Control Evaluation of Tasks

@@ -323,19 +373,10 @@ ```ts

const prepared = await connection.prepare('from range(10_000_000)');
try {
const pending = prepared.start();
try {
while (pending.runTask() !== DuckDBPendingResultState.RESULT_READY) {
console.log('not ready');
await sleep(1);
}
console.log('ready');
const result = await pending.getResult();
// ...
result.dispose();
} finally {
pending.dispose();
}
} finally {
prepared.dispose();
const pending = prepared.start();
while (pending.runTask() !== DuckDBPendingResultState.RESULT_READY) {
console.log('not ready');
await sleep(1);
}
console.log('ready');
const result = await pending.getResult();
// ...
```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc