pub fn cast(expr: Expr, to: &str) -> ExprExpand description
Create a CAST(expr AS type) expression.
The to parameter is parsed as a data type name. Common built-in types (INT, BIGINT,
VARCHAR, BOOLEAN, TIMESTAMP, etc.) are recognized directly. More complex types
(e.g. "DECIMAL(10,2)", "ARRAY<INT>") are parsed via the full SQL parser as a
fallback.
ยงExamples
use polyglot_sql::builder::{cast, col};
let expr = cast(col("id"), "VARCHAR");
assert_eq!(expr.to_sql(), "CAST(id AS VARCHAR)");