Skip to content
Last updated

Tableau Cloud Export Integration

Using Tableau Cloud (formerly Tableau Online) with Treasure Data allows you to interactively explore huge amounts of data and share your data discoveries across your business organizations.

For sample workflows of exporting to Tableau Cloud, view Treasure Boxes.

Prerequisites

  • Basic knowledge of Treasure Data.
  • A license and its installation of Tableau Cloud.
  • The connector requires the Datasource publish permission; the creator or admin user role would be matched.
  • Personal Access Token name and secret when you want to authenticate with Personal Access Token.

Limitations

  • The maximum result record is 250,000,000 records.
    If it is exceeded, the log displays the message: Extract file records limit exceeded: 250000000.

  • The lowest Timestamp value is 1000-01-01 00:00:00.
    If it is exceeded, the log displays the message: invalid date value.

  • Appending a large dataset to an existing Data Source may result in a timeout.
    You will see the below message in the job logs:

    2019-04-10 19:20:41.460 +0000 [WARN] (0001:transaction): !!! Data Source Publish is timed out. This is a known issue of Tableau when you append a large extract file to existing Data Source.
    2019-04-10 19:20:41.460 +0000 [WARN] (0001:transaction): !!! Check Tableau Console for final result of the Publish.
  • The job succeeds, but you must check the final result on Tableau Console (you can verify by using the Number of records in the Data Source).

  • The project name of Tableau must be unique. If multiple projects have the same name, the export will fail: Project Name must be unique, but found n projects with name: '<project_name>'.

  • Token expiry when the user chooses Personal Access Token for authentication method. Personal access tokens will expire if they are not used after 15 consecutive days. If they are used more frequently than every 15 days, an access token will expire after 1 year. After a year, you must create a new token. Expired personal access tokens will not display on the My Account Settings page.

  • When you authenticate with a PAT, you can only run one process using that PAT at a time (unlike when you authenticate using a username and password). If you run a second authentication using the same PAT while the first job is still running causes the authentication/authorization for the first job to be dropped and results in errors.
    It results in the following message in the job logs:

    2021-12-26 07:55:47.926 +0000 [WARN] (0001:transaction): Retrying 2/7 after 2 seconds. Message: javax.ws.rs.WebApplicationException: HTTP 401 Unauthorized
    ....
    2021-12-26 07:57:53.523 +0000 [ERROR] (main): org.embulk.util.retryhelper.RetryGiveupException: java.lang.NullPointerException

Static IP Address of Treasure Data Integration

If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection.

Please find the complete list of static IP addresses, organized by region, at the following link:
https://api-docs.treasuredata.com/en/overview/ip-addresses-integrations-result-workers/

Use the TD Console to Create a Connection

You must create and configure the data connection in Treasure Data before running your query. As part of the data connection, you provide authentication to access the integration.

There are two different processes to create a connection:

  • Use your Tableau username and password
  • Use a personal access token

Create a New Authentication with Tableau Username and Password

  1. Open TD Console.

  2. Navigate to Integrations Hub > Catalog.

  3. Search for and select Tableau.

  4. Select Create Authentication.

  5. Type the following credentials to authenticate.

    ParameterDescription
    HostTableau Cloud host where your site exists
    (e.g. 10az.online.tableau.com )
    UsernameYour Tableau Cloud username
    PasswordYour Tableau Cloud password
  6. Select Continue.

  7. Type a name for your connection.

  8. Select Done.

Create a New Authentication with Personal Access Token

  1. Log in to your Tableau Cloud server and go to My Account Settings.

  2. Enter a Personal Access Token name from the Settings tab and then select Create new token.

  3. Copy and store the Personal Access Token name/ Personal Access Token secret.

Log in to TD Console

  1. Open TD Console.

  2. Navigate to Integrations Hub > Catalog.

  3. Search for and select Tableau.

  4. Select Create Authentication.

  5. Type the following credentials to authenticate.

    ParameterDescription
    HostTableau Cloud host where your site exists
    (e.g. 10az.online.tableau.com)
    Auth methodPersonal Access Token
    Personal Access Token NameYour Tableau Cloud Personal Access Token name
    Personal Access Token SecretYour Tableau Cloud Personal Access Token secret
  6. Select Continue.

  7. Type a name for your connection.Select Done.

Define your Query

  1. Navigate to Data Workbench > Queries.
  2. Select New Query.
  3. Run the query to validate the result set.

One-Time Query CLI Usage

Add the Tableau result output destination by using the -r / —result option for the td query command:

Password Authentication

td query \
  -d mydb \
  -r '{
    "type": "tableau",
    "host": "company.online.tableau.com",
    "auth_method": "password",
    "username": "my_user",
    "password": "passw0rd",
    "ssl": true,
    "ssl_verify": false,
    "server_version": "online",
    "datasource": "my_ds",
    "site": "MarketingTeam",
    "project": "",
    "mode": "replace",
    "chunk_size_in_mb": 50,
    "timezone": "America/Los_Angeles"
  }' \
  'SELECT * FROM access'

