BackBenChers
BackBenChers

Reputation: 304

Big Query DDL Command to Create Table From Existing One?

I Need to Create A Temp Table in BigQuery Using DDL Command But While I Write The Statement as

CREATE TABLE IF NOT EXISTS DataSet.newtable1 (x INT64, y STRUCT<a ARRAY<STRING>, b BOOL>)
 PARTITION BY DATE(_PARTITIONTIME)
 OPTIONS(
   expiration_timestamp=TIMESTAMP "2020-01-01 00:00:00 UTC",
   partition_expiration_days=1,
   description="a table that expires in 2020, with each partition living for 24 hours",
   labels=[("org_unit", "development")]
 ) As SELECT * FROM DATASET.newTable

I Got A Response as CREATE TABLE AS SELECT is not supported Any Alternative So I can Achieve my Goal to Create a Temp Table As Per Requirement and And Delete It.

Upvotes: 1

Views: 1904

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173190

Support for CREATE TABLE AS SELECT statements is under development

Meantime, you can just create table using DDL and then you either use it as destination table for your SELECT * FROM DATASET.newTable or alternatively you can use DML

INSERT DATASET.newTable1 (x INT64, y STRUCT<a ARRAY<STRING>, b BOOL>)
SELECT *
FROM DATASET.newTable

Upvotes: 2

Related Questions