completion

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AggregateFunctions = []string{
	"COUNT", "MAX", "MIN", "AVG", "SUM",
}

Aggregate functions

View Source
var AllResourceTargets = []string{
	"KEYSPACES", "FUNCTIONS", "ROLES",
}

AllResourceTarget for GRANT/REVOKE ON ALL

View Source
var AlterObjectTypes = []string{
	"KEYSPACE", "MATERIALIZED", "ROLE", "TABLE", "TYPE", "USER",
}

AlterObjectTypes for ALTER command

View Source
var AlterSpecificTypes = []string{"TABLE", "KEYSPACE", "TYPE", "ROLE", "USER"}

AlterSpecificTypes for ALTER command (subset)

View Source
var AlterTableOperations = []string{
	"ADD", "DROP", "ALTER", "RENAME", "WITH",
}

AlterTableOperations for ALTER TABLE

View Source
var AlterTypeOperations = []string{
	"ADD", "RENAME",
}

AlterTypeOperations for ALTER TYPE

View Source
var AndKeyword = []string{"AND"}
View Source
var AsKeyword = []string{"AS"}
View Source
var AscDescComma = []string{"ASC", "DESC", ","}
View Source
var BatchTypes = []string{
	"BATCH", "UNLOGGED", "COUNTER",
}

BatchTypes for BEGIN command

View Source
var ByKeyword = []string{"BY"}

SingleKeywords for various single keyword returns

View Source
var CQLDataTypes = []string{
	"ascii", "bigint", "blob", "boolean", "counter",
	"date", "decimal", "double", "float", "frozen",
	"inet", "int", "list", "map", "set",
	"smallint", "text", "time", "timestamp", "timeuuid",
	"tinyint", "tuple", "uuid", "varchar", "varint",
}

Data types for CREATE TABLE

View Source
var CQLPermissions = []string{
	"ALL",
	"ALTER",
	"AUTHORIZE",
	"CREATE",
	"DESCRIBE",
	"DROP",
	"EXECUTE",
	"MODIFY",
	"SELECT",
	"INSERT",
	"UPDATE",
	"DELETE",
	"TRUNCATE",
}

Permissions for GRANT/REVOKE commands

View Source
var ComparisonOperators = []string{
	"=", "!=", "<", ">", "<=", ">=", "IN", "CONTAINS", "CONTAINS KEY",
}

Comparison operators for WHERE clauses

View Source
var ConsistencyLevels = []string{
	"ALL",
	"EACH_QUORUM",
	"QUORUM",
	"LOCAL_QUORUM",
	"ONE",
	"TWO",
	"THREE",
	"LOCAL_ONE",
	"ANY",
	"SERIAL",
	"LOCAL_SERIAL",
}

Consistency levels

View Source
var CopyDirections = []string{
	"TO", "FROM",
}

CopyDirections for COPY command

View Source
var CopyFileSuggestions = []string{
	"'/tmp/export.csv'",
	"'/tmp/export.parquet'",
	"'/tmp/export.json'",
	"'/home/user/data.csv'",
	"'/home/user/data.parquet'",
	"'/data/partitioned/export/'",
	"'./export.csv'",
	"'./export.parquet'",
}

CopyFileSuggestions for COPY command file paths

View Source
var CopyFormats = []string{
	"PARQUET", "CSV", "JSON",
}

CopyFormats for COPY command FORMAT option

View Source
var CopyOptions = []string{

	"HEADER", "DELIMITER", "NULLVAL", "PAGESIZE", "ENCODING", "QUOTE",
	"MAXROWS", "SKIPROWS", "MAXPARSEERRORS", "MAXINSERTERRORS",
	"MAXBATCHSIZE", "MINBATCHSIZE", "CHUNKSIZE",

	"FORMAT", "COMPRESSION", "PARTITION", "PARTITION_FILTER", "MAX_FILE_SIZE",
}

CopyOptions for COPY command WITH clause

View Source
var CreateDropObjectTypes = []string{
	"KEYSPACE", "TABLE", "INDEX", "TYPE", "FUNCTION", "AGGREGATE", "MATERIALIZED", "ROLE", "USER",
}

CreateDropObjectTypes for CREATE/DROP commands (without MATERIALIZED which needs VIEW after it)

View Source
var CreateDropObjectTypesNoMaterialized = []string{
	"KEYSPACE", "TABLE", "INDEX", "TYPE", "FUNCTION", "AGGREGATE", "ROLE", "USER",
}

CreateDropObjectTypesNoMaterialized for checking in switch statements

View Source
var CreateObjectTypes = []string{
	"AGGREGATE", "FUNCTION", "INDEX", "KEYSPACE", "MATERIALIZED",
	"ROLE", "TABLE", "TRIGGER", "TYPE", "USER",
}

