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: 

How to query a table with backslashes in the name.

Dale_Ware
New Contributor III

I am trying to query a snowflake table from a databricks data frame similar to the following example.

sql_query = "select * from Database.Schema.Table_/Name_/V"

sqlContext.sql(f"{sql_query}" ) 

And I get an error like this.

ParseException:

[PARSE_SYNTAX_ERROR] Syntax error at or near '/'(line 1, pos 36)

== SQL ==

select * from Database.Schema.Table_/Name_/V

------------------------------------^^^

Does anyone know how I can escape those / characters?

1 ACCEPTED SOLUTION

Accepted Solutions

Your answer was close but still had the error. This is what we found to work in our snowflake query from a data bricks data frame:

.option("query", "select * from Database.schema.\"Table_/Name_/V\"") \

This was because the query was already inside quotes.

View solution in original post

2 REPLIES 2

Aviral-Bhardwaj
Esteemed Contributor III

You can use Double Quotes to get the plan. Using quotes it is important to write the table names in capital letters.

SELECT * FROM "/TABLE/NAME"

Your answer was close but still had the error. This is what we found to work in our snowflake query from a data bricks data frame:

.option("query", "select * from Database.schema.\"Table_/Name_/V\"") \

This was because the query was already inside quotes.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!