Skip to content

Commit c9721c2

Browse files
authored
Merge pull request #9 from duckdb/jray/implement-functions
implement (many) functions
2 parents b3cd67f + 6ae0bd7 commit c9721c2

19 files changed

+2287
-540
lines changed

bindings/pkgs/@duckdb/node-bindings/duckdb.d.ts

Lines changed: 107 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,85 @@
33
export const sizeof_bool: number;
44

55
export enum PendingState {
6-
RESULT_READY = 0,
7-
RESULT_NOT_READY = 1,
8-
ERROR = 2,
9-
NO_TASKS_AVAILABLE = 3,
6+
RESULT_READY = 0,
7+
RESULT_NOT_READY = 1,
8+
ERROR = 2,
9+
NO_TASKS_AVAILABLE = 3,
1010
}
1111

1212
export enum ResultType {
1313
INVALID = 0,
14-
CHANGED_ROWS = 1,
15-
NOTHING = 2,
16-
QUERY_RESULT = 3,
14+
CHANGED_ROWS = 1,
15+
NOTHING = 2,
16+
QUERY_RESULT = 3,
1717
}
1818

1919
export enum StatementType {
2020
INVALID = 0,
21-
SELECT = 1,
22-
INSERT = 2,
23-
UPDATE = 3,
24-
EXPLAIN = 4,
25-
DELETE = 5,
26-
PREPARE = 6,
27-
CREATE = 7,
28-
EXECUTE = 8,
29-
ALTER = 9,
30-
TRANSACTION = 10,
31-
COPY = 11,
32-
ANALYZE = 12,
33-
VARIABLE_SET = 13,
34-
CREATE_FUNC = 14,
35-
DROP = 15,
36-
EXPORT = 16,
37-
PRAGMA = 17,
38-
VACUUM = 18,
39-
CALL = 19,
40-
SET = 20,
41-
LOAD = 21,
42-
RELATION = 22,
43-
EXTENSION = 23,
44-
LOGICAL_PLAN = 24,
45-
ATTACH = 25,
46-
DETACH = 26,
47-
MULTI = 27,
21+
SELECT = 1,
22+
INSERT = 2,
23+
UPDATE = 3,
24+
EXPLAIN = 4,
25+
DELETE = 5,
26+
PREPARE = 6,
27+
CREATE = 7,
28+
EXECUTE = 8,
29+
ALTER = 9,
30+
TRANSACTION = 10,
31+
COPY = 11,
32+
ANALYZE = 12,
33+
VARIABLE_SET = 13,
34+
CREATE_FUNC = 14,
35+
DROP = 15,
36+
EXPORT = 16,
37+
PRAGMA = 17,
38+
VACUUM = 18,
39+
CALL = 19,
40+
SET = 20,
41+
LOAD = 21,
42+
RELATION = 22,
43+
EXTENSION = 23,
44+
LOGICAL_PLAN = 24,
45+
ATTACH = 25,
46+
DETACH = 26,
47+
MULTI = 27,
4848
}
4949

5050
export enum Type {
5151
INVALID = 0,
52-
BOOLEAN = 1,
53-
TINYINT = 2,
54-
SMALLINT = 3,
55-
INTEGER = 4,
56-
BIGINT = 5,
57-
UTINYINT = 6,
58-
USMALLINT = 7,
59-
UINTEGER = 8,
60-
UBIGINT = 9,
61-
FLOAT = 10,
62-
DOUBLE = 11,
63-
TIMESTAMP = 12,
64-
DATE = 13,
65-
TIME = 14,
66-
INTERVAL = 15,
67-
HUGEINT = 16,
68-
UHUGEINT = 32,
69-
VARCHAR = 17,
70-
BLOB = 18,
71-
DECIMAL = 19,
72-
TIMESTAMP_S = 20,
73-
TIMESTAMP_MS = 21,
74-
TIMESTAMP_NS = 22,
75-
ENUM = 23,
76-
LIST = 24,
77-
STRUCT = 25,
78-
MAP = 26,
79-
ARRAY = 33,
80-
UUID = 27,
81-
UNION = 28,
82-
BIT = 29,
83-
TIME_TZ = 30,
84-
TIMESTAMP_TZ = 31,
52+
BOOLEAN = 1,
53+
TINYINT = 2,
54+
SMALLINT = 3,
55+
INTEGER = 4,
56+
BIGINT = 5,
57+
UTINYINT = 6,
58+
USMALLINT = 7,
59+
UINTEGER = 8,
60+
UBIGINT = 9,
61+
FLOAT = 10,
62+
DOUBLE = 11,
63+
TIMESTAMP = 12,
64+
DATE = 13,
65+
TIME = 14,
66+
INTERVAL = 15,
67+
HUGEINT = 16,
68+
UHUGEINT = 32,
69+
VARCHAR = 17,
70+
BLOB = 18,
71+
DECIMAL = 19,
72+
TIMESTAMP_S = 20,
73+
TIMESTAMP_MS = 21,
74+
TIMESTAMP_NS = 22,
75+
ENUM = 23,
76+
LIST = 24,
77+
STRUCT = 25,
78+
MAP = 26,
79+
ARRAY = 33,
80+
UUID = 27,
81+
UNION = 28,
82+
BIT = 29,
83+
TIME_TZ = 30,
84+
TIMESTAMP_TZ = 31,
8585
}
8686

