Skip to content

Commit 591a357

Browse files
committed
[SEA-NodeJS] add TIMESTAMP_NTZ / TIMESTAMP_LTZ bound-param types
Consolidates the last net-new bit of the superseded #408: two SEA-path DBSQLParameterType variants for binding timezone-explicit timestamps. The type name flows through the existing param codec (toSparkParameter → sqlType), which the kernel accepts — validated live (SELECT ? with TIMESTAMP_NTZ/LTZ returns the bound values). On the Thrift backend they degrade to a plain TIMESTAMP bind. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
1 parent 368945a commit 591a357

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

lib/DBSQLParameter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ export enum DBSQLParameterType {
88
STRING = 'STRING',
99
DATE = 'DATE',
1010
TIMESTAMP = 'TIMESTAMP',
11+
// Timezone-explicit timestamp variants. A bare `Date` value defaults to
12+
// `TIMESTAMP`; set one of these explicitly to bind a TIMESTAMP_NTZ (no
13+
// timezone, wall-clock) or TIMESTAMP_LTZ (local timezone) parameter. These
14+
// are SEA-path types the kernel param codec accepts; the Thrift wire only
15+
// has `TIMESTAMP`, so on the Thrift backend they degrade to a plain
16+
// TIMESTAMP bind.
17+
TIMESTAMP_NTZ = 'TIMESTAMP_NTZ',
18+
TIMESTAMP_LTZ = 'TIMESTAMP_LTZ',
1119
FLOAT = 'FLOAT',
1220
DECIMAL = 'DECIMAL',
1321
DOUBLE = 'DOUBLE',

tests/unit/sea/positionalParams.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ describe('SeaPositionalParams.buildSeaPositionalParams', () => {
7575
{ sqlType: 'TIMESTAMP', value: '2024-01-15 10:30:00' },
7676
]);
7777
});
78+
79+
it('honours explicit TIMESTAMP_NTZ / TIMESTAMP_LTZ types (kernel param codec)', () => {
80+
expect(
81+
buildSeaPositionalParams([
82+
new DBSQLParameter({ type: DBSQLParameterType.TIMESTAMP_NTZ, value: '2024-01-15 10:30:00' }),
83+
new DBSQLParameter({ type: DBSQLParameterType.TIMESTAMP_LTZ, value: '2024-01-15 10:30:00' }),
84+
]),
85+
).to.deep.equal([
86+
{ sqlType: 'TIMESTAMP_NTZ', value: '2024-01-15 10:30:00' },
87+
{ sqlType: 'TIMESTAMP_LTZ', value: '2024-01-15 10:30:00' },
88+
]);
89+
});
7890
});
7991

8092
describe('SeaPositionalParams.buildSeaNamedParams', () => {

0 commit comments

Comments
 (0)