Jack
Jack

Reputation: 193

How to create non partitioned table in BigQuery. and exporting table SQL for tables in BigQuery?

I am working on BigQuery and I am still new to it.
Can somebody please help me on below questions?

1. Create new non partitioned table with _partitiontime field in it.
2. Export table structure in SQL of table (partitioned tables on date) from BigQuery.
3. Create new non partitioned table from partitioned table with exact structure.

Tagging this question to java for more visibility.

Upvotes: 0

Views: 191

Answers (1)

Hua Zhang
Hua Zhang

Reputation: 1551

  1. _partitiontime is a reserved field for partitioned tables, so you cannot create a non partitioned table with _partitiontime field.
  2. Not quite sure what you need here but guess you want a SQL to create the non-partitioned table in 3.
  3. If you simply copy the partitioned table to a new table, the new table will also be partitioned. But if you create the new table first and copy to it, the new table will remain un-partitioned:

bq mk my_data_set.my_new_table bq cp my_data_set.partitioned_table my_data_set.my_new_table

Please note that the un-partitioned table will not have the _partitiontime field. It's a pseudo column so it will not be copied over. If you do need it, you can run a query like this and save it to table:

bq query --destination_table=my_data_set.my_new_table 'SELECT *, _partitiontime AS partition_time FROM my_data_set.partitioned_table'

Upvotes: 1

Related Questions