renato2099 commented on issue #1305: URL: https://github.com/apache/datafusion-python/issues/1305#issuecomment-3649873478
thinking more about this , I think we should just not allow `drop_duplicate_keys` when doing a full outer join. I think that would be the right behavior because (1) For a FULL OUTER JOIN, the left and right join keys are NOT equivalent columns (2) That would resemble the expected from upstream and what other databases do. For example, postgresql https://www.postgresql.org/docs/8.2/queries-table-expressions.html (3) User can decide on how to merge columns afterwards. then we can allow something like this: ``` batch = pa.RecordBatch.from_arrays( [pa.array([1, 2, 3]), pa.array(['a', 'b', 'c'])], names=["num", "name"], ) batch2 = pa.RecordBatch.from_arrays( [pa.array([1, 3, 5]), pa.array([True, True, False])], names=["num", "value"], ) df1 = ctx.create_dataframe([[batch]], "l") df2 = ctx.create_dataframe([[batch2]], "r") df3 = df1.join(df2, on="num", how="full", drop_duplicate_keys=False) df3.show() +-----+------+-----+-------+ | num | name | num | value | +-----+------+-----+-------+ | 1 | a | 1 | true | | 3 | c | 3 | true | | 2 | b | | | | | | 5 | false | +-----+------+-----+-------+ ``` then user can do as they want, like coalescing ``` df5 = df3.select_exprs( "coalesce(l.num, r.num) as num", "l.name", "r.value" ) df5.show() +-----+------+-------+ | num | name | value | +-----+------+-------+ | 1 | a | true | | 3 | c | true | | 2 | b | | | 5 | | false | +-----+------+-------+ ``` then no weird semantics + no workarounds + give user the power to decide what to do. Also created PR for it here https://github.com/apache/datafusion-python/pull/1320 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
