Syntax to create partitioned table based on timestamp column in BigQuery

When we try to create a partitioned table based on a timestamp column in BigQuery it throws the below error message:

Create table Tableaname
(
Id INT64,
Create_TS TIMESTAMP
)
PARTITION BY Create_TS;
Error: PARTITION BY expression must be DATE(<timestamp_column>) or else a 
DATE column

Syntax to Create a Timestamp Partitioned table

You should use PARTITION BY DATE(TS), like shown below

Create table Tableaname
(
Id INT64,
Create_TS TIMESTAMP
)
PARTITION BY DATE(Create_TS);

mCollins

posted on 01 Nov 20

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds