Mismatched Input 'From' Expecting <Eof> SQL

mismatched input 'GROUP' expecting <EOF> SQL

The SQL constructs should appear in the following order:

SELECT
FROM
WHERE
GROUP BY **
HAVING **
ORDER BY

Getting this error: mismatched input 'from' expecting <EOF> while Spark SQL

No worries, able to figure out the issue. As I was using the variables in the query, I just have to add 's' at the beginning of the query like this:

val prevPartitionDate = spark.sql(s
"select to_date(concat(year_p,'-',month_p,'-',day_p))
from ips.command_room_table
where
to_date(concat(year_p,'-',month_p,'-',day_p)) < to_date(concat($yearAsInt,'-',$monthAsInt,'-',$dayAsInt))
group by year_p, month_p, day_p
order by to_date(concat(year_p,'-',month_p,'-',day_p)) desc limit 1"
).first.getDate(0)

How to get rid of this error mismatched input 'line' expecting <EOF>(line 1, pos 17) in spark-sql

You have 3 CASE clause but only 2 END statements, you missed one more END keyword.
And one CASE clause can have only one ELSE clause.

Below modified query should work for you.

SELECT
CASE
WHEN line = 'KEY' THEN
CASE
WHEN Length(pop)>0
AND pop NOT rlike '^[0-9]+@.*' THEN ''
ELSE
CASE
WHEN pop rlike '^[0-9]+@.*' THEN regexp_extract(pop, '^[^@]+', 0)
ELSE ''
END
END
ELSE ''
END as pop
FROM input


Related Topics



Leave a reply



Submit