(
&self,
plan: &LogicalPlan,
query: &mut Option<QueryBuilder>,
)
| 192 | } |
| 193 | |
| 194 | fn select_to_sql_expr( |
| 195 | &self, |
| 196 | plan: &LogicalPlan, |
| 197 | query: &mut Option<QueryBuilder>, |
| 198 | ) -> Result<SetExpr> { |
| 199 | let mut select_builder = SelectBuilder::default(); |
| 200 | select_builder.push_from(TableWithJoinsBuilder::default()); |
| 201 | let mut relation_builder = RelationBuilder::default(); |
| 202 | self.select_to_sql_recursively( |
| 203 | plan, |
| 204 | query, |
| 205 | &mut select_builder, |
| 206 | &mut relation_builder, |
| 207 | )?; |
| 208 | |
| 209 | // If we were able to construct a full body (i.e. UNION ALL), return it |
| 210 | if let Some(body) = query.as_mut().and_then(|q| q.take_body()) { |
| 211 | return Ok(*body); |
| 212 | } |
| 213 | |
| 214 | // If no projection is set, add a wildcard projection to the select |
| 215 | // which will be translated to `SELECT *` in the SQL statement |
| 216 | if !select_builder.already_projected() { |
| 217 | select_builder.projection(vec![ast::SelectItem::Wildcard( |
| 218 | ast::WildcardAdditionalOptions::default(), |
| 219 | )]); |
| 220 | } |
| 221 | |
| 222 | let mut twj = select_builder.pop_from().unwrap(); |
| 223 | twj.relation(relation_builder); |
| 224 | select_builder.push_from(twj); |
| 225 | |
| 226 | Ok(SetExpr::Select(Box::new(select_builder.build()?))) |
| 227 | } |
| 228 | |
| 229 | /// Reconstructs a SELECT SQL statement from a logical plan by unprojecting column expressions |
| 230 | /// found in a [Projection] node. This requires scanning the plan tree for relevant Aggregate |
no test coverage detected