Currently the only way to generate different sql for dialects is to switch on the dialect in the unparse method. This is used quite heavily in e.g. SqlFloorFunction, but there are also switches in:
- SqlDateLiteral quoting
- SqlTimestampLiteral quoting
- Dialects using different interval literals (e.g. Hsqldb uses YYYY & MM rather than YEAR & MONTH)
- limit/offset construction
- mysql isnull function
- type differences
It would be great to have dialect specific handlers to deal with these, making testing & addition of new handlers (new dialects, or new overrides for a given function) much easier in the future.
One suggested path to approach this: https://issues.apache.org/jira/browse/CALCITE-1798?focusedCommentId=16031609&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16031609
There is a comment in SqlImplementor that reads "MySQL doesn't have a VARCHAR type, only CHAR.". Not sure if this was for a very old version of mysql, but it's certainly not true anymore.