Skip to content

Apache DataFusion SQL Query Engine

Minor: Add `DFField.with_nullable(bool)` (#5966)

compheadcbccfca9594b
diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs
index 77f20f21e2..295577dafa 100644
--- a/datafusion/common/src/dfschema.rs
+++ b/datafusion/common/src/dfschema.rs
@@ -727,6 +727,13 @@ impl DFField {
self.qualifier = None;
self
}
+
+ /// Return field with nullable specified
+ pub fn with_nullable(mut self, nullable: bool) -> Self {
+ let f = self.field().as_ref().clone().with_nullable(nullable);
+ self.field = f.into();
+ self
+ }
}
impl From<FieldRef> for DFField {
diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs
index cd507ec408..d16b7cd8c5 100644
--- a/datafusion/expr/src/logical_plan/builder.rs
+++ b/datafusion/expr/src/logical_plan/builder.rs
@@ -1057,15 +1057,9 @@ pub fn build_join_schema(
// left then right, right set to nullable in case of not matched scenario
let right_fields_nullable: Vec<DFField> = right_fields
.iter()
- .map(|f| {
- let field = f.field().as_ref().clone().with_nullable(true);
- if let Some(q) = f.qualifier() {
- DFField::from_qualified(q, field)
- } else {
- DFField::from(field)
- }
- })
+ .map(|f| f.clone().with_nullable(true))
.collect();
+
left_fields
.iter()
.chain(&right_fields_nullable)