batch

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsShellCommand added in v0.1.2

func IsShellCommand(cmd string) bool

IsShellCommand checks if a command is a shell command that terminates on newline

func SplitForNode added in v0.1.2

func SplitForNode(text string) ([]string, error)

SplitForNode is the main entry point for splitting CQL input into statement strings. This function was created for the Node.js bindings and provides robust tokenization that correctly handles semicolons inside strings, comments, and BATCH blocks.

Types

type Executor

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

Executor handles batch mode execution

func NewExecutor

func NewExecutor(options *Options, writer io.Writer) (*Executor, error)

NewExecutor creates a new batch executor

func (*Executor) Close

func (e *Executor) Close() error

Close closes the executor and its resources

func (*Executor) Execute

func (e *Executor) Execute(cql string) error

Execute runs a single CQL statement

func (*Executor) ExecuteFile

func (e *Executor) ExecuteFile(filename string) error

ExecuteFile executes CQL from a file

func (*Executor) ExecuteMulti added in v0.1.2

func (e *Executor) ExecuteMulti(cql string) error

ExecuteMulti runs multiple CQL statements using the robust CQL splitter

func (*Executor) ExecuteStdin

func (e *Executor) ExecuteStdin() error

ExecuteStdin executes CQL from stdin

type Options

type Options struct {
	Execute     string       // CQL to execute directly (-e flag)
	File        string       // CQL file to execute (-f flag)
	Format      OutputFormat // Output format
	NoHeader    bool         // Skip headers in output
	FieldSep    string       // Field separator for CSV
	NoPager     bool         // Disable paging (print all results)
	PageSize    int          // Number of rows per batch for streaming
	ConnOptions ui.ConnectionOptions
}

Options contains batch execution options

type OutputFormat

type OutputFormat string

OutputFormat represents the output format for batch mode

const (
	OutputFormatASCII OutputFormat = "ascii"
	OutputFormatJSON  OutputFormat = "json"
	OutputFormatCSV   OutputFormat = "csv"
	OutputFormatTable OutputFormat = "table" // Default table format
)

type SplitResult added in v0.1.2

type SplitResult struct {
	Statements  [][]Token // Each statement as array of tokens
	Incomplete  bool      // True if input is incomplete
	SourceText  string    // Original source text
	Identifiers []string  // First identifier of each statement (SELECT, INSERT, etc.)
	ExtraTokens []string  // 2nd and 3rd meaningful tokens from first statement
}

SplitResult contains the result of splitting CQL statements

func SplitStatements added in v0.1.2

func SplitStatements(text string) (*SplitResult, error)

SplitStatements splits CQL input into individual statements

func (*SplitResult) ExtractStatementText added in v0.1.2

func (sr *SplitResult) ExtractStatementText(tokens []Token) string

ExtractStatementText extracts the original text for a token slice

func (*SplitResult) GetStatementStrings added in v0.1.2

func (sr *SplitResult) GetStatementStrings() []string

GetStatementStrings returns the statements as strings

type Token added in v0.1.2

type Token struct {
	Type  TokenType
	Value string
	Start int
	End   int
}

Token represents a lexed CQL token

func Lex added in v0.1.2

func Lex(text string) ([]Token, error)

Lex tokenizes CQL input text

func MassageTokens added in v0.1.2

func MassageTokens(tokens []Token) []Token

MassageTokens converts newlines to endtokens for special commands

type TokenType added in v0.1.2

type TokenType int

TokenType represents the type of a CQL token

const (
	TokenEndline TokenType = iota
	TokenEndtoken
	TokenIdentifier
	TokenQuotedStringLiteral
	TokenQuotedName
	TokenPgStringLiteral
	TokenUnclosedString
	TokenUnclosedName
	TokenUnclosedPgString
	TokenUnclosedComment
	TokenFloat
	TokenUUID
	TokenBlobLiteral
	TokenWholenumber
	TokenColon
	TokenStar
	TokenOp
	TokenCmp
	TokenBrackets
	TokenJunk // For patterns we want to skip (whitespace, comments)
)

Jump to

Keyboard shortcuts

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