Skip to main content

Databricks

Databricks combines data warehouses & data lakes into a lakehouse architecture.

TagsDatabaseSQL

Credential configuration

To access your Databricks cluster or SQL warehouse you'll need:

  • Your Databricks personal access token, which is similar to the following: dapi1ab2c34defabc567890123d4efa56789.
  • Your cluster's or SQL warehouse's Server Hostname, that is similar to the following: dbc-a1b2345c-d6e7.cloud.databricks.com.
  • The HTTP Path value for the path, which is similar to the following:
    • For a cluster, sql/protocolv1/o/1234567890123456/1234-567890-abcdefgh
    • For a SQL warehouse, /sql/1.0/endpoints/a1b234c5678901d2

Check this page for more information.

Here is an example of a filled credential configuration form in YepCode:

Databricks Snippets available in editor

note

The title is the triggering text for YepCode to autocomplete the script.

Integration

New integration from credential
const databricksClient = yepcode.integration.databricks("credential-slug");
New integration from plain authentication data
const { DBSQLClient } = require('@databricks/sql');

const databricksClient = new DBSQLClient();

await databricksClient
.connect({
host: 'host',
path: 'path',
token: 'token',
})

Execute Query

Execute query
const session = await databricksClient.openSession();

const queryOperation = await session.executeStatement(
'SELECT "Hello, World!"',
{ runAsync: true }
);
const result = await queryOperation.fetchAll();
await queryOperation.close();

console.table(result);

await session.close();
await databricksClient.close();

Execute Insert

Execute insert
const session = await databricksClient.openSession();

const createTableOperation = await session.executeStatement(
'CREATE TABLE IF NOT EXISTS pokes (foo INT, bar STRING)',
);
await createTableOperation.fetchAll();
await createTableOperation.close();

await session.close();
await databricksClient.close();