You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/11/03 04:42:00 UTC

[GitHub] [pinot] xiangfu0 edited a comment on pull request #7678: Fixing DISTINCT with AS function

xiangfu0 edited a comment on pull request #7678:
URL: https://github.com/apache/pinot/pull/7678#issuecomment-958651669


   > > > > > I don't think we should introduce `AS` as a transform function. The fix should be purely on the query rewrite.
   > > > > > `select CAST(runs AS string) as ddd from baseballStats GROUP BY 1` should be rewritten to `select DISTINCT(CAST(runs AS string)) as ddd from baseballStats` instead of `select DISTINCT(CAST(runs AS string) as ddd) from baseballStats`. Notice the place of `as ddd`.
   > > > > > In fact, `select DISTINCT(CAST(runs AS string) as ddd) from baseballStats` is not a valid SQL query
   > > > > 
   > > > > 
   > > > > True, I think the tricky case here is that distinct can have multiple arguments, e.g.
   > > > > ```
   > > > > select CAST(runs AS string) as a, CAST(num AS int) as b from baseballStats GROUP BY 1, 2
   > > > > ```
   > > > 
   > > > 
   > > > For this query, can we rewrite it to `select CAST(runs AS string) as a, CAST(num AS int) as b, DISTINCT(a, b) from baseballStats`? This way it is still valid SQL
   > > 
   > > 
   > > I think this query `select CAST(runs AS string) as a, CAST(num AS int) as b, DISTINCT(a, b) from baseballStats` actually changes the number of output columns?
   > 
   > This should have the same behavior as `SELECT C1 AS ALIAS_C1, C2 AS ALIAS_C2, ADD(alias_c1, alias_c2) FROM Foo` which you just fixed in #7590. I think the alias part will be ignored
   
   oh, i mean `select CAST(runs AS string) as a, CAST(num AS int) as b, DISTINCT(a, b) from baseballStats`  will output 4 columns(distinct(a,b)  returns two columns? ): a, b, a, b. but we only want 2 columns a, b.
   


-- 
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: commits-unsubscribe@pinot.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org