iffyio commented on code in PR #1767: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1767#discussion_r2001562854
########## src/ast/mod.rs: ########## @@ -7919,11 +7921,28 @@ impl fmt::Display for ContextModifier { write!(f, "") } Self::Local => { - write!(f, " LOCAL") + write!(f, "LOCAL ") } Self::Session => { - write!(f, " SESSION") + write!(f, "SESSION ") } + Self::Global => { + write!(f, "GLOBAL ") + } + } + } +} + +impl From<Option<Keyword>> for ContextModifier { + fn from(kw: Option<Keyword>) -> Self { + match kw { + Some(kw) => match kw { + Keyword::LOCAL => Self::Local, + Keyword::SESSION => Self::Session, + Keyword::GLOBAL => Self::Global, + _ => Self::None, + }, + None => Self::None, } } Review Comment: Yeah exactly, essentially to put the logic in a function instead, maybe something more like? ```rust fn context_modifier_from_keyword(kw: Keyword) -> Result<ContextModifier> { } // on the caller side if it has an option modifier.map(context_modifier_from_keyword) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org