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

SQL Identifier clause

jura
New Contributor II

Hi, 

I was trying to prepare some dynamic SQLs to create table using the IDENTIFIER clause and WITH AS clause, but I'm stuck on some bug as it seems. 
could someone verify it or tell me that I am doing something wrong?
code is running on SQL Warehouse 

Thanks in advance

Case 1 => Create Table Conventional => Success

 

jura_2-1710922868633.png

Case 2 => Create Table using IDENTIFIER clause (without with as clause) => Success

jura_3-1710923081107.png

Case 3 => Create Table using IDENTIFIER clause and using WITH AS clause => FAIL

jura_4-1710923152252.png

I've tried using brackets around with as and select, didn't help ..

 

Any suggestions? 

#identifier #sql

2 REPLIES 2

raphaelblg
New Contributor III
New Contributor III

Hello @jura ,

I'm Raphael and i'll be helping you out.

The approach below should work:

USE CATALOG dev;

CREATE OR REPLACE TABLE IDENTIFIER("bronze.jura_test")
as SELECT ...

Please let me know the outcome and feel free to ask any further questions. If my response addresses your needs then please mark it as the official solution.

Thanks!

Best regards,

Raphael Balogo
Sr. Technical Solutions Engineer
Databricks

jura
New Contributor II

Hi @raphaelblg 

thanks for your answer, but this doesn't work.

jura_0-1711092079664.png

Problem is in WITH AS clause, when it is used in combination of CREATE TABLE and IDENTIFIER functions. Your example is same as my case 2 in opening post. 

Do you have any other propositions ? 

Another thing that I've found is that in SQL notebook + SQL Warehouse parameters cannot be used for some commands, i.e. USE CATALOG.  

jura_1-1711092347117.png

Thanks for your answer, but if you have any other suggestions, feel free to share 

br
Dino

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.