Skip to content

fix: [branch-1.2] keep Text build sides on Spark by default and add Text conversion configs (#7123) - #7205

Merged
andygrove merged 1 commit into
apache:branch-1.2from
andygrove:backport-7123-branch-1.2
Oct 26, 2026
Merged

andygrove merged 1 commit into
apache:branch-1.2from
andygrove:backport-7123-branch-1.2

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #7118.

Backport of #7123 (squash commit 2b1c6a3) to branch-1.2.

Rationale for this change

#6786 is already on branch-1.2. It made Comet convert a Text scan on a broadcast join's build side to Arrow by default, where 1.1.0 left it on Spark. Arrow strings must be valid UTF-8, so Comet replaces each ill-formed sequence with U+FFFD, and hex, length, hashing, equality and ordering over a Latin-1 Text file can then differ from Spark. Without this fix, 1.2.0 would return different results from 1.1.0 for the same query. See #7123 for the full rationale.

What changes are included in this PR?

A clean cherry-pick of #7123 with -x. The changed lines are identical to the source commit, and no file was adapted:

  • New spark.comet.convert.text.enabled (default false), so a Text scan is converted only by its own config, like CSV, JSON and Parquet. spark.comet.convert.broadcastBuildSide.enabled stays on, but a Text build side is bridged only when the Text config is set.
  • Compatibility guide, datasources.md and migration guide updates.
  • The Text-format source on a broadcast build side blocks native BroadcastHashJoin #6008 build-side tests move from CometExecSuite to CometBroadcastBuildSideSuite, and run against an ORC build side.

docs/source/user-guide/latest/configs.md on branch-1.2 still holds the CONFIG_TABLE markers rather than generated tables, so there is no row to update.

Backports to other branches: none needed. #6786 is not on branch-1.0 or branch-1.1, so neither has the behavior this fixes.

How are these changes tested?

On this branch, with Spark 4.1 (the default profile):

  • CometBroadcastBuildSideSuite and CometExecSuite ran 194 tests: 193 passed, one was canceled (a Spark 3.4-only test) and one failed. The failure is "native scan loads the next file's metadata while it reads the current file" (0 did not equal 3). It exercises perf: load the next Parquet file's footer and page index while the current file is read #7094, which merged after the libcomet I used was built, and this PR does not touch it. I did not rerun it with a freshly built library.
  • ./mvnw test-compile -Pspark-3.5,delta -Pstrict-warnings and the Scalafix CHECK run both pass.

…n configs (apache#7123)

* fix: default broadcast build side conversion to off and document invalid UTF-8 cases

Converting a Text scan on a broadcast build side to Arrow decodes invalid
UTF-8 to U+FFFD, so 1.2.0 could return different results from 1.1.0. Default
spark.comet.convert.broadcastBuildSide.enabled to false and name the
Text-source and CAST(binary AS STRING) cases in the compatibility guide.

* test: move the apache#6008 build-side tests into CometBroadcastBuildSideSuite

CometBroadcastBuildSideSuite turns the build-side bridge on for every test, so the tests no
longer need the bridgeTest helper, and a test added later cannot miss the setting. The two tests
that failed because they were not wrapped in bridgeTest now run with the bridge on, and the five
that asserted nothing was bridged now exercise the bridge again. The test bodies are unchanged.

* fix: keep Text build sides on Spark by default and add Text conversion configs

Converting a Text scan to Arrow replaces bytes that are not valid UTF-8 with U+FFFD, so
bridging a Text build side by default (apache#6786) could return different results from 1.1.0
(apache#7118). The other formats that reach the bridge either define strings as UTF-8 (ORC, Avro,
Iceberg) or are decoded by Spark, so spark.comet.convert.broadcastBuildSide.enabled goes back
to on by default, and Text gets its own configs:

- spark.comet.convert.broadcastBuildSide.text.enabled (default false) bridges a Text build
  side. Without it, the scan records a fallback reason that names the config.
- spark.comet.convert.text.enabled (default false) converts every Text scan, like the CSV,
  JSON and Parquet configs. The sparkToColumnar operator list still converts Text as before.

The compatibility guide now names Text rather than CSV and JSON, no longer says that Spark
requires Parquet strings to be valid UTF-8, adds Comet columnar shuffle as a path, and gives
the configs that keep min/max over CAST(binary AS STRING) in Spark.

* test: drop the QueryStageExec import that the test move left unused

* fix: convert a Text build side only with spark.comet.convert.text.enabled

Drop spark.comet.convert.broadcastBuildSide.text.enabled. A Text scan, on a
build side or not, is now converted only by spark.comet.convert.text.enabled,
like CSV, JSON and Parquet, and the build-side fallback reason names that
config. Text goes through isConversionEnabled, so naming FileSourceScan or
BatchScan in spark.comet.sparkToColumnar.supportedOperatorList still converts
it but is deprecated.

The apache#6008 build-side tests read ORC instead of Text, since a global Text switch
would convert their probes and no-bridge assertions too.

* docs: describe Text conversion through its own config only

Update the Text, build-side and compatibility sections for the removal of
spark.comet.convert.broadcastBuildSide.text.enabled, and note in the migration
guide that converting Text through sparkToColumnar is deprecated.

* fix: drop the unused SparkConf import and narrow the min/max workaround

The suite no longer overrides sparkConf, so its SparkConf import failed
Scalafix and the strict-warnings build. Reformat a CometExecRule comment
that Spotless rejected.

The three-config min/max workaround only keeps the decode out of the
query when the cast is the aggregate's own argument. A cast in a
projection below the aggregate runs natively and decodes first, so the
guide now says so and keeps disabling Comet as the general answer.

(cherry picked from commit 2b1c6a3)
@github-actions github-actions Bot added the bug Something isn't working label Oct 25, 2026
@andygrove
andygrove merged commit 8af6dfb into apache:branch-1.2 Oct 26, 2026
142 checks passed
@andygrove

Copy link
Copy Markdown
Member Author

Thank you for the review @manuzhang!

@andygrove
andygrove deleted the backport-7123-branch-1.2 branch October 26, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants