Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mismatched input 'from' expecting <EOF> SQL

I am running a process on Spark which uses SQL for the most part. In one of the workflows I am getting the following error:

mismatched input 'from' expecting

The code is

 select a.ACCOUNT_IDENTIFIER,a.LAN_CD, a.BEST_CARD_NUMBER,  
 decision_id, 
 case when a.BEST_CARD_NUMBER = 1 then 'Y' else 'N' end as best_card_excl_flag 
 from (select a.ACCOUNT_IDENTIFIER,a.LAN_CD, a. decision_id row_number()
 over (partition by CUST_GRP_MBRP_ID 
    order by coalesce(BEST_CARD_RANK,999)) as BEST_CARD_NUMBER 
 from Accounts_Inclusions_Exclusions_Flagged a) a 

I cannot figure out what the error is for the life of me

I've tried checking for comma errors or unexpected brackets but that doesn't seem to be the issue.

like image 888
Khalid Mohammed Avatar asked Jun 19 '19 21:06

Khalid Mohammed


People also ask

What does expecting EOF mean in SQL?

EOF stands for "end of file," and this syntax error occurs when Python detects an unfinished statement or block of code. This can happen for many reasons, but the most likely cause is missing punctuation or an incorrectly indented block.

How does spark SQL work?

Spark SQL is a Spark module for structured data processing. It provides a programming abstraction called DataFrames and can also act as a distributed SQL query engine. It enables unmodified Hadoop Hive queries to run up to 100x faster on existing deployments and data.


1 Answers

In the 4th line of you code, you just need to add a comma after a.decision_id, since row_number() over is a separate column/function.

P.S.: Try yo use indentation in nested select statements so you and your peers can understand the code easily. Cheers!

like image 72
Pranav Tumkur Avatar answered Nov 18 '22 16:11

Pranav Tumkur