def suggest_type(full_text, text_before_cursor):

    if full_text.startswith('\\i '):
        return (Path(),)

    word_before_cursor = last_word(text_before_cursor,
            include='many_punctuations')

    identifier = None

    def strip_named_query(txt):
        """
        This will strip "save named query" command in the beginning of the line:
        '\ns zzz SELECT * FROM abc'   -> 'SELECT * FROM abc'
        '  \ns zzz SELECT * FROM abc' -> 'SELECT * FROM abc'
        """
        pattern = re.compile(r'^\s*\\ns\s+[A-z0-9\-_]+\s+')
        if pattern.match(txt):
            txt = pattern.sub('', txt)
        return txt

    full_text = strip_named_query(full_text)
    text_before_cursor = strip_named_query(text_before_cursor)

    # If we've partially typed a word then word_before_cursor won't be an empty
    # string. In that case we want to remove the partially typed string before
    # sending it to the sqlparser. Otherwise the last token will always be the
    # partially typed string which renders the smart completion useless because
    # it will always return the list of keywords as completion.
    if word_before_cursor:
        if word_before_cursor[-1] == '(' or word_before_cursor[0] == '\\':
            parsed = sqlparse.parse(text_before_cursor)
        else:
            parsed = sqlparse.parse(
                text_before_cursor[:-len(word_before_cursor)])

            identifier = parse_partial_identifier(word_before_cursor)
    else:
        parsed = sqlparse.parse(text_before_cursor)

    if len(parsed) > 1:
        # Multiple statements being edited -- isolate the current one by
        # cumulatively summing statement lengths to find the one that bounds the
        # current position
        current_pos = len(text_before_cursor)
        stmt_start, stmt_end = 0, 0

        for statement in parsed:
            stmt_len = len(statement.to_unicode())
            stmt_start, stmt_end = stmt_end, stmt_end + stmt_len

            if stmt_end >= current_pos:
                text_before_cursor = full_text[stmt_start:current_pos]
                full_text = full_text[stmt_start:]
                break

    elif parsed:
        # A single statement
        statement = parsed[0]
    else:
        # The empty string
        statement = None

    # Check for special commands and handle those separately
    if statement:
        # Be careful here because trivial whitespace is parsed as a statement,
        # but the statement won't have a first token
        tok1 = statement.token_first()
        if tok1 and tok1.value == '\\':
            return suggest_special(text_before_cursor)

    last_token = statement and statement.token_prev(len(statement.tokens)) or ''

    return suggest_based_on_last_token(last_token, text_before_cursor,
                                       full_text, identifier)
Creates a union of N sorted sets at dstkey. keys can be a list
dataset/ETHPy150Open dbcli/pgcli/pgcli/packages/sqlcompletion.py/suggest_type--crossover with--dataset/ETHPy150Open deldotdr/txRedis/txredis/client.py/RedisClient.zunionstore