databricks-sql-nodejs
databricks-sql-nodejs copied to clipboard
DDL Statement vs Select statement identical results
Hello,
After testing, it appears that the results of the following 2 queries are indistinguishable when looking at the result sets:
CREATE TABLE example (
col1 INT
);
and
SELECT 'sample' as Result
WHERE 1 = 0;
This is because when iterating over the rows, both return 0 rows:
import { DBSQLClient } from '@databricks/sql';
const connectionOptions = {...};
let results = [];
const client = new DBSQLClient();
const session = await client.connect(connectOptions);
const query = await session.executeStatement(query, options);
do {
results = results.concat(await query.fetchChunk());
} while (await query.hasMoreRows());
console.log(results);
And the schema is exactly the same:
... code above
console.log(query.metadata.schema)
Do you have any advice for differentiating the operations without requiring in a SQL parser to determine the query? Would it be possible to add the operation type to the query.metadata, or a result row for DDL operations?