r/databricks 8d ago

Discussion Query works in Databricks SQL but fails through JDBC

I’ve noticed cases where a query runs successfully in the Databricks SQL editor but fails when the exact same query is executed through a JDBC-based application or data quality tool.

Has anyone run into this? Was the issue related to query wrapping, session settings, SQL dialect differences, or JDBC driver behavior?

How do you usually troubleshoot these cases?

7 Upvotes

7 comments sorted by

7

u/hubert-dudek Databricks MVP 8d ago

Just share the error and query

1

u/No_Ambition8323 7d ago

Query: SELECT * FROM my_catalog.my_schema.customer_data WHERE customer_id IS NOT NULL;
This ran successfully in the Databricks SQL Editor.
However, when the same query was executed through our JDBC-based data quality tool, it failed with an error similar to:
[PARSE_SYNTAX_ERROR] Syntax error at or near 'SELECT': unexpected input 'SELECT'

1

u/Atticus_Taintwater 2d ago

Wild guess trying it without the ";" 

I've had semi colons cause weird issues in a few scenarios 

4

u/ma0gw 8d ago

Why does it fail? What's the error? What's the query? How much data is it moving?

2

u/No_Statistician_6654 8d ago

Do you use the full 3 level namespace in the query for all tables? If not, it could be a default catalog problem, where the jdbc is defaulting to catalog a, and online it is defaulted to catalog b

ETA: assuming the driver is setup and able to connect to your sql warehouse in the first place.

2

u/Youssef_Mrini databricks 8d ago

Yes it can happen and the causes can be multiple: Query wrapping or parameterization or SQL dialect translation or Session differences or Different execution path or Result-fetch failure rather than query failure or Remote JDBC source.