gengliangwang commented on code in PR #60679:
URL: https://github.com/apache/spark/pull/60679#discussion_r4620082891
##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/WritableColumnVector.java:
##########
@@ -825,19 +856,46 @@ public final int appendStruct(boolean isNull) {
* or Optional.empty() otherwise.
*/
public Optional<Integer> appendObjects(int length, Object value) {
+ boolean fillNullsAndWideDecimals = hasNullOrWideDecimal(value) &&
Review Comment:
**[P2] Design: Reader legacy-behavior flag is read via SQLConf.get() inside
the generic WritableColumnVector.appendObjects API**
The public `WritableColumnVector.appendObjects(int, Object)` method now
reads
`SQLConf.LEGACY_VECTORIZED_READER_FAIL_ON_NULL_FIELD_OR_WIDE_DECIMAL_DEFAULT`
from the executor's ambient `SQLConf.get()` (lines 859-861). That decides
whether a generic column-vector append succeeds or fails. The decision is a
Parquet/ORC reader policy, and the two readers already own the error it
produces: `ParquetColumnVector.java:92-95` and
`OrcColumnarBatchReader.java:222-225` throw "Cannot assign default column value
...".
The reader code elsewhere reads confs on the driver and passes them in:
- `ParquetFileFormat.scala:140-171` copies session confs into the Hadoop
conf.
- `VectorizedParquetRecordReader.java:274-277` reads the comparable legacy
flag `LEGACY_PARQUET_RETURN_NULL_STRUCT_IF_ALL_FIELDS_MISSING` from that conf,
not from `SQLConf.get()`.
- The ORC reader gets its settings through its constructor
(`OrcFileFormat.scala:219`, `OrcPartitionReaderFactory.scala:151`).
- No Java reader under `execution/datasources/` calls `SQLConf.get()`.
The constructor's existing `SQLConf.get()`
(`WritableColumnVector.java:1158-1159`) tunes the vector's own memory, which is
a vector concern. It is not a reader policy.
Suggested change: make the 3-arg `appendObjects(length, value,
fillNullsAndWideDecimals)` the public entry point, or keep the 2-arg version
always filling. Then let `ParquetColumnVector` and `OrcColumnarBatchReader`
apply the legacy check, using the conf they already receive from their format
or factory.
**Why it matters:** As written, the result of a generic vector method
depends on thread-local session state, through a conf named after the readers,
so every future caller of `appendObjects` gets reader-specific failure
behavior. That includes the planned map-branch fix in SPARK-60940. Reading the
conf at the vector level also skips the driver-captured conf path the readers
use, so the legacy setting may not apply where executor-side `SQLConf.get()`
sees only default values.
##########
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/WritableColumnVector.java:
##########
@@ -889,7 +947,7 @@ public Optional<Integer> appendObjects(int length, Object
value) {
appendStruct(false);
for (int j = 0; j < row.values().length; ++j) {
Object element = row.values()[j];
- if (childColumns[j].appendObjects(1, element).isEmpty()) {
+ if (childColumns[j].appendObjects(1, element,
fillNullsAndWideDecimals).isEmpty()) {
Review Comment:
**[P0] Reject mixed NULL/map defaults until map lengths are fixed**
The new NULL support makes the existing map corruption reachable for
defaults that previously failed. For a struct containing a NULL sibling and an
ordinary two-entry map, this recursive call now succeeds for both fields. The
map receives length=1, and its branch calls appendArray(length), recording one
entry while appending both keys and values. getMap() uses that recorded length,
so the second entry silently disappears. Passing false to map-entry recursion
does not prevent this because ordinary entries remain supported. Preserve the
old failure for these mixed defaults until map population is corrected.
**Failure scenario:** With vectorized ORC reads enabled: CREATE TABLE t(id
INT) USING ORC; INSERT INTO t VALUES (1); ALTER TABLE t ADD COLUMN s
STRUCT<n:INT,m:MAP<STRING,INT>> DEFAULT named_struct('n', CAST(NULL AS INT),
'm', map('a', 1, 'b', 2)); SELECT s FROM t; returns {NULL, {'a':1}} instead of
{NULL, {'a':1,'b':2}}. Before this change, the NULL field caused the read to
fail.
--
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]