You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a sample which demonstrates how to publish a plain multi-table .hyper file to Tableau Server (without wrapping it into a TDSX file). This is supported in Tableau Online/Tableau Server starting with version 2021.4. Renamed the old sample which demonstrates how to wrap a multi-table extract into a TDSX file.
- Demonstrates the full end-to-end workflow of how to create a multi-table `.hyper` file, place the extract into a `.tdsx`, and publish to Tableau Online or Server.
- Demonstrates how to create a `.hyper` file from a wildcard union on text files held in an AWS S3 bucket. The extract is then placed in a `.tdsx` file and published to Tableau Online or Server.
In contrast to single-table `.hyper` files, with multi-table `.hyper` files it is not obvious which data model you want to analyze in the data source on Tableau Server. Thus, when publishing to Tableau Server < 2021.4, you can only publish single-table `.hyper` files or need to wrap the `.hyper` file into a Packaged Data Source (.tdsx). Starting with version 2021.4, you can now publish multi-table `.hyper` files to Tableau Server and Tableau Online; the data model will be automatically inferred (as specified by assumed table constraints).
7
+
8
+
This sample demonstrates how to wrap the `.hyper` file into a Packaged Data Source (.tdsx). If you are looking for how to publish a plain multi-table `.hyper` file to Tableau Server 2021.4+, have a look at [this sample](https://github.com/tableau/hyper-api-samples/tree/main/Community-Supported/publish-multi-table-hyper).
9
+
10
+
This sample demonstrates how to leverage the Hyper API, Tableau Server Client Library, and Tableau Tools to do the following:
11
+
- Create a multi-table `.hyper` file
12
+
- Swap the newly created extract into an existing Packaged Data Source file (.tdsx)
13
+
- Publish the data source to a specified project on Tableau Online/Server
14
+
15
+
It should serve as a starting point for anyone looking to automate the publishing process of multi-table extracts and data sources to Tableau.
16
+
17
+
# Get started
18
+
19
+
## __Prerequisites__
20
+
To run the script, you will need:
21
+
- Windows or Mac
22
+
- Tableau Desktop v10.5 or higher
23
+
- Python 3
24
+
- Run `pip install -r requirements.txt`
25
+
- Tableau Online/Server credentials or Personal Access Token
26
+
27
+
## __Configuration File__
28
+
Modify `config.json` and add the following fields:
29
+
- Name of the `.hyper` file
30
+
- Name of the .tdsx file
31
+
- Server/Online url
32
+
- Site name
33
+
- Project name
34
+
- Authentication information
35
+
36
+
## __Data and Table Definitions__
37
+
If you want to simply run the sample to test the publishing process, you do not need to make any changes to the python file. Ensure that you have installed the requirements, update the config file with authentication information and execute the python file.
38
+
39
+
Once you are ready to use your own data, you will need to change the `build_tables()` and the `get_data()` functions. `build_tables()` returns the schema of all tables to be created (an array of `TableDefinition` objects, one for each table you want to create). `get_data()` returns the data to be inserted, one array for each table (an array of arrays, one containing the data to be inserted for each table). Those functions could be a part of an existing ETL workflow, grab the data from an API request, or pull CSVs from cloud storage like AWS, Azure, or GCP. In any case, writing that code is up to you. You can [check out this doc](https://help.tableau.com/current/api/hyper_api/en-us/reference/py/tableauhyperapi.html?tableauhyperapi.Inserter) information on how to pass data to Hyper's `inserter()` method and [this doc](https://help.tableau.com/current/api/hyper_api/en-us/reference/py/tableauhyperapi.html?tableauhyperapi.SqlType) for more information on the the Hyper API's SqlType class.
40
+
41
+
__Note:__ The current example features two tables, but in theory, this could support as many as you'd like. Just be sure to add the proper table definitions and make sure that the order in the list of table data and table definitions properly match.
42
+
43
+
## __Creating the .tdsx File__
44
+
As mentioned, one key step needed for the automatic publishing of multi-table `.hyper` files is a Packaged Data Source, or .tdsx. As of now, this is a step that must be completed manually as a part of the setup process. _You will only need to do this once_. If a .tdsx is not present in the directory, the script will prompt you to create one. At this point, you should have entered the required config fields and have run the python script once to create the multi-table `.hyper` file.
45
+
46
+
Packaged Data Sources contain important metadata needed for Tableau Desktop and Server/Online. This includes things like defined joins and join clauses, relationships, calculated fields, and more.
47
+
48
+
To create the .tdsx, [follow these steps](https://help.tableau.com/current/pro/desktop/en-us/export_connection.htm):
49
+
- Run the script without a data source present to create the initial `.hyper` file
50
+
- Double-click the `.hyper` file to open it in Tableau Desktop
51
+
- Click and drag the relevant tables and create the joins or relationships
52
+
- Head to 'Sheet 1'
53
+
- In the top-left corner, right-click on the data source and select 'Add to Saved Data Sources...'
54
+
- Name the file to match the value in `config.json`
55
+
- Select 'Tableau __Packaged__ Data Source (*.tdsx)' from the dropdown
56
+
- Save it in the directory with the script and `.hyper` file
57
+
58
+
Now you are free to rerun the script and validate the swapping and publishing process. Unless you change how the `.hyper` file is being created (schema, column names, joins, etc.), you will not need to remake the .tdsx again.
59
+
60
+
## __Additional Customization__
61
+
If you end up needing to change more about how the extract is built (e.g., inserting directly from a CSV file) then you will need to also change the `add_to_hyper()` function, but most likely nothing else.
62
+
63
+
Leverage the [official Hyper API samples](https://github.com/tableau/hyper-api-samples/tree/master/Python) to learn more about what's possible.
64
+
65
+
66
+
## __Resources__
67
+
Check out these resources to learn more:
68
+
-[Hyper API docs](https://help.tableau.com/current/api/hyper_api/en-us/index.html)
0 commit comments