Skip to content

DDL Statement vs Select statement identical results #309

Open

Description

@Tiuipuv

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions