szehon-ho commented on PR #6760:
URL: https://github.com/apache/iceberg/pull/6760#issuecomment-1464734878

   I walked through the code and see the problem.  
   
   I still think, let's change the original method: 
collectResolvedSparkExpression to not throw AnalysisException in this case.  I 
feel its not so useful to make an additional method that does the same thing , 
and have the code have to call both.
   
   ```
     def collectResolvedSparkExpression(session: SparkSession, tableName: 
String, where: String): Option[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 => Some(filter.condition)
       }.getOrElse(Option.empty())
     }
   ```
   
   
   
   ```
     def collectResolvedSparkExpression(session: SparkSession, tableName: 
String, where: String): Option[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 => Some(filter.condition)
         case _: LocalRelation => Option.empty
       }.getOrElse(throw new AnalysisException("Failed to find filter 
expression"))
     }
   ```
   
   That way its less code to change


-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to