(tmp_path)
| 1401 | |
| 1402 | |
| 1403 | def test_jsonlines_reading_pk(tmp_path): |
| 1404 | class InputSchema(pw.Schema): |
| 1405 | a: int = pw.column_definition(primary_key=True) |
| 1406 | b: int = pw.column_definition(primary_key=True) |
| 1407 | c: int | None |
| 1408 | |
| 1409 | path = tmp_path / "input.jsonlines" |
| 1410 | generate_jsonlines(path) |
| 1411 | input = pw.io.jsonlines.read(path, schema=InputSchema, mode="static") |
| 1412 | result = input.with_columns( |
| 1413 | b=pw.fill_error(pw.this.b, 0), c=pw.fill_error(pw.this.c, 0) |
| 1414 | ) |
| 1415 | expected = T( |
| 1416 | """ |
| 1417 | a | b | c |
| 1418 | 1 | 2 | 3 |
| 1419 | 1 | 3 | 0 |
| 1420 | 7 | 1 | |
| 1421 | """ |
| 1422 | ) |
| 1423 | expected_errors = T( |
| 1424 | """ |
| 1425 | message |
| 1426 | error in primary key, skipping the row: failed to create a field "b" with type int from json payload: "x" |
| 1427 | error in primary key, skipping the row: failed to create a field "b" with type int from json payload: "1" |
| 1428 | failed to create a field "c" with type int / None from json payload: "y" |
| 1429 | """, |
| 1430 | split_on_whitespace=False, |
| 1431 | ).select(message=pw.this.message.str.replace("/", "|")) |
| 1432 | # can't use | because it's a column sep |
| 1433 | |
| 1434 | assert_table_equality_wo_index( |
| 1435 | (result, pw.global_error_log().select(pw.this.message)), |
| 1436 | (expected, expected_errors), |
| 1437 | terminate_on_error=False, |
| 1438 | ) |
| 1439 | |
| 1440 | |
| 1441 | def test_python_connector(): |
nothing calls this directly
no test coverage detected