Documentation
¶
Overview ¶
Package sqlparse provides a lightweight SQL validator for Athena and Redshift. It extracts table and column references from SQL statements and validates them against a schema registry. It does NOT execute queries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(parsed *ParseResult, registry *SchemaRegistry) []string
Validate checks a parsed SQL result against a schema registry. Returns validation errors (table not found, column not found).
Types ¶
type ParseResult ¶
type ParseResult struct {
StatementType string // SELECT, INSERT, CREATE, etc.
Tables []string // Table references from FROM/JOIN
Columns []string // Column references from SELECT/WHERE
IsValid bool
Errors []string
}
ParseResult contains the extracted elements from a SQL statement.
func Parse ¶
func Parse(sql string) *ParseResult
Parse extracts table and column references from a SQL statement.
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry maps "database.table" to column lists.
func NewSchemaRegistry ¶
func NewSchemaRegistry() *SchemaRegistry
NewSchemaRegistry creates an empty registry.
func (*SchemaRegistry) Len ¶
func (r *SchemaRegistry) Len() int
Len returns the number of registered schemas.
func (*SchemaRegistry) Lookup ¶
func (r *SchemaRegistry) Lookup(ref string) (*Schema, bool)
Lookup returns the schema for a table, checking both "db.table" and just "table".
func (*SchemaRegistry) Register ¶
func (r *SchemaRegistry) Register(database, table string, columns []string)
Register adds a table schema.