shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

single table throw NoSuchTableException in method validateTableExist

Open lenxeon opened this issue 3 years ago • 4 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

5.4.0

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

Actual behavior

throw NoSuchTableException

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

my project upgrade from 4.0.0-RC2-SNAPSHOT to 5.4.0

tables in mysql database: db_uc

tb_third_employee_000 tb_third_employee_001 tb_uc_account

tableName=tb_third_employee, column=organization_id

        Properties properties = new Properties();
        properties.setProperty("algorithm-expression", tableName + "_00${" + column + " % 2}");
        String shardingStrategyKey = "sharding_algorithm_" + tableName;
        shardingRuleConfig.getShardingAlgorithms().put(shardingStrategyKey, new AlgorithmConfiguration("INLINE", properties));
        shardingRuleConfig.getBindingTableGroups().add(new ShardingTableReferenceRuleConfiguration("db_" + schemaName, tableName));
        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration(tableName, "db_" + schemaName + "." + tableName + "_00${[0, 1]}");
        result.setTableShardingStrategy(new StandardShardingStrategyConfiguration(column, shardingStrategyKey));
        shardingRuleConfig.getTables().add(result);
// create datasource
        Properties pop = new Properties();
        pop.setProperty(ConfigurationPropertyKey.SQL_SHOW.getKey(), Boolean.TRUE.toString());
        pop.setProperty(ConfigurationPropertyKey.SQL_SIMPLE.getKey(), Boolean.FALSE.toString());
        dataSource = ShardingSphereDataSourceFactory.createDataSource("db_" + schema, ds, Lists.newArrayList(shardingRuleConfig), pop);

Example codes for reproduce this issue (such as a github link).

lenxeon avatar Jul 12 '23 07:07 lenxeon

is no sharding table must in a default database ?

lenxeon avatar Jul 13 '23 01:07 lenxeon

i also encountered this problem, if it is not a sharding table , it will appear 'table not exist'

doupeng19940218 avatar Jul 17 '23 11:07 doupeng19940218

Please refer this document to config single table rule - https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/rules/single/.

Starting from 5.4.0, the single table will not be loaded by default, users need to declare in yaml or use LOAD SINGLE TABLE to load.

strongduanmu avatar Jul 17 '23 11:07 strongduanmu

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

github-actions[bot] avatar Aug 16 '23 20:08 github-actions[bot]