Skip to content

Conversation

crepererum
Copy link

@crepererum crepererum commented Jun 27, 2025

Tracking issue: https://github.com/influxdata/influxdb_iox/issues/14640

Patches

Patches map to commits 1:1 (i.e. every patch is exactly 1 commit) and are ordered for easier correlation of the description and the respective commits. They are also grouped in 3 stages.

A: Dummy

No actual patches, can be dropped at any point:

  1. a dummy patch just to get "a diff" to the base branch

B: CI Fixes

Need to get CI up and running before picking any actual patches:

None!

All commits afterwards should build cleanly!

C: Patches

These are the actual relevant patches:

  1. chore: default=true for skip_physical_aggregate_schema_check, and add warn logging:
    until we chase down all warnings in our iox logs (see https://github.com/influxdata/influxdb_iox/issues/12404 )
  2. (New) Test + workaround for SanityCheck plan:
    according to this slack thread, we can drop this with DataFusion version 49.
  3. chore: skip order calculation / exponential planning:
    workaround for Exponential planning time (100s of seconds) with UNION and ORDER BY queries apache/datafusion#13748 -- which should be fixed in DataFusion version 49
  4. fix: temporary fix to handle incorrect coalesce (inserted during EnforceDistribution) which later causes an error during EnforceSort (without our patch). The next DataFusion version 46 upgrade does the proper fix, which is to not insert the coalesce in the first place.:
    There is EAR-5822 (also see https://github.com/influxdata/influxdb_iox/issues/13310 ) despite what the note in Patched DataFusion version 45.0.0 #54 and ParallelizeSorts, a subrule of EnforceSorting optimizer, should not remove necessary coalesce. apache/datafusion#14691 (comment) say, this is still required for DF version 46. Otherwise the regression test fails. Also see this slack thread.
  5. fix: reserved keywords in qualified column names:
    That's fix: reserved keywords in qualified column names apache/datafusion#16584 . Can be dropped with DF 49.

…rceDistribution) which later causes an error during EnforceSort (without our patch). The next DataFusion version 46 upgrade does the proper fix, which is to not insert the coalesce in the first place.

test: recreating the iox plan:
* demonstrate the insertion of coalesce after the use of column estimates, and the removal of the test scenario's forcing of rr repartitioning

test: reproducer of SanityCheck failure after EnforceSorting removes the coalesce added in the EnforceDistribution

fix: special case to not remove the needed coalesce
@crepererum crepererum force-pushed the upgrade-df-ver4700-a branch from e6e3a8b to 0b003c3 Compare July 1, 2025 15:20
Comment on lines +2352 to +2357
/// Same as [`repartitions_for_aggregate_after_sorted_union`], but adds a projection
/// as well between the union and aggregate. This change the outcome:
///
/// * we no longer get repartitioning, and instead get coalescing.
#[test]
fn coalesces_for_aggregate_after_sorted_union_projection() -> Result<()> {
Copy link
Collaborator

@wiedld wiedld Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crepererum -- in follow up to our chat earlier today.

Some context behind this test case, vs the test in iox. And how the DF patch relates to the EAR.

  1. we had an EAR:
  2. I made an iox reproducer:
  3. using the iox reproducer, I then made the closest DF reproducers.
    • using the iox influxQL query, I determined the plan changes for the EnforceDistribution and EnforceSorting passes.
    • I made unit test cases in the DF optimizers, to reproduce these changes.
      • EnforceDistribution:
        • a CoalesceExec was added, but only for a very specific input plan.
        • the test case coalesces_for_aggregate_after_sorted_union_projection shows the inserted CoalesceExec.
      • EnforceSort:
        • Coalesce is removed, leading to the same error as the EAR: f792cfa

.

** NOTE THAT THE IOX REPRODUCER IS NOT THE SAME AS THE DATAFUSION REPRODUCER.**

  1. the unit tests for EnforceDistribution are outdated.

.

If the iox InfluxQL reproducer still requires the DF patch (adding if is_coalesce_partitions(&children[0].plan) && !is_aggregation(plan) to the EnforceSorting), then we still have the bug. Either in the iox plans we produce, or in the DataFusion optimizers.

Copy link
Collaborator

@wiedld wiedld Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also recommend removing the old unit tests for EnforceDistribution.

The goal of those unit tests were:

  • (a) to demonstrate why the EAR error was inconsistent. It was inconsistent because it only occurred when our data layout created a very specific plan. (I mention this inconsistency in the EAR: https://github.com/influxdata/EAR/issues/5822#issuecomment-2616886813).
  • (b) to make a DF reproducer with the minimal plan needed. (vs the iox reproducer which is the minimal InfluxQL needed).

Copy link
Collaborator

@wiedld wiedld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this patched DF branch (with all green tests ❤️) .

I added a bit of history as an FYI only. No changes needed!

In your next DF upgrade branch (not this one), feel free to drop any outdated unit tests which no longer reflect the plans generated by the iox reproducer.

@alamb
Copy link
Collaborator

alamb commented Jul 3, 2025

I like that the number of patches required in DF 47 is significantly smaller than it was in DF 46

@crepererum
Copy link
Author

no longer needed

@crepererum crepererum closed this Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants