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

Method simplify

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

datetime_to_daysFunction · 0.85
LiteralInterface · 0.50
as_refMethod · 0.45
config_optionsMethod · 0.45

Tested by

no test coverage detected