MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / visit_expr_mut

Method visit_expr_mut

src/sql/src/pure.rs:3000–3023  ·  view source on GitHub ↗
(&mut self, expr: &'_ mut Expr<Aug>)

Source from the content-addressed store, hash-verified

2998
2999impl VisitMut<'_, Aug> for MzNowPurifierVisitor {
3000 fn visit_expr_mut(&mut self, expr: &'_ mut Expr<Aug>) {
3001 match expr {
3002 Expr::Function(Function {
3003 name:
3004 ResolvedItemName::Item {
3005 full_name: FullItemName { item, .. },
3006 ..
3007 },
3008 ..
3009 }) if item == &MZ_NOW_NAME.to_string() => {
3010 let mz_now = self.mz_now.expect(
3011 "we should have chosen a timestamp if the expression contains mz_now()",
3012 );
3013 // We substitute `mz_now()` with number + a cast to `mz_timestamp`. The cast is to
3014 // not alter the type of the expression.
3015 *expr = Expr::Cast {
3016 expr: Box::new(Expr::Value(Value::Number(mz_now.to_string()))),
3017 data_type: self.mz_timestamp_type.clone(),
3018 };
3019 self.introduced_mz_timestamp = true;
3020 }
3021 _ => visit_expr_mut(self, expr),
3022 }
3023 }
3024}

Callers 4

visit_function_mutMethod · 0.45
create_statementFunction · 0.45
visit_query_mutMethod · 0.45

Calls 4

expectMethod · 0.80
ValueInterface · 0.50
to_stringMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected