Skip to content

Commit

Permalink
Merge pull request #25 from duckdb/jray/update-duckdb-to-v1.1.1
Browse files Browse the repository at this point in the history
update duckdb to v1.1.1; add types & fix tests
  • Loading branch information
jraymakers authored Oct 13, 2024
2 parents 71937c0 + 82e91f2 commit 4e5d25c
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 96 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ node test.mjs
Expected output for above example:

```
v1.0.0
v1.1.1
[col 0] bool::BOOLEAN
[row 0] false
[row 1] true
Expand Down
9 changes: 9 additions & 0 deletions api/src/DuckDBLogicalType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import duckdb from '@duckdb/node-bindings';
import {
DuckDBAnyType,
DuckDBArrayType,
DuckDBBigIntType,
DuckDBBitType,
Expand All @@ -15,6 +16,7 @@ import {
DuckDBIntervalType,
DuckDBListType,
DuckDBMapType,
DuckDBSQLNullType,
DuckDBSmallIntType,
DuckDBStructType,
DuckDBTimeTZType,
Expand All @@ -34,6 +36,7 @@ import {
DuckDBUUIDType,
DuckDBUnionType,
DuckDBVarCharType,
DuckDBVarIntType,
} from './DuckDBType';
import { DuckDBTypeId } from './DuckDBTypeId';

Expand Down Expand Up @@ -204,6 +207,12 @@ export class DuckDBLogicalType {
return DuckDBTimeTZType.instance;
case DuckDBTypeId.TIMESTAMP_TZ:
return DuckDBTimestampTZType.instance;
case DuckDBTypeId.ANY:
return DuckDBAnyType.instance;
case DuckDBTypeId.VARINT:
return DuckDBVarIntType.instance;
case DuckDBTypeId.SQLNULL:
return DuckDBSQLNullType.instance;
default:
throw new Error(`Unexpected type id: ${this.typeId}`);
}
Expand Down
24 changes: 24 additions & 0 deletions api/src/DuckDBType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ export class DuckDBTimestampTZType extends BaseDuckDBType {
public static readonly instance = new DuckDBTimestampTZType();
}

export class DuckDBAnyType extends BaseDuckDBType {
private constructor() {
super(DuckDBTypeId.ANY);
}
public static readonly instance = new DuckDBAnyType();
}

export class DuckDBVarIntType extends BaseDuckDBType {
private constructor() {
super(DuckDBTypeId.VARINT);
}
public static readonly instance = new DuckDBVarIntType();
}

export class DuckDBSQLNullType extends BaseDuckDBType {
private constructor() {
super(DuckDBTypeId.SQLNULL);
}
public static readonly instance = new DuckDBSQLNullType();
}

export type DuckDBType =
| DuckDBBooleanType
| DuckDBTinyIntType
Expand Down Expand Up @@ -300,4 +321,7 @@ export type DuckDBType =
| DuckDBBitType
| DuckDBTimeTZType
| DuckDBTimestampTZType
| DuckDBAnyType
| DuckDBVarIntType
| DuckDBSQLNullType
;
3 changes: 3 additions & 0 deletions api/src/DuckDBTypeId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ export enum DuckDBTypeId {
BIT = 29,
TIME_TZ = 30,
TIMESTAMP_TZ = 31,
ANY = 34,
VARINT = 35,
SQLNULL = 36,
}
6 changes: 6 additions & 0 deletions api/src/DuckDBVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ export abstract class DuckDBVector<T> {
return DuckDBTimeTZVector.fromRawVector(vector, itemCount);
case DuckDBTypeId.TIMESTAMP_TZ:
return DuckDBTimestampVector.fromRawVector(vector, itemCount);
case DuckDBTypeId.ANY:
throw new Error(`Vector not implemented for ANY type`);
case DuckDBTypeId.VARINT:
return DuckDBBlobVector.fromRawVector(vector, itemCount); // TODO: VARINT
case DuckDBTypeId.SQLNULL:
throw new Error(`Vector not implemented for SQLNULL type`);
default:
throw new Error(`Invalid type id: ${vectorType.typeId}`);
}
Expand Down
111 changes: 67 additions & 44 deletions api/test/api.test.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bindings/pkgs/@duckdb/node-bindings/duckdb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export enum Type {
BIT = 29,
TIME_TZ = 30,
TIMESTAMP_TZ = 31,
ANY = 34,
VARINT = 35,
SQLNULL = 36,
}


Expand Down
2 changes: 1 addition & 1 deletion bindings/scripts/fetch_libduckdb_linux.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from fetch_libduckdb import fetch_libduckdb

zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-linux-amd64.zip"
zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.1.1/libduckdb-linux-amd64.zip"
output_dir = os.path.join(os.path.dirname(__file__), "..", "libduckdb")
files = [
"duckdb.h",
Expand Down
2 changes: 1 addition & 1 deletion bindings/scripts/fetch_libduckdb_mac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from fetch_libduckdb import fetch_libduckdb

zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-osx-universal.zip"
zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.1.1/libduckdb-osx-universal.zip"
output_dir = os.path.join(os.path.dirname(__file__), "..", "libduckdb")
files = [
"duckdb.h",
Expand Down
2 changes: 1 addition & 1 deletion bindings/scripts/fetch_libduckdb_win.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from fetch_libduckdb import fetch_libduckdb

zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-windows-amd64.zip"
zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.1.1/libduckdb-windows-amd64.zip"
output_dir = os.path.join(os.path.dirname(__file__), "..", "libduckdb")
files = [
"duckdb.h",
Expand Down
4 changes: 4 additions & 0 deletions bindings/src/duckdb_node_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,9 @@ Napi::Object CreateTypeEnum(Napi::Env env) {
DefineEnumMember(typeEnum, "BIT", 29);
DefineEnumMember(typeEnum, "TIME_TZ", 30);
DefineEnumMember(typeEnum, "TIMESTAMP_TZ", 31);
DefineEnumMember(typeEnum, "ANY", 34);
DefineEnumMember(typeEnum, "VARINT", 35);
DefineEnumMember(typeEnum, "SQLNULL", 36);
return typeEnum;
}

Expand Down Expand Up @@ -1095,6 +1098,7 @@ class DuckDBNodeAddon : public Napi::Addon<DuckDBNodeAddon> {
auto env = info.Env();
duckdb_config config;
if (duckdb_create_config(&config)) {
duckdb_destroy_config(&config);
throw Napi::Error::New(env, "Failed to create config");
}
return CreateExternalForConfig(env, config);
Expand Down
4 changes: 2 additions & 2 deletions bindings/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { expect, suite, test } from 'vitest';

suite('config', () => {
test('config_count', () => {
expect(duckdb.config_count()).toBe(78);
expect(duckdb.config_count()).toBe(100);
});
test('get_config_flag', () => {
expect(duckdb.get_config_flag(0).name).toBe('access_mode');
expect(duckdb.get_config_flag(77).name).toBe('http_logging_output');
expect(duckdb.get_config_flag(99).name).toBe('http_logging_output');
});
test('get_config_flag out of bounds', () => {
expect(() => duckdb.get_config_flag(-1)).toThrowError(/^Config option not found$/);
Expand Down
2 changes: 1 addition & 1 deletion bindings/test/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ suite('constants', () => {
expect(duckdb.sizeof_bool).toBe(1);
});
test('library_version', () => {
expect(duckdb.library_version()).toBe('v1.0.0');
expect(duckdb.library_version()).toBe('v1.1.1');
});
test('vector_size', () => {
expect(duckdb.vector_size()).toBe(2048);
Expand Down
2 changes: 1 addition & 1 deletion bindings/test/prepared_statements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ suite('prepared statements', () => {
expect(duckdb.param_type(prepared, 20)).toBe(duckdb.Type.BLOB);

duckdb.bind_null(prepared, 21);
expect(duckdb.param_type(prepared, 21)).toBe(duckdb.Type.INVALID);
expect(duckdb.param_type(prepared, 21)).toBe(duckdb.Type.SQLNULL);

const result = await duckdb.execute_prepared(prepared);
try {
Expand Down
Loading

0 comments on commit 4e5d25c

Please sign in to comment.