Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      A Week In The Life Of An AI-Augmented Designer

      August 22, 2025

      This week in AI updates: Gemini Code Assist Agent Mode, GitHub’s Agents panel, and more (August 22, 2025)

      August 22, 2025

      Microsoft adds Copilot-powered debugging features for .NET in Visual Studio

      August 21, 2025

      Blackstone portfolio company R Systems Acquires Novigo Solutions, Strengthening its Product Engineering and Full-Stack Agentic-AI Capabilities

      August 21, 2025

      I found the ultimate MacBook Air alternative for Windows users – and it’s priced well

      August 23, 2025

      Outdated IT help desks are holding businesses back – but there is a solution

      August 23, 2025

      Android’s latest update can force apps into dark mode – how to see it now

      August 23, 2025

      I tried the Google Pixel Watch 4 – and these key features made it feel indispensable

      August 23, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Building Cross-Platform Alerts with Laravel’s Notification Framework

      August 23, 2025
      Recent

      Building Cross-Platform Alerts with Laravel’s Notification Framework

      August 23, 2025

      Add Notes Functionality to Eloquent Models With the Notable Package

      August 23, 2025

      How to install OpenPlatform — IoT platform

      August 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Basics of Digital Forensics

      August 22, 2025
      Recent

      Basics of Digital Forensics

      August 22, 2025

      Top Linux Server Automation Tools: Simplifying System Administration

      August 22, 2025

      Rising from the Ashes: How AlmaLinux and Rocky Linux Redefined the Post-CentOS Landscape

      August 22, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Loading JSON Data into Snowflake From Local Directory

    Loading JSON Data into Snowflake From Local Directory

    May 23, 2025

    In today’s world, there are various data formats such as traditional, unstructured, raw format and semi structured data and load into target system. Semi structured data is often used in web applications, IOT and API sensors. Customers use JSON format mostly to get the data because it is easy to understand.
    Snowflake
    Snowflake is a cloud data warehouse that helps to load different data types and format of data. It can automatically scale up/down its computed resources to load integrate data. Snowflakes do not utilize any physical or hardware. Snowflake runs public cloud infrastructure.
    JSON
    JSON is a text-based format that uses key value pair, and it is easily accessible. The syntax is designed to be easy for humans to read and write.

    Why do we use JSON?
    1.Simplicity and Readability:
    JSON syntax is quite simple. It is easy to read as it represents key value
    2.Lightweight:
    It is a text-based format, larger than other formats like XML which can lead to faster data transfer and storage.
    3.Configuration Files:
    Mostly JSON use in config also and it is easily readable format
    4. Data Exchange:
    JSON supports data exchange between different software and systems.
    5. JSON Data Type:
    Snowflake use variant datatype to load JSON data as it is semi structured data

    In this blog, we will use two methods to load JSON data (sales.json) into Snowflake from local directory
    And JSON would like to be:

    {"location": {"state_city": "MA-Lexington","zip": "40503"},"sale_date": "2017-3-5","price": "275836"}
    {"location": {"state_city": "MA-Belmont","zip": "02478"},"sale_date": "2017-3-17","price": "392567"}
    {"location": {"state_city": "MA-Winchester","zip": "01890"},"sale_date": "2017-3-21","price": "389921"}

    1. Direct load JSON data in Snowflake (No Stage involved):
      In Snowflake, we need to create data warehouse, schema and database  to compute the data  as below:
      Picjson1

    And  Snowflake provides facility to load the file directly into table as  it is available in local, follow below steps:
    Picturejson2
    Click on Upload local files
    Picturejson3
    Browse the file which you want to load into the table
    Picturejson4

    Picturejson5

    Click on next
    Picturejson6

    Then load the data into table

    Picturejson8
    Step 2:
    Load JSON data through Internal Stage:

    Internal Stage:
    Internal stage in Snowflake helps to load the data internally. It does not require any cloud integration outside.

    Below are the steps to load the JSON file in internal stage:

    1. Create file format as below:
      Fileformat
    2. Create Stage as below
      Stage
      3.Put file into Stage
      To execute the PUT command in Snow SQL
      Please go through link to install Snow SQL (SnowSQL)
      Add file into stage via PUT command as below:
      PUT syntax as below
      PUT file://path of file @Stage_Name
      PUT file://C:temploadsales.Json @  JSON_DATA_STAGE;
      Once execute the PUT command in Snowflake:
      Put
      To check file load into stage through below query:
      list @LOAD_JSON_DATABASE.LOAD_JSON_SCHEMA.JSON_DATA_STAGE;
      Logs
      Copy data into the target table:

         Directly load into table:

    Table definition as below:

    create or replace TABLE LOAD_JSON_DATABASE.LOAD_JSON_SCHEMA.JSON_DATA (VARIANT_COL                VARIANT);
    Loadtable

    Create table with column names in Snow sight:
    create or replace TABLE LOAD_JSON_DATABASE.LOAD_JSON_SCHEMA.JSON_DATA_SALES (
    city varchar, state varchar,zip varchar, sale_date date,price int);
    Copy data into table:
    Tabled
    Note:

    $1 use to select single column where the JSON stored

    How to retrieve Json data through SELECT query:
    1. Dot and colon Notation:
    As it is JSON in JSON, so it shows result as below:
    Json
    If want to retrieve data as a single column, use below query
    Singlec
    In the above image, get values as in string format but if we want retrieve in actual data type. Use explicitly casting as below query as:
    Actuald
    2.FLATTEN IN JSON:
      Flattening is the process to divide the array or object into the columnar format

    Please go through link to know about FLATTEN(FLATTEN)
    Flatten
    Lateral
    3.GET METHOD:
    We can get values of Json from GET method also and use below query as:
    Get

    Conclusion:
    Snowflake supports different format of data to load into tables and JSON is the basic form of data as today many customers use due to easy to understand and key pair value. To retrieve Json data, Snowflake provides different approaches and if any array or object in JSON, we use flatten and get method. And we can load the data through explicitly casting of values.

     

     

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleStreamline Conditional Logic with Laravel’s Fluent Conditionable Trait
    Next Article A timeline of JavaScript’s history

    Related Posts

    Development

    Building Cross-Platform Alerts with Laravel’s Notification Framework

    August 23, 2025
    Development

    Add Notes Functionality to Eloquent Models With the Notable Package

    August 23, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-30445 – Apple Type Confusion Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    4 ways you can start using gen AI to its full potential

    News & Updates

    CVE-2025-8765 – Datacom DM955 5GT 1200 Wireless Basic Settings Cross Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-6473 – School Fees Payment System Cross-Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-5984 – SourceCodester Online Student Clearance System Cross-Site Scripting Vulnerability

    June 10, 2025

    CVE ID : CVE-2025-5984

    Published : June 10, 2025, 11:15 p.m. | 2 hours, 34 minutes ago

    Description : A vulnerability has been found in SourceCodester Online Student Clearance System 1.0 and classified as problematic. Affected by this vulnerability is an unknown functionality of the file /Admin/add-fee.php. The manipulation of the argument txtamt leads to cross site scripting. The attack can be launched remotely. The exploit has been disclosed to the public and may be used.

    Severity: 3.5 | LOW

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    “Fear not—we are cooking!” Helldivers 2 devs say there’s “exciting news to come” and a new Warbond in May as we defeat the Illuminate, which surely means it’s about to invade for real and kill us all

    April 29, 2025

    CVE-2025-52782 – King Rayhan Scroll UP Cross-site Scripting Vulnerability

    June 20, 2025

    Splunk Enterprise XSS Vulnerability Let Attackers Execute Unauthorized JavaScript Code

    June 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.