Uroš Bojanić created SPARK-58711:
------------------------------------
Summary: Use StructType.getFieldIndex in Parquet and ORC aggregate
push down
Key: SPARK-58711
URL: https://issues.apache.org/jira/browse/SPARK-58711
Project: Spark
Issue Type: Improvement
Components: SQL
Affects Versions: 4.3.0
Reporter: Uroš Bojanić
The aggregate push down paths look up a column position with
dataSchema.fieldNames.indexOf(name). fieldNames is a def that allocates a fresh
Array on every call, and the Parquet variant additionally converts it to a
List, so each lookup allocates twice and then scans linearly.
StructType.getFieldIndex reads a cached name to index map instead.
This switches the three Parquet sites and the one ORC site to getFieldIndex,
and replaces a partitionSchema.fields.map(_.name).toSet.contains check, which
built a set per call, with getFieldIndex(...).isDefined.
This is a readability and allocation cleanup rather than a measurable speedup:
aggregate push down is off by default and the surrounding work reads Parquet or
ORC footer statistics, which dominates.
Behavior is unchanged. getOrElse(-1) matches the not-found contract of indexOf,
and the exact-match variant is used rather than the case-insensitive one. The
two forms would differ only for a schema with duplicate column names, where
indexOf returns the first match and a name keyed map the last; FileTable
rejects duplicate column names in both schemas before a scan is built, so that
case is unreachable.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]