111. Databricks | Pyspark| SQL Coding Interview: Exchange Seats of Students

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

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

  • @Manikanta-n5v
    @Manikanta-n5v 10 месяцев назад +3

    Assignment Qn: if below approach is incorrect, pls let me know
    spark.sql("""select id, name,
    case when id=1 then lead(name,3) over(order by id)
    when id=4 then lag(name,3) over(order by id)
    else name
    end as fname
    from
    users""")

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

    Thanks for Sharing the real time scenario,
    Waiting for more information,Keep it going..!!!!!!

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

    Really very informative videos, please upload more. you are explaining in very good manner. Keep it going !!!

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

    Sir, Thanks a lot for your commitment and Please Upload more coding exercise videos , This will be the game changer , Respect to you

  • @GANGAEDIGA
    @GANGAEDIGA 8 месяцев назад +3

    For given exercise:
    exchange_df1 = df.withColumn("ExchageStudent",
    when (col('id')%2==1 , coalesce(lead('name',3).over(Window.orderBy('id')),col('name'))).
    when (col('id')%2==0 , coalesce(lag('name',3).over(Window.orderBy('id')),col('name'))).
    otherwise(col('name'))
    )

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

    Please upload more coding excercise videos they are amazing.
    Really helpful for developing analytical thinking.

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

    Exactly keep uploading more videos like this

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

      Sure, will create more videos on coding exercises after completing delta live table series soon

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

    Hi, do you have these codes put somwhere in the github or anywhere please?

  • @nitishhs5536
    @nitishhs5536 2 месяца назад +1

    with temp as
    (select count(id) as cnt
    from table_a)
    select
    case when table_a.id%2=0 then table_a.id
    when.table_a.id%20 and table_a.id

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

    Thanks for the valuable content.

  • @AnujRastogi-m6v
    @AnujRastogi-m6v Месяц назад

    I Required more sql and pyspark problems for practice is there any paid course you have which i can purchase for practice only

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

    Good explanation Raja . Keep it going .

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

    Keep up the good work. 🙂

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

    Thanks sir u gave the data.
    please keep going sir.
    Please include how to present project infront of interview,manerial round question etc.
    How to handle big data managerial question. how to dominate interview in our ways.

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

    Thank you😮

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

    Thank You ..! Please attach the the notebook

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

    superb!

  • @Munchkin_K
    @Munchkin_K 6 месяцев назад +1

    You speak continuous, need time to grasp 😊

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

    please provide the answer for the exercise

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

    Plz answer the Quiz question.

  • @ShubhamSharma-sy2ce
    @ShubhamSharma-sy2ce 10 месяцев назад +1

    SELECT
    id,
    CASE
    WHEN student = 'Alice' THEN (SELECT student FROM students_view WHERE student = 'David')
    WHEN student = 'David' THEN (SELECT student FROM students_view WHERE student = 'Alice')
    ELSE student
    END as updated_student,
    student
    FROM students_view;

    • @ShubhamSharma-sy2ce
      @ShubhamSharma-sy2ce 10 месяцев назад

      in pyspark: updated_students_view = students_view.withColumn("updated_student",
      when(students_view["student"] == 'Alice',
      students_view.filter(students_view["student"] == 'David')["student"]
      )
      .when(students_view["student"] == 'David',
      students_view.filter(students_view["student"] == 'Alice')["student"]
      )
      .otherwise(students_view["student"])
      )

    • @rajasdataengineering7585
      @rajasdataengineering7585  10 месяцев назад

      Thanks for sharing your approach

    • @snehanangunuri4390
      @snehanangunuri4390 9 дней назад

      directly u can assign david and alice ...u dont have to query student and in where condition u r giving student itself.

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

    Great scenario to practice Thanks for providing. I have been following your channel for Spark, and your explanation for every topic is clean and easy to understand for everyone.
    Here is the code that I practiced, it may help anyone to practice. please let me know of any corrections or suggestions in terms of performance.
    #creating Dataframe
    data=[(1,'Alice'),(2,'Bob'),(3,'Charlie'),(4,'David'),(5,'Eve')]
    df=spark.createDataFrame(data,['id','student'])
    df.show()
    #Pyspark solution
    from pyspark.sql.functions import col,lead,lag,when
    from pyspark.sql.window import *
    df.withColumn('new',when (col('id')%2==0,lag('student').over(Window.orderBy('id'))).\
    when (col('id')%2== 1,coalesce(lead('student').over(Window.orderBy('id')),'student'))).drop('student').show()
    #creating tempview
    df.createOrReplaceTempView('sampl')
    #sql solution
    %sql
    select id,case when id%2=0 then lag(student) over(order by id)
    when id%2=1 then lead(student,1,student) over(order by id) end new from sampl

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

      Thank you! It looks good. Hope it helps data engineers in this community

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

      this code is for the assignment which raja sir has given in the last?