alamb commented on a change in pull request #1639:
URL: https://github.com/apache/arrow-datafusion/pull/1639#discussion_r790139091
##########
File path: datafusion/src/sql/planner.rs
##########
@@ -213,9 +213,19 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
) -> Result<LogicalPlan> {
let set_expr = &query.body;
if let Some(with) = &query.with {
+ // a `WITH` block can't use the same name for many times
+ let mut cte_names = HashSet::new();
// Process CTEs from top to bottom
// do not allow self-references
for cte in &with.cte_tables {
+ let cte_name = cte.alias.name.value.clone();
Review comment:
If you do need a hashtable in this function, I think you can avoid
cloning the string here (and just store `&str` in the set):
```suggestion
let cte_name = cte.alias.name.value.as_ref();
```
##########
File path: datafusion/src/sql/planner.rs
##########
@@ -213,9 +213,19 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
) -> Result<LogicalPlan> {
let set_expr = &query.body;
if let Some(with) = &query.with {
+ // a `WITH` block can't use the same name for many times
+ let mut cte_names = HashSet::new();
Review comment:
Since this function gets a hashtable called `ctes` as a parameter, I
wonder if you could check for the name in that hashtable rather than making a
new one?
```rust
ctes: &mut HashMap<String, LogicalPlan>,
```
--
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]