Ready to get started?

Download a free trial of the DoubleClick Driver to get started:

 Download Now

Learn more:

DoubleClick Campaign Manager Icon DoubleClick JDBC Driver

An easy-to-use database-like interface for Java based applications and reporting tools access to live DoubleClick Campaign Manager data (Ads, Accounts, Creatives, Orders, and more).

How to work with Google Campaign Manager Data in Apache Spark using SQL

Access and process Google Campaign Manager 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 Google Campaign Manager, Spark can work with live Google Campaign Manager data. This article describes how to connect to and query Google Campaign Manager data from a Spark shell.

The CData JDBC Driver offers unmatched performance for interacting with live Google Campaign Manager data due to optimized data processing built into the driver. When you issue complex SQL queries to Google Campaign Manager, the driver pushes supported SQL operations, like filters and aggregations, directly to Google Campaign Manager 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 Google Campaign Manager data using native data types.

Install the CData JDBC Driver for Google Campaign Manager

Download the CData JDBC Driver for Google Campaign Manager installer, unzip the package, and run the JAR file to install the driver.

Start a Spark Shell and Connect to Google Campaign Manager Data

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

    Google Campaign Manager uses the OAuth authentication standard. The data provider facilitates OAuth in various ways as described below. The following OAuth flow requires the authenticating user to interact with DoubleClick Campaign Manager, using the browser. You can also use a service account to authenticate.

    For authentication guides, see the Getting Started section of the data provider help documentation.

    Built-in Connection String Designer

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

    java -jar cdata.jdbc.googlecm.jar

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

    Configure the connection to Google Campaign Manager, using the connection string generated above.

    scala> val googlecm_df ="jdbc").option("url", "jdbc:googlecm:UserProfileID=MyUserProfileID;").option("dbtable","CampaignPerformance").option("driver","cdata.jdbc.googlecm.GoogleCMDriver").load()
  3. Once you connect and the data is loaded you will see the table schema displayed.
  4. Register the Google Campaign Manager data as a temporary table:

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

    scala> googlecm_df.sqlContext.sql("SELECT Clicks, Device FROM CampaignPerformance WHERE Device = Mobile devices with full browsers").collect.foreach(println)

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

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