0% found this document useful (0 votes)
57 views58 pages

Snowflake

This document provides a comprehensive overview of Snowflake, a cloud-based data warehousing platform, detailing its advantages over traditional data warehouses, account types, and warehouse sizing. It covers essential topics such as data loading, creating users and roles, and managing data through various Snowflake menus. Additionally, it includes practical steps for setting up a Snowflake account and utilizing its features for data management and analysis.

Uploaded by

New king India
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views58 pages

Snowflake

This document provides a comprehensive overview of Snowflake, a cloud-based data warehousing platform, detailing its advantages over traditional data warehouses, account types, and warehouse sizing. It covers essential topics such as data loading, creating users and roles, and managing data through various Snowflake menus. Additionally, it includes practical steps for setting up a Snowflake account and utilizing its features for data management and analysis.

Uploaded by

New king India
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

snowflake

Basics To Intermediate

Sathish Vadivel

Data Engineer

[email protected]
https://bit.ly/4mcoVP3
Topics Covered
What is Snowflake
Why Snowflake
Uses of Snowflak
Cloud VS Traditional Data
Warehous
Snowflake Account Type
Snowflake Warehouse Siz
Calculate Warehouse Credit and
Amoun
Summary of Data Type
Supported Cloud Region
How to Create Snowflake Accoun
Snowflake Menus in Homepag
Create warehous
Create Use
Create Role
Workshee
Databas
Schem
Table

@Sathish Vadivel
Topics Covered
Creating View Tabl
Load data
Using local file
Internal stag
External stage
Retention Tim
Types of Tabl
Creating variable
Function
Snowflake Shortcut
Useful Tips for Working in Snowflak
Free Courses for Snowflake

@Sathish Vadivel
What is Snowflake?

Snowflake is a cloud-based data


warehousing platform that allows
organizations to store, manage, and analyze
large volumes of data efficiently. It’s built
specifically for the cloud and offers features
that solve many limitations of traditional on-
premise databases and data warehouses.

Why Snowflake
In traditional systems, compute and
storage are tightly coupled, causing
inefficiencies
Snowflake separates them so you can scale
compute (virtual warehouses) up/down
independently of storage
This saves money: pay for compute only
when in use.

@Sathish Vadivel
Uses of Snowflake:
You can query semi-structured data using
SQL without transformation
Data Sharing: Share data across accounts
or organizations without copying it
Time Travel: Access historical data (up to
90 days)
Each team or app can use its own virtual
warehouse, so performance doesn't
degrade
You don’t need to wait for others’ queries to
finish
Decoupled architecture lets you manage
and pay for storage and compute
independently.
Use Streams + Tasks to build incremental,
automated ELT pipelines inside Snowflake
Easily integrates with tools like Tableau,
Power BI, dbt, Airflow, and Python ML
libraries.

@Sathish Vadivel
Cloud Data Warehouse vs Traditional
Data Warehouse :-

@Sathish Vadivel
Snowflake Account Types
Comparison Table :-

@Sathish Vadivel
Snowflake Virtual Warehouse Sizes
Table :-

@Sathish Vadivel
Basic Formula to Calculate
Warehouse Credit and Amount :-

Credits used = (Running time in minutes / 60) ×

Credit rate per hour

For Example,

