@@ -599,30 +599,104 @@ export const SnowflakeBlock: BlockConfig<SnowflakeStatementResponse> = {
599599 tool : ( params ) => `snowflake_${ params . operation } ` ,
600600 params : ( params ) => {
601601 const jsonBudget = { bytes : 0 }
602- return {
603- async : optionalBoolean ( params . async ) ,
604- bindings : parseJson ( params . bindings , 'Bindings' , jsonBudget ) ,
605- database : params . database || params . contextDatabase || undefined ,
606- schema : params . schema || params . contextSchema || undefined ,
607- taskName : params . taskName || params . taskNameFilter || undefined ,
608- rows : parseJson ( params . rows , 'Rows' , jsonBudget ) ,
609- matchColumns : parseJson ( params . matchColumns , 'Match columns' , jsonBudget ) ,
610- filters : parseJson ( params . filters , 'Filters' , jsonBudget ) ,
611- procedureArguments : parseJson (
612- params . procedureArguments ,
613- 'Procedure arguments' ,
614- jsonBudget
615- ) ,
616- partition : optionalNumber ( params . partition ) ,
602+ const statementParams = ( ) => ( {
617603 timeout : optionalNumber ( params . timeout ) ,
618604 maxRows : optionalNumber ( params . maxRows ) ,
619- limit : optionalNumber ( params . limit ) ,
620- purge : optionalBoolean ( params . purge ) ,
621- force : optionalBoolean ( params . force ) ,
622- retryLast : optionalBoolean ( params . retryLast ) ,
623- errorOnly : optionalBoolean ( params . errorOnly ) ,
624- includeViews : optionalBoolean ( params . includeViews ) ,
625- onError : copyOnError ( params . onError , params . onErrorThreshold ) ,
605+ } )
606+ const contextParams = ( ) => ( {
607+ ...statementParams ( ) ,
608+ database : params . contextDatabase || undefined ,
609+ schema : params . contextSchema || undefined ,
610+ } )
611+ const objectParams = ( ) => ( {
612+ ...statementParams ( ) ,
613+ database : params . database || undefined ,
614+ schema : params . schema || undefined ,
615+ } )
616+
617+ switch ( params . operation ) {
618+ case 'execute_sql' :
619+ return {
620+ ...contextParams ( ) ,
621+ async : optionalBoolean ( params . async ) ,
622+ bindings : parseJson ( params . bindings , 'Bindings' , jsonBudget ) ,
623+ }
624+ case 'get_statement' :
625+ return {
626+ partition : optionalNumber ( params . partition ) ,
627+ maxRows : optionalNumber ( params . maxRows ) ,
628+ }
629+ case 'insert_rows' :
630+ return {
631+ ...objectParams ( ) ,
632+ rows : parseJson ( params . rows , 'Rows' , jsonBudget ) ,
633+ }
634+ case 'update_rows' :
635+ case 'upsert_rows' :
636+ return {
637+ ...objectParams ( ) ,
638+ rows : parseJson ( params . rows , 'Rows' , jsonBudget ) ,
639+ matchColumns : parseJson ( params . matchColumns , 'Match columns' , jsonBudget ) ,
640+ }
641+ case 'delete_rows' :
642+ return {
643+ ...objectParams ( ) ,
644+ filters : parseJson ( params . filters , 'Filters' , jsonBudget ) ,
645+ }
646+ case 'load_data' :
647+ return {
648+ ...objectParams ( ) ,
649+ purge : optionalBoolean ( params . purge ) ,
650+ force : optionalBoolean ( params . force ) ,
651+ onError : copyOnError ( params . onError , params . onErrorThreshold ) ,
652+ }
653+ case 'list_warehouses' :
654+ case 'get_warehouse' :
655+ case 'resume_warehouse' :
656+ case 'suspend_warehouse' :
657+ case 'cancel_task_run' :
658+ case 'get_task_run_output' :
659+ return contextParams ( )
660+ case 'list_tasks' :
661+ return {
662+ ...objectParams ( ) ,
663+ limit : optionalNumber ( params . limit ) ,
664+ }
665+ case 'get_task' :
666+ return objectParams ( )
667+ case 'run_task' :
668+ return {
669+ ...objectParams ( ) ,
670+ retryLast : optionalBoolean ( params . retryLast ) ,
671+ }
672+ case 'list_task_runs' :
673+ return {
674+ ...contextParams ( ) ,
675+ taskName : params . taskNameFilter || undefined ,
676+ limit : optionalNumber ( params . limit ) ,
677+ errorOnly : optionalBoolean ( params . errorOnly ) ,
678+ }
679+ case 'get_task_run' :
680+ return {
681+ ...contextParams ( ) ,
682+ taskName : params . taskNameFilter || undefined ,
683+ }
684+ case 'introspect_schema' :
685+ return {
686+ ...objectParams ( ) ,
687+ includeViews : optionalBoolean ( params . includeViews ) ,
688+ }
689+ case 'call_procedure' :
690+ return {
691+ ...objectParams ( ) ,
692+ procedureArguments : parseJson (
693+ params . procedureArguments ,
694+ 'Procedure arguments' ,
695+ jsonBudget
696+ ) ,
697+ }
698+ default :
699+ return { }
626700 }
627701 } ,
628702 } ,
0 commit comments