raviston commented on code in PR #60588:
URL: https://github.com/apache/spark/pull/60588#discussion_r4596487177
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -2873,7 +2873,7 @@ class AstBuilder extends DataTypeAstBuilder
}
val bytesStr = ctx.bytes.getText
if (bytesStr.matches("[0-9]+[bBkKmMgG]")) {
- throw
QueryParsingErrors.tableSampleByBytesUnsupportedError("byteLengthLiteral", ctx)
+ throw QueryParsingErrors.tableSampleByBytesUnsupportedError("BYTES",
ctx)
} else {
throw QueryParsingErrors.invalidByteLengthLiteralError(bytesStr, ctx)
Review Comment:
`getText` joins the tokens without the whitespace between them, so `SELECT *
FROM t TABLESAMPLE(CAST(1 AS INT))` now says `TABLESAMPLE (CAST(1ASINT)) is not
a valid sampling method`. Since the message now shows it as the sampling method
the user wrote, could this use the source text, as
`timeTravelTimestampReferencesColumnsError` does?
```suggestion
throw
QueryParsingErrors.invalidByteLengthLiteralError(source(ctx.bytes), ctx)
```
The `pipe-operators.sql` golden file is unchanged with this (its value is
`200`). A test for it in `PlanParserSuite` "sampled relations" could be:
```scala
val sql5 = "SELECT * FROM t TABLESAMPLE(CAST(1 AS INT))"
checkError(
exception = parseException(sql5),
condition = "INVALID_SQL_SYNTAX.INVALID_TABLESAMPLE_METHOD",
sqlState = "42000",
parameters = Map("sampleMethod" -> "CAST(1 AS INT)"),
context = ExpectedContext(
fragment = "TABLESAMPLE(CAST(1 AS INT))",
start = 16,
stop = 42))
```
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala:
##########
@@ -1496,11 +1496,9 @@ class DDLParserSuite extends AnalysisTest {
val sql4 = "ALTER TABLE table_name CHANGE COLUMN a.b.c new_name INT"
checkError(
exception = parseException(sql4),
- condition = "_LEGACY_ERROR_TEMP_0034",
- parameters = Map(
- "operation" -> "Renaming column",
- "command" -> "ALTER COLUMN",
- "msg" -> ", please run RENAME COLUMN instead"),
+ condition = "UNSUPPORTED_CHANGE_COLUMN.RENAME",
Review Comment:
`UNSUPPORTED_CHANGE_COLUMN.NOT_NULL` is reachable but has no test. Could you
add one here?
```scala
val sqlNotNull = "ALTER TABLE table_name CHANGE COLUMN a.b.c c INT NOT
NULL"
checkError(
exception = parseException(sqlNotNull),
condition = "UNSUPPORTED_CHANGE_COLUMN.NOT_NULL",
sqlState = "0A000",
parameters = Map.empty,
context = ExpectedContext(
fragment = sqlNotNull,
start = 0,
stop = 56))
```
--
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]