You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2018/12/23 00:31:00 UTC
[GitHub] dongjoon-hyun commented on a change in pull request #23373:
[SPARK-14023][CORE][SQL] Don't reference 'field' in StructField errors for
clarity in exceptions
dongjoon-hyun commented on a change in pull request #23373: [SPARK-14023][CORE][SQL] Don't reference 'field' in StructField errors for clarity in exceptions
URL: https://github.com/apache/spark/pull/23373#discussion_r243749697
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
##########
@@ -301,8 +300,8 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
def fieldIndex(name: String): Int = {
nameToIndex.getOrElse(name,
throw new IllegalArgumentException(
- s"""Field "$name" does not exist.
- |Available fields: ${fieldNames.mkString(", ")}""".stripMargin))
+ s""""$name" does not exist.
+ |Available: ${fieldNames.mkString("\"", "\", \"", "\"")}""".stripMargin))
Review comment:
Can we keep the original form instead of adding additional `"` here?
```scala
scala> val s = org.apache.spark.sql.types.StructType.fromDDL("`\"` INT")
s: org.apache.spark.sql.types.StructType = StructType(StructField(",IntegerType,true))
scala> s("a")
java.lang.IllegalArgumentException: "a" does not exist.
Available: """
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org