Skip to content

Strings

These functions are used to parse and manipulate STRING inputs.

Functions

parse_resource_id

Attribute Value
Name parse_resource_id
ID bqtools.[region].parse_resource_id
Description Parses valid resource_ids into constituent components.
Type FUNCTION
Arguments resource_id STRING
Returns STRUCT<is_valid BOOL, project_id STRING, dataset_name STRING, resource_name STRING, dataset_id STRING, resource_id STRING>
Dependencies None

execution: parse_resource_id

SELECT bqtools.eu.parse_resource_id(resource_id);
Individual components can be directly accessed using the following syntax (this will return the resource_name):
SELECT bqtools.eu.parse_resource_id(resource_id).resource_name;

SELECT bqtools.us.parse_resource_id(resource_id);
Individual components can be directly accessed using the following syntax (this will return the resource_name):
SELECT bqtools.us.parse_resource_id(resource_id).resource_name;

encode_uri_component

Attribute Value
Name encode_uri_component
ID bqtools.[region].encode_uri_component
Description Encodes a URI (Uniform Resource Identifier) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. Functional SQL implementation of the JavaScript function encodeURIComponent.
Type FUNCTION (JS)
Arguments input_uri STRING
Returns STRING
Dependencies encodeURIComponent()

execution: encode_uri_component

SELECT bqtools.eu.decode_uri_component(input_uri);
CALL bqtools.us.decode_uri_component(input_uri);
example: encode_uri_component
SELECT bqtools.eu.decode_uri_component("test?");
response: "test%3F"

decode_uri_component

Attribute Value
Name decode_uri_component
ID bqtools.[region].decode_uri_component
Description Decodes a URI (Uniform Resource Identifier) component. Functional SQL implementation of the JavaScript function decodeURIComponent.
Type FUNCTION (JS)
Arguments input_uri STRING
Returns STRING
Dependencies decodeURIComponent()

execution: decode_uri_component

SELECT bqtools.eu.decode_uri_component(input_uri);
CALL bqtools.us.decode_uri_component(input_uri);
example: decode_uri_component
SELECT bqtools.eu.decode_uri_component("test%3F");
response: "test?"

replace_resource_project_id

Attribute Value
Name replace_resource_project_id
ID bqtools.[region].replace_resource_project_id
Description Replaces the resource_project_id of the original_resource_id by the new replacement_project_id.
Type FUNCTION
Arguments original_resource_id STRING, replacement_project_id STRING
Returns resource_id STRING
Dependencies bqtools.[region].parse_resource_id

execution: replace_resource_project_id

SELECT bqtools.eu.replace_resource_project_id(original_resource_id, replacement_project_id);
CALL bqtools.us.replace_resource_project_id(original_resource_id, replacement_project_id);
example: replace_resource_project_id
DECLARE original_resource_id STRING;
DECLARE replacement_project_id STRING;

SET original_resource_id = "project_id.dataset_name.resource_name";
SET replacement_project_id = "new_project_id";

SELECT bqtools.eu.replace_resource_project_id(original_resource_id, replacement_project_id);

replace_resource_dataset_id

Attribute Value
Name replace_resource_dataset_id
ID bqtools.[region].replace_resource_dataset_id
Description Replaces the resource_dataset_id of the original_resource_id by the new replacement_dataset_id.
Type FUNCTION
Arguments original_resource_id STRING, replacement_dataset_id STRING
Returns resource_id STRING
Dependencies bqtools.[region].parse_resource_id

execution: replace_resource_dataset_id

SELECT bqtools.eu.replace_resource_dataset_id(original_resource_id, replacement_dataset_id);
CALL bqtools.us.replace_resource_dataset_id(original_resource_id, replacement_dataset_id);
example: replace_resource_dataset_id
DECLARE original_resource_id STRING;
DECLARE replacement_dataset_id STRING;

SET original_resource_id = "project_id.dataset_name.resource_name";
SET replacement_dataset_id = "new_project_id.new_dataset_name";

SELECT bqtools.eu.replace_resource_dataset_id(original_resource_id, replacement_dataset_id);
response: "new_project_id.new_dataset_name.resource_name"

replace_resource_dataset_name

Attribute Value
Name replace_resource_dataset_name
ID bqtools.[region].replace_resource_dataset_name
Description Replaces the resource_dataset_name of the original_resource_id by the new replacement_dataset_name.
Type FUNCTION
Arguments original_resource_id STRING, replacement_dataset_name STRING
Returns resource_id STRING
Dependencies bqtools.[region].parse_resource_id

execution: replace_resource_dataset_name

SELECT bqtools.eu.replace_resource_dataset_name(original_resource_id, replacement_dataset_name);
CALL bqtools.us.replace_resource_dataset_name(original_resource_id, replacement_dataset_name);
example: replace_resource_dataset_name
DECLARE original_resource_id STRING;
DECLARE replacement_dataset_name STRING;

SET original_resource_id = "project_id.dataset_name.resource_name";
SET replacement_dataset_name = "new_dataset_name";

SELECT bqtools.eu.replace_resource_dataset_name(original_resource_id, replacement_dataset_name);
response: "project_id.new_dataset_name.resource_name"

replace_resource_table_name

Attribute Value
Name replace_resource_table_name
ID bqtools.[region].replace_resource_table_name
Description Replaces the resource_table_name of the original_resource_id by the new replacement_table_name.
Type FUNCTION
Arguments original_resource_id STRING, replacement_table_name STRING
Returns resource_id STRING
Dependencies bqtools.[region].parse_resource_id

execution: replace_resource_table_name

SELECT bqtools.eu.replace_resource_table_name(original_resource_id, replacement_table_name);
CALL bqtools.us.replace_resource_table_name(original_resource_id, replacement_table_name);
example: replace_resource_table_name
DECLARE original_resource_id STRING;
DECLARE replacement_table_name STRING;

SET original_resource_id = "project_id.dataset_name.table_name";
SET replacement_table_name = "new_table_name";

SELECT bqtools.eu.replace_resource_table_name(original_resource_id, replacement_table_name);
response: "project_id.dataset_name.new__table_name"