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

Function test_json_input

python/pathway/tests/test_json.py:354–392  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

352
353
354def test_json_input():
355 table = _json_table_from_list(
356 [
357 {
358 "a": {"field": 1},
359 "b": 2,
360 "c": 1.5,
361 "d": True,
362 "e": "foo",
363 "f": [1, 2, 3],
364 }
365 ]
366 )
367
368 result = table.select(
369 a=pw.this.a["field"].as_int(),
370 b=pw.this.b.as_int(),
371 c=pw.this.c.as_float(),
372 d=pw.this.d.as_bool(),
373 e=pw.this.e.as_str(),
374 f=pw.this.f[1].as_int(),
375 )
376
377 assert_table_equality(
378 T(
379 """
380 | a | b | c | d | e | f
381 1 | 1 | 2 | 1.5 | True | foo | 2
382 """
383 ).update_types(
384 a=Optional[int],
385 b=Optional[int],
386 c=Optional[float],
387 d=Optional[bool],
388 e=Optional[str],
389 f=Optional[int],
390 ),
391 result,
392 )
393
394
395def test_json_apply():

Callers

nothing calls this directly

Calls 8

TFunction · 0.90
_json_table_from_listFunction · 0.85
update_typesMethod · 0.80
selectMethod · 0.45
as_intMethod · 0.45
as_floatMethod · 0.45
as_boolMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected