-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathapp.py
More file actions
196 lines (160 loc) Β· 10.2 KB
/
app.py
File metadata and controls
196 lines (160 loc) Β· 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
## IMPORTANT CALL OUT
## ==================
## As you may have noticed, this script can use a lot of refactoring
## and should be broken down into multiple modules for better readability
## and easier maintanance. If you are interested in helping out,
## please open an issue/PR and contribute to the project.
## The community will greatly appreciate your help and contribution!
import streamlit as st
from snowflake_cheatsheet.database import database_segment
from snowflake_cheatsheet.schema import schema_segment
from snowflake_cheatsheet.table import table_segment
from snowflake_cheatsheet.view import view_segment
from snowflake_cheatsheet.materialized_view import materialized_view_segment
from snowflake_cheatsheet.stage import stage_segment
from snowflake_cheatsheet.pipe import pipe_segment
from snowflake_cheatsheet.data_loading import data_loading_segment
from snowflake_cheatsheet.task import task_segment
from snowflake_cheatsheet.stream import stream_segment
from snowflake_cheatsheet.function import function_segment
from snowflake_cheatsheet.procedure import procedure_segment
from snowflake_cheatsheet.dynamic_table import dynamic_table_segment
from snowflake_cheatsheet.alert import alert_segment
from snowflake_cheatsheet.cortex_search import cortex_search_segment
from snowflake_cheatsheet.data_manipulation import data_manipulation_segment
from snowflake_cheatsheet.layout import default_layout
st.set_page_config(page_title='Snowflake', layout='wide',
# initial_sidebar_state=st.session_state.get('sidebar_state', 'collapsed'),
)
st.image("./logo/snowflake_cheatsheet_logo_v2.png", use_container_width=True )
st.snow()
_, exp_col, _ = st.columns([1,3,1])
with exp_col:
with st.expander("**π How to Use This Cheat Sheet**"):
st.markdown("""
However you like! π€·π»
But here's my recommendation:
In a typical Snowflake work session, you might find yourself juggling various commands such as
cloning a database and schema, creating new tables or views, rummaging through files on a stage, keeping tabs on Snowpipe, wrangling data through manual copying, insertion, or updating, etc, etc ... the list is long!
Now, keeping the precise syntax of all these commands at your fingertips, especially for the less-frequently-used ones, can be quite a challenge.
I recommend keeping this cheat sheet open in a tab while you work. This way, you can swiftly refer to the provided code snippets and easily adapt them to your specific tasks.
To keep things streamlit π... sorry, I mean streamlined, I have removed options and arguments that are not frequently used in each command.
However, keep in mind that I have cherry-picked the options based on my personal workflow experience which may not necessarily align with yours.
Within each segment, there's a special treat βοΈ: a bonus section with top tips to elevate your Snowflake skills.
I suggest that whenever you are using a command for the first time, spend a few minutes reading the tips and hopefully pick up something new.
""")
st.info("""
This guide is not intended to be a replacement for the official [Snowflake documentation](https://docs.snowflake.com/) (which is fantastic by the way!).
For a comprehensive reference of objects and methods, make sure to explore the official documentation.
""")
st.markdown("""
If you happen to spot any errors or have suggestions for improving the descriptions or tips, please don't hesitate to reach out to me directly [here](https://www.linkedin.com/in/siavash-yasini/), or open an [issue](https://github.com/syasini/snowflake_cheatsheet/issues/new) on the GitHub page. Your feedback is invaluableβand relied uponβin keeping this guide accurate and useful.
π Don't forget to check the sidebar for additional info and layout options!
Now, go build something awesome on Snowflake! π
""")
st.sidebar.title("βοΈ Snowflake Cheatsheet π")
st.sidebar.caption("Made by an [Ungifted Amateur](https://www.linkedin.com/in/siavash-yasini/)")
st.sidebar.caption("Check out the accompanying Snowflake tutorial [here](https://medium.com/snowflake/the-ungifted-amateurs-guide-to-snowflake-449284e4bd72).")
with st.sidebar.expander("See My Other Streamlit Apps"):
st.caption("streamliTissues: [App](https://tissues.streamlit.app/) π")
st.caption("Sophisticated Palette: [App](https://sophisticated-palette.streamlit.app/) π, [Blog Post](https://blog.streamlit.io/create-a-color-palette-from-any-image/) π")
st.caption("Wordler: [App](https://wordler.streamlit.app/) π, [Blog Post](https://blog.streamlit.io/the-ultimate-wordle-cheat-sheet/) π")
st.caption("Koffee of the World: [App](https://koffee.streamlit.app/) π")
with st.sidebar.expander("βΉοΈ **Latest Snowflake Release Notes**"):
st.markdown("""Stay frosty and keep up with the coolest updates on the Snowflake website [here](https://docs.snowflake.com/en/release-notes/new-features).""")
cols = st.columns(2)
left_column_defaults = [
"π database",
"π schema",
"π table",
"ποΈ view",
"πΈ materialized view",
"π dynamic table",
"π task",
"π stream",
"π¨ alert",
]
right_column_defaults = [
"π§ cortex search",
"π stage",
"π data loading",
"π data manipulation",
"πͺ function",
"πͺ procedure",
"π° pipe",
]
all_segments = left_column_defaults + right_column_defaults
custom_layout = st.sidebar.expander("π§βπ¨ Customize Layout")
with custom_layout:
st.button(
"Default Layout",
on_click=lambda: default_layout(left_column_defaults, right_column_defaults),
)
side_left_col, side_right_col = st.columns(2)
left_col_segments = side_left_col.multiselect("Left Column",
options=all_segments,
default=left_column_defaults,
key="layout_left_column")
right_col_segments = side_right_col.multiselect("Right Column",
options=all_segments,
default=right_column_defaults,
key="layout_right_column")
segment_dict = {
"π database": database_segment,
"π table": table_segment,
"π schema": schema_segment,
"ποΈ view": view_segment,
"πΈ materialized view": materialized_view_segment,
"π stage": stage_segment,
"π° pipe": pipe_segment,
"π data loading": data_loading_segment,
"π task": task_segment,
"π stream": stream_segment,
"πͺ function": function_segment,
"πͺ procedure": procedure_segment,
"π dynamic table": dynamic_table_segment,
"π¨ alert": alert_segment,
"π§ cortex search": cortex_search_segment,
"π data manipulation": data_manipulation_segment,
}
with cols[0]:
for seg in left_col_segments:
segment_dict[seg]()
with cols[1]:
for seg in right_col_segments:
segment_dict[seg]()
# st.header("Clustering")
# st.header("Data Sampling")
# st.header("Time Travel")
# st.header("External Table")
with st.sidebar.expander("πΊ Legend", expanded=True):
st.markdown("""
- Text inside `[ BRACKETS ]` indicates *optional parameters* that can be omitted. Drop carefully!
- Text inside `{ CURLY | BRACKETS }` indicates *available options* for the command. Choose wisely!
- Text inside `< angle.brackets >` indicates *entity names* (e.g. table, schema, etc.). Pick responsibly!
- The [βοΈ](https://docs.snowflake.com/) icon in each section will snow-flake you to the relevant section on the documentation website.
""")
st.sidebar.info("""
Note: This online cheatsheet for Snowflake is based on materials from the [Snowflake documentation website](https://docs.snowflake.com/).
The content and logo of Snowflake used in this application are the intellectual property of Snowflake Inc. and are used here with proper attribution.
This cheatsheet is not affiliated with or endorsed by Snowflake Inc. Please refer to the official Snowflake documentation for detailed information and updates.
"""
)
st.sidebar.success("""
This guide is limited in scope and offers just a glimpse into the expansive array of Snowflake's *cool* featuresβpun intended.
The reason for this is threefold:
1. Time is finite, as suggested by modern physics.
2. Snowflake is breaking the laws of physics by adding features faster than the speed of light, making it impossible for any mortal to catch up.
3. I am a mortal.
But here's where you come in, my knowledgeable friend. You likely have insights, cool features, or corrections that could benefit the entire Snowflake community.
As an open-source project, I warmly (or should I say coolly? π€) welcome and eagerly look forward to your invaluable contribution.
Don't hesitate to jump to the GitHub repository to open an issue or start a pull request (PR) to suggest additions or modifications to the content.
Your expertise can help us keep this guide up-to-date and comprehensive.
"""
)
with st.sidebar.expander("Acknowledgments"):
st.markdown("""
I am incredibly grateful to my amazing Snowflake mentor, [Sang Hai](https://www.linkedin.com/in/sangvhai/), who is always sharing his extensive knowledge about the exciting and innovative features of Snowflake and guiding me in implementing them in my work.
I would also like to express my heartfelt appreciation to [Kathryn Reck Harris](https://www.linkedin.com/in/kathrynreck/) and [Varun Chavakula](https://www.linkedin.com/in/varunchavakula/), my awesome Snowflake buddies, who always share the exhilarating ride of exploring Snowflake and provide invaluable insights and support.
Lastly, a special thanks to [**Jessica Smith**](https://www.linkedin.com/in/jessica-s-095a861b3/), a true champion of the Streamlit platform, for always encouraging me to create fun things in Streamlit and for her continuous support within the vibrant Streamlit community.
""")