Let’s say
You use a Small warehouse (2 credits/hour
It runs for 22 minutes

Then ,

Credits = (22 / 60) × 2

= 0.733 × 2

= 1.466 credits

If your price per credit is $3 and you use 1.47


credits, then:

Cost = 1.47 × $3 = $4.41

@Sathish Vadivel
Summary of data types :-

@Sathish Vadivel
Summary of data types :-

@Sathish Vadivel
Supported Cloud Regions :-

Available Cloud region in INDIA :-

@Sathish Vadivel
Step-by-Step:

How to Create a Snowflake Account:-

Step 1: Visit the Signup Page

Go to https://signup.snowflake.com

Step 2:

Fill the Signup Form Enter the following


First Nam
Last Nam
Email Addres
Company Nam
Phone Number (optional
Country/Region (e.g., India
Click “Continue”

Step 3:

Choose Your Cloud Provider & Regio


Select a Cloud Platform: AWS, Azure, or GC
Select the Region: e.g., Asia Pacific (India)
for AWS or Central India (Pune) for Azur
Click “Get Started”
@Sathish Vadivel
Step 4:

Verify Your Emai


Check your email inbox for a verification
link from Snowflak
Click the link to activate your account

Step 5:

Set Up Your Logi


Create a username and passwor
Accept the terms and condition
Click “Create Account”

Step 6:

Log In to Snowflake Web U


After setup, you’ll be redirected to the
Snowflake Web Interfac
Log in using your new credential
Start to explore the snowflake from
homepage.

@Sathish Vadivel
Menus on the Snowflake homepage :
Home
Search
Projects
Data
Data Products
AI & ML
Monitoring
Admin

Home :-

Overview: Your personalized Snowflake landing


page.

What you see


Recently accessed objects (like databases,
worksheets
Sample querie
Quick links to tutorials or documentation

Purpose: Acts as your dashboard or starting


point for all Snowflake activity.

@Sathish Vadivel
Search :-

Overview: A powerful global search across


your Snowflake environment.

What you can search:

Databases, schemas, tables, views, stored


procedures, users, roles, etc.

Purpose: Quickly locate any object or user


without navigating manually.

Projects :-

Overview: Interface to manage Snowpark


projects and workloads.

It contains 5 sub-menus
Worksheets
Notebooks
Streamlit
Dashboards
App Packages

@Sathish Vadivel
Worksheets →Write and run SQL queries
Notebooks →Interactive Python + SQL
notebooks
Streamlit →Build Python-based interactive
apps
Dashboards →Visualize SQL data in charts
and tables
App Packages →Build and distribute
complete data apps.

Data :-

Overview: Central location to browse and


manage all your data assets.

It contains 3 sub-menus
Database
Add Dat
Migration

Databases →Browse and manage


Snowflake databases.

@Sathish Vadivel
Add Data →Load new data into Snowflake
from files or external sources
Migrations →Plan and execute migrations
from other systems/databases.

Data Products :-

Overview: Access and manage data sharing


and Snowflake Marketplace.

It contains 5 sub-menus
Marketplac
App
Private Sharin
Provider Studi
Partner Connec

Marketplace →Discover and subscribe to


3rd-party data and apps
Apps →View, manage, and run Snowflake
Native Apps.

@Sathish Vadivel
Private Sharing →Share data securely with
other Snowflake account
Provider Studio →Publish and manage your
own data or app
Partner Connect →Connect Snowflake to
partner tools for ETL, BI, ML, etc.

AI & ML :-

Overview: Tools and integrations for machine


learning and AI development.

It contains 6 sub-menus
Studi
Cortex Searc
Feature
Model
Evaluation
Document A

Studio →Build ML workflows visually or


with code.

@Sathish Vadivel
Cortex Search →Perform semantic/vector
search
Features →Manage ML feature sets across
models
Models →Train, register, and run ML
models in Snowflake
Evaluations →Compare model performance
and metrics
Document AI →Extract structured data
from unstructured documents.

Monitoring :-

Overview: View system usage and


performance.

It contains 7 sub-menus
Query Histor
Copy Histor
Task Histor
Dynamic Table
Traces & Log
Trust Cente
Governance
@Sathish Vadivel
Query History →View past SQL queries and
their performanc
Copy History →Track data loads from files/
clou
Task History →Monitor scheduled tasks
and workflow
Dynamic Tables →View refresh status of
dynamic (live) table
Traces & Logs →Debug advanced code
execution like Snowpark or UDF
Trust Center →Access service status,
compliance, and security inf
Governance →Monitor data policies,
masking, roles, classifications

Admin :-

Overview: User, role, security, and account


management.

It contains 8 sub-menus
Cost Managemen
Warehouses

@Sathish Vadivel
Compute Pools
Users & Roles
Accounts
Security
Contacts
Billing & Term

Cost Management →Track credit usage,


forecasts, and set cost alert
Warehouses →Manage compute resource
Compute Pools →Run and monitor
Snowpark container
Users & Roles →Manage users and role-
based acces
Accounts →Administer multiple Snowflake
accounts (org-level
Security →Configure login, network, and
session policie
Contacts →Maintain billing and alert
contact
Billing & Terms →Check billing history,
terms, and credits left

@Sathish Vadivel
Create Warehouse :-

Using SQL Query,

Using UI,

Navigate to the Admin tab in the Snowflake


interface, then click on the Warehouses option in the
submenu.

@Sathish Vadivel
Next, click the + Warehouse button located at
the top-right corner of the interface.

Provide a name for the warehouse, and then


choose the warehouse type.

@Sathish Vadivel
Then, select the warehouse size.

Finally, click the Create Warehouse button


to create the warehouse.

@Sathish Vadivel
Create user :-

Using SQL Query,

Simple way to create user

Creating the user by providing all the required


details.

We can also create the user without providing


some of this details.
@Sathish Vadivel
Using UI,

Navigate to the Admin tab in the Snowflake


interface, then click on the Users & Roles
option in the submenu.

Next, click the + User button located at the top-


right corner of the interface.

@Sathish Vadivel
By providing the basic details such as User
Name, Email, Password and Confirm password,
we can create a new user.

Additionally, we can provide extra details


to fully configure the user.

@Sathish Vadivel
Create Roles :-

Using SQL Query,

Simple way to create Role

Using UI,

By clicking the Roles menu at the top of the


page, you can navigate to the Roles page.

@Sathish Vadivel
Next, click the + Role button located at the top-
right corner of the interface.

Enter the name, select the role, and then click the
'Create Role' button to create the role.

@Sathish Vadivel
Creating the Worksheet:-

First, navigate to the Projects tab in the


Snowflake interface, then click on the
Worksheets option in the sub-menu.

Click the + button in the top-right corner to


create an SQL worksheet, Python worksheet, or
folder.

@Sathish Vadivel
After clicking on SQL Worksheet, you will be
redirected to a page like this.

@Sathish Vadivel
You can rename the worksheet in two ways by
clicking the three dots. You can also duplicate,
delete, or move the worksheet to a folder.

@Sathish Vadivel
Creating the Database :-

Creating the Schema :-

@Sathish Vadivel
Creating the table :-

When a database is created, two schemas—


INFORMATION_SCHEMA and PUBLIC are
automatically generated by default.

INFORMATION_SCHEMA →Provides read-only


metadata about database objects such as
tables, views, columns, users, and privileges.

PUBLIC → A default user-defined schema


provided for convenience. It's a general-purpose
space for creating tables, views, functions, etc.
@Sathish Vadivel
structure of Database :-

By clicking on the Databases menu on


top, you can view the structure of all available
databases.

Creating view table :-

A view in Snowflake is a virtual table


that simplifies complex queries by
encapsulating SQL logic. It enhances data
security, reusability, and abstraction, allowing
users to access filtered or formatted data
without exposing the underlying tables.
@Sathish Vadivel
Loading the data to the table :-

Navigate to the Data tab in the Snowflake


interface, then click on the Databases option in
the sub-menu.

Next, select the table you want to load data into.


Then, click the "Load Data" button located at the
top-right corner to begin the data upload.

@Sathish Vadivel
After clicking the "Load Data" button, a pop-up
window will appear.

@Sathish Vadivel
You can either drag and drop the file or browse
to select it.

@Sathish Vadivel
After clicking the "Load" button, a success pop-
up window will appear.

@Sathish Vadivel
To use an internal stage, install SnowSQL
locally based on your operating system.

https://www.snowflake.com/en/developers/
downloads/snowsql/

Create the stage in worksheet,

@Sathish Vadivel
Connect SnowSQL to your Snowflake account
using the command line.

After that, upload the file to the stage using


SnowSQL.

Execute this query in the worksheet to load data


from the stage into the table.

@Sathish Vadivel
For an external stage,

We need to set up a storage integration for


the external stage.

Storage Integration in Snowflake refers to


the process of configuring and managing
access to external storage locations, such as
Amazon S3, Azure Blob Storage, or Google
Cloud Storage

Query to create the storage integration for


azure. Here the storage integration name is
my_azure_integration.

@Sathish Vadivel
SQL query to create a stage for Azure cloud
storage with storage integration.

SQL query to copy data from the stage into a


table.

@Sathish Vadivel
Retention Time :-

Time Travel in Snowflake allows you to


query historical data and restore tables,
schemas, or databases to a previous state
within a defined retention period.

The retention time for Time Travel is


typically set at a default of 1 day but can be
increased up to 90 days depending on your
Snowflake account edition and configuration

During this retention period, you can query


past data or restore data to a previous point
in time
Once the retention time is exceeded, the
historical data is no longer accessible and
cannot be queried or restored.

You can run this query to see the retention time


for the particular table.

@Sathish Vadivel
The table's retention period can be extended
for up to 90 days.

We can update the retention time using


this query.

@Sathish Vadivel
Types of Table :-

Snowflake has three types of tables.


Permanent Tabl
Temporary Tabl
Transient Table

1. Permanent Table :-

Persistence: Long-term storage.

Retention Period: Data in permanent tables is


stored persistently and remains until explicitly
deleted or modified.

The retention period for this table can


be adjusted between 0 and 90 days.

2. Temporary Table :-

Persistence: Session-based.

Retention Period: Data in temporary tables is


retained only for the duration of the session.
Once the session ends, the table and its data are
automatically dropped.

The retention period for this table can


be modified from 0 to 1 day.
@Sathish Vadivel
3. Transient Table :-

Persistence: Short-term storage.

Retention Period:
Data in transient tables is retained for a
configurable period, typically up to 7 days.
Unlike permanent tables, data in transient
tables is not retained indefinitely and is
automatically purged after the retention
period
The retention period for this table can be
modified from 0 to 1 day.

Creating Variables :-

We can create a variable that


can be used in the WHERE clause
and also we can run using a SELECT
statement.

syntax:

SET variable_name = value;


@Sathish Vadivel
To check the value of the variable, we can use a
SELECT statement.

This variable can be utilized in WHERE


conditions, such as:

@Sathish Vadivel
Functions :-

Many built-in functions are already


available, and you can view them using the
SHOW FUNCTIONS command.

Creating UDF(User Defined Functions) :-

1.Scalar function: -

Here’s an example of creating a function


in Snowflake.

The function is named as add_numbers,


the language used is SQL, and the return data
type is specified as NUMBER.

@Sathish Vadivel
You can execute this function as follows:

2.Table functions :-

A table function returns a table (or set of


rows) based on input parameters.

Syntax for creating the table function,

@Sathish Vadivel
Snowflake Shortcuts (for MAC):-

@Sathish Vadivel
Useful tips for working in snowflake :
Keyboard Shortcuts :-

After clicking the


"Show Shortcuts"
menu, a popup
window will appear
and display the list
of shortcuts.

@Sathish Vadivel
2.Basic table details :-

Context menu :-

@Sathish Vadivel
Place Name in Editor – Inserts the table
name into the worksheet in the format
database.schema.table
Copy Name – Copies the fully qualified
table name in the format
database.schema.table
Add Columns in Editor – Inserts all column
names of the selected table into the
worksheet
View Definition – Displays the table’s DDL,
including column names and data types
Load Data – Opens options to load data
into the table from a local file or from
internal/external stages

Preview data :-

You can preview the data by selecting the table


name, then clicking the three dots (more
options menu), where you'll find the Preview
Data option.

@Sathish Vadivel
“The popup
window will open
and display the
data of the table”

@Sathish Vadivel
Free Courses for snowflake :

Coursera

Free course without


certificate

Intro to snowflake for Devs,


Data scientists, Data engineers

DataCamp

Free course with certificate

Introduction to Snowflake


@Sathish Vadivel
thank

you!
@Sathish Vadivel

You might also like