(v: Vec<CsrConfigOption<Aug>>)
| 3604 | impl std::convert::TryFrom<Vec<CsrConfigOption<Aug>>> for CsrConfigOptionExtracted { |
| 3605 | type Error = crate::plan::PlanError; |
| 3606 | fn try_from(v: Vec<CsrConfigOption<Aug>>) -> Result<CsrConfigOptionExtracted, Self::Error> { |
| 3607 | let mut extracted = CsrConfigOptionExtracted::default(); |
| 3608 | let mut common_doc_comments = BTreeMap::new(); |
| 3609 | for option in v { |
| 3610 | if !extracted.seen.insert(option.name.clone()) { |
| 3611 | return Err(PlanError::Unstructured({ |
| 3612 | format!("{} specified more than once", option.name) |
| 3613 | })); |
| 3614 | } |
| 3615 | let option_name = option.name.clone(); |
| 3616 | let option_name_str = option_name.to_ast_string_simple(); |
| 3617 | let better_error = |e: PlanError| PlanError::InvalidOptionValue { |
| 3618 | option_name: option_name.to_ast_string_simple(), |
| 3619 | err: e.into(), |
| 3620 | }; |
| 3621 | let to_compatibility_level = |val: Option<WithOptionValue<Aug>>| { |
| 3622 | val.map(|s| match s { |
| 3623 | WithOptionValue::Value(Value::String(s)) => { |
| 3624 | mz_ccsr::CompatibilityLevel::try_from(s.to_uppercase().as_str()) |
| 3625 | } |
| 3626 | _ => Err("must be a string".to_string()), |
| 3627 | }) |
| 3628 | .transpose() |
| 3629 | .map_err(PlanError::Unstructured) |
| 3630 | .map_err(better_error) |
| 3631 | }; |
| 3632 | match option.name { |
| 3633 | CsrConfigOptionName::AvroKeyFullname => { |
| 3634 | extracted.avro_key_fullname = |
| 3635 | <Option<String>>::try_from_value(option.value).map_err(better_error)?; |
| 3636 | } |
| 3637 | CsrConfigOptionName::AvroValueFullname => { |
| 3638 | extracted.avro_value_fullname = |
| 3639 | <Option<String>>::try_from_value(option.value).map_err(better_error)?; |
| 3640 | } |
| 3641 | CsrConfigOptionName::NullDefaults => { |
| 3642 | extracted.null_defaults = |
| 3643 | <bool>::try_from_value(option.value).map_err(better_error)?; |
| 3644 | } |
| 3645 | CsrConfigOptionName::AvroDocOn(doc_on) => { |
| 3646 | let value = String::try_from_value(option.value.ok_or_else(|| { |
| 3647 | PlanError::InvalidOptionValue { |
| 3648 | option_name: option_name_str, |
| 3649 | err: Box::new(PlanError::Unstructured("cannot be empty".to_string())), |
| 3650 | } |
| 3651 | })?) |
| 3652 | .map_err(better_error)?; |
| 3653 | let key = match doc_on.identifier { |
| 3654 | DocOnIdentifier::Column(ast::ColumnName { |
| 3655 | relation: ResolvedItemName::Item { id, .. }, |
| 3656 | column: ResolvedColumnReference::Column { name, index: _ }, |
| 3657 | }) => DocTarget::Field { |
| 3658 | object_id: id, |
| 3659 | column_name: name, |
| 3660 | }, |
| 3661 | DocOnIdentifier::Type(ResolvedItemName::Item { id, .. }) => { |
| 3662 | DocTarget::Type(id) |
| 3663 | } |
nothing calls this directly
no test coverage detected