goldmedal commented on code in PR #14781:
URL: https://github.com/apache/datafusion/pull/14781#discussion_r1991936799


##########
datafusion/sql/src/unparser/plan.rs:
##########
@@ -860,8 +877,12 @@ impl Unparser<'_> {
         query: &mut Option<QueryBuilder>,
         select: &mut SelectBuilder,
         relation: &mut RelationBuilder,
+        alias: &str,
     ) -> Result<()> {
         let mut unnest_relation = UnnestRelationBuilder::default();
+
+        unnest_relation.alias(Some(self.new_table_alias(alias.to_string(), 
vec![])));
+

Review Comment:
   BTW, I'm considering how to fix the issue mentioned in 
(https://github.com/apache/datafusion/pull/15090#discussion_r1989018918). I 
think add an alias for the unnest may be a good idea. 
   
   I think it should like
   ```suggestion
           unnest_relation.alias(Some(self.new_table_alias("unnset_table_1", 
vec![alias.to_string()])));
   ```
   
   Then, we can get the result like
   ```sql
   SELECT "UNNEST(make_array(Int64(1),Int64(2),Int64(3)))" FROM UNNEST([1, 2, 
3]) AS unnest_table ("UNNEST(make_array(Int64(1),Int64(2),Int64(3)))")
   ```
   
   It can not only fit what you want to do but generate a valid SQL. 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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to