5

I am trying to execute this query but it doesn't work:

SELECT COLUMN
FROM TABLE A           
WHERE  A.COLUM_1 = '9999-12-31' AND NOT EXISTS (SELECT 1 FROM TABLE2 ET WHERE ET.COl1 = A.COL2 LIMIT 1)

It results in an error which says the following:

"mismatched input FROM expecting"

Went through this post as it states its supported by Spark with 2.0+ version.

3
  • 1
    AND NOT EXISTS? Commented Sep 12, 2018 at 10:12
  • Which version of Spark are you using? Commented Sep 18, 2018 at 20:26
  • version - 2.3.0 Commented Sep 20, 2018 at 5:08

1 Answer 1

4

I'm not sure that SparkSQL supports TOP. But it is not needed. Does this work?

SELECT t.COLUMN
FROM TABLE t           
WHERE t.COLUM_1 = '9999-12-31' AND
      NOT EXISTS (SELECT 1 FROM TABLE2 ET WHERE ET.COl1 = t.COL2);

This fixes a few other syntax issues with the query (such as no alias A).

LIMIT in the subquery is also not needed. NOT EXISTS should stop at the first match.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes iam sorry TOP is incorrect as its not supported, i should be using LIMIT 1 i suppose instead of TOP 1, Thanks BTW

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.