KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums KX Academy advanced capstone project 1.4

  • advanced capstone project 1.4

    Posted by harshit-raghuvanshi on April 2, 2024 at 6:31 pm

    Hello,

    I was doing advanced capstone project.

    I am unable to understand question 1.4.

    Please help me in this.

    Laura replied 1 week, 3 days ago 2 Members · 15 Replies
  • 15 Replies
  • Laura

    Administrator
    April 3, 2024 at 8:46 am

    Hi @harshit-raghuvanshi ,

    Through completing the previous exercises and creating the .f1.createLapTable function, you should be able to create a table in memory called “lap”, and exercise 1.4 requires you to save this table into your database using .Q.dpft.

    If you’re unsure about how to use this function or would like some practice with partitioned databases, we would recommend you complete the exercises in the Partitioned lesson of the Advanced/Level 3 course (access to the sandbox and exercises is here: Partitioned Tables – KX Learning Hub)

    Hope this helps, please reach out if you need any further assistance!

    Laura

  • harshit-raghuvanshi

    Member
    April 3, 2024 at 9:40 am

    Thank you for your reply Laura,

    for creating lap table it should have data for 2 jan 2020 and also sensorId.

    do we need to create again one table for lap with the help of event and sensor table in which these two are present.

    lap : select from event where date <> first date and session = “P3” giving error.

  • Laura

    Administrator
    April 3, 2024 at 3:16 pm

    Hi @harshit-raghuvanshi ,

    By exercise 1.4, you should have updated the function called .f1.createLapTable which takes two tables as its parameters and does a window join.

    So in order to create your lap table, you need to create two smaller tables from the event and sensor tables for the date specified and then pass those into your .f1.createLapTable function. The table that is output from this function is what you need to save down using .Q.dpft.

    Hope this helps,

    Laura

    • harshit-raghuvanshi

      Member
      April 4, 2024 at 8:21 am

      Hi @Laura

      below in my code snippet,

      event1 : select from event where date <> first date
      
      sensor1 : select from sensor where date <> first date
      
      .f1.createLapTable1:{[eventTab;sensorTab]
      
      distinctSensors: distinct select sensorId from sensorTab;
      
      crosspdt:(select from eventTab) cross distinctSensors;
      
      windows:(crosspdt[`time;crosspdt[`endTime]);
      
      p:wj[windows;`date`sensorId`time;select from crosspdt;(select from sensorTab;avg;`sensorValue))];
      
      }
      lap: .f1.createLapTable1[event1;sensor1]
      show lap
      .Q.dpft[`:/f1;2020.01.02;`sensorId;`lap]

      while running .Q.dpft I am getting mismatched type error

  • Laura

    Administrator
    April 4, 2024 at 9:08 am

    Hi @harshit-raghuvanshi ,

    If you double check the pseudocode for .f1.createLapTable, you’ll see that it needs to return a table, but your function is not returning anything (you just need to add the output of “p”)

    The rest of your code looks fine so once you have the lap table defined in memory,

    you should be able to save it down using .Q.dpft.

    edit: just another note to say that event01 and sensor01 should be passed in to your function like this:

    lap:.f1.createLapTable1[event01;sensor01]

    i.e. not as symbols

    Hope this helps!

    Laura

  • harshit-raghuvanshi

    Member
    April 4, 2024 at 6:10 pm

    Thank you @Laura for your help it is working now.

    After created my lap table successfully I have saved it with the help of .Q.dpft.

    and then I run below code snippet for exercise 1.5

    .Q.chk[`:f1]

    but when I run test cases, some of them are failing. I have attached one photo of my console.

  • Laura

    Administrator
    April 5, 2024 at 10:22 am

    Hi @harshit-raghuvanshi ,

    Can you show me the output of

    get hsym `$getenv[`AX_WORKSPACE],"/f1"

    after you have run .Q.dpft.

    It should look like the attached image. The issue could be if you ran

    .Q.dpft[`:f1; 2020.01.02; `sensorId; `lap]

    while you were already in the f1 directory. This will mean you have created another f1 directory inside the original.

    The solution will be to check the directory you are in and remove the f1/f1 directory if it has been created.

    Then you can run .Q.dpft again like this:

    .Q.dpft[`:.; 2020.01.02; `sensorId; `lap]

    And then

    .Q.chk[`:.]
    
    

    Let me know how you get on,

    Laura

  • harshit-raghuvanshi

    Member
    April 5, 2024 at 1:48 pm

    Hi @Laura

    .Q.dpft[`:.;2020.01.02;`sensorId;`lap];

    I am running the above line of code and after that the below one

    get hsym `$getenv[`AX_WORKSPACE],"/f1"

    and I am getting this as shown in attached image

  • Laura

    Administrator
    April 5, 2024 at 2:15 pm

    You can use the system keyword to remove the erroneous f1.

    You should only have the sym file and your two date partitions in your database.

    Then you can use .Q.chk to fill the table in the other date partition

    Hope this helps,

    Laura

  • harshit-raghuvanshi

    Member
    April 5, 2024 at 6:15 pm

    Hi @Laura I was trying it again and got some test cases pass except 2.

    I have attached the output of both console test cases and below code

    get hsym $getenv[AX_WORKSPACE],”/f1″

  • Laura

    Administrator
    April 10, 2024 at 10:42 am

    Hi @harshit-raghuvanshi ,

    I can see from your screenshots that you still have a directory called “f1” within your HDB that shouldn’t be there. I would recommend deleting this as I’ve mentioned above and seeing if that resolves your issue.

    Calling

    get hsym `$getenv[`AX_WORKSPACE],"/f1"

    should only show the two dates and the sym file, as in the attached image.

    Hope this helps,

    Laura

    • This reply was modified 1 month, 1 week ago by  Laura.
    • This reply was modified 1 month, 1 week ago by  Laura.
    • This reply was modified 1 month, 1 week ago by  Laura.
    • This reply was modified 1 month, 1 week ago by  Laura.
    • harshit-raghuvanshi

      Member
      April 12, 2024 at 8:47 am

      Hi @laura ,

      Thank you for your support , I have cleared it.

      • harshit-raghuvanshi

        Member
        May 13, 2024 at 7:49 am

        hi @laura

        me and my team is waiting for their respective certification.

        is there any kind of glitch. Please let me know.

        Thank you

  • Laura

    Administrator
    May 13, 2024 at 8:51 am

    Hi @harshit-raghuvanshi ,

    I can see that passcodes have now been sent out to you and several of your colleagues for the KDB courses.

    If there are any outstanding certificates let me know, you can email me directly at communitymanager@kx.com.

    Thanks,

    Laura

Log in to reply.