From 2e83338b216ef71dcf2a77e418346ff253b95c5d Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Tue, 23 Aug 2022 16:02:51 -0700 Subject: [PATCH] Do not push down filter to ORC for union type schema --- orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java b/orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java index 5606e8cd58..07d1cca270 100644 --- a/orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java +++ b/orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java @@ -102,8 +102,12 @@ public CloseableIterator iterator() { // to push down filters to ORC's SearchArgument, since we are not reading anything from files at all boolean isEmptyStruct = readOrcSchema.getChildren().size() == 0; + // If the projected ORC schema has union type, we can't reliably build a pushdown filter for the + // underlying ORC files, since the Iceberg schema has a different representation than the ORC schema. + boolean containsUnion = readOrcSchema.toString().contains("uniontype"); + SearchArgument sarg = null; - if (filter != null && !isEmptyStruct) { + if (filter != null && !isEmptyStruct && !containsUnion) { Expression boundFilter = Binder.bind(schema.asStruct(), filter, caseSensitive); sarg = ExpressionToSearchArgument.convert(boundFilter, readOrcSchema); }