Skip to content

Commit

Permalink
allow qualified wildcard expressions to exist in the logical plan
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal committed Jul 26, 2024
1 parent d097ca3 commit bd9e37d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
4 changes: 1 addition & 3 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2305,9 +2305,7 @@ fn write_name<W: Write>(w: &mut W, e: &Expr) -> Result<()> {
}
Expr::Wildcard { qualifier } => match qualifier {
Some(qualifier) => {
return internal_err!(
"Create name does not support qualified wildcard, got {qualifier}"
)
write!(w, "{}.*", qualifier)?;
}
None => write!(w, "*")?,
},
Expand Down
21 changes: 5 additions & 16 deletions datafusion/expr/src/expr_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use crate::{utils, LogicalPlan, Projection, Subquery, WindowFunctionDefinition};
use arrow::compute::can_cast_types;
use arrow::datatypes::{DataType, Field};
use datafusion_common::{
internal_err, not_impl_err, plan_datafusion_err, plan_err, Column, ExprSchema,
Result, TableReference,
not_impl_err, plan_datafusion_err, plan_err, Column, ExprSchema, Result,
TableReference,
};
use std::collections::HashMap;
use std::sync::Arc;
Expand Down Expand Up @@ -254,13 +254,7 @@ impl ExprSchemable for Expr {
)
})
}
Expr::Wildcard { qualifier } => {
// Wildcard do not really have a type and do not appear in projections
match qualifier {
Some(_) => internal_err!("QualifiedWildcard expressions are not valid in a logical query plan"),
None => Ok(DataType::Null)
}
}
Expr::Wildcard { .. } => Ok(DataType::Null),
Expr::GroupingSet(_) => {
// grouping sets do not really have a type and do not appear in projections
Ok(DataType::Null)
Expand Down Expand Up @@ -374,12 +368,7 @@ impl ExprSchemable for Expr {
| Expr::SimilarTo(Like { expr, pattern, .. }) => {
Ok(expr.nullable(input_schema)? || pattern.nullable(input_schema)?)
}
Expr::Wildcard { qualifier } => match qualifier {
Some(_) => internal_err!(
"QualifiedWildcard expressions are not valid in a logical query plan"
),
None => Ok(false),
},
Expr::Wildcard { .. } => Ok(false),
Expr::GroupingSet(_) => {
// grouping sets do not really have the concept of nullable and do not appear
// in projections
Expand Down Expand Up @@ -560,7 +549,7 @@ mod tests {
use super::*;
use crate::{col, lit};

use datafusion_common::{DFSchema, ScalarValue};
use datafusion_common::{internal_err, DFSchema, ScalarValue};

macro_rules! test_is_expr_nullable {
($EXPR_TYPE:ident) => {{
Expand Down

0 comments on commit bd9e37d

Please sign in to comment.