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