alamb commented on code in PR #5748:
URL: https://github.com/apache/arrow-datafusion/pull/5748#discussion_r1152231567
##########
datafusion/expr/src/logical_plan/builder.rs:
##########
@@ -1041,20 +1041,44 @@ pub fn build_join_schema(
right: &DFSchema,
join_type: &JoinType,
) -> Result<DFSchema> {
+ let right_fields = right.fields();
+ let left_fields = left.fields();
+
let fields: Vec<DFField> = match join_type {
- JoinType::Inner | JoinType::Left | JoinType::Full | JoinType::Right =>
{
- let right_fields = right.fields().iter();
- let left_fields = left.fields().iter();
+ JoinType::Inner | JoinType::Full | JoinType::Right => {
// left then right
- left_fields.chain(right_fields).cloned().collect()
+ left_fields
+ .iter()
+ .chain(right_fields.iter())
+ .cloned()
+ .collect()
+ }
+ JoinType::Left => {
+ // 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().clone().with_nullable(true);
+ if let Some(q) = f.qualifier() {
+ DFField::from_qualified(q, field)
+ } else {
+ DFField::from(field)
Review Comment:
Maybe we could add a `DFField::with_nullable` to make this more concise:
```
let field = f.clone().with_nullable(true);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]