How to work with Claude Compliance Data in Apache Spark using SQL

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Access and process Claude Compliance 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 Claude Compliance, Spark can work with live Claude Compliance data. This article describes how to connect to and query Claude Compliance data from a Spark shell.

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

Install the CData JDBC Driver for Claude Compliance

Download the CData JDBC Driver for Claude Compliance installer, unzip the package, and run the JAR file to install the driver.

Start a Spark Shell and Connect to Claude Compliance Data

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

    The driver connects to Claude Compliance using a Compliance Access Key, the only supported authentication method. Set the following connection property:

    • APIKey: The Compliance Access Key you created.

    Creating a Compliance Access Key

    1. Enable the Compliance API for your organization.
    2. Sign in to claude.ai as a primary owner or organization owner and open Organization settings > API > Keys.
    3. Select Create Key and assign only the scopes your integration needs:
      • read:compliance_activities for Activities and the typed activity views.
      • read:compliance_org_data for organizations, roles, groups, and settings.
      • read:compliance_user_data for users, chats, files, projects, and downloads.
      • delete:compliance_user_data for the explicit Delete stored procedures.
    4. Create the key and copy it when it appears. The key starts with sk-ant-api01- and is shown only once.

    Optionally, set OrganizationUUID to limit organization-scoped views (such as OrganizationUsers and ComplianceRoles) to a single linked organization. If it is left empty, those views default to the first available organization and do not include data from all linked organizations.

    Built-in Connection String Designer

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

    
    java -jar cdata.jdbc.claudecompliance.jar
    

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

    Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

    Configure the connection to Claude Compliance, using the connection string generated above.

    
    scala> val claudecompliance_df = spark.sqlContext.read.format("jdbc").option("url", "jdbc:claudecompliance:APIKey=your_compliance_access_key;").option("dbtable","Projects").option("driver","cdata.jdbc.claudecompliance.ClaudeComplianceDriver").load()
    
  3. Once you connect and the data is loaded you will see the table schema displayed.
  4. Register the Claude Compliance data as a temporary table:

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

    scala> claudecompliance_df.sqlContext.sql("SELECT Id, Name FROM Projects WHERE OrganizationUuid = abcdef01-2345-6789-abcd-ef0123456789").collect.foreach(println)

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

    Data in Apache Spark (Salesforce is shown)

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

Ready to get started?

Download a free trial of the Claude Compliance Driver to get started:

 Download Now

Learn more:

Claude Compliance Icon Claude Compliance JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Claude Compliance data including Activities, Chats, ChatMessages, CodeArtifacts, ComplianceRoles, Organizations, OrganizationUsers, Projects, and more!