cloud-fan commented on code in PR #57311:
URL: https://github.com/apache/spark/pull/57311#discussion_r3603249254


##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala:
##########
@@ -81,6 +81,25 @@ class ResolveSessionCatalog(val catalogManager: 
CatalogManager)
     case ReplaceColumns(ResolvedV1TableIdentifier(ident), _) =>
       throw QueryCompilationErrors.unsupportedTableOperationError(ident, 
"REPLACE COLUMNS")
 
+    // Comment-only changes that touch multiple columns or a nested field (e.g.
+    // `COMMENT ON TABLE t COLUMN (a IS 'x', b IS 'y')` or `... (point.x IS 
'x')`) cannot be
+    // expressed by the single-column, top-level-only 
`AlterTableChangeColumnCommand`. Handle them
+    // with a dedicated V1 command that applies all specs at once via 
`applySchemaChanges`.
+    case a @ AlterColumns(rt @ ResolvedTable(catalog, _, table: V1Table, _), 
specs)
+        if supportsV1Command(catalog) && a.resolved && 
isMultiOrNestedCommentOnly(specs) =>

Review Comment:
   This case matches on plan *shape* (`isMultiOrNestedCommentOnly`), not on 
which syntax produced the `AlterColumns` — so it also catches the pre-existing 
`ALTER TABLE t ALTER COLUMN point.x COMMENT 'c'` and bulk `ALTER COLUMN a 
COMMENT 'x', b COMMENT 'y'` on the session catalog. Those forms build the same 
`AlterColumns` plan and previously fell through to the next case, throwing 
`UNSUPPORTED_FEATURE.TABLE_OPERATION` ("ALTER COLUMN with qualified column" / 
"in bulk"); now they succeed silently.
   
   That's probably a welcome improvement, but it's an unstated behavior change 
to an existing command (the PR describes only `COMMENT ON COLUMN`), and it 
leaves V1 `ALTER COLUMN` internally inconsistent: a nested/bulk *comment* now 
works while a nested/bulk *type/nullability/position* change on the same column 
still throws. It's also untested through the `ALTER TABLE` syntax — all 
coverage goes via `COMMENT ON TABLE ... COLUMN`.
   
   Confirm the change is intended; if so, add a test that drives it through 
`ALTER TABLE ... ALTER COLUMN` and note it in the description. If not, the 
predicate should also gate on the command origin so the ALTER TABLE path keeps 
its old error.



##########
docs/sql-ref-syntax-ddl-comment.md:
##########
@@ -0,0 +1,95 @@
+---
+layout: global
+title: COMMENT ON
+displayTitle: COMMENT ON
+license: |
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+---
+
+### Description
+
+The `COMMENT ON` statement sets or updates the comment on a database, a table, 
or
+one or more table columns. Setting the comment to `NULL` removes it.

Review Comment:
   This removal claim holds only for columns. `COMMENT ON TABLE t IS NULL` and 
`COMMENT ON DATABASE d IS NULL` go through `visitComment`, which maps a missing 
string literal to `""` — an empty comment, not removal. Scope the sentence to 
the column form:
   ```suggestion
   one or more table columns. Setting a column comment to `NULL` removes it.
   ```



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

Reply via email to