cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Facing issue while creating Delta Live Table on top of csv file

Manasi_Sarang
New Contributor II

Hello Everyone,

I am trying to create Delta Live Table on top of csv file using below syntax:

CREATE OR REFRESH LIVE TABLE employee_bronze_dlt

COMMENT "The bronze employee dataset, ingested from /mnt/lakehouse/PoC/DLT/Source/."

AS SELECT * FROM csv.`/mnt/lakehouse/PoC/DLT/Source/Employee.csv`;

Table is getting created but headers are appearing as part of data in table as shown below:

imageCan you please let me know what needs to be added in table creation definition to identify first row in data as header?

4 REPLIES 4

artsheiko
Databricks Employee
Databricks Employee

Hi, let's try the next :

CREATE TEMPORARY VIEW vw_employee
USING CSV
OPTIONS (path "/mnt/lakehouse/PoC/DLT/Source/Employee.csv", header "true");
 
CREATE OR REFRESH LIVE TABLE employee_bronze_dlt
COMMENT "The bronze employee dataset, ingested from /mnt/lakehouse/PoC/DLT/Source/."
AS SELECT * FROM vw_employee;

Hi,

I tried the above approach but getting below error:

org.apache.spark.sql.AnalysisException: Unable to process statement of type: 'CreateTempViewUsing'. DLT currently only accepts 'CREATE TEMPORARY LIVE VIEW', 'CREATE OR REFRESH LIVE TABLE', 'APPLY CHANGES INTO', and 'SET' statements.

Please find attached image file for error message.

AbhiJ
New Contributor III

Facing similar issue

"message": "Unable to process top-level query. DLT currently only accepts 'CREATE TEMPORARY LIVE VIEW', 'CREATE OR REFRESH LIVE TABLE', 'APPLY CHANGES INTO', and 'SET' statements.".

Please let me know if you have got any luck.

pvignesh92
Honored Contributor

Hi @Manasi_Sarang ,

I believe the Delta is unable to infer the schema as you are using select statement to read entire content from csv file and I think the inferschema won't work here.  Instead you can try to create a temp live table or live view with the below options and read from that table or view. 

USING csv OPTIONS (path "./file.csv", header "true", inferSchema "true")

Connect with Databricks Users in Your Area

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