Skip to main content
Table of Contents
< All Topics
Print

Autoscaling Lakebase Usage

Autoscaling Lakebases are useful data storage tools that can be utilized in many ways within your VDAB applications. This page will guide you through the steps to add an Autoscaling Lakebase to a VDAB application so that it can be used.

Autoscaling Lakebase as a Resource

In order to utilize the data stored within an Autoscaling Lakebase, you must first add it as a resource to a VDAB app. To do this, enter the app’s settings page, and click the Resources tab.

  1. Select Edit, choose Autoscaling Lakebase as resource type, then click + Add resource
  2. Fill in all of the fields: Lakebase Project Name, Branch UID, and Database
  3. Select Save resources, then save the App

Data Component Binding

Now that the app has access to an Autoscaling Lakebase, you can set that Lakebase as a data binding for specific data components such as Data Windows or Charts. Add one of the following components to your app:

  • Data Window
  • Editable Data Window
  • Bar Chart
  • Line Chart
  • Pie Chart
  • Donut Chart

Next, you will have to add the binding to this component:

  1. Open the component’s settings and add a new Binding
  2. Select Autoscaling Lakebase and set the following: Lakebase Project Name, Branch UID, Database, Schema, and Table
  3. Save and Deploy the App

Now, the Lakebase should be added as a VDAB app resource and as a binding for the selected data component. However, there is one more step that must be completed to fully allow the data to be displayed or used by the VDAB application.

Databricks Autoscaling Lakebase Permissions

This section explains how to grant Lakebase permissions for a Databricks App that uses an Autoscaling Lakebase database as a resource and/or data component binding. When a Databricks App connects to Lakebase, the database grants must be applied to the Postgres role used by the running app.

Use the app environment runtime PGUSER value as the role name in these SQL grants.

Run the following SQL grants in Databricks SQL editor connected to the Autoscaling Lakebase you are using as a resource or data binding. Choose the permission section below that corresponds with the scope or restrictions you want for your Lakebase.

1. Minimum Read Access For One Table

Use this when the app only needs to read a single table.

GRANT CONNECT ON DATABASE <database_name> TO <PGUSER>;

GRANT USAGE ON SCHEMA <schema_name> TO <PGUSER>;
GRANT SELECT ON TABLE <schema_name>.<table_name> TO <PGUSER>;
  • CONNECT allows the app to connect to the database <database_name>
  • USAGE ON SCHEMA allows the app to access objects inside the schema <schema_name>
  • SELECT ON TABLE allows reading the specific table at <schema_name>.<table_name>

2.1 Read Access For All Current Tables In A Schema

Use this when the app should be able to read all existing tables in one schema.

GRANT CONNECT ON DATABASE <database_name> TO <PGUSER>;

GRANT USAGE ON SCHEMA <schema_name> TO <PGUSER>;
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name>TO <PGUSER>;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA <schema_name> TO <PGUSER>;
  • Grants read access to all current tables in <schema_name>
  • Grants sequence access needed when tables use identity/serial-backed columns

2.2 Read Access For Future Tables In A Schema

Use this together with section 2.1 if new tables will be created later and the app should keep working without manual re-grants.

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name>
GRANT SELECT ON TABLES TO <PGUSER>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name>
GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO <PGUSER>;
  • Automatically grants read access to future tables created in the schema
  • Automatically grants sequence access for future tables

3. Broad Read/Write Access For A Schema

Use this when the app needs to read and modify data in the schema.

GRANT CONNECT ON DATABASE <database_name> TO <PGUSER>;
GRANT USAGE, CREATE ON SCHEMA <schema_name> TO <PGUSER>;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA <schema_name> TO <PGUSER>;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA <schema_name> TO <PGUSER>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name>
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO <PGUSER>;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name>
GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO <PGUSER>;
  • Allows reading and modifying all current tables in the schema
  • Allows future tables and sequences in that schema to inherit the same permissions
  • Includes CREATE ON SCHEMA so the app can create objects in that schema if needed

Overall Setup Steps

  1. Add the Autoscaling Lakebase resource to the Databricks App.
  2. Determine the app runtime Postgres role from PGUSER.
  3. Grant database, schema, table, and sequence permissions to that role.
  4. Add a Data Component to VDAB app.
  5. Set the Autoscaling Lakebase as Data Component’s binding.
  6. Redeploy the app after the grants are in place.
  7. Test the deployed app against the target schema and table.