Github user chunhui-shi commented on a diff in the pull request: https://github.com/apache/drill/pull/546#discussion_r71634838 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java --- @@ -129,11 +129,21 @@ private void setFlattenVector() { try { final TypedFieldId typedFieldId = incoming.getValueVectorId(popConfig.getColumn()); final MaterializedField field = incoming.getSchema().getColumn(typedFieldId.getFieldIds()[0]); - final RepeatedValueVector vector = RepeatedValueVector.class.cast(incoming.getValueAccessorById( - field.getValueClass(), typedFieldId.getFieldIds()).getValueVector()); + RepeatedValueVector vector = null; + try { + vector = RepeatedValueVector.class.cast(incoming.getValueAccessorById( + field.getValueClass(), typedFieldId.getFieldIds()).getValueVector()); + } catch(ClassCastException ex) { + if(incoming.getRecordCount() != 0) { + throw UserException.unsupportedError(ex).message("Flatten does not support inputs of non-list values.").build(logger); + } + //when incoming recordCount is 0, don't throw exception since the type being seen here is not solid + logger.error("setFlattenVector cast failed and recordcount is 0, create empty vector anyway."); + vector = new RepeatedMapVector(field, oContext.getAllocator(), null); + } flattener.setFlattenField(vector); } catch (Exception ex) { - throw UserException.unsupportedError(ex).message("Trying to flatten a non-repeated field.").build(logger); + throw UserException.unsupportedError(ex).message("Flatten does not support inputs of non-list values.").build(logger); --- End diff -- The two catch blocks are parallel. The UserException in line 138 wont be caught and thrown again in line 146.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---