Worksheets and a Simple Example - Part I
1. Worksheets and a Simple Example - Part I
In my opinion, the most efficient way to learn Snowflake is to see the product in action. So in this video, I’m going to upload a SQL Worksheet and start querying data. But be aware, there are other ways to interact with Snowflake - we could use Python Worksheets or even Snowflake-native Notebooks directly from the Snowflake Web UI. For now, I’ll stick with a SQL Worksheet, which will give us a starting point for thinking about Snowflake. In a later video, as we work through the different parts of the Snowflake UI, we’ll begin to see the bigger picture. While I’m sharing my screen and demoing Snowflake in this course, I don’t recommend that you run the same code at the same time. I’m not expecting that. You’ll have plenty of exercises to do in between videos – and don’t worry, I’ll provide all the instructions and code you need to get started, including instructions on how to set up your Snowflake account. Our goal in this video is to start using Snowflake to work with a really cool dataset Snowflake created about a fake food truck company called Tasty Bytes. This fictitious company runs 450 food trucks in many countries – India, Japan, France, Poland and more – and it has huge growth ambitions. This dataset will be our main source of data throughout the course. So let’s get an early taste of what’s in it! Okay, so here we go! What you’re seeing now is the primary browser-based way of interacting with Snowflake. We call it Snowsight, and we’ll do most of our work in Snowsight for this course. Under “Projects” on the left hand side of the screen, I click on “Worksheets.” What we’re looking at now are Snowflake worksheets. If you look at the “Type” column, you’ll see some SQL ones, and some Python ones, plus a folder or two, which will contain – you guessed it – more worksheets. It’s basically worksheet heaven. I’m going to upload a worksheet called “Worksheets and a Simple Example.” I do this by clicking on the three dots on the right hand side of the screen, and selecting “Create Worksheet from SQL File.” Then I select my SQL file, and now the fun starts! And again, don’t worry about doing this yourself. You’ll get access to any instructions or files you need later. What we’re looking at is a SQL worksheet. SQL worksheets let you “[write](https://docs.snowflake.com/en/user-guide/ui-snowsight-worksheets-gs) and run SQL statements, explore and filter query results, and visualize the results.” You can see at the top of this worksheet that there is grayed-out text – These are comments, and when you run the worksheet, these comments don’t do anything. As is standard in SQL, there are two different ways of adding comments – One comments out a whole block by starting with a forward slash and an asterisk, and ending with an asterisk and a forward slash, and everything between those two bookends is a comment. The other comments out a single line by adding two dashes (“--”) in a row. You can play around with deleting the asterisks or the dashes and seeing that the comments change color from being grayed out to being interpreted as regular code. Cool, so now we’re going to do a few things in quick succession to get the data set up so we can query it – and don’t worry, we’ll cover everything we’ve done in more detail later. Right now we’re just doing a few things to get to the point where we have data we can query, and in our video on Stages and Basic ingestion we’ll learn more about what we did to ingest data. So first we set the role – You do this by putting your cursor inside the block of code you want to run. Each block of code is separated by a semicolon. So just put your cursor somewhere before the semicolon, but after the previous semicolon. Then if you’re on a mac, hold command + return to run that block, and if you’re on PC, hold control + enter. You should see a status update on the bottom of the screen that the “statement executed successfully.” To see a list of the hotkeys you can use in a worksheet, you can hold command + shift + the question mark. Make sure to scroll down to see them all. Now I’ll set the warehouse by putting my cursor anywhere in the “USE WAREHOUSE” line, then I’ll type command + enter to run that line because I’m on a Mac. If you’re on a PC, type control + enter. In the video on Virtual Warehouses we’ll talk about why we did this and what effect it had, but for now, we’re trying to get to the point where we can query some data as quickly as possible, and we can’t learn everything all at once. Okay, now I’m going to move a little faster – I’ll use my cursor to highlight all of the code from steps 2 to 4 (inclusive), and I’ll type command + enter to run all of that. We just created a database, schema, and table; we created a stage with data from S3; and we copied data from that stage into our new table. Again, don’t worry about what any of this means – we’ll go over this later. Now comes the triumphant moment – the moment we’ve been building up to: Querying one of our Tasty Bytes food truck tables! Now let’s run the next line of code: SELECT COUNT(*) AS row_count FROM tasty_bytes_sample_data.raw_pos.menu; To see how many rows are in our new table. Looks like there are 100! We just ran our first query! That’s a big deal. In this video we learned about the fictional Tasty Bytes dataset, hopped into Snowsight, loaded a worksheet, and ran a query. Next, we’ll pick up right where we left off and learn more about our data.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.