KX Community

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

Home Forums KX Academy Advanced Capstone 2.2

  • Advanced Capstone 2.2

    Posted by jeanluck on July 4, 2024 at 9:07 am

    Hi,

    I have a failed test on exercise2.2

    exercise2.2 Fail “contain all columns for 2nd Jan 2020”

    Do you know what is the expected columns? For which table?

    In the instruction, with the sample output, I understood that there should be these columns in lapTable table:

    lapTable: date, sensorId, session, lapId, time, endTime, sensorValue

    Did I miss something?

    Thank you,

    quizItem success description error

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------

    exercise2.1 Pass "check if race day in process" ""

    exercise2.1 Pass "have correct schema" ""

    exercise2.2 Pass "check if lap table in process" ""

    exercise2.2 Pass "only contains data for 2nd Jan 2020" ""

    exercise2.2 Fail "contain all columns for 2nd Jan 2020" "length"

    exercise2.3 Pass "not allowed to use select keyword" ""

    exercise2.3 Pass "return correct values for temp" ""

    exercise2.3 Pass "return correct values for wind" ""

    exercise2.3 Pass "return correct values for all" ""

    exercise2.4 Pass "when given the wrong option return error \"<mysensor> is not a valid option for mysensor - valid options include temptyrewindall\"" ""

    exercise2.5 Pass "func should return same result as before" ""

    exercise2.5 Pass "`p attribute exists" ""

    mwoods replied 4 months, 2 weeks ago 3 Members · 11 Replies
  • 11 Replies
  • megan_mcp

    Administrator
    July 5, 2024 at 8:51 am

    Hi @jeanluck

    Can you send me your exact answer for exercise 2.2 so I can spot where you might be going wrong?

    Thanks,

    Megan🙂

  • jeanluck

    Member
    July 5, 2024 at 11:23 am

    Hi @megan_mcp,

    Not sure if it is useful as it is only checking columns in some table to pass the test?

    But here is it

    path_lap_20200102:$":",getenv[AX_WORKSPACE],"/f1/2020.01.02/lap"
    lapTable:update date:2020.01.02 from get path_lap_20200102
    /lapTable:select date:2020.01.02, sensorId, session, lapId, time, endTime, sensorValue from get path_lap_20200102

    Note: it is not well rendered, so you might not see some characters

    • megan_mcp

      Administrator
      July 5, 2024 at 11:55 am

      Hi @jeanluck

      You currently have your select statement commentated out, are you removing this when submitting your answer?

      Thanks,

      Megan

      • jeanluck

        Member
        July 5, 2024 at 12:02 pm

        Hi @megan_mcp

        Yes, I commented it.

        It was my trial as I was wondering if it is a matter of the order of the columns but the test still failed.

        Regards,

  • mwoods

    Administrator
    July 5, 2024 at 2:04 pm

    @jeanluck watch the order of your columns as per the sample table, date should be out in front. Another way to load in partitioned data WITH date column already added so you dont have to add it in manually using update and then reordering columns is using select from statement instead of get

    • jeanluck

      Member
      July 5, 2024 at 3:20 pm

      @mwoods I am not sure to understand: my lap table on disk does not contain a date column, that’s why I added it manually because if I added a date column, exercise1.4 will fail.

      OK, following what you said that I don’t need to add a date column manually, it means that at exercise1.4, I need to add the column date: maybe I did a mistake on exercise1.4.

      After I added the column date and all columns in the order in exercise1.4, exercise2.2 passed.

      lap:select date:2020.01.02, sensorId, session, lapId, time, endTime, sensorValue from .f1.createLapTable[tlap;tsensor]
      .Q.dpft[path_f1;2020.01.02;date;lap]

      Then I don’t understand what this error means?

      exercise1.4 Fail “create col files for lap table” “”

      quizItem    success description                                    error
      ------------------------------------------------------------------------
      exercise1.1 Pass "column file in DB should be renamed to lapId" ""
      exercise1.1 Pass ".d file in DB should be renamed to lapId" ""
      exercise1.1 Pass "all column files should be in event dir" ""
      exercise1.2 Pass "lapId should exist in event table" ""
      exercise1.3 Pass "check if all values are correct" ""
      exercise1.4 Pass "check if lap table exists" ""
      exercise1.4 Pass "create new lap dir in f1 DB" ""
      exercise1.4 Fail "create col files for lap table" ""
      exercise1.4 Pass ".d file should consist of all col names" ""
      exercise1.5 Pass "check if lap table exists in date dir" ""
      exercise1.5 Fail "create col files for lap table" ""
      exercise1.5 Pass ".d file should consist of all col names" ""
  • mwoods

    Administrator
    July 5, 2024 at 5:10 pm

    After writing table to disk using .Q.dpft and loading into memory you should see the date column on your table. You do not need to pass the column name date as in your example, the third parameter should be the column to key on, in this case sensorId. See an example here of what that looks like: https://code.kx.com/q/ref/dotq/#dpft-save-table

    Note in that example the table in memory is first deleted and then the table on disk is reloaded – only after loading from disk does date then appear when calling the table or using meta. So for exercise 2.2 you should see date appear without needing to do anything other load table into memory as long as your .Q.dpft worked correctly.

    If you can get all your exercise 1 passing thats a good sign .Q.dpft worked correctly. Then use \l to load into memory.

    • jeanluck

      Member
      July 6, 2024 at 8:22 am

      @mwoods There is something not clear or not mentioned in the instruction.

      In exercise1.4, does “lap” table saved on the disk contains the “date” column or not?
      Because it is not mentioned or no sample provided of the output columns.
      I am asking this because originally, to pass the test in exercise1.4, I didn’t add the the “date” column on “lap” table on the disk but it will break the test in exercise2.2.

      On exercise2.2, it seems that if you want to pass the test, you need the “date” column in “lap” table saved on the disk with “date” as the third parameter in .Q.dpft. Otherwise the test will fail in exercise2.2.

      I was thinking there is potential discrepancy between test and instruction as I found that in exercise3.5, instruction talked about “?” but test description talked about “!” and when I replaced “?” by “!”, the test passed.

  • mwoods

    Administrator
    July 8, 2024 at 9:41 am

    @jeanluck is your issue on 1.4/2.2 solved now? Or are you still stuck?

    Thanks for letting us know and we will clarify that question by specifying we want a date partitioned table in the question.

    Re. 3.5 I am not following, can you send a screenshot of the discrepancy please and we will have a look and update if needed.

    Your feedback is appreciated as we aim to continuously improve the course materials. 🙂

    • jeanluck

      Member
      July 8, 2024 at 1:25 pm

      @mwoods I am still stuck and could not do anything because there are interdependencies to pass both tests:
      – if 1.4 pass, I have to make 2.2 failed
      – if 2.2 pass, I have to make 1.4 failed
      So I don’t really know if the test has some errors like 3.5 in fact.

      Ok, if you are saying that in 1.4, the “date” column should be on disk in addition to columns returned by “.f1.createLapTable”, then you are saying my real issue lies in 1.4.
      But to make 2.2 passed, in 1.4, I have to pass “date” as the 3rd parameter in “.Q.dpft” and not “sensorId”. Then 1.4 will fail as we added extra “date” column in addition to columns returned by “.f1.createLapTable”.
      You can check in test code for 1.4 and 2.2 to know why maybe?

      For 3.5, in the instruction, it is said that if there is no function, it should return “?”.
      But the test description is “return ! if given update query” which means we should return “!” instead then the test passed.

  • mwoods

    Administrator
    July 8, 2024 at 3:25 pm

    @jeanluck to get you unblocked quickly it will be best if you can share your answers file with me in a DM or to evangelism@kx.com. Then I can better investigate what is going wrong for you as is hard to diagnose without seeing what you have ran.

Log in to reply.