strongduanmu edited a comment on issue #10635:
URL: 
https://github.com/apache/shardingsphere/issues/10635#issuecomment-853797289


   This exception is an error reported by calcite query optimization. 
@tristaZero Can you help look at this problem?
   
   ```
   [INFO ] 2021-06-03 19:24:19.266 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Logic SQL: SELECT c_discount, c_last, c_credit, w_tax FROM 
bmsql_customer c JOIN bmsql_warehouse w ON (w.w_id = c.c_w_id) WHERE c_w_id = 1 
AND c_d_id = 3 AND c_id = 1912;
   [INFO ] 2021-06-03 19:24:19.269 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - SQLStatement: 
PostgreSQLSelectStatement(limit=Optional.empty, lock=Optional.empty, 
window=Optional.empty)
   [INFO ] 2021-06-03 19:24:19.269 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Actual SQL: ds_0 ::: SELECT c_discount, c_last, c_credit, 
w_tax FROM bmsql_customer c JOIN bmsql_warehouse w ON (w.w_id = c.c_w_id) WHERE 
c_w_id = 1 AND c_d_id = 3 AND c_id = 1912;
   [ERROR] 2021-06-03 19:24:19.826 [Connection-2-ThreadExecutor] 
o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
   java.sql.SQLException: Error while preparing statement [SELECT c_discount, 
c_last, c_credit, w_tax FROM bmsql_customer c JOIN bmsql_warehouse w ON (w.w_id 
= c.c_w_id) WHERE c_w_id = 1 AND c_d_id = 3 AND c_id = 1912;]
        at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
        at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
        at 
org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement_(CalciteConnectionImpl.java:220)
        at 
org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement(CalciteConnectionImpl.java:202)
        at 
org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement(CalciteConnectionImpl.java:93)
        at 
org.apache.calcite.avatica.AvaticaConnection.prepareStatement(AvaticaConnection.java:175)
        at 
org.apache.shardingsphere.infra.executor.sql.federate.execute.FederateJDBCExecutor.execute(FederateJDBCExecutor.java:85)
        at 
org.apache.shardingsphere.infra.executor.sql.federate.execute.FederateJDBCExecutor.executeQuery(FederateJDBCExecutor.java:68)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.federateExecute(ProxySQLExecutor.java:153)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:123)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:114)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxyLockEngine.doExecute(ProxyLockEngine.java:103)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxyLockEngine.execute(ProxyLockEngine.java:81)
        at 
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:98)
        at 
org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
        at 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.text.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:63)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
   Caused by: java.lang.RuntimeException: parse failed: Encountered ";" at line 
1, column 159.
   Was expecting one of:
       <EOF> 
       "EXCEPT" ...
       "FETCH" ...
       "GROUP" ...
       "HAVING" ...
       "INTERSECT" ...
       "LIMIT" ...
       "OFFSET" ...
       "ORDER" ...
       "MINUS" ...
       "UNION" ...
       "WINDOW" ...
       "." ...
       "NOT" ...
       "IN" ...
       "<" ...
       "<=" ...
       ">" ...
       ">=" ...
       "=" ...
       "<>" ...
       "!=" ...
       "BETWEEN" ...
       "LIKE" ...
       "SIMILAR" ...
       "+" ...
       "-" ...
       "*" ...
       "/" ...
       "%" ...
       "||" ...
       "AND" ...
       "OR" ...
       "IS" ...
       "MEMBER" ...
       "SUBMULTISET" ...
       "CONTAINS" ...
       "OVERLAPS" ...
       "EQUALS" ...
       "PRECEDES" ...
       "SUCCEEDS" ...
       "IMMEDIATELY" ...
       "MULTISET" ...
       "[" ...
       "FORMAT" ...
       
        at 
org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:623)
        at 
org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:508)
        at 
org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:478)
        at 
org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:231)
        at 
org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement_(CalciteConnectionImpl.java:213)
        ... 18 common frames omitted
   Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered ";" 
at line 1, column 159.
   Was expecting one of:
       <EOF> 
       "EXCEPT" ...
       "FETCH" ...
       "GROUP" ...
       "HAVING" ...
       "INTERSECT" ...
       "LIMIT" ...
       "OFFSET" ...
       "ORDER" ...
       "MINUS" ...
       "UNION" ...
       "WINDOW" ...
       "." ...
       "NOT" ...
       "IN" ...
       "<" ...
       "<=" ...
       ">" ...
       ">=" ...
       "=" ...
       "<>" ...
       "!=" ...
       "BETWEEN" ...
       "LIKE" ...
       "SIMILAR" ...
       "+" ...
       "-" ...
       "*" ...
       "/" ...
       "%" ...
       "||" ...
       "AND" ...
       "OR" ...
       "IS" ...
       "MEMBER" ...
       "SUBMULTISET" ...
       "CONTAINS" ...
       "OVERLAPS" ...
       "EQUALS" ...
       "PRECEDES" ...
       "SUCCEEDS" ...
       "IMMEDIATELY" ...
       "MULTISET" ...
       "[" ...
       "FORMAT" ...
       
        at 
org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)
        at 
org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:151)
        at 
org.apache.calcite.sql.parser.SqlParser.handleException(SqlParser.java:140)
        at 
org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:155)
        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:180)
        at 
org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:619)
        ... 22 common frames omitted
   Caused by: org.apache.calcite.sql.parser.impl.ParseException: Encountered 
";" at line 1, column 159.
   Was expecting one of:
       <EOF> 
       "EXCEPT" ...
       "FETCH" ...
       "GROUP" ...
       "HAVING" ...
       "INTERSECT" ...
       "LIMIT" ...
       "OFFSET" ...
       "ORDER" ...
       "MINUS" ...
       "UNION" ...
       "WINDOW" ...
       "." ...
       "NOT" ...
       "IN" ...
       "<" ...
       "<=" ...
       ">" ...
       ">=" ...
       "=" ...
       "<>" ...
       "!=" ...
       "BETWEEN" ...
       "LIKE" ...
       "SIMILAR" ...
       "+" ...
       "-" ...
       "*" ...
       "/" ...
       "%" ...
       "||" ...
       "AND" ...
       "OR" ...
       "IS" ...
       "MEMBER" ...
       "SUBMULTISET" ...
       "CONTAINS" ...
       "OVERLAPS" ...
       "EQUALS" ...
       "PRECEDES" ...
       "SUCCEEDS" ...
       "IMMEDIATELY" ...
       "MULTISET" ...
       "[" ...
       "FORMAT" ...
       
        at 
org.apache.calcite.sql.parser.impl.SqlParserImpl.generateParseException(SqlParserImpl.java:35588)
        at 
org.apache.calcite.sql.parser.impl.SqlParserImpl.jj_consume_token(SqlParserImpl.java:35402)
        at 
org.apache.calcite.sql.parser.impl.SqlParserImpl.SqlStmtEof(SqlParserImpl.java:3739)
        at 
org.apache.calcite.sql.parser.impl.SqlParserImpl.parseSqlStmtEof(SqlParserImpl.java:199)
        at 
org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:153)
        ... 24 common frames omitted
   Exception in thread "Connection-2-ThreadExecutor" 
java.lang.NullPointerException
        at 
org.apache.shardingsphere.infra.executor.sql.federate.execute.FederateJDBCExecutor.close(FederateJDBCExecutor.java:74)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection.closeFederateExecutor(BackendConnection.java:302)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.closeExecutionResources(CommandExecutorTask.java:119)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
   ```
   
   When I removed the semicolon, the following problem appeared.
   ```
   sharding_db=> SELECT c_discount, c_last, c_credit, w_tax FROM bmsql_customer 
c JOIN bmsql_warehouse w ON (w.w_id = c.c_w_id) WHERE c_w_id = 1 AND c_d_id = 3 
AND c_id = 1912;
   ERROR:  Cannot find JDBC type '3' in PostgreSQL column type
   ```


-- 
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:
[email protected]


Reply via email to