cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Error when create an external location using code

noimeta
Contributor II

I'm trying to create an external location from notebook, and I got this kind of error

[PARSE_SYNTAX_ERROR] Syntax error at or near 'LOCATION'(line 1, pos 16)
 
== SQL ==
CREATE EXTERNAL LOCATION IF NOT EXISTS test_location URL 's3://test-bronze/db/test_schema/test_table' WITH (STORAGE CREDENTIAL test-credential)
----------------^^^

I tried with DBR10.4, DBR11.1 and DBR11.2, unfortunately, none of them worked.

However, SHOW EXTERNAL LOCATIONS and DESCRIBE EXTERNAL LOCATION *** work just fine.

Also, I can create an external location from the UI without any problem

Anyone knows how to solve this issue?

17 REPLIES 17

Pat
Honored Contributor III

It seems like error is due to '-' in the storage credential name, you need to use backticks `some-name`:

CREATE EXTERNAL LOCATION IF NOT EXISTS test_location URL 's3://test-bronze/db/test_schema/test_table' WITH (STORAGE CREDENTIAL `test-credential`)

thanks,

Patryk.

noimeta
Contributor II

It works! Thank you so much!!

There's no back tick in the example, so I didn't think about it at all.

Lokeshv
New Contributor II

Hey everyone,

I'm facing an issue with retrieving data from a volume or table that contains a string with a symbol, for example, 'databricks+'. Whenever I try to retrieve this data, I encounter a syntax error. Can anyone help me resolve this issue?

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.