ludlows commented on code in PR #6760:
URL: https://github.com/apache/iceberg/pull/6760#discussion_r1186593636
##########
spark/v3.3/spark/src/main/scala/org/apache/spark/sql/execution/datasources/SparkExpressionConverter.scala:
##########
@@ -37,13 +39,17 @@ object SparkExpressionConverter {
}
@throws[AnalysisException]
- def collectResolvedSparkExpression(session: SparkSession, tableName: String,
where: String): Expression = {
+ def collectResolvedIcebergExpression(session: SparkSession,
+ tableName: String,
+ where: String):
org.apache.iceberg.expressions.Expression = {
val tableAttrs = session.table(tableName).queryExecution.analyzed.output
val unresolvedExpression =
session.sessionState.sqlParser.parseExpression(where)
val filter = Filter(unresolvedExpression, DummyRelation(tableAttrs))
val optimizedLogicalPlan =
session.sessionState.executePlan(filter).optimizedPlan
optimizedLogicalPlan.collectFirst {
- case filter: Filter => filter.condition
+ case filter: Filter => convertToIcebergExpression(filter.condition)
+ case dummyRelation: DummyRelation => Expressions.alwaysTrue()
Review Comment:
hi @szehon-ho , do we need an Expression.TRUE in spark expression? finally
we only need an iceberg one. but it seems possible if we implement it in the
following way:
```scala
optimizedLogicalPlan.collectFirst {
case filter: Filter =>filter.condition
case dummyRelation: DummyRelation =>
session.sessionState.sqlParser.parseExpression("true")
case localRelation: LocalRelation =>
session.sessionState.sqlParser.parseExpression("false")
}.getOrElse(throw new AnalysisException("Failed to find filter
expression"))
```
how do you think about it?
--
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]