sql_diff: Structural diff between two SQL statements

View source: R/analysis.R

sql_diffR Documentation

Structural diff between two SQL statements

Description

Compares the ASTs of two statements and reports inserted, removed, moved and updated nodes.

Usage

sql_diff(sql_from, sql_to, dialect = "generic", delta_only = TRUE)

Arguments

sql_from, sql_to

Single SQL statements to compare.

dialect

Dialect used for parsing.

delta_only

If TRUE (default), omit unchanged ("keep") nodes.

Value

A data frame with columns op ("insert", "remove", "move", "update", "keep"), expression (SQL of the affected node) and target (for updates, the new SQL).

Examples

sql_diff("SELECT a FROM t", "SELECT a, b FROM t WHERE a > 1")

polyglotSQL documentation built on Sept. 27, 2026, 5:06 p.m.