Skip to content

Base

bcql_py.models.base

Base class for all BCQL AST nodes.

Every node in the parsed BCQL tree inherits from BCQLNode, a frozen Pydantic v2 BaseModel (immutable after construction) with a node_type discriminator field used for serialisation and query reconstruction.

BCQLNode

Bases: BaseModel, ABC

Abstract base for every node in the BCQL abstract syntax tree.

Sub-classes must override to_bcql and set node_type to a unique Literal string so that discrimination works correctly.

Configuration
  • frozen = True: instances are immutable after creation
  • use_enum_values = True: enum fields store their .value

bcql cached property

bcql: str

Convenience property to get the BCQL string representation of this node.

to_bcql abstractmethod

to_bcql() -> str

Reconstruct a BCQL query string from this AST node.

The returned string is functionally equivalent to the original query but may differ in trivial whitespace and formatting.