Skip to content

Commit 81065bf

Browse files
Remove support for production of union data (pending fixes in the vector classes)
1 parent fa7d470 commit 81065bf

File tree

4 files changed

+8
-200
lines changed

4 files changed

+8
-200
lines changed

adapter/avro/src/main/java/org/apache/arrow/adapter/avro/ArrowToAvroUtils.java

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.apache.arrow.adapter.avro.producers.AvroBigIntProducer;
2222
import org.apache.arrow.adapter.avro.producers.AvroBooleanProducer;
2323
import org.apache.arrow.adapter.avro.producers.AvroBytesProducer;
24-
import org.apache.arrow.adapter.avro.producers.AvroDenseUnionProducer;
2524
import org.apache.arrow.adapter.avro.producers.AvroFixedSizeBinaryProducer;
2625
import org.apache.arrow.adapter.avro.producers.AvroFixedSizeListProducer;
2726
import org.apache.arrow.adapter.avro.producers.AvroFloat2Producer;
@@ -40,7 +39,6 @@
4039
import org.apache.arrow.adapter.avro.producers.AvroUint2Producer;
4140
import org.apache.arrow.adapter.avro.producers.AvroUint4Producer;
4241
import org.apache.arrow.adapter.avro.producers.AvroUint8Producer;
43-
import org.apache.arrow.adapter.avro.producers.AvroUnionProducer;
4442
import org.apache.arrow.adapter.avro.producers.BaseAvroProducer;
4543
import org.apache.arrow.adapter.avro.producers.CompositeAvroProducer;
4644
import org.apache.arrow.adapter.avro.producers.Producer;
@@ -94,12 +92,10 @@
9492
import org.apache.arrow.vector.UInt8Vector;
9593
import org.apache.arrow.vector.VarBinaryVector;
9694
import org.apache.arrow.vector.VarCharVector;
97-
import org.apache.arrow.vector.complex.DenseUnionVector;
9895
import org.apache.arrow.vector.complex.FixedSizeListVector;
9996
import org.apache.arrow.vector.complex.ListVector;
10097
import org.apache.arrow.vector.complex.MapVector;
10198
import org.apache.arrow.vector.complex.StructVector;
102-
import org.apache.arrow.vector.complex.UnionVector;
10399
import org.apache.arrow.vector.types.FloatingPointPrecision;
104100
import org.apache.arrow.vector.types.TimeUnit;
105101
import org.apache.arrow.vector.types.Types;
@@ -158,11 +154,11 @@ public class ArrowToAvroUtils {
158154
* of its child fields are nullable. The schema for a nullable union will always contain a null
159155
* type,none of the direct child types will be nullable.
160156
*
161-
* <p>List fields must contain precisely one child field, which may be nullable. Map fields must
162-
* contain precisely two child fields, the key field and the value field. The key field must
163-
* always be of type STRING (Utf8) and cannot be nullable. The value can be of any type and may be
164-
* nullable. Record types must contain at least one child field and cannot contain multiple fields
165-
* with the same name
157+
* <p>List fields must contain precisely one child field, which may be nullable. Map fields are
158+
* represented as a list of structs, where the struct fields are "key" and "value". The key field
159+
* must always be of type STRING (Utf8) and cannot be nullable. The value can be of any type and
160+
* may be nullable. Record types must contain at least one child field and cannot contain multiple
161+
* fields with the same name
166162
*
167163
* @param arrowFields The arrow fields used to generate the Avro schema
168164
* @param typeName Name of the top level Avro record type
@@ -707,27 +703,9 @@ private static BaseAvroProducer<?> createProducer(FieldVector vector, boolean nu
707703
new AvroStructProducer(entryVector, new Producer<?>[] {keyProducer, valueProducer});
708704
return new AvroMapProducer(mapVector, entryProducer);
709705

710-
case UNION:
711-
UnionVector unionVector = (UnionVector) vector;
712-
List<FieldVector> unionChildVectors = unionVector.getChildrenFromFields();
713-
Producer<?>[] unionChildProducers = new Producer<?>[unionChildVectors.size()];
714-
for (int i = 0; i < unionChildVectors.size(); i++) {
715-
FieldVector unionChildVector = unionChildVectors.get(i);
716-
unionChildProducers[i] =
717-
createProducer(unionChildVector, /* nullable = */ false); // Do not nest union types
718-
}
719-
return new AvroUnionProducer(unionVector, unionChildProducers);
720-
721-
case DENSEUNION:
722-
DenseUnionVector denseUnionVector = (DenseUnionVector) vector;
723-
List<FieldVector> denseChildVectors = denseUnionVector.getChildrenFromFields();
724-
Producer<?>[] denseChildProducers = new Producer<?>[denseChildVectors.size()];
725-
for (int i = 0; i < denseChildVectors.size(); i++) {
726-
FieldVector denseChildVector = denseChildVectors.get(i);
727-
denseChildProducers[i] =
728-
createProducer(denseChildVector, /* nullable = */ false); // Do not nest union types
729-
}
730-
return new AvroDenseUnionProducer(denseUnionVector, denseChildProducers);
706+
// Support for UNION and DENSEUNION is not currently available
707+
// This is pending fixes in the implementation of the union vectors themselves
708+
// https://github.com/apache/arrow-java/issues/108
731709

732710
default:
733711
// Not all Arrow types are supported for encoding (yet)!

adapter/avro/src/main/java/org/apache/arrow/adapter/avro/producers/AvroDenseUnionProducer.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

adapter/avro/src/main/java/org/apache/arrow/adapter/avro/producers/AvroUnionProducer.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

adapter/avro/src/main/java/org/apache/arrow/adapter/avro/producers/BaseUnionProducer.java

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)