'creating time partition by week
I am trying to build partitioned big query table, previously it was built using time partitioning type DAY, but I want to change it to week, I simply changed Day into WEEEk but got compilation error:
cannot find symbol
symbol: variable WEEk
location: class com.google.cloud.bigquery.TimePartitioning.Type
the code used:
TimePartitioning.newBuilder(TimePartitioning.Type.DAY)
.setField("partition_year_month_day") // name of the column used for partitioning
.build();
StandardTableDefinition tableDefinition = StandardTableDefinition.newBuilder()
.setSchema(schema)
.setTimePartitioning(partitioning)
.build();
TableInfo tableInfo = TableInfo.of(tableId, tableDefinition);
bigquery.create(tableInfo);
Any idea how to make it partitioned by week? I understand that TYPE can be set to month, hour based on this link: https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.table.TimePartitioning.html but is there a way to do partition into week? UPDATE: I tried to do partitioning by month and I got the same error:
cannot find symbol
[ERROR] symbol: variable MONTH
[ERROR] location: class com.google.cloud.bigquery.TimePartitioning.Type
Solution 1:[1]
Week is not supported at the moment. According to the official java documentation about TimePartitioning Types:
The supported types are DAY, HOUR, MONTH, and YEAR, which will generate one partition per day, hour, month, and year, respectively. When the interval is not specified, the default behavior is DAY.
Also, what is your bigquery library version? latest version supports MONTH, old versions (<= v1.117.3) DAY/HOUR only.
Note: You can check the current code for TimePartitioning.java of the bigquery library on the official github project page.
As mention in the comment, There is a good code sample on the official google page to create a partitioned table. Please check the page about Create a time-unit column-partitioned table. Also, an alternative to partitioned tables would be sharded tables but I don't think its as optimal as partitioned tables as documented on Partitioning versus sharding.
As a final note, you can request a feature request on issue tracker for an update to the current library or leave an open issue on the current github project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
