What would you like to happen?
Motivation
The Java JsonIO connector (sdks/java/io/json/.../JsonIO.java) currently supports only writing withJsonIO.write() and JsonIO.writeRows(). There is no read path. The connector's own class Javadoc acknowledges this gap:
"Reading from JSON files is not yet implemented in Java. Please see
#24552."
That linked issue (#24552) is actually titled "Implement CsvIO.Read" and is closed as not planned, CsvIO.Read was subsequently implemented under a different path, so there is currently no live tracking issue for JSON reading, and the Javadoc reference is stale. This issue is intended to be that tracking issue.
Proposal
Add a read/parse surface to JsonIO symmetric to the existing write surface
and mirroring the pattern CsvIO already established:
JsonIO.parse(Class<T> klass) // JSON records -> user type T
JsonIO.parseRows(Schema schema) // JSON records -> Row
modeled on CsvIO.parse(Class, CSVFormat) (CsvIO.java:419) and CsvIO.parseRows(Schema, CSVFormat) (CsvIO.java:497), including their CsvIOParse result-and-error-handling pattern.
Why this is tractable
The core JSON→Row conversion already exists and is reusable:
- JsonUtils.getJsonStringToRowFunction(Schema)
(sdks/java/core/.../schemas/utils/JsonUtils.java:104)
- JsonUtils.getJsonBytesToRowFunction(Schema) (line 93)
- JsonUtils.beamSchemaFromJsonSchema(String) (line 201)
The work is primarily wiring these into a read PTransform over FileIO.match() + line reading, following the CsvIO parse structure not new parsing logic.
Testing plan
- Unit tests mirroring CsvIO parse tests: schema validation, type conversion to both Row and custom user classes, error/failure routing.
- Round-trip test: write JSON via JsonIO.write(), read it back via JsonIO.parseRows(), assert equality.
- No new dependencies- JSON schema/parse machinery is already in sdks/java/core.
Issue Priority
Priority: 2 (default / most feature requests should be filed as P2)
Issue Components
What would you like to happen?
Motivation
The Java
JsonIOconnector (sdks/java/io/json/.../JsonIO.java) currently supports only writing withJsonIO.write()andJsonIO.writeRows(). There is no read path. The connector's own class Javadoc acknowledges this gap:That linked issue (#24552) is actually titled "Implement CsvIO.Read" and is closed as not planned, CsvIO.Read was subsequently implemented under a different path, so there is currently no live tracking issue for JSON reading, and the Javadoc reference is stale. This issue is intended to be that tracking issue.
Proposal
Add a read/parse surface to
JsonIOsymmetric to the existing write surfaceand mirroring the pattern
CsvIOalready established:modeled on CsvIO.parse(Class, CSVFormat) (CsvIO.java:419) and CsvIO.parseRows(Schema, CSVFormat) (CsvIO.java:497), including their CsvIOParse result-and-error-handling pattern.
Why this is tractable
The core JSON→Row conversion already exists and is reusable:
(sdks/java/core/.../schemas/utils/JsonUtils.java:104)
The work is primarily wiring these into a read PTransform over FileIO.match() + line reading, following the CsvIO parse structure not new parsing logic.
Testing plan
Issue Priority
Priority: 2 (default / most feature requests should be filed as P2)
Issue Components