# Pentaho Data Import Integration この記事では、[presto-jdbc driver](https://prestosql.io/docs/current/installation/jdbc.md)を使用して、[Pentaho Data Integration](https://www.hitachivantara.com/en-us/home.md)でTreasure Dataを使用する方法を説明します。Treasure DataとPentahoを組み合わせることで、ユーザーは既存のPentaho Data Integration環境を拡張して、膨大な量のデータを処理できます。 ## 前提条件 - Treasure Dataの基本知識 ## Pentaho Data Integration(Kettle)のダウンロード 以下のリンクからPentaho Data Integration(Kettle)をダウンロードできます。この記事ではバージョン8.2がテストされました - [Pentaho Data Integration (Kettle)](http://kettle.pentaho.com/) ## JDBCドライバーのダウンロード 以下のリンクからドライバーをダウンロードできます。ドライバーはまだベータ版です。フィードバックをお待ちしております。 Pentahoで動作するには、**td-jdbc-VERSION-jar-with-dependencies.jarファイル**を使用する必要があります。 - [JDBC Driver Download](https://mvnrepository.com/artifact/com.treasuredata/td-jdbc/0.5.10) Treasure Data JDBDドライバーは非推奨です。 ## JDBCドライバーjarをPentaho Data Integrationにコピー Pentaho Data Integrationを起動する前に、Treasure Data JDBCドライバーをPentaho Data Integrationで指定された`lib`ディレクトリにコピーしてください。 ```bash $ cp td-jdbc-VERSION-jar-with-dependencies.jar \ pentaho-data-integration-install/data-integration/lib ``` ## Treasure Dataデータベース接続を作成 Treasure DataをPentaho Data Integrationのデータベース接続に接続し、新しいトランスフォーメーションを作成します。以下の手順に従ってください。 ## 新しいトランスフォームを作成 1. Pentaho DIアプリケーションを開きます。 ![](/assets/pentaho1.5627a392657af19d960c7162f85ea3463a4dbf166ac959051e1c1d6978171008.22c8db65.png) 2. File > New > Transformationを選択します ![](/assets/pentaho2.008f0b6a615c5aa4de9137bacc2cb9d8706a351df3960390165d638e70e11a6c.22c8db65.png) ## 新しいデータベース接続を作成 1. Tools > Wizard > Create database connectionに移動します。 ![](/assets/pentaho3.d87a8e1870c7857e0607440a8e32ef8bcc282615de3f1822a141f986a5aaa7d6.22c8db65.png) 2. ポップアップダイアログで詳細を編集します。 - データベース接続に名前を付けます - type of databaseにGeneric Databaseを選択します - type of database accessにNative (JDBC)を選択します ![](/assets/pentaho4.0698ebb9ee9549dfbcac94e1f31db92ce4be023c0bce8803a005f7f0d53cbac8.22c8db65.png) 3. 接続のURL([APIエンドポイント](https://api-docs.treasuredata.com/en/overview/aboutendpoints/#treasure-data-sites-and-baseurls)を参照)とドライバークラスの名前を指定します。 - Driver classはcom.treasuredata.jdbc.TreasureDataDriverです ![](/assets/screen-shot-2022-07-20-at-9.38.45.a82a5acbea14d9332063794361e9a5f8917260c8dea70faf551d8176f4b49f4d.22c8db65.png) URLは以下のいずれかの方法で指定できます: - `jdbc:td://api.treasuredata.com/` - SSLを強制する場合は`jdbc:td://api.treasuredata.com/;useSSL=True`を使用します - パラメータでクエリエンジン[Hive](https://docs.treasuredata.com/articles/project-product-documentation/about-hive-query-engine)または[Presto](https://docs.treasuredata.com/articles/project-product-documentation/about-presto-distributed-query-engine)(デフォルト)を選択できます - jdbc:[td://api.treasuredata.com/sample_db;useSSL=true;type=hive](td://api.treasuredata.com/sample_db;useSSL=true;type=hive) - jdbc:[td://api.treasuredata.com/sample_db;useSSL=true;type=presto](td://api.treasuredata.com/sample_db;useSSL=true;type=presto) 4. ユーザー名とパスワードを指定します。これらのフィールドにはTreasure Dataの資格情報を使用します(ユーザー名はTreasure Dataに登録するために使用したメールアドレスです)。 - Test database connectionを選択します。 ![](/assets/pentaho6.4daefaf1a1a5b0acd8ac8eb0c59d5d50ae9d25969e71d1bf25b118f6cf915253.22c8db65.png) # Treasure DataデータベースをTable Inputとして使用 ## Table Inputを指定 1. トランスフォームのInputメニューから**Table Input**を選択します。 2. 次のようにワークスペースにドラッグアンドドロップします: ![](/assets/image-20190927-233140.7666969354b64786b3fc1dede46cacdcd2a295214221d23fe079173a3e3fa7e2.22c8db65.png) ## Table Inputを編集 1. ワークスペースのTable inputアイコンを右クリックします。 2. コンテキストメニューから**Edit**を選択します。 3. 次のようにTable inputを設定します: ![](/assets/image-20190927-233323.c8d7888cf3e443e33140d2156318b507c9b9e335bb85c6bdb68b4fd23d15abdd.22c8db65.png) 前述のクエリは、[JasperSoft iReport with JDBC Driver](/ja/int/jaspersoft-ireport-export-integration)の記事でレビューされています。 ## Table Inputを確認 Table inputの動作を確認するには、Treasure Data上のデータを次のようにJSON出力に送信します: ![](/assets/image-20190927-233412.e1150c1c21103f781da15266ee8c4b0ca9ebbfa862fa0baf12a5508e34f02a31.22c8db65.png) # ヒント: プロキシ経由でPentahoを使用するにはどうすればよいですか? 'start-pentaho.bat'または'start-pentaho.sh'を確認し、CATALINA_OPTSオプションに以下のパラメータを追加します: ``` CATALINA_OPTS="-Dhttp.proxyHost=proxy address -Dhttp.proxyPort=proxy port" ```