peter-toth commented on code in PR #60009:
URL: https://github.com/apache/spark/pull/60009#discussion_r4617299645
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala:
##########
@@ -755,7 +769,9 @@ case class FileSourceScanExec(
override val tableIdentifier: Option[TableIdentifier],
override val disableBucketedScan: Boolean = false,
override val markedForSingleTaskExecution: Boolean = false,
- override val storageFilters: Seq[Expression] = Nil)
+ override val storageFilters: Seq[Expression] = Nil,
+ override val bucketingEnabled: Boolean,
Review Comment:
**Finding 4.** The planned decision can live in the existing
`disableBucketedScan` field. SPARK-60260 did it this way for `BatchScanExec`:
`DataSourceV2Strategy` filters the existing `keyGroupedPartitioning` field at
planning, and the scan reads no config, so its signature did not change. Here
that is:
```scala
// FileSourceStrategy
disableBucketedScan = fsRelation.bucketSpec.isDefined &&
!SQLConf.get.bucketingEnabled,
```
```scala
// FileSourceScanLike.bucketedScan
lazy val bucketedScan: Boolean = {
if (relation.bucketSpec.isDefined && !disableBucketedScan) {
```
`DisableUnnecessaryBucketedScan` stays as in this PR, without the live gate.
What it saves:
- `FileSourceScanExec` keeps its signature. The two new fields have no
defaults and come after the defaulted ones, so every constructor call and every
positional extractor of the node has to change, as the three test files here
show. Code outside Spark matches on this node too.
- The canonical form of a non-bucketed scan does not change, so finding 1
cannot come up, and `isBucketedRelation` is not needed.
- A bucketed scan that the planner disabled and one planned with bucketing
off read the same way, and with this they also canonicalize the same, both with
`disableBucketedScan = true`. In this PR they differ.
- Without a signature change, the fix can be backported to branch-4.1.
What I ran: the change above on this PR's merge base, with the four new
`BucketedReadSuite` tests. The canonical-form test plans each scan under the
config instead of using `copy(bucketingEnabled = ...)`. All four pass. Without
the change, the zip test and the canonical-form test fail, as on master. With
the live gate back in `DisableUnnecessaryBucketedScan`, its test fails, so that
part of this PR is needed either way. `BucketedReadWithoutHiveSupportSuite`,
both `DisableUnnecessaryBucketedScan` suites, `CoalesceBucketsInJoinSuite`,
both `ExplainSuite`s, `SameResultSuite`, `SparkPlanSuite`, both
`DynamicPartitionPruningV1` suites, `DataFrameJoinSuite` and `SubquerySuite`
pass, 361 tests.
Two reads of the live config stay, as on master:
- The explain label. A scan planned with bucketing off and explained after
it is turned back on says "disabled by query planner" instead of "disabled by
configuration".
- The bucket pruning in `createReadRDD`. It only changes which files are
read, since the filters stay above the scan.
--
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]