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"

AviralBhardwaj

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.

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