cloud-fan commented on code in PR #60025: URL: https://github.com/apache/spark/pull/60025#discussion_r4535445446
########## docs/sql-migration-guide.md: ########## @@ -24,6 +24,7 @@ license: | ## Upgrading from Spark SQL 4.4 to 5.0 +- Since Spark 5.0, when `spark.sql.cbo.enabled` is `true`, the optimizer estimates plans over analyzed `CHAR` columns from their column statistics, as it does for `STRING` columns. Since Spark 3.4, read-side `CHAR` padding (`spark.sql.readSideCharPadding`, `true` by default) hid these statistics, so, for example, a filter on a `CHAR` partition column was estimated to keep every row. The estimate assumes evenly distributed values, so for a skewed partition it can now be smaller than the data, and the pruned relation can become small enough to be broadcast. This also applies to partition pruning when only `spark.sql.cbo.planStats.enabled` is `true`. Review Comment: **Nit (P3):** This entry says, with no condition on the CHAR/VARCHAR semantics setting, that CBO now estimates analyzed `CHAR` columns from their statistics as it does for `STRING` columns. That does not hold when `spark.sql.charVarchar.standardSemantics.enabled` is `true`: `addPaddingForScan` then wraps CHAR columns in `charTypeReadSideCheck`, which `ReadSidePadding` deliberately does not match, so from reading the code `getAliasStats` and `calculateSingleCondition` still lose their statistics, as the `TODO(SPARK-60830)` in `getAliasStats` says. `spark.sql.readSideCharPadding`, which the entry names as the cause, is ignored in that mode, so a user who has turned on the standard-semantics preview reads this as promising the new estimates and the partition-pruning and broadcast changes it describes, and gets neither. The two existing 4.4 entries about the same padding wrapper (JDBC CHAR pushdown and the `IS [NOT] NULL` unwrap) scope themselves to `spark.sql.charVarchar.standardSema ntics.enabled` being false for the same reason. One added sentence would cover it: ```suggestion - Since Spark 5.0, when `spark.sql.cbo.enabled` is `true`, the optimizer estimates plans over analyzed `CHAR` columns from their column statistics, as it does for `STRING` columns. Since Spark 3.4, read-side `CHAR` padding (`spark.sql.readSideCharPadding`, `true` by default) hid these statistics, so, for example, a filter on a `CHAR` partition column was estimated to keep every row. The estimate assumes evenly distributed values, so for a skewed partition it can now be smaller than the data, and the pruned relation can become small enough to be broadcast. This also applies to partition pruning when only `spark.sql.cbo.planStats.enabled` is `true`. None of this applies yet when `spark.sql.charVarchar.standardSemantics.enabled` is `true`, under which `CHAR` columns keep their previous estimates. ``` **Verification:** - **Inspection:** The migration guide entry about CHAR column statistics under spark.sql.cbo.enabled states that it does not apply when spark.sql.charVarchar.standardSemantics.enabled is true, and still names spark.sql.cbo.planStats.enabled for the partition-pruning case. -- 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]
