-
Notifications
You must be signed in to change notification settings - Fork 2
feat: introduce Lakebase Autoscaling driver #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pkosiec
wants to merge
9
commits into
main
Choose a base branch
from
pkosiec/lakebase-v2-driver-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,505
−146
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
093037b
feat(appkit): introduce Lakebase Autoscaling driver
pkosiec c9654c6
chore: cleanup code
pkosiec afd8982
chore: remove unused stuff
pkosiec 7b14aaf
fix: bring back using DATABRICKS_CLIENT_ID as user
pkosiec 2ba1a30
chore: fix test mock
pkosiec c893af6
chore: extract Lakebase driver as a separate package
pkosiec 374583c
chore: regenerate docs after rebase
pkosiec 40b6c1b
fix: include `@opentelemetry/api` in the packages
pkosiec 62aecae
feat: add default logger configuration
pkosiec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Release @databricks/lakebase | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry-run: | ||
| description: "Dry run (no actual release)" | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: | ||
| group: databricks-protected-runner-group | ||
| labels: linux-ubuntu-latest | ||
|
|
||
| environment: release | ||
|
|
||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup Git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: "pnpm" | ||
|
|
||
| - name: Update npm | ||
| run: npm install -g npm@latest | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Release | ||
| working-directory: packages/lakebase | ||
| run: | | ||
| if [ "${{ inputs.dry-run }}" == "true" ]; then | ||
| pnpm release:dry | ||
| else | ||
| pnpm release:ci | ||
| fi | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
docs/docs/api/appkit/Enumeration.RequestedClaimsPermissionSet.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Enumeration: RequestedClaimsPermissionSet | ||
|
|
||
| Permission set for Unity Catalog table access | ||
|
|
||
| ## Enumeration Members | ||
|
|
||
| ### READ\_ONLY | ||
|
|
||
| ```ts | ||
| READ_ONLY: "READ_ONLY"; | ||
| ``` | ||
|
|
||
| Read-only access to specified UC tables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Function: createLakebasePool() | ||
|
|
||
| ```ts | ||
| function createLakebasePool(config?: Partial<LakebasePoolConfig>): Pool; | ||
| ``` | ||
|
|
||
| Create a Lakebase pool with appkit's logger integration. | ||
| Telemetry automatically uses appkit's OpenTelemetry configuration via global registry. | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `config?` | `Partial`\<[`LakebasePoolConfig`](Interface.LakebasePoolConfig.md)\> | Lakebase pool configuration | | ||
|
|
||
| ## Returns | ||
|
|
||
| `Pool` | ||
|
|
||
| PostgreSQL pool with appkit integration |
55 changes: 55 additions & 0 deletions
55
docs/docs/api/appkit/Function.generateDatabaseCredential.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Function: generateDatabaseCredential() | ||
|
|
||
| ```ts | ||
| function generateDatabaseCredential(workspaceClient: WorkspaceClient, request: GenerateDatabaseCredentialRequest): Promise<DatabaseCredential>; | ||
| ``` | ||
|
|
||
| Generate OAuth credentials for Postgres database connection using the proper Postgres API. | ||
|
|
||
| This generates a time-limited OAuth token (expires after 1 hour) that can be used | ||
| as a password when connecting to Lakebase Postgres databases. | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `workspaceClient` | `WorkspaceClient` | Databricks workspace client for authentication | | ||
| | `request` | [`GenerateDatabaseCredentialRequest`](Interface.GenerateDatabaseCredentialRequest.md) | Request parameters including endpoint path and optional UC claims | | ||
|
|
||
| ## Returns | ||
|
|
||
| `Promise`\<[`DatabaseCredential`](Interface.DatabaseCredential.md)\> | ||
|
|
||
| Database credentials with OAuth token and expiration time | ||
|
|
||
| ## See | ||
|
|
||
| https://docs.databricks.com/aws/en/oltp/projects/authentication | ||
|
|
||
| ## Examples | ||
|
|
||
| ```typescript | ||
| // Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id} | ||
| // Note: Use actual IDs from Databricks (project-id is a UUID) | ||
| const credential = await generateDatabaseCredential(workspaceClient, { | ||
| endpoint: "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0" | ||
| }); | ||
|
|
||
| // Use credential.token as password | ||
| const conn = await pg.connect({ | ||
| host: "ep-abc123.database.us-east-1.databricks.com", | ||
| user: "user@example.com", | ||
| password: credential.token | ||
| }); | ||
| ``` | ||
|
|
||
| ```typescript | ||
| // Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id} | ||
| const credential = await generateDatabaseCredential(workspaceClient, { | ||
| endpoint: "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0", | ||
| claims: [{ | ||
| permission_set: RequestedClaimsPermissionSet.READ_ONLY, | ||
| resources: [{ table_name: "catalog.schema.users" }] | ||
| }] | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Function: getLakebaseOrmConfig() | ||
|
|
||
| ```ts | ||
| function getLakebaseOrmConfig(config?: Partial<LakebasePoolConfig>): { | ||
| password: string | () => string | () => Promise<string> | undefined; | ||
| ssl: | boolean | ||
| | { | ||
| rejectUnauthorized: boolean | undefined; | ||
| }; | ||
| username: string | undefined; | ||
| }; | ||
| ``` | ||
|
|
||
| Get Lakebase connection configuration for ORMs that don't accept pg.Pool directly. | ||
|
|
||
| Designed for ORMs like TypeORM and Sequelize that need connection parameters | ||
| rather than a pre-configured pool instance. | ||
|
|
||
| Returns connection config with field names compatible with common ORMs: | ||
| - `username` instead of `user` | ||
| - Simplified SSL config | ||
| - Password callback support for OAuth token refresh | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `config?` | `Partial`\<[`LakebasePoolConfig`](Interface.LakebasePoolConfig.md)\> | Optional configuration (reads from environment if not provided) | | ||
|
|
||
| ## Returns | ||
|
|
||
| ```ts | ||
| { | ||
| password: string | () => string | () => Promise<string> | undefined; | ||
| ssl: | boolean | ||
| | { | ||
| rejectUnauthorized: boolean | undefined; | ||
| }; | ||
| username: string | undefined; | ||
| } | ||
| ``` | ||
|
|
||
| ORM-compatible connection configuration | ||
|
|
||
| ### password | ||
|
|
||
| ```ts | ||
| password: string | () => string | () => Promise<string> | undefined; | ||
| ``` | ||
|
|
||
| ### ssl | ||
|
|
||
| ```ts | ||
| ssl: | ||
| | boolean | ||
| | { | ||
| rejectUnauthorized: boolean | undefined; | ||
| }; | ||
| ``` | ||
|
|
||
| ### username | ||
|
|
||
| ```ts | ||
| username: string | undefined = user; | ||
| ``` | ||
|
|
||
| ## Example | ||
|
|
||
| ```typescript | ||
| // TypeORM | ||
| const dataSource = new DataSource({ | ||
| type: 'postgres', | ||
| ...getLakebaseOrmConfig(), | ||
| entities: [User], | ||
| synchronize: true, | ||
| }); | ||
|
|
||
| // Sequelize | ||
| const sequelize = new Sequelize({ | ||
| dialect: 'postgres', | ||
| ...getLakebaseOrmConfig(), | ||
| logging: false, | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Function: getLakebasePgConfig() | ||
|
|
||
| ```ts | ||
| function getLakebasePgConfig( | ||
| config?: Partial<LakebasePoolConfig>, | ||
| telemetry?: DriverTelemetry, | ||
| logger?: Logger): PoolConfig; | ||
| ``` | ||
|
|
||
| Get Lakebase connection configuration for PostgreSQL clients. | ||
|
|
||
| Returns pg.PoolConfig with OAuth token authentication configured. | ||
| Best used with pg.Pool directly or ORMs that accept pg.Pool instances (like Drizzle). | ||
|
|
||
| For ORMs that need connection parameters (TypeORM, Sequelize), use getLakebaseOrmConfig() instead. | ||
|
|
||
| Used internally by createLakebasePool(). | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `config?` | `Partial`\<[`LakebasePoolConfig`](Interface.LakebasePoolConfig.md)\> | Optional configuration (reads from environment if not provided) | | ||
| | `telemetry?` | `DriverTelemetry` | Optional pre-initialized telemetry (created internally if not provided) | | ||
| | `logger?` | `Logger` | Optional logger (silent if not provided) | | ||
|
|
||
| ## Returns | ||
|
|
||
| `PoolConfig` | ||
|
|
||
| PostgreSQL pool configuration with OAuth token refresh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Function: getWorkspaceClient() | ||
|
|
||
| ```ts | ||
| function getWorkspaceClient(config: Partial<LakebasePoolConfig>): Promise<WorkspaceClient>; | ||
| ``` | ||
|
|
||
| Get workspace client from config or SDK default auth chain | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `config` | `Partial`\<[`LakebasePoolConfig`](Interface.LakebasePoolConfig.md)\> | | ||
|
|
||
| ## Returns | ||
|
|
||
| `Promise`\<`WorkspaceClient`\> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Interface: DatabaseCredential | ||
|
|
||
| Database credentials with OAuth token for Postgres connection | ||
|
|
||
| ## Properties | ||
|
|
||
| ### expire\_time | ||
|
|
||
| ```ts | ||
| expire_time: string; | ||
| ``` | ||
|
|
||
| Token expiration time in UTC (ISO 8601 format) | ||
| Tokens expire after 1 hour from generation | ||
|
|
||
| #### Example | ||
|
|
||
| ```ts | ||
| "2026-02-06T17:07:00Z" | ||
| ``` | ||
|
|
||
| *** | ||
|
|
||
| ### token | ||
|
|
||
| ```ts | ||
| token: string; | ||
| ``` | ||
|
|
||
| OAuth token to use as the password when connecting to Postgres |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping the workflow dispatch as it won't be triggered automatically anyway for now 👍 Later we'll add on main push trigger