@uwdata/mosaic-sql
Version:
SQL query construction and analysis.
32 lines • 837 B
JavaScript
import { CastNode } from '../ast/cast.js';
import { asNode } from '../util/ast.js';
/**
* Perform a type cast.
* @param expr The expression to type cast.
* @param type The type to cast to.
*/
export function cast(expr, type) {
return new CastNode(asNode(expr), type);
}
/**
* Cast an expression to a 32-bit integer type.
* @param expr The expression to type cast.
*/
export function int32(expr) {
return cast(expr, 'INTEGER');
}
/**
* Cast an expression to a 32-bit floating point number type.
* @param expr The expression to type cast.
*/
export function float32(expr) {
return cast(expr, 'FLOAT');
}
/**
* Cast an expression to a 64-bit floating point number type.
* @param expr The expression to type cast.
*/
export function float64(expr) {
return cast(expr, 'DOUBLE');
}
//# sourceMappingURL=cast.js.map