Skip to content

Commit f0e99b0

Browse files
committed
rebuild and retest
1 parent 19f2ba2 commit f0e99b0

File tree

5 files changed

+804
-747
lines changed

5 files changed

+804
-747
lines changed

build/lib/data_algebra/polars_model.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,18 @@ def _natural_join_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *
884884
how = op.jointype.lower()
885885
if how == "full":
886886
how = "outer"
887-
coalesce_columns = (
888-
set(op.sources[0].columns_produced()).intersection(op.sources[1].columns_produced())
889-
- set(op.on_a))
890887
if how != "right":
888+
coalesce_columns = (
889+
set(op.sources[0].columns_produced()).intersection(op.sources[1].columns_produced())
890+
- set(op.on_a))
891+
orphan_keys = [c for c in op.on_b if c not in set(op.on_a)]
892+
input_right = inputs[1]
893+
if len(orphan_keys) > 0:
894+
input_right = input_right.with_columns([
895+
pl.col(c).alias(f"{c}_da_join_tmp_key") for c in orphan_keys
896+
])
891897
res = inputs[0].join(
892-
inputs[1],
898+
input_right,
893899
left_on=op.on_a,
894900
right_on=op.on_b,
895901
how=how,
@@ -903,10 +909,21 @@ def _natural_join_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *
903909
.alias(c)
904910
for c in coalesce_columns
905911
])
912+
if len(orphan_keys) > 0:
913+
res = res.rename({f"{c}_da_join_tmp_key": c for c in orphan_keys})
906914
else:
907915
# simulate right join with left join
916+
coalesce_columns = (
917+
set(op.sources[0].columns_produced()).intersection(op.sources[1].columns_produced())
918+
- set(op.on_b))
919+
orphan_keys = [c for c in op.on_a if c not in set(op.on_b)]
920+
input_right = inputs[0]
921+
if len(orphan_keys) > 0:
922+
input_right = input_right.with_columns([
923+
pl.col(c).alias(f"{c}_da_join_tmp_key") for c in orphan_keys
924+
])
908925
res = inputs[1].join(
909-
inputs[0],
926+
input_right,
910927
left_on=op.on_b,
911928
right_on=op.on_a,
912929
how="left",
@@ -920,6 +937,8 @@ def _natural_join_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *
920937
.alias(c)
921938
for c in coalesce_columns
922939
])
940+
if len(orphan_keys) > 0:
941+
res = res.rename({f"{c}_da_join_tmp_key": c for c in orphan_keys})
923942
res = res.select(op.columns_produced())
924943
return res
925944

coverage.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ data_algebra/op_container.py 127 49 61% 46-47, 63-71, 80-81
161161
data_algebra/pandas_base.py 696 68 90% 54, 68, 77, 87, 92, 101, 223, 225, 239, 242, 247, 252, 427, 467, 478, 503, 506, 511, 514, 516, 528, 534-541, 548, 582-587, 617, 621, 624, 626, 663, 717, 758, 775, 795, 813, 823, 838, 886, 894, 902, 917, 928, 940, 959, 974, 1002, 1017, 1054, 1071, 1074, 1085, 1113, 1145, 1154, 1181, 1198, 1210, 1265, 1279-1281
162162
data_algebra/pandas_model.py 19 2 89% 32-33
163163
data_algebra/parse_by_lark.py 164 24 85% 71, 93, 108, 129-130, 137, 161, 171, 185-186, 188, 200, 206, 213-217, 245, 253, 263-266
164-
data_algebra/polars_model.py 584 72 88% 180, 189, 203, 447-453, 459-466, 484-485, 487, 570, 586, 596, 603, 616-620, 628, 630, 655, 658, 663, 666, 715, 733, 749, 816, 832-834, 879, 931, 946, 964, 982, 1002, 1014-1016, 1019, 1026, 1028, 1035-1047, 1054, 1059, 1090, 1119, 1128, 1156, 1171, 1183
164+
data_algebra/polars_model.py 597 74 88% 180, 189, 203, 447-453, 459-466, 484-485, 487, 570, 586, 596, 603, 616-620, 628, 630, 655, 658, 663, 666, 715, 733, 749, 816, 832-834, 879, 922, 941, 950, 965, 983, 1001, 1021, 1033-1035, 1038, 1045, 1047, 1054-1066, 1073, 1078, 1109, 1138, 1147, 1175, 1190, 1202
165165
data_algebra/python3_lark.py 1 0 100%
166166
data_algebra/solutions.py 112 3 97% 63, 308, 367
167167
data_algebra/sql_format_options.py 15 2 87% 61, 69
168168
data_algebra/test_util.py 333 62 81% 28-29, 104, 126, 136, 139, 143, 166, 169, 173, 175-178, 189, 246-247, 263-268, 272, 284, 286-294, 331, 333, 344, 352, 363, 370, 376, 388, 399, 413, 468, 472, 523-526, 528-531, 533-536, 538-541, 652-657, 662-663, 665
169169
data_algebra/util.py 127 28 78% 26, 59-60, 63-64, 67-68, 71-72, 75-76, 79-80, 83-84, 87-88, 91-92, 95-96, 143, 165, 167, 182, 223, 227, 229
170170
--------------------------------------------------------------------
171-
TOTAL 6809 974 86%
171+
TOTAL 6822 976 86%
172172

173173

174-
======================= 363 passed in 813.20s (0:13:33) ========================
174+
======================= 363 passed in 832.16s (0:13:52) ========================
104 Bytes
Binary file not shown.

dist/data_algebra-1.6.2.tar.gz

102 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)