You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (JIRA)" <ji...@apache.org> on 2018/08/19 16:40:00 UTC

[jira] [Issue Comment Deleted] (CALCITE-2434) SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match

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

Vladimir Sitnikov updated CALCITE-2434:
---------------------------------------
    Comment: was deleted

(was: {code:sql}select catalog.sales.em^ from catalog.sales.emp{code}
simplifies to 
{code:sql}select catalog.sales. _sugest_ from catalog.sales.emp{code}
and validator produces the following exception:
{noformat}org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 20: Table 'CATALOG.SALES' 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:783)
	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4776)
	at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:330)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.findTableColumnPair(SqlValidatorImpl.java:3428)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.isRolledUpColumn(SqlValidatorImpl.java:3461)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUp(SqlValidatorImpl.java:3385)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUp(SqlValidatorImpl.java:3398)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.checkRollUpInSelectList(SqlValidatorImpl.java:3324)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3312)
	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:973)
	at org.apache.calcite.sql.advise.SqlAdvisorValidator.validateNamespace(SqlAdvisorValidator.java:185)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:949)
	at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:924)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
	at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:341)
	at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:210)
	at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:173)
	at org.apache.calcite.sql.test.SqlAdvisorTest.assertComplete(SqlAdvisorTest.java:499)
	at org.apache.calcite.sql.test.SqlAdvisorTest.testNestTable(SqlAdvisorTest.java:1462)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.apache.calcite.test.SqlValidatorTestCase$TesterConfigurationRule$1.evaluate(SqlValidatorTestCase.java:663)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Table 'CATALOG.SALES' 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.runtime.Resources$ExInst.ex(Resources.java:572)
	... 46 more{noformat}

It looks more like a bug in SqlValidator)

> SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match
> ----------------------------------------------------------------------------
>
>                 Key: CALCITE-2434
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2434
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Vladimir Sitnikov
>            Priority: Major
>
> Test (SqlAdvisorTest):
> {code:java}  @Test public void testNestSchema() throws Exception {
>     String sql;
>     sql = "select * from sales.n^";
>     assertComplete(
>         sql,
>     ...);
> }
> {code}
> Expected output: "SALES.NEST" schema and tables inside and so on
> Actual output: empty.
> The thing is it properly uses {{n}} for prefix search, however it uses {{hint.toString()}} and it fails for multi-name identifiers:
> {code:java}        // Regular identifier. Case-insensitive match.
>         for (SqlMoniker hint : completionHints) {
>           String cname = hint.toString();
>           if ((cname.length() >= word.length())
>               && cname.substring(0, word.length()).equalsIgnoreCase(word)) {
>             result.add(hint);
>           }
>         }
> {code}
> Hints are like "CATALOG.SALES.NEST", and they fail {{cname.substring(0, word.length()).equalsIgnoreCase(word)}} check



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)