sqlparse

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 3 Imported by: 0

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 Schema

type Schema struct {
	Database string
	Table    string
	Columns  []string
}

Schema describes a table's columns for validation.

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.

Jump to

Keyboard shortcuts

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