Skip to content

Metadata

These functions are used to query resource metadata to support efficient, automated data workflows.

GET Date Partitions

Attribute Value
Function Name get_date_partitions
ID bqtools.[region].get_date_partitions
Version bqtools:v1.0.0
Description Returns an array of dates corresponding to all existing partitions in a single partitioned table, sorted by descending date.
Type PROCEDURE
Arguments partitioned_table_id STRING, OUT partitions ARRAY<DATE>
Returns OUT partitions ARRAY<DATE>
Dependencies bqtools-qb.[region].get_date_partitions

EXECUTION

DECLARE partitioned_table_id STRING;
DECLARE partitions ARRAY<DATE>;

SET partitioned_table_id = 'project_id.dataset_name.partitioned_table_name';

CALL bqtools.eu.get_date_partitions(partitioned_table_id, partitions);
DECLARE partitioned_table_id STRING;
DECLARE partitions ARRAY<DATE>;

SET partitioned_table_id = 'project_id.dataset_name.partitioned_table_name';

CALL bqtools.us.get_date_partitions(partitioned_table_id, partitions);

GET First Date Partition

Attribute Value
Function Name get_first_date_partition
ID bqtools.[region].get_first_date_partition
Version bqtools:v1.0.0
Description Returns the first partition date from a single date-partitioned table.
Type PROCEDURE
Arguments partitioned_table_id STRING, OUT first_partition DATE
Returns OUT first_partition DATE
Dependencies bqtools.[region].get_date_partitions

EXECUTION

DECLARE partitioned_table_id STRING;
DECLARE first_partition DATE;

SET partitioned_table_id = 'project_id.dataset_name.partitioned_table_name';

CALL bqtools.eu.get_first_date_partition(partitioned_table_id, first_partition);
DECLARE partitioned_table_id STRING;
DECLARE first_partition DATE;

SET partitioned_table_id = 'project_id.dataset_name.partitioned_table_name';

CALL bqtools.us.get_first_date_partition(partitioned_table_id, first_partition);

GET Last Date Partition

Attribute Value
Function Name get_last_date_partition
ID bqtools.[region].get_last_date_partition
Version bqtools:v1.0.0
Description Returns the last partition date from a single date-partitioned table.
Type PROCEDURE
Arguments partitioned_table_id STRING, OUT last_partition DATE
Returns OUT last_partition DATE
Dependencies bqtools.[region].get_date_partitions

EXECUTION

DECLARE partitioned_table_id STRING;
DECLARE last_partition DATE;

SET partitioned_table_id = 'project_id.dataset_name.partitioned_table_name';

CALL bqtools.eu.get_last_date_partition(partitioned_table_id, last_partition);
DECLARE partitioned_table_id STRING;
DECLARE last_partition DATE;

SET partitioned_table_id = 'project_id.dataset_name.partitioned_table_name';

CALL bqtools.us.get_last_date_partition(partitioned_table_id, last_partition);

GET Date Shards

Attribute Value
Function Name get_date_shards
ID bqtools.[region].get_date_shards
Version bqtools:v1.0.0
Description Returns an array of shard_dates corresponding to all existing date shards in a single date-sharded table, sorted by descending date.
Type PROCEDURE
Arguments sharded_table_dataset_id STRING, sharded_table_prefix STRING, OUT shard_dates ARRAY<DATE>
Returns OUT shard_dates ARRAY<DATE>
Dependencies bqtools-qb.[region].get_date_shards

EXECUTION

DECLARE sharded_table_dataset_id, sharded_table_prefix STRING;
DECLARE shard_dates ARRAY<DATE>;

SET sharded_table_dataset_id = 'project_id.dataset_name';
SET sharded_table_prefix = 'my_table_prefix_';

CALL bqtools.eu.get_date_shards(sharded_table_dataset_id, sharded_table_prefix, shard_dates);
DECLARE sharded_table_dataset_id, sharded_table_prefix STRING;
DECLARE shard_dates ARRAY<DATE>;

SET sharded_table_dataset_id = 'project_id.dataset_name';
SET sharded_table_prefix = 'my_table_prefix_';

CALL bqtools.us.get_date_shards(sharded_table_dataset_id, sharded_table_prefix, shard_dates);

GET First Date Shard

Attribute Value
Function Name get_first_date_shard
ID bqtools.[region].get_first_date_shard
Version bqtools:v1.0.0
Description Returns the first shard_date from a single sharded table.
Type PROCEDURE
Arguments sharded_table_dataset_id STRING, sharded_table_prefix STRING, OUT first_shard DATE
Returns OUT first_shard DATE
Dependencies bqtools.[region].get_date_shards

EXECUTION

DECLARE sharded_table_dataset_id, sharded_table_prefix STRING;
DECLARE first_shard DATE;

SET sharded_table_dataset_id = 'project_id.dataset_name';
SET sharded_table_prefix = 'my_table_prefix_';

CALL bqtools.eu.get_first_date_shard(sharded_table_dataset_id, sharded_table_prefix, first_shard);
DECLARE sharded_table_dataset_id, sharded_table_prefix STRING;
DECLARE first_shard DATE;

SET sharded_table_dataset_id = 'project_id.dataset_name';
SET sharded_table_prefix = 'my_table_prefix_';

CALL bqtools.us.get_first_date_shard(sharded_table_dataset_id, sharded_table_prefix, first_shard);

GET Last Date Shard

Attribute Value
Function Name get_last_date_shard
ID bqtools.[region].get_last_date_shard
Version bqtools:v1.0.0
Description Returns the last shard_date from a single date-sharded table.
Type PROCEDURE
Arguments sharded_table_dataset_id STRING, sharded_table_prefix STRING, OUT last_shard DATE
Returns OUT last_shard DATE
Dependencies bqtools.[region].get_date_shards

EXECUTION

DECLARE sharded_table_dataset_id, sharded_table_prefix STRING;
DECLARE last_shard DATE;

SET sharded_table_dataset_id = 'project_id.dataset_name';
SET sharded_table_prefix = 'my_table_prefix_';

CALL bqtools.eu.get_last_date_shard(sharded_table_dataset_id, sharded_table_prefix, last_shard);
DECLARE sharded_table_dataset_id, sharded_table_prefix STRING;
DECLARE last_shard DATE;

SET sharded_table_dataset_id = 'project_id.dataset_name';
SET sharded_table_prefix = 'my_table_prefix_';

CALL bqtools.us.get_last_date_shard(sharded_table_dataset_id, sharded_table_prefix, last_shard);