From 87052ab4aa16f52f79a0d15a84dbc52b05652f0c Mon Sep 17 00:00:00 2001 From: Gal Topper Date: Fri, 29 Dec 2023 03:34:55 +0800 Subject: [PATCH] Actually convert single key to a string in `stringify_key()` (#484) --- storey/utils.py | 4 ++-- tests/test_flow.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/storey/utils.py b/storey/utils.py index bebf981e..1f159cb4 100644 --- a/storey/utils.py +++ b/storey/utils.py @@ -211,9 +211,9 @@ def stringify_key(key_list): return str(key_list[0]) + "." + hash_list(key_list[1:]) if len(key_list) == 2: return str(key_list[0]) + "." + str(key_list[1]) - return key_list[0] + return str(key_list[0]) else: - return key_list + return str(key_list) def _create_filter_tuple(dtime, attr, sign, list_tuples): diff --git a/tests/test_flow.py b/tests/test_flow.py index 2697ff00..bf6824b8 100644 --- a/tests/test_flow.py +++ b/tests/test_flow.py @@ -2826,8 +2826,8 @@ def test_write_to_parquet_with_inference_error_on_partition_index_collision(tmpd def test_join_by_key(): table = Table("test", NoopDriver()) - table._update_static_attrs(9, {"age": 1, "color": "blue9"}) - table._update_static_attrs(7, {"age": 3, "color": "blue7"}) + table._update_static_attrs("9", {"age": 1, "color": "blue9"}) + table._update_static_attrs("7", {"age": 3, "color": "blue7"}) controller = build_flow( [ @@ -2848,8 +2848,8 @@ def test_join_by_key(): def test_join_by_key_error(): table = Table("test", NoopDriver()) - table._update_static_attrs(1, {"age": 1, "color": "blue"}) - table._update_static_attrs(3, {"age": 3, "color": "red"}) + table._update_static_attrs("1", {"age": 1, "color": "blue"}) + table._update_static_attrs("3", {"age": 3, "color": "red"}) recovery_step = Reduce([], lambda acc, x: append_and_return(acc, x)) terminal_step = Reduce([], lambda acc, x: append_and_return(acc, x)) @@ -2877,8 +2877,8 @@ def test_join_by_key_error(): def test_join_by_key_full_event(): table = Table("test", NoopDriver()) - table._update_static_attrs(9, {"age": 1, "color": "blue9"}) - table._update_static_attrs(7, {"age": 3, "color": "blue7"}) + table._update_static_attrs("9", {"age": 1, "color": "blue9"}) + table._update_static_attrs("7", {"age": 3, "color": "blue7"}) controller = build_flow( [ @@ -2899,8 +2899,8 @@ def test_join_by_key_full_event(): def test_join_by_string_key(): table = Table("test", NoopDriver()) - table._update_static_attrs(9, {"age": 1, "color": "blue9"}) - table._update_static_attrs(7, {"age": 3, "color": "blue7"}) + table._update_static_attrs("9", {"age": 1, "color": "blue9"}) + table._update_static_attrs("7", {"age": 3, "color": "blue7"}) controller = build_flow( [ @@ -2921,8 +2921,8 @@ def test_join_by_string_key(): def test_join_with_join_function(): table = Table("test", NoopDriver()) - table._update_static_attrs(2, {"age": 2, "color": "blue"}) - table._update_static_attrs(3, {"age": 3, "color": "red"}) + table._update_static_attrs("2", {"age": 2, "color": "blue"}) + table._update_static_attrs("3", {"age": 3, "color": "red"}) def join_function(event, aug): event.update(aug)