Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →How to connect and process Paylocity Data from Azure Databricks
Use CData, Azure, and Databricks to perform data engineering and data science on live Paylocity Data
Databricks is a cloud-based service that provides data processing capabilities through Apache Spark. When paired with the CData JDBC Driver, customers can use Databricks to perform data engineering and data science on live Paylocity data. This article walks through hosting the CData JDBC Driver in Azure, as well as connecting to and processing live Paylocity data in Databricks.
With built-in optimized data processing, the CData JDBC driver offers unmatched performance for interacting with live Paylocity data. When you issue complex SQL queries to Paylocity, the driver pushes supported SQL operations, like filters and aggregations, directly to Paylocity and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations). Its built-in dynamic metadata querying allows you to work with and analyze Paylocity data using native data types.
Install the CData JDBC Driver in Azure
To work with live Paylocity data in Databricks, install the driver on your Azure cluster.
- Navigate to your Databricks administration screen and select the target cluster.
- On the Libraries tab, click "Install New."
- Select "DBFS" as the Library Source and "JAR" as the Library Type.
- Upload the JDBC JAR file (cdata.jdbc.paylocity.jar) from the installation location (typically C:\Program Files\CData\CData JDBC Driver for Paylocity\lib).
Connect to Paylocity from Databricks
With the JAR file installed, we are ready to work with live Paylocity data in Databricks. Start by creating a new notebook in your workspace. Name the workbook, make sure Python is selected as the language (which should be by default), click on Connect and under General Compute select the cluster where you installed the JDBC driver (should be selected by default).
Configure the Connection to Paylocity
Connect to Paylocity by referencing the class for the JDBC Driver and constructing a connection string to use in the JDBC URL. Additionally, you will need to set the RTK property in the JDBC URL (unless you are using a Beta driver). You can view the licensing file included in the installation for information on how to set this property.
driver = "cdata.jdbc.paylocity.PaylocityDriver" url = "jdbc:paylocity:RTK=5246...;OAuthClientID=YourClientId;OAuthClientSecret=YourClientSecret;RSAPublicKey=YourRSAPubKey;Key=YourKey;IV=YourIV;InitiateOAuth=GETANDREFRESH"
Built-in Connection String Designer
For assistance in constructing the JDBC URL, use the connection string designer built into the Paylocity JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.paylocity.jar
Fill in the connection properties and copy the connection string to the clipboard.
Set the following to establish a connection to Paylocity:
- RSAPublicKey: Set this to the RSA Key associated with your Paylocity, if the RSA Encryption is enabled in the Paylocity account.
This property is required for executing Insert and Update statements, and it is not required if the feature is disabled.
- UseSandbox: Set to true if you are using sandbox account.
- CustomFieldsCategory: Set this to the Customfields category. This is required when IncludeCustomFields is set to true. The default value for this property is PayrollAndHR.
- Key: The AES symmetric key(base 64 encoded) encrypted with the Paylocity Public Key. It is the key used to encrypt the content.
Paylocity will decrypt the AES key using RSA decryption.
It is an optional property if the IV value not provided, The driver will generate a key internally. - IV: The AES IV (base 64 encoded) used when encrypting the content. It is an optional property if the Key value not provided, The driver will generate an IV internally.
Connect Using OAuth Authentication
You must use OAuth to authenticate with Paylocity. OAuth requires the authenticating user to interact with Paylocity using the browser. For more information, refer to the OAuth section in the Help documentation.
The Pay Entry API
The Pay Entry API is completely separate from the rest of the Paylocity API. It uses a separate Client ID and Secret, and must be explicitly requested from Paylocity for access to be granted for an account. The Pay Entry API allows you to automatically submit payroll information for individual employees, and little else. Due to the extremely limited nature of what is offered by the Pay Entry API, we have elected not to give it a separate schema, but it may be enabled via the UsePayEntryAPI connection property.
Please be aware that when setting UsePayEntryAPI to true, you may only use the CreatePayEntryImportBatch & MergePayEntryImportBatchgtable stored procedures, the InputTimeEntry table, and the OAuth stored procedures. Attempts to use other features of the product will result in an error. You must also store your OAuthAccessToken separately, which often means setting a different OAuthSettingsLocation when using this connection property.
Load Paylocity Data
Once the connection is configured, you can load Paylocity data as a dataframe using the CData JDBC Driver and the connection information.
remote_table = spark.read.format ( "jdbc" ) \ .option ( "driver" , driver) \ .option ( "url" , url) \ .option ( "dbtable" , "Employee") \ .load ()
Display Paylocity Data
Check the loaded Paylocity data by calling the display function.
display (remote_table.select ("FirstName"))
Analyze Paylocity Data in Azure Databricks
If you want to process data with Databricks SparkSQL, register the loaded data as a Temp View.
remote_table.createOrReplaceTempView ( "SAMPLE_VIEW" )
The SparkSQL below retrieves the Paylocity data for analysis.
result = spark.sql("SELECT FirstName, LastName FROM SAMPLE_VIEW WHERE SAMPLE_VIEWId = '1234'")
The data from Paylocity is only available in the target notebook. If you want to use it with other users, save it as a table.
remote_table.write.format ( "parquet" ) .saveAsTable ( "SAMPLE_TABLE" )
Download a free, 30-day trial of the CData JDBC Driver for Paylocity and start working with your live Paylocity data in Azure Databricks. Reach out to our Support Team if you have any questions.