Documentation
¶
Overview ¶
Package trino provides SQL parser for Trino.
Package trino provides SQL parser for Trino.
Index ¶
- func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, ...) ([]base.Candidate, error)
- func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)
- func ExtractDatabaseSchemaName(ctx parser.IQualifiedNameContext, defaultDatabase, defaultSchema string) (string, string, string)
- func ExtractQualifiedNameParts(ctx parser.IQualifiedNameContext) []string
- func GetQuerySpan(ctx context.Context, gCtx base.GetQuerySpanContext, ...) (*base.QuerySpan, error)
- func IsDataChangingStatement(tree any) bool
- func IsReadOnlyStatement(tree any) bool
- func IsSchemaChangingStatement(tree any) bool
- func NormalizeTrinoIdentifier(ident string) string
- func ParseTrino(sql string) ([]*base.ParseResult, error)
- func SplitSQL(statement string) ([]base.SingleSQL, error)
- type Completer
- type CompletionMap
- type SelectAliasListener
- type StatementType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Completion ¶
func Diagnose ¶
func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)
Diagnose diagnoses the SQL statement and returns any syntax errors.
func ExtractDatabaseSchemaName ¶
func ExtractDatabaseSchemaName(ctx parser.IQualifiedNameContext, defaultDatabase, defaultSchema string) (string, string, string)
ExtractDatabaseSchemaName extracts catalog/database, schema, and table/name parts from qualified name. For data access control features, we need consistent catalog.schema.table.column format
func ExtractQualifiedNameParts ¶
func ExtractQualifiedNameParts(ctx parser.IQualifiedNameContext) []string
ExtractQualifiedNameParts extracts the parts of a qualified name.
func GetQuerySpan ¶
func GetQuerySpan(ctx context.Context, gCtx base.GetQuerySpanContext, statement, database, schema string, ignoreCaseSensitive bool) (*base.QuerySpan, error)
GetQuerySpan gets the query span for Trino. This is the entry point registered with the base package.
func IsDataChangingStatement ¶
IsDataChangingStatement returns whether the statement changes data.
func IsReadOnlyStatement ¶
IsReadOnlyStatement returns whether the statement is read-only.
func IsSchemaChangingStatement ¶
IsSchemaChangingStatement returns whether the statement changes schema.
func NormalizeTrinoIdentifier ¶
NormalizeTrinoIdentifier normalizes the identifier for Trino.
func ParseTrino ¶
func ParseTrino(sql string) ([]*base.ParseResult, error)
ParseTrino parses the given SQL statement and returns a list of ParseResults. Each ParseResult represents one statement with its AST, tokens, and base line offset.
Types ¶
type Completer ¶
type Completer struct {
// contains filtered or unexported fields
}
func NewStandardCompleter ¶
func NewTrickyCompleter ¶
type CompletionMap ¶
func (CompletionMap) Insert ¶
func (m CompletionMap) Insert(entry base.Candidate)
type SelectAliasListener ¶
type SelectAliasListener struct {
*trinoparser.BaseTrinoParserListener
// contains filtered or unexported fields
}
func (*SelectAliasListener) EnterAs_column_alias ¶
func (l *SelectAliasListener) EnterAs_column_alias(ctx *trinoparser.As_column_aliasContext)
type StatementType ¶
type StatementType int
StatementType is the type of the SQL statement.
const ( Unsupported StatementType = iota Select Explain Insert Update Delete Merge CreateTable CreateView AlterTable DropTable DropView CreateSchema DropSchema RenameTable CreateTableAsSelect Set Show )
Statement types
func GetStatementType ¶
func GetStatementType(tree any) StatementType
GetStatementType returns the detailed statement type for query span.