sunchao commented on code in PR #7156:
URL: https://github.com/apache/datafusion-comet/pull/7156#discussion_r4735337573
##########
spark/src/main/scala/org/apache/comet/serde/operator/CometIcebergNativeScan.scala:
##########
@@ -962,14 +1000,15 @@ object CometIcebergNativeScan extends
CometOperatorSerde[CometBatchScanExec] wit
}
}
} else if (exprClass.getName.endsWith(Constants.ExpressionTypes.AND)) {
- val left = icebergExprToProto(
- IcebergReflection.getMethod(exprClass, "left").invoke(icebergExpr),
- output,
- pageIndexUnsupportedColumns)
- val right = icebergExprToProto(
- IcebergReflection.getMethod(exprClass, "right").invoke(icebergExpr),
- output,
- pageIndexUnsupportedColumns)
+ // A row whose column is NULL fails a conjunct `NOT_NULL(column)`, so
the whole AND is
+ // false in Spark and the native reader alike. The other conjuncts can
then treat the column
+ // as non-nullable. Spark infers that conjunct for the columns a filter
compares, so it keeps
+ // `c = false`, which Spark rewrites to `NOT c`, pushable on a nullable
boolean.
+ val nonNullAttributes = attributes ++
notNullColumns(icebergExpr).flatMap { name =>
Review Comment:
Could we collect `NOT_NULL` columns once at the root of each contiguous
`AND` chain and reuse that attribute map for its child `AND`s? Start a new
collection for a chain below `OR` or `NOT`, keeping any inherited constraints.
[Iceberg combines filters left to
right](https://github.com/apache/iceberg/blob/apache-iceberg-1.8.1/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScanBuilder.java#L135-L137),
so this walks 32 leaves, then 31, and so on. The driver repeats that work for
every file task before interning the residual.
I timed `icebergExprToProto` on 16 nullable `INT` columns with 16 null
checks and 16 equalities. Median time per conversion over five rounds was 123
µs on the base, 184 µs here, and 26 µs collecting once per chain. That change
also cut allocations from 204 KB to 31 KB per conversion and produced the same
protobuf.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]