apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.97k stars 6.75k forks source link

table name is not rewrited correctly in subquery #6228

Closed nkuflk closed 4 years ago

nkuflk commented 4 years ago

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 commented 4 years ago

you can try 4.1.1.

nkuflk commented 4 years ago

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 commented 4 years ago

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

kimmking commented 4 years ago

@jingshanglu will track it.

jingshanglu commented 4 years ago

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

jingshanglu commented 4 years ago

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

nkuflk commented 4 years ago

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

Thanks