spark-test commented on code in PR #60169: URL: https://github.com/apache/spark/pull/60169#discussion_r4505001178
########## sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ShowCommandHelper.scala: ########## @@ -0,0 +1,63 @@ +/* + * 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. + */ + +package org.apache.spark.sql.catalyst.analysis + +import org.apache.spark.sql.catalyst.SQLConfHelper +import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, ShowFunctions, ShowTables, ShowTablesExtended, ShowViews} +import org.apache.spark.sql.connector.catalog.ViewCatalog +import org.apache.spark.sql.errors.QueryCompilationErrors +import org.apache.spark.sql.execution.command.{ShowFunctionsCommand, ShowTablesCommand, ShowViewsCommand} +import org.apache.spark.sql.internal.SQLConf + +/** Lowers session-catalog SHOW commands, e.g. `SHOW VIEWS IN db` to [[ShowViewsCommand]]. */ Review Comment: **Nit (P3):** This doc reads as covering every session-catalog SHOW command, but `rewrite` lowers only SHOW TABLES, SHOW TABLE EXTENDED, SHOW VIEWS and SHOW FUNCTIONS and returns any other plan unchanged through `case _ => command`. `ResolveSessionCatalog` still lowers SHOW TABLE EXTENDED ... PARTITION, SHOW CREATE TABLE, SHOW PARTITIONS, SHOW COLUMNS and SHOW TBLPROPERTIES itself, so a caller going by this doc would get, say, a session-catalog `ShowPartitions` back un-lowered with no error. `DropTableHelper`, `ViewCommandHelper` and `CreateTableHelper` each name the commands they handle; naming the four here, with a note in the `rewrite` doc that every other plan is returned unchanged, would match them. For example: ```suggestion /** * Lowers session-catalog SHOW TABLES, SHOW TABLE EXTENDED, SHOW VIEWS and SHOW FUNCTIONS, e.g. * `SHOW VIEWS IN db` to [[ShowViewsCommand]]. Other SHOW commands are not handled here. */ ``` **Verification:** - **Inspection:** The ShowCommandHelper object and rewrite docs list exactly the commands that the cases of rewrite lower and say that every other plan is returned unchanged. That list must match the four SHOW types ResolveSessionCatalog sends to the helper. ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/KeepLegacyOutputs.scala: ########## @@ -45,4 +44,19 @@ object KeepLegacyOutputs extends Rule[LogicalPlan] { } } } + + /** Applies the legacy SHOW TABLES schema without changing output expression IDs. */ Review Comment: **Nit (P3):** This says the method applies the legacy SHOW TABLES schema, but it does so only when `spark.sql.legacy.keepCommandOutputSchema` is enabled; under the default it returns `showTables` unchanged and the first column stays `namespace`. That gate is what separates it from `withLegacyShowTablesDatabaseColumn` below, which renames unconditionally, so a caller reusing these helpers can't tell from the docs which one to call. For example: ```suggestion /** * Applies the legacy SHOW TABLES schema, keeping output expression IDs, when * `spark.sql.legacy.keepCommandOutputSchema` is enabled; otherwise returns the plan unchanged. */ ``` **Verification:** - **Inspection:** The doc comment on keepLegacyShowTablesOutput names the spark.sql.legacy.keepCommandOutputSchema condition and says the plan is returned unchanged when that setting is off. It must also agree with the method body and with the doc of the unconditional rename helper. -- 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]
