{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Step 1: Prepare Your Databricks Data","description":"Organize your Databricks tables for Composable Audience Studio, including Customers table, Behaviors tables, and Unity Catalog permissions.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"step-1-prepare-your-databricks-data","__idx":0},"children":["Step 1: Prepare Your Databricks Data"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Organize your Databricks tables to match the Parent Segment data model: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["one Customers table and one or more Behaviors tables."]}," Tables should be managed or external tables within a Unity Catalog schema."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"customers-table","__idx":1},"children":["Customers Table"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Customers table is the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["single source of all profile data and attributes."]}," Every column you want to use for segmentation ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["must be in this table."]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Requirement"},"children":["Requirement"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unique key column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A column with ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["unique values per customer"]}," (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_customer_id"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["No duplicate keys"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Each row must represent a unique customer profile"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["All attributes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["All customer properties for segmentation must be columns in this table"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-customers-table","__idx":2},"children":["Example Customers Table"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"cdp_customer_id"},"children":["cdp_customer_id"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"email"},"children":["email"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"first_name"},"children":["first_name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"last_name"},"children":["last_name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"city"},"children":["city"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"country"},"children":["country"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"gender"},"children":["gender"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"membership_tier"},"children":["membership_tier"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"ltv"},"children":["ltv"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"aov"},"children":["aov"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"next_best_channel"},"children":["next_best_channel"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"next_best_offer"},"children":["next_best_offer"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["001"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["alice@example.com"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Alice"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Smith"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tokyo"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JP"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["F"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Gold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5000"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["120"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["email"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["discount_20"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["002"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["bob@example.com"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bob"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Jones"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Osaka"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JP"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["M"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Silver"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2500"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["80"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["push"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["free_shipping"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"behaviors-tables","__idx":3},"children":["Behaviors Tables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each Behaviors table represents a specific type of customer activity. You can define multiple Behaviors tables (e.g., page views, purchases, email clicks)."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Requirement"},"children":["Requirement"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Key column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Must contain a column with the same customer identifier used in the Customers table (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_customer_id"]},") to join the two tables"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Time column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Timestamp column for the event (e.g., ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["time"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Event columns"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Additional columns describing the event details"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-behaviors-table","__idx":4},"children":["Example Behaviors Table"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"cdp_customer_id"},"children":["cdp_customer_id"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"time"},"children":["time"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"td_url"},"children":["td_url"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"td_title"},"children":["td_title"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["001"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2025-11-20 10:30:00"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://example.com/products"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Products Page"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["001"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2025-11-20 11:00:00"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://example.com/cart"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping Cart"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["002"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2025-11-20 12:15:00"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://example.com/sale"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sale Page"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"databricks-permissions","__idx":5},"children":["Databricks Permissions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ensure the service principal you plan to use has the required permissions in Unity Catalog. You can grant these via the Databricks UI (",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Catalog"]}," > select your catalog > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Permissions"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Grant"]},") or via SQL:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"-- Grant usage on the catalog and schema\nGRANT USE CATALOG ON CATALOG <catalog_name> TO `<service_principal_name>`;\nGRANT USE SCHEMA ON SCHEMA <catalog_name>.<schema_name> TO `<service_principal_name>`;\n\n-- Grant SELECT on the Customers table\nGRANT SELECT ON TABLE <catalog_name>.<schema_name>.customers TO `<service_principal_name>`;\n\n-- Grant SELECT on each Behaviors table\nGRANT SELECT ON TABLE <catalog_name>.<schema_name>.behavior_pageviews TO `<service_principal_name>`;\n-- Repeat for each Behaviors table\n\n-- Grant CREATE TABLE on the schema to create and clean up temporary tables during activation\nGRANT CREATE TABLE ON SCHEMA <catalog_name>.<schema_name> TO `<service_principal_name>`;\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Alternatively, use the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Data Reader"]}," privilege preset in the Databricks UI to grant USE CATALOG, USE SCHEMA, EXECUTE, and SELECT permissions at the catalog level. Note that the Data Reader preset does not include ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CREATE TABLE"]},", which is additionally required for running activations and must be granted separately as shown above."]}]},"headings":[{"value":"Step 1: Prepare Your Databricks Data","id":"step-1-prepare-your-databricks-data","depth":1},{"value":"Customers Table","id":"customers-table","depth":2},{"value":"Example Customers Table","id":"example-customers-table","depth":3},{"value":"Behaviors Tables","id":"behaviors-tables","depth":2},{"value":"Example Behaviors Table","id":"example-behaviors-table","depth":3},{"value":"Databricks Permissions","id":"databricks-permissions","depth":2}],"frontmatter":{"seo":{"title":"Step 1: Prepare Your Databricks Data","description":"Organize your Databricks tables for Composable Audience Studio, including Customers table, Behaviors tables, and Unity Catalog permissions."}},"lastModified":"2026-05-23T17:00:18.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/composable-cdp/databricks/prepare-databricks-data","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}