spark-test commented on code in PR #60059: URL: https://github.com/apache/spark/pull/60059#discussion_r4509923767
########## docs/sql-migration-guide.md: ########## @@ -52,6 +52,7 @@ license: | - Since Spark 4.4, the Oracle JDBC datasource maps bare `NUMBER` columns (declared without explicit precision or scale) to `DecimalType(38, 18)` instead of `DecimalType(38, 10)`. This uses `DecimalType.DEFAULT_SCALE` and preserves up to 18 fractional digits instead of 10, reducing silent precision loss. However, the integer range shrinks from 28 to 20 digits; bare `NUMBER` values with more than 20 integer digits that previously read correctly will raise `NUMERIC_VALUE_OUT_OF_RANGE`. The same change applies to Oracle `FLOAT` columns, which JDBC reports as `NUMERIC` with `scale = -127`. Columns with explicit `NUMBER(p,s)` are not affected. To restore the previous `DecimalType(38, 10)` mapping, set `spark.sql.legacy.oracle.numberMapping.enabled` to `true`. - Since Spark 4.4, when `spark.sql.charVarchar.standardSemantics.enabled` is false and `spark.sql.readSideCharPadding` is true (the default), JDBC Data Source V2 catalog tables on H2, PostgreSQL, SQL Server, and Oracle push CHAR equality, inequality, null-safe equality, and `IN`/`NOT IN`. In 4.3 the default read-side padding wrap kept those filters in Spark. Pushed predicates use the remote collation, so a case-insensitive SQL Server collation can match a stored `'ABC'` with `flag = 'abc'` while a Spark-local comparison would not. The V1 path (`spark.read.jdbc` and `USING jdbc`) still evaluates these CHAR filters in Spark. PostgreSQL's internal `"char"` type (JDBC type name `char`) is mapped to `STRING` instead of `CHAR(1)`, so Spark no longer blank-pads its empty value. - Since Spark 4.4, when `spark.sql.charVarchar.standardSemantics.enabled` is false and `spark.sql.readSideCharPadding` is true (the default), `IS [NOT] NULL` over a CHAR scan column is unwrapped to the raw column for every Data Source V2 source, including every JDBC dialect. Previously the padding wrap kept that null check in Spark. +- Since Spark 4.4, a CHAR/VARCHAR column of the outer query that a LATERAL or correlated subquery returns keeps its CHAR/VARCHAR type, as an inner column does. Previously it became `STRING`: comparisons against it were not padded and could silently return no rows, and CTAS and views over it stored `STRING`. Inside a LATERAL subquery this affected `t.c AS k`, `t.c` and `t.*` in all earlier versions; in other correlated subqueries it affected `t.c AS k` in all earlier versions, `t.*` since Spark 4.2 and `t.c` since Spark 4.3. A table created with CTAS over such a column now gets `CHAR(n)`/`VARCHAR(n)`, so later inserts are length-checked (`EXCEED_LIMIT_LENGTH`) and CHAR values are padded. To keep `STRING`, cast the column in the query, for example `CAST(t.c AS STRING) AS k`. Permanent views created by an earlier version keep the `STRING` type they stored, so comparisons against a CHAR column of such a view still return no rows until the view is recreated with `CREATE OR REPLACE VIEW` or `ALTER VIEW ... AS`. Views created `WITH SCHEMA EVOLUTION` are the exception: they take the CHAR/VARCHAR type from their query on the first read after the upgrade, although `DESCRIBE` still shows the stored `STRING`. Review Comment: **Nit (P3):** This clause calls the affected column "a CHAR column of such a view", but such a view has no CHAR column. As the first half of the sentence says, the view stores the column as STRING, and `DESCRIBE` reports it that way. So a user who checks an old view for CHAR columns finds none and may conclude that the view is unaffected. The clause also says these comparisons "still return no rows", but only comparisons that rely on CHAR padding miss rows: `k = 'ab'` returns nothing, while `k = 'ab '` still matches. Naming the column by where it came from and qualifying the effect fixes both, for example: "so a view column that came from an outer CHAR column is still compared without CHAR padding, and a comparison such as `k = 'ab'` can return no rows until the view is recreated with `CREATE OR REPLACE VIEW` or `ALTER VIEW ... AS`". This wording also keeps VARCHAR columns, whose comparisons are never padded, out of the caveat. **Verification:** - **Inspection:** The view caveat no longer calls the affected column a CHAR column of the view, keeps the caveat limited to view columns that came from an outer CHAR column, and presents the missed rows as a possibility for comparisons that depend on CHAR padding rather than as true of every comparison. -- 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]
