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/01/27 12:43:22 UTC

[GitHub] [incubator-shardingsphere] encodeering opened a new issue #4092: class cast exception if no viable alternative could be found

encodeering opened a new issue #4092: class cast exception if no viable alternative could be found
URL: https://github.com/apache/incubator-shardingsphere/issues/4092
 
 
   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   5.0.0-RC1-SNAPSHOT
   
   Commit 63f880bcab14eba5d4ac83ef22fc5ae346a62821 
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   
   Sharding-JDBC
   
   ### Expected behavior
   
   SQL statements with schema and quotation work equally compared to 3.x
   
   ### Actual behavior
   
   The following sql statement causes a class cast exception
   
   ```
   databaseTypeName = "PostgreSQL"
   sql = "select count(*) from "abc"."order" where ("abc"."order"."user" = ? and "abc"."order"."status" = ?)"
   ```
   
   Schema (`abc`) and table (`order`) names have been rewritten using the same character set [a-z]
   
   ### Reason analyze (If you can)
   
   ```
   no viable alternative at input '("abc"."order".'
   
   org.antlr.v4.runtime.NoViableAltException
   
   class org.antlr.v4.runtime.tree.ErrorNodeImpl cannot be cast to class org.antlr.v4.runtime.ParserRuleContext (org.antlr.v4.runtime.tree.ErrorNodeImpl and org.antlr.v4.runtime.ParserRuleContext are in unnamed module of loader 'app')
   java.lang.ClassCastException: class org.antlr.v4.runtime.tree.ErrorNodeImpl cannot be cast to class org.antlr.v4.runtime.ParserRuleContext (org.antlr.v4.runtime.tree.ErrorNodeImpl and org.antlr.v4.runtime.ParserRuleContext are in unnamed module of loader 'app')
   	at org.jooq_3.12.1.POSTGRES.debug(Unknown Source) ~[?:?]
   	at org.apache.shardingsphere.sql.parser.core.extractor.impl.dml.PredicateExtractor.extractRecursiveWithParen(PredicateExtractor.java:116) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.core.extractor.impl.dml.PredicateExtractor.extractRecursiveWithLogicalOperation(PredicateExtractor.java:71) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.core.extractor.impl.dml.PredicateExtractor.extract(PredicateExtractor.java:65) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.core.extractor.impl.dml.WhereExtractor.extract(WhereExtractor.java:48) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.core.extractor.SQLSegmentsExtractorEngine.extract(SQLSegmentsExtractorEngine.java:47) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.core.SQLParseKernel.parse(SQLParseKernel.java:59) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.SQLParseEngine.parse0(SQLParseEngine.java:70) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.sql.parser.SQLParseEngine.parse(SQLParseEngine.java:52) ~[shardingsphere-sql-parser-engine-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.masterslave.route.engine.MasterSlaveRouter.route(MasterSlaveRouter.java:49) ~[master-slave-core-route-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.MasterSlavePreparedStatement.<init>(MasterSlavePreparedStatement.java:70) ~[sharding-jdbc-core-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.MasterSlavePreparedStatement.<init>(MasterSlavePreparedStatement.java:55) ~[sharding-jdbc-core-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.MasterSlaveConnection.prepareStatement(MasterSlaveConnection.java:76) ~[sharding-jdbc-core-5.0.0-RC1-SNAPSHOT.jar:5.0.0-RC1-SNAPSHOT]
   	at org.jooq.impl.ProviderEnabledConnection.prepareStatement(ProviderEnabledConnection.java:109) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.SettingsEnabledConnection.prepareStatement(SettingsEnabledConnection.java:73) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.prepare(AbstractResultQuery.java:273) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:336) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:501) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:470) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.fetchLazyNonAutoClosing(AbstractResultQuery.java:484) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:653) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:605) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:611) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.SelectImpl.fetchOne(SelectImpl.java:2847) ~[jooq-3.12.1.jar:?]
   	at org.jooq.impl.DefaultDSLContext.fetchCount(DefaultDSLContext.java:4283) ~[jooq-3.12.1.jar:?]
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   Should be reproducible with the same sql statement and postgres parser.
   
   ### 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [shardingsphere] encodeering commented on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
encodeering commented on issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092#issuecomment-645930406


   @jingshanglu thanks for getting back and taking care of it! 
   
   I've build a version based on the latest master commit 310d2003 and ran some of our tests. The output is a bit different now
   
   ```
   line 1:9 missing {'=', TO} at ''postgres''
   line 1:7 no viable alternative at input 'CREATESCHEMA'
   
   org.apache.shardingsphere.sql.parser.exception.SQLParsingException: Unsupported SQL of `CREATE SCHEMA "abc"`
   
   	at org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor.execute(SQLParserExecutor.java:49)
   	at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:78)
   	at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:60)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:137)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:111)
   	at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:78)
   	at org.flywaydb.core.internal.jdbc.JdbcTemplate.prepareStatement(JdbcTemplate.java:346)
   	at org.flywaydb.core.internal.jdbc.JdbcTemplate.execute(JdbcTemplate.java:223)
   
   ```
   
   Do you think this is related or do you want me to create a different task?
   
   Cheers


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



[GitHub] [shardingsphere] jingshanglu commented on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092#issuecomment-645261121


   @encodeering It has been fixed by #6045 .


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



[GitHub] [shardingsphere] jingshanglu commented on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092#issuecomment-646381517


   @encodeering Now ,only select,delete,update,insert is compatible, others will be fixed in future.


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



[GitHub] [shardingsphere] sandynz commented on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
sandynz commented on issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092#issuecomment-943172953


   Since the original problem was fixed, it will be closed now. Welcome to submit new issue for new problem.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092#issuecomment-644727538


   @encodeering @terrymanu #6045 has fix it.


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



[GitHub] [incubator-shardingsphere] terrymanu commented on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #4092: class cast exception if no viable alternative could be found
URL: https://github.com/apache/incubator-shardingsphere/issues/4092#issuecomment-579103365
 
 
   Hi, we don't parse schema owner for select SQL for now.
   It is a bug, I prefer to open it as volunteer wanted who interested to fix this one.

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


With regards,
Apache Git Services

[GitHub] [shardingsphere] jingshanglu removed a comment on issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
jingshanglu removed a comment on issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092#issuecomment-644727538


   @encodeering @terrymanu #6045 has fix it.


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



[GitHub] [shardingsphere] sandynz closed issue #4092: class cast exception if no viable alternative could be found

Posted by GitBox <gi...@apache.org>.
sandynz closed issue #4092:
URL: https://github.com/apache/shardingsphere/issues/4092


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org