You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/snowflake/actions/execute-sql-query/execute-sql-query.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ import snowflake from "../../snowflake.app.mjs";
2
2
3
3
exportdefault{
4
4
name: "Execute SQL Query",
5
-
version: "0.2.0",
5
+
version: "0.2.1",
6
6
key: "snowflake-execute-sql-query",
7
7
description: "Execute a custom Snowflake query. See [our docs](https://pipedream.com/docs/databases/working-with-sql) to learn more about working with SQL in Pipedream.",
Copy file name to clipboardExpand all lines: components/snowflake/actions/insert-multiple-rows/insert-multiple-rows.mjs
+113-6Lines changed: 113 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ export default {
6
6
key: "snowflake-insert-multiple-rows",
7
7
name: "Insert Multiple Rows",
8
8
description: "Insert multiple rows into a table",
9
-
version: "0.1.2",
9
+
version: "0.1.3",
10
10
props: {
11
11
snowflake,
12
12
database: {
@@ -50,29 +50,136 @@ export default {
50
50
"values",
51
51
],
52
52
},
53
+
batchSize: {
54
+
type: "integer",
55
+
label: "Batch Size",
56
+
description: "Number of rows to process per batch. Automatically calculated based on data size if not specified. Recommended: `50-200` for wide tables, `100-500` for narrow tables.",
57
+
optional: true,
58
+
default: 100,
59
+
min: 10,
60
+
max: 1000,
61
+
},
62
+
maxPayloadSizeMB: {
63
+
type: "integer",
64
+
label: "Max Payload Size (MB)",
65
+
description: "Maximum payload size per batch in MB. Helps prevent `413 Payload Too Large` errors.",
66
+
optional: true,
67
+
default: 5,
68
+
min: 1,
69
+
max: 10,
70
+
},
71
+
enableBatching: {
72
+
type: "boolean",
73
+
label: "Enable Batch Processing",
74
+
description: "Enable automatic batch processing for large datasets. Disable only for small datasets (< 50 rows) or troubleshooting.",
75
+
optional: true,
76
+
default: true,
77
+
},
53
78
},
54
79
asyncrun({ $ }){
55
80
letrows=this.values;
56
81
57
82
letinputValidated=true;
58
83
59
84
if(!Array.isArray(rows)){
60
-
rows=JSON.parse(rows);
85
+
try{
86
+
rows=JSON.parse(rows);
87
+
}catch(parseError){
88
+
thrownewConfigurationError("The row data could not be parsed as JSON. Please ensure it's a valid JSON array of arrays.");
console.log(`Row ${index+1} is not an array:`,row);
98
+
inputValidated=false;
99
+
}
100
+
});
67
101
}
68
102
69
103
// Throw an error if input validation failed
70
104
if(!inputValidated){
71
105
thrownewConfigurationError("The row data you passed is not an array of arrays. Please enter an array of arrays in the `Values` parameter above. If you're trying to add a single row to Snowflake, select the **Insert Single Row** action.");
$.export("$summary",`Successfully inserted ${this.values.length} rows in ${this.tableName}`);
76
-
returnresponse;
108
+
constexpectedColumnCount=this.columns.length;
109
+
constinvalidRows=rows.filter((row,index)=>{
110
+
if(row.length!==expectedColumnCount){
111
+
console.error(`Row ${index+1} has ${row.length} values but ${expectedColumnCount} columns specified`);
112
+
returntrue;
113
+
}
114
+
returnfalse;
115
+
});
116
+
117
+
if(invalidRows.length>0){
118
+
thrownewConfigurationError(`${invalidRows.length} rows have a different number of values than the specified columns. Each row must have exactly ${expectedColumnCount} values to match the selected columns.`);
119
+
}
120
+
121
+
// Add batch processing options
122
+
constbatchOptions={
123
+
batchSize: this.batchSize,
124
+
maxPayloadSizeMB: this.maxPayloadSizeMB,
125
+
enableBatching: this.enableBatching,
126
+
};
127
+
128
+
try{
129
+
constresponse=awaitthis.snowflake.insertRows(
130
+
this.tableName,
131
+
this.columns,
132
+
rows,
133
+
batchOptions,
134
+
);
135
+
136
+
// Handle different response formats (batched vs single insert)
137
+
if(response.summary){
138
+
// Batched response
139
+
const{ summary }=response;
140
+
$.export("$summary",`Successfully inserted ${summary.totalRowsProcessed} rows into ${this.tableName} using ${summary.totalBatches} batches`);
141
+
142
+
// Export detailed batch information
143
+
$.export("batchDetails",{
144
+
totalRows: summary.totalRows,
145
+
totalBatches: summary.totalBatches,
146
+
successfulBatches: summary.successfulBatches,
147
+
failedBatches: summary.failedBatches,
148
+
batchSize: summary.batchSize,
149
+
processingTime: newDate().toISOString(),
150
+
});
151
+
152
+
// Export batch results for debugging if needed
153
+
$.export("batchResults",summary.results);
154
+
155
+
returnresponse;
156
+
157
+
}else{
158
+
// Single insert response (small dataset or batching disabled)
159
+
$.export("$summary",`Successfully inserted ${rows.length} rows into ${this.tableName}`);
0 commit comments