You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Wang Weidong (Jira)" <ji...@apache.org> on 2019/11/25 04:36:00 UTC

[jira] [Closed] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

     [ https://issues.apache.org/jira/browse/CALCITE-3532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wang Weidong closed CALCITE-3532.
---------------------------------
    Resolution: Invalid

> SqlValidator throws exception with message of db not found while table not existed
> ----------------------------------------------------------------------------------
>
>                 Key: CALCITE-3532
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3532
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0
>            Reporter: Wang Weidong
>            Priority: Major
>
> I found that if a SqlNode of a sql with an not existed table is validated, an exception with message of db not found while table not existed will be thrown even though the db is existed.
> For instance, when validate the SqlNode of this sql 
> {code:sql}
> select * from db1.t
> {code}
> in which db1 is existed and t is not existed in db1.
> An exception was thrown with stack trace as follows
> {code:java}
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to line 1, column 19: Object 'db1' not found
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> 	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
> 	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
> 	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
> 	at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
> 	at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
> 	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3122)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3104)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3376)
> 	at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
> 	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
> 	at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:939)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:646)
> 	at com.alipay.smartsql.vtable.parser.validate.DefaultSqlValidator.validate(DefaultSqlValidator.java:52)
> {code}
> I found that the cause of this problem may be the process at https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/validate/IdentifierNamespace.java#L180
> which only produces message of the first component of table path when throws exception.
> Can we fix this problem? 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)