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/16 20:47:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=16583046#comment-16583046 ] 

Vladimir Sitnikov commented on CALCITE-2434:
--------------------------------------------

[~julianhyde],  current {{org.apache.calcite.sql.validate.SqlValidatorWithHints}} produces hints as follows:
{code:java}List<SqlMoniker> lookupHints(SqlNode topNode, SqlParserPos pos);{code}

In other words, if {{select * from sales.e^}} autocompletes to {{catalog.sales.emps}}, then SqlMoniker would be {{CATALOG.SALES.EMPS}}, and it does store information that {{e}} should be replaced with {{emps}}, and not with {{sales.emps}} or even {{catalog.sales.emps}}.

I'm going to add relevant methods to {{SqlMoniker}} to designate either "number of already present in the query parts of name"
For instance, for {{sales.e^}} and {{catalog.sales.emps}} it would return 2 meaning the first two names are already present in the query.

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