Skip to content

Fix name tracker (#19856)#20539

Merged
alamb merged 1 commit intoapache:branch-52from
hareshkh:backport-19856
Feb 25, 2026
Merged

Fix name tracker (#19856)#20539
alamb merged 1 commit intoapache:branch-52from
hareshkh:backport-19856

Conversation

@hareshkh
Copy link
Contributor

The previous implementation used UUID-based aliasing as a workaround to prevent duplicate names for literals in Substrait plans. This approach had several drawbacks:

  • Non-deterministic plan names that made testing difficult (requiring UUID regex filters)

  • Only addressed literal naming conflicts, not the broader issue of name deduplication

  • Added unnecessary dependency on the uuid crate

  • Didn't properly handle cases where the same qualified name could appear with different schema representations

    1. Enhanced NameTracker: Refactored to detect two types of conflicts:
  • Duplicate schema names: Tracked via schema_name() to prevent validate_unique_names failures (e.g., two Utf8(NULL) literals)

  • Ambiguous references: Tracked via qualified_name() to prevent DFSchema::check_names failures when a qualified field (e.g., left.Utf8(NULL)) and unqualified field (e.g., Utf8(NULL)) share the same column name

  1. Removed UUID dependency: Eliminated the uuid crate from datafusion/substrait
  2. Removed literal-specific aliasing: The UUID-based workaround in project_rel.rs is no longer needed as the improved NameTracker handles all naming conflicts consistently
  3. Deterministic naming: Name conflicts now use predictable __temp__N suffixes instead of random UUIDs

Note: This doesn't fully fix all the issues in #17508 which allow some special casing of CAST which are not included here.

Yes:

  • Updated snapshot tests to reflect the new deterministic naming (e.g., Utf8("people")__temp__0 instead of UUID-based names)
  • Modified some roundtrip tests to verify semantic equivalence (schema matching and execution) rather than exact string matching, which is more robust
  • All existing integration tests pass with the new naming scheme

Minimal. The generated plan names are now deterministic and more readable (using __temp__N suffixes instead of UUIDs), but this is primarily an internal representation change. The functional behavior and query results remain unchanged.

Which issue does this PR close?

  • Closes #.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

- Closes apache#17508

The previous implementation used UUID-based aliasing as a workaround to
prevent duplicate names for literals in Substrait plans. This approach
had several drawbacks:
- Non-deterministic plan names that made testing difficult (requiring
UUID regex filters)
- Only addressed literal naming conflicts, not the broader issue of name
deduplication
- Added unnecessary dependency on the `uuid` crate
- Didn't properly handle cases where the same qualified name could
appear with different schema representations

  1. Enhanced NameTracker: Refactored to detect two types of conflicts:
- Duplicate schema names: Tracked via schema_name() to prevent
validate_unique_names failures (e.g., two Utf8(NULL) literals)
- Ambiguous references: Tracked via qualified_name() to prevent
DFSchema::check_names failures when a qualified field (e.g.,
left.Utf8(NULL)) and unqualified field (e.g., Utf8(NULL)) share the same
column name
2. **Removed UUID dependency**: Eliminated the `uuid` crate from
`datafusion/substrait`
3. **Removed literal-specific aliasing**: The UUID-based workaround in
`project_rel.rs` is no longer needed as the improved NameTracker handles
all naming conflicts consistently
4. **Deterministic naming**: Name conflicts now use predictable
`__temp__N` suffixes instead of random UUIDs

Note: This doesn't fully fix all the issues in apache#17508 which allow some
special casing of `CAST` which are not included here.

Yes:
- Updated snapshot tests to reflect the new deterministic naming (e.g.,
`Utf8("people")__temp__0` instead of UUID-based names)
- Modified some roundtrip tests to verify semantic equivalence (schema
matching and execution) rather than exact string matching, which is more
robust
- All existing integration tests pass with the new naming scheme

Minimal. The generated plan names are now deterministic and more
readable (using `__temp__N` suffixes instead of UUIDs), but this is
primarily an internal representation change. The functional behavior and
query results remain unchanged.
@github-actions github-actions bot added the substrait Changes to the substrait crate label Feb 25, 2026
Copy link
Contributor

@gabotechs gabotechs left a comment

Choose a reason for hiding this comment

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

As original reviewer of this PR, this looks correct 👍

@alamb
Copy link
Contributor

alamb commented Feb 25, 2026

Security audit CI failure is not related to this PR

I made a separate PR to fix that

@alamb alamb merged commit 4aa7071 into apache:branch-52 Feb 25, 2026
30 of 31 checks passed
comphead pushed a commit that referenced this pull request Feb 25, 2026
…0546)

## Which issue does this PR close?

- Part of #20287

## Rationale for this change

The security audit CI check [failed
here](https://github.com/apache/datafusion/actions/runs/22381549301/job/64783156671?pr=20539)
on
- #20539

This is due to some dependencies being yanked (aws-smithy specifically)

## What changes are included in this PR?

Let's update the relevant dependencies with small security related fixes

## Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants