Skip to content

Conversation

@TimelordUK
Copy link
Owner

  • Create minimal DataProvider trait with core data access methods
  • Add DataViewProvider trait for filtering/sorting operations
  • Include default implementations for common methods
  • Add comprehensive tests for the new traits

This is the first step in migrating to a DataTable/DataView architecture. The traits define the contract that the TUI will use to access data, allowing us to gradually replace the underlying implementation.

- Create minimal DataProvider trait with core data access methods
- Add DataViewProvider trait for filtering/sorting operations
- Include default implementations for common methods
- Add comprehensive tests for the new traits

This is the first step in migrating to a DataTable/DataView architecture.
The traits define the contract that the TUI will use to access data,
allowing us to gradually replace the underlying implementation.
@TimelordUK TimelordUK merged commit 19a6a0d into main Aug 12, 2025
2 checks passed
TimelordUK added a commit that referenced this pull request Oct 26, 2025
Extends the AST preprocessing pipeline to work with script execution (-f flag),
enabling all Quick Win features (WHERE/GROUP BY/HAVING alias expansion) in
SQL scripts with GO separators.

## Problem

Scripts executed with -f flag were bypassing the preprocessing pipeline,
so Quick Win features (alias expansion) only worked in query mode (-q) and
interactive mode. This made scripts inconsistent with other execution modes.

## Solution

Added preprocessing pipeline to script execution in execute_script():
- Parse each statement in the script
- Apply full preprocessing pipeline if statement has FROM clause
- Fall back to original query if preprocessing fails
- Preserve special row-iteration semantics for queries without FROM

## Implementation

Modified src/non_interactive.rs execute_script():
- Check if statement has FROM clause
- If yes: apply preprocessing pipeline, then format AST back to SQL
- If no: preserve original behavior (special semantics)
- Handle INTO clause removal after preprocessing

Pipeline runs transformers in order:
1. ExpressionLifter
2. WhereAliasExpander
3. GroupByAliasExpander
4. HavingAliasTransformer
5. CTEHoister
6. InOperatorLifter

## New Reference File

Added examples/expansion_transformers.sql:
- Comprehensive reference showing all supported alias expansion features
- Documents Quick Wins #1, #2, #3
- Shows working examples for each transformer
- Documents future enhancements (CASE, BETWEEN, IN with aliases)
- Includes implementation notes and testing commands
- Can be run directly: sql-cli examples/expansion_transformers.sql

## Tests

All tests passing:
- 487 Rust unit tests
- 397 integration tests
- 511 Python tests
- expansion_transformers.sql runs successfully with all features working

## Benefits

- Scripts now have feature parity with query and interactive modes
- Users can write cleaner SQL scripts with alias expansion
- Example files demonstrate best practices
- Consistent behavior across all execution modes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant