ludlows commented on code in PR #7760:
URL: https://github.com/apache/iceberg/pull/7760#discussion_r1228831213


##########
spark/v3.1/spark/src/main/scala/org/apache/spark/sql/execution/datasources/SparkExpressionConverter.scala:
##########
@@ -36,15 +40,16 @@ object SparkExpressionConverter {
 
   @throws[AnalysisException]
   def collectResolvedSparkExpression(session: SparkSession, tableName: String, 
where: String): Expression = {
-    var expression: Expression = null
-    // Add a dummy prefix linking to the table to collect the resolved spark 
expression from optimized plan.
-    val prefix = String.format("SELECT 42 from %s where ", tableName)
-    val logicalPlan = session.sessionState.sqlParser.parsePlan(prefix + where)
-    val optimizedLogicalPlan = 
session.sessionState.executePlan(logicalPlan).optimizedPlan
+    val tableAttrs = session.table(tableName).queryExecution.analyzed.output
+    val unresolvedExpression = 
session.sessionState.sqlParser.parseExpression(where)
+    val filter = Filter(unresolvedExpression, DummyRelation(tableAttrs))

Review Comment:
   it seems that "select 42 from table where" is used only to form a complete 
sql sentence together with the where condtion. now we can evaluate the where 
condtion directly without this "select" sql sentence. 



-- 
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]

Reply via email to