Data setup
Jump in the shoes of an oil and gas data analyst who is analyzing data about the wells! You'll work with a free dataset from North Dakota Department of Mineral Resources (DMR) that contains information about the wells in the state. Your agent will help you produce valuable insights, and connect with various tools that you need to get the job done.

Are you ready to get started? Let's get you set up with the data first!
Create a warehouse and roles
We'll create a warehouse and a demo role that will be used throughout the tutorial. Run the following SQL commands to create the necessary resources:
USE ROLE SECURITYADMIN;
CREATE ROLE IF NOT EXISTS SEMA4_DEMO_ROLE;
GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE SEMA4_DEMO_ROLE;
GRANT ROLE SEMA4_DEMO_ROLE TO USER <user>;
USE ROLE sysadmin;
-- Create demo database
CREATE OR REPLACE DATABASE OIL_AND_GAS;
-- Create schema
CREATE OR REPLACE SCHEMA OIL_AND_GAS.PUBLIC;
-- Create warehouse
CREATE OR REPLACE WAREHOUSE SEMA4_DEMO_WH
WAREHOUSE_SIZE = 'xsmall'
WAREHOUSE_TYPE = 'standard'
AUTO_SUSPEND = 60
AUTO_RESUME = TRUE
INITIALLY_SUSPENDED = TRUE
COMMENT = 'Warehouse for Sema4.ai Team Edition Preview demo';
GRANT USAGE ON WAREHOUSE SEMA4_DEMO_WH TO ROLE SEMA4_DEMO_ROLE;
GRANT OPERATE ON WAREHOUSE SEMA4_DEMO_WH TO ROLE SEMA4_DEMO_ROLE;
GRANT OWNERSHIP ON SCHEMA OIL_AND_GAS.PUBLIC TO ROLE SEMA4_DEMO_ROLE;
GRANT OWNERSHIP ON DATABASE OIL_AND_GAS TO ROLE SEMA4_DEMO_ROLE;
USE ROLE SEMA4_DEMO_ROLE;
USE WAREHOUSE SEMA4_DEMO_WH;
USE DATABASE OIL_AND_GAS;
USE SCHEMA OIL_AND_GAS.PUBLIC;
-- Create stage for manifest file
CREATE OR REPLACE STAGE cortex_analyst DIRECTORY = (ENABLE = TRUE);
Loading data
Follow these steps to get the data ready for the tutorial:
- Download the dataset zip file
oil-and-gas-data.csv.zip
from here (opens in a new tab) and unzip it to your local machine. - Make sure you are using role
SEMA4_DEMO_ROLE
(left bottom corner in Snowsight) - In Snowsight, click + Create and select Table from File option.

- Drop the unzipped
oil-and-gas-data.csv
file into the Snowsight window. - Choose database
OIL_AND_GAS
and schemaPUBLIC
. - Give a name to your new table, it should be exactly this:
PRODUCTION_REPORTS
.

- Click Next
- Validate that your column mappings look like this:

- Click Load and wait for the table to be created.
- Click Done
Setting up Cortex Analyst
Next, we'll set up the Cortex Analyst semantic model. We have prepared the model file so that you can get started quickly.
- Download the
oil_gas.yaml
file from here (opens in a new tab) and save it to your local machine. - In Snowsight, navigate to Data > Databases.
- Choose
OIL_AND_GAS
database,PUBLIC
schema, and thenCORTEX_ANALYST
Stage. - Click + Files.
- Drop your
oil_gas.yaml
file to the dialog, and click Upload.

Granting access to Team Edition application
When running agent using the Oil & Gas data in Team Edition in Snowflake, you will need to grant the required permissions also to the application. This is not required needed if you only are planning to use Sema4.ai Studio.
First, make sure you have access to the application through one of the roles. Follow instructions in user management section of the documentation.
Then, run following SQL commands to grant application the necessary permissions:
GRANT USAGE ON DATABASE OIL_AND_GAS TO APPLICATION ENTERPRISE_AI_AGENTS_TEAM_EDITION;
GRANT USAGE ON SCHEMA OIL_AND_GAS.PUBLIC TO APPLICATION ENTERPRISE_AI_AGENTS_TEAM_EDITION;
GRANT SELECT ON ALL TABLES IN SCHEMA OIL_AND_GAS.PUBLIC TO APPLICATION ENTERPRISE_AI_AGENTS_TEAM_EDITION;
GRANT USAGE ON ALL STAGES IN SCHEMA OIL_AND_GAS.PUBLIC TO APPLICATION ENTERPRISE_AI_AGENTS_TEAM_EDITION;
GRANT READ ON STAGE OIL_AND_GAS.PUBLIC.CORTEX_ANALYST TO APPLICATION ENTERPRISE_AI_AGENTS_TEAM_EDITION;
GRANT USAGE ON WAREHOUSE SEMA4_DEMO_WH TO APPLICATION ENTERPRISE_AI_AGENTS_TEAM_EDITION;