Personal Access Token Authentication

td query \
  -d mydb \
  -r '{
    "type": "tableau",
    "host": "company.online.tableau.com",
    "auth_method": "pat",
    "pat_name": "pat_name",
    "pat_secret": "pat_secret",
    "ssl": true,
    "ssl_verify": false,
    "server_version": "online",
    "datasource": "my_ds",
    "site": "MarketingTeam",
    "project": "",
    "mode": "replace",
    "chunk_size_in_mb": 50,
    "timezone": "America/Los_Angeles"
  }' \
  'SELECT * FROM access'
ParameterDescription
auth_methodAuthentication method support([password, pat], default: password)
usernameYour Tableau Cloud Username (required if auth_method is password)
passwordYour Tableau Cloud Password (required if auth_method is password)
pat_nameYour Personal Access Token name ( required if auth_method is pat)
pat_secretYour Personal Access Token secret (required if auth_method is pat)
hostTableau Cloud Host on which your site exists (e.g. 10ay.online.tableau.com)
datasourceTarget Tableau DataSource name
siteThe URL of the site to sign in to To determine the value to use for the site attribute, sign in to Tableau Cloud, and examine the value that appears after /site/ in the URL. For example, in the following URL, the site value is MarketingTeam: https://online.tableau.com/#/site/MarketingTeam/workbooks Read the [REST API reference](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#Sign_In?TocPath=API%2520Reference
ModeReplace- replace Data Source each time Append- append to existing Data Source. (Default is Append)
chunk_size_in_mbChunk file size (in MB) to be uploaded each time, default: 100, min: 50, max: 512
read_timeout_millisThe time you wait for the response (max: 7200000). Value in milliseconds
timezoneTimezone to convert from Timestamp data type to Tableau DateTime data type, default: UTC

Change the Tableau result output destination from JSON format to URL format as in the following example:

$ td query -d mydb -r 'tableau://username:password@host/datasource?mode=replace&site' 'SELECT * FROM access'

Migrating Existing Output Configurations to Tableau Hyper

Tableau has updated its data engine with a technology called Hyper. To take advantage of this, you must update your existing Treasure Data output configurations. New Treasure Data configurations automatically use the latest version.

Upgrade Your Existing Configurations

  1. Go to Queries and select your scheduled query.
  2. In Query Editor and click Export Results target.
  3. Choose your saved Tableau connection.
  4. Input the Site ID value; it’s required for Tableau Cloud.
  5. Select 'hyper' for Data Source Type.
  6. Click Done to save your configuration.

You do not need to change the timezone configuration when migrating from the legacy Tableau to the current Tableau. You can leave the default value (UTC). See also the timezone in this article.

One-Time Query using TD Console

Go to the query editor on the TD Console, and type in the query. The following example query uses the access log example data set and calculates the distribution of the HTTP methods per day.

HIVE

-- HiveQL
SELECT
  CAST(TD_TIME_FORMAT(time, "yyyy-MM-dd 00:00:00") AS TIMESTAMP) AS `dates`,
  method AS `Method`,
  COUNT(1) AS `Count`
FROM
  www_access
GROUP BY
  TD_TIME_FORMAT(time, "yyyy-MM-dd 00:00:00"),
  method

PRESTO

-- Presto
SELECT
  CAST(TD_TIME_FORMAT(time, 'yyyy-MM-dd 00:00:00') AS TIMESTAMP) AS "dates",
  method AS "Method",
  COUNT(1) AS "Count"
FROM
  www_access
GROUP BY
  TD_TIME_FORMAT(time, 'yyyy-MM-dd 00:00:00'),
  method

Treasure Data is casting the Datetime column from String type to TIMESTAMP type in Tableau.

Tableau doesn’t support fractional seconds in a timestamp. Remove fractional seconds (for example, by using subtr() function) before casting to the TIMESTAMP type in the query.

Choose Saved Connection

A dialog Choose Integration displays. Select an existing Tableau Cloud connection. If you do not have a Saved Integration already set up, follow the next step on how to create a new connection within the Sources Catalog.

Additional Configuration

After you create a Tableau connection or select an existing one, you see the following Configuration popup.

