def apply(self, bq_resource: BQTable) -> BQTable: new_resource = deepcopy(bq_resource) new_resource.range_partitioning = RangePartitioning( field=self.field, range_=PartitionRange(start=self.start, end=self.end, interval=self.interval) ) return new_resource
def test_range_partitioning_setter(self): from google.cloud.bigquery.table import PartitionRange from google.cloud.bigquery.table import RangePartitioning object_under_test = self._get_target_class()() object_under_test.range_partitioning = RangePartitioning( field="column_one", range_=PartitionRange(start=1, end=1000, interval=10)) object_under_test.range_partitioning.field == "column_one" object_under_test.range_partitioning.range_.start == 1 object_under_test.range_partitioning.range_.end == 1000 object_under_test.range_partitioning.range_.interval == 10
def test_change_partition_by_range(bqtk: BQTestKit): with bqtk.project("it").dataset("dataset_foo").isolate() as ds: table_bar_schema = [SchemaField("my_int", "int64")] with ds.table("table_bar"). \ with_schema(from_=table_bar_schema). \ partition_by(Range(on_field="my_int", start=0, end=10000, interval=10)). \ isolate() as t: show_res = t.show() assert show_res is not None assert show_res.time_partitioning is None expected_range = RangePartitioning(field='my_int', range_=PartitionRange(end=10000, interval=10, start=0)) assert show_res.range_partitioning == expected_range
def range_partitioning(self): """Optional[google.cloud.bigquery.table.RangePartitioning]: Configures range-based partitioning for destination table. .. note:: **Beta**. The integer range partitioning feature is in a pre-release state and might change or have limited support. Only specify at most one of :attr:`~google.cloud.bigquery.job.LoadJobConfig.time_partitioning` or :attr:`~google.cloud.bigquery.job.LoadJobConfig.range_partitioning`. Raises: ValueError: If the value is not :class:`~google.cloud.bigquery.table.RangePartitioning` or :data:`None`. """ resource = self._get_sub_prop("rangePartitioning") if resource is not None: return RangePartitioning(_properties=resource)