Skip to content

full_outer join does not produce a full outer join. #795

@BenSimonds

Description

@BenSimonds

Expected behaviour - using full_outer=True produces a record set containing all records from both input tables, even those that do not match.

Observed behaviour - full_outer=True behaves just like a left join.

Steps to replicate:

import agate

table_1 = agate.Table.from_object([{"id": 1, "value": "A"}, {"id": 2, "value": "B"}])
table_2 = agate.Table.from_object([{"id": 2, "value": "B"}, {"id": 3, "value": "C"}])

joined = table_1.join(
    table_2,
    left_key=["id"],
    right_key=["id"],
    full_outer=True,
)

# We would expect three rows in our output.
print("Joined rowcount:", len(joined.rows))
print("Joined Table:")
for row in joined.rows:
    print(row)

assert len(joined.rows) == 3, "Expected 3 rows in the joined table"

Output:

Joined rowcount: 2
Joined Table:
<agate.Row: (Decimal('1'), 'A', None, None)>
<agate.Row: (Decimal('2'), 'B', Decimal('2'), 'B')>
Traceback (most recent call last):
  File "/Users/ben/Repositories/test-agate/test.py", line 19, in <module>
    assert len(joined.rows) == 3, "Expected 3 rows in the joined table"
           ^^^^^^^^^^^^^^^^^^^^^
AssertionError: Expected 3 rows in the joined table

Using Version: 1.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions