dutyu opened a new pull request, #27231: URL: https://github.com/apache/doris/pull/27231
## Proposed changes **Thanks for** pr #21855 to provide a wonderful reference. Maybe it is very difficult and **cost-expensive** to implement **a comprehensive logical plan adapter**, maybe there is just some small syntax variations between doris and some other engines (such as hive/spark), so we can just **focus on** the **difference** here. This pr mainly focus on the **syntax difference between doris and hive**. For instance, do some function tranformations and override some syntax validations. - add a dialect named `hive` - move method `NereidsParser#parseSQLWithDialect` to `TrinoParser` - extract some `FnCallTransformer`/`FnCallTransformers` classes, so we can reuse the logic about the function transformers - allow derived tables without alias when we set dialect to `hive`(legacy and nereids parser are both supported) - add some function transformers for hive built-in functions ### Test case (from our online doris cluster) - Test derived table without alias ```sql MySQL [(none)]> show variables like '%dialect%'; +---------------+-------+---------------+---------+ | Variable_name | Value | Default_Value | Changed | +---------------+-------+---------------+---------+ | sql_dialect | hive | doris | 1 | +---------------+-------+---------------+---------+ 1 row in set (0.01 sec) MySQL [(none)]> select * from (select 1); +------+ | 1 | +------+ | 1 | +------+ 1 row in set (0.03 sec) MySQL [(none)]> set sql_dialect=doris; Query OK, 0 rows affected (0.02 sec) MySQL [(none)]> select * from (select 1); ERROR 1248 (42000): errCode = 2, detailMessage = Every derived table must have its own alias MySQL [(none)]> ``` - Test hive functions ```sql MySQL [(none)]> show global functions; Empty set (0.01 sec) MySQL [(none)]> show variables like '%dialect%'; +---------------+-------+---------------+---------+ | Variable_name | Value | Default_Value | Changed | +---------------+-------+---------------+---------+ | sql_dialect | hive | doris | 1 | +---------------+-------+---------------+---------+ 1 row in set (0.01 sec) MySQL [(none)]> select get_json_object('{"a":"b"}', '$.a'); +----------------------------------+ | json_extract('{"a":"b"}', '$.a') | +----------------------------------+ | "b" | +----------------------------------+ 1 row in set (0.04 sec) MySQL [(none)]> select split("a b c", " "); +-------------------------------+ | split_by_string('a b c', ' ') | +-------------------------------+ | ["a", "b", "c"] | +-------------------------------+ 1 row in set (1.17 sec) ``` -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org