mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.43k stars 290 forks source link

Multiple Valid SQL Statements, Valid SQL Statement Termination - Parse Error #1278

Open poorbadger opened 5 months ago

poorbadger commented 5 months ago

Describe the bug When attempting to run multiple consecutive SQL commands delimited with a semicolon between commands (eg. SELECT FROM table1; SELECT FROM table2;) SQL Tools raises a PARSE_SYNTAX ERROR.

If you run commands line by line (eg. highlight line 1, select Command + e, highlight line 2, select Command + e, etc) the commands execute successfully.

SQL Console Output: [PARSE_SYNTAX_ERROR] Syntax error at or near 'use': extra input 'use'.(line 2, pos 0)

To Reproduce Steps to reproduce the behavior:

  1. Goto SQL Tools
  2. Connect to Database
  3. Create new SQL file
  4. Enter multiple valid SQL commands delimited by valid ANSI SQL statement terminator (ie. Semicolon)

Expected behavior Consecutive valid commands should execute successfully. User shouldn't need to separate commands into multiple SQL files or highlight line by line and execute each validly terminated command manually.

Desktop (please complete the following information):

Screenshot 2024-01-15 at 2 04 58 PM

== SQL == use catalog samples; use database nyctaxi; select * from trips LIMIT 10;

poorbadger commented 5 months ago

Updating with results when commands are highlighted manually and run one at a time.

Screenshot 2024-01-15 at 2 21 06 PM
poorbadger commented 5 months ago

After digging into databricks a little more it looks like the parse error is occurring on their side and being returned to you. Somehow the same commands issued through their web UI work fine. They must be parsing themselves through the UI and issuing commands one by one.

Screenshot 2024-01-15 at 2 29 16 PM Screenshot 2024-01-15 at 2 26 42 PM
poorbadger commented 5 months ago

Results when running via PyCharm Database Tool - Success

Screenshot 2024-01-15 at 2 37 06 PM

Databricks Logs - most recent error is when running via VSCode SQLTools Extension. Subsequent successful queries were run from PyCharm in one multi statement batch.

Screenshot 2024-01-15 at 2 39 21 PM
poorbadger commented 5 months ago

A few other query execution options from PyCharm Database Tool in case it's useful. Notice the execute as separate statement option.

Screenshot 2024-01-15 at 4 42 24 PM Screenshot 2024-01-15 at 4 42 33 PM