Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gene-db committed Mar 28, 2024
1 parent 915ee61 commit 81d1e87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions python/pyspark/sql/connect/functions/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ def parse_json(col: "ColumnOrName") -> Column:

parse_json.__doc__ = pysparkfuncs.parse_json.__doc__


def posexplode(col: "ColumnOrName") -> Column:
return _invoke_function_over_columns("posexplode", col)

Expand Down
8 changes: 4 additions & 4 deletions python/pyspark/sql/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,14 +1306,14 @@ def test_map_functions(self):
self.assertEqual(expected, actual["from_items"])

def test_parse_json(self):
df = self.spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ])
df = self.spark.createDataFrame([{"json": """{ "a" : 1 }"""}])
actual = df.select(
F.to_json(F.parse_json(df.json)).alias("var"),
F.to_json(F.parse_json(F.lit('''{"b": [{"c": "str2"}]}'''))).alias("var_lit"),
F.to_json(F.parse_json(F.lit("""{"b": [{"c": "str2"}]}"""))).alias("var_lit"),
).first()

self.assertEqual('''{"a":1}''', actual["var"])
self.assertEqual('''{"b":[{"c":"str2"}]}''', actual["var_lit"])
self.assertEqual("""{"a":1}""", actual["var"])
self.assertEqual("""{"b":[{"c":"str2"}]}""", actual["var_lit"])

def test_schema_of_json(self):
with self.assertRaises(PySparkTypeError) as pe:
Expand Down

0 comments on commit 81d1e87

Please sign in to comment.