MCPcopy Index your code
hub / github.com/pathwaycom/pathway / test_json_optional_values

Function test_json_optional_values

python/pathway/tests/test_io.py:949–977  ·  view source on GitHub ↗
(tmp_path: pathlib.Path)

Source from the content-addressed store, hash-verified

947
948
949def test_json_optional_values(tmp_path: pathlib.Path):
950 data = """
951{"k": "a", "v": 1}
952{"k": "b", "v": 2, "w": 512}
953 """
954 input_path = tmp_path / "input.csv"
955 write_lines(input_path, data)
956
957 class InputSchema(pw.Schema):
958 k: str = pw.column_definition(primary_key=True)
959 v: int = pw.column_definition(default_value=0)
960 w: int = pw.column_definition(default_value=1024)
961
962 table = pw.io.jsonlines.read(
963 str(input_path),
964 schema=InputSchema,
965 mode="static",
966 )
967
968 assert_table_equality(
969 table,
970 T(
971 """
972 k | v | w
973 a | 1 | 1024
974 b | 2 | 512
975 """
976 ).with_id_from(pw.this.k),
977 )
978
979
980def test_json_optional_values_with_paths(tmp_path: pathlib.Path):

Callers

nothing calls this directly

Calls 3

write_linesFunction · 0.90
TFunction · 0.90
with_id_fromMethod · 0.80

Tested by

no test coverage detected