v0.14 to v1 AST Migration
If there are inaccuracies discovered with this documentation, please submit a GitHub issue. |
This guide is intended to cover the differences between the Abstract Syntax Tree (AST) interfaces used in partiql-lang-kotlin v0.14 and partiql-lang-kotlin v1.
Changes Between v0.14 and v1
AST Class Definitions
The primary change between the two versions are the class definitions and representation of enums. Many of the classes
have been renamed to avoid overly nesting class definitions. For example, a select list item expression in v0.14 would
have a type of Select.Project.Item.Expression
whereas in v1, the equivalent name would be SelectItem.Expr.
Another major change was the modeling of select-from-where queries. In v0.14, the modeling of Expr.SFW
, did not
permit representing queries with LIMIT
, OFFSET
, and ORDER BY
applied on a set operation and the SFW query.
In v1, this improper modeling has been corrected with the introduction of ExprQuerySet and QueryBody.
v0.14’s usage of data classes, sealed classes, and enums, restricted our ability to add new features
in a backwards-compatible way. Adding a new enum variant for example would break any existing when
expressions in
Kotlin and switch
statements in Java if the customer had not included an else branch. v1
introduces its own
AstEnum abstract class that models the same functionality as typical enum
classes but requires including an
else
branch when used.
Finally, since v1’s classes are written in Java as opposed to v0.14 being written in Kotlin, users cannot use named arguments for constructor calls. v1 still provides the capability to use Kotlin named arguments in the factory methods. v1 still provides the same builder, equality, and hashcode functionality from v0.14.
AST Other Changes
v1 still provides some default interfaces for visiting the AST. v0.14’s basic visitor AstBaseVisitor
has
been renamed to AstVisitor in v1. v0.14’s basic rewriter AstRewriter
follows the same name in v1. More on AST manipulation can be found
here.
The AST → SQL text converter, SqlDialect
, also retains the same naming in v1.