@haybarn/node-api 1.5.6-rc1 → 2.0.0-rc3
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/README.md +315 -20
- package/lib/DuckDBAppender.d.ts +8 -2
- package/lib/DuckDBAppender.js +19 -1
- package/lib/DuckDBConnection.d.ts +2 -0
- package/lib/DuckDBConnection.js +4 -1
- package/lib/DuckDBDataChunk.d.ts +30 -0
- package/lib/DuckDBDataChunk.js +94 -1
- package/lib/DuckDBDataChunkWriter.d.ts +74 -0
- package/lib/DuckDBDataChunkWriter.js +109 -0
- package/lib/DuckDBLogicalType.d.ts +5 -1
- package/lib/DuckDBLogicalType.js +18 -1
- package/lib/DuckDBMaterializedResult.d.ts +8 -1
- package/lib/DuckDBMaterializedResult.js +22 -2
- package/lib/DuckDBPendingResult.d.ts +16 -1
- package/lib/DuckDBPendingResult.js +19 -2
- package/lib/DuckDBPreparedStatement.d.ts +4 -1
- package/lib/DuckDBPreparedStatement.js +17 -4
- package/lib/DuckDBResult.d.ts +21 -1
- package/lib/DuckDBResult.js +87 -5
- package/lib/DuckDBResultReader.d.ts +5 -0
- package/lib/DuckDBResultReader.js +9 -2
- package/lib/DuckDBScalarFunction.d.ts +9 -5
- package/lib/DuckDBScalarFunction.js +14 -5
- package/lib/DuckDBScalarFunctionBindInfo.d.ts +16 -0
- package/lib/{DuckDBBindInfo.js → DuckDBScalarFunctionBindInfo.js} +5 -3
- package/lib/DuckDBScalarFunctionInfo.d.ts +16 -0
- package/lib/{DuckDBFunctionInfo.js → DuckDBScalarFunctionInfo.js} +11 -3
- package/lib/{DuckDBBindInfo.d.ts → DuckDBScalarFunctionInitInfo.d.ts} +6 -4
- package/lib/DuckDBScalarFunctionInitInfo.js +39 -0
- package/lib/DuckDBTableFunction.d.ts +41 -0
- package/lib/DuckDBTableFunction.js +83 -0
- package/lib/DuckDBTableFunctionBindInfo.d.ts +21 -0
- package/lib/DuckDBTableFunctionBindInfo.js +54 -0
- package/lib/DuckDBTableFunctionInfo.d.ts +15 -0
- package/lib/DuckDBTableFunctionInfo.js +42 -0
- package/lib/DuckDBTableFunctionInitInfo.d.ts +22 -0
- package/lib/DuckDBTableFunctionInitInfo.js +58 -0
- package/lib/DuckDBType.d.ts +1 -373
- package/lib/DuckDBType.js +14 -927
- package/lib/DuckDBTypeId.d.ts +4 -1
- package/lib/DuckDBTypeId.js +3 -0
- package/lib/DuckDBValueConverter.d.ts +10 -0
- package/lib/DuckDBValueConverters.d.ts +27 -0
- package/lib/DuckDBValueConverters.js +128 -1
- package/lib/DuckDBVector.d.ts +1 -596
- package/lib/DuckDBVector.js +14 -2522
- package/lib/JSDuckDBValueConverter.d.ts +1 -2
- package/lib/JSDuckDBValueConverter.js +5 -2
- package/lib/JSInputTypeForTypeId.d.ts +104 -0
- package/lib/JSInputTypeForTypeId.js +3 -0
- package/lib/JSToDuckDBValueConverter.d.ts +30 -0
- package/lib/JSToDuckDBValueConverter.js +83 -0
- package/lib/JSTypeForTypeId.d.ts +91 -0
- package/lib/JSTypeForTypeId.js +3 -0
- package/lib/JsonDuckDBValueConverter.d.ts +1 -2
- package/lib/JsonDuckDBValueConverter.js +4 -1
- package/lib/JsonTypeForTypeId.d.ts +96 -0
- package/lib/JsonTypeForTypeId.js +3 -0
- package/lib/ToDuckDBValueConverter.d.ts +41 -0
- package/lib/ToDuckDBValueConverter.js +27 -0
- package/lib/ToDuckDBValueConverters.d.ts +54 -0
- package/lib/ToDuckDBValueConverters.js +199 -0
- package/lib/conversion/dateTimeStringConversion.d.ts +2 -2
- package/lib/conversion/dateTimeStringConversion.js +20 -7
- package/lib/conversion/varintDecode.d.ts +18 -0
- package/lib/conversion/varintDecode.js +42 -0
- package/lib/convertColumnsFromChunks.d.ts +1 -1
- package/lib/convertColumnsFromChunks.js +2 -2
- package/lib/createResult.d.ts +2 -1
- package/lib/createResult.js +3 -3
- package/lib/createValue.js +63 -5
- package/lib/duckdb.d.ts +15 -2
- package/lib/duckdb.js +15 -2
- package/lib/getColumnsFromChunks.d.ts +1 -1
- package/lib/getColumnsFromChunks.js +2 -2
- package/lib/getColumnsObjectFromChunks.js +3 -0
- package/lib/readValue.d.ts +22 -0
- package/lib/readValue.js +35 -0
- package/lib/typeForValue.js +21 -2
- package/lib/types/BaseDuckDBType.d.ts +11 -0
- package/lib/types/BaseDuckDBType.js +34 -0
- package/lib/types/DuckDBAnyType.d.ts +8 -0
- package/lib/types/DuckDBAnyType.js +16 -0
- package/lib/types/DuckDBArrayType.d.ts +14 -0
- package/lib/types/DuckDBArrayType.js +38 -0
- package/lib/types/DuckDBBigIntType.d.ts +12 -0
- package/lib/types/DuckDBBigIntType.js +24 -0
- package/lib/types/DuckDBBigNumType.d.ts +12 -0
- package/lib/types/DuckDBBigNumType.js +24 -0
- package/lib/types/DuckDBBitType.d.ts +8 -0
- package/lib/types/DuckDBBitType.js +16 -0
- package/lib/types/DuckDBBlobType.d.ts +8 -0
- package/lib/types/DuckDBBlobType.js +16 -0
- package/lib/types/DuckDBBooleanType.d.ts +8 -0
- package/lib/types/DuckDBBooleanType.js +16 -0
- package/lib/types/DuckDBDateType.d.ts +14 -0
- package/lib/types/DuckDBDateType.js +32 -0
- package/lib/types/DuckDBDecimalType.d.ts +14 -0
- package/lib/types/DuckDBDecimalType.js +45 -0
- package/lib/types/DuckDBDoubleType.d.ts +12 -0
- package/lib/types/DuckDBDoubleType.js +24 -0
- package/lib/types/DuckDBEnumType.d.ts +29 -0
- package/lib/types/DuckDBEnumType.js +100 -0
- package/lib/types/DuckDBFloatType.d.ts +12 -0
- package/lib/types/DuckDBFloatType.js +24 -0
- package/lib/types/DuckDBGeometryType.d.ts +19 -0
- package/lib/types/DuckDBGeometryType.js +38 -0
- package/lib/types/DuckDBHugeIntType.d.ts +12 -0
- package/lib/types/DuckDBHugeIntType.js +24 -0
- package/lib/types/DuckDBIntegerLiteralType.d.ts +8 -0
- package/lib/types/DuckDBIntegerLiteralType.js +16 -0
- package/lib/types/DuckDBIntegerType.d.ts +12 -0
- package/lib/types/DuckDBIntegerType.js +24 -0
- package/lib/types/DuckDBIntervalType.d.ts +8 -0
- package/lib/types/DuckDBIntervalType.js +16 -0
- package/lib/types/DuckDBListType.d.ts +13 -0
- package/lib/types/DuckDBListType.js +35 -0
- package/lib/types/DuckDBMapType.d.ts +14 -0
- package/lib/types/DuckDBMapType.js +38 -0
- package/lib/types/DuckDBSQLNullType.d.ts +10 -0
- package/lib/types/DuckDBSQLNullType.js +20 -0
- package/lib/types/DuckDBSmallIntType.d.ts +12 -0
- package/lib/types/DuckDBSmallIntType.js +24 -0
- package/lib/types/DuckDBStringLiteralType.d.ts +8 -0
- package/lib/types/DuckDBStringLiteralType.js +16 -0
- package/lib/types/DuckDBStructType.d.ts +29 -0
- package/lib/types/DuckDBStructType.js +86 -0
- package/lib/types/DuckDBTimeNSType.d.ts +11 -0
- package/lib/types/DuckDBTimeNSType.js +23 -0
- package/lib/types/DuckDBTimeTZType.d.ts +12 -0
- package/lib/types/DuckDBTimeTZType.js +26 -0
- package/lib/types/DuckDBTimeType.d.ts +11 -0
- package/lib/types/DuckDBTimeType.js +23 -0
- package/lib/types/DuckDBTimestampMillisecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampMillisecondsType.js +32 -0
- package/lib/types/DuckDBTimestampNanosecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampNanosecondsType.js +32 -0
- package/lib/types/DuckDBTimestampSecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampSecondsType.js +32 -0
- package/lib/types/DuckDBTimestampTZNanosecondsType.d.ts +15 -0
- package/lib/types/DuckDBTimestampTZNanosecondsType.js +35 -0
- package/lib/types/DuckDBTimestampTZType.d.ts +15 -0
- package/lib/types/DuckDBTimestampTZType.js +35 -0
- package/lib/types/DuckDBTimestampType.d.ts +16 -0
- package/lib/types/DuckDBTimestampType.js +33 -0
- package/lib/types/DuckDBTinyIntType.d.ts +12 -0
- package/lib/types/DuckDBTinyIntType.js +24 -0
- package/lib/types/DuckDBType.d.ts +43 -0
- package/lib/types/DuckDBType.js +2 -0
- package/lib/types/DuckDBUBigIntType.d.ts +12 -0
- package/lib/types/DuckDBUBigIntType.js +24 -0
- package/lib/types/DuckDBUHugeIntType.d.ts +12 -0
- package/lib/types/DuckDBUHugeIntType.js +24 -0
- package/lib/types/DuckDBUIntegerType.d.ts +12 -0
- package/lib/types/DuckDBUIntegerType.js +24 -0
- package/lib/types/DuckDBUSmallIntType.d.ts +12 -0
- package/lib/types/DuckDBUSmallIntType.js +24 -0
- package/lib/types/DuckDBUTinyIntType.d.ts +12 -0
- package/lib/types/DuckDBUTinyIntType.js +24 -0
- package/lib/types/DuckDBUUIDType.d.ts +11 -0
- package/lib/types/DuckDBUUIDType.js +23 -0
- package/lib/types/DuckDBUnionType.d.ts +18 -0
- package/lib/types/DuckDBUnionType.js +64 -0
- package/lib/types/DuckDBVarCharType.d.ts +8 -0
- package/lib/types/DuckDBVarCharType.js +16 -0
- package/lib/types/DuckDBVariantType.d.ts +8 -0
- package/lib/types/DuckDBVariantType.js +16 -0
- package/lib/types/index.d.ts +44 -0
- package/lib/types/index.js +60 -0
- package/lib/values/DuckDBGeometryValue.d.ts +12 -0
- package/lib/values/DuckDBGeometryValue.js +30 -0
- package/lib/values/DuckDBTimestampTZNanosecondsValue.d.ts +14 -0
- package/lib/values/DuckDBTimestampTZNanosecondsValue.js +33 -0
- package/lib/values/DuckDBTupleValue.d.ts +11 -0
- package/lib/values/DuckDBTupleValue.js +22 -0
- package/lib/values/DuckDBUUIDValue.js +5 -1
- package/lib/values/DuckDBValue.d.ts +5 -1
- package/lib/values/DuckDBVariantValue.d.ts +19 -0
- package/lib/values/DuckDBVariantValue.js +30 -0
- package/lib/values/index.d.ts +4 -0
- package/lib/values/index.js +4 -0
- package/lib/vectors/DuckDBArrayVector.d.ts +21 -0
- package/lib/vectors/DuckDBArrayVector.js +79 -0
- package/lib/vectors/DuckDBBigIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBBigIntVector.js +58 -0
- package/lib/vectors/DuckDBBigNumVector.d.ts +21 -0
- package/lib/vectors/DuckDBBigNumVector.js +70 -0
- package/lib/vectors/DuckDBBitVector.d.ts +22 -0
- package/lib/vectors/DuckDBBitVector.js +74 -0
- package/lib/vectors/DuckDBBlobVector.d.ts +32 -0
- package/lib/vectors/DuckDBBlobVector.js +83 -0
- package/lib/vectors/DuckDBBooleanVector.d.ts +18 -0
- package/lib/vectors/DuckDBBooleanVector.js +58 -0
- package/lib/vectors/DuckDBDateVector.d.ts +18 -0
- package/lib/vectors/DuckDBDateVector.js +64 -0
- package/lib/vectors/DuckDBDecimal128Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal128Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal16Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal16Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal32Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal32Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal64Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal64Vector.js +64 -0
- package/lib/vectors/DuckDBDoubleVector.d.ts +17 -0
- package/lib/vectors/DuckDBDoubleVector.js +54 -0
- package/lib/vectors/DuckDBEnum16Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum16Vector.js +57 -0
- package/lib/vectors/DuckDBEnum32Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum32Vector.js +57 -0
- package/lib/vectors/DuckDBEnum8Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum8Vector.js +57 -0
- package/lib/vectors/DuckDBFloatVector.d.ts +17 -0
- package/lib/vectors/DuckDBFloatVector.js +54 -0
- package/lib/vectors/DuckDBGeometryVector.d.ts +22 -0
- package/lib/vectors/DuckDBGeometryVector.js +69 -0
- package/lib/vectors/DuckDBHugeIntVector.d.ts +19 -0
- package/lib/vectors/DuckDBHugeIntVector.js +63 -0
- package/lib/vectors/DuckDBIntegerVector.d.ts +17 -0
- package/lib/vectors/DuckDBIntegerVector.js +61 -0
- package/lib/vectors/DuckDBIntervalVector.d.ts +19 -0
- package/lib/vectors/DuckDBIntervalVector.js +67 -0
- package/lib/vectors/DuckDBListVector.d.ts +35 -0
- package/lib/vectors/DuckDBListVector.js +151 -0
- package/lib/vectors/DuckDBMapVector.d.ts +17 -0
- package/lib/vectors/DuckDBMapVector.js +60 -0
- package/lib/vectors/DuckDBSQLNullVector.d.ts +18 -0
- package/lib/vectors/DuckDBSQLNullVector.js +44 -0
- package/lib/vectors/DuckDBSmallIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBSmallIntVector.js +61 -0
- package/lib/vectors/DuckDBStructVector.d.ts +35 -0
- package/lib/vectors/DuckDBStructVector.js +105 -0
- package/lib/vectors/DuckDBTimeNSVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeNSVector.js +61 -0
- package/lib/vectors/DuckDBTimeTZVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeTZVector.js +61 -0
- package/lib/vectors/DuckDBTimeVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeVector.js +61 -0
- package/lib/vectors/DuckDBTimestampMillisecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampMillisecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampNanosecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampNanosecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampSecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampSecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampTZNanosecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampTZNanosecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampTZVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampTZVector.js +61 -0
- package/lib/vectors/DuckDBTimestampVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampVector.js +61 -0
- package/lib/vectors/DuckDBTinyIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBTinyIntVector.js +61 -0
- package/lib/vectors/DuckDBTupleVector.d.ts +26 -0
- package/lib/vectors/DuckDBTupleVector.js +91 -0
- package/lib/vectors/DuckDBUBigIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUBigIntVector.js +58 -0
- package/lib/vectors/DuckDBUHugeIntVector.d.ts +19 -0
- package/lib/vectors/DuckDBUHugeIntVector.js +63 -0
- package/lib/vectors/DuckDBUIntegerVector.d.ts +17 -0
- package/lib/vectors/DuckDBUIntegerVector.js +61 -0
- package/lib/vectors/DuckDBUSmallIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUSmallIntVector.js +61 -0
- package/lib/vectors/DuckDBUTinyIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUTinyIntVector.js +61 -0
- package/lib/vectors/DuckDBUUIDVector.d.ts +19 -0
- package/lib/vectors/DuckDBUUIDVector.js +59 -0
- package/lib/vectors/DuckDBUnionVector.d.ts +17 -0
- package/lib/vectors/DuckDBUnionVector.js +70 -0
- package/lib/vectors/DuckDBValidity.d.ts +12 -0
- package/lib/vectors/DuckDBValidity.js +91 -0
- package/lib/vectors/DuckDBVarCharVector.d.ts +21 -0
- package/lib/vectors/DuckDBVarCharVector.js +74 -0
- package/lib/vectors/DuckDBVariantVector.d.ts +42 -0
- package/lib/vectors/DuckDBVariantVector.js +461 -0
- package/lib/vectors/DuckDBVector.d.ts +14 -0
- package/lib/vectors/DuckDBVector.js +27 -0
- package/lib/vectors/createVector.d.ts +1 -0
- package/lib/vectors/createVector.js +201 -0
- package/lib/vectors/dataAccessors.d.ts +45 -0
- package/lib/vectors/dataAccessors.js +344 -0
- package/lib/vectors/index.d.ts +47 -0
- package/lib/vectors/index.js +65 -0
- package/lib/vectors/vectorRegistry.d.ts +20 -0
- package/lib/vectors/vectorRegistry.js +16 -0
- package/package.json +3 -2
- package/lib/DuckDBFunctionInfo.d.ts +0 -10
package/lib/DuckDBResult.js
CHANGED
|
@@ -13,25 +13,83 @@ const convertColumnsFromChunks_1 = require("./convertColumnsFromChunks");
|
|
|
13
13
|
const convertColumnsObjectFromChunks_1 = require("./convertColumnsObjectFromChunks");
|
|
14
14
|
const convertRowObjectsFromChunks_1 = require("./convertRowObjectsFromChunks");
|
|
15
15
|
const convertRowsFromChunks_1 = require("./convertRowsFromChunks");
|
|
16
|
+
const enums_1 = require("./enums");
|
|
16
17
|
const getColumnsFromChunks_1 = require("./getColumnsFromChunks");
|
|
17
18
|
const getColumnsObjectFromChunks_1 = require("./getColumnsObjectFromChunks");
|
|
18
19
|
const getRowObjectsFromChunks_1 = require("./getRowObjectsFromChunks");
|
|
19
20
|
const getRowsFromChunks_1 = require("./getRowsFromChunks");
|
|
20
21
|
class DuckDBResult {
|
|
21
22
|
result;
|
|
22
|
-
|
|
23
|
+
preparedStatementType;
|
|
24
|
+
closedMetadata;
|
|
25
|
+
/**
|
|
26
|
+
* `preparedStatementType` is the type of the prepared statement the result
|
|
27
|
+
* came from, if any. It is reported as the result's statement type when
|
|
28
|
+
* DuckDB reports EXECUTE instead.
|
|
29
|
+
*/
|
|
30
|
+
constructor(result, preparedStatementType) {
|
|
23
31
|
this.result = result;
|
|
32
|
+
this.preparedStatementType = preparedStatementType;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Destroys the result, freeing its memory. On DuckDB 2.0, a streaming result
|
|
36
|
+
* that has not been read to the end blocks its connection from starting
|
|
37
|
+
* another statement until it is closed.
|
|
38
|
+
*
|
|
39
|
+
* The return type, statement type, column names and types, and rows changed
|
|
40
|
+
* stay available; fetching throws. If a fetch is in flight, the result is
|
|
41
|
+
* destroyed, and its connection unblocked, only once that fetch finishes.
|
|
42
|
+
* Closing again does nothing.
|
|
43
|
+
*/
|
|
44
|
+
closeSync() {
|
|
45
|
+
if (!this.closedMetadata) {
|
|
46
|
+
const columnCount = this.columnCount;
|
|
47
|
+
const columnNames = [];
|
|
48
|
+
const columnTypes = [];
|
|
49
|
+
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
50
|
+
columnNames.push(this.columnName(columnIndex));
|
|
51
|
+
columnTypes.push(this.columnType(columnIndex));
|
|
52
|
+
}
|
|
53
|
+
this.closedMetadata = {
|
|
54
|
+
returnType: this.returnType,
|
|
55
|
+
statementType: this.statementType,
|
|
56
|
+
columnNames,
|
|
57
|
+
columnTypes,
|
|
58
|
+
isStreaming: this.isStreaming,
|
|
59
|
+
rowsChanged: this.rowsChanged,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
node_bindings_1.default.destroy_result_sync(this.result);
|
|
24
63
|
}
|
|
25
64
|
get returnType() {
|
|
65
|
+
if (this.closedMetadata) {
|
|
66
|
+
return this.closedMetadata.returnType;
|
|
67
|
+
}
|
|
26
68
|
return node_bindings_1.default.result_return_type(this.result);
|
|
27
69
|
}
|
|
28
70
|
get statementType() {
|
|
29
|
-
|
|
71
|
+
if (this.closedMetadata) {
|
|
72
|
+
return this.closedMetadata.statementType;
|
|
73
|
+
}
|
|
74
|
+
const statementType = node_bindings_1.default.result_statement_type(this.result);
|
|
75
|
+
// On DuckDB 2.0, results of prepared statements report EXECUTE; see
|
|
76
|
+
// https://github.com/duckdb/duckdb/issues/27415
|
|
77
|
+
if (statementType === enums_1.StatementType.EXECUTE &&
|
|
78
|
+
this.preparedStatementType !== undefined) {
|
|
79
|
+
return this.preparedStatementType;
|
|
80
|
+
}
|
|
81
|
+
return statementType;
|
|
30
82
|
}
|
|
31
83
|
get columnCount() {
|
|
84
|
+
if (this.closedMetadata) {
|
|
85
|
+
return this.closedMetadata.columnNames.length;
|
|
86
|
+
}
|
|
32
87
|
return node_bindings_1.default.column_count(this.result);
|
|
33
88
|
}
|
|
34
89
|
columnName(columnIndex) {
|
|
90
|
+
if (this.closedMetadata) {
|
|
91
|
+
return this.closedMetadata.columnNames[this.checkClosedColumnIndex(columnIndex)];
|
|
92
|
+
}
|
|
35
93
|
return node_bindings_1.default.column_name(this.result, columnIndex);
|
|
36
94
|
}
|
|
37
95
|
columnNames() {
|
|
@@ -60,13 +118,22 @@ class DuckDBResult {
|
|
|
60
118
|
return outputColumnNames;
|
|
61
119
|
}
|
|
62
120
|
columnTypeId(columnIndex) {
|
|
121
|
+
if (this.closedMetadata) {
|
|
122
|
+
return this.columnType(columnIndex).typeId;
|
|
123
|
+
}
|
|
63
124
|
return node_bindings_1.default.column_type(this.result, columnIndex);
|
|
64
125
|
}
|
|
65
126
|
columnLogicalType(columnIndex) {
|
|
127
|
+
if (this.closedMetadata) {
|
|
128
|
+
return this.columnType(columnIndex).toLogicalType();
|
|
129
|
+
}
|
|
66
130
|
return DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.column_logical_type(this.result, columnIndex));
|
|
67
131
|
}
|
|
68
132
|
columnType(columnIndex) {
|
|
69
|
-
|
|
133
|
+
if (this.closedMetadata) {
|
|
134
|
+
return this.closedMetadata.columnTypes[this.checkClosedColumnIndex(columnIndex)];
|
|
135
|
+
}
|
|
136
|
+
return this.columnLogicalType(columnIndex).asType();
|
|
70
137
|
}
|
|
71
138
|
columnTypeJson(columnIndex) {
|
|
72
139
|
return this.columnType(columnIndex).toJson();
|
|
@@ -105,9 +172,15 @@ class DuckDBResult {
|
|
|
105
172
|
return columnNameAndTypeObjects;
|
|
106
173
|
}
|
|
107
174
|
get isStreaming() {
|
|
175
|
+
if (this.closedMetadata) {
|
|
176
|
+
return this.closedMetadata.isStreaming;
|
|
177
|
+
}
|
|
108
178
|
return node_bindings_1.default.result_is_streaming(this.result);
|
|
109
179
|
}
|
|
110
180
|
get rowsChanged() {
|
|
181
|
+
if (this.closedMetadata) {
|
|
182
|
+
return this.closedMetadata.rowsChanged;
|
|
183
|
+
}
|
|
111
184
|
return node_bindings_1.default.rows_changed(this.result);
|
|
112
185
|
}
|
|
113
186
|
async fetchChunk() {
|
|
@@ -126,11 +199,11 @@ class DuckDBResult {
|
|
|
126
199
|
}
|
|
127
200
|
async getColumns() {
|
|
128
201
|
const chunks = await this.fetchAllChunks();
|
|
129
|
-
return (0, getColumnsFromChunks_1.getColumnsFromChunks)(chunks);
|
|
202
|
+
return (0, getColumnsFromChunks_1.getColumnsFromChunks)(chunks, this.columnCount);
|
|
130
203
|
}
|
|
131
204
|
async convertColumns(converter) {
|
|
132
205
|
const chunks = await this.fetchAllChunks();
|
|
133
|
-
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(chunks, converter);
|
|
206
|
+
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(chunks, this.columnCount, converter);
|
|
134
207
|
}
|
|
135
208
|
async getColumnsJS() {
|
|
136
209
|
return this.convertColumns(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
@@ -225,5 +298,14 @@ class DuckDBResult {
|
|
|
225
298
|
yieldRowObjectJson() {
|
|
226
299
|
return this.yieldConvertedRowObjects(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
227
300
|
}
|
|
301
|
+
/** Converts the index as the bindings do (ToUint32), then checks range. */
|
|
302
|
+
checkClosedColumnIndex(columnIndex) {
|
|
303
|
+
const index = columnIndex >>> 0;
|
|
304
|
+
const columnCount = this.closedMetadata?.columnNames.length ?? 0;
|
|
305
|
+
if (index >= columnCount) {
|
|
306
|
+
throw new RangeError(`column index ${index} is out of range (count: ${columnCount})`);
|
|
307
|
+
}
|
|
308
|
+
return index;
|
|
309
|
+
}
|
|
228
310
|
}
|
|
229
311
|
exports.DuckDBResult = DuckDBResult;
|
|
@@ -14,6 +14,11 @@ export declare class DuckDBResultReader {
|
|
|
14
14
|
private currentRowCount_;
|
|
15
15
|
private done_;
|
|
16
16
|
constructor(result: DuckDBResult);
|
|
17
|
+
/**
|
|
18
|
+
* Closes the result being read; see `DuckDBResult.closeSync`. Rows already
|
|
19
|
+
* read and the column metadata stay available; reading more throws.
|
|
20
|
+
*/
|
|
21
|
+
closeSync(): void;
|
|
17
22
|
get returnType(): ResultReturnType;
|
|
18
23
|
get statementType(): StatementType;
|
|
19
24
|
get columnCount(): number;
|
|
@@ -24,6 +24,13 @@ class DuckDBResultReader {
|
|
|
24
24
|
this.currentRowCount_ = 0;
|
|
25
25
|
this.done_ = false;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Closes the result being read; see `DuckDBResult.closeSync`. Rows already
|
|
29
|
+
* read and the column metadata stay available; reading more throws.
|
|
30
|
+
*/
|
|
31
|
+
closeSync() {
|
|
32
|
+
this.result.closeSync();
|
|
33
|
+
}
|
|
27
34
|
get returnType() {
|
|
28
35
|
return this.result.returnType;
|
|
29
36
|
}
|
|
@@ -152,10 +159,10 @@ class DuckDBResultReader {
|
|
|
152
159
|
});
|
|
153
160
|
}
|
|
154
161
|
getColumns() {
|
|
155
|
-
return (0, getColumnsFromChunks_1.getColumnsFromChunks)(this.chunks);
|
|
162
|
+
return (0, getColumnsFromChunks_1.getColumnsFromChunks)(this.chunks, this.columnCount);
|
|
156
163
|
}
|
|
157
164
|
convertColumns(converter) {
|
|
158
|
-
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(this.chunks, converter);
|
|
165
|
+
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(this.chunks, this.columnCount, converter);
|
|
159
166
|
}
|
|
160
167
|
getColumnsJS() {
|
|
161
168
|
return this.convertColumns(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import duckdb from '@haybarn/node-bindings';
|
|
2
2
|
import { DuckDBDataChunk } from './DuckDBDataChunk';
|
|
3
|
-
import {
|
|
3
|
+
import { DuckDBScalarFunctionBindInfo } from './DuckDBScalarFunctionBindInfo';
|
|
4
|
+
import { DuckDBScalarFunctionInfo } from './DuckDBScalarFunctionInfo';
|
|
5
|
+
import { DuckDBScalarFunctionInitInfo } from './DuckDBScalarFunctionInitInfo';
|
|
4
6
|
import { DuckDBType } from './DuckDBType';
|
|
5
7
|
import { DuckDBVector } from './DuckDBVector';
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
export type DuckDBScalarMainFunction = (functionInfo:
|
|
8
|
+
export type DuckDBScalarBindFunction = (bindInfo: DuckDBScalarFunctionBindInfo) => void;
|
|
9
|
+
export type DuckDBScalarInitFunction = (initInfo: DuckDBScalarFunctionInitInfo) => void;
|
|
10
|
+
export type DuckDBScalarMainFunction = (functionInfo: DuckDBScalarFunctionInfo, inputDataChunk: DuckDBDataChunk, outputVector: DuckDBVector) => void;
|
|
9
11
|
export declare class DuckDBScalarFunction {
|
|
10
12
|
readonly scalar_function: duckdb.ScalarFunction;
|
|
11
13
|
constructor();
|
|
12
|
-
static create({ name, bindFunction, mainFunction, returnType, parameterTypes, varArgsType, specialHandling, volatile, extraInfo, }: {
|
|
14
|
+
static create({ name, bindFunction, initFunction, mainFunction, returnType, parameterTypes, varArgsType, specialHandling, volatile, extraInfo, }: {
|
|
13
15
|
name: string;
|
|
14
16
|
bindFunction?: DuckDBScalarBindFunction;
|
|
17
|
+
initFunction?: DuckDBScalarInitFunction;
|
|
15
18
|
mainFunction: DuckDBScalarMainFunction;
|
|
16
19
|
returnType: DuckDBType;
|
|
17
20
|
parameterTypes?: readonly DuckDBType[];
|
|
@@ -23,6 +26,7 @@ export declare class DuckDBScalarFunction {
|
|
|
23
26
|
destroySync(): void;
|
|
24
27
|
setName(name: string): void;
|
|
25
28
|
setBindFunction(bindFunction: DuckDBScalarBindFunction): void;
|
|
29
|
+
setInitFunction(initFunction: DuckDBScalarInitFunction): void;
|
|
26
30
|
setMainFunction(mainFunction: DuckDBScalarMainFunction): void;
|
|
27
31
|
setReturnType(returnType: DuckDBType): void;
|
|
28
32
|
addParameter(parameterType: DuckDBType): void;
|
|
@@ -6,20 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DuckDBScalarFunction = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
8
|
const DuckDBDataChunk_1 = require("./DuckDBDataChunk");
|
|
9
|
-
const
|
|
9
|
+
const DuckDBScalarFunctionBindInfo_1 = require("./DuckDBScalarFunctionBindInfo");
|
|
10
|
+
const DuckDBScalarFunctionInfo_1 = require("./DuckDBScalarFunctionInfo");
|
|
11
|
+
const DuckDBScalarFunctionInitInfo_1 = require("./DuckDBScalarFunctionInitInfo");
|
|
10
12
|
const DuckDBVector_1 = require("./DuckDBVector");
|
|
11
|
-
const DuckDBBindInfo_1 = require("./DuckDBBindInfo");
|
|
12
13
|
class DuckDBScalarFunction {
|
|
13
14
|
scalar_function;
|
|
14
15
|
constructor() {
|
|
15
16
|
this.scalar_function = node_bindings_1.default.create_scalar_function();
|
|
16
17
|
}
|
|
17
|
-
static create({ name, bindFunction, mainFunction, returnType, parameterTypes, varArgsType, specialHandling, volatile, extraInfo, }) {
|
|
18
|
+
static create({ name, bindFunction, initFunction, mainFunction, returnType, parameterTypes, varArgsType, specialHandling, volatile, extraInfo, }) {
|
|
18
19
|
const scalarFunction = new DuckDBScalarFunction();
|
|
19
20
|
scalarFunction.setName(name);
|
|
20
21
|
if (bindFunction) {
|
|
21
22
|
scalarFunction.setBindFunction(bindFunction);
|
|
22
23
|
}
|
|
24
|
+
if (initFunction) {
|
|
25
|
+
scalarFunction.setInitFunction(initFunction);
|
|
26
|
+
}
|
|
23
27
|
scalarFunction.setMainFunction(mainFunction);
|
|
24
28
|
scalarFunction.setReturnType(returnType);
|
|
25
29
|
if (parameterTypes) {
|
|
@@ -49,13 +53,18 @@ class DuckDBScalarFunction {
|
|
|
49
53
|
}
|
|
50
54
|
setBindFunction(bindFunction) {
|
|
51
55
|
node_bindings_1.default.scalar_function_set_bind(this.scalar_function, (info) => {
|
|
52
|
-
const bindInfo = new
|
|
56
|
+
const bindInfo = new DuckDBScalarFunctionBindInfo_1.DuckDBScalarFunctionBindInfo(info);
|
|
53
57
|
bindFunction(bindInfo);
|
|
54
58
|
});
|
|
55
59
|
}
|
|
60
|
+
setInitFunction(initFunction) {
|
|
61
|
+
node_bindings_1.default.scalar_function_set_init(this.scalar_function, (info) => {
|
|
62
|
+
initFunction(new DuckDBScalarFunctionInitInfo_1.DuckDBScalarFunctionInitInfo(info));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
56
65
|
setMainFunction(mainFunction) {
|
|
57
66
|
node_bindings_1.default.scalar_function_set_function(this.scalar_function, (info, input, output) => {
|
|
58
|
-
const functionInfo = new
|
|
67
|
+
const functionInfo = new DuckDBScalarFunctionInfo_1.DuckDBScalarFunctionInfo(info);
|
|
59
68
|
const inputDataChunk = new DuckDBDataChunk_1.DuckDBDataChunk(input);
|
|
60
69
|
const outputVector = DuckDBVector_1.DuckDBVector.create(output, inputDataChunk.rowCount);
|
|
61
70
|
mainFunction(functionInfo, inputDataChunk, outputVector);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
|
+
export declare class DuckDBScalarFunctionBindInfo {
|
|
4
|
+
private readonly bind_info;
|
|
5
|
+
constructor(bind_info: duckdb.ScalarFunctionBindInfo);
|
|
6
|
+
get clientContext(): DuckDBClientContext;
|
|
7
|
+
getClientContext(): DuckDBClientContext;
|
|
8
|
+
get extraInfo(): object | undefined;
|
|
9
|
+
getExtraInfo(): object | undefined;
|
|
10
|
+
setBindData(bindData: object): void;
|
|
11
|
+
setError(error: string): void;
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Renamed to DuckDBScalarFunctionBindInfo. */
|
|
14
|
+
export declare const DuckDBBindInfo: typeof DuckDBScalarFunctionBindInfo;
|
|
15
|
+
/** @deprecated Renamed to DuckDBScalarFunctionBindInfo. */
|
|
16
|
+
export type DuckDBBindInfo = DuckDBScalarFunctionBindInfo;
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DuckDBBindInfo = void 0;
|
|
6
|
+
exports.DuckDBBindInfo = exports.DuckDBScalarFunctionBindInfo = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
8
|
const DuckDBClientContext_1 = require("./DuckDBClientContext");
|
|
9
|
-
class
|
|
9
|
+
class DuckDBScalarFunctionBindInfo {
|
|
10
10
|
bind_info;
|
|
11
11
|
constructor(bind_info) {
|
|
12
12
|
this.bind_info = bind_info;
|
|
@@ -30,4 +30,6 @@ class DuckDBBindInfo {
|
|
|
30
30
|
node_bindings_1.default.scalar_function_bind_set_error(this.bind_info, error);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
exports.
|
|
33
|
+
exports.DuckDBScalarFunctionBindInfo = DuckDBScalarFunctionBindInfo;
|
|
34
|
+
/** @deprecated Renamed to DuckDBScalarFunctionBindInfo. */
|
|
35
|
+
exports.DuckDBBindInfo = DuckDBScalarFunctionBindInfo;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
export declare class DuckDBScalarFunctionInfo {
|
|
3
|
+
private readonly function_info;
|
|
4
|
+
constructor(function_info: duckdb.ScalarFunctionInfo);
|
|
5
|
+
get bindData(): object | undefined;
|
|
6
|
+
getBindData(): object | undefined;
|
|
7
|
+
get extraInfo(): object | undefined;
|
|
8
|
+
getExtraInfo(): object | undefined;
|
|
9
|
+
get state(): object | undefined;
|
|
10
|
+
getState(): object | undefined;
|
|
11
|
+
setError(error: string): void;
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Renamed to DuckDBScalarFunctionInfo. */
|
|
14
|
+
export declare const DuckDBFunctionInfo: typeof DuckDBScalarFunctionInfo;
|
|
15
|
+
/** @deprecated Renamed to DuckDBScalarFunctionInfo. */
|
|
16
|
+
export type DuckDBFunctionInfo = DuckDBScalarFunctionInfo;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DuckDBFunctionInfo = void 0;
|
|
6
|
+
exports.DuckDBFunctionInfo = exports.DuckDBScalarFunctionInfo = void 0;
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
-
class
|
|
8
|
+
class DuckDBScalarFunctionInfo {
|
|
9
9
|
function_info;
|
|
10
10
|
constructor(function_info) {
|
|
11
11
|
this.function_info = function_info;
|
|
@@ -22,8 +22,16 @@ class DuckDBFunctionInfo {
|
|
|
22
22
|
getExtraInfo() {
|
|
23
23
|
return node_bindings_1.default.scalar_function_get_extra_info(this.function_info);
|
|
24
24
|
}
|
|
25
|
+
get state() {
|
|
26
|
+
return this.getState();
|
|
27
|
+
}
|
|
28
|
+
getState() {
|
|
29
|
+
return node_bindings_1.default.scalar_function_get_state(this.function_info);
|
|
30
|
+
}
|
|
25
31
|
setError(error) {
|
|
26
32
|
node_bindings_1.default.scalar_function_set_error(this.function_info, error);
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
|
-
exports.
|
|
35
|
+
exports.DuckDBScalarFunctionInfo = DuckDBScalarFunctionInfo;
|
|
36
|
+
/** @deprecated Renamed to DuckDBScalarFunctionInfo. */
|
|
37
|
+
exports.DuckDBFunctionInfo = DuckDBScalarFunctionInfo;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import duckdb from '@haybarn/node-bindings';
|
|
2
2
|
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
|
-
export declare class
|
|
4
|
-
private readonly
|
|
5
|
-
constructor(
|
|
3
|
+
export declare class DuckDBScalarFunctionInitInfo {
|
|
4
|
+
private readonly init_info;
|
|
5
|
+
constructor(init_info: duckdb.ScalarFunctionInitInfo);
|
|
6
6
|
get clientContext(): DuckDBClientContext;
|
|
7
7
|
getClientContext(): DuckDBClientContext;
|
|
8
8
|
get extraInfo(): object | undefined;
|
|
9
9
|
getExtraInfo(): object | undefined;
|
|
10
|
-
|
|
10
|
+
get bindData(): object | undefined;
|
|
11
|
+
getBindData(): object | undefined;
|
|
12
|
+
setState(state: object): void;
|
|
11
13
|
setError(error: string): void;
|
|
12
14
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DuckDBScalarFunctionInitInfo = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBClientContext_1 = require("./DuckDBClientContext");
|
|
9
|
+
class DuckDBScalarFunctionInitInfo {
|
|
10
|
+
init_info;
|
|
11
|
+
constructor(init_info) {
|
|
12
|
+
this.init_info = init_info;
|
|
13
|
+
}
|
|
14
|
+
get clientContext() {
|
|
15
|
+
return this.getClientContext();
|
|
16
|
+
}
|
|
17
|
+
getClientContext() {
|
|
18
|
+
return new DuckDBClientContext_1.DuckDBClientContext(node_bindings_1.default.scalar_function_init_get_client_context(this.init_info));
|
|
19
|
+
}
|
|
20
|
+
get extraInfo() {
|
|
21
|
+
return this.getExtraInfo();
|
|
22
|
+
}
|
|
23
|
+
getExtraInfo() {
|
|
24
|
+
return node_bindings_1.default.scalar_function_init_get_extra_info(this.init_info);
|
|
25
|
+
}
|
|
26
|
+
get bindData() {
|
|
27
|
+
return this.getBindData();
|
|
28
|
+
}
|
|
29
|
+
getBindData() {
|
|
30
|
+
return node_bindings_1.default.scalar_function_init_get_bind_data(this.init_info);
|
|
31
|
+
}
|
|
32
|
+
setState(state) {
|
|
33
|
+
node_bindings_1.default.scalar_function_init_set_state(this.init_info, state);
|
|
34
|
+
}
|
|
35
|
+
setError(error) {
|
|
36
|
+
node_bindings_1.default.scalar_function_init_set_error(this.init_info, error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.DuckDBScalarFunctionInitInfo = DuckDBScalarFunctionInitInfo;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
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
|
+
export type DuckDBTableBindFunction = (bindInfo: DuckDBTableFunctionBindInfo) => void;
|
|
8
|
+
export type DuckDBTableInitFunction = (initInfo: DuckDBTableFunctionInitInfo) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Produces one chunk of the scan per call.
|
|
11
|
+
*
|
|
12
|
+
* Set `outputDataChunk.rowCount` before writing, then write that many rows to
|
|
13
|
+
* each column vector. A row count of zero reports that the scan is finished, so
|
|
14
|
+
* a function that never sets zero never terminates.
|
|
15
|
+
*/
|
|
16
|
+
export type DuckDBTableMainFunction = (functionInfo: DuckDBTableFunctionInfo, outputDataChunk: DuckDBDataChunk) => void;
|
|
17
|
+
export declare class DuckDBTableFunction {
|
|
18
|
+
readonly table_function: duckdb.TableFunction;
|
|
19
|
+
constructor();
|
|
20
|
+
static create({ name, bindFunction, initFunction, localInitFunction, mainFunction, parameterTypes, namedParameterTypes, supportsProjectionPushdown, extraInfo, }: {
|
|
21
|
+
name: string;
|
|
22
|
+
bindFunction: DuckDBTableBindFunction;
|
|
23
|
+
initFunction: DuckDBTableInitFunction;
|
|
24
|
+
localInitFunction?: DuckDBTableInitFunction;
|
|
25
|
+
mainFunction: DuckDBTableMainFunction;
|
|
26
|
+
parameterTypes?: readonly DuckDBType[];
|
|
27
|
+
namedParameterTypes?: Readonly<Record<string, DuckDBType>>;
|
|
28
|
+
supportsProjectionPushdown?: boolean;
|
|
29
|
+
extraInfo?: object;
|
|
30
|
+
}): DuckDBTableFunction;
|
|
31
|
+
destroySync(): void;
|
|
32
|
+
setName(name: string): void;
|
|
33
|
+
setBindFunction(bindFunction: DuckDBTableBindFunction): void;
|
|
34
|
+
setInitFunction(initFunction: DuckDBTableInitFunction): void;
|
|
35
|
+
setLocalInitFunction(localInitFunction: DuckDBTableInitFunction): void;
|
|
36
|
+
setMainFunction(mainFunction: DuckDBTableMainFunction): void;
|
|
37
|
+
addParameter(parameterType: DuckDBType): void;
|
|
38
|
+
addNamedParameter(name: string, parameterType: DuckDBType): void;
|
|
39
|
+
setSupportsProjectionPushdown(pushdown: boolean): void;
|
|
40
|
+
setExtraInfo(extraInfo: object): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DuckDBTableFunction = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBDataChunk_1 = require("./DuckDBDataChunk");
|
|
9
|
+
const DuckDBTableFunctionBindInfo_1 = require("./DuckDBTableFunctionBindInfo");
|
|
10
|
+
const DuckDBTableFunctionInfo_1 = require("./DuckDBTableFunctionInfo");
|
|
11
|
+
const DuckDBTableFunctionInitInfo_1 = require("./DuckDBTableFunctionInitInfo");
|
|
12
|
+
class DuckDBTableFunction {
|
|
13
|
+
table_function;
|
|
14
|
+
constructor() {
|
|
15
|
+
this.table_function = node_bindings_1.default.create_table_function();
|
|
16
|
+
}
|
|
17
|
+
static create({ name, bindFunction, initFunction, localInitFunction, mainFunction, parameterTypes, namedParameterTypes, supportsProjectionPushdown, extraInfo, }) {
|
|
18
|
+
const tableFunction = new DuckDBTableFunction();
|
|
19
|
+
tableFunction.setName(name);
|
|
20
|
+
tableFunction.setBindFunction(bindFunction);
|
|
21
|
+
tableFunction.setInitFunction(initFunction);
|
|
22
|
+
if (localInitFunction) {
|
|
23
|
+
tableFunction.setLocalInitFunction(localInitFunction);
|
|
24
|
+
}
|
|
25
|
+
tableFunction.setMainFunction(mainFunction);
|
|
26
|
+
if (parameterTypes) {
|
|
27
|
+
for (const parameterType of parameterTypes) {
|
|
28
|
+
tableFunction.addParameter(parameterType);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (namedParameterTypes) {
|
|
32
|
+
for (const [parameterName, parameterType,] of Object.entries(namedParameterTypes)) {
|
|
33
|
+
tableFunction.addNamedParameter(parameterName, parameterType);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (supportsProjectionPushdown) {
|
|
37
|
+
tableFunction.setSupportsProjectionPushdown(true);
|
|
38
|
+
}
|
|
39
|
+
if (extraInfo) {
|
|
40
|
+
tableFunction.setExtraInfo(extraInfo);
|
|
41
|
+
}
|
|
42
|
+
return tableFunction;
|
|
43
|
+
}
|
|
44
|
+
destroySync() {
|
|
45
|
+
node_bindings_1.default.destroy_table_function_sync(this.table_function);
|
|
46
|
+
}
|
|
47
|
+
setName(name) {
|
|
48
|
+
node_bindings_1.default.table_function_set_name(this.table_function, name);
|
|
49
|
+
}
|
|
50
|
+
setBindFunction(bindFunction) {
|
|
51
|
+
node_bindings_1.default.table_function_set_bind(this.table_function, (info) => {
|
|
52
|
+
bindFunction(new DuckDBTableFunctionBindInfo_1.DuckDBTableFunctionBindInfo(info));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
setInitFunction(initFunction) {
|
|
56
|
+
node_bindings_1.default.table_function_set_init(this.table_function, (info) => {
|
|
57
|
+
initFunction(new DuckDBTableFunctionInitInfo_1.DuckDBTableFunctionInitInfo(info));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
setLocalInitFunction(localInitFunction) {
|
|
61
|
+
node_bindings_1.default.table_function_set_local_init(this.table_function, (info) => {
|
|
62
|
+
localInitFunction(new DuckDBTableFunctionInitInfo_1.DuckDBTableFunctionInitInfo(info));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
setMainFunction(mainFunction) {
|
|
66
|
+
node_bindings_1.default.table_function_set_function(this.table_function, (info, output) => {
|
|
67
|
+
mainFunction(new DuckDBTableFunctionInfo_1.DuckDBTableFunctionInfo(info), new DuckDBDataChunk_1.DuckDBDataChunk(output));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
addParameter(parameterType) {
|
|
71
|
+
node_bindings_1.default.table_function_add_parameter(this.table_function, parameterType.toLogicalType().logical_type);
|
|
72
|
+
}
|
|
73
|
+
addNamedParameter(name, parameterType) {
|
|
74
|
+
node_bindings_1.default.table_function_add_named_parameter(this.table_function, name, parameterType.toLogicalType().logical_type);
|
|
75
|
+
}
|
|
76
|
+
setSupportsProjectionPushdown(pushdown) {
|
|
77
|
+
node_bindings_1.default.table_function_supports_projection_pushdown(this.table_function, pushdown);
|
|
78
|
+
}
|
|
79
|
+
setExtraInfo(extraInfo) {
|
|
80
|
+
node_bindings_1.default.table_function_set_extra_info(this.table_function, extraInfo);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.DuckDBTableFunction = DuckDBTableFunction;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
import { DuckDBClientContext } from './DuckDBClientContext';
|
|
3
|
+
import { DuckDBType } from './DuckDBType';
|
|
4
|
+
import { DuckDBValue } from './values';
|
|
5
|
+
export declare class DuckDBTableFunctionBindInfo {
|
|
6
|
+
private readonly bind_info;
|
|
7
|
+
constructor(bind_info: duckdb.TableFunctionBindInfo);
|
|
8
|
+
get clientContext(): DuckDBClientContext;
|
|
9
|
+
getClientContext(): DuckDBClientContext;
|
|
10
|
+
get extraInfo(): object | undefined;
|
|
11
|
+
getExtraInfo(): object | undefined;
|
|
12
|
+
get parameterCount(): number;
|
|
13
|
+
getParameterCount(): number;
|
|
14
|
+
getParameter(index: number): DuckDBValue;
|
|
15
|
+
/** Returns null if no parameter with this name was supplied. */
|
|
16
|
+
getNamedParameter(name: string): DuckDBValue | null;
|
|
17
|
+
addResultColumn(name: string, type: DuckDBType): void;
|
|
18
|
+
setBindData(bindData: object): void;
|
|
19
|
+
setCardinality(cardinality: number, isExact: boolean): void;
|
|
20
|
+
setError(error: string): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DuckDBTableFunctionBindInfo = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBClientContext_1 = require("./DuckDBClientContext");
|
|
9
|
+
const readValue_1 = require("./readValue");
|
|
10
|
+
class DuckDBTableFunctionBindInfo {
|
|
11
|
+
bind_info;
|
|
12
|
+
constructor(bind_info) {
|
|
13
|
+
this.bind_info = bind_info;
|
|
14
|
+
}
|
|
15
|
+
get clientContext() {
|
|
16
|
+
return this.getClientContext();
|
|
17
|
+
}
|
|
18
|
+
getClientContext() {
|
|
19
|
+
return new DuckDBClientContext_1.DuckDBClientContext(node_bindings_1.default.table_function_get_client_context(this.bind_info));
|
|
20
|
+
}
|
|
21
|
+
get extraInfo() {
|
|
22
|
+
return this.getExtraInfo();
|
|
23
|
+
}
|
|
24
|
+
getExtraInfo() {
|
|
25
|
+
return node_bindings_1.default.bind_get_extra_info(this.bind_info);
|
|
26
|
+
}
|
|
27
|
+
get parameterCount() {
|
|
28
|
+
return this.getParameterCount();
|
|
29
|
+
}
|
|
30
|
+
getParameterCount() {
|
|
31
|
+
return node_bindings_1.default.bind_get_parameter_count(this.bind_info);
|
|
32
|
+
}
|
|
33
|
+
getParameter(index) {
|
|
34
|
+
return (0, readValue_1.readValue)(node_bindings_1.default.bind_get_parameter(this.bind_info, index));
|
|
35
|
+
}
|
|
36
|
+
/** Returns null if no parameter with this name was supplied. */
|
|
37
|
+
getNamedParameter(name) {
|
|
38
|
+
const value = node_bindings_1.default.bind_get_named_parameter(this.bind_info, name);
|
|
39
|
+
return value === null ? null : (0, readValue_1.readValue)(value);
|
|
40
|
+
}
|
|
41
|
+
addResultColumn(name, type) {
|
|
42
|
+
node_bindings_1.default.bind_add_result_column(this.bind_info, name, type.toLogicalType().logical_type);
|
|
43
|
+
}
|
|
44
|
+
setBindData(bindData) {
|
|
45
|
+
node_bindings_1.default.bind_set_bind_data(this.bind_info, bindData);
|
|
46
|
+
}
|
|
47
|
+
setCardinality(cardinality, isExact) {
|
|
48
|
+
node_bindings_1.default.bind_set_cardinality(this.bind_info, cardinality, isExact);
|
|
49
|
+
}
|
|
50
|
+
setError(error) {
|
|
51
|
+
node_bindings_1.default.bind_set_error(this.bind_info, error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.DuckDBTableFunctionBindInfo = DuckDBTableFunctionBindInfo;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
export declare class DuckDBTableFunctionInfo {
|
|
3
|
+
private readonly function_info;
|
|
4
|
+
constructor(function_info: duckdb.TableFunctionInfo);
|
|
5
|
+
get extraInfo(): object | undefined;
|
|
6
|
+
getExtraInfo(): object | undefined;
|
|
7
|
+
get bindData(): object | undefined;
|
|
8
|
+
getBindData(): object | undefined;
|
|
9
|
+
get initData(): object | undefined;
|
|
10
|
+
getInitData(): object | undefined;
|
|
11
|
+
/** The init data set by the local init function, which is per scanning thread. */
|
|
12
|
+
get localInitData(): object | undefined;
|
|
13
|
+
getLocalInitData(): object | undefined;
|
|
14
|
+
setError(error: string): void;
|
|
15
|
+
}
|