[ 
https://issues.apache.org/jira/browse/IGNITE-6772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16322088#comment-16322088
 ] 

Roman Kondakov commented on IGNITE-6772:
----------------------------------------

[~ptupitsyn], 
*  This made for an uniformity error messages between different types of JDBC 
drivers. JDBC and JDBC2 drivers used to return {{Value is an not instance of " 
+ cls.getName()}} in case of types mismatch. JDBC Thin driver returns {{Cannot 
convert to URL/boolean/float... etc.}} where type is hardcoded. It is useful 
not only for users but also for testing purposes.  I'm not sure if we need to 
add a source class to the message because this problem is relevant only for 
JDBC and JDBC2 drivers which are going to be deprecated as far as I know. Thin 
driver {{ResultSet}} includes value (but not value class) in the error message. 
E.g. {{"Cannot convert to float: " + val}}. From my point of view it should be 
enough for debugging reasons.
* Query text is already included into the exception's message sent from the 
parsing engine: {{Column "WRONG" not found; SQL statement: select wrong from 
test \[42122-195\]}}. If we also include it here, query will be dublicated in 
the same message.

> SQL exception messages are not descriptive
> ------------------------------------------
>
>                 Key: IGNITE-6772
>                 URL: https://issues.apache.org/jira/browse/IGNITE-6772
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Pavel Tupitsyn
>            Assignee: Roman Kondakov
>              Labels: usability
>             Fix For: 2.4
>
>
> Top level SQL exception messages are cryptic and not descriptive. Real 
> details are buried deep inside inner exceptions.
> For example, when there is a typo in table name, exception looks like this:
> {code}
> class org.apache.ignite.IgniteCheckedException: Failed to parse query: SELECT 
> "persons-sql"."PERSON"._KEY, "persons-sql"."PERSON"._VAL from Person1, 
> "orgs-sql".Organization where Person.OrgId = "orgs-sql".Organization._key and 
> "orgs-sql".Organization.Name = ?
>   at 
> org.apache.ignite.internal.processors.platform.utils.PlatformUtils.unwrapQueryException(PlatformUtils.java:510)
>   at 
> org.apache.ignite.internal.processors.platform.cache.PlatformCache.runQuery(PlatformCache.java:1219)
>   at 
> org.apache.ignite.internal.processors.platform.cache.PlatformCache.processInStreamOutObject(PlatformCache.java:875)
>   at 
> org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl.inStreamOutObject(PlatformTargetProxyImpl.java:77)
> Caused by: javax.cache.CacheException: class 
> org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to 
> parse query: SELECT "persons-sql"."PERSON"._KEY, "persons-sql"."PERSON"._VAL 
> from Person1, "orgs-sql".Organization where Person.OrgId = 
> "orgs-sql".Organization._key and "orgs-sql".Organization.Name = ?
>   at 
> org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:807)
>   at 
> org.apache.ignite.internal.processors.platform.cache.PlatformCache.runQuery(PlatformCache.java:1213)
>   ... 2 more
> Caused by: class 
> org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to 
> parse query: SELECT "persons-sql"."PERSON"._KEY, "persons-sql"."PERSON"._VAL 
> from Person1, "orgs-sql".Organization where Person.OrgId = 
> "orgs-sql".Organization._key and "orgs-sql".Organization.Name = ?
>   at 
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryDistributedSqlFields(IgniteH2Indexing.java:1293)
>   at 
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryDistributedSql(IgniteH2Indexing.java:1198)
>   at 
> org.apache.ignite.internal.processors.query.GridQueryProcessor$8.applyx(GridQueryProcessor.java:1957)
>   at 
> org.apache.ignite.internal.processors.query.GridQueryProcessor$8.applyx(GridQueryProcessor.java:1955)
>   at 
> org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
>   at 
> org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2293)
>   at 
> org.apache.ignite.internal.processors.query.GridQueryProcessor.queryDistributedSql(GridQueryProcessor.java:1954)
>   at 
> org.apache.ignite.internal.processors.query.GridQueryProcessor.querySql(GridQueryProcessor.java:1934)
>   at 
> org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:792)
>   ... 3 more
> Caused by: org.h2.jdbc.JdbcSQLException: Table "PERSON1" not found; SQL 
> statement:
> SELECT "persons-sql"."PERSON"._KEY, "persons-sql"."PERSON"._VAL from Person1, 
> "orgs-sql".Organization where Person.OrgId = "orgs-sql".Organization._key and 
> "orgs-sql".Organization.Name = ? [42102-195]
>   at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
>   at org.h2.message.DbException.get(DbException.java:179)
>   at org.h2.message.DbException.get(DbException.java:155)
>   at org.h2.command.Parser.readTableOrView(Parser.java:5506)
>   at org.h2.command.Parser.readTableFilter(Parser.java:1260)
>   at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1940)
>   at org.h2.command.Parser.parseSelectSimple(Parser.java:2089)
>   at org.h2.command.Parser.parseSelectSub(Parser.java:1934)
>   at org.h2.command.Parser.parseSelectUnion(Parser.java:1749)
>   at org.h2.command.Parser.parseSelect(Parser.java:1737)
>   at org.h2.command.Parser.parsePrepared(Parser.java:448)
>   at org.h2.command.Parser.parse(Parser.java:320)
>   at org.h2.command.Parser.parse(Parser.java:292)
>   at org.h2.command.Parser.prepareCommand(Parser.java:257)
>   at org.h2.engine.Session.prepareLocal(Session.java:573)
>   at org.h2.engine.Session.prepareCommand(Session.java:514)
>   at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204)
>   at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
>   at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288)
>   at 
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:398)
>   at 
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryDistributedSqlFields(IgniteH2Indexing.java:1273)
> {code}
> As we can see, top level message is {{Failed to parse query}}, but the real 
> problem that user needs to know is {{Table "PERSON1" not found}}. We should 
> make sure that top level message includes the useful information and not some 
> internal implementation details.
> Make sure to add unit tests for common SQL query problems:
> * Incorrect table name
> * Incorrect column name
> * Syntax error (shoukd include character index)
> Error messages are part of the API.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to