cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Valued Contributor III
Valued Contributor III

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")

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.