Description
What is the current behavior?
In a multi statement query, snowflake is not sending back responses of queries executed successfully when one of the queries errors out. In a 4 statement query if there's an error in the 3rd statement, first 2 statements are executed but snowflake doesn't send back the response.
What is the desired behavior?
Snowflake should send back both the success and error responses.
How would this improve snowflake-connector-nodejs
?
Even in case when one of the queries fail, users might want to work with the success responses of other statements.
References, Other Background
In the below example, we're executing a query containing 3 statements. The tables for first 2 statements are present in snowflake and queries run successfully. If for 3rd statement the table name doesn't exist, complete callback will throw an error. But the success responses for the preceeding queries is not returned.
function executeQuery (connection) {
return new Promise((resolve, reject) => {
const MULTI_STATEMENT_COUNT = 0
// Execute a query using the stream option
const rows = []
connection.execute({
sqlText: "insert into **TABLE_EXISTS** (ID, NAME) values ('test', 'run'); DELETE FROM **TABLE_EXISTS** where PARENTID=12;
insert into **TABLE_DOESNT_EXIST** (ID, NAME) values ('test', 'run')",
parameters: { MULTI_STATEMENT_COUNT },
complete: async function (err, stmt, row, multiResultIds) {
// we're getting only the error back
if (err) {
console.error('Failed to execute statement due to the following error:', err.message)
return reject(err)
}
rows.push(...row)
if (stmt?.hasNext?.()) {
stmt.NextResult()
} else {
resolve(rows)
}
}
})
// Handle connection close event
connection.on('close', () => {
console.log('Snowflake connection closed')
})
})
}
Activity