Quickstart: Set up a user to query a table


This feature is in Public Preview. Contact your Databricks representative to request access.

This quickstart shows how to add a user, create a SQL endpoint, create a table containing 10 million people records from a Databricks dataset, and configure access to the table for the user. It is required for the SQL Analytics user quickstart.


Step 1: Add a user

  1. Go to the Admin Console.

  2. On the Users tab, click Add User.

  3. Enter the user email ID.

    Add user
  4. Click Send invite.

    Databricks sends a confirmation email with a temporary password. If the user does not receive the confirmation email within 5 minutes, ask the user to check their spam folder.

The user is added to the workspace.

Added user

Although the Workspace access and SQL Analytics checkboxes are not selected, the user inherits these entitlements as a member of the users group, which has the entitlements. Workspace admins can remove the entitlements from the users group and assign them individually to users on the Users page. For information about the SQL Analytics access entitlement, see Manage users and groups.

Step 2: Create and start a SQL endpoint

  1. At the bottom of the sidebar, select App Switcher Icon > App Switcher - SQL Analytics

  2. Click the Endpoints Icon icon in the sidebar.

  3. Click + New SQL Endpoint.

    Create endpoint
  4. In the Name field, enter QS Endpoint.

  5. Click Create.

  6. In the SQL Endpoint Permissions dialog, click the Down Arrow Icon icon. Select the All Users principal and the Can Use permission.

  7. Click Add.

    Add quickstart endpoint
  8. Click Save.

  9. Click the Endpoints Icon icon in the sidebar.

  10. In the Endpoints list, type QS in the filter box.

    View QS endpoint

    The QS Endpoint should display with State Starting Starting. Wait until the State is Running Running.

Step 3: Create a table of 10 million people

  1. Click the Queries Icon icon in the sidebar.

  2. Click + New Query. The query editor displays.

  3. Select the QS Endpoint endpoint.

  4. Paste the following in the query editor:

     CREATE TABLE default.people10m OPTIONS (PATH 'dbfs:/databricks-datasets/learning-spark-v2/people/people-10m.delta')

    This statement creates a Delta table using Delta Lake files stored in Databricks datasets.

  5. Press Ctrl/Cmd + Enter or click the Execute button. The query will return No data was returned.

  6. To refresh the schema, click the Refresh Schema button at the bottom of the schema browser.

  7. Type peo in the text box to the right of the database. The schema browser displays the new table.

    Schema browser

Step 4: Configure access to the default.people10m table

Enable the user you created in Step 1 to access the default.people10m table you created in Step 3. Enter the following queries one by one:

GRANT USAGE ON TABLE default.people10m TO `user@example.com`;

GRANT SELECT ON TABLE default.people10m TO `user@example.com`;

GRANT READ_METADATA on TABLE default.people10m TO `user@example.com`;

SHOW GRANT `user@example.com` ON TABLE default.people10m;

After each query, press Ctrl/Cmd + Enter or click the Execute button. After the last query, it should display:

| Principal        | ActionType    | ObjectType | ObjectKey             |
| user@example.com | READ_METADATA | TABLE      | `default`.`people10m` |
| user@example.com | SELECT        | TABLE      | `default`.`people10m` |
| user@example.com | USAGE         | TABLE      | `default`.`people10m` |