You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Michael Edge (JIRA)" <ji...@apache.org> on 2015/11/20 12:00:13 UTC

[jira] [Commented] (CASSANDRA-10733) Inconsistencies in CQLSH auto-complete

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

Michael Edge commented on CASSANDRA-10733:
------------------------------------------

Need some advice on the second issue in this JIRA from someone more familiar with cqlsh. The problem is caused by this piece of code (see code between ####):

{{cqlhandling.py}}
{code}
    def cql_complete_multiple(self, text, first, init_bindings, startsymbol='Start'):
        debug = init_bindings.get('*DEBUG*', True)
        try:
            completions, hints = self.cql_complete_single(text + first, '', init_bindings,
                                                          startsymbol=startsymbol)
        except Exception:
            if debug:
                print "** completion expansion had a problem:"
                traceback.print_exc()
            return first
        if hints:
            ########################
             if not first[-1].isspace():
                first += ' '
            ########################
            if debug:
                print "** completion expansion found hints: %r. First: %r." % (hints,first,)
            return first
{code}

This code adds a space onto an auto-completed clause, which is fine; unfortunately it also adds a space onto a partially completed clause, which is causing the problem. I could remove this, or only apply it if the clause is complete (not partially complete), but I don't know whether it would impact any other components.

h3. To replicate the issue do the following:

In a keyspace with no functions (let's call the keyspace 'shopping'), create two functions with the same prefix; for example, 'avgstate' and 'avgfinal'. There are now 2 functions in keyspace 'shopping'. Then in cqlsh type {{'desc function sho'}} and hit the tab key. cqlsh should complete the clause and show {{'desc function shopping.avg'}}. A further tab would display the two matching functions.

Instead it displays {{'desc function shopping.avg '}} (note the trailing space). A further tab does not display the matching functions.

> Inconsistencies in CQLSH auto-complete
> --------------------------------------
>
>                 Key: CASSANDRA-10733
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10733
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL, Tools
>            Reporter: Michael Edge
>            Assignee: Michael Edge
>            Priority: Trivial
>              Labels: cqlsh, lhf
>             Fix For: 2.1.x, 2.2.x, 3.x
>
>         Attachments: CASSANDRA-3.0-10733-CQLSH-Auto.patch
>
>
> Auto-complete in cqlsh does not work correctly on some commands. We see some inconsistent behaviour when completing part of the statement and hitting the tab key.
> {color:green}Works correctly{color}
> Auto-complete on {{'desc table '}}, {{'desc function '}} and {{'desc type '}} works correctly. We see a list of all tables (or functions, types) in the current keyspace plus a list of all available keyspaces followed by a full stop (e.g. system.)
> {code}
> cqlsh:fxaggr> desc TABLE 
>                      minutedata           system_distributed.
> ;                    rawtickdatabylp      system_traces.
> <enter>              rawtickdatabysymbol  tickdata
> daydata              system.              
> fxaggr.              system_auth.     
> {code}
> {color:red}Fix required{color}
> {{'desc aggregate '}} displays the aggregates in the current keyspace (in this case, only 1, called 'average') but does not display a list of available keyspaces. It only displays the current keyspace, with no following full stop.
> {code}
> cqlsh:fxaggr> desc aggregate 
>          ;        <enter>  average  fxaggr
> {code}
> {color:green}Works correctly{color}
> Auto-complete on {{'desc table <keyspace>. '}} and {{'desc type <keyspace>.'}} works correctly. We see a list of all tables (or types) in the current keyspace
> {code}
> cqlsh:fxaggr> desc table fxaggr.
> daydata              rawtickdatabylp      tickdata
> minutedata           rawtickdatabysymbol  
> {code}
> {color:red}Fix required{color}
> Auto-complete on {{'desc function <keyspace>. '}} and {{'desc aggregate <keyspace>.'}} works inconsistently. In a keyspace with 2 functions, both beginning with the letters 'avg', if I type {{'desc function <keyspace>'}} and hit tab, auto-complete will result in this: {{'desc function fxaggr.avg '}} and will not display the matching functions. If I type {{'desc function <keyspace>.'}} (note the trailing full stop) and hit tab, auto-complete will work correctly:
> {code}
> cqlsh:fxaggr> desc function fxaggr.avg
> avgfinal  avgstate  
> {code}
> If I type {{'desc aggregate <keyspace>'}} and hit tab, auto-complete returns  {{'desc aggregate <keyspace> '}}  (it adds a space) and does not show me the list of available aggregates. If I type {{'desc aggregate <keyspace>.'}} (note the trailing full stop) and hit tab, auto-complete will work correctly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)