Macro mz_sql::normalize::generate_extracted_config

source ·
macro_rules! generate_extracted_config {
    ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty), $($tail:tt),*) => { ... };
    ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty)) => { ... };
    ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, Default($v:expr)), $($tail:tt),*) => { ... };
    ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, Default($v:expr))) => { ... };
    ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, AllowMultiple), $($tail:tt),*) => { ... };
    ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, AllowMultiple)) => { ... };
    ($option_ty:ty, [$(($option_name:path, $t:ty, $v:expr, $allow_multiple:literal))+]) => { ... };
    ($option_ty:ty, $($h:tt),+) => { ... };
    (@ifexpr false, $lhs:expr, $rhs:expr) => { ... };
    (@ifexpr true, $lhs:expr, $rhs:expr) => { ... };
    (@ifty false, $lhs:ty, $rhs:ty) => { ... };
    (@ifty true, $lhs:ty, $rhs:ty) => { ... };
}
Expand description

Generates a struct capable of taking a Vec of types commonly used to represent WITH options into useful data types, such as strings. Additionally, it is able to convert the useful data types back to the Vec of options.

§Parameters

  • $option_ty: Accepts a struct representing a set of WITH options, which must contain the fields name and value.
    • name must be of type $option_tyName, e.g. if $option_ty is FooOption, then name must be of type FooOptionName. $option_tyName must be an enum representing WITH option keys.
    • TryFromValue<value> must be implemented for the type you want to take the option to. The sql::plan::with_option module contains these implementations.
  • $option_name must be an element of $option_tyName
  • $t is the type you want to convert the option’s value to. If the option’s value is absent (i.e. the user only entered the option’s key), you can also define a default value.
  • Default($v) is an optional parameter that sets the default value of the field to $v. $v must be convertible to $t using .into. This also converts the struct’s type from Option<$t> to <$t>.
  • AllowMultiple is an optional parameter that, when specified, allows the given option to appear multiple times in the WITH clause. This also converts the struct’s type from $t to Vec<$t>.