You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by manishgupta88 <gi...@git.apache.org> on 2018/08/30 07:03:58 UTC
[GitHub] carbondata pull request #2671: [CARBONDATA-2876]AVRO datatype support throug...
Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2671#discussion_r213916136
--- Diff: store/sdk/src/main/java/org/apache/carbondata/sdk/file/AvroCarbonWriter.java ---
@@ -213,6 +218,225 @@ private Object avroFieldToObject(Schema.Field avroField, Object fieldValue) {
}
out = new ArrayObject(arrayChildObjects);
break;
+ case BYTES:
+ // DECIMAL type is defined in Avro as a BYTE type with the logicalType property
+ // set to "decimal" and a specified precision and scale
+ if (logicalType instanceof LogicalTypes.Decimal) {
+ out = new BigDecimal(new String(((ByteBuffer) fieldValue).array(),
+ CarbonCommonConstants.DEFAULT_CHARSET_CLASS));
+ ;
+ } else {
+ out = fieldValue;
+ }
+ break;
+ case UNION:
+ List<Schema> fieldsUnion = avroField.schema().getTypes();
+ int countIfNotNull = 0;
+ for (Schema unionField : fieldsUnion) {
+ if (!unionField.getType().equals(Schema.Type.NULL)) {
+ countIfNotNull++;
+ }
+ }
+ Object[] values;
+ values = new Object[countIfNotNull];
--- End diff --
1. Rename countIfNotNull to notNullUnionFieldsCount
2. merge above 2 lines 'Object[] values = new Object[countIfNotNull];'
3. Check union behavior for only NULL type and handle if any special handling is required
---