gengliangwang commented on code in PR #60588:
URL: https://github.com/apache/spark/pull/60588#discussion_r4637142539
##########
sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala:
##########
@@ -908,10 +929,10 @@ private[sql] object QueryParsingErrors extends
DataTypeErrorsBase {
messageParameters = Map.empty)
}
- def invalidTimeTravelSpec(reason: String, ctx: ParserRuleContext): Throwable
= {
+ def timeTravelTimestampReferencesColumnsError(ctx: ParserRuleContext):
Throwable = {
new ParseException(
- errorClass = "_LEGACY_ERROR_TEMP_0056",
- messageParameters = Map("reason" -> reason),
+ errorClass = "INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.COLUMN_REFERENCE",
+ messageParameters = Map("expr" -> ("\"" + SparkParserUtils.source(ctx) +
"\"")),
Review Comment:
**[P2] Design: COLUMN_REFERENCE quotes `<expr>` by hand instead of using
quoteByDefault**
`timeTravelTimestampReferencesColumnsError` builds its parameter as `"\"" +
SparkParserUtils.source(ctx) + "\""`. That string concatenation is exactly
`DataTypeErrorsBase.quoteByDefault` (DataTypeErrorsBase.scala:103, `"\"" + elem
+ "\""`). QueryParsingErrors extends DataTypeErrorsBase and can call it; the
method is `protected[sql]` and QueryParsingErrors is in
org.apache.spark.sql.errors.
The sibling subconditions of the same parent,
`INVALID_TIME_TRAVEL_TIMESTAMP_EXPR.{INPUT, UNEVALUABLE, NON_DETERMINISTIC}`,
get `<expr>` from `toSQLExpr` (QueryCompilationErrors.scala:4191), which is
`quoteByDefault(toPrettySQL(e))` (QueryErrorsBase.scala:50-51). No other method
in QueryParsingErrors quotes by hand; they all go through the `toSQL*` helpers
(lines 100, 377, 674, 902).
Fix: write `"expr" -> quoteByDefault(SparkParserUtils.source(ctx))`.
**Why it matters:** The parameter for this condition would be quoted
separately from the shared quoting helper used for its sibling subconditions.
If Spark changes how `<expr>` values are quoted, this subcondition silently
drifts and renders differently from the other
INVALID_TIME_TRAVEL_TIMESTAMP_EXPR messages.
--
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]