製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

Azure Data Lake Storage JDBC Driver

Azure Data Lake Storage データに連携するJava アプリケーションを素早く、簡単に開発できる便利なドライバー。

データ連携でお困りですか?

お問い合わせ

Apache Spark でAzure Data Lake Storage データをSQL で操作


CData JDBC ドライバーを使用して、Apache Spark でAzure Data Lake Storage にデータ連携。


azuredatalake ロゴ画像
jdbc ロゴ画像

JDBC

Apache Spark ロゴ画像

Apache Spark は大規模データ処理のための高速で一般的なエンジンです。CData JDBC Driver for ADLS と組み合わせると、Spark はリアルタイムAzure Data Lake Storage にデータ連携して処理ができます。ここでは、Spark シェルに接続してAzure Data Lake Storage をクエリする方法について説明します。

CData JDBC Driver は、最適化されたデータ処理がドライバーに組み込まれているため、リアルタイムAzure Data Lake Storage と対話するための高いパフォーマンスを提供します。Azure Data Lake Storage に複雑なSQL クエリを発行すると、ドライバーはフィルタや集計など、サポートされているSQL操作を直接Azure Data Lake Storage にプッシュし、組込みSQL エンジンを使用してサポートされていない操作(SQL 関数やJOIN 操作)をクライアント側で処理します。組み込みの動的メタデータクエリを使用すると、ネイティブデータ型を使用してAzure Data Lake Storage を操作して分析できます。

CData JDBC Driver for ADLS をインストール

CData JDBC Driver for ADLS インストーラをダウンロードし、パッケージを解凍し、JAR ファイルを実行してドライバーをインストールします。

Spark Shell を起動してAzure Data Lake Storage データに接続

  1. ターミナルを開き、Spark shell でCData JDBC Driver for ADLS JAR file をjars パラメータに設定します: $ spark-shell --jars /CData/CData JDBC Driver for ADLS/lib/cdata.jdbc.adls.jar
  2. Shell でJDBC URL を使ってAzure Data Lake Storage に接続し、SQL Context load() function でテーブルを読み込みます。

    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:

    1. Sign in to your Azure Account through the .
    2. Select "Azure Active Directory".
    3. Select "App registrations".
    4. Select "New application registration".
    5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
    6. 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.
    7. 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 接続文字列URL の作成には、Azure Data Lake Storage JDBC Driver にビルトインされたデザイナを使用できます。JAR ファイルをダブルクリックするか、コマンドラインでJAR ファイルを実行するとデザイナが開きます。

    java -jar cdata.jdbc.adls.jar

    接続プロパティを入力し、接続文字列をクリップボードにコピーします。

    scala> val adls_df = spark.sqlContext.read.format("jdbc").option("url", "jdbc:adls:Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;").option("dbtable","Resources").option("driver","cdata.jdbc.adls.ADLSDriver").load()
  3. 接続が完了し、データがロードされたら、テーブルスキーマが表示されます。
  4. Azure Data Lake Storage をテンポラリーテーブルとして登録します:

    scala> adls_df.registerTable("resources")
  5. データに対して、次のようなカスタムSQL クエリを実行します:

    scala> adls_df.sqlContext.sql("SELECT FullPath, Permission FROM Resources WHERE Type = FILE").collect.foreach(println)

    You will see the results displayed in the console, similar to the following:

    Data in Apache Spark (Salesforce is shown)

CData JDBC Driver for ADLS をApache Spark で使って、Azure Data Lake Storage に対して、複雑かつハイパフォーマンスなクエリを実行できます。是非、30日の無償評価版 をダウンロードしてお試しください。