Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion-testing
10 changes: 10 additions & 0 deletions datafusion/common/src/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ impl AliasGenerator {
Self::default()
}

/// Advance the counter to at least `min_id`, ensuring future aliases
/// won't collide with already-existing ones.
///
/// For example, if the query already contains an alias `alias_42`, then calling
/// `update_min_id(42)` will ensure that future aliases generated by this
/// [`AliasGenerator`] will start from `alias_43`.
pub fn update_min_id(&self, min_id: usize) {
self.next_id.fetch_max(min_id + 1, Ordering::Relaxed);
}

/// Return a unique alias with the provided prefix
pub fn next(&self, prefix: &str) -> String {
let id = self.next_id.fetch_add(1, Ordering::Relaxed);
Expand Down
Loading
Loading