8787

@@ -98,21 +98,21 @@ export interface DateParts {
9898
}
9999

100100
export interface Decimal {
101-
width: number;
102-
scale: number;
103-
value: bigint;
101+
width: number;
102+
scale: number;
103+
value: bigint;
104104
}
105105

106106
export interface Interval {
107-
months: number;
108-
days: number;
109-
micros: bigint;
107+
months: number;
108+
days: number;
109+
micros: bigint;
110110
}
111111

112112
export interface QueryProgress {
113113
percentage: number;
114-
rows_processed: number;
115-
total_rows_to_process: number;
114+
rows_processed: bigint;
115+
total_rows_to_process: bigint;
116116
}
117117

118118
export interface Time {
@@ -127,71 +127,82 @@ export interface TimeParts {
127127
}
128128

129129
export interface TimeTZ {
130-
/** 40 bits for micros, 24 bits for offset */
131-
bits: number; // or bigint, or buffer?
130+
/**
131+
* 40 bits for micros, then 24 bits for encoded offset in seconds.
132+
*
133+
* Max absolute unencoded offset = 15:59:59 = 60 * (60 * 15 + 59) + 59 = 57599.
134+
*
135+
* Encoded offset is unencoded offset inverted then shifted (by +57599) to unsigned.
136+
*
137+
* Max unencoded offset = 57599 -> -57599 -> 0 encoded.
138+
*
139+
* Min unencoded offset = -57599 -> 57599 -> 115198 encoded.
140+
*/
141+
bits: bigint;
132142
}
133143
export interface TimeTZParts {
134144
time: TimeParts;
145+
/** Offset in seconds, from -15:59:59 = -57599 to 15:59:59 = 57599 */
135146
offset: number;
136147
}
137148

138149
export interface Timestamp {
139-
/** Microseconds since 1970-01-01 */
140-
micros: bigint;
150+
/** Microseconds since 1970-01-01 */
151+
micros: bigint;
141152
}
142153
export interface TimestampParts {
143-
date: DateParts;
144-
time: TimeParts;
154+
date: DateParts;
155+
time: TimeParts;
145156
}
146157

147158
export interface Vector {
148-
__duckdb_type: 'duckdb_vector';
159+
__duckdb_type: 'duckdb_vector';
149160
}
150161

151162
// Types (explicit destroy)
152163

153164
export interface Appender {
154-
__duckdb_type: 'duckdb_appender';
165+
__duckdb_type: 'duckdb_appender';
155166
}
156167

157168
export interface Config {
158-
__duckdb_type: 'duckdb_config';
169+
__duckdb_type: 'duckdb_config';
159170
}
160171

161172
export interface Connection {
162-
__duckdb_type: 'duckdb_connection';
173+
__duckdb_type: 'duckdb_connection';
163174
}
164175

165176
export interface Database {
166-
__duckdb_type: 'duckdb_database';
177+
__duckdb_type: 'duckdb_database';
167178
}
168179

169180
export interface DataChunk {
170-
__duckdb_type: 'duckdb_data_chunk';
181+
__duckdb_type: 'duckdb_data_chunk';
171182
}
172183

173184
export interface ExtractedStatements {
174-
__duckdb_type: 'duckdb_extracted_statements';
185+
__duckdb_type: 'duckdb_extracted_statements';
175186
}
176187

177188
export interface LogicalType {
178-
__duckdb_type: 'duckdb_logical_type';
189+
__duckdb_type: 'duckdb_logical_type';
179190
}
180191

181192
export interface PendingResult {
182-
__duckdb_type: 'duckdb_pending_result';
193+
__duckdb_type: 'duckdb_pending_result';
183194
}
184195

185196
export interface PreparedStatement {
186-
__duckdb_type: 'duckdb_config';
197+
__duckdb_type: 'duckdb_prepared_statement';
187198
}
188199

189200
export interface Result {
190-
__duckdb_type: 'duckdb_result';
201+
__duckdb_type: 'duckdb_result';
191202
}
192203

193204
export interface Value {
194-
__duckdb_type: 'duckdb_value';
205+
__duckdb_type: 'duckdb_value';
195206
}
196207

197208
// Types (TypeScript only)
@@ -202,8 +213,8 @@ export interface ConfigFlag {
202213
}
203214

204215
export interface ExtractedStatementsAndCount {
205-
extracted_statements: ExtractedStatements;
206-
statement_count: number;
216+
extracted_statements: ExtractedStatements;
217+
statement_count: number;
207218
}
208219

209220

@@ -659,7 +670,7 @@ export function vector_get_column_type(vector: Vector): LogicalType;
659670
export function vector_get_data(vector: Vector, byte_count: number): Uint8Array;
660671

661672
// DUCKDB_API uint64_t *duckdb_vector_get_validity(duckdb_vector vector);
662-
export function vector_get_validity(vector: Vector, byte_cunt: number): Uint8Array;
673+
export function vector_get_validity(vector: Vector, byte_count: number): Uint8Array;
663674

664675
// DUCKDB_API void duckdb_vector_ensure_validity_writable(duckdb_vector vector);
665676
export function vector_ensure_validity_writable(vector: Vector): void;

0 commit comments

Comments
 (0)