jiangML opened a new issue, #26659:
URL: https://github.com/apache/shardingsphere/issues/26659

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   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?
   
   master
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   proxy
   
   ### Expected behavior
   search successful
   ### Actual behavior
   fail
   
   ```shell
   mysql> select * from information_schema.PLUGINS;
   ERROR 30000 (HY000): Unknown exception: Cannot invoke 
"org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutor.execute(org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable,
 
org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutorContext)"
 because "this.pushDownTableScanExecutor" is null
   ```
   Proxy Error
   ```shell
   [ERROR] 2023-06-28 16:34:30.325 [ShardingSphere-Command-0] 
o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
   java.lang.NullPointerException: Cannot invoke 
"org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutor.execute(org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable,
 
org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutorContext)"
 because "this.pushDownTableScanExecutor" is null
           at 
org.apache.shardingsphere.sqlfederation.compiler.metadata.schema.SQLFederationTable.project(SQLFederationTable.java:107)
           at Baz.bind(Unknown Source)
           at 
org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine.executeQuery(SQLFederationEngine.java:160)
           at 
org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.doExecuteFederation(DatabaseConnector.java:249)
           at 
org.apache.shardingsphere.proxy.backend.connector.DatabaseConnector.execute(DatabaseConnector.java:166)
           at 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:99)
           at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.doExecuteCommand(CommandExecutorTask.java:126)
           at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:121)
           at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
           at com.alibaba.ttl.TtlRunnable.run(TtlRunnable.java:60)
           at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
           at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
           at java.base/java.lang.Thread.run(Thread.java:833)
   ```
   
   ### Reason analyze (If you can)
   
   The name in ShardingSphereTable is capitalized
   SQLFederationSchema.class
   ```java
       private Map<String, Table> createTableMap(final ShardingSphereSchema 
schema, final DatabaseType protocolType, final JavaTypeFactory javaTypeFactory) 
{
           Map<String, Table> result = new 
LinkedHashMap<>(schema.getTables().size(), 1F);
           for (ShardingSphereTable each : schema.getTables().values()) {
               if (schema.containsView(each.getName())) {
                   result.put(each.getName(), getViewTable(schema, each, 
protocolType, javaTypeFactory));
               } else {
                   // TODO implement table statistic logic after using custom 
operators
                   result.put(each.getName(), new SQLFederationTable(each, new 
SQLFederationStatistic(), protocolType));
               }
           }
           return result;
       }
   ```
   SQLFederationEngine.class 
`metaData.getDatabase(databaseName).getSchema(schemaName).getAllTableNames()` 
gets lowercase table names
   ```java
       private void registerTableScanExecutor(final Schema sqlFederationSchema, 
final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
                                              final JDBCExecutorCallback<? 
extends ExecuteResult> callback, final SQLFederationExecutorContext 
federationContext,
                                              final OptimizerContext 
optimizerContext) {
           if (null == sqlFederationSchema) {
               return;
           }
           TableScanExecutorContext executorContext = new 
TableScanExecutorContext(databaseName, schemaName, metaData.getProps(), 
federationContext);
           EnumerablePushDownTableScanExecutor pushDownTableScanExecutor =
                   new EnumerablePushDownTableScanExecutor(prepareEngine, 
jdbcExecutor, callback, optimizerContext, metaData.getGlobalRuleMetaData(), 
executorContext, statistics);
           // TODO register only the required tables
           for (String each : 
metaData.getDatabase(databaseName).getSchema(schemaName).getAllTableNames()) {
               Table table = sqlFederationSchema.getTable(each);
               if (table instanceof SQLFederationTable) {
                   ((SQLFederationTable) 
table).setPushDownTableScanExecutor(pushDownTableScanExecutor);
               }
           }
       }
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to