yihua commented on code in PR #14059:
URL: https://github.com/apache/hudi/pull/14059#discussion_r2446401976
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/SparkHoodieTableFileIndex.scala:
##########
@@ -248,12 +248,24 @@ class SparkHoodieTableFileIndex(spark: SparkSession,
// the whole table
if (haveProperPartitionValues(partitionPaths.toSeq) &&
partitionSchema.nonEmpty) {
val predicate = partitionPruningPredicates.reduce(expressions.And)
- val boundPredicate = InterpretedPredicate(predicate.transform {
+ val transformedPredicate = predicate.transform {
case a: AttributeReference =>
val index = partitionSchema.indexWhere(a.name == _.name)
BoundReference(index, partitionSchema(index).dataType, nullable =
true)
- })
-
+ }
+ val boundPredicate: BasePredicate = try {
+ // Try using 1-arg constructor via reflection
+ val clazz =
Class.forName("org.apache.spark.sql.catalyst.expressions.InterpretedPredicate")
+ val ctor = clazz.getConstructor(classOf[Expression])
+ ctor.newInstance(transformedPredicate).asInstanceOf[BasePredicate]
+ } catch {
+ case _: NoSuchMethodException | _: IllegalArgumentException =>
+ // Fallback: Try using 2-arg constructor
+ val clazz =
Class.forName("org.apache.spark.sql.catalyst.expressions.InterpretedPredicate")
+ val ctor = clazz.getConstructor(classOf[Expression],
classOf[Boolean])
+ ctor.newInstance(transformedPredicate, java.lang.Boolean.FALSE)
+ .asInstanceOf[BasePredicate]
Review Comment:
nit: add docs on what the second argument represents?
--
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]