shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

SS 3.1.0.M1 can not route sql

Open a598070240 opened this issue 7 years ago • 1 comments

Bug Report

For English only, other languages will not accept.

DataBase: MySql 5.7.24-log

CREATE TABLE `sys_org_tree_rel` (
	`comp_id` INT(11) NULL DEFAULT NULL COMMENT 'id',
	`areaid` INT(11) NULL DEFAULT NULL COMMENT 'id',
	`groupid` INT(11) NULL DEFAULT NULL COMMENT 'id',
	`teamid` INT(11) NULL DEFAULT NULL COMMENT 'id',
	`last_modify` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
	UNIQUE INDEX `teamid` (`teamid`),
	INDEX `comp_id` (`comp_id`),
	INDEX `areaid` (`areaid`),
	INDEX `groupid` (`groupid`)
)
COMMENT='关系表'
COLLATE='utf8mb4_bin'
ENGINE=InnoDB
;

Sharding Table Configration:

sharding:
  jdbc:
    datasource:
      names: druid0
      druid0:
        type: com.alibaba.druid.pool.DruidDataSource
        url: jdbc:mysql://*******************?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=GMT%2B8
        driver-class-name: com.mysql.cj.jdbc.Driver
        username: ************
        password: **********
        initial-size: 10
        min-idle: 1
        max-active: 100
        max-wait: 6000
        min-evictable-idle-time-millis: 60000
        time-between-eviction-runs-millis: 6000
        validation-query: "SELECT 'x' from dual"
        validation-query-timeout: 6000
        pool-prepared-statements: true
        max-pool-prepared-statement-per-connection-size: 20
        test-while-idle: true
        test-on-borrow: true
        test-on-return: true
        filter:
          stat:
            log-slow-sql: true
    config:
      sharding:
        tables:
          record_callin:
            actual-data-nodes:  druid0.record_callin_${2018..Calendar.getInstance().get(Calendar.YEAR)}${(1..12).collect{if(it<10) "0"+it else it}}
            table-strategy:
              inline:
                sharding-column: create_time
                algorithm-expression: record_callin_${create_time.format('yyyyMM')}
            key-generator-column-name: id
        default-key-generator-class-name: io.shardingsphere.core.keygen.DefaultKeyGenerator
        props:
          show.sql: true
          sql.show: true
          max.connections.size.per.query: 15
          executor.size: 15

SQL:


SELECT COUNT(1) AS 'cnt'
FROM record_callin r, sys_org_tree_rel tree
WHERE tree.teamid = r.teamid AND r.create_time >=? AND r.create_time <=?


or 


SELECT COUNT(1) AS 'cnt'
FROM record_callin r
INNER  JOIN  sys_org_tree_rel tree ON tree.teamid = r.teamid  
WHERE  r.create_time >=? AND r.create_time <=?

issue: it works well with sharding jdbc 3.0.0 but can not work with sharding jdbc 3.1.0.M1

a598070240 avatar Dec 20 '18 06:12 a598070240

Parsing alias failed, causing sql parsing error,alias should support string

codefairy08 avatar Dec 21 '18 06:12 codefairy08