-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UDFs for generating deep links to BigQuery console (#359)
Co-authored-by: ddeleo <danieldeleo@google.com>
- Loading branch information
1 parent
9a9a2c8
commit 4fcd597
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
config { hasOutput: true } | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* Generates a deep link to the BigQuery console for a given job_id in the form: | ||
* project:location.job_id. | ||
*/ | ||
CREATE OR REPLACE FUNCTION ${self()}(job_id STRING) | ||
RETURNS STRING | ||
OPTIONS(description="""Generates a deep link to the BigQuery console | ||
for a given job_id in the form: "project:location.job_id". | ||
""") AS ( | ||
"https://console.cloud.google.com/bigquery?project=" | ||
|| SPLIT(job_id, ":")[SAFE_OFFSET(0)] | ||
|| "&j=bq:" | ||
|| SPLIT(SPLIT(job_id, ":")[SAFE_OFFSET(1)], ".")[SAFE_OFFSET(0)] | ||
|| ":" | ||
|| SPLIT(job_id, ".")[SAFE_OFFSET(1)] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
config { hasOutput: true } | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* | ||
* Generates a deep link to the BigQuery console for a table or view. | ||
*/ | ||
CREATE OR REPLACE FUNCTION ${self()}(table_id STRING) | ||
RETURNS STRING | ||
OPTIONS(description="""Generates a deep link to the BigQuery console | ||
for a table or view in the form: "project.dataset.table". | ||
""") AS ( | ||
"https://console.cloud.google.com/bigquery?p=" | ||
|| SPLIT(table_id, ".")[SAFE_OFFSET(0)] | ||
|| "&d=" | ||
|| SPLIT(table_id, ".")[SAFE_OFFSET(1)] | ||
|| "&t=" | ||
|| SPLIT(table_id, ".")[SAFE_OFFSET(2)] | ||
|| "&page=table" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters