def test_json_syntax_error(self): assert_json_result_equals( _parse_json_with_defaults("not JSON"), ParseJsonResult( pyarrow.table({}), [ ParseJsonWarning.TODO_i18n( "JSON parse error at byte 1: Invalid value.") ], ), )
def test_json_not_array(self): assert_json_result_equals( _parse_json_with_defaults('"foo"'), ParseJsonResult( pyarrow.table({}), [ ParseJsonWarning.TODO_i18n( 'JSON is not an Array or Object containing an Array; got: "foo"' ) ], ), )
def test_json_not_records(self): assert_json_result_equals( _parse_json_with_defaults(["foo", "bar"]), ParseJsonResult( pyarrow.table({}), [ ParseJsonWarning.TODO_i18n( 'skipped 2 non-Object records; example Array item 0: "foo"' ) ], ), )
def test_json_replace_badly_encoded_characters(self): assert_json_result_equals( _parse_json_with_defaults('[{"x": "café"}]'.encode("windows-1252"), encoding="utf-8"), ParseJsonResult( pyarrow.table({"x": ["caf�"]}), [ ParseJsonWarning.RepairedEncoding( encoding="utf-8", first_invalid_byte=233, first_invalid_byte_position=11, ) ], ), )
def test_max_bytes_per_column_name(self): assert_json_result_equals( _parse_json_with_defaults([{ "ABCD": "x", "BCDEFG": "y" }]), ParseJsonResult( pyarrow.table({ "AB": ["x"], "BC": ["y"] }), [ ParseJsonWarning.TODO_i18n( "truncated 2 column names; example AB") ], ), )
def test_max_rows(self): assert_json_result_equals( _parse_json_with_defaults([{ "A": "a" }, { "A": "b" }, { "A": "c" }]), ParseJsonResult( pyarrow.table({"A": ["a", "b"]}), [ ParseJsonWarning.TODO_i18n( "skipped 1 rows (after row limit of 2)") ], ), )
def test_max_bytes_per_value(self): assert_json_result_equals( _parse_json_with_defaults([{ "A": ["abc", "def"], "B": "ghij" }]), ParseJsonResult( pyarrow.table({ "A": ['["a'], "B": ["ghi"] }), [ ParseJsonWarning.TODO_i18n( "truncated 2 values (value byte limit is 3; see row 0 column A)" ) ], ), )
def test_max_bytes_text(self): assert_json_result_equals( _parse_json_with_defaults([{ "A": "abcd", "B": "bcde" }, { "A": "c", "B": "def" }]), ParseJsonResult( pyarrow.table({ "A": ["abcd"], "B": ["bcde"] }), [ ParseJsonWarning.TODO_i18n( "stopped at limit of 8 bytes of data") ], ), )
def test_max_columns(self): assert_json_result_equals( _parse_json_with_defaults([{ "A": "a", "B": "b", "C": "c" }, { "A": "aa", "B": "bb" }]), ParseJsonResult( pyarrow.table({ "A": ["a", "aa"], "B": ["b", "bb"] }), [ ParseJsonWarning.TODO_i18n( "skipped column C (after column limit of 2)") ], ), )