sandeep-katta commented on a change in pull request #24182: 
[SPARK-27246][SQL]scalar subquery with no columns throws exception in spark 
shell
URL: https://github.com/apache/spark/pull/24182#discussion_r268470286
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/subquery.scala
 ##########
 @@ -248,7 +248,11 @@ case class ScalarSubquery(
     children: Seq[Expression] = Seq.empty,
     exprId: ExprId = NamedExpression.newExprId)
   extends SubqueryExpression(plan, children, exprId) with Unevaluable {
-  override def dataType: DataType = plan.schema.fields.head.dataType
+  override def dataType: DataType = if (!plan.schema.fields.isEmpty) {
+    plan.schema.fields.head.dataType
+  } else {
+    NullType
 
 Review comment:
   scalar subquery should throw analysisException if no column is passed, but 
in this case it is throwing NoSuchElementException, so there is no functional 
issue, it's just an testcase issue which is using boundary condition

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to