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/05/21 04:09:39 UTC
[GitHub] [shardingsphere] tristaZero edited a comment on issue #5357: agg function must include an alias stmt instead of exeucte it directly
tristaZero edited a comment on issue #5357:
URL: https://github.com/apache/shardingsphere/issues/5357#issuecomment-631867252
Hi @xiaoma20082008
Thanks for your feedback. I tried the SQL `select max(order_id),min(order_id) from t_order` in the `master branch` and there is no exception, see this,
```
[INFO ] 12:02:50.003 [ShardingSphere-Command-1] ShardingSphere-SQL - Logic SQL: show tables
[INFO ] 12:02:50.003 [ShardingSphere-Command-1] ShardingSphere-SQL - SQLStatement: CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql.ShowTablesStatement@1977d221, tablesContext=TablesContext(tables=[]))
[INFO ] 12:02:50.003 [ShardingSphere-Command-1] ShardingSphere-SQL - Actual SQL: ds_0 ::: show tables
[INFO ] 12:02:50.118 [ShardingSphere-Command-2] ShardingSphere-SQL - Logic SQL: SHOW COLUMNS FROM t_order_item FROM sharding_db
[INFO ] 12:02:50.118 [ShardingSphere-Command-2] ShardingSphere-SQL - SQLStatement: CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql.ShowColumnsStatement@6b8dfa7c, tablesContext=TablesContext(tables=[SimpleTableSegment(tableName=TableNameSegment(startIndex=18, stopIndex=29, identifier=IdentifierValue(value=t_order_item, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty)]))
[INFO ] 12:02:50.118 [ShardingSphere-Command-2] ShardingSphere-SQL - Actual SQL: ds_0 ::: SHOW COLUMNS FROM t_order_item_0
[INFO ] 12:02:50.358 [ShardingSphere-Command-3] ShardingSphere-SQL - Logic SQL: select max(order_id),min(order_id) from t_order
[INFO ] 12:02:50.358 [ShardingSphere-Command-3] ShardingSphere-SQL - SQLStatement: SelectStatementContext(super=CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement@18ddab5a, tablesContext=TablesContext(tables=[SimpleTableSegment(tableName=TableNameSegment(startIndex=40, stopIndex=46, identifier=IdentifierValue(value=t_order, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty)])), tablesContext=TablesContext(tables=[SimpleTableSegment(tableName=TableNameSegment(startIndex=40, stopIndex=46, identifier=IdentifierValue(value=t_order, quoteCharacter=NONE)), owner=Optional.empty, alias=Optional.empty)]), projectionsContext=ProjectionsContext(startIndex=7, stopIndex=33, distinctRow=false, projections=[AggregationProjection(type=MAX, innerExpression=(order_id), alias=Optional.empty, derivedAggregationProjections=[], index=-1), AggregationProjection(type=MIN, innerExpression=(order_id), alias=Optional.empty, derivedAggregationProjections=[], index=-1)]), groupByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.groupby.GroupByContext@6b5f856b, orderByContext=org.apache.shardingsphere.sql.parser.binder.segment.select.orderby.OrderByContext@1dd18185, paginationContext=org.apache.shardingsphere.sql.parser.binder.segment.select.pagination.PaginationContext@6532edb3, containsSubquery=false)
[INFO ] 12:02:50.359 [ShardingSphere-Command-3] ShardingSphere-SQL - Actual SQL: ds_0 ::: select max(order_id),min(order_id) from t_order_0
[INFO ] 12:02:50.359 [ShardingSphere-Command-3] ShardingSphere-SQL - Actual SQL: ds_0 ::: select max(order_id),min(order_id) from t_order_1
[INFO ] 12:02:50.359 [ShardingSphere-Command-3] ShardingSphere-SQL - Actual SQL: ds_1 ::: select max(order_id),min(order_id) from t_order_0
[INFO ] 12:02:50.359 [ShardingSphere-Command-3] ShardingSphere-SQL - Actual SQL: ds_1 ::: select max(order_id),min(order_id) from t_order_1
```
My configuration is,
```yaml
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_1:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
rules:
- !SHARDING
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithm:
type: INLINE
props:
algorithm.expression: t_order_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_id
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithm:
type: INLINE
props:
algorithm.expression: t_order_item_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_item_id
bindingTables:
- t_order,t_order_item
defaultDatabaseStrategy:
standard:
shardingColumn: user_id
shardingAlgorithm:
type: INLINE
props:
algorithm.expression: ds_${user_id % 2}
defaultTableStrategy:
none:
```
**Could you try your SQL in the `master branch` or the latest release, i.e., `4.1.0`?**
----------------------------------------------------------------
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