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 2022/11/04 07:31:54 UTC
[GitHub] [spark] MaxGekk commented on a diff in pull request #38498: [SPARK-40769][CORE][SQL] Migrate type check failures of aggregate expressions onto error classes
MaxGekk commented on code in PR #38498:
URL: https://github.com/apache/spark/pull/38498#discussion_r1013693767
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Count.scala:
##########
@@ -56,9 +59,17 @@ case class Count(children: Seq[Expression]) extends DeclarativeAggregate {
override def checkInputDataTypes(): TypeCheckResult = {
if (children.isEmpty && !SQLConf.get.getConf(SQLConf.ALLOW_PARAMETERLESS_COUNT)) {
- TypeCheckResult.TypeCheckFailure(s"$prettyName requires at least one argument. " +
- s"If you have to call the function $prettyName without arguments, set the legacy " +
- s"configuration `${SQLConf.ALLOW_PARAMETERLESS_COUNT.key}` as true")
+ DataTypeMismatch(
+ errorSubClass = "WRONG_NUM_ARGS_WITH_SUGGESTION",
+ messageParameters = Map(
+ "functionName" -> toSQLId(prettyName),
+ "expectedNum" -> " >= 1",
+ "actualNum" -> "0",
+ "legacyNum" -> "0",
+ "legacyConfKey" -> SQLConf.ALLOW_PARAMETERLESS_COUNT.key,
Review Comment:
Please, use `toSQLConf()` to quote the config.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Count.scala:
##########
@@ -56,9 +59,17 @@ case class Count(children: Seq[Expression]) extends DeclarativeAggregate {
override def checkInputDataTypes(): TypeCheckResult = {
if (children.isEmpty && !SQLConf.get.getConf(SQLConf.ALLOW_PARAMETERLESS_COUNT)) {
- TypeCheckResult.TypeCheckFailure(s"$prettyName requires at least one argument. " +
- s"If you have to call the function $prettyName without arguments, set the legacy " +
- s"configuration `${SQLConf.ALLOW_PARAMETERLESS_COUNT.key}` as true")
+ DataTypeMismatch(
+ errorSubClass = "WRONG_NUM_ARGS_WITH_SUGGESTION",
+ messageParameters = Map(
+ "functionName" -> toSQLId(prettyName),
+ "expectedNum" -> " >= 1",
+ "actualNum" -> "0",
+ "legacyNum" -> "0",
+ "legacyConfKey" -> SQLConf.ALLOW_PARAMETERLESS_COUNT.key,
+ "legacyConfValue" -> true.toString
Review Comment:
`true` should be quoted by `""`, see `error-classes.json`. For instance,
https://github.com/apache/spark/blob/5741d38ee272418a919fe7d102514c221a6e741a/core/src/main/resources/error/error-classes.json#L10
I would add new helper `toSQLConfVal()` like:
```scala
def toSQLConfVal(conf: String): String = {
quoteByDefault(conf)
}
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org