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: 

PARSE_SYNTAX_ERROR creating view from CSV

DaniW
New Contributor III

Hello, if i run this code:

 

%sql

CREATE OR REPLACE VIEW esprosilver.xxx.encuestas_talleres
AS
SELECT * FROM CSV.`abfss://landing@esproanalyticscenterdl.dfs.core.windows.net/oracle-dwh/encuestas_talleres/encuestas_talleres.csv`
 
It creates the view in unity catalog, but places all data in a column _c0. so I have to tell it that it has headers. But if I run this query:
%sql

CREATE OR REPLACE VIEW esprosilver.xxxx.encuestas_talleres
USING csv
OPTIONS (
  path "abfss://landing@esproanalyticscenterdl.dfs.core.windows.net/oracle-dwh/encuestas_talleres/encuestas_talleres.csv",
  header = "true",
  inferSchema "true",
  mode "FAILFAST")

it returns this error:

ParseException: [PARSE_SYNTAX_ERROR] Syntax error at or near 'USING'(line 2, pos 0) == SQL == CREATE OR REPLACE VIEW esprosilver.realeseguros_dwh.encuestas_talleres
USING csv
^^^
OPTIONS ( path "abfss:REDACTED_LOCAL_PART@esproanalyticscenterdl.dfs.core.windows.net/oracle-dwh/encuestas_talleres/encuestas_talleres.csv", header = "true", inferSchema "true", mode "FAILFAST")

Can someone help me fix it? Thank you in advance
1 ACCEPTED SOLUTION

Accepted Solutions

DaniW
New Contributor III

I finally used the managed table creation and works perfectly. So I don't need to schedule. I leave the code here in case is of any use for someone:

%sql

CREATE TABLE IF NOT EXISTS esprosilver.XXXX.encuestas_talleres
USING CSV
OPTIONS (
  path "abfss://landing@esproanalyticscenterdl.dfs.core.windows.net/oracle-dwh/encuestas_talleres/encuestas_talleres.csv",
  header "true",
  inferSchema "true",
  delimiter ";",
  format "csv"
)

Thank you very much Mo for your time and giving me the idea of using tables. Have a great day!

View solution in original post

3 REPLIES 3

DaniW
New Contributor III

I forgot to mention that the csv delimiter is ';'

DaniW
New Contributor III

 

Hello Mo,

Thank you for the prompt reply. I require the data and schema to be accessible to all users at all times. Considering this, I'm thinking of creating a managed table that would function similarly to a view. If I create a table first and then a view based on it, any changes to the CSV file would necessitate re-creating the table. Right?

DaniW
New Contributor III

I finally used the managed table creation and works perfectly. So I don't need to schedule. I leave the code here in case is of any use for someone:

%sql

CREATE TABLE IF NOT EXISTS esprosilver.XXXX.encuestas_talleres
USING CSV
OPTIONS (
  path "abfss://landing@esproanalyticscenterdl.dfs.core.windows.net/oracle-dwh/encuestas_talleres/encuestas_talleres.csv",
  header "true",
  inferSchema "true",
  delimiter ";",
  format "csv"
)

Thank you very much Mo for your time and giving me the idea of using tables. Have a great day!

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