Ready to get started?

Learn more about the CData JDBC Driver for Open Exchange Rates or download a free trial:

Download Now

Work with Open Exchange Rates Data in Apache Spark Using SQL

Access and process Open Exchange Rates Data in Apache Spark using the CData JDBC Driver.

Apache Spark is a fast and general engine for large-scale data processing. When paired with the CData JDBC Driver for Open Exchange Rates, Spark can work with live Open Exchange Rates data. This article describes how to connect to and query Open Exchange Rates data from a Spark shell.

The CData JDBC Driver offers unmatched performance for interacting with live Open Exchange Rates data due to optimized data processing built into the driver. When you issue complex SQL queries to Open Exchange Rates, the driver pushes supported SQL operations, like filters and aggregations, directly to Open Exchange Rates and utilizes the embedded SQL engine to process unsupported operations (often SQL functions and JOIN operations) client-side. With built-in dynamic metadata querying, you can work with and analyze Open Exchange Rates data using native data types.

Install the CData JDBC Driver for Open Exchange Rates

Download the CData JDBC Driver for Open Exchange Rates installer, unzip the package, and run the JAR file to install the driver.

Start a Spark Shell and Connect to Open Exchange Rates Data

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

    The Open Exchange Rates API supports basic authentication with an App Id. After you register, your App Id is displayed in your account dashboard. Set this to the AppId connection property.

    Built-in Connection String Designer

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

    java -jar cdata.jdbc.openexchangerates.jar

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

    Configure the connection to Open Exchange Rates, using the connection string generated above.

    scala> val openexchangerates_df ="jdbc").option("url", "jdbc:openexchangerates:AppId=abc1234;").option("dbtable","Projects").option("driver","cdata.jdbc.openexchangerates.OpenExchangeRatesDriver").load()
  3. Once you connect and the data is loaded you will see the table schema displayed.
  4. Register the Open Exchange Rates data as a temporary table:

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

    scala> openexchangerates_df.sqlContext.sql("SELECT Id, Statistics_ViewCount FROM Projects WHERE Id = MyProjectId").collect.foreach(println)

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

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