DDL Statement vs Select statement identical results

Open
#309 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
sql, typescript

Research direction

Start with the DBSQLClient session.executeStatement flow and the query.fetchChunk(), query.hasMoreRows(), and query.metadata.schema APIs shown in the report. Compare how the CREATE TABLE and empty SELECT operations are exposed, then determine whether metadata can distinguish them or whether a result-row change is appropriate. Done means callers can reliably identify the operation without parsing SQL.

Written by the indexing model from the issue text.

Description

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?

Dominant language
TypeScript
Stars
36
Forks
50
Avg merge
13h 46m
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from databricks/databricks-sql-nodejs

All issues in databricks/databricks-sql-nodejs

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.