Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/1170#discussion_r178225725
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/record/VectorContainer.java
---
@@ -136,14 +138,28 @@ public void transferOut(VectorContainer containerOut)
{
public <T extends ValueVector> T addOrGet(final MaterializedField field,
final SchemaChangeCallBack callBack) {
final TypedFieldId id =
getValueVectorId(SchemaPath.getSimplePath(field.getName()));
final ValueVector vector;
- final Class<?> clazz =
TypeHelper.getValueVectorClass(field.getType().getMinorType(),
field.getType().getMode());
+
if (id != null) {
- vector = getValueAccessorById(id.getFieldIds()).getValueVector();
+ vector =
getValueAccessorById(id.getFieldIds()).getValueVector();
+ final Class<?> clazz =
TypeHelper.getValueVectorClass(field.getType().getMinorType(),
field.getType().getMode());
+
+ // Check whether incoming field and the current one are compatible;
if not then replace previous one with the new one
if (id.getFieldIds().length == 1 && clazz != null &&
!clazz.isAssignableFrom(vector.getClass())) {
final ValueVector newVector = TypeHelper.getNewVector(field,
this.getAllocator(), callBack);
replace(vector, newVector);
return (T) newVector;
}
+
+ // At this point, we know incoming and current fields are
compatible. Maps can have children,
+ // we need to ensure they have the same structure.
+ if (MinorType.MAP.equals(field.getType().getMinorType())
--- End diff --
This is tricky and probably broken elsewhere. If the incoming type is a
union or a list, then it can contain a nested map.
---