0

While running a Spark SQL, I am getting mismatched input 'from' expecting <EOF> error.

I checked the common syntax errors which can occur but didn't find any.

val prevPartitionDate = spark.sql(
"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)

What can I do to resolve this?

1
  • did u check "$" sign? Commented Dec 21, 2020 at 10:49

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.