You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/09/02 11:04:17 UTC
[GitHub] [shardingsphere] tristaZero commented on issue #7225: how to use bindingTables rightly
tristaZero commented on issue #7225:
URL: https://github.com/apache/shardingsphere/issues/7225#issuecomment-685628211
Hi @lxj1027997254
Do you think the following result is what you expected?
```yaml
rules:
- !SHARDING
tables:
t_order:
actualDataNodes: ds_0.t_order_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: t_order_inline
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
t_order_item:
actualDataNodes: ds_0.t_order_item_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: t_order_item_inline
keyGenerateStrategy:
column: order_item_id
keyGeneratorName: snowflake
bindingTables:
- t_order,t_order_item
shardingAlgorithms:
database_inline:
type: INLINE
props:
algorithm.expression: ds_${user_id % 2}
t_order_inline:
type: INLINE
props:
algorithm.expression: t_order_${order_id % 2}
t_order_item_inline:
type: INLINE
props:
algorithm.expression: t_order_item_${order_id % 2}
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker.id: 123
```
```
[INFO ] 19:02:27.015 [ShardingSphere-Command-5] ShardingSphere-SQL - Logic SQL: select * from t_order, t_order_item where t_order.order_id = t_order_item.order_id and t_order.order_id in (1,2)
[INFO ] 19:02:27.015 [ShardingSphere-Command-5] ShardingSphere-SQL - SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement@5f51ee73, tablesContext=TablesContext(tables=[SimpleTableSegment(tableName=TableNameSegment(startIndex=14, stopIndex=20, identifier=IdentifierValue(value=t_order, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty), SimpleTableSegment(tableName=TableNameSegment(startIndex=23, stopIndex=34, identifier=IdentifierValue(value=t_order_item, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty)])), tablesContext=TablesContext(tables=[SimpleTableSegment(tableName=TableNameSegment(startIndex=14, stopIndex=20, identifier=IdentifierValue(value=t_order, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty), SimpleTableSegment(tableName=TableNameSegment(startIndex=23, stopIndex=34, identifier=IdentifierValue(value=t_order_item,
quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty)]), projectionsContext=ProjectionsContext(startIndex=7, stopIndex=7, distinctRow=false, projections=[ShorthandProjection(owner=Optional.empty, actualColumns=[ColumnProjection(owner=null, name=order_id, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty), ColumnProjection(owner=null, name=status, alias=Optional.empty), ColumnProjection(owner=null, name=order_item_id, alias=Optional.empty), ColumnProjection(owner=null, name=order_id, alias=Optional.empty), ColumnProjection(owner=null, name=user_id, alias=Optional.empty), ColumnProjection(owner=null, name=status, alias=Optional.empty)])]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@51960be9, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@55a98503, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.paginatio
n.PaginationContext@10ab01d2, containsSubquery=false)
[INFO ] 19:02:27.015 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order_0, t_order_item_0 where t_order_0.order_id = t_order_item_0.order_id and t_order_0.order_id in (1,2)
[INFO ] 19:02:27.015 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order_1, t_order_item_1 where t_order_1.order_id = t_order_item_1.order_id and t_order_1.order_id in (1,2)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org