vishalmore90 opened a new pull request, #41717: URL: https://github.com/apache/beam/pull/41717
- [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). ### Summary Fixes #41715. Updates Beam YAML `Explode` in both Python (`_Explode`) and Java (`JavaExplodeTransformProvider`) to handle `None`/`null` collections and preserve accurate output schemas: 1. **Python (`sdks/python/apache_beam/yaml/yaml_mapping.py`)**: - Explicitly skip `None` collections in `explode_cross_product` (emitting 0 rows, matching `[]`) and substitute `()` for `None` inputs in `explode_zip` before `itertools.zip_longest`. - Replace `getattr(row, name)` in `_Explode.expand` with `_row_to_dict` (`row.__dict__` for `beam.Row`, `row._asdict()` when callable, `getattr` fallback). - Update `_Explode.infer_output_type` to convert native schema types via `convert_to_beam_type`, unwrap `Optional[...]`, infer element types via `trivial_inference.element_type`, and mark multi-field zipped output fields `Optional[...]` so `RowCoder` accepts `None` padding on unequal/null inputs. 2. **Java (`sdks/java/core/.../JavaExplodeTransformProvider.java`)**: - Guard against `null` iterables in both cross-product and zip execution paths. - Replace `ImmutableList.copyOf(current)` with `Row.withSchema(outputSchema).addValues(Arrays.asList(current)).build()` so nullable non-exploded fields or null elements do not throw `NullPointerException`. - Mark exploded output fields nullable when zipping multiple fields (`!crossProduct && fields.size() > 1`), matching the `null` padding behavior of zip mode. 3. **Tests & Changelog**: - Added Python unit tests in `sdks/python/apache_beam/yaml/yaml_mapping_test.py`. - Added YAML test pipelines in `sdks/python/apache_beam/yaml/tests/explode.yaml`. - Updated/added Java unit tests in `JavaExplodeTransformProviderTest.java`. - Updated `CHANGES.md`. ### Verification - Ran `python -m unittest apache_beam.yaml.yaml_mapping_test` (34 tests passed). - Ran all 5 pipelines in `sdks/python/apache_beam/yaml/tests/explode.yaml` through `YamlTransform` on `DirectRunner` (all passed). - Java unit tests, Spotless, Python formatter/lint, `validateChanges`, and xlang integration tests deferred to GitHub Actions PreCommit checks (local environment has JDK 25 only). -- 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]
