-
I tried to do a test data mock by reading https://opensource.googleblog.com/2021/04/logica-organizing-your-data-queries.html. The following code is a sample that is supposed to query the Google Analytics session table mytable.l
test.l
However, when I tried to generate the SQL, I got the following error.
I can mock a reference to a BigQuery table, but can't I mock an arbitrary predicate? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can in fact mock an arbitrary predicate! To mock a predicate that is defined in the program we need to import it in the test file. It doesn't need to be done for BQ tables because they are global. Thus to make your test work we need to add import mytable.UidCount;
import mytable.GAEvent; # <= New line.
MockEvent(user_id: 1);
MockEvent(user_id: 2);
# I want to mock GAEvent with MockEvent.
TestUidCount := UidCount(GAEvent: MockEvent); I've tested it on my machine and it appears to work as intended. Please let me know if this solves your problem and if you have further questions. |
Beta Was this translation helpful? Give feedback.
You can in fact mock an arbitrary predicate!
To mock a predicate that is defined in the program we need to import it in the test file. It doesn't need to be done for BQ tables because they are global.
Thus to make your test work we need to add
import mytable.GAEvent;
at the top.So the
test.l
would look like:I've tested it on my machine and it appears to work as intended.
Please let me know if this solves your problem and if you have further questions.