3

DELTA does not have CREATE TABLE LIKE. It does have CTAS.

I want to copy the definition of a table only, but also specify the LOCATION.

E.g. this does not work:

CREATE TABLE IF NOT EXISTS NEW_CUSTOMER_FEED 
AS SELECT * from NEW_CUSTOMER_FEED WHERE 1 = 0 
LOCATION '/atRest/data'

What am I missing?

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
thebluephantom
  • 16,458
  • 8
  • 40
  • 83

1 Answers1

4

if you check syntax for CREATE TABLE USING, then you will see that AS SELECT ... should be the last clause, after all options. So in your case it should be

CREATE TABLE IF NOT EXISTS NEW_CUSTOMER_FEED 
LOCATION '/atRest/data'
AS SELECT * from NEW_CUSTOMER_FEED WHERE 1 = 0 

P.S. Instead of WHERE 1=0, you can just do LIMIT 0...

Alex Ott
  • 80,552
  • 8
  • 87
  • 132