Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data value overhaul #38

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions api/src/DuckDBAppender.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import duckdb from '@duckdb/node-bindings';
import { DuckDBType } from './DuckDBType';
import { DuckDBLogicalType } from './DuckDBLogicalType';
import { Date_, Interval, Time, Timestamp } from './DuckDBValue';
import { DuckDBDataChunk } from './DuckDBDataChunk';
import { DuckDBLogicalType } from './DuckDBLogicalType';
import { DuckDBType } from './DuckDBType';
import {
DuckDBDateValue,
DuckDBIntervalValue,
DuckDBTimestampValue,
DuckDBTimeValue,
} from './values';

export class DuckDBAppender {
private readonly appender: duckdb.Appender;
Expand Down Expand Up @@ -70,18 +75,18 @@ export class DuckDBAppender {
public appendDouble(value: number) {
duckdb.append_double(this.appender, value);
}
public appendDate(value: Date_) {
public appendDate(value: DuckDBDateValue) {
duckdb.append_date(this.appender, value);
}
public appendTime(value: Time) {
public appendTime(value: DuckDBTimeValue) {
duckdb.append_time(this.appender, value);
}
public appendTimestamp(value: Timestamp) {
public appendTimestamp(value: DuckDBTimestampValue) {
duckdb.append_timestamp(this.appender, value);
}
// TODO: append TIMESTAMPS_S/_MS/_NS?
// TODO: append TIME_TZ/TIMESTAMP_TZ?
public appendInterval(value: Interval) {
public appendInterval(value: DuckDBIntervalValue) {
duckdb.append_interval(this.appender, value);
}
public appendVarchar(value: string) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/DuckDBLogicalType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class DuckDBArrayLogicalType extends DuckDBLogicalType {
public get length(): number {
return duckdb.array_type_array_size(this.logical_type);
}
public override asType(): DuckDBListType {
public override asType(): DuckDBArrayType {
return new DuckDBArrayType(this.valueType.asType(), this.length);
}
}
Expand Down
18 changes: 12 additions & 6 deletions api/src/DuckDBPreparedStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import duckdb from '@duckdb/node-bindings';
import { DuckDBPendingResult } from './DuckDBPendingResult';
import { DuckDBResult } from './DuckDBResult';
import { DuckDBTypeId } from './DuckDBTypeId';
import { Date_, Decimal, Interval, Time, Timestamp } from './DuckDBValue';
import { StatementType } from './enums';
import {
DuckDBDateValue,
DuckDBDecimalValue,
DuckDBIntervalValue,
DuckDBTimestampValue,
DuckDBTimeValue,
} from './values';

export class DuckDBPreparedStatement {
private readonly prepared_statement: duckdb.PreparedStatement;
Expand Down Expand Up @@ -67,7 +73,7 @@ export class DuckDBPreparedStatement {
public bindUHugeInt(parameterIndex: number, value: bigint) {
duckdb.bind_uhugeint(this.prepared_statement, parameterIndex, value);
}
public bindDecimal(parameterIndex: number, value: Decimal) {
public bindDecimal(parameterIndex: number, value: DuckDBDecimalValue) {
duckdb.bind_decimal(this.prepared_statement, parameterIndex, value);
}
public bindFloat(parameterIndex: number, value: number) {
Expand All @@ -76,18 +82,18 @@ export class DuckDBPreparedStatement {
public bindDouble(parameterIndex: number, value: number) {
duckdb.bind_double(this.prepared_statement, parameterIndex, value);
}
public bindDate(parameterIndex: number, value: Date_) {
public bindDate(parameterIndex: number, value: DuckDBDateValue) {
duckdb.bind_date(this.prepared_statement, parameterIndex, value);
}
public bindTime(parameterIndex: number, value: Time) {
public bindTime(parameterIndex: number, value: DuckDBTimeValue) {
duckdb.bind_time(this.prepared_statement, parameterIndex, value);
}
public bindTimestamp(parameterIndex: number, value: Timestamp) {
public bindTimestamp(parameterIndex: number, value: DuckDBTimestampValue) {
duckdb.bind_timestamp(this.prepared_statement, parameterIndex, value);
}
// TODO: bind TIMESTAMPS_S/_MS/_NS?
// TODO: bind TIME_TZ/TIMESTAMP_TZ?
public bindInterval(parameterIndex: number, value: Interval) {
public bindInterval(parameterIndex: number, value: DuckDBIntervalValue) {
duckdb.bind_interval(this.prepared_statement, parameterIndex, value);
}
public bindVarchar(parameterIndex: number, value: string) {
Expand Down
Loading