MCPcopy Index your code
hub / github.com/apache/datafusion / expr_to_sql_inner

Method expr_to_sql_inner

datafusion/sql/src/unparser/expr.rs:105–616  ·  view source on GitHub ↗
(&self, expr: &Expr)

Source from the content-addressed store, hash-verified

103
104 #[cfg_attr(feature = "recursive_protection", recursive::recursive)]
105 fn expr_to_sql_inner(&self, expr: &Expr) -> Result<ast::Expr> {
106 match expr {
107 Expr::InList(InList {
108 expr,
109 list,
110 negated,
111 }) => {
112 let list_expr = list
113 .iter()
114 .map(|e| self.expr_to_sql_inner(e))
115 .collect::<Result<Vec<_>>>()?;
116 Ok(ast::Expr::InList {
117 expr: Box::new(self.expr_to_sql_inner(expr)?),
118 list: list_expr,
119 negated: *negated,
120 })
121 }
122 Expr::ScalarFunction(ScalarFunction { func, args }) => {
123 let func_name = func.name();
124
125 if let Some(expr) = self
126 .dialect
127 .scalar_function_to_sql_overrides(self, func_name, args)?
128 {
129 return Ok(expr);
130 }
131
132 self.scalar_function_to_sql(func_name, args)
133 }
134 Expr::Between(Between {
135 expr,
136 negated,
137 low,
138 high,
139 }) => {
140 let sql_parser_expr = self.expr_to_sql_inner(expr)?;
141 let sql_low = self.expr_to_sql_inner(low)?;
142 let sql_high = self.expr_to_sql_inner(high)?;
143 Ok(ast::Expr::Nested(Box::new(self.between_op_to_sql(
144 sql_parser_expr,
145 *negated,
146 sql_low,
147 sql_high,
148 ))))
149 }
150 Expr::Column(col) => self.col_to_sql(col),
151 Expr::BinaryExpr(BinaryExpr {
152 left,
153 op: Operator::IsDistinctFrom,
154 right,
155 }) => {
156 let l = self.expr_to_sql_inner(left.as_ref())?;
157 let r = self.expr_to_sql_inner(right.as_ref())?;
158
159 Ok(ast::Expr::Nested(Box::new(ast::Expr::IsDistinctFrom(
160 Box::new(l),
161 Box::new(r),
162 ))))

Callers 2

expr_to_sqlMethod · 0.80
cast_to_sqlMethod · 0.80

Calls 15

newFunction · 0.85
FunctionEnum · 0.85
SubqueryClass · 0.85
IsNullClass · 0.85
IsNotNullClass · 0.85
IsTrueClass · 0.85
IsNotTrueClass · 0.85
IsFalseClass · 0.85
IsNotFalseClass · 0.85
IsUnknownClass · 0.85
IsNotUnknownClass · 0.85
IdentifierClass · 0.85

Tested by

no test coverage detected