Skip to content

[ANSI] Include original SQL in error messages #2215

@andygrove

Description

@andygrove

What is the problem the feature request solves?

Spark includes the original SQL query in error messages with hints to which part of the query failed.

scala> spark.sql("select cast('a' as date)").show()
org.apache.spark.SparkDateTimeException: [CAST_INVALID_INPUT] The value 'a' of the type "STRING" cannot be cast to "DATE" because it is malformed. Correct the value as per the syntax, or change its target type. Use `try_cast` to tolerate malformed input and return NULL instead. SQLSTATE: 22018
== SQL (line 1, position 8) ==
select cast('a' as date)

Comet does not do this:

org.apache.comet.CometNativeException: [CAST_INVALID_INPUT] The value 'a' of the type "STRING" cannot be cast to "DATE" because it is malformed. Correct the value as per the syntax, or change its target type. Use `try_cast` to tolerate malformed input and return NULL instead. If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error.

Therefore we see test failures such as:

did not contain "select cast(s as date) from t"

Example test (in ANSI mode)

SPARK-39175: Query context of Cast should be serialized to executors when WSCG is off *** FAILED ***

Describe the potential solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions