Skip to content
Advertisement

Beam PAssert messes up the Row

I am exploring testing with Beam and encountered a weird problem.

My driver program works as expected, but its test is failing with an error like this:

JavaScript

And here is my PAssert code:

JavaScript

On the last step of my pipeline, I log the element in question.

JavaScript

This is the expected result.

When I debugged the test, the problem boiled down to CoderUtils from Beam Java SDK.

After CoderUtils encodes and decodes, it produces a completely different expected Row. All of its fields are messed up, and as a result, PAssert fails.

I am wondering if there are any solutions to this problem. Any suggestions are more than welcome.

Thanks in advance!

OUTPUT_SCHEMA definition:

JavaScript

Advertisement

Answer

The code can work as expected and the test fails. I believe that is happening because of an error on the PAssert definition.

  • Add the project tag in the test row definition .withFieldValue("project_id", "p1"), it may solve the problem of the crossed parameters.

  • For the error Expected: iterable with items [<Row: ... >] in any order but: not matched: please provide the output variable as an Array of Rows, instead of only a single Row. Its expecting an array but just receiving a single Row.

Your final code will be something like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement