DATABRICKS Library

DATABRICKS Library

The DATABRICKS Library is an importable library containing functions to connect, authenticate, and interact with Databricks' API. This library is used in the Databricks Adapter.

When imported into projects, typically only the DATABRICKSclient module needs to be required in order to create the client and access the API methods.

require "DATABRICKS.DATABRICKSclient"

How it works:

Use the Translator’s built in help to review how to use each function:

Sets up the Databricks adapter framework, adding the various method modules to a metatable and storing the configurations added to the custom fields.
DATABRICKScustom takes in any API requests and parameters to make the API call and return the response. First, the function checks if the token key exists. If not, it calls DATABRICKSauth to perform the authentication workflow to obtain the token to be used in subsequent requests. Uses the passed configurations API request parameters - the method (ex. post), API (ex. 2.0/sql/statements) and parameters for the call (ex. the sql statement to execute) - to build and carry out the appropriate HTTP request.
DATABRICKSgetSqlWarehouses prepares the parameters and calls the “2.0/sql/warehouses” endpoint using DATABRICKScustom for a HTTP GET request.
DATABRICKSrunSQL prepares the parameters and calls the “2.0/sql/statements” endpoint using DATABRICKScustom for a HTTP POST request.
DATABRICKSrunJob prepares the parameters and calls the “2.2/jobs/run-now” endpoint using DATABRICKScustom for a HTTP POST request, starting a job in Databricks. Note that this is an asynchronous call, meaning that it will return a job id, but not the actual result.