[
https://issues.apache.org/jira/browse/BEAM-10564?focusedWorklogId=466896&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-466896
]
ASF GitHub Bot logged work on BEAM-10564:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 05/Aug/20 17:21
Start Date: 05/Aug/20 17:21
Worklog Time Spent: 10m
Work Description: lukecwik commented on a change in pull request #12367:
URL: https://github.com/apache/beam/pull/12367#discussion_r465884172
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/AvroUtils.java
##########
@@ -601,12 +601,26 @@ private void readObject(ObjectInputStream in) throws
IOException, ClassNotFoundE
private Map<String, String> getMapping(Schema schema) {
Map<String, String> mapping = Maps.newHashMap();
for (Field field : schema.getFields()) {
- String underscore =
CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field.getName());
- mapping.put(underscore, field.getName());
+ String fieldName = field.getName();
+ String getter;
+ if (fieldName.contains("_")) {
+ if (Character.isLowerCase(fieldName.charAt(0))) {
+ // field_name -> fieldName
+ getter = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,
fieldName);
+ } else {
+ // FIELD_NAME -> fIELDNAME
+ getter = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL,
fieldName.replace("_", ""));
Review comment:
```suggestion
getter = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,
fieldName.replace("_", ""));
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 466896)
Time Spent: 0.5h (was: 20m)
> Support more Avro field name formats when mapping to Java fields
> ----------------------------------------------------------------
>
> Key: BEAM-10564
> URL: https://issues.apache.org/jira/browse/BEAM-10564
> Project: Beam
> Issue Type: Improvement
> Components: sdk-java-core
> Reporter: Ryan Worley
> Assignee: Ryan Worley
> Priority: P2
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> When mapping Avro schema field names to the related generated Java class
> fields, Beam currently supports Avro field names like field_name and
> fieldName. This improvement will add support for Avro field names like
> FieldName and FIELD_NAME.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)