Issue 1:
If the original SQL is:

SELECT t_account.* FROM t_account WHERE account_id=?

The current rewrited SQL which is incorrect:

SELECT `t_account`.col1, `t_account`.col2, `t_account`.col_n FROM t_account_0 WHERE account_id=?

It should be rewrite to:

SELECT `t_account_0`.col1, `t_account_0`.col2, `t_account_0`.col_n FROM t_account_0 WHERE account_id=?

The owner of projection can not rewrite to sharded table name.

The solution for now is adding alias for table, for example:

SELECT a.* FROM t_account a WHERE account_id=?

It can rewrite correctly

SELECT a.* FROM t_account_0 a WHERE account_id=?

Please see #9512 to find commented test cases for this issue.

Issue 2:
Bug Report

this ‘s my sharding config

sharding.jdbc.datasource.names=ds0,ds1,ds2
sharding.jdbc.datasource.ds0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds0.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds0.url=jdbc:mysql://localhost:3306/ds0?serverTimezone=GMT%2B8`
sharding.jdbc.datasource.ds0.username=root
sharding.jdbc.datasource.ds0.password=root

sharding.jdbc.datasource.ds1.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds1.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds1.url=jdbc:mysql://localhost:3306/ds1?serverTimezone=GMT%2B8
sharding.jdbc.datasource.ds1.username=root
sharding.jdbc.datasource.ds1.password=root

sharding.jdbc.datasource.ds2.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds2.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds2.url=jdbc:mysql://localhost:3306/ds2?serverTimezone=GMT%2B8
sharding.jdbc.datasource.ds2.username=root
sharding.jdbc.datasource.ds2.password=root

sharding.jdbc.config.sharding.default-data-source-name=ds2
sharding.jdbc.config.sharding.default-database-strategy.inline.sharding-column=user_id
sharding.jdbc.config.sharding.default-database-strategy.inline.algorithm-expression=ds$->{user_id % 3}
sharding.jdbc.config.sharding.default-key-generator-class-name=liuxun.jpa.shard.config.SnowFlakeGenerator

sharding.jdbc.config.sharding.tables.t_order.actual-data-nodes=ds$->{0..2}.t_order$->{0..1}
sharding.jdbc.config.sharding.tables.t_order.table-strategy.inline.sharding-column=order_id
sharding.jdbc.config.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order.key-generator-column-name=order_id
sharding.jdbc.config.sharding.tables.t_order_item.actual-data-nodes=ds$->{0..2}.t_order_item$->{0..1}
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding-column=order_id
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression=t_order_item$->{order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator-column-name=order_item_id
sharding.jdbc.config.sharding.binding-tables=t_order,t_order_item

sharding.jdbc.config.sharding.tables.t_user.actual-data-nodes=ds$->{0..2}.t_user$->{0..1}
sharding.jdbc.config.sharding.tables.t_user.table-strategy.inline.sharding-column=user_id
sharding.jdbc.config.sharding.tables.t_user.table-strategy.inline.algorithm-expression=t_user$->{user_id % 2}
sharding.jdbc.config.sharding.tables.t_user.key-generator-column-name=user_id

sharding.jdbc.config.sharding.tables.t_product.actual-data-nodes=ds$->{0..2}.t_product$->{0..1}
sharding.jdbc.config.sharding.tables.t_product.database-strategy.inline.sharding-column=product_id
sharding.jdbc.config.sharding.tables.t_product.database-strategy.inline.algorithm-expression=ds$->{product_id % 2}
sharding.jdbc.config.sharding.tables.t_product.table-strategy.inline.sharding-column=product_id
sharding.jdbc.config.sharding.tables.t_product.table-strategy.inline.algorithm-expression=t_product$->{product_id % 2}
sharding.jdbc.config.sharding.tables.t_product.key-generator-column-name=product_id

sharding.jdbc.config.sharding.props.sql.show=true

I have configured three database, each with two tables in each database including t_order , t_order_item, t_user and t_product. The default data source is ds0 but I have an error when querying orders based on the amount range.

java.sql.SQLSyntaxErrorException: Table 'ds1.t_order_order_items' doesn't exist at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.13.jar:8.0.13] at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.13.jar:8.0.13] at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.13.jar:8.0.13]

How to solve it? This table is automatically generated by shading, and in the default data source ds2, .t_order_order_items