Unable to pass 1.3 on testSection[`exercise1] on Advanced Capstone

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 Fail “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 Pass “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 Pass “create col files for lap table” “”
exercise1.5 Pass “.d file should consist of all col names” “”

 

meta lap shows

c t f a
date d
session s p
lapId j
time t
endTime t
sensorId s
sensorValue f

count lap shows 410

first few rows of lap shows

date session lapId time endTime sensorId sensorValue

2020.01.02 P3 1 12:00:42.329 12:01:14.042 windSpeedFront 159.7311
2020.01.02 P3 1 12:00:42.329 12:01:14.042 windSpeedBack 159.7292
2020.01.02 P3 1 12:00:42.329 12:01:14.042 tyrePressureFrontRight 203.8121
2020.01.02 P3 1 12:00:42.329 12:01:14.042 tyrePressureFrontLeft 203.8102
2020.01.02 P3 1 12:00:42.329 12:01:14.042 tyrePressureBackRight 203.8104
2020.01.02 P3 1 12:00:42.329 12:01:14.042 tyrePressureBackLeft 203.8072

and I used the test data and all seemed correct. Not sure why test is not passing.
Thanks

Check the columns sequences, mine passed and correct order is 

c | t f a -----------| ----- date | d sensorId | s p session | s lapId | j time | t endTime | t sensorValue| f 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 Pass “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 Pass “create col files for lap table” “” exercise1.5 Pass “.d file should consist of all col names” “”

 

Looks like count and meta are different, they should be:

//“meta lap” c | t f a -----------| ----- date | d sensorId | s p session | s lapId | j time | t endTime | t sensorValue| f // “count lap” 210 //“lap” date sensorId session lapId time endTime sensorValue ----------------------------------------------------------------------------- 2020.01.02 tempBackLeft P3 1 12:00:42.329 12:01:14.042 20.61488 2020.01.02 tempBackLeft P3 2 12:01:14.042 12:02:27.094 20.62392 2020.01.02 tempBackLeft P3 3 12:02:27.094 12:02:54.318 20.61883 2020.01.02 tempBackLeft P3 4 12:02:54.318 12:16:52.146 20.621

 

If still stuck can add your code with the spoiler feature (in toolbar - click three dots ) then I can better suggest where you might be going wrong.

Hi, 
I defined .f1.createLapTable as

// 1. create cross product of event table with unique list of sensorId’s - see https://code.kx.com/q/ref/cross/
crossTab:(select from eventTab) cross distinct select sensorId from sensorTab;
// 2. get a pair of lists of times/timestamps, begin and end - use time and endTime from cross product table (#1)
w:(crossTab[time];crossTab[endTime]);
// 3. use wj: see https://code.kx.com/q/ref/wj/
res:wj[w;`sensorId`time;select from crossTab;(select from sensorTab;(avg;`sensorValue))];
res

and afterwards applied asc so I can apply the parted attribute.

lap:select asc sensorId,session,lapId,time, endTime, sensorValue from lap;
update p#sensorId from lap

Hi   you’re very nearly there.

The date column should be removed in .f1.createLapTable for 1.3 to pass. And you do not need to explicitly add the parted attribute. These both should come when you save lap down to disk in exercise 1.4. Date gets added and parted attribute gets applied when you use 

.Q.dpft

 I would recommend the Partitioned Tables course to help you get familiar with the basics of saving tables to disk that will help with this project.

Hi ,

Thanks for clarifying! I did remove the date column by 
doing the following select statement
lap:select asc sensorId,session,lapId,time, endTime, sensorValue from lap;
but I will do that in the function instead then.

However, the count is still  wrong as I am getting 410 instead of 210 in your solution.

 

Thanks

 is 1.3 passing after you moved that piece inside the function? I would expect yes as I tried your code on my side and it looks correct and passes for me. You can open the unit for this function which might help debug further if not

feature .f1.createLapTable before .test.lapTable:(date:2#2020.01.02;session:2#P3;lapId:1 1;time:13:00:00.00 13:02:48.156;endTime:13:02:48.156 13:04:57.689); .test.sensorTable:([]date:6#2020.01.02;sensorId:((2#tempBackLeft),(2#tempBackRight),2#tyrePressureBackLeft);time:13:00:00.00+6?3000;lapId:6#1;units:((4#degreesCel),2#pascals);sensorValue:((20+4?1.),200+2?1.);session:6#`P3); should Each Sensor Should Have Start Time From Lap Table expect ((3#13:00:00.000),3#13:02:48.156)~exec time from .f1.createLapTable[.test.lapTable;.test.sensorTable] should Each Sensor Should Have End Time From Lap Table expect ((3#13:02:48.156),3#13:04:57.689)~exec endTime from .f1.createLapTable[.test.lapTable;.test.sensorTable]

 

For number of rows is that for 1.4 after saving lap to disk? This might be due to tables you are passing to the function rather than the function itself.

lap:.f1.createLapTable[select from event where date in 2020.01.02, session in P3;select from sensor where date in 2020.01.02, session in P3]

 

Hi,

 

Tests passed

All 2 tests passed

meta lap shows

c t f a
date d
sensorId s p
session s
lapId j
time t
endTime t
sensorValue f
count lap shows

210

Not sure why I am still getting the error for

 

exercise1.3 Fail “check if all values are correct” “”

my function looks like the following: crossTab:(select from eventTab) cross distinct select sensorId from sensorTab;
w:(crossTab[time];crossTab[endTime]);
res:select sensorId,session,lapId,time, endTime, sensorValue from wj[w;`sensorId`time;select from crossTab;(select from sensorTab;(avg;`sensorValue))];
res

  I don’t see where are you deleting date within the function?

Hi,

 

Even with the delete I am having issues.

 

 

crossTab:(delete date from select from eventTab) cross distinct delete date from select sensorId from sensorTab;

still shows
exercise1.3 Fail “check if all values are correct” “”

while I am running

lap:.f1.createLapTable[select from event where date in 2020.01.02, session in P3;select from sensor where date in 2020.01.02, session in P3];
.Q.dpft[`:/home/jovyan/developer/workspace/ nouser /adv_capstone/f1;2020.01.02;`sensorId;`lap]

 The selecting of the columns is not required around the wj 

.f1.createLapTable:{[eventTab;sensorTab] crossTab:(select from eventTab) cross distinct select sensorId from sensorTab; w:(crossTab[time];crossTab[endTime]); res:wj[w;`sensorId`time;select from crossTab;(select from sensorTab;(avg;`sensorValue))]; delete date from res }

Thank you!