Skip to content

Commit 239dccb

Browse files
authored
fix: Remove date in favor of timestamp, handle interval, pass underlying value to arrow (#62)
1 parent ffa3979 commit 239dccb

File tree

3 files changed

+9
-92
lines changed

3 files changed

+9
-92
lines changed

src/scalar/date.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/scalar/scalar.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { DataType, Precision } from '@apache-arrow/esnext-esm';
1+
import { DataType, Precision, TimeUnit } from '@apache-arrow/esnext-esm';
22

33
import { JSONType } from '../types/json.js';
44
import { UUIDType } from '../types/uuid.js';
55

66
import { Bool } from './bool.js';
7-
import { Date } from './date.js';
87
import { Float32 } from './float32.js';
98
import { Float64 } from './float64.js';
109
import { Int16 } from './int16.js';
@@ -90,7 +89,13 @@ export const newScalar = (dataType: DataType): Scalar<unknown> => {
9089
}
9190

9291
if (DataType.isDate(dataType)) {
93-
return new Date(dataType.unit);
92+
// TODO: Add Date support
93+
return new Timestamp(TimeUnit.SECOND);
94+
}
95+
96+
if (DataType.isInterval(dataType)) {
97+
// TODO: Add Interval support
98+
return new JSONScalar();
9499
}
95100

96101
if (dataType instanceof UUIDType) {

src/schema/resource.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { tableToIPC, Table as ArrowTable, RecordBatch, vectorFromArray } from '@
33
import { ResourceError } from '../errors/errors.js';
44
import type { Scalar, Vector } from '../scalar/scalar.js';
55
import { newScalar } from '../scalar/scalar.js';
6-
import { isExtensionType } from '../types/extensions.js';
76

87
import { cqIDColumn } from './meta.js';
98
import type { Table } from './table.js';
@@ -64,11 +63,7 @@ export const encodeResource = (resource: Resource): Uint8Array => {
6463
let batch = new RecordBatch(schema, undefined);
6564
for (let index = 0; index < table.columns.length; index++) {
6665
const column = table.columns[index];
67-
// For extension types, we need to get the underlying value
68-
const data = isExtensionType(column.type)
69-
? resource.getColumnData(column.name).value
70-
: resource.getColumnData(column.name);
71-
66+
const data = resource.getColumnData(column.name).value;
7267
const vector = vectorFromArray([data], column.type);
7368
batch = batch.setChildAt(index, vector);
7469
}

0 commit comments

Comments
 (0)