Skip to main content

Databricks

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

Credential configuration

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

  • Your Databricks personal access token, that 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 path, that 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 you have 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 ${1:databricksClient} = yepcode.integration.databricks("${2:credential-slug}");
New integration from plain authentication data
const { DBSQLClient } = require('@databricks/sql');

const ${1:databricksClient} = new DBSQLClient();

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

Execute query

Execute query
const session = await ${1: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 ${1:databricksClient}.close();

Execute insert

Execute insert
const session = await ${1: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 ${1:databricksClient}.close();