CreateObjectTypes for CREATE command

View Source
var DDLObjectTypes = []string{
	"TABLE", "KEYSPACE", "INDEX", "TYPE",
	"FUNCTION", "AGGREGATE", "MATERIALIZED",
	"ROLE", "USER", "TRIGGER",
}

DDL object types

View Source
var DescribeObjects = []string{
	"KEYSPACE", "KEYSPACES",
	"TABLE", "TABLES",
	"TYPE", "TYPES",
	"FUNCTION", "FUNCTIONS",
	"AGGREGATE", "AGGREGATES",
	"MATERIALIZED",
	"INDEX",
	"SCHEMA",
	"CLUSTER",
}

DescribeObjects are the objects that can be described

View Source
var DescribeObjectsBasic = []string{
	"KEYSPACE",
	"KEYSPACES",
	"TABLE",
	"TABLES",
	"TYPE",
	"TYPES",
	"FUNCTION",
	"FUNCTIONS",
	"AGGREGATE",
	"AGGREGATES",
	"MATERIALIZED",
}

DescribeObjectsBasic for parser-based describe (subset)

View Source
var ExistsKeyword = []string{"EXISTS"}
View Source
var FilteringKeyword = []string{
	"FILTERING",
}

CommonDataManipulationKeywords

View Source
var FromCommaAs = []string{"FROM", ",", "AS"}

SelectCompletionKeywords

View Source
var FromKeyword = []string{"FROM"}
View Source
var IfAnd = []string{"IF", "AND"}
View Source
var IfClauseKeywords = []string{
	"NOT", "EXISTS",
}

IfClause keywords

View Source
var IfKeyword = []string{"IF"}
View Source
var IntoKeyword = []string{"INTO"}
View Source
var KeyKeyword = []string{"KEY"}
View Source
var KeyspaceOptions = []string{
	"REPLICATION", "DURABLE_WRITES", "CLUSTERING", "COMPACT", "COMPRESSION",
}

KeyspaceOptions for WITH clause

View Source
var LimitKeyword = []string{"LIMIT"}
View Source
var LimitKeywords = []string{
	"LIMIT", "PARTITION",
}

LimitKeywords

View Source
var ListTargets = []string{
	"USERS", "ROLES", "PERMISSIONS",
}

ListTargets for LIST command

View Source
var LogicalOperators = []string{"AND", "OR"}

Logical operators

View Source
var MaterializedKeyword = []string{
	"VIEW",
}

MaterializedKeyword

View Source
var MaterializedViews = []string{
	"VIEW", "VIEWS",
}

MaterializedViews plural

View Source
var NotKeyword = []string{"NOT"}
View Source
var OnKeyword = []string{"ON"}
View Source
var OrKeyword = []string{"OR"}
View Source
var OutputFormats = []string{
	"ASCII", "TABLE", "EXPAND", "JSON",
}

OutputFormats for OUTPUT command

View Source
var ParquetCompressionTypes = []string{
	"SNAPPY", "GZIP", "ZSTD", "LZ4", "NONE",
}

ParquetCompressionTypes for COPY command COMPRESSION option

View Source
var PartitionKeyword = []string{"PARTITION"}
View Source
var RBACPermissions = []string{"ALL", "SELECT", "MODIFY", "CREATE", "ALTER", "DROP", "AUTHORIZE"}

RBACPermissions for more granular permissions

View Source
var RBACResourceTypes = []string{"KEYSPACE", "TABLE", "ROLE", "ALL"}

RBACResourceTypes

View Source
var ReplicationStrategies = []string{
	"SimpleStrategy",
	"NetworkTopologyStrategy",
}

Replication strategies

View Source
var ResourceTypes = []string{
	"ALL", "KEYSPACE", "TABLE", "ROLE",
	"FUNCTION", "AGGREGATE", "INDEX", "MATERIALIZED",
}

ResourceTypes for GRANT/REVOKE ON clause

View Source
var SelectKeywords = []string{
	"*", "DISTINCT", "JSON",
}

SelectKeywords for SELECT clause

View Source
var SetKeyword = []string{"SET"}
View Source
var SetUsing = []string{"SET", "USING"}

UpdateCompletionKeywords

View Source
var ShowCommands = []string{
	"VERSION", "HOST", "SESSION",
}

ShowCommands for SHOW command completions

View Source
var SortOrders = []string{"ASC", "DESC"}

Sort orders for ORDER BY

View Source
var SystemFunctions = []string{
	"token", "uuid", "blobAsText", "textAsBlob",
	"blobAsBigint", "bigintAsBlob", "TTL", "WRITETIME",
}

Other system functions

View Source
var TableKeyword = []string{"TABLE"}

TableKeyword for TRUNCATE TABLE

