@@ -8,6 +8,15 @@ export enum DBSQLParameterType {
88 STRING = 'STRING' ,
99 DATE = 'DATE' ,
1010 TIMESTAMP = 'TIMESTAMP' ,
11+ // `TIMESTAMP_NTZ` binds a timezone-free (wall-clock) timestamp. It is a real
12+ // Spark type, bound natively on both the Thrift and kernel backends (requires
13+ // a server that supports TIMESTAMP_NTZ; Spark 3.4+ / recent DBR).
14+ TIMESTAMP_NTZ = 'TIMESTAMP_NTZ' ,
15+ // `TIMESTAMP_LTZ` is an alias for `TIMESTAMP`: Spark has no distinct
16+ // TIMESTAMP_LTZ type — `TIMESTAMP` already carries local/instant (LTZ)
17+ // semantics. `toSparkParameter` therefore binds it as `TIMESTAMP` on the wire
18+ // (valid on both backends); it exists only as a self-documenting alias.
19+ TIMESTAMP_LTZ = 'TIMESTAMP_LTZ' ,
1120 FLOAT = 'FLOAT' ,
1221 DECIMAL = 'DECIMAL' ,
1322 DOUBLE = 'DOUBLE' ,
@@ -50,10 +59,16 @@ export class DBSQLParameter {
5059 return new TSparkParameter ( { name } ) ; // for NULL neither `type` nor `value` should be set
5160 }
5261
62+ // Map timezone-explicit timestamp aliases to their Spark wire type. Spark
63+ // has no distinct TIMESTAMP_LTZ type (TIMESTAMP carries LTZ semantics), so
64+ // bind it as TIMESTAMP — valid on both the Thrift and kernel backends.
65+ // TIMESTAMP_NTZ is a real Spark type and is bound natively.
66+ const wireType = this . type === DBSQLParameterType . TIMESTAMP_LTZ ? DBSQLParameterType . TIMESTAMP : this . type ;
67+
5368 if ( typeof this . value === 'boolean' ) {
5469 return new TSparkParameter ( {
5570 name,
56- type : this . type ?? DBSQLParameterType . BOOLEAN ,
71+ type : wireType ?? DBSQLParameterType . BOOLEAN ,
5772 value : new TSparkParameterValue ( {
5873 stringValue : this . value ? 'TRUE' : 'FALSE' ,
5974 } ) ,
@@ -63,7 +78,7 @@ export class DBSQLParameter {
6378 if ( typeof this . value === 'number' ) {
6479 return new TSparkParameter ( {
6580 name,
66- type : this . type ?? ( Number . isInteger ( this . value ) ? DBSQLParameterType . INTEGER : DBSQLParameterType . DOUBLE ) ,
81+ type : wireType ?? ( Number . isInteger ( this . value ) ? DBSQLParameterType . INTEGER : DBSQLParameterType . DOUBLE ) ,
6782 value : new TSparkParameterValue ( {
6883 stringValue : Number ( this . value ) . toString ( ) ,
6984 } ) ,
@@ -73,7 +88,7 @@ export class DBSQLParameter {
7388 if ( this . value instanceof Int64 || typeof this . value === 'bigint' ) {
7489 return new TSparkParameter ( {
7590 name,
76- type : this . type ?? DBSQLParameterType . BIGINT ,
91+ type : wireType ?? DBSQLParameterType . BIGINT ,
7792 value : new TSparkParameterValue ( {
7893 stringValue : this . value . toString ( ) ,
7994 } ) ,
@@ -83,7 +98,7 @@ export class DBSQLParameter {
8398 if ( this . value instanceof Date ) {
8499 return new TSparkParameter ( {
85100 name,
86- type : this . type ?? DBSQLParameterType . TIMESTAMP ,
101+ type : wireType ?? DBSQLParameterType . TIMESTAMP ,
87102 value : new TSparkParameterValue ( {
88103 stringValue : this . value . toISOString ( ) ,
89104 } ) ,
@@ -92,7 +107,7 @@ export class DBSQLParameter {
92107
93108 return new TSparkParameter ( {
94109 name,
95- type : this . type ?? DBSQLParameterType . STRING ,
110+ type : wireType ?? DBSQLParameterType . STRING ,
96111 value : new TSparkParameterValue ( {
97112 stringValue : this . value ,
98113 } ) ,
0 commit comments