@@ -35,7 +35,7 @@ use databricks_sql_kernel::{Error as KernelError, Session, TypedValue};
3535
3636use crate :: async_statement:: AsyncStatement ;
3737use crate :: error:: napi_err_from_kernel;
38- use crate :: params:: { parse_typed_value, TypedValueInput } ;
38+ use crate :: params:: { parse_typed_value, RawParameterInput , TypedValueInput } ;
3939use crate :: runtime;
4040use crate :: statement:: Statement ;
4141use crate :: util:: guarded;
@@ -56,6 +56,8 @@ use crate::util::guarded;
5656/// `rowLimit` (SEA `row_limit`) is exposed here and threaded onto the kernel
5757/// `StatementSpec`. `positionalParams` (`?`) and `namedParams` (`:name`)
5858/// carry bound query parameters, decoded via `params::parse_typed_value`.
59+ /// `rawParams` carries pre-marshalled parameters whose SQL type must be
60+ /// preserved verbatim on the SEA wire (for example `INTERVAL MONTH`).
5961/// (There is no `queryTimeoutSecs`: it abused the SEA `wait_timeout` inline-hold
6062/// window and was removed — a real per-statement timeout is `STATEMENT_TIMEOUT`.)
6163///
@@ -115,6 +117,17 @@ pub struct ExecuteOptions {
115117 /// positional is the documented-undocumented variant. The two are
116118 /// mutually exclusive at the SQL level (`?` vs `:name`).
117119 pub named_params : Option < Vec < NamedTypedValueInput > > ,
120+ /// Pre-marshalled SEA parameters. The SQL type and string value are sent
121+ /// verbatim through `StatementSpec::param_raw`, bypassing `TypedValue`
122+ /// conversion. This preserves qualified types such as `INTERVAL MONTH`
123+ /// and `INTERVAL DAY` that the generic `TypedValue::Interval` cannot
124+ /// represent.
125+ ///
126+ /// Omit `name` for positional parameters (ordinals are assigned 1-based
127+ /// in array order); include it for named parameters. Raw parameters are
128+ /// mutually exclusive with `positionalParams` / `namedParams`, and a raw
129+ /// list cannot mix named and positional markers.
130+ pub raw_params : Option < Vec < RawParameterInput > > ,
118131}
119132
120133/// A named bound parameter — a [`TypedValueInput`] plus its `:name`. Kept a
@@ -187,6 +200,7 @@ fn build_statement(
187200 row_limit : Option < i64 > ,
188201 positional_params : Vec < TypedValue > ,
189202 named_params : Vec < ( String , TypedValue ) > ,
203+ raw_params : Vec < RawParameterInput > ,
190204) -> napi:: Result < databricks_sql_kernel:: Statement > {
191205 // Positional/named mutual-exclusivity is enforced in the kernel's
192206 // `build_execute_params` (StatementSpec dispatch), so every binding
@@ -221,6 +235,11 @@ fn build_statement(
221235 . param_named ( name, value)
222236 . map_err ( napi_err_from_kernel) ?;
223237 }
238+ // Bind pre-marshalled params without converting through `TypedValue`, so
239+ // qualified type names (notably INTERVAL MONTH / INTERVAL DAY) survive.
240+ for raw in raw_params {
241+ stmt. spec ( ) . param_raw ( raw. name , raw. sql_type , raw. value ) ;
242+ }
224243 Ok ( stmt)
225244}
226245
@@ -300,6 +319,10 @@ impl Connection {
300319 . map ( decode_named_params)
301320 . transpose ( ) ?
302321 . unwrap_or_default ( ) ;
322+ let raw_params = options
323+ . as_mut ( )
324+ . and_then ( |o| o. raw_params . take ( ) )
325+ . unwrap_or_default ( ) ;
303326 // Pull the explicit `statement_conf` map and the `query_tags`
304327 // convenience map out of `options`. The kernel `StatementSpec`
305328 // owns the merge + serialisation: set the explicit conf first,
@@ -330,6 +353,7 @@ impl Connection {
330353 row_limit,
331354 positional_params,
332355 named_params,
356+ raw_params,
333357 ) ?
334358 // session lock released here
335359 } ;
@@ -384,6 +408,10 @@ impl Connection {
384408 . map ( decode_named_params)
385409 . transpose ( ) ?
386410 . unwrap_or_default ( ) ;
411+ let raw_params = options
412+ . as_mut ( )
413+ . and_then ( |o| o. raw_params . take ( ) )
414+ . unwrap_or_default ( ) ;
387415 let statement_conf = options. as_mut ( ) . and_then ( |o| o. statement_conf . take ( ) ) ;
388416 let query_tags = options. as_mut ( ) . and_then ( |o| o. query_tags . take ( ) ) ;
389417 guarded ( async move {
@@ -398,6 +426,7 @@ impl Connection {
398426 row_limit,
399427 positional_params,
400428 named_params,
429+ raw_params,
401430 ) ?
402431 } ;
403432
@@ -452,6 +481,10 @@ impl Connection {
452481 . map ( decode_named_params)
453482 . transpose ( ) ?
454483 . unwrap_or_default ( ) ;
484+ let raw_params = options
485+ . as_mut ( )
486+ . and_then ( |o| o. raw_params . take ( ) )
487+ . unwrap_or_default ( ) ;
455488 let statement_conf = options. as_mut ( ) . and_then ( |o| o. statement_conf . take ( ) ) ;
456489 let query_tags = options. as_mut ( ) . and_then ( |o| o. query_tags . take ( ) ) ;
457490 guarded ( async move {
@@ -473,6 +506,7 @@ impl Connection {
473506 row_limit,
474507 positional_params,
475508 named_params,
509+ raw_params,
476510 ) ?
477511 // session lock released here
478512 } ;
@@ -520,6 +554,10 @@ impl Connection {
520554 . map ( decode_named_params)
521555 . transpose ( ) ?
522556 . unwrap_or_default ( ) ;
557+ let raw_params = options
558+ . as_mut ( )
559+ . and_then ( |o| o. raw_params . take ( ) )
560+ . unwrap_or_default ( ) ;
523561 // Same conf + query_tags plumbing as `execute_statement`: the
524562 // kernel `StatementSpec` owns the merge + serialisation.
525563 let statement_conf = options. as_mut ( ) . and_then ( |o| o. statement_conf . take ( ) ) ;
@@ -546,6 +584,7 @@ impl Connection {
546584 row_limit,
547585 positional_params,
548586 named_params,
587+ raw_params,
549588 ) ?
550589 // session lock released here
551590 } ;
0 commit comments