MCPcopy Create free account
hub / github.com/apache/datafusion / simplify

Method simplify

datafusion/functions/src/datetime/current_time.rs:106–134  ·  view source on GitHub ↗
(
        &self,
        args: Vec<Expr>,
        info: &SimplifyContext,
    )

Source from the content-addressed store, hash-verified

104 }
105
106 fn simplify(
107 &self,
108 args: Vec<Expr>,
109 info: &SimplifyContext,
110 ) -> Result<ExprSimplifyResult> {
111 let Some(now_ts) = info.query_execution_start_time() else {
112 return Ok(ExprSimplifyResult::Original(args));
113 };
114
115 // Try to get timezone from config and convert to local time
116 let nano = info
117 .config_options()
118 .execution
119 .time_zone
120 .as_ref()
121 .and_then(|tz| tz.parse::<Tz>().ok())
122 .map_or_else(
123 || datetime_to_time_nanos(&now_ts),
124 |tz| {
125 let local_now = tz.from_utc_datetime(&now_ts.naive_utc());
126 datetime_to_time_nanos(&local_now)
127 },
128 );
129
130 Ok(ExprSimplifyResult::Simplified(Expr::Literal(
131 ScalarValue::Time64Nanosecond(nano),
132 None,
133 )))
134 }
135
136 fn documentation(&self) -> Option<&Documentation> {
137 self.doc()

Callers 1

Calls 5

datetime_to_time_nanosFunction · 0.85
LiteralInterface · 0.50
as_refMethod · 0.45
config_optionsMethod · 0.45

Tested by 1