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

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.