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

Vladimir Sitnikov commented on CALCITE-2439:
--------------------------------------------

AFAIK, IDEA (which is Apache 2.0 licensed) uses multiple weigher classes, and 
it does not need to have all the suggestions in order to weigh them.

CompletionWeigher: note that it takes LookupElement and produces a Comparable

https://github.com/JetBrains/intellij-community/blob/32490f0799fb27cafe7a3c3887726c76fd45649c/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionWeigher.java#L15

PrioritizedLookupElement describes several ways to weigh elements (e.g. 
assigned by developer weigh, frequency of use, etc, etc)

https://github.com/JetBrains/intellij-community/blob/32490f0799fb27cafe7a3c3887726c76fd45649c/platform/lang-api/src/com/intellij/codeInsight/completion/PrioritizedLookupElement.java#L12

Actual completions seems to be identified "one by one" like 
https://github.com/JetBrains/intellij-community/blob/f30026027e66c8cac6f48adfa9c48e23d61eee0c/java/java-impl/src/com/intellij/codeInsight/completion/JavaMemberNameCompletionContributor.java#L112

Based on that I assume a function like "find all possible" + multiple weighers 
should be enough for Calcite purposes as well.



> Smart complete for SqlAdvisor
> -----------------------------
>
>                 Key: CALCITE-2439
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2439
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>
> Current implementation of SqlAdvisor provides no way to perform smart 
> complete.
> For example,
>  1) A valid completion for {{select cd^ from clients}} might be {{select 
> client_id from clients}}.
>  That is completion is valid if all input characters are represented in final 
> word in a proper sequence.
> 2) Completion might be case-insensitive if all input characters have the same 
> upper/lower case.
> 3) "Contains" might be valid completion option as well. That is {{select id^ 
> from ...}} might be completed to \{{select client_id from...} as well.
> Of course, exact match should be sorted the first, then partial matches and 
> so on.
> It is not clear if smart complete logic belongs to {{SqlAdvisor}} or not. 
> Current client-facing API provides no way to skip default "case-sensitive 
> prefix filtering", so there's no way to implement smart complete at the 
> client side only.
> It is not clear where this logic belongs:
>  a) Ultimate solution would be "skip filtering the identifiers at SqlAdvisor 
> side". Then client can filter and sort the way it wants. The downside of the 
> approach is it would force client to pipe large amount of items across JDBC 
> bridge
>  b) It might be helpful if Calcite had pre-defined implementations that would 
> filter and sort the results. The good part is it simplifies client 
> development, however various clients might have various filters applied.



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

Reply via email to