Create Database


-- the default schema will be where our production data lives
DROP SCHEMA IF EXISTS retail cascade;
DROP SCHEMA IF EXISTS dbt_user cascade;
CREATE SCHEMA retail; -- our raw sample data will go here
CREATE SCHEMA dbt_user; -- our development data will go here
GRANT ALL PRIVILEGES ON SCHEMA retail TO users;
GRANT ALL PRIVILEGES ON SCHEMA dbt_user TO users;
USE SCHEMA retail;

Create Raw Tables


CREATE TABLE retail.customers 
    USING csv 
    OPTIONS (path"/databricks-datasets/retail-org/customers/customers.csv", header "true");
CREATE TABLE retail.loyalty_segments 
    USING csv 
    OPTIONS (path"/databricks-datasets/retail-org/loyalty_segments/loyalty_segment.csv", header "true");
CREATE TABLE retail.sales_orders 
    USING json 
    OPTIONS (path"/databricks-datasets/retail-org/sales_orders/part-00000-tid-1771549084454148016-e2275afd-a5bb-40ed-b044-1774c0fdab2b-105592-1-c000.json", header "true");

Query Raw Tables


SELECT * FROM retail.customers limit 10;
SELECT * FROM retail.loyalty_segments limit 10;
SELECT * FROM retail.sales_orders limit 10;