Creating a delta table Mismatch Input Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2021 02:17 AM
can you try putting a semicolon (;) at the end of the drop table statement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2021 08:24 AM
I did that but still getting the same error.
Thanks @werners
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2021 08:44 AM
can you try with CREATE OR REPLACE table1 (instead of drop and create)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2021 08:50 AM
Thanks again @werners, I tried that but still getting the same error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2021 05:13 PM
Thank you @Werner Stinckens I was able to resolve this issue. Your assistance is much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2021 05:13 PM
Thanks Jose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

