mihailoale-db commented on code in PR #59681:
URL: https://github.com/apache/spark/pull/59681#discussion_r4347092663


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/resolver/SubqueryExpressionResolver.scala:
##########
@@ -54,6 +55,9 @@ class SubqueryExpressionResolver(expressionResolver: 
ExpressionResolver, resolve
    */
   def resolveScalarSubquery(unresolvedScalarSubquery: ScalarSubquery): 
Expression = {
     traversals.current.parentOperator match {
+      case _: UnresolvedInlineTable

Review Comment:
   Here as well.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/finishAnalysis.scala:
##########
@@ -92,20 +92,23 @@ object EvalInlineTables extends Rule[LogicalPlan] with 
CastSupport {
 
     def eval(table: ResolvedInlineTable): LocalRelation = {
       val newRows: Seq[InternalRow] =
-        table.rows.map { row => InternalRow.fromSeq(row.map { e =>
-          try {
-            prepareForEval(e).eval()
-          } catch {
-            case NonFatal(ex) =>
-              table.failAnalysis(
-                errorClass = 
"INVALID_INLINE_TABLE.FAILED_SQL_EXPRESSION_EVALUATION",
-                messageParameters = Map("sqlExpr" -> toSQLExpr(e)),
-                cause = ex)
-          }})
-        }
+        table.rows.map(row => 
InternalRow.fromSeq(row.map(evalExpression(table, _))))
 
       LocalRelation(table.output, newRows)
     }
+
+    /** Evaluates one of the expressions of the given inline table. */
+    def evalExpression(table: ResolvedInlineTable, e: Expression): Any = {
+      try {
+        prepareForEval(e).eval()

Review Comment:
   Do we need try/catch block here?



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/resolver/Resolver.scala:
##########
@@ -654,6 +657,13 @@ class Resolver(
     val resolvedRelation = EvaluateUnresolvedInlineTable
       .evaluateUnresolvedInlineTable(withResolvedExpressions)
 
+    resolvedRelation match {

Review Comment:
   I would omit these changes for now, single-pass resolver is not enabled in 
tests yet.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/EvaluateUnresolvedInlineTable.scala:
##########
@@ -105,6 +141,28 @@ object EvaluateUnresolvedInlineTable extends SQLConfHelper
     }
   }
 
+  /**
+   * Returns whether the resolved expression can be evaluated by itself when 
the query runs.
+   * Aggregate, window and generator functions are not meaningful in a VALUES 
list. Outer
+   * references and subqueries other than uncorrelated scalar subqueries are 
not supported, and
+   * neither are the remaining unevaluable expressions, such as SQL and Python 
UDFs, which would
+   * have to be rewritten into separate operators.
+   */
+  private def isRuntimeEvaluable(e: Expression): Boolean = {

Review Comment:
   Could we do:
   ```
   e.eval() match {
     case null => false
     case other => true
   ```
   instead?



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