Databricks SQL Exists does not work correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Can someone explain to me how this is possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I replicated the query exactly but I couldn't produce the same results, and got back the expected result of the single row with 'aaa'. My initial thought is that it could be a bug in the runtime. Can you share the runtime of the cluster you are using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@Sergecom This looks to be a possible bug, thank you for flagging. It looks like the EXISTS function works as intended with Serverless Compute and Serverless SQL Warehouses, but exhibits a different behavior when run on all-purpose compute. I've raised a ticket so that they can look into this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Thanks for the update! Let me know if you need any more details from my side—happy to help.
Is there any way to follow this ticket @TheShua ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
21 hours ago
We were able to reproduce the problem, but it only occurs in Databricks SQL version 2025.10. With version 2024.05, the correct result is obtained.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20 hours ago - last edited 20 hours ago
Thanks for feedback @MarcoI've also tested with an older All-purpose Runtime 12.2 LTS and it works.
But its alarming that the latest runtime does not work as expected.
I will post SQL code so it will be easier for other to test. Both these queries give wrong results:
WITH a AS (
SELECT 'aaa' as produktkod
UNION ALL
SELECT 'bbb' as produktkod
),
b AS (
SELECT 'aaa' as produktkod
UNION ALL
SELECT 'ccc' as produktkod
)
SELECT a.*,
(SELECT COUNT(1)
FROM b
WHERE b.produktkod = a.produktkod) as match_count
FROM a;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
@Sergecom The engineering team worked on this and I believe it is now resolved for the newer runtimes. I confirmed it nows works as expected on 16.2. Can you confirm if it works on your end?

