refresh_tableau¶
refresh_tableau(workbook_or_datasource_title, site, server, token_name, token_secret)
Description¶
Refresh a tableau datasource or workbook
named workbook_or_datasource_title
.
Use case:
After model refresh, launch tableau datasource / workbook refresh from BigQuery in SQL
- in a dbt post-hook
- in a dataform post_operations
- in a SQL Mesh post-statements
- in your favorite orchestration tool
Docs
- Tableau's doc for creating a personnal access token on tableau server (cloud or onprem) for api usage
Encrypt your secrets
We advise NOT TO write your token in plain text in token_secret
argument.
Otherwise, they will be stored in plain text in your BigQuery logs for months.
Instead, you can use the following snippet to generate an encrypted version of token_secret
that you can copy safely as token_secret
argument.
This public bigfunction (deployed on bigfunctions GCP project) will be able to decrypt it. But no one else can.
Usage¶
Call or Deploy refresh_tableau
?
Call refresh_tableau
directly
The easiest way to use bigfunctions
refresh_tableau
function is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Deploy refresh_tableau
in your project
Why deploy?
- You may prefer to deploy
refresh_tableau
in your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
refresh_tableau
function can be deployed with:
pip install bigfunctions
bigfun get refresh_tableau
bigfun deploy refresh_tableau
Requirements
refresh_tableau
uses the following secrets. Get them by reading the documentation link and store them in Google Secret Manager in the project where you deploy the function (and give Accessor role to the service account of the function):
name | description | documentation to get the secret |
---|---|---|
refresh_tableau_rsa_private_key |
RSA Private Key used to decrypt secrets | doc |
Examples¶
select bigfunctions.eu.refresh_tableau("My Great Workbook", "site_name", "eu-west-1a.online.tableau.com", "token_name", "ENCRYPTED_SECRET(GvVm...)")
select bigfunctions.us.refresh_tableau("My Great Workbook", "site_name", "eu-west-1a.online.tableau.com", "token_name", "ENCRYPTED_SECRET(GvVm...)")
select bigfunctions.europe_west1.refresh_tableau("My Great Workbook", "site_name", "eu-west-1a.online.tableau.com", "token_name", "ENCRYPTED_SECRET(GvVm...)")
+----------+
| response |
+----------+
| ok |
+----------+
Use cases¶
A common use case for the refresh_tableau
function is automating the refresh of Tableau dashboards after underlying data has been updated.
Scenario: Imagine a company that uses BigQuery to store sales data and Tableau to visualize this data in dashboards. They have a daily ETL process that updates the sales data in BigQuery. They want their Tableau dashboards to reflect this updated data automatically.
Implementation using refresh_tableau
:
-
Tableau Setup: A personal access token is created in Tableau Server with appropriate permissions to refresh the target datasource or workbook.
-
BigQuery Implementation: The
refresh_tableau
function is called within a BigQuery script, scheduled to run after the daily ETL process completes. This script would look something like this (using the US region example):
-- Assume the ETL process has just finished updating sales data.
SELECT bigfunctions.us.refresh_tableau(
'Sales Dashboard', -- Replace with the actual workbook/datasource name
'site_name', -- Replace with the Tableau site name
'eu-west-1a.online.tableau.com', -- Replace with your Tableau server address
'token_name', -- Replace with your token name
'ENCRYPTED_SECRET(GvVm...)' -- Replace with your encrypted token secret
);
- Orchestration (Optional): A workflow orchestration tool like Cloud Composer or Cloud Functions could be used to manage the dependencies between the ETL process and the BigQuery script. The orchestration tool would ensure that the
refresh_tableau
function is called only after the ETL process has successfully completed.
Benefits:
- Automation: Eliminates the need for manual refreshes, saving time and ensuring data consistency.
- Data Freshness: Dashboards always reflect the latest data.
- Integration: Seamlessly integrates with BigQuery ETL processes.
- Centralized Management: Tableau refresh logic is managed within BigQuery, simplifying administration.
This automation ensures that business users always have access to the most up-to-date insights in their Tableau dashboards without any manual intervention. The encrypted secret provides a secure way to manage the Tableau access token within the BigQuery environment.
Need help or Found a bug?
Get help using refresh_tableau
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about refresh_tableau
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.