Skip to content

AST Tree Nodes Reference

This section provides comprehensive documentation for all Abstract Syntax Tree (AST) nodes in General SQL Parser. The AST represents the hierarchical structure of parsed SQL statements, where each node corresponds to a specific SQL element.

Looking for "how do I walk the tree"?

This section is a catalog of node types — what fields each one has. If you're learning how the AST is wired together, start with Parse-tree Internals. If you want copy-pasteable traversal recipes, see Walk the Parse Tree.

Quick Navigation

Core Node Categories

📋 SQL Statements

Top-level SQL operations and commands - SELECT Statement - Query operations - INSERT Statement - Data insertion
- UPDATE Statement - Data modification - DELETE Statement - Data removal - DDL Statements - Schema operations

🔧 SQL Clauses

Components that appear within SQL statements - WHERE Clause - Filtering conditions - FROM Clause - Data sources - JOIN Clause - Table relationships - GROUP BY Clause - Data grouping - ORDER BY Clause - Result sorting

🧮 Expressions

Mathematical, logical, and comparison operations - Basic Expressions - TExpression overview - Function Calls - SQL functions - Arithmetic Operations - Math operations - Logical Operations - AND, OR, NOT - CASE Expressions - Conditional logic

🗂️ Table References

How tables and data sources are represented - Table Nodes - Basic table references - JOIN Nodes - Table joins - Derived Tables - Subqueries as tables

📊 Columns and Lists

Column selections and list structures
- Result Columns - SELECT column lists - Column References - Column identifiers - Value Lists - INSERT values

📝 Literals and Constants

Constant values and data types - String Literals - Text values - Numeric Literals - Numbers
- Date Literals - Dates and times

🚀 Advanced Nodes

Complex SQL features and database-specific nodes - Window Functions - OVER clauses - Common Table Expressions - WITH clauses - Database-Specific Features - Vendor extensions

Getting Started

For SQL Analysts

  1. Start with SELECT Statement to understand query structure
  2. Learn about WHERE Clause for filtering
  3. Explore Expressions for condition analysis

For .NET Developers

  1. Review Basic Expressions for core concepts
  2. Check API Reference for method signatures
  3. See the DocFX API site for the complete type reference

For Data Engineers

  1. Focus on Table References for lineage analysis
  2. Study JOIN Nodes for relationship mapping
  3. Use Advanced Nodes for complex transformations

Common Usage Patterns

Traversing AST trees

1
2
3
4
5
6
// Basic pattern for visiting all nodes
public void TraverseAst(TCustomSqlStatement stmt)
{
    stmt.acceptChildren(new LambdaVisitor(node =>
        Console.WriteLine(node.GetType().Name)));
}

Finding specific node types

1
2
3
4
5
6
7
8
// Find all SELECT statements in a script
var selects = new List<TSelectSqlStatement>();
for (int i = 0; i < parser.sqlstatements.size(); i++)
{
    TCustomSqlStatement stmt = parser.sqlstatements.get(i);
    if (stmt is TSelectSqlStatement select)
        selects.Add(select);
}

Node Hierarchy Overview

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
TSqlStatement (Abstract base)
├── TSelectSqlStatement
├── TInsertSqlStatement  
├── TUpdateSqlStatement
├── TDeleteSqlStatement
├── TCreateSqlStatement
└── TCustomSqlStatement
    └── Various database-specific statements

TParseTreeNode (Abstract base)
├── TExpression (and subtypes)
├── TSourceToken
└── Various clause and component nodes

📋 Nodes in XML

See Also