@avidian/duckdb-bun 0.0.0-stage → 1.0.1
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 +286 -2
- package/package.json +96 -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 +213 -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 +153 -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,31 @@
|
|
|
1
|
+
import duckdb from "../../../../src/bindings/index.ts";
|
|
2
|
+
import { DuckDBLogicalType } from '../DuckDBLogicalType';
|
|
3
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
4
|
+
import { Json } from '../Json';
|
|
5
|
+
|
|
6
|
+
export abstract class BaseDuckDBType<T extends DuckDBTypeId> {
|
|
7
|
+
public readonly typeId: T;
|
|
8
|
+
public readonly alias?: string;
|
|
9
|
+
protected constructor(typeId: T, alias?: string) {
|
|
10
|
+
this.typeId = typeId;
|
|
11
|
+
this.alias = alias;
|
|
12
|
+
}
|
|
13
|
+
public toString(): string {
|
|
14
|
+
return DuckDBTypeId[this.typeId];
|
|
15
|
+
}
|
|
16
|
+
public toLogicalType(): DuckDBLogicalType {
|
|
17
|
+
const logicalType = DuckDBLogicalType.create(
|
|
18
|
+
duckdb.create_logical_type(this.typeId as number as duckdb.Type)
|
|
19
|
+
);
|
|
20
|
+
if (this.alias) {
|
|
21
|
+
logicalType.alias = this.alias;
|
|
22
|
+
}
|
|
23
|
+
return logicalType;
|
|
24
|
+
}
|
|
25
|
+
public toJson(): Json {
|
|
26
|
+
return {
|
|
27
|
+
typeId: this.typeId,
|
|
28
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBAnyType extends BaseDuckDBType<DuckDBTypeId.ANY> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.ANY, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBAnyType();
|
|
9
|
+
public static create(alias?: string): DuckDBAnyType {
|
|
10
|
+
return alias ? new DuckDBAnyType(alias) : DuckDBAnyType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const ANY = DuckDBAnyType.instance;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import type { DuckDBType } from './DuckDBType';
|
|
3
|
+
import { DuckDBLogicalType } from '../DuckDBLogicalType';
|
|
4
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
5
|
+
import { Json } from '../Json';
|
|
6
|
+
|
|
7
|
+
export class DuckDBArrayType extends BaseDuckDBType<DuckDBTypeId.ARRAY> {
|
|
8
|
+
public readonly valueType: DuckDBType;
|
|
9
|
+
public readonly length: number;
|
|
10
|
+
public constructor(valueType: DuckDBType, length: number, alias?: string) {
|
|
11
|
+
super(DuckDBTypeId.ARRAY, alias);
|
|
12
|
+
this.valueType = valueType;
|
|
13
|
+
this.length = length;
|
|
14
|
+
}
|
|
15
|
+
public toString(): string {
|
|
16
|
+
return `${this.valueType}[${this.length}]`;
|
|
17
|
+
}
|
|
18
|
+
public override toLogicalType(): DuckDBLogicalType {
|
|
19
|
+
const logicalType = DuckDBLogicalType.createArray(
|
|
20
|
+
this.valueType.toLogicalType(),
|
|
21
|
+
this.length
|
|
22
|
+
);
|
|
23
|
+
if (this.alias) {
|
|
24
|
+
logicalType.alias = this.alias;
|
|
25
|
+
}
|
|
26
|
+
return logicalType;
|
|
27
|
+
}
|
|
28
|
+
public override toJson(): Json {
|
|
29
|
+
return {
|
|
30
|
+
typeId: this.typeId,
|
|
31
|
+
valueType: this.valueType.toJson(),
|
|
32
|
+
length: this.length,
|
|
33
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function ARRAY(
|
|
38
|
+
valueType: DuckDBType,
|
|
39
|
+
length: number,
|
|
40
|
+
alias?: string
|
|
41
|
+
): DuckDBArrayType {
|
|
42
|
+
return new DuckDBArrayType(valueType, length, alias);
|
|
43
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBBigIntType extends BaseDuckDBType<DuckDBTypeId.BIGINT> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.BIGINT, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBBigIntType();
|
|
9
|
+
public static create(alias?: string): DuckDBBigIntType {
|
|
10
|
+
return alias ? new DuckDBBigIntType(alias) : DuckDBBigIntType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max: bigint = 2n ** 63n - 1n;
|
|
13
|
+
public static readonly Min: bigint = -(2n ** 63n);
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBBigIntType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBBigIntType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const BIGINT = DuckDBBigIntType.instance;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBBigNumType extends BaseDuckDBType<DuckDBTypeId.BIGNUM> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.BIGNUM, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBBigNumType();
|
|
9
|
+
public static create(alias?: string): DuckDBBigNumType {
|
|
10
|
+
return alias ? new DuckDBBigNumType(alias) : DuckDBBigNumType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max: bigint = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
|
|
13
|
+
public static readonly Min: bigint = -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBBigNumType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBBigNumType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const BIGNUM = DuckDBBigNumType.instance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBBitType extends BaseDuckDBType<DuckDBTypeId.BIT> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.BIT, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBBitType();
|
|
9
|
+
public static create(alias?: string): DuckDBBitType {
|
|
10
|
+
return alias ? new DuckDBBitType(alias) : DuckDBBitType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const BIT = DuckDBBitType.instance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBBlobType extends BaseDuckDBType<DuckDBTypeId.BLOB> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.BLOB, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBBlobType();
|
|
9
|
+
public static create(alias?: string): DuckDBBlobType {
|
|
10
|
+
return alias ? new DuckDBBlobType(alias) : DuckDBBlobType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const BLOB = DuckDBBlobType.instance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBBooleanType extends BaseDuckDBType<DuckDBTypeId.BOOLEAN> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.BOOLEAN, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBBooleanType();
|
|
9
|
+
public static create(alias?: string): DuckDBBooleanType {
|
|
10
|
+
return alias ? new DuckDBBooleanType(alias) : DuckDBBooleanType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const BOOLEAN = DuckDBBooleanType.instance;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
import { DuckDBDateValue } from '../values';
|
|
4
|
+
|
|
5
|
+
export class DuckDBDateType extends BaseDuckDBType<DuckDBTypeId.DATE> {
|
|
6
|
+
public constructor(alias?: string) {
|
|
7
|
+
super(DuckDBTypeId.DATE, alias);
|
|
8
|
+
}
|
|
9
|
+
public static readonly instance = new DuckDBDateType();
|
|
10
|
+
public static create(alias?: string): DuckDBDateType {
|
|
11
|
+
return alias ? new DuckDBDateType(alias) : DuckDBDateType.instance;
|
|
12
|
+
}
|
|
13
|
+
public get epoch() {
|
|
14
|
+
return DuckDBDateValue.Epoch;
|
|
15
|
+
}
|
|
16
|
+
public get max() {
|
|
17
|
+
return DuckDBDateValue.Max;
|
|
18
|
+
}
|
|
19
|
+
public get min() {
|
|
20
|
+
return DuckDBDateValue.Min;
|
|
21
|
+
}
|
|
22
|
+
public get posInf() {
|
|
23
|
+
return DuckDBDateValue.PosInf;
|
|
24
|
+
}
|
|
25
|
+
public get negInf() {
|
|
26
|
+
return DuckDBDateValue.NegInf;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const DATE = DuckDBDateType.instance;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBLogicalType } from '../DuckDBLogicalType';
|
|
3
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
4
|
+
import { Json } from '../Json';
|
|
5
|
+
|
|
6
|
+
export class DuckDBDecimalType extends BaseDuckDBType<DuckDBTypeId.DECIMAL> {
|
|
7
|
+
public readonly width: number;
|
|
8
|
+
public readonly scale: number;
|
|
9
|
+
public constructor(width: number, scale: number, alias?: string) {
|
|
10
|
+
super(DuckDBTypeId.DECIMAL, alias);
|
|
11
|
+
this.width = width;
|
|
12
|
+
this.scale = scale;
|
|
13
|
+
}
|
|
14
|
+
public toString(): string {
|
|
15
|
+
return `DECIMAL(${this.width},${this.scale})`;
|
|
16
|
+
}
|
|
17
|
+
public override toLogicalType(): DuckDBLogicalType {
|
|
18
|
+
const logicalType = DuckDBLogicalType.createDecimal(this.width, this.scale);
|
|
19
|
+
if (this.alias) {
|
|
20
|
+
logicalType.alias = this.alias;
|
|
21
|
+
}
|
|
22
|
+
return logicalType;
|
|
23
|
+
}
|
|
24
|
+
public override toJson(): Json {
|
|
25
|
+
return {
|
|
26
|
+
typeId: this.typeId,
|
|
27
|
+
width: this.width,
|
|
28
|
+
scale: this.scale,
|
|
29
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
public static readonly default = new DuckDBDecimalType(18, 3);
|
|
33
|
+
}
|
|
34
|
+
export function DECIMAL(
|
|
35
|
+
width?: number,
|
|
36
|
+
scale?: number,
|
|
37
|
+
alias?: string
|
|
38
|
+
): DuckDBDecimalType {
|
|
39
|
+
if (width === undefined) {
|
|
40
|
+
return DuckDBDecimalType.default;
|
|
41
|
+
}
|
|
42
|
+
if (scale === undefined) {
|
|
43
|
+
return new DuckDBDecimalType(width, 0);
|
|
44
|
+
}
|
|
45
|
+
return new DuckDBDecimalType(width, scale, alias);
|
|
46
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBDoubleType extends BaseDuckDBType<DuckDBTypeId.DOUBLE> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.DOUBLE, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBDoubleType();
|
|
9
|
+
public static create(alias?: string): DuckDBDoubleType {
|
|
10
|
+
return alias ? new DuckDBDoubleType(alias) : DuckDBDoubleType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max = Number.MAX_VALUE;
|
|
13
|
+
public static readonly Min = -Number.MAX_VALUE;
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBDoubleType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBDoubleType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const DOUBLE = DuckDBDoubleType.instance;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBLogicalType } from '../DuckDBLogicalType';
|
|
3
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
4
|
+
import { Json } from '../Json';
|
|
5
|
+
import { quotedString } from '../sql';
|
|
6
|
+
|
|
7
|
+
export class DuckDBEnumType extends BaseDuckDBType<DuckDBTypeId.ENUM> {
|
|
8
|
+
public readonly values: readonly string[];
|
|
9
|
+
public readonly valueIndexes: Readonly<Record<string, number>>;
|
|
10
|
+
public readonly internalTypeId: DuckDBTypeId;
|
|
11
|
+
public constructor(
|
|
12
|
+
values: readonly string[],
|
|
13
|
+
internalTypeId: DuckDBTypeId,
|
|
14
|
+
alias?: string
|
|
15
|
+
) {
|
|
16
|
+
super(DuckDBTypeId.ENUM, alias);
|
|
17
|
+
this.values = values;
|
|
18
|
+
// Null prototype: with a plain object literal, a lookup of an inherited key
|
|
19
|
+
// such as 'toString' or 'constructor' returns a function instead of
|
|
20
|
+
// undefined, so neither this map nor indexForValue could tell a member from
|
|
21
|
+
// an Object.prototype property.
|
|
22
|
+
const valueIndexes: Record<string, number> = Object.create(null);
|
|
23
|
+
for (let i = 0; i < values.length; i++) {
|
|
24
|
+
valueIndexes[values[i]] = i;
|
|
25
|
+
}
|
|
26
|
+
this.valueIndexes = valueIndexes;
|
|
27
|
+
this.internalTypeId = internalTypeId;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The index of the given value in this enum.
|
|
31
|
+
*
|
|
32
|
+
* Throws if the value is not a member: storing an unknown value would
|
|
33
|
+
* otherwise write index 0, silently substituting the enum's first member.
|
|
34
|
+
*/
|
|
35
|
+
public indexForValue(value: string): number {
|
|
36
|
+
const index = this.valueIndexes[value];
|
|
37
|
+
if (index === undefined) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`${quotedString(value)} is not a member of ${this.toStringForError()}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return index;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Like toString, but bounded: an enum can have millions of members, and all of
|
|
46
|
+
* them in an error message would bury the part that matters.
|
|
47
|
+
*/
|
|
48
|
+
private toStringForError(): string {
|
|
49
|
+
if (this.alias) {
|
|
50
|
+
return this.alias;
|
|
51
|
+
}
|
|
52
|
+
const shown = 8;
|
|
53
|
+
if (this.values.length <= shown) {
|
|
54
|
+
return this.toString();
|
|
55
|
+
}
|
|
56
|
+
const listed = this.values.slice(0, shown).map(quotedString).join(', ');
|
|
57
|
+
return `ENUM(${listed}, and ${this.values.length - shown} more)`;
|
|
58
|
+
}
|
|
59
|
+
public toString(): string {
|
|
60
|
+
return `ENUM(${this.values.map(quotedString).join(', ')})`;
|
|
61
|
+
}
|
|
62
|
+
public override toLogicalType(): DuckDBLogicalType {
|
|
63
|
+
const logicalType = DuckDBLogicalType.createEnum(this.values);
|
|
64
|
+
if (this.alias) {
|
|
65
|
+
logicalType.alias = this.alias;
|
|
66
|
+
}
|
|
67
|
+
return logicalType;
|
|
68
|
+
}
|
|
69
|
+
public override toJson(): Json {
|
|
70
|
+
return {
|
|
71
|
+
typeId: this.typeId,
|
|
72
|
+
values: [...this.values],
|
|
73
|
+
internalTypeId: this.internalTypeId,
|
|
74
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function ENUM8(
|
|
79
|
+
values: readonly string[],
|
|
80
|
+
alias?: string
|
|
81
|
+
): DuckDBEnumType {
|
|
82
|
+
return new DuckDBEnumType(values, DuckDBTypeId.UTINYINT, alias);
|
|
83
|
+
}
|
|
84
|
+
export function ENUM16(
|
|
85
|
+
values: readonly string[],
|
|
86
|
+
alias?: string
|
|
87
|
+
): DuckDBEnumType {
|
|
88
|
+
return new DuckDBEnumType(values, DuckDBTypeId.USMALLINT, alias);
|
|
89
|
+
}
|
|
90
|
+
export function ENUM32(
|
|
91
|
+
values: readonly string[],
|
|
92
|
+
alias?: string
|
|
93
|
+
): DuckDBEnumType {
|
|
94
|
+
return new DuckDBEnumType(values, DuckDBTypeId.UINTEGER, alias);
|
|
95
|
+
}
|
|
96
|
+
export function ENUM(
|
|
97
|
+
values: readonly string[],
|
|
98
|
+
alias?: string
|
|
99
|
+
): DuckDBEnumType {
|
|
100
|
+
if (values.length < 256) {
|
|
101
|
+
return ENUM8(values, alias);
|
|
102
|
+
} else if (values.length < 65536) {
|
|
103
|
+
return ENUM16(values, alias);
|
|
104
|
+
} else if (values.length < 4294967296) {
|
|
105
|
+
return ENUM32(values, alias);
|
|
106
|
+
} else {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`ENUM types cannot have more than 4294967295 values; received ${values.length}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBFloatType extends BaseDuckDBType<DuckDBTypeId.FLOAT> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.FLOAT, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBFloatType();
|
|
9
|
+
public static create(alias?: string): DuckDBFloatType {
|
|
10
|
+
return alias ? new DuckDBFloatType(alias) : DuckDBFloatType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max = Math.fround(3.4028235e38);
|
|
13
|
+
public static readonly Min = Math.fround(-3.4028235e38);
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBFloatType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBFloatType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const FLOAT = DuckDBFloatType.instance;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
import { Json } from '../Json';
|
|
4
|
+
import { quotedString } from '../sql';
|
|
5
|
+
|
|
6
|
+
export class DuckDBGeometryType extends BaseDuckDBType<DuckDBTypeId.GEOMETRY> {
|
|
7
|
+
/**
|
|
8
|
+
* Coordinate Reference System (e.g. a WKT2 string) attached to the type.
|
|
9
|
+
*
|
|
10
|
+
* Read-only: setting `crs` on a `DuckDBGeometryType` is not propagated by
|
|
11
|
+
* `toLogicalType()`. To produce a GEOMETRY logical type carrying a CRS,
|
|
12
|
+
* construct it via SQL (e.g. `'POINT(1 2)'::GEOMETRY('<crs>')`).
|
|
13
|
+
*/
|
|
14
|
+
public readonly crs?: string;
|
|
15
|
+
public constructor(alias?: string, crs?: string) {
|
|
16
|
+
super(DuckDBTypeId.GEOMETRY, alias);
|
|
17
|
+
this.crs = crs;
|
|
18
|
+
}
|
|
19
|
+
public override toString(): string {
|
|
20
|
+
return this.crs ? `GEOMETRY(${quotedString(this.crs)})` : 'GEOMETRY';
|
|
21
|
+
}
|
|
22
|
+
public override toJson(): Json {
|
|
23
|
+
return {
|
|
24
|
+
typeId: this.typeId,
|
|
25
|
+
...(this.crs ? { crs: this.crs } : {}),
|
|
26
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
public static readonly instance = new DuckDBGeometryType();
|
|
30
|
+
public static create(alias?: string, crs?: string): DuckDBGeometryType {
|
|
31
|
+
return alias || crs
|
|
32
|
+
? new DuckDBGeometryType(alias, crs)
|
|
33
|
+
: DuckDBGeometryType.instance;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const GEOMETRY = DuckDBGeometryType.instance;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBHugeIntType extends BaseDuckDBType<DuckDBTypeId.HUGEINT> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.HUGEINT, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBHugeIntType();
|
|
9
|
+
public static create(alias?: string): DuckDBHugeIntType {
|
|
10
|
+
return alias ? new DuckDBHugeIntType(alias) : DuckDBHugeIntType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max: bigint = 2n ** 127n - 1n;
|
|
13
|
+
public static readonly Min: bigint = -(2n ** 127n);
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBHugeIntType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBHugeIntType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const HUGEINT = DuckDBHugeIntType.instance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBIntegerLiteralType extends BaseDuckDBType<DuckDBTypeId.INTEGER_LITERAL> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.INTEGER_LITERAL, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBIntegerLiteralType();
|
|
9
|
+
public static create(alias?: string): DuckDBIntegerLiteralType {
|
|
10
|
+
return alias ? new DuckDBIntegerLiteralType(alias) : DuckDBIntegerLiteralType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const INTEGER_LITERAL = DuckDBIntegerLiteralType.instance;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBIntegerType extends BaseDuckDBType<DuckDBTypeId.INTEGER> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.INTEGER, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBIntegerType();
|
|
9
|
+
public static create(alias?: string): DuckDBIntegerType {
|
|
10
|
+
return alias ? new DuckDBIntegerType(alias) : DuckDBIntegerType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max = 2 ** 31 - 1;
|
|
13
|
+
public static readonly Min = -(2 ** 31);
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBIntegerType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBIntegerType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const INTEGER = DuckDBIntegerType.instance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBIntervalType extends BaseDuckDBType<DuckDBTypeId.INTERVAL> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.INTERVAL, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBIntervalType();
|
|
9
|
+
public static create(alias?: string): DuckDBIntervalType {
|
|
10
|
+
return alias ? new DuckDBIntervalType(alias) : DuckDBIntervalType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const INTERVAL = DuckDBIntervalType.instance;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import type { DuckDBType } from './DuckDBType';
|
|
3
|
+
import { DuckDBLogicalType } from '../DuckDBLogicalType';
|
|
4
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
5
|
+
import { Json } from '../Json';
|
|
6
|
+
|
|
7
|
+
export class DuckDBListType extends BaseDuckDBType<DuckDBTypeId.LIST> {
|
|
8
|
+
public readonly valueType: DuckDBType;
|
|
9
|
+
public constructor(valueType: DuckDBType, alias?: string) {
|
|
10
|
+
super(DuckDBTypeId.LIST, alias);
|
|
11
|
+
this.valueType = valueType;
|
|
12
|
+
}
|
|
13
|
+
public toString(): string {
|
|
14
|
+
return `${this.valueType}[]`;
|
|
15
|
+
}
|
|
16
|
+
public override toLogicalType(): DuckDBLogicalType {
|
|
17
|
+
const logicalType = DuckDBLogicalType.createList(
|
|
18
|
+
this.valueType.toLogicalType()
|
|
19
|
+
);
|
|
20
|
+
if (this.alias) {
|
|
21
|
+
logicalType.alias = this.alias;
|
|
22
|
+
}
|
|
23
|
+
return logicalType;
|
|
24
|
+
}
|
|
25
|
+
public override toJson(): Json {
|
|
26
|
+
return {
|
|
27
|
+
typeId: this.typeId,
|
|
28
|
+
valueType: this.valueType.toJson(),
|
|
29
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function LIST(valueType: DuckDBType, alias?: string): DuckDBListType {
|
|
34
|
+
return new DuckDBListType(valueType, alias);
|
|
35
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import type { DuckDBType } from './DuckDBType';
|
|
3
|
+
import { DuckDBLogicalType } from '../DuckDBLogicalType';
|
|
4
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
5
|
+
import { Json } from '../Json';
|
|
6
|
+
|
|
7
|
+
export class DuckDBMapType extends BaseDuckDBType<DuckDBTypeId.MAP> {
|
|
8
|
+
public readonly keyType: DuckDBType;
|
|
9
|
+
public readonly valueType: DuckDBType;
|
|
10
|
+
public constructor(
|
|
11
|
+
keyType: DuckDBType,
|
|
12
|
+
valueType: DuckDBType,
|
|
13
|
+
alias?: string
|
|
14
|
+
) {
|
|
15
|
+
super(DuckDBTypeId.MAP, alias);
|
|
16
|
+
this.keyType = keyType;
|
|
17
|
+
this.valueType = valueType;
|
|
18
|
+
}
|
|
19
|
+
public toString(): string {
|
|
20
|
+
return `MAP(${this.keyType}, ${this.valueType})`;
|
|
21
|
+
}
|
|
22
|
+
public override toLogicalType(): DuckDBLogicalType {
|
|
23
|
+
const logicalType = DuckDBLogicalType.createMap(
|
|
24
|
+
this.keyType.toLogicalType(),
|
|
25
|
+
this.valueType.toLogicalType()
|
|
26
|
+
);
|
|
27
|
+
if (this.alias) {
|
|
28
|
+
logicalType.alias = this.alias;
|
|
29
|
+
}
|
|
30
|
+
return logicalType;
|
|
31
|
+
}
|
|
32
|
+
public override toJson(): Json {
|
|
33
|
+
return {
|
|
34
|
+
typeId: this.typeId,
|
|
35
|
+
keyType: this.keyType.toJson(),
|
|
36
|
+
valueType: this.valueType.toJson(),
|
|
37
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function MAP(
|
|
42
|
+
keyType: DuckDBType,
|
|
43
|
+
valueType: DuckDBType,
|
|
44
|
+
alias?: string
|
|
45
|
+
): DuckDBMapType {
|
|
46
|
+
return new DuckDBMapType(keyType, valueType, alias);
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBSQLNullType extends BaseDuckDBType<DuckDBTypeId.SQLNULL> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.SQLNULL, alias);
|
|
7
|
+
}
|
|
8
|
+
/** DuckDB's name for the type, quoted because NULL is a keyword. */
|
|
9
|
+
public toString(): string {
|
|
10
|
+
return '"NULL"';
|
|
11
|
+
}
|
|
12
|
+
public static readonly instance = new DuckDBSQLNullType();
|
|
13
|
+
public static create(alias?: string): DuckDBSQLNullType {
|
|
14
|
+
return alias ? new DuckDBSQLNullType(alias) : DuckDBSQLNullType.instance;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const SQLNULL = DuckDBSQLNullType.instance;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBSmallIntType extends BaseDuckDBType<DuckDBTypeId.SMALLINT> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.SMALLINT, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBSmallIntType();
|
|
9
|
+
public static create(alias?: string): DuckDBSmallIntType {
|
|
10
|
+
return alias ? new DuckDBSmallIntType(alias) : DuckDBSmallIntType.instance;
|
|
11
|
+
}
|
|
12
|
+
public static readonly Max = 2 ** 15 - 1;
|
|
13
|
+
public static readonly Min = -(2 ** 15);
|
|
14
|
+
public get max() {
|
|
15
|
+
return DuckDBSmallIntType.Max;
|
|
16
|
+
}
|
|
17
|
+
public get min() {
|
|
18
|
+
return DuckDBSmallIntType.Min;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const SMALLINT = DuckDBSmallIntType.instance;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseDuckDBType } from './BaseDuckDBType';
|
|
2
|
+
import { DuckDBTypeId } from '../DuckDBTypeId';
|
|
3
|
+
|
|
4
|
+
export class DuckDBStringLiteralType extends BaseDuckDBType<DuckDBTypeId.STRING_LITERAL> {
|
|
5
|
+
public constructor(alias?: string) {
|
|
6
|
+
super(DuckDBTypeId.STRING_LITERAL, alias);
|
|
7
|
+
}
|
|
8
|
+
public static readonly instance = new DuckDBStringLiteralType();
|
|
9
|
+
public static create(alias?: string): DuckDBStringLiteralType {
|
|
10
|
+
return alias ? new DuckDBStringLiteralType(alias) : DuckDBStringLiteralType.instance;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const STRING_LITERAL = DuckDBStringLiteralType.instance;
|