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
Postgres Query to Check a String Is a Number
Sql Query to Select Million Records Quickly
Retrieve String Between HTML Tags Using Regex
How to Insert Null into the Datetime Coulmn Instead 1900-01-01 00:00:00.000 in SQL Server
Add a Column to Specific Position in Mssql Server
How to Extract Part of a String in Hive
Nodejs, MySQL - Json Stringify - Advanced Query
How to Subtract One Day from Current Date Then Convert to String in Hive
Pg Copy Error: Invalid Input Syntax for Integer
Sql - How to Sum/Aggregate Certain Rows in a Table
Auto Increment the Column Value by 1 Conditionally in Select Query in SQL
Sql Query to Select from 1 Hour Ago
How to Select the Last Record of a Table in SQL
How to Get Max Date Value of Date Column in Multiple Tables
Want to Run Multiple SQL Script File in One Go With in Sqlplus
List All Employee'S Names and Their Managers by Manager Name Using an Inner Join