Snowflake - Loading Semi Structured Data - JSON

Поделиться
HTML-код
  • Опубликовано: 24 дек 2024

Комментарии • 61

  • @charlesa9431
    @charlesa9431 10 месяцев назад +3

    You know what? I have developed a personal likeness for you Janar.... so good and audible!

  • @tanukuwest3119
    @tanukuwest3119 5 месяцев назад +1

    Your way of explaining each and every detail is amazing Sir.People with no knowledge of databases can also understand your videos easily.Thank you so much for your wonderful content.
    Please upload 4-5 project videos using Snowflake.
    I wish you could also make tutorials on DATABRICKS.

  • @VasukiM-sy3ls
    @VasukiM-sy3ls 8 месяцев назад +1

    This is the only video explaining Loading JSON from Azure.Kudos to you.Thanks

  • @swapnagandi1287
    @swapnagandi1287 Год назад +2

    You are just Amazing!!!! The minute details you share feels speechless. Thanks a Zillion!!!

  • @prabhakarreddyk194
    @prabhakarreddyk194 2 года назад +2

    Thank you so much for your detailed explanation.

  • @mounikakaja3902
    @mounikakaja3902 2 года назад +3

    Can you please upload more videos, the content is very useful and explained in a very clear manner with Examples. Thankyou

  • @riyazriyyu936
    @riyazriyyu936 2 года назад +2

    Very well explained ,Kudos!

  • @venkis2072
    @venkis2072 2 года назад +2

    Very nice explanation

  • @rajinikanthgudimalla5454
    @rajinikanthgudimalla5454 2 года назад +3

    Thanks for uploading....keep more for others learning

  • @madhusudhanchinnala1986
    @madhusudhanchinnala1986 Год назад +1

    You are great sir🎉 Thank you.

  • @Pardhu007
    @Pardhu007 2 года назад +2

    This was a good video it will help to others
    Can you make more videos about snowflake like real time scenarios

  • @subashinisevell4439
    @subashinisevell4439 Год назад +2

    Awesome 👍👍

  • @Jubin369
    @Jubin369 2 года назад +3

    Good presentation. Just one suggestion. We are unable to see the result of the queries since it is hidden by your face. If you can turn off the video camera while recording the session, then it would be helpful.

  • @mrjana520
    @mrjana520  2 года назад +1

    -- Processing semi-structured data (Ex.JSON Data)
    --Creating required schemas
    CREATE OR REPLACE SCHEMA JANA_DB.EXTN_STAGES;
    CREATE OR REPLACE SCHEMA JANA_DB.STAGE_TBLS;
    CREATE OR REPLACE SCHEMA JANA_DB.INTG_TBLS;
    --Creating file format object
    CREATE OR REPLACE FILE FORMAT JANA_DB.EXTN_STAGES.FILE_FORMAT_JSON
    TYPE = JSON;
    --Creating stage object
    CREATE OR REPLACE STAGE JANA_DB.EXTN_STAGES.STAGE_JSON
    STORAGE_INTEGRATION = azsf_jana_feb22
    URL = 'azure://optumstagejana22.blob.core.windows.net/datalakejana';
    --Listing files in the stage
    LIST @JANA_DB.EXTN_STAGES.STAGE_JSON;
    --Creating Stage Table to store RAW Data
    CREATE OR REPLACE TABLE JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    (raw_file variant);
    --Copy the RAW data into a Stage Table
    COPY INTO JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    FROM @JANA_DB.EXTN_STAGES.STAGE_JSON
    file_format= JANA_DB.EXTN_STAGES.FILE_FORMAT_JSON
    FILES=('pets_data.json');
    --View RAW table data
    SELECT * FROM JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW;
    --Extracting single column
    SELECT raw_file:Name::string as Name FROM JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW;
    --Extracting Array data
    SELECT raw_file:Name::string as Name,
    raw_file:Pets[0]::string as Pet
    FROM JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW;
    --Get the size of ARRAY
    SELECT max(ARRAY_SIZE(RAW_FILE:Pets)) as PETS_AR_SIZE
    FROM JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW;
    --Extracting nested data
    SELECT raw_file:Name::string as Name,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State
    FROM JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW;
    --Parsing entire file
    SELECT raw_file:Name::string as Name,
    raw_file:Gender::string as Gender,
    raw_file:DOB::date as DOB,
    raw_file:Pets[0]::string as Pets,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State,
    raw_file:Phone.Work::number as Work_Phone,
    raw_file:Phone.Mobile::number as Mobile_Phone
    from JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    UNION ALL
    SELECT raw_file:Name::string as Name,
    raw_file:Gender::string as Gender,
    raw_file:DOB::date as DOB,
    raw_file:Pets[1]::string as Pets,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State,
    raw_file:Phone.Work::number as Work_Phone,
    raw_file:Phone.Mobile::number as Mobile_Phone
    from JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    UNION ALL
    SELECT raw_file:Name::string as Name,
    raw_file:Gender::string as Gender,
    raw_file:DOB::date as DOB,
    raw_file:Pets[2]::string as Pets,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State,
    raw_file:Phone.Work::number as Work_Phone,
    raw_file:Phone.Mobile::number as Mobile_Phone
    from JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    WHERE Pets is not null;
    --Creating/Loading parsed data to another table
    CREATE TABLE JANA_DB.INTG_TBLS.PETS_DATA
    AS
    SELECT raw_file:Name::string as Name,
    raw_file:Gender::string as Gender,
    raw_file:DOB::date as DOB,
    raw_file:Pets[0]::string as Pets,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State,
    raw_file:Phone.Work::number as Work_Phone,
    raw_file:Phone.Mobile::number as Mobile_Phone
    from JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    UNION ALL
    SELECT raw_file:Name::string as Name,
    raw_file:Gender::string as Gender,
    raw_file:DOB::date as DOB,
    raw_file:Pets[1]::string as Pets,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State,
    raw_file:Phone.Work::number as Work_Phone,
    raw_file:Phone.Mobile::number as Mobile_Phone
    from JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    UNION ALL
    SELECT raw_file:Name::string as Name,
    raw_file:Gender::string as Gender,
    raw_file:DOB::date as DOB,
    raw_file:Pets[2]::string as Pets,
    raw_file:Address."House Number"::string as House_No,
    raw_file:Address.City::string as City,
    raw_file:Address.State::string as State,
    raw_file:Phone.Work::number as Work_Phone,
    raw_file:Phone.Mobile::number as Mobile_Phone
    from JANA_DB.STAGE_TBLS.PETS_DATA_JSON_RAW
    WHERE Pets is not null;
    --Viewing final data
    SELECT * from JANA_DB.INTG_TBLS.PETS_DATA;

  • @MrErPratikParab
    @MrErPratikParab Год назад +2

    Instead of parsing array index 0 to n-1, (for pet details), can we store array max size in one variable, and Run loop from index 0 to varaible-1 time, and pass value

    • @mrjana520
      @mrjana520  Год назад +1

      No need to parse entire array, we can easily do with Flatten approach.
      I didn't cover flatten approach in this video.
      Please look at the Description of the video for code with flatten approach.

  • @MrVenkatesh69
    @MrVenkatesh69 5 месяцев назад

    Hi Sir, If I have to Automate the process to run daily, do I need to create multiple tasks which runs one by one? Do we have any option to create a task flow option which runs one by one?

    • @mrjana520
      @mrjana520  5 месяцев назад

      Go through my Tasks for scheduling video, you will get answer

  • @trumper9298
    @trumper9298 2 года назад +2

    Pls upload plain vedios i.e without adding your face vedio snippet.
    Since most of corner information missing,
    Also looks your are comfortable in explain.

  • @SaiKumarGaddam-g3x
    @SaiKumarGaddam-g3x 6 месяцев назад

    why json support only variant data type in snowflake

    • @mrjana520
      @mrjana520  6 месяцев назад

      To process semi-strucctured data like json, avro, parquet files snowflake has defined a new data type called Variant.

  • @muralikrishna-gk4hx
    @muralikrishna-gk4hx 7 месяцев назад

    Hi sir in my stage i have json file without lading variant column using select how we can read

    • @mrjana520
      @mrjana520  7 месяцев назад

      There is a concept called external table, I have explained in my playlist, pls go through that

  • @kumarevk4195
    @kumarevk4195 Год назад

    Can we have a local variable where we keep a JSON data and load into a temporary table? Instead of having JSON in S3. Please clarify.

    • @mrjana520
      @mrjana520  Год назад

      A local variable can't store large file data and that will be a manual headache..

  • @shaikyusuf4932
    @shaikyusuf4932 Месяц назад

    Hi Sir,
    Can you please attach the Raw data (json) file that would be very help!!.

  • @ushakiran1624
    @ushakiran1624 5 месяцев назад

    HOW TO RECTIFY THIS ERROR
    Object does not exist, or operation cannot be performed.

    • @mrjana520
      @mrjana520  5 месяцев назад

      Mostly the object is not created or the user doesn't have access to perform that operation on that object

  • @satishgunishetty6567
    @satishgunishetty6567 Год назад

    Your videos are very helpful to learn.
    Can you please share the queries also anna.

  • @SaiKumarGaddam-g3x
    @SaiKumarGaddam-g3x 5 месяцев назад

    Hi, can you help me in completing my capstone project

    • @mrjana520
      @mrjana520  5 месяцев назад

      Reach me on jana.snowflake2@gmail.com

  • @nagacnu03
    @nagacnu03 Год назад

    How to make array size dynamic

    • @mrjana520
      @mrjana520  Год назад +1

      There is something called Flatten, I didn't explain in the video but it is available in the queries given in the description, we can process whatever the array size is by using this Flatten

  • @saraneegupta7426
    @saraneegupta7426 Год назад

    If on day1,json contains 100 colums,next day 96..will it throw error while loading into table

    • @mrjana520
      @mrjana520  Год назад

      If those fields are not nullable in the target table then it will throw error otherwsie it will not throw

  • @truecaller-bz8hf
    @truecaller-bz8hf Год назад

    Sir, not able to find Json sample file. plz help me on this

    • @mrjana520
      @mrjana520  Год назад

      I can be reachable on jana.snowflake2@gmail.com

  • @saraneegupta7426
    @saraneegupta7426 Год назад

    Why null is coming from Ravi though there are two pets

    • @mrjana520
      @mrjana520  Год назад

      Please watch the full video and listen carefully, I have explained why null is coming and how to avoid that null record.

  • @ramakrishnatirumala428
    @ramakrishnatirumala428 Год назад

    why you have taken pets[0] unianall pets[1]??/ if there are fifty animals in array .should we use 50 union all?? why dont you iterate each value in array in python or you can write Store procedure . and iterate that pets information....if i am not wrong

    • @mrjana520
      @mrjana520  Год назад

      Go all the way down, see the last query, we can avoid all those union all using FLATTEN function..

  • @masarathunnisa727
    @masarathunnisa727 Год назад

    Sir you did not show , how u created the integration...please show

    • @mrjana520
      @mrjana520  Год назад

      It is there in the other video named Sonwflake-AWS integration, please follow the videos in playlist where i have placed they order wise.

  • @mrjana520
    @mrjana520  2 года назад +1

    {
    "Name": "Ravi",
    "Gender": "Male",
    "DOB": "1990-03-21",
    "Pets": ["Dog", "Cat"],
    "Address": {
    "House Number": "123/4",
    "City": "Hyderabad",
    "State": "Telangana"
    },
    "Phone": {
    "Work": 123456789,
    "Mobile": 987654321
    }
    },
    {
    "Name": "Latha",
    "Gender": "Female",
    "DOB": "1995-04-16",
    "Pets": ["Dog", "Rabbit", "Mouse"],
    "Address": {
    "House Number": "567/8",
    "City": "Bangalore",
    "State": "Karnataka" },
    "Phone": {
    "Work": 112233445,
    "Mobile": 998877665 }
    }

  • @shaikjakeer1347
    @shaikjakeer1347 2 года назад

    Hi sir dicuess about cet concept

    • @mrjana520
      @mrjana520  2 года назад

      What is cet?

    • @shaikjakeer1347
      @shaikjakeer1347 2 года назад

      @@mrjana520 common table expression standard SQL feature sir please share u r number will want to talk

    • @mrjana520
      @mrjana520  2 года назад

      That is CTE not cet. I can be reachable on jana.snowflake2@gmail.com

    • @shaikjakeer1347
      @shaikjakeer1347 2 года назад +1

      @@mrjana520 sorry sir I did spell mistake

  • @PremKumar-wy3mx
    @PremKumar-wy3mx 9 месяцев назад

    Hello sir, Can you please share this pets_data.json file in the description, I have downloaded different sample JSON file from internet but its displaying incorrectly so..

    • @mrjana520
      @mrjana520  9 месяцев назад +1

      reach me on jana.snowflake2@gmail.com

  • @gsk320
    @gsk320 2 года назад +1

    Please provide data in comments

    • @mrjana520
      @mrjana520  2 года назад

      {
      "Name": "Ravi",
      "Gender": "Male",
      "DOB": "1990-03-21",
      "Pets": ["Dog", "Cat"],
      "Address": {
      "House Number": "123/4",
      "City": "Hyderabad",
      "State": "Telangana"
      },
      "Phone": {
      "Work": 123456789,
      "Mobile": 987654321
      }
      },
      {
      "Name": "Latha",
      "Gender": "Female",
      "DOB": "1995-04-16",
      "Pets": ["Dog", "Rabbit", "Mouse"],
      "Address": {
      "House Number": "567/8",
      "City": "Bangalore",
      "State": "Karnataka" },
      "Phone": {
      "Work": 112233445,
      "Mobile": 998877665 }
      }

  • @keerthanr1011
    @keerthanr1011 4 месяца назад

    to parse max array items you skipped, i guess if 1000 items cant be parsed using union all, Please explain that Sir, Thank You

    • @mrjana520
      @mrjana520  4 месяца назад

      Yes, I missed that part, we can handle this using FLATTEN, please check the queries in the description, please check