@@ -32,9 +32,12 @@ use cubenativeutils::wrappers::NativeContextHolder;
3232use cubesqlplanner:: cube_bridge:: base_query_options:: NativeBaseQueryOptions ;
3333use cubesqlplanner:: planner:: base_query:: BaseQuery ;
3434
35+ use cubeorchestrator:: cubestore_message_parser:: parse_cubestore_ws_result;
36+
3537use cubesql:: { telemetry:: ReportingLogger , CubeError } ;
3638
3739use neon:: prelude:: * ;
40+ use neon:: types:: buffer:: TypedArray ;
3841
3942struct SQLInterface {
4043 services : Arc < NodeCubeServices > ,
@@ -503,6 +506,30 @@ fn debug_js_to_clrepr_to_js(mut cx: FunctionContext) -> JsResult<JsValue> {
503506 arg_clrep. into_js ( & mut cx)
504507}
505508
509+ //============ sql orchestrator ===================
510+
511+ fn parse_cubestore_ws_result_message ( mut cx : FunctionContext ) -> JsResult < JsValue > {
512+ let msg = cx. argument :: < JsBuffer > ( 0 ) ?;
513+ let msg_data = msg. as_slice ( & cx) ;
514+ match parse_cubestore_ws_result ( msg_data. to_vec ( ) ) {
515+ Ok ( result) => {
516+ let js_array = JsArray :: new ( & mut cx, result. len ( ) ) ;
517+ for ( i, row) in result. into_iter ( ) . enumerate ( ) {
518+ let js_row = JsObject :: new ( & mut cx) ;
519+ for ( key, value) in row {
520+ let js_key = cx. string ( key) ;
521+ let js_value = cx. string ( value) ;
522+ js_row. set ( & mut cx, js_key, js_value) ?;
523+ }
524+ js_array. set ( & mut cx, i as u32 , js_row) ?;
525+ }
526+ Ok ( js_array. upcast ( ) )
527+ }
528+ Err ( err) => cx. throw_error ( err. to_string ( ) ) ,
529+ }
530+ }
531+
532+
506533pub fn register_module_exports < C : NodeConfiguration + ' static > (
507534 mut cx : ModuleContext ,
508535) -> NeonResult < ( ) > {
@@ -513,8 +540,12 @@ pub fn register_module_exports<C: NodeConfiguration + 'static>(
513540 cx. export_function ( "isFallbackBuild" , is_fallback_build) ?;
514541 cx. export_function ( "__js_to_clrepr_to_js" , debug_js_to_clrepr_to_js) ?;
515542
543+ //============ sql planner exports ===================
516544 cx. export_function ( "buildSqlAndParams" , build_sql_and_params) ?;
517545
546+ //========= sql orchestrator exports =================
547+ cx. export_function ( "parseCubestoreResultMessage" , parse_cubestore_ws_result_message) ?;
548+
518549 crate :: template:: template_register_module ( & mut cx) ?;
519550
520551 #[ cfg( feature = "python" ) ]
0 commit comments