xanderbailey commented on code in PR #19856:
URL: https://github.com/apache/datafusion/pull/19856#discussion_r2812566869
##########
datafusion/substrait/src/logical_plan/consumer/utils.rs:
##########
@@ -396,10 +433,25 @@ impl NameTracker {
&mut self,
expr: Expr,
) -> datafusion::common::Result<Expr> {
- match self.get_unique_name(expr.name_for_alias()?) {
- (_, NameTrackerStatus::NeverSeen) => Ok(expr),
- (name, NameTrackerStatus::SeenBefore) => Ok(expr.alias(name)),
+ if !self.would_conflict(&expr) {
+ self.insert(&expr);
+ return Ok(expr);
}
+
+ // Name collision - need to generate a unique alias
+ let schema_name = expr.schema_name().to_string();
+ let mut counter = 0;
+ let candidate_name = loop {
+ let candidate_name = format!("{schema_name}__temp__{counter}");
+ // .alias always produces an unqualified name so check for
conflicts accordingly.
Review Comment:
Yeah great question, looked at that and I think it complicates things and I
can't find a reason to change it. I.e. I couldn't write a failing test that it
would fix so thought it was best to keep it as is. WDYT?
--
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]