CData JDBC Driver for ADLS を使用して、Squirrel SQL Client などのツールでAzure Data Lake Storage へのクエリを実行できます。この記事では、JDBC data source for ADLS を作成し、クエリを実行します。
JDBC Driver for ADLS を追加する
以下のステップに従ってドライバーJAR を追加します。
- Squirrel SQL で[Windows]->[View Drivers]と進みます。
- プラスアイコンをクリックし、[Add Driver]ウィザードを開きます。
- [Name]ボックスで、CData JDBC Driver for ADLS のようなドライバーのわかりやすい名前を入力します。
- [Example URL]ボックスで、jdbc:adls: と入力します。
- [Extra Class Path]タブで[Add]をクリックします。
- 表示される[file explorer]ダイアログで、インストールディレクトリのlib サブフォルダにあるドライバーのJAR ファイルを選択します。
- [List Drivers]をクリックして[Class Name]メニューにドライバーのクラス名(cdata.jdbc.adls.ADLSDriver) を入力します。
接続プロパティを定義する
以下のステップに従って、接続プロパティをドライバーエイリアスに保存します。
- [Windows]->[View Aliases]と進みます。
- エイリアスが一覧表示されているペインで、プラスアイコンをクリックします。
表示される[Add Alias]ウィザードで、JDBC ドライバーには以下のフィールドが要求されます。
- Name:CData Azure Data Lake Storage Source のようなエイリアスの名前を入力します。
- Driver:CData JDBC Driver for ADLS を選択します。
- URL:jdbc:adls: と入力します。
- 追加のプロパティを定義する場合は、[Properties]をクリックします。
- 表示されるダイアログの[Driver properties]タブで、[Use driver properties]のチェックボックスを選択します。
- [Specify]カラムで必要な接続プロパティのチェックボックスを選択します。
Authenticating to a Gen 1 DataLakeStore Account
Gen 1 uses OAuth 2.0 in Azure AD for authentication.
For this, an Active Directory web application is required. You can create one as follows:
- Sign in to your Azure Account through the
[.
]- Select "Azure Active Directory".
- Select "App registrations".
- Select "New application registration".
- Provide a name and URL for the application. Select Web app for the type of application you want to create.
- Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
- Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.
To authenticate against a Gen 1 DataLakeStore account, the following properties are required:
- Schema: Set this to ADLSGen1.
- Account: Set this to the name of the account.
- OAuthClientId: Set this to the application Id of the app you created.
- OAuthClientSecret: Set this to the key generated for the app you created.
- TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
- Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
Authenticating to a Gen 2 DataLakeStore Account
To authenticate against a Gen 2 DataLakeStore account, the following properties are required:
- Schema: Set this to ADLSGen2.
- Account: Set this to the name of the account.
- FileSystem: Set this to the file system which will be used for this account.
- AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
- Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
以下は一般的な接続文字列です。
jdbc:adls:Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;InitiateOAuth=GETANDREFRESH
- [OK]をクリックし、表示されるダイアログで[connect]をクリックして接続を確認します。
スキーマを検出しAzure Data Lake Storage データをクエリする
メタデータが読み込まれると、Azure Data Lake Storage データソースの新しいタブが表示されます。[Objects]サブタブでは、使用可能なテーブルやビューなどのスキーマ情報を見つけることができます。
テーブルデータを表示するには[Objects]タブでテーブルを選択します。その後、テーブルデータが[Content]タブのグリッドに読み込まれます。
SQL クエリを実行するには、[SQL]タブにクエリを入力し、[Run SQL](ランナーアイコン)をクリックします。例:
SELECT FullPath, Permission FROM Resources WHERE Type = 'FILE'