また、黒い画面のお話をします。
Tableau Prep BuilderにはGUIで操作できるインターフェースとは別に、フローをコマンドラインで実行させるユーティリティ「tableau-prep-cli.bat」が含まれています。
Tableau Prepコマンドラインを使いこなすことが出来れば、フローファイルをソフトウェアで開かずとも処理を実行させることが出来ます。スクリプトを組める方は、Tableau Serverの「tabcmd」と組み合わせて、1. フロー実行、2. 抽出ファイルのサーバーアップロードというタスクを自動化することが出来るでしょう。
導入と基本的な使い方について記事投稿します。
Tableau Prep Conductorがあればコマンドラインは不要

組織ですでに、データ準備拡張機能である「Tableau Prep Conductor」が導入されていれば、今回ご紹介する記事の内容は不要となります。なぜなら、Tableau Server上にフローファイルをパブリッシュして、そこでスケジューラー実行できるからです。
とは言え、「Tableau Data Management Add-on」が必要となります。そして、このライセンス体系がなかなかのトラップ…(苦笑
フローの共有、自動実行を検討されている方には葛藤になりえるライセンス体系です。詳細は割愛します…w
Tableau Prepコマンドライン「tableau-prep-cli」
環境準備・導入
Tableau Prepコマンドラインは、Tableau Prep Builderに含まれています。Prepの導入が終わっていれば使うことが出来ます。
- クライアントPCの管理者権限。
- 「tableau-prep-cli.bat」のパス
- Tableau Flow (.tfl) ファイルが置かれているパス
- JSON認証資格情報ファイル
上記の通り、クライアントマシンには管理者権限が必要です。各種ファイルパスは、ローカルかネットワークドライブかをよく確認しておくことを勧めます。
「tableau-prep-cli.bat」のパス
Windows10と2019.4の組み合わせでは次の場所にコマンドユーティリティがインストールされていました。
インストール場所 | C:\Program Files\Tableau\Tableau Prep Builder 2019.2\scripts |
---|
「Tableau Prep Builder <バージョン>」はお使いのバージョンによって変わります。
JSON認証資格情報ファイル
Tableau Prepのフロー実行で関係する認証情報はJSON形式のファイルにまとめます。
データクリーニングで読み込んだ各種データベースへの接続は、入力情報(inputConnections)として定義。出力がTableau Serverであれば出力情報(outputConnections)として定義。
以下はどちらも必要というわけではなく、用途に応じて片方・両方の利用を使い分ければよいです。
{
"inputConnections":[
{
"username": "jsmith",
"contentUrl": "my-testing-site",
"hostname":"https://my-server",
"port":123,
"password": "passw0rd$"
}
],
"outputConnections":[
{
"serverUrl":"https://my-server",
"contentUrl":"my-testing-site",
"username":"jsmith",
"password":"passw0rd$"
}
]
}
username | ユーザー名 |
---|---|
contentUrl | サイトID, Tableau Server または Tableau Online にサインインしたときに URL の /site/ の後ろに表示される文字列。 |
hostname | ホスト名(またはIPアドレス) |
port | ポート番号 |
password | パスワード |
serverUrl | Tableau Server または Tableau OnlineのURL |
---|---|
contentUrl | サイトID, Tableau Server または Tableau Online にサインインしたときに URL の /site/ の後ろに表示される文字列。 |
username | ユーザー名 |
password | パスワード |
基本的な使い方
環境変数の追加
私が確認したWindows10の場合は、コマンドパスが通っていませんでした。GUI操作で通しておくか、スクリプトにする場合は都度以下のようなコマンドをいれておくとよいと思います(以下は、Powershellの場合)
$Env:Path += ";C:\Program Files\Tableau\Tableau Prep Builder 2019.2\scripts"
コマンドヘルプ
PS > tableau-prep-cli.bat -h
JAVA_HOME is set to : C:\Program Files\Tableau\Tableau Prep Builder 2019.2\scrip
ts..\Plugins\jre temporarily
usage: tableau-prep-cli [-c <arg>] [-d] [-h] [-t <arg>]
-c,–connections <arg> Path to a file with all connection information
-d,–debug This option is for debugging
-h,–help Print usage message
-t,–tflFile <arg> The Tableau Prep flow file
コマンドオプション | 説明 |
---|---|
-c,–connections | ログイン情報ファイルへの接続パスです。 |
-d,–debug | フロープロセスのデバッグを行います。 |
-h,–help | 構文オプションのヘルプを表示します。 |
-t,–tflFile | 実効する「.tflフローファイル」を指定します。 |
コマンド実行例
PS > tableau-prep-cli.bat -c <資格情報ファイルパス> -t <フローファイルパス>
JAVA_HOME is set to : C:\Program Files\Tableau\Tableau Prep Builder 2019.2\scripts..\Plugins\jre temporarily
Preparing to run the flow : <フローファイルパス>
Loading the flow.
Creating temp directory at C:\Users\\AppData\Local\Temp\prep-cli-7764126444030950643
Loaded the flow.
Updated the connections with supplied credentials.
Established input connections to remote connection: xxx.xxx.xxx.xxx
Established input connections with remote data sources.
Checking the flow document for errors.
Flow Document has no errors.
Preparing to execute the flow.
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Running
Flow Execution Status: Finished
Finished running the flow successfully.
まとめ
「Tableau Prep Conductor」はなかなかすぐに手を出せないという企業は、価格が値下がりすることを祈ってこのコマンドを使うことにしましょう。Tableau Server「tabcmd」と組み合わせればより強力です。