ParametersDescriptionDefault values
Datasource NameThe name of the destination Data Source on Tableau Cloud
Site IDThe URL of the site to sign in to. To determine the value to use for the site attribute, sign in to Tableau Cloud, and examine the value that appears after /site/ in the URL. For example, in the following URL, the site value is MarketingTeam: https://online.tableau.com/#/site/MarketingTeam/workbooks This is required for Tableau Cloud.
Project NameGo to your Tableau Cloud to get a list of projects.Default
Modereplace to replace Data Source each time, append to append to existing Data Source.append
Chunk File Size In MBThe extract file is split into chunks before uploading. This option defines the file size of each chunk (min: 100, max: 1024).200
HTTP read timeout in millisecondsThe time you wait for the response (max: 7200000). Value in milliseconds.7200000
TimezoneTimezone ID to use when converting from Timestamp (timezone-independent) to Tableau DateTime (timezone-dependent).UTC

Append Mode ignores new columns if it is exporting data inserted an existing data source because of the specification of Tableau. https://onlinehelp.tableau.com/current/pro/desktop/en-us/extracting_addfromfile.html

  1. After completing all the fields, Submit the query. The system will execute the query, create the Tableau Data Extract file (.tde or .hyper), and upload the extract file to Tableau Cloud.
  2. Go to your Tableau Cloud, and click Data Sources at the top left bar. You can view the list of data sources, including your TDE file.
  3. Select New Workbook to create the charts and dashboard from the browser. Drag and drop the dimensions and measures from the left navigation to the top right navigation to create graphs. Select Save to store the result.

Migration Authentication from Password to Personal Access Token

When you enable MFA on the Tableau Cloud console, you can no longer use a username/password to authenticate. Tableau requires a Personal Access Token authentication. You must migrate all connections that used the Password Authentication method to the Personal Access Token Authentication method.

Change Connection to Personal Access Token Authentication Method

  1. Log in to TD console and go to Authentication.

  2. Change Auth method from Password to Personal Access Token and enter the token name/secret.

  3. You can use this connection to export data to Tableau with your Personal Access Token name/secret.

Update a Save Query to Personal Access Token Authentication Method

  1. Change the connector in the saved query from Password Authentication to Personal Access Token Authentication.

  2. Navigate to Data Workbench > Queries.

  3. Select your saved query and select Clone. Enter a new name for your query.

  4. From the query editor, select Export Result and choose the connection that was edited from Step 1; complete the export configuration again.

  5. Go to query on TD console and delete your old query.

Options

Result output to Tableau supports various options. The options can be specified as URL parameters on the CLI or with the REST APIs or the Console where supported. The options are normally compatible with each other and can be combined. Where applicable, the default behavior is indicated.

ssl Option

The ssl option determines whether to use SSL for connecting to the Tableau server. When ‘true’, SSL is used. ssl=true is the default when this option is not specified.

tableau://username:password@host/?ssl=true

ssl_verify Option

The ssl_verify option determines whether to require certificate verification for the SSL communication. When ‘true’, certificate verification is required. ssl_verify=true is the default when this option is not specified.

tableau://username:password@host/?ssl=true&ssl_verify=true

Disabling certificate verification is useful when the Tableau server’s SSL certificate is self-signed.

Timezone

  1. To convert from timestamp value, which is timezone independent, for example, 1548979200, to Tableau DateTime, which includes day, hour, minute, etc., the connector needs to know the target timezone.
  2. If your query contains a TIMESTAMP column or cast a datetime column to TIMESTAMP, the value is exported to the Tableau server as DateTime. There is a conversion, and you must provide the required target timezone.
  3. Treasure Data stores datetime value using UTC timezone. In most cases, leave the timezone config as default (UTC) to preserve the value from Treasure Data unless you want to convert the value to another timezone.

An example of configuring a timezone other than the default UTC is as follows:

From the CLI

$ td query "..." -r '{ "type": "tableau", ..., "timezone": "America/Los_Angeles" }'

As part of TD Workflow

host: "company.online.tableau.com"ssl: truessl_verify: trueusername: "my_user"password: "passw0rd"
datasource: "my_ds"site: "my_company"project: "Default" server_version: "online"
timezone: "America/Los_Angeles"

(Optional) Configure Export Results in Workflow

Within Treasure Workflow, you can specify the use of a data connector to export data.

Learn more at Using Workflows to Export Data with the TD Toolbelt.

Example Workflow for Password Authentication Method

_export:
  td:
    database: tableau_db
 
+tableau_export_task:
  td>: export_tableau.sql
  database: ${td.database}
  result_connection: new_created_tableau_auth
  result_settings:
    datasource: "datasource"
    site: "site"
    project: "project"
    targetType: "hyper"
    chunkSizeInMb: 100
    timezone: "UTC"

Example Workflow for Personal Access Token Authentication Method

_export:
  td:
    database: tableau_db
 
+tableau_export_task:
  td>: export_tableau.sql
  database: ${td.database}
  result_connection: new_created_tableau_auth
  result_settings:
    datasource: "datasource"
    site: "site"
    project: "project"
    targetType: "hyper"
    chunkSizeInMb: 100
    timezone: "UTC"