rusackas commented on PR #41125:
URL: https://github.com/apache/superset/pull/41125#issuecomment-4835616262

   > Whlie this might be a bug in 6.0, this should work in `master`, since we 
now use the `REDSHIFT` dialect instead of `POSTGRES`:
   > 
   > ```python
   > >>> import sqlglot
   > >>> from sqlglot.dialects.dialect import Dialects
   > >>> sqlglot.parse_one("ROUND(AVG(x), n)", 
Dialects.POSTGRES).sql(Dialects.POSTGRES)
   > 'ROUND(CAST(AVG(x) AS DECIMAL), n)'
   > >>> sqlglot.parse_one("ROUND(AVG(x), n)", 
Dialects.REDSHIFT).sql(Dialects.REDSHIFT)
   > 'ROUND(AVG(x), n)'
   > >>>
   > ```
   > 
   > In general I think the safest way to move forward with cases like this is 
either updating or creating the sqlglot dialect, instead of falling back to 
special cases.
   
    @betodealmeida, it looks like Redshift is covered because redshift maps to 
Dialects.REDSHIFT. But cockroachdb, hana, netezza, and postgresql itself still 
point at Dialects.POSTGRES in SQLGLOT_DIALECTS, so the ROUND(CAST(...)) rewrite 
is still live for those, and the regression still applies to them.
   
   On the special-casing concern, I don't think this one adds any. Rather than 
branching per dialect, it just stops round-tripping the user's clause through 
the engine generator at all, and returns it verbatim. The only spot that still 
re-renders is the comment path, and that now normalizes through the base 
dialect (None) instead of the engine, so no Postgres-specific CAST sneaks back 
in.
   
   Lemme know if that makes sense / sounds right :D 


-- 
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]

Reply via email to