View Source
var TableOptions = []string{
	"bloom_filter_fp_chance",
	"caching",
	"comment",
	"compaction",
	"compression",
	"crc_check_chance",
	"dclocal_read_repair_chance",
	"default_time_to_live",
	"gc_grace_seconds",
	"max_index_interval",
	"memtable_flush_period_in_ms",
	"min_index_interval",
	"read_repair_chance",
	"speculative_retry",
}

Common table options for WITH clause

View Source
var TimeFunctions = []string{
	"now", "currentTimeUUID", "currentTimestamp", "currentDate",
	"minTimeuuid", "maxTimeuuid", "toDate", "toTimestamp",
	"toUnixTimestamp", "dateOf", "unixTimestampOf",
}

Time/UUID functions

View Source
var TimestampKeyword = []string{"TIMESTAMP"}
View Source
var ToKeyword = []string{"TO"}
View Source
var TopLevelCommands = []string{
	"SELECT", "INSERT", "UPDATE", "DELETE",
	"CREATE", "DROP", "ALTER", "TRUNCATE",
	"GRANT", "REVOKE",
	"USE",
	"DESCRIBE", "DESC",
	"BEGIN", "APPLY",
	"LIST",
	"CONSISTENCY",
	"OUTPUT",
	"TRACING",
	"PAGING",
	"AUTOFETCH",
	"SHOW",
	"HELP",
	"SOURCE",
	"CAPTURE",
	"EXPAND",
	"COPY",
}

TopLevelCommands are the main CQL and meta commands

View Source
var TopLevelKeywords = []string{
	"ALTER",
	"APPLY",
	"BEGIN",
	"CAPTURE",
	"CONSISTENCY",
	"COPY",
	"CREATE",
	"DELETE",
	"DESCRIBE",
	"DESC",
	"DROP",
	"EXPAND",
	"GRANT",
	"HELP",
	"INSERT",
	"LIST",
	"OUTPUT",
	"PAGING",
	"AUTOFETCH",
	"REVOKE",
	"SELECT",
	"SHOW",
	"SOURCE",
	"TRACING",
	"TRUNCATE",
	"UPDATE",
	"USE",
}

TopLevelKeywords for parser-based completion (alphabetical)

View Source
var UsingOptions = []string{
	"TTL", "TIMESTAMP",
}

UsingOptions for INSERT/UPDATE/DELETE

View Source
var ValuesKeyword = []string{"VALUES"}
View Source
var WhereIf = []string{"WHERE", "IF"}
View Source
var WhereKeyword = []string{"WHERE"}
View Source
var WhereUsingIf = []string{"WHERE", "USING", "IF"}

DeleteCompletionKeywords

View Source
var WithKeyword = []string{"WITH"}

Individual keyword constants for safer access

Functions

func FindCommonPrefix

func FindCommonPrefix(completions []string) string

FindCommonPrefix finds the common prefix of all completion options

func GetCommandObjects

func GetCommandObjects(command, objectType string) []string

GetCommandObjects returns object names for DDL commands

func GetFollowKeywords

func GetFollowKeywords(keyword string) []string

GetFollowKeywords returns keywords that can follow a given keyword

func IsCompleteKeyword

func IsCompleteKeyword(word string) bool

IsCompleteKeyword checks if a word is a complete CQL keyword This is exported for use by other packages (e.g., ui package)

func IsObjectType

func IsObjectType(word string) bool

IsObjectType checks if a word is a database object type

Types

type CompletionEngine

type CompletionEngine struct {
	// contains filtered or unexported fields
}

CompletionEngine handles tab completion for CQL commands

func NewCompletionEngine

func NewCompletionEngine(dbSession *db.Session, sessionMgr *session.Manager) *CompletionEngine

NewCompletionEngine creates a new completion engine

func (*CompletionEngine) Complete

func (ce *CompletionEngine) Complete(input string) []string

Complete returns possible completions for the given input

func (*CompletionEngine) CompleteNative added in v0.0.5

func (ce *CompletionEngine) CompleteNative(input string) []string

CompleteNative returns possible completions for the given input using native pattern matching

type SimpleCompletionEngine added in v0.0.11

type SimpleCompletionEngine struct {
	*CompletionEngine
}

SimpleCompletionEngine provides completions without using ANTLR

func NewSimpleCompletionEngine added in v0.0.11

func NewSimpleCompletionEngine(ce *CompletionEngine) *SimpleCompletionEngine

NewSimpleCompletionEngine creates a completion engine without ANTLR

func (*SimpleCompletionEngine) GetTokenCompletions added in v0.0.11

func (sce *SimpleCompletionEngine) GetTokenCompletions(input string) []string

GetTokenCompletions provides context-aware completions using simple string parsing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL