Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请求添加对【IMPALA-SQL】的HINT解析支持 #5789

Open
solidco2 opened this issue Mar 21, 2024 · 2 comments
Open

请求添加对【IMPALA-SQL】的HINT解析支持 #5789

solidco2 opened this issue Mar 21, 2024 · 2 comments

Comments

@solidco2
Copy link

在使用com.alibaba.druid.sql.parser.SQLExprParser 类解析IMPALA SQL的时候,添加了HINT会报错。可能由于IMPALA的HINT用法和其他语言有一定差异。下面给出报错的IMPALA SQL,以下SQL在IMPALA中是合法的:

SELECT T1.a
FROM
    D.T1
    JOIN /* +shuffle */ D.T2
        ON T1.x = T2.x

但是在解析时会抛出异常:
Exception in thread "main" com.alibaba.druid.sql.parser.ParserException: ERROR. pos 41, line 1, column 28, token HINT

IMPALA的HINT有三种形式:

-- 1.  /* */
D.T1 JOIN /* +shuffle */ D.T2
-- 2. [ ]
D.T1 JOIN [shuffle] D.T2
-- 3. 行尾注释
D.T1 JOIN -- +shuffle
    D.T2

目前只有第3类可以通过解析,但问题是这样的写法局限性比较大,因为是行尾注释。
所以请求兼容前两种HINT,感谢

@lizongbo
Copy link
Collaborator

发完整的可以用于验证的sql来。

@solidco2
Copy link
Author

抱歉是我提问的时候没有写清楚,三个Case如下:

  1. /**/ 型HINT,解析抛出异常
SELECT T1.a
FROM
    D.T1
    JOIN /* +shuffle */ D.T2
        ON T1.x = T2.x
  1. [ HINT ] 型HINT,解析错误,在HIVE类型中抛出异常,在odps/sqlserver类型中SQL被截断
SELECT T1.a
FROM
    D.T1
    JOIN [shuffle] D.T2
        ON T1.x = T2.x
  1. -- 型HINT,解析成功,但会丢失该注释
SELECT T1.a
FROM
    D.T1
    JOIN -- +shuffle
        D.T2
        ON T1.x = T2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants