trino

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package trino provides SQL parser for Trino.

Package trino provides SQL parser for Trino.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Completion

func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) ([]base.Candidate, error)

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

func IsDataChangingStatement(tree any) bool

IsDataChangingStatement returns whether the statement changes data.

func IsReadOnlyStatement

func IsReadOnlyStatement(tree any) bool

IsReadOnlyStatement returns whether the statement is read-only.

func IsSchemaChangingStatement

func IsSchemaChangingStatement(tree any) bool

IsSchemaChangingStatement returns whether the statement changes schema.

func NormalizeTrinoIdentifier

func NormalizeTrinoIdentifier(ident string) string

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.

func SplitSQL

func SplitSQL(statement string) ([]base.SingleSQL, error)

SplitSQL splits the given SQL statement into multiple SQL statements. Following TSQL's pattern, we try parser-based splitting first, then fall back to tokenizer.

Types

type Completer

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

func NewStandardCompleter

func NewStandardCompleter(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) *Completer

func NewTrickyCompleter

func NewTrickyCompleter(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) *Completer

type CompletionMap

type CompletionMap map[string]base.Candidate

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.

Jump to

Keyboard shortcuts

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