11-30-2021 07:09 PM
I am trying to create a delta table for streaming data, but I am getting the following error; Error in SQL statement: ParseException:
mismatched input 'CREATE' expecting {<EOF>, ';'}(line 2, pos 0).
My statement is as follows;
%sql
DROP TABLE IF EXISTS table1
CREATE TABLE table1 (
col_1 STRING,
col_2 STRING,
col_date_1 DATE,
col_dat_2 DATE,
col_3 Double,
col_4 Double,
) USING DELTA
I can't figure out why I am getting this error.
12-01-2021 02:17 AM
can you try putting a semicolon (;) at the end of the drop table statement?
12-01-2021 08:24 AM
I did that but still getting the same error.
Thanks @werners
12-01-2021 08:44 AM
can you try with CREATE OR REPLACE table1 (instead of drop and create)?
12-01-2021 08:50 AM
Thanks again @werners, I tried that but still getting the same error
12-03-2021 12:44 AM
strange,
can you try to execute both statements in separated cells?
Like that you can see where the problem exactly is
12-06-2021 05:13 PM
Thank you @Werner Stinckens I was able to resolve this issue. Your assistance is much appreciated
12-06-2021 04:45 PM
hi @Ambrose Walker ,
Here is the link to the docs https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-syntax-ddl-create-table-d...
Here is the syntax:
CREATE TABLE [ IF NOT EXISTS ] table_identifier
[ ( col_name1 col_type1 [ COMMENT col_comment1 ], ... ) ]
USING data_source
[ OPTIONS ( key1 [ = ] val1, key2 [ = ] val2, ... ) ]
[ PARTITIONED BY ( col_name1, col_name2, ... ) ]
[ CLUSTERED BY ( col_name3, col_name4, ... )
[ SORTED BY ( col_name [ ASC | DESC ], ... ) ]
INTO num_buckets BUCKETS ]
[ LOCATION path ]
[ COMMENT table_comment ]
[ TBLPROPERTIES ( key1 [ = ] val1, key2 [ = ] val2, ... ) ]
[ AS select_statement ]
12-06-2021 05:13 PM
Thanks Jose.
12-07-2021 01:26 PM
@Ambrose Walker - If Jose's answer resolved your issue, would you be happy to mark that post as best? That will help others find the solution more quickly.
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group