Skip to main content

Module typeconv

Module typeconv 

Source
Expand description

Maintains a catalog of valid casts between mz_repr::SqlScalarTypes, as well as other cast-related functions.

Macrosยง

casts ๐Ÿ”’

Structsยง

CastImpl ๐Ÿ”’
The implementation of a cast.
CastTemplate ๐Ÿ”’
A cast template is a function that produces a Cast given a concrete input and output type and a failure mode. A template can return None to indicate that it is incapable of producing a cast for the specified types, or for the specified failure mode.

Enumsยง

CastContext
Describes the context of a cast.
CastError
Error returned when a cast is not available or not allowed.

Constantsยง

REG_STRING_CAST_TEMPLATE ๐Ÿ”’
STRING_REG_CAST_TEMPLATE ๐Ÿ”’
STRING to REG*

Staticsยง

REGCLASS_TO_STRING ๐Ÿ”’
REGPROC_TO_STRING ๐Ÿ”’
REGTYPE_TO_STRING ๐Ÿ”’
STRING_TO_REGCLASS_COERCED ๐Ÿ”’
STRING_TO_REGCLASS_EXPLICIT ๐Ÿ”’
STRING_TO_REGPROC ๐Ÿ”’
STRING_TO_REGTYPE ๐Ÿ”’
VALID_CASTS ๐Ÿ”’

Functionsยง

can_cast
Reports whether it is possible to perform a cast from the specified types.
extract_unary_stages_for_try_cast ๐Ÿ”’
The unary functions a strict cast from from applies to its input, innermost first, or None if the cast has any other shape. See CastTemplate::new for the shape a cast must have.
get_cast ๐Ÿ”’
Get casts directly between two SqlScalarTypes, with control over the allowed CastContext.
guess_best_common_type
Guesses the most-common type among a set of SqlScalarTypes that all members can be cast to. Returns None if a common type cannot be deduced.
plan_cast
Plans a cast between SqlScalarTypes, specifying which types of casts are permitted using CastContext.
plan_cast_with_failure_mode
Like plan_cast, but with the given failure mode. Under CastFailureMode::NullFallback every stage of the cast, including the intermediate string cast that string-like types route through, is wrapped so that a failure anywhere yields NULL.
plan_coerce
plan_coerce_with_failure_mode
Like plan_coerce, but the casts that coerce a literal to coerce_to use the given failure mode. TRY_CAST('abc' AS int4) reaches its cast through this coercion, so the mode has to apply here too.
plan_hypothetical_cast
Similar to plan_cast, but for situations where you only know the type of the input expression (from) and not the expression itself. The returned expression refers to the first column of some imaginary row, where the first column is assumed to have type from.
plan_hypothetical_cast_with_failure_mode
Similar to plan_hypothetical_cast, but with a CastFailureMode to specify behavior.
sql_impl_cast ๐Ÿ”’
Like func::sql_impl_func, but for casts.
sql_impl_cast_per_context ๐Ÿ”’
to_jsonb
Converts an expression to SqlScalarType::Jsonb.
to_string
Converts an expression to SqlScalarType::String.
valid_cast_base_type_pairs
The base type pairs that have an entry in the cast table, for tests that want to prove they exercised every one.
validate_range_element_type ๐Ÿ”’
Returns an error if the given type is not a supported range element type (PostgreSQL built-in range types: int32, int64, date, numeric, timestamp, timestamptz).

Type Aliasesยง

Cast ๐Ÿ”’
A cast is a function that takes a ScalarExpr to another ScalarExpr.