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

table name is not rewrited correctly in subquery #6228

Closed
nkuflk opened this issue Jul 1, 2020 · 7 comments · Fixed by #6259
Closed

table name is not rewrited correctly in subquery #6228

nkuflk opened this issue Jul 1, 2020 · 7 comments · Fixed by #6259

Comments

@nkuflk
Copy link

nkuflk commented Jul 1, 2020

I have a SQL
SELECT min(id) AS min_id, max(id) AS max_id from ( select id FROM msg WHERE id > #{minId} AND date = #{date} ORDER BY id limit #{step} ) a
In version 4.0.0, the actual in log is
SELECT min(id) AS min_id, max(id) AS max_id from ( select id FROM msg_10 WHERE id > ? AND date = ? ORDER BY id limit ? ) a ::: [-1, 2019-04-26 00:00:00.0, 1]
But when I upgrade to 4.0.1, the actual sql in log is
SELECT min(id) AS min_id, max(id) AS max_id from ( select id FROM msg WHERE id > ? AND date = ? ORDER BY id limit ? ) a ::: [-1, 2019-04-26 00:00:00.0, 1]

@kimmking
Copy link
Member

kimmking commented Jul 1, 2020

you can try 4.1.1.

@nkuflk
Copy link
Author

nkuflk commented Jul 2, 2020

you can try 4.1.1.

4.1.1 also has this problem. I have tried 4.0.0, 4.0.1, 4.1.0, 4.1.1, only 4.0.0 is ok.
I review the SQLParseEngine in shardingsphere-sql-parser, it has a big upgrade in 4.0.1, maybe the upgrade has some problem.

@nkuflk
Copy link
Author

nkuflk commented Jul 2, 2020

I hope to use 4.1.1 because it has long sql optimize. But 4.1.1 still not work for alias table.

@kimmking
Copy link
Member

kimmking commented Jul 2, 2020

@jingshanglu will track it.

@kimmking kimmking changed the title mysql alias table not work when I upgrade from 4.0.0 to 4.0.1 table name is not rewrited correctly in subquery Jul 3, 2020
@jingshanglu
Copy link
Contributor

@kimmking @nkuflk Ok, i'll check it.

@jingshanglu
Copy link
Contributor

@nkuflk Now the pr #6259 fix it,but plz use alias in whereClause and projections, Alias not applicable in subquery is not supported.

@nkuflk
Copy link
Author

nkuflk commented Jul 4, 2020

@nkuflk Now the pr #6259 fix it,but plz use alias in whereClause and projections, Alias not applicable in subquery is not supported.

Thanks

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

Successfully merging a pull request may close this issue.

3 participants