Skip to content

Conversation

@itholic
Copy link
Contributor

@itholic itholic commented Nov 15, 2022

What changes were proposed in this pull request?

This PR proposes to assign a name to _LEGACY_ERROR_TEMP_1042.

Thus, in this PR we integrate _LEGACY_ERROR_TEMP_1042 into DATATYPE_MISMATCH.WRONG_NUM_ARGS since it's duplicated.

Why are the changes needed?

The legacy error classes were temporary named to cover the all exceptions by error class, so we should assign the proper name on those all legacy error classes.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

./build/sbt “sql/testOnly org.apache.spark.sql.SQLQueryTestSuite*”

Copy link
Member

@MaxGekk MaxGekk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a duplicate of DATATYPE_MISMATCH.WRONG_NUM_ARGS. Can't you re-use it?

@itholic
Copy link
Contributor Author

itholic commented Nov 15, 2022

Sure, let me integrate into DATATYPE_MISMATCH.WRONG_NUM_ARGS

@itholic itholic marked this pull request as draft November 16, 2022 03:17
@itholic itholic changed the title [SPARK-41147][SQL] Assign a name to the legacy error class _LEGACY_ERROR_TEMP_1042 [WIP][SPARK-41147][SQL] Assign a name to the legacy error class _LEGACY_ERROR_TEMP_1042 Nov 16, 2022
@itholic itholic marked this pull request as ready for review November 16, 2022 06:54
@itholic itholic changed the title [WIP][SPARK-41147][SQL] Assign a name to the legacy error class _LEGACY_ERROR_TEMP_1042 [SPARK-41147][SQL] Assign a name to the legacy error class _LEGACY_ERROR_TEMP_1042 Nov 16, 2022
.map(_.getParameterCount).distinct.sorted
throw QueryCompilationErrors.invalidFunctionArgumentNumberError(
validParametersCount, name, params.length)
expressions.map(toPrettySQL(_)).mkString(","),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pass Seq[Expression] into invalidFunctionArgumentNumberError(), and form a string inside of the method as we do in other places like:

  def moreThanOneGeneratorError(generators: Seq[Expression], clause: String): Throwable = {
    new AnalysisException(
      errorClass = "UNSUPPORTED_GENERATOR.MULTI_GENERATOR",
      messageParameters = Map(
        "clause" -> clause,
        "num" -> generators.size.toString,
        "generators" -> generators.map(toSQLExpr).mkString(", ")))
  }

For instance, if we change the implementation of toSQLExpr(), your exceptions won't pick up new impl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Just addressed it.

@itholic
Copy link
Contributor Author

itholic commented Nov 24, 2022

Thanks for the review, @MaxGekk
Just addressed the comments!

"expectedNum" : "2",
"functionName" : "`decode`"
"functionName" : "`decode`",
"sqlExpr" : "\"encode(abc, utf-8)\""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message confuses slightly:

"Cannot resolve "encode(abc, utf-8)" due to data type mismatch:"

Actually, the issue is not in encode but in decode. sqlExpr should point out to the parent expression. @itholic Could you change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me handle it. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. Ping me when you finish this.

@github-actions github-actions bot removed the CORE label Nov 29, 2022
new AnalysisException(
errorClass = "WRONG_NUM_ARGS",
messageParameters = Map(
"sqlExpr" -> sqlExpr.map(toSQLExpr(_)).mkString(","),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed anymore. Could you remove it, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, seems like it's duplicated to #38707 ?

Can we just close this ticket ?

@itholic
Copy link
Contributor Author

itholic commented Dec 8, 2022

Closing since it's duplicated to #38707

@itholic itholic closed this Dec 8, 2022
@itholic itholic deleted the SPARK-41147 branch April 22, 2023 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants