mananmangal opened a new issue, #40299:
URL: https://github.com/apache/beam/issues/40299

   ### What happened?
   
   Writing a `Row` with an `EnumerationType` logical type field (e.g. from 
`ProtoSchemaTranslator` on a proto message with an `enum` field) to 
`IcebergIO.writeRows()` fails. `EnumerationType` isn't one of the cases 
[handled 
here](https://github.com/apache/beam/blob/020707df9d6d0276a936d98e4f79f4792e761005/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergUtils.java#L236),
 so schema derivation throws immediately:
   
   ```
   java.lang.RuntimeException: Unsupported Beam logical type Enum
         at 
org.apache.beam.sdk.io.iceberg.IcebergUtils.beamFieldTypeToIcebergFieldType(IcebergUtils.java:236)
         at 
org.apache.beam.sdk.io.iceberg.IcebergUtils.beamSchemaToIcebergSchema(IcebergUtils.java:323)
   ```
   
   Pre-creating the table doesn't help either. `copyFieldIntoRecord` calls 
`Row.getString()`/`Row.getInt32()` 
[directly](https://github.com/apache/beam/blob/020707df9d6d0276a936d98e4f79f4792e761005/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergUtils.java#L392),
 so it fails trying to cast the field's `EnumerationType.Value` to `String`:
   
   ```
   java.lang.ClassCastException: class 
org.apache.beam.sdk.schemas.logicaltypes.EnumerationType$Value cannot be cast 
to class java.lang.String
         at 
org.apache.beam.sdk.io.iceberg.IcebergUtils.copyFieldIntoRecord(IcebergUtils.java:392)
   ```
   
   Avro (`AvroUtils.genericFromBeamField`) and BigQuery 
(`BigQueryUtils.fromBeamField`) already convert `EnumerationType` to a string 
on write, so there's a working pattern to follow here.
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [x] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [x] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Infrastructure
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Prism Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
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]

Reply via email to