@@ -9,7 +9,7 @@ export const SnowflakeBlock: BlockConfig<SnowflakeResponse> = {
99 description : 'Execute queries on Snowflake data warehouse' ,
1010 authMode : AuthMode . OAuth ,
1111 longDescription :
12- 'Integrate Snowflake into your workflow. Execute SQL queries, list databases, schemas, and tables, and describe table structures in your Snowflake data warehouse.' ,
12+ 'Integrate Snowflake into your workflow. Execute SQL queries, insert, update, and delete rows, list databases, schemas, and tables, and describe table structures in your Snowflake data warehouse.' ,
1313 docsLink : 'https://docs.sim.ai/tools/snowflake' ,
1414 category : 'tools' ,
1515 bgColor : '#E0E0E0' ,
@@ -21,6 +21,9 @@ export const SnowflakeBlock: BlockConfig<SnowflakeResponse> = {
2121 type : 'dropdown' ,
2222 options : [
2323 { label : 'Execute Query' , id : 'execute_query' } ,
24+ { label : 'Insert Rows' , id : 'insert_rows' } ,
25+ { label : 'Update Rows' , id : 'update_rows' } ,
26+ { label : 'Delete Rows' , id : 'delete_rows' } ,
2427 { label : 'List Databases' , id : 'list_databases' } ,
2528 { label : 'List Schemas' , id : 'list_schemas' } ,
2629 { label : 'List Tables' , id : 'list_tables' } ,
@@ -234,6 +237,9 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
234237 'list_file_formats' ,
235238 'list_stages' ,
236239 'describe_table' ,
240+ 'insert_rows' ,
241+ 'update_rows' ,
242+ 'delete_rows' ,
237243 ] ,
238244 } ,
239245 } ,
@@ -251,6 +257,9 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
251257 'list_file_formats' ,
252258 'list_stages' ,
253259 'describe_table' ,
260+ 'insert_rows' ,
261+ 'update_rows' ,
262+ 'delete_rows' ,
254263 ] ,
255264 } ,
256265 } ,
@@ -262,7 +271,51 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
262271 required : true ,
263272 condition : {
264273 field : 'operation' ,
265- value : 'describe_table' ,
274+ value : [ 'describe_table' , 'insert_rows' , 'update_rows' , 'delete_rows' ] ,
275+ } ,
276+ } ,
277+ {
278+ id : 'columns' ,
279+ title : 'Columns' ,
280+ type : 'long-input' ,
281+ placeholder : '["column1", "column2", "column3"]' ,
282+ required : true ,
283+ condition : {
284+ field : 'operation' ,
285+ value : 'insert_rows' ,
286+ } ,
287+ } ,
288+ {
289+ id : 'values' ,
290+ title : 'Values' ,
291+ type : 'long-input' ,
292+ placeholder : '[["value1", "value2", "value3"], ["value4", "value5", "value6"]]' ,
293+ required : true ,
294+ condition : {
295+ field : 'operation' ,
296+ value : 'insert_rows' ,
297+ } ,
298+ } ,
299+ {
300+ id : 'updates' ,
301+ title : 'Updates' ,
302+ type : 'long-input' ,
303+ placeholder : '{"column1": "new_value", "column2": 123, "updated_at": "2024-01-01"}' ,
304+ required : true ,
305+ condition : {
306+ field : 'operation' ,
307+ value : 'update_rows' ,
308+ } ,
309+ } ,
310+ {
311+ id : 'whereClause' ,
312+ title : 'WHERE Clause' ,
313+ type : 'long-input' ,
314+ placeholder : 'id = 123 (leave empty to update/delete ALL rows)' ,
315+ required : false ,
316+ condition : {
317+ field : 'operation' ,
318+ value : [ 'update_rows' , 'delete_rows' ] ,
266319 } ,
267320 } ,
268321 {
@@ -279,6 +332,9 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
279332 tools : {
280333 access : [
281334 'snowflake_execute_query' ,
335+ 'snowflake_insert_rows' ,
336+ 'snowflake_update_rows' ,
337+ 'snowflake_delete_rows' ,
282338 'snowflake_list_databases' ,
283339 'snowflake_list_schemas' ,
284340 'snowflake_list_tables' ,
@@ -293,6 +349,12 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
293349 switch ( params . operation ) {
294350 case 'execute_query' :
295351 return 'snowflake_execute_query'
352+ case 'insert_rows' :
353+ return 'snowflake_insert_rows'
354+ case 'update_rows' :
355+ return 'snowflake_update_rows'
356+ case 'delete_rows' :
357+ return 'snowflake_delete_rows'
296358 case 'list_databases' :
297359 return 'snowflake_list_databases'
298360 case 'list_schemas' :
@@ -410,6 +472,89 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
410472 break
411473 }
412474
475+ case 'insert_rows' : {
476+ if ( ! params . database || ! params . schema || ! params . table ) {
477+ throw new Error (
478+ 'Database, Schema, and Table are required for insert_rows operation'
479+ )
480+ }
481+ if ( ! params . columns || ! params . values ) {
482+ throw new Error ( 'Columns and Values are required for insert_rows operation' )
483+ }
484+
485+ // Parse columns and values if they are strings
486+ let columns = params . columns
487+ let values = params . values
488+
489+ if ( typeof columns === 'string' ) {
490+ try {
491+ columns = JSON . parse ( columns )
492+ } catch ( e ) {
493+ throw new Error ( 'Columns must be a valid JSON array' )
494+ }
495+ }
496+
497+ if ( typeof values === 'string' ) {
498+ try {
499+ values = JSON . parse ( values )
500+ } catch ( e ) {
501+ throw new Error ( 'Values must be a valid JSON array of arrays' )
502+ }
503+ }
504+
505+ baseParams . database = params . database
506+ baseParams . schema = params . schema
507+ baseParams . table = params . table
508+ baseParams . columns = columns
509+ baseParams . values = values
510+ if ( params . timeout ) baseParams . timeout = Number . parseInt ( params . timeout )
511+ break
512+ }
513+
514+ case 'update_rows' : {
515+ if ( ! params . database || ! params . schema || ! params . table ) {
516+ throw new Error (
517+ 'Database, Schema, and Table are required for update_rows operation'
518+ )
519+ }
520+ if ( ! params . updates ) {
521+ throw new Error ( 'Updates object is required for update_rows operation' )
522+ }
523+
524+ // Parse updates if it's a string
525+ let updates = params . updates
526+ if ( typeof updates === 'string' ) {
527+ try {
528+ updates = JSON . parse ( updates )
529+ } catch ( e ) {
530+ throw new Error ( 'Updates must be a valid JSON object' )
531+ }
532+ }
533+
534+ baseParams . database = params . database
535+ baseParams . schema = params . schema
536+ baseParams . table = params . table
537+ baseParams . updates = updates
538+ if ( params . whereClause ) baseParams . whereClause = params . whereClause
539+ if ( params . timeout ) baseParams . timeout = Number . parseInt ( params . timeout )
540+ break
541+ }
542+
543+ case 'delete_rows' : {
544+ if ( ! params . database || ! params . schema || ! params . table ) {
545+ throw new Error (
546+ 'Database, Schema, and Table are required for delete_rows operation'
547+ )
548+ }
549+
550+ baseParams . database = params . database
551+ baseParams . schema = params . schema
552+ baseParams . table = params . table
553+ if ( params . whereClause ) baseParams . whereClause = params . whereClause
554+ if ( params . timeout ) baseParams . timeout = Number . parseInt ( params . timeout )
555+ break
556+ }
557+
413558 default :
414559 throw new Error ( `Unknown operation: ${ operation } ` )
415560 }
@@ -431,6 +576,10 @@ Return ONLY the SQL query - no explanations, no markdown code blocks, no extra t
431576 database : { type : 'string' , description : 'Database name' } ,
432577 schema : { type : 'string' , description : 'Schema name' } ,
433578 table : { type : 'string' , description : 'Table name' } ,
579+ columns : { type : 'json' , description : 'Array of column names for insert operation' } ,
580+ values : { type : 'json' , description : 'Array of arrays containing values for insert operation' } ,
581+ updates : { type : 'json' , description : 'Object containing column-value pairs for update operation' } ,
582+ whereClause : { type : 'string' , description : 'WHERE clause for update/delete operations' } ,
434583 timeout : { type : 'string' , description : 'Query timeout in seconds' } ,
435584 } ,
436585 outputs : {
0 commit comments