Module preprocessor

Module preprocessor 

Source
Expand description

SQL dialect-specific preprocessing.

This module transforms SQL statements to remove or normalize constructs that are not supported by the sqlparser crate, while preserving the semantic meaning for analysis.

§Supported Dialects

  • ClickHouse: Handles CODEC, TTL, SETTINGS clauses

§Architecture

The preprocessor operates in two phases:

  1. Extraction: Captures dialect-specific metadata (codecs, TTL rules)
  2. Transformation: Removes unsupported syntax for clean parsing

§Example

use sql_query_analyzer::{preprocessor::Preprocessor, query::SqlDialect};

let sql = "CREATE TABLE logs (data String CODEC(ZSTD)) ENGINE = MergeTree ORDER BY id";
let result = Preprocessor::new(SqlDialect::ClickHouse).process(sql);

assert!(!result.sql.contains("CODEC"));
assert!(result.metadata.codecs.contains_key("data"));

Modules§

clickhouse
ClickHouse-specific SQL preprocessing.

Structs§

Preprocessor
Preprocessor for dialect-specific SQL transformations.
PreprocessorMetadata
Metadata extracted during preprocessing.
PreprocessorResult
Result of SQL preprocessing.