Ready to get started?

Learn more about the CData JDBC Driver for SQL Analysis Services or download a free trial:

Download Now

Apache Spark でSQL Analysis Services Data をSQL で操作

CData JDBC ドライバーを使用して、Apache Spark でSQL Analysis Services Data にデータ連携。

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

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

CData JDBC Driver for SQL Analysis Services をインストール

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

Spark Shell を起動してSQL Analysis Services Data に接続

  1. Open a terminal and start the Spark shell with the CData JDBC Driver for SQL Analysis Services JAR file as the jars parameter: $ spark-shell --jars /CData/CData JDBC Driver for SQL Analysis Services/lib/cdata.jdbc.ssas.jar
  2. With the shell running, you can connect to SQL Analysis Services with a JDBC URL and use the SQL Context load() function to read a table.

    To connect, provide authentication and set the Url property to a valid SQL Server Analysis Services endpoint. You can connect to SQL Server Analysis Services instances hosted over HTTP with XMLA access. See the Microsoft documentation to configure HTTP access to SQL Server Analysis Services.

    To secure connections and authenticate, set the corresponding connection properties, below. The data provider supports the major authentication schemes, including HTTP and Windows, as well as SSL/TLS.

    • HTTP Authentication

      Set AuthScheme to "Basic" or "Digest" and set User and Password. Specify other authentication values in CustomHeaders.

    • Windows (NTLM)

      Set the Windows User and Password and set AuthScheme to "NTLM".

    • Kerberos and Kerberos Delegation

      To authenticate with Kerberos, set AuthScheme to NEGOTIATE. To use Kerberos delegation, set AuthScheme to KERBEROSDELEGATION. If needed, provide the User, Password, and KerberosSPN. By default, the data provider attempts to communicate with the SPN at the specified Url.

    • SSL/TLS:

      By default, the data provider attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store. To specify another certificate, see the SSLServerCert property for the available formats.

    You can then access any cube as a relational table: When you connect the data provider retrieves SSAS metadata and dynamically updates the table schemas. Instead of retrieving metadata every connection, you can set the CacheLocation property to automatically cache to a simple file-based store.

    See the Getting Started section of the CData documentation, under Retrieving Analysis Services Data, to execute SQL-92 queries to the cubes.


    For assistance in constructing the JDBC URL, use the connection string designer built into the SQL Analysis Services JDBC Driver.Either double-click the JAR file or execute the jar file from the command-line.

    java -jar cdata.jdbc.ssas.jar

    Fill in the connection properties and copy the connection string to the clipboard.

    scala> val ssas_df ="jdbc").option("url", "jdbc:ssas:User=myuseraccount;Password=mypassword;URL=http://localhost/OLAP/msmdpump.dll;").option("dbtable","Adventure_Works").option("driver","cdata.jdbc.ssas.SSASDriver").load()
  3. Once you connect and the data is loaded you will see the table schema displayed.
  4. Register the SQL Analysis Services data as a temporary table:

    scala> ssas_df.registerTable("adventure_works")
  5. Perform custom SQL queries against the Data using commands like the one below:

    scala> ssas_df.sqlContext.sql("SELECT Fiscal_Year, Sales_Amount FROM Adventure_Works WHERE Fiscal_Year = FY 2008").collect.foreach(println)

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

Using the CData JDBC Driver for SQL Analysis Services in Apache Spark, you are able to perform fast and complex analytics on SQL Analysis Services data, combining the power and utility of Spark with your data.Download a free, 30 day trial of any of the 190+ CData JDBC Drivers and get started today.