@avidian/duckdb-bun 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +284 -2
- package/package.json +95 -4
- package/src/bindings/api/appender.ts +288 -0
- package/src/bindings/api/data-chunk.ts +58 -0
- package/src/bindings/api/database.ts +232 -0
- package/src/bindings/api/datetime.ts +158 -0
- package/src/bindings/api/index.ts +13 -0
- package/src/bindings/api/logical-types.ts +227 -0
- package/src/bindings/api/query.ts +616 -0
- package/src/bindings/api/scalar-function.ts +274 -0
- package/src/bindings/api/table-function.ts +339 -0
- package/src/bindings/api/values.ts +546 -0
- package/src/bindings/api/vector.ts +266 -0
- package/src/bindings/generated/capi.ts +695 -0
- package/src/bindings/generated/contract.ts +162 -0
- package/src/bindings/index.ts +10 -0
- package/src/bindings/runtime/convert.ts +307 -0
- package/src/bindings/runtime/diagnostics.ts +45 -0
- package/src/bindings/runtime/dispatch.ts +200 -0
- package/src/bindings/runtime/exception.ts +103 -0
- package/src/bindings/runtime/flags.ts +19 -0
- package/src/bindings/runtime/handle.ts +217 -0
- package/src/bindings/runtime/kinds.ts +53 -0
- package/src/bindings/runtime/marshal.ts +190 -0
- package/src/bindings/runtime/native.ts +150 -0
- package/src/bindings/runtime/ring.ts +54 -0
- package/src/bindings/runtime/scope.ts +133 -0
- package/src/bindings/runtime/trace.ts +65 -0
- package/src/connection.ts +35 -0
- package/src/database.ts +27 -0
- package/src/errors.ts +30 -0
- package/src/file-assets.d.ts +10 -0
- package/src/index.ts +17 -0
- package/src/library.ts +83 -0
- package/src/neo.ts +16 -0
- package/src/reader.ts +47 -0
- package/src/statement.ts +61 -0
- package/src/types.ts +52 -0
- package/src/version.ts +6 -0
- package/vendor/node-api/LICENSE +7 -0
- package/vendor/node-api/PROVENANCE.md +54 -0
- package/vendor/node-api/node-bindings.d.ts +1669 -0
- package/vendor/node-api/src/DuckDBAppender.ts +237 -0
- package/vendor/node-api/src/DuckDBClientContext.ts +13 -0
- package/vendor/node-api/src/DuckDBConnection.ts +315 -0
- package/vendor/node-api/src/DuckDBDataChunk.ts +412 -0
- package/vendor/node-api/src/DuckDBDataChunkWriter.ts +144 -0
- package/vendor/node-api/src/DuckDBExtractedStatements.ts +37 -0
- package/vendor/node-api/src/DuckDBInstance.ts +35 -0
- package/vendor/node-api/src/DuckDBInstanceCache.ts +29 -0
- package/vendor/node-api/src/DuckDBLogicalType.ts +446 -0
- package/vendor/node-api/src/DuckDBMaterializedResult.ts +39 -0
- package/vendor/node-api/src/DuckDBPendingResult.ts +83 -0
- package/vendor/node-api/src/DuckDBPreparedStatement.ts +376 -0
- package/vendor/node-api/src/DuckDBPreparedStatementCollection.ts +5 -0
- package/vendor/node-api/src/DuckDBPreparedStatementWeakRefCollection.ts +31 -0
- package/vendor/node-api/src/DuckDBResult.ts +403 -0
- package/vendor/node-api/src/DuckDBResultReader.ts +283 -0
- package/vendor/node-api/src/DuckDBScalarFunction.ts +149 -0
- package/vendor/node-api/src/DuckDBScalarFunctionBindInfo.ts +34 -0
- package/vendor/node-api/src/DuckDBScalarFunctionInfo.ts +34 -0
- package/vendor/node-api/src/DuckDBScalarFunctionInitInfo.ts +35 -0
- package/vendor/node-api/src/DuckDBTableFunction.ts +149 -0
- package/vendor/node-api/src/DuckDBTableFunctionBindInfo.ts +56 -0
- package/vendor/node-api/src/DuckDBTableFunctionInfo.ts +36 -0
- package/vendor/node-api/src/DuckDBTableFunctionInitInfo.ts +52 -0
- package/vendor/node-api/src/DuckDBType.ts +1 -0
- package/vendor/node-api/src/DuckDBTypeId.ts +46 -0
- package/vendor/node-api/src/DuckDBValueConverter.ts +23 -0
- package/vendor/node-api/src/DuckDBValueConverters.ts +461 -0
- package/vendor/node-api/src/DuckDBVector.ts +1 -0
- package/vendor/node-api/src/JS.ts +11 -0
- package/vendor/node-api/src/JSDuckDBValueConverter.ts +85 -0
- package/vendor/node-api/src/JSInputTypeForTypeId.ts +101 -0
- package/vendor/node-api/src/JSToDuckDBValueConverter.ts +136 -0
- package/vendor/node-api/src/JSTypeForTypeId.ts +78 -0
- package/vendor/node-api/src/Json.ts +7 -0
- package/vendor/node-api/src/JsonDuckDBValueConverter.ts +72 -0
- package/vendor/node-api/src/JsonTypeForTypeId.ts +86 -0
- package/vendor/node-api/src/ToDuckDBValueConverter.ts +68 -0
- package/vendor/node-api/src/ToDuckDBValueConverters.ts +303 -0
- package/vendor/node-api/src/configurationOptionDescriptions.ts +13 -0
- package/vendor/node-api/src/conversion/bytesFromString.ts +5 -0
- package/vendor/node-api/src/conversion/dateTimeStringConversion.ts +343 -0
- package/vendor/node-api/src/conversion/displayStringForDuckDBValue.ts +12 -0
- package/vendor/node-api/src/conversion/stringFromBlob.ts +48 -0
- package/vendor/node-api/src/conversion/stringFromDecimal.ts +129 -0
- package/vendor/node-api/src/conversion/varintDecode.ts +42 -0
- package/vendor/node-api/src/convertColumnsFromChunks.ts +28 -0
- package/vendor/node-api/src/convertColumnsObjectFromChunks.ts +29 -0
- package/vendor/node-api/src/convertRowObjectsFromChunks.ts +21 -0
- package/vendor/node-api/src/convertRowsFromChunks.ts +16 -0
- package/vendor/node-api/src/createConfig.ts +14 -0
- package/vendor/node-api/src/createDuckDBValueConverter.ts +17 -0
- package/vendor/node-api/src/createResult.ts +15 -0
- package/vendor/node-api/src/createValue.ts +355 -0
- package/vendor/node-api/src/duckdb.ts +51 -0
- package/vendor/node-api/src/enums.ts +7 -0
- package/vendor/node-api/src/getColumnsFromChunks.ts +13 -0
- package/vendor/node-api/src/getColumnsObjectFromChunks.ts +16 -0
- package/vendor/node-api/src/getRowObjectsFromChunks.ts +13 -0
- package/vendor/node-api/src/getRowsFromChunks.ts +12 -0
- package/vendor/node-api/src/index.ts +3 -0
- package/vendor/node-api/src/readValue.ts +31 -0
- package/vendor/node-api/src/sleep.ts +5 -0
- package/vendor/node-api/src/sql.ts +7 -0
- package/vendor/node-api/src/tsconfig.json +7 -0
- package/vendor/node-api/src/typeForValue.ts +144 -0
- package/vendor/node-api/src/types/BaseDuckDBType.ts +31 -0
- package/vendor/node-api/src/types/DuckDBAnyType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBArrayType.ts +43 -0
- package/vendor/node-api/src/types/DuckDBBigIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBBigNumType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBBitType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBBlobType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBBooleanType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBDateType.ts +29 -0
- package/vendor/node-api/src/types/DuckDBDecimalType.ts +46 -0
- package/vendor/node-api/src/types/DuckDBDoubleType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBEnumType.ts +111 -0
- package/vendor/node-api/src/types/DuckDBFloatType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBGeometryType.ts +36 -0
- package/vendor/node-api/src/types/DuckDBHugeIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBIntegerLiteralType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBIntegerType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBIntervalType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBListType.ts +35 -0
- package/vendor/node-api/src/types/DuckDBMapType.ts +47 -0
- package/vendor/node-api/src/types/DuckDBSQLNullType.ts +17 -0
- package/vendor/node-api/src/types/DuckDBSmallIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBStringLiteralType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBStructType.ts +104 -0
- package/vendor/node-api/src/types/DuckDBTimeNSType.ts +20 -0
- package/vendor/node-api/src/types/DuckDBTimeTZType.ts +23 -0
- package/vendor/node-api/src/types/DuckDBTimeType.ts +20 -0
- package/vendor/node-api/src/types/DuckDBTimestampMillisecondsType.ts +29 -0
- package/vendor/node-api/src/types/DuckDBTimestampNanosecondsType.ts +29 -0
- package/vendor/node-api/src/types/DuckDBTimestampSecondsType.ts +29 -0
- package/vendor/node-api/src/types/DuckDBTimestampTZNanosecondsType.ts +32 -0
- package/vendor/node-api/src/types/DuckDBTimestampTZType.ts +32 -0
- package/vendor/node-api/src/types/DuckDBTimestampType.ts +32 -0
- package/vendor/node-api/src/types/DuckDBTinyIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBType.ts +86 -0
- package/vendor/node-api/src/types/DuckDBUBigIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBUHugeIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBUIntegerType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBUSmallIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBUTinyIntType.ts +21 -0
- package/vendor/node-api/src/types/DuckDBUUIDType.ts +20 -0
- package/vendor/node-api/src/types/DuckDBUnionType.ts +74 -0
- package/vendor/node-api/src/types/DuckDBVarCharType.ts +13 -0
- package/vendor/node-api/src/types/DuckDBVariantType.ts +13 -0
- package/vendor/node-api/src/types/index.ts +44 -0
- package/vendor/node-api/src/values/DuckDBArrayValue.ts +18 -0
- package/vendor/node-api/src/values/DuckDBBitValue.ts +117 -0
- package/vendor/node-api/src/values/DuckDBBlobValue.ts +26 -0
- package/vendor/node-api/src/values/DuckDBDateValue.ts +43 -0
- package/vendor/node-api/src/values/DuckDBDecimalValue.ts +44 -0
- package/vendor/node-api/src/values/DuckDBGeometryValue.ts +30 -0
- package/vendor/node-api/src/values/DuckDBIntervalValue.ts +22 -0
- package/vendor/node-api/src/values/DuckDBListValue.ts +18 -0
- package/vendor/node-api/src/values/DuckDBMapValue.ts +25 -0
- package/vendor/node-api/src/values/DuckDBStructValue.ts +22 -0
- package/vendor/node-api/src/values/DuckDBTimeNSValue.ts +23 -0
- package/vendor/node-api/src/values/DuckDBTimeTZValue.ts +96 -0
- package/vendor/node-api/src/values/DuckDBTimeValue.ts +34 -0
- package/vendor/node-api/src/values/DuckDBTimestampMillisecondsValue.ts +29 -0
- package/vendor/node-api/src/values/DuckDBTimestampNanosecondsValue.ts +28 -0
- package/vendor/node-api/src/values/DuckDBTimestampSecondsValue.ts +28 -0
- package/vendor/node-api/src/values/DuckDBTimestampTZNanosecondsValue.ts +44 -0
- package/vendor/node-api/src/values/DuckDBTimestampTZValue.ts +54 -0
- package/vendor/node-api/src/values/DuckDBTimestampValue.ts +45 -0
- package/vendor/node-api/src/values/DuckDBTupleValue.ts +22 -0
- package/vendor/node-api/src/values/DuckDBUUIDValue.ts +48 -0
- package/vendor/node-api/src/values/DuckDBUnionValue.ts +22 -0
- package/vendor/node-api/src/values/DuckDBValue.ts +53 -0
- package/vendor/node-api/src/values/DuckDBVariantValue.ts +34 -0
- package/vendor/node-api/src/values/index.ts +24 -0
- package/vendor/node-api/src/vectors/DuckDBArrayVector.ts +107 -0
- package/vendor/node-api/src/vectors/DuckDBBigIntVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBBigNumVector.ts +98 -0
- package/vendor/node-api/src/vectors/DuckDBBitVector.ts +102 -0
- package/vendor/node-api/src/vectors/DuckDBBlobVector.ts +112 -0
- package/vendor/node-api/src/vectors/DuckDBBooleanVector.ts +84 -0
- package/vendor/node-api/src/vectors/DuckDBDateVector.ts +80 -0
- package/vendor/node-api/src/vectors/DuckDBDecimal128Vector.ts +107 -0
- package/vendor/node-api/src/vectors/DuckDBDecimal16Vector.ts +104 -0
- package/vendor/node-api/src/vectors/DuckDBDecimal32Vector.ts +104 -0
- package/vendor/node-api/src/vectors/DuckDBDecimal64Vector.ts +104 -0
- package/vendor/node-api/src/vectors/DuckDBDoubleVector.ts +68 -0
- package/vendor/node-api/src/vectors/DuckDBEnum16Vector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBEnum32Vector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBEnum8Vector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBFloatVector.ts +68 -0
- package/vendor/node-api/src/vectors/DuckDBGeometryVector.ts +97 -0
- package/vendor/node-api/src/vectors/DuckDBHugeIntVector.ts +89 -0
- package/vendor/node-api/src/vectors/DuckDBIntegerVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBIntervalVector.ts +100 -0
- package/vendor/node-api/src/vectors/DuckDBListVector.ts +221 -0
- package/vendor/node-api/src/vectors/DuckDBMapVector.ts +88 -0
- package/vendor/node-api/src/vectors/DuckDBSQLNullVector.ts +53 -0
- package/vendor/node-api/src/vectors/DuckDBSmallIntVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBStructVector.ts +138 -0
- package/vendor/node-api/src/vectors/DuckDBTimeNSVector.ts +80 -0
- package/vendor/node-api/src/vectors/DuckDBTimeTZVector.ts +80 -0
- package/vendor/node-api/src/vectors/DuckDBTimeVector.ts +80 -0
- package/vendor/node-api/src/vectors/DuckDBTimestampMillisecondsVector.ts +88 -0
- package/vendor/node-api/src/vectors/DuckDBTimestampNanosecondsVector.ts +88 -0
- package/vendor/node-api/src/vectors/DuckDBTimestampSecondsVector.ts +88 -0
- package/vendor/node-api/src/vectors/DuckDBTimestampTZNanosecondsVector.ts +88 -0
- package/vendor/node-api/src/vectors/DuckDBTimestampTZVector.ts +86 -0
- package/vendor/node-api/src/vectors/DuckDBTimestampVector.ts +83 -0
- package/vendor/node-api/src/vectors/DuckDBTinyIntVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBTupleVector.ts +125 -0
- package/vendor/node-api/src/vectors/DuckDBUBigIntVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBUHugeIntVector.ts +89 -0
- package/vendor/node-api/src/vectors/DuckDBUIntegerVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBUSmallIntVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBUTinyIntVector.ts +75 -0
- package/vendor/node-api/src/vectors/DuckDBUUIDVector.ts +89 -0
- package/vendor/node-api/src/vectors/DuckDBUnionVector.ts +84 -0
- package/vendor/node-api/src/vectors/DuckDBValidity.ts +104 -0
- package/vendor/node-api/src/vectors/DuckDBVarCharVector.ts +100 -0
- package/vendor/node-api/src/vectors/DuckDBVariantVector.ts +609 -0
- package/vendor/node-api/src/vectors/DuckDBVector.ts +33 -0
- package/vendor/node-api/src/vectors/createVector.ts +269 -0
- package/vendor/node-api/src/vectors/dataAccessors.ts +387 -0
- package/vendor/node-api/src/vectors/index.ts +50 -0
- package/vendor/node-api/src/vectors/vectorRegistry.ts +24 -0
- package/vendor/node-api/src/version.ts +5 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
3
|
+
import { DuckDBScalarFunctionBindInfo } from './DuckDBScalarFunctionBindInfo';
|
|
4
|
+
import { DuckDBScalarFunctionInfo } from './DuckDBScalarFunctionInfo';
|
|
5
|
+
import { DuckDBScalarFunctionInitInfo } from './DuckDBScalarFunctionInitInfo';
|
|
6
|
+
import { DuckDBType } from './DuckDBType';
|
|
7
|
+
import { DuckDBVector } from './DuckDBVector';
|
|
8
|
+
|
|
9
|
+
export type DuckDBScalarBindFunction = (bindInfo: DuckDBScalarFunctionBindInfo) => void;
|
|
10
|
+
|
|
11
|
+
export type DuckDBScalarInitFunction = (
|
|
12
|
+
initInfo: DuckDBScalarFunctionInitInfo,
|
|
13
|
+
) => void;
|
|
14
|
+
|
|
15
|
+
export type DuckDBScalarMainFunction = (
|
|
16
|
+
functionInfo: DuckDBScalarFunctionInfo,
|
|
17
|
+
inputDataChunk: DuckDBDataChunk,
|
|
18
|
+
outputVector: DuckDBVector,
|
|
19
|
+
) => void;
|
|
20
|
+
|
|
21
|
+
export class DuckDBScalarFunction {
|
|
22
|
+
readonly scalar_function: duckdb.ScalarFunction;
|
|
23
|
+
|
|
24
|
+
public constructor() {
|
|
25
|
+
this.scalar_function = duckdb.create_scalar_function();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static create({
|
|
29
|
+
name,
|
|
30
|
+
bindFunction,
|
|
31
|
+
initFunction,
|
|
32
|
+
mainFunction,
|
|
33
|
+
returnType,
|
|
34
|
+
parameterTypes,
|
|
35
|
+
varArgsType,
|
|
36
|
+
specialHandling,
|
|
37
|
+
volatile,
|
|
38
|
+
extraInfo,
|
|
39
|
+
}: {
|
|
40
|
+
name: string;
|
|
41
|
+
bindFunction?: DuckDBScalarBindFunction;
|
|
42
|
+
initFunction?: DuckDBScalarInitFunction;
|
|
43
|
+
mainFunction: DuckDBScalarMainFunction;
|
|
44
|
+
returnType: DuckDBType;
|
|
45
|
+
parameterTypes?: readonly DuckDBType[];
|
|
46
|
+
varArgsType?: DuckDBType;
|
|
47
|
+
specialHandling?: boolean;
|
|
48
|
+
volatile?: boolean;
|
|
49
|
+
extraInfo?: object;
|
|
50
|
+
}): DuckDBScalarFunction {
|
|
51
|
+
const scalarFunction = new DuckDBScalarFunction();
|
|
52
|
+
scalarFunction.setName(name);
|
|
53
|
+
if (bindFunction) {
|
|
54
|
+
scalarFunction.setBindFunction(bindFunction);
|
|
55
|
+
}
|
|
56
|
+
if (initFunction) {
|
|
57
|
+
scalarFunction.setInitFunction(initFunction);
|
|
58
|
+
}
|
|
59
|
+
scalarFunction.setMainFunction(mainFunction);
|
|
60
|
+
scalarFunction.setReturnType(returnType);
|
|
61
|
+
if (parameterTypes) {
|
|
62
|
+
for (const parameterType of parameterTypes) {
|
|
63
|
+
scalarFunction.addParameter(parameterType);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (varArgsType) {
|
|
67
|
+
scalarFunction.setVarArgs(varArgsType);
|
|
68
|
+
}
|
|
69
|
+
if (specialHandling) {
|
|
70
|
+
scalarFunction.setSpecialHandling();
|
|
71
|
+
}
|
|
72
|
+
if (volatile) {
|
|
73
|
+
scalarFunction.setVolatile();
|
|
74
|
+
}
|
|
75
|
+
if (extraInfo) {
|
|
76
|
+
scalarFunction.setExtraInfo(extraInfo);
|
|
77
|
+
}
|
|
78
|
+
return scalarFunction;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public destroySync() {
|
|
82
|
+
duckdb.destroy_scalar_function_sync(this.scalar_function);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public setName(name: string) {
|
|
86
|
+
duckdb.scalar_function_set_name(this.scalar_function, name);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public setBindFunction(bindFunction: DuckDBScalarBindFunction) {
|
|
90
|
+
duckdb.scalar_function_set_bind(this.scalar_function, (info) => {
|
|
91
|
+
const bindInfo = new DuckDBScalarFunctionBindInfo(info);
|
|
92
|
+
bindFunction(bindInfo);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public setInitFunction(initFunction: DuckDBScalarInitFunction) {
|
|
97
|
+
duckdb.scalar_function_set_init(this.scalar_function, (info) => {
|
|
98
|
+
initFunction(new DuckDBScalarFunctionInitInfo(info));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public setMainFunction(mainFunction: DuckDBScalarMainFunction) {
|
|
103
|
+
duckdb.scalar_function_set_function(
|
|
104
|
+
this.scalar_function,
|
|
105
|
+
(info, input, output) => {
|
|
106
|
+
const functionInfo = new DuckDBScalarFunctionInfo(info);
|
|
107
|
+
const inputDataChunk = new DuckDBDataChunk(input);
|
|
108
|
+
const outputVector = DuckDBVector.create(
|
|
109
|
+
output,
|
|
110
|
+
inputDataChunk.rowCount,
|
|
111
|
+
);
|
|
112
|
+
mainFunction(functionInfo, inputDataChunk, outputVector);
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public setReturnType(returnType: DuckDBType) {
|
|
118
|
+
duckdb.scalar_function_set_return_type(
|
|
119
|
+
this.scalar_function,
|
|
120
|
+
returnType.toLogicalType().logical_type,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public addParameter(parameterType: DuckDBType) {
|
|
125
|
+
duckdb.scalar_function_add_parameter(
|
|
126
|
+
this.scalar_function,
|
|
127
|
+
parameterType.toLogicalType().logical_type,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public setVarArgs(varArgsType: DuckDBType) {
|
|
132
|
+
duckdb.scalar_function_set_varargs(
|
|
133
|
+
this.scalar_function,
|
|
134
|
+
varArgsType.toLogicalType().logical_type,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public setSpecialHandling() {
|
|
139
|
+
duckdb.scalar_function_set_special_handling(this.scalar_function);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public setVolatile() {
|
|
143
|
+
duckdb.scalar_function_set_volatile(this.scalar_function);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public setExtraInfo(extraInfo: object) {
|
|
147
|
+
duckdb.scalar_function_set_extra_info(this.scalar_function, extraInfo);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
|
+
|
|
4
|
+
export class DuckDBScalarFunctionBindInfo {
|
|
5
|
+
private readonly bind_info: duckdb.ScalarFunctionBindInfo;
|
|
6
|
+
constructor(bind_info: duckdb.ScalarFunctionBindInfo) {
|
|
7
|
+
this.bind_info = bind_info;
|
|
8
|
+
}
|
|
9
|
+
public get clientContext(): DuckDBClientContext {
|
|
10
|
+
return this.getClientContext();
|
|
11
|
+
}
|
|
12
|
+
public getClientContext(): DuckDBClientContext {
|
|
13
|
+
return new DuckDBClientContext(
|
|
14
|
+
duckdb.scalar_function_get_client_context(this.bind_info),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
public get extraInfo(): object | undefined {
|
|
18
|
+
return this.getExtraInfo();
|
|
19
|
+
}
|
|
20
|
+
public getExtraInfo(): object | undefined {
|
|
21
|
+
return duckdb.scalar_function_bind_get_extra_info(this.bind_info);
|
|
22
|
+
}
|
|
23
|
+
public setBindData(bindData: object) {
|
|
24
|
+
duckdb.scalar_function_set_bind_data(this.bind_info, bindData);
|
|
25
|
+
}
|
|
26
|
+
public setError(error: string) {
|
|
27
|
+
duckdb.scalar_function_bind_set_error(this.bind_info, error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @deprecated Renamed to DuckDBScalarFunctionBindInfo. */
|
|
32
|
+
export const DuckDBBindInfo = DuckDBScalarFunctionBindInfo;
|
|
33
|
+
/** @deprecated Renamed to DuckDBScalarFunctionBindInfo. */
|
|
34
|
+
export type DuckDBBindInfo = DuckDBScalarFunctionBindInfo;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
|
|
3
|
+
export class DuckDBScalarFunctionInfo {
|
|
4
|
+
private readonly function_info: duckdb.ScalarFunctionInfo;
|
|
5
|
+
constructor(function_info: duckdb.ScalarFunctionInfo) {
|
|
6
|
+
this.function_info = function_info;
|
|
7
|
+
}
|
|
8
|
+
public get bindData(): object | undefined {
|
|
9
|
+
return this.getBindData();
|
|
10
|
+
}
|
|
11
|
+
public getBindData(): object | undefined {
|
|
12
|
+
return duckdb.scalar_function_get_bind_data(this.function_info);
|
|
13
|
+
}
|
|
14
|
+
public get extraInfo(): object | undefined {
|
|
15
|
+
return this.getExtraInfo();
|
|
16
|
+
}
|
|
17
|
+
public getExtraInfo(): object | undefined {
|
|
18
|
+
return duckdb.scalar_function_get_extra_info(this.function_info);
|
|
19
|
+
}
|
|
20
|
+
public get state(): object | undefined {
|
|
21
|
+
return this.getState();
|
|
22
|
+
}
|
|
23
|
+
public getState(): object | undefined {
|
|
24
|
+
return duckdb.scalar_function_get_state(this.function_info);
|
|
25
|
+
}
|
|
26
|
+
public setError(error: string) {
|
|
27
|
+
duckdb.scalar_function_set_error(this.function_info, error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @deprecated Renamed to DuckDBScalarFunctionInfo. */
|
|
32
|
+
export const DuckDBFunctionInfo = DuckDBScalarFunctionInfo;
|
|
33
|
+
/** @deprecated Renamed to DuckDBScalarFunctionInfo. */
|
|
34
|
+
export type DuckDBFunctionInfo = DuckDBScalarFunctionInfo;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
|
+
|
|
4
|
+
export class DuckDBScalarFunctionInitInfo {
|
|
5
|
+
private readonly init_info: duckdb.ScalarFunctionInitInfo;
|
|
6
|
+
constructor(init_info: duckdb.ScalarFunctionInitInfo) {
|
|
7
|
+
this.init_info = init_info;
|
|
8
|
+
}
|
|
9
|
+
public get clientContext(): DuckDBClientContext {
|
|
10
|
+
return this.getClientContext();
|
|
11
|
+
}
|
|
12
|
+
public getClientContext(): DuckDBClientContext {
|
|
13
|
+
return new DuckDBClientContext(
|
|
14
|
+
duckdb.scalar_function_init_get_client_context(this.init_info),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
public get extraInfo(): object | undefined {
|
|
18
|
+
return this.getExtraInfo();
|
|
19
|
+
}
|
|
20
|
+
public getExtraInfo(): object | undefined {
|
|
21
|
+
return duckdb.scalar_function_init_get_extra_info(this.init_info);
|
|
22
|
+
}
|
|
23
|
+
public get bindData(): object | undefined {
|
|
24
|
+
return this.getBindData();
|
|
25
|
+
}
|
|
26
|
+
public getBindData(): object | undefined {
|
|
27
|
+
return duckdb.scalar_function_init_get_bind_data(this.init_info);
|
|
28
|
+
}
|
|
29
|
+
public setState(state: object) {
|
|
30
|
+
duckdb.scalar_function_init_set_state(this.init_info, state);
|
|
31
|
+
}
|
|
32
|
+
public setError(error: string) {
|
|
33
|
+
duckdb.scalar_function_init_set_error(this.init_info, error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
3
|
+
import { DuckDBTableFunctionBindInfo } from './DuckDBTableFunctionBindInfo';
|
|
4
|
+
import { DuckDBTableFunctionInfo } from './DuckDBTableFunctionInfo';
|
|
5
|
+
import { DuckDBTableFunctionInitInfo } from './DuckDBTableFunctionInitInfo';
|
|
6
|
+
import { DuckDBType } from './DuckDBType';
|
|
7
|
+
|
|
8
|
+
export type DuckDBTableBindFunction = (
|
|
9
|
+
bindInfo: DuckDBTableFunctionBindInfo,
|
|
10
|
+
) => void;
|
|
11
|
+
|
|
12
|
+
export type DuckDBTableInitFunction = (
|
|
13
|
+
initInfo: DuckDBTableFunctionInitInfo,
|
|
14
|
+
) => void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Produces one chunk of the scan per call.
|
|
18
|
+
*
|
|
19
|
+
* Set `outputDataChunk.rowCount` before writing, then write that many rows to
|
|
20
|
+
* each column vector. A row count of zero reports that the scan is finished, so
|
|
21
|
+
* a function that never sets zero never terminates.
|
|
22
|
+
*/
|
|
23
|
+
export type DuckDBTableMainFunction = (
|
|
24
|
+
functionInfo: DuckDBTableFunctionInfo,
|
|
25
|
+
outputDataChunk: DuckDBDataChunk,
|
|
26
|
+
) => void;
|
|
27
|
+
|
|
28
|
+
export class DuckDBTableFunction {
|
|
29
|
+
readonly table_function: duckdb.TableFunction;
|
|
30
|
+
|
|
31
|
+
public constructor() {
|
|
32
|
+
this.table_function = duckdb.create_table_function();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public static create({
|
|
36
|
+
name,
|
|
37
|
+
bindFunction,
|
|
38
|
+
initFunction,
|
|
39
|
+
localInitFunction,
|
|
40
|
+
mainFunction,
|
|
41
|
+
parameterTypes,
|
|
42
|
+
namedParameterTypes,
|
|
43
|
+
supportsProjectionPushdown,
|
|
44
|
+
extraInfo,
|
|
45
|
+
}: {
|
|
46
|
+
name: string;
|
|
47
|
+
bindFunction: DuckDBTableBindFunction;
|
|
48
|
+
initFunction: DuckDBTableInitFunction;
|
|
49
|
+
localInitFunction?: DuckDBTableInitFunction;
|
|
50
|
+
mainFunction: DuckDBTableMainFunction;
|
|
51
|
+
parameterTypes?: readonly DuckDBType[];
|
|
52
|
+
namedParameterTypes?: Readonly<Record<string, DuckDBType>>;
|
|
53
|
+
supportsProjectionPushdown?: boolean;
|
|
54
|
+
extraInfo?: object;
|
|
55
|
+
}): DuckDBTableFunction {
|
|
56
|
+
const tableFunction = new DuckDBTableFunction();
|
|
57
|
+
tableFunction.setName(name);
|
|
58
|
+
tableFunction.setBindFunction(bindFunction);
|
|
59
|
+
tableFunction.setInitFunction(initFunction);
|
|
60
|
+
if (localInitFunction) {
|
|
61
|
+
tableFunction.setLocalInitFunction(localInitFunction);
|
|
62
|
+
}
|
|
63
|
+
tableFunction.setMainFunction(mainFunction);
|
|
64
|
+
if (parameterTypes) {
|
|
65
|
+
for (const parameterType of parameterTypes) {
|
|
66
|
+
tableFunction.addParameter(parameterType);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (namedParameterTypes) {
|
|
70
|
+
for (const [
|
|
71
|
+
parameterName,
|
|
72
|
+
parameterType,
|
|
73
|
+
] of Object.entries(namedParameterTypes)) {
|
|
74
|
+
tableFunction.addNamedParameter(parameterName, parameterType);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (supportsProjectionPushdown) {
|
|
78
|
+
tableFunction.setSupportsProjectionPushdown(true);
|
|
79
|
+
}
|
|
80
|
+
if (extraInfo) {
|
|
81
|
+
tableFunction.setExtraInfo(extraInfo);
|
|
82
|
+
}
|
|
83
|
+
return tableFunction;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public destroySync() {
|
|
87
|
+
duckdb.destroy_table_function_sync(this.table_function);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public setName(name: string) {
|
|
91
|
+
duckdb.table_function_set_name(this.table_function, name);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public setBindFunction(bindFunction: DuckDBTableBindFunction) {
|
|
95
|
+
duckdb.table_function_set_bind(this.table_function, (info) => {
|
|
96
|
+
bindFunction(new DuckDBTableFunctionBindInfo(info));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public setInitFunction(initFunction: DuckDBTableInitFunction) {
|
|
101
|
+
duckdb.table_function_set_init(this.table_function, (info) => {
|
|
102
|
+
initFunction(new DuckDBTableFunctionInitInfo(info));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public setLocalInitFunction(localInitFunction: DuckDBTableInitFunction) {
|
|
107
|
+
duckdb.table_function_set_local_init(this.table_function, (info) => {
|
|
108
|
+
localInitFunction(new DuckDBTableFunctionInitInfo(info));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public setMainFunction(mainFunction: DuckDBTableMainFunction) {
|
|
113
|
+
duckdb.table_function_set_function(
|
|
114
|
+
this.table_function,
|
|
115
|
+
(info, output) => {
|
|
116
|
+
mainFunction(
|
|
117
|
+
new DuckDBTableFunctionInfo(info),
|
|
118
|
+
new DuckDBDataChunk(output),
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public addParameter(parameterType: DuckDBType) {
|
|
125
|
+
duckdb.table_function_add_parameter(
|
|
126
|
+
this.table_function,
|
|
127
|
+
parameterType.toLogicalType().logical_type,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public addNamedParameter(name: string, parameterType: DuckDBType) {
|
|
132
|
+
duckdb.table_function_add_named_parameter(
|
|
133
|
+
this.table_function,
|
|
134
|
+
name,
|
|
135
|
+
parameterType.toLogicalType().logical_type,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public setSupportsProjectionPushdown(pushdown: boolean) {
|
|
140
|
+
duckdb.table_function_supports_projection_pushdown(
|
|
141
|
+
this.table_function,
|
|
142
|
+
pushdown,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public setExtraInfo(extraInfo: object) {
|
|
147
|
+
duckdb.table_function_set_extra_info(this.table_function, extraInfo);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
|
+
import { DuckDBType } from './DuckDBType';
|
|
4
|
+
import { readValue } from './readValue';
|
|
5
|
+
import { DuckDBValue } from './values';
|
|
6
|
+
|
|
7
|
+
export class DuckDBTableFunctionBindInfo {
|
|
8
|
+
private readonly bind_info: duckdb.TableFunctionBindInfo;
|
|
9
|
+
constructor(bind_info: duckdb.TableFunctionBindInfo) {
|
|
10
|
+
this.bind_info = bind_info;
|
|
11
|
+
}
|
|
12
|
+
public get clientContext(): DuckDBClientContext {
|
|
13
|
+
return this.getClientContext();
|
|
14
|
+
}
|
|
15
|
+
public getClientContext(): DuckDBClientContext {
|
|
16
|
+
return new DuckDBClientContext(
|
|
17
|
+
duckdb.table_function_get_client_context(this.bind_info),
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
public get extraInfo(): object | undefined {
|
|
21
|
+
return this.getExtraInfo();
|
|
22
|
+
}
|
|
23
|
+
public getExtraInfo(): object | undefined {
|
|
24
|
+
return duckdb.bind_get_extra_info(this.bind_info);
|
|
25
|
+
}
|
|
26
|
+
public get parameterCount(): number {
|
|
27
|
+
return this.getParameterCount();
|
|
28
|
+
}
|
|
29
|
+
public getParameterCount(): number {
|
|
30
|
+
return duckdb.bind_get_parameter_count(this.bind_info);
|
|
31
|
+
}
|
|
32
|
+
public getParameter(index: number): DuckDBValue {
|
|
33
|
+
return readValue(duckdb.bind_get_parameter(this.bind_info, index));
|
|
34
|
+
}
|
|
35
|
+
/** Returns null if no parameter with this name was supplied. */
|
|
36
|
+
public getNamedParameter(name: string): DuckDBValue | null {
|
|
37
|
+
const value = duckdb.bind_get_named_parameter(this.bind_info, name);
|
|
38
|
+
return value === null ? null : readValue(value);
|
|
39
|
+
}
|
|
40
|
+
public addResultColumn(name: string, type: DuckDBType) {
|
|
41
|
+
duckdb.bind_add_result_column(
|
|
42
|
+
this.bind_info,
|
|
43
|
+
name,
|
|
44
|
+
type.toLogicalType().logical_type,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
public setBindData(bindData: object) {
|
|
48
|
+
duckdb.bind_set_bind_data(this.bind_info, bindData);
|
|
49
|
+
}
|
|
50
|
+
public setCardinality(cardinality: number, isExact: boolean) {
|
|
51
|
+
duckdb.bind_set_cardinality(this.bind_info, cardinality, isExact);
|
|
52
|
+
}
|
|
53
|
+
public setError(error: string) {
|
|
54
|
+
duckdb.bind_set_error(this.bind_info, error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
|
|
3
|
+
export class DuckDBTableFunctionInfo {
|
|
4
|
+
private readonly function_info: duckdb.TableFunctionInfo;
|
|
5
|
+
constructor(function_info: duckdb.TableFunctionInfo) {
|
|
6
|
+
this.function_info = function_info;
|
|
7
|
+
}
|
|
8
|
+
public get extraInfo(): object | undefined {
|
|
9
|
+
return this.getExtraInfo();
|
|
10
|
+
}
|
|
11
|
+
public getExtraInfo(): object | undefined {
|
|
12
|
+
return duckdb.function_get_extra_info(this.function_info);
|
|
13
|
+
}
|
|
14
|
+
public get bindData(): object | undefined {
|
|
15
|
+
return this.getBindData();
|
|
16
|
+
}
|
|
17
|
+
public getBindData(): object | undefined {
|
|
18
|
+
return duckdb.function_get_bind_data(this.function_info);
|
|
19
|
+
}
|
|
20
|
+
public get initData(): object | undefined {
|
|
21
|
+
return this.getInitData();
|
|
22
|
+
}
|
|
23
|
+
public getInitData(): object | undefined {
|
|
24
|
+
return duckdb.function_get_init_data(this.function_info);
|
|
25
|
+
}
|
|
26
|
+
/** The init data set by the local init function, which is per scanning thread. */
|
|
27
|
+
public get localInitData(): object | undefined {
|
|
28
|
+
return this.getLocalInitData();
|
|
29
|
+
}
|
|
30
|
+
public getLocalInitData(): object | undefined {
|
|
31
|
+
return duckdb.function_get_local_init_data(this.function_info);
|
|
32
|
+
}
|
|
33
|
+
public setError(error: string) {
|
|
34
|
+
duckdb.function_set_error(this.function_info, error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import duckdb from "../../../src/bindings/index.ts";
|
|
2
|
+
|
|
3
|
+
export class DuckDBTableFunctionInitInfo {
|
|
4
|
+
private readonly init_info: duckdb.TableFunctionInitInfo;
|
|
5
|
+
constructor(init_info: duckdb.TableFunctionInitInfo) {
|
|
6
|
+
this.init_info = init_info;
|
|
7
|
+
}
|
|
8
|
+
public get extraInfo(): object | undefined {
|
|
9
|
+
return this.getExtraInfo();
|
|
10
|
+
}
|
|
11
|
+
public getExtraInfo(): object | undefined {
|
|
12
|
+
return duckdb.init_get_extra_info(this.init_info);
|
|
13
|
+
}
|
|
14
|
+
public get bindData(): object | undefined {
|
|
15
|
+
return this.getBindData();
|
|
16
|
+
}
|
|
17
|
+
public getBindData(): object | undefined {
|
|
18
|
+
return duckdb.init_get_bind_data(this.init_info);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The number of columns the scan has been asked for, which is all of them
|
|
22
|
+
* unless the function opted into projection pushdown.
|
|
23
|
+
*/
|
|
24
|
+
public get columnCount(): number {
|
|
25
|
+
return this.getColumnCount();
|
|
26
|
+
}
|
|
27
|
+
public getColumnCount(): number {
|
|
28
|
+
return duckdb.init_get_column_count(this.init_info);
|
|
29
|
+
}
|
|
30
|
+
/** The index, among the bound result columns, of the given projected column. */
|
|
31
|
+
public getColumnIndex(columnIndex: number): number {
|
|
32
|
+
return duckdb.init_get_column_index(this.init_info, columnIndex);
|
|
33
|
+
}
|
|
34
|
+
/** All projected column indexes, in order. */
|
|
35
|
+
public getColumnIndexes(): number[] {
|
|
36
|
+
const count = this.getColumnCount();
|
|
37
|
+
const indexes: number[] = [];
|
|
38
|
+
for (let i = 0; i < count; i++) {
|
|
39
|
+
indexes.push(this.getColumnIndex(i));
|
|
40
|
+
}
|
|
41
|
+
return indexes;
|
|
42
|
+
}
|
|
43
|
+
public setInitData(initData: object) {
|
|
44
|
+
duckdb.init_set_init_data(this.init_info, initData);
|
|
45
|
+
}
|
|
46
|
+
public setMaxThreads(maxThreads: number) {
|
|
47
|
+
duckdb.init_set_max_threads(this.init_info, maxThreads);
|
|
48
|
+
}
|
|
49
|
+
public setError(error: string) {
|
|
50
|
+
duckdb.init_set_error(this.init_info, error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// copy of duckdb_type, with names shortened
|
|
2
|
+
export enum DuckDBTypeId {
|
|
3
|
+
INVALID = 0,
|
|
4
|
+
BOOLEAN = 1,
|
|
5
|
+
TINYINT = 2,
|
|
6
|
+
SMALLINT = 3,
|
|
7
|
+
INTEGER = 4,
|
|
8
|
+
BIGINT = 5,
|
|
9
|
+
UTINYINT = 6,
|
|
10
|
+
USMALLINT = 7,
|
|
11
|
+
UINTEGER = 8,
|
|
12
|
+
UBIGINT = 9,
|
|
13
|
+
FLOAT = 10,
|
|
14
|
+
DOUBLE = 11,
|
|
15
|
+
TIMESTAMP = 12,
|
|
16
|
+
DATE = 13,
|
|
17
|
+
TIME = 14,
|
|
18
|
+
INTERVAL = 15,
|
|
19
|
+
HUGEINT = 16,
|
|
20
|
+
UHUGEINT = 32,
|
|
21
|
+
VARCHAR = 17,
|
|
22
|
+
BLOB = 18,
|
|
23
|
+
DECIMAL = 19,
|
|
24
|
+
TIMESTAMP_S = 20,
|
|
25
|
+
TIMESTAMP_MS = 21,
|
|
26
|
+
TIMESTAMP_NS = 22,
|
|
27
|
+
ENUM = 23,
|
|
28
|
+
LIST = 24,
|
|
29
|
+
STRUCT = 25,
|
|
30
|
+
MAP = 26,
|
|
31
|
+
ARRAY = 33,
|
|
32
|
+
UUID = 27,
|
|
33
|
+
UNION = 28,
|
|
34
|
+
BIT = 29,
|
|
35
|
+
TIME_TZ = 30,
|
|
36
|
+
TIMESTAMP_TZ = 31,
|
|
37
|
+
ANY = 34,
|
|
38
|
+
BIGNUM = 35,
|
|
39
|
+
SQLNULL = 36,
|
|
40
|
+
STRING_LITERAL = 37,
|
|
41
|
+
INTEGER_LITERAL = 38,
|
|
42
|
+
TIME_NS = 39,
|
|
43
|
+
GEOMETRY = 40,
|
|
44
|
+
VARIANT = 41,
|
|
45
|
+
TIMESTAMP_TZ_NS = 42,
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DuckDBType } from './DuckDBType';
|
|
2
|
+
import { DuckDBValue } from './values';
|
|
3
|
+
|
|
4
|
+
export type DuckDBValueConverter<T> = (
|
|
5
|
+
value: DuckDBValue,
|
|
6
|
+
type: DuckDBType,
|
|
7
|
+
converter: DuckDBValueConverter<T>
|
|
8
|
+
) => T | null;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A converter for a single DuckDB type id, whose output type is narrower than
|
|
12
|
+
* the output type of the top-level converter it recurses through.
|
|
13
|
+
*
|
|
14
|
+
* `DuckDBValueConverter<T>` ties both the return type and the recursion hook
|
|
15
|
+
* to the same `T`. In a per-type-id converter map, only the return type varies
|
|
16
|
+
* by id: the `converter` argument is always the map's top-level converter, so
|
|
17
|
+
* `Nested` stays fixed while `Out` narrows.
|
|
18
|
+
*/
|
|
19
|
+
export type DuckDBValueConverterFor<Out, Nested> = (
|
|
20
|
+
value: DuckDBValue,
|
|
21
|
+
type: DuckDBType,
|
|
22
|
+
converter: DuckDBValueConverter<Nested>
|
|
23
|
+
) => Out | null;
|