tvalentyn commented on a change in pull request #15900:
URL: https://github.com/apache/beam/pull/15900#discussion_r747670341
##########
File path: sdks/python/apache_beam/examples/fastavro_it_test.py
##########
@@ -123,65 +137,44 @@ def batch_indices(start):
| 'expand-batches' >> FlatMap(batch_indices) \
| 'create-records' >> Map(record)
- fastavro_output = '/'.join([self.output, 'fastavro'])
- avro_output = '/'.join([self.output, 'avro'])
-
# pylint: disable=expression-not-assigned
records_pcoll \
| 'write_fastavro' >> WriteToAvro(
fastavro_output,
parse_schema(json.loads(self.SCHEMA_STRING)),
- use_fastavro=True
)
+ result = self.test_pipeline.run()
+ result.wait_until_finish()
+ fastavro_pcoll = self.test_pipeline \
+ | 'create-fastavro' >> Create(['%s*' % fastavro_output]) \
+ | 'read-fastavro' >> ReadAllFromAvro()
- # pylint: disable=expression-not-assigned
- records_pcoll \
- | 'write_avro' >> WriteToAvro(
- avro_output,
- Parse(self.SCHEMA_STRING),
- use_fastavro=False
- )
+ mapped_fastavro_pcoll = fastavro_pcoll | "map_fastavro" >> Map(
+ lambda x: (x['number'], x))
+ mapped_record_pcoll = records_pcoll | "map_record" >> Map(
+ lambda x: (x['number'], x))
+
+ def validate_record(elem):
+ v = elem[1]
+
+ def assertEqual(l, r):
+ if l != r:
+ raise BeamAssertException('Assertion failed: %s == %s' % (l, r))
+
+ assertEqual(sorted(v.keys()), ['fastavro', 'record_pcoll'])
+ record_pcoll_values = v['record_pcoll']
+ fastavro_values = v['fastavro']
+ assertEqual(record_pcoll_values, fastavro_values)
+ assertEqual(len(record_pcoll_values), 1)
Review comment:
What guarantees that we have unique keys for each record (so that after
GBK we only have 1 value per key)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]