Skip to content

Commit

Permalink
add config back after off by default
Browse files Browse the repository at this point in the history
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
  • Loading branch information
thirtiseven committed Apr 25, 2024
1 parent 40790a1 commit 6b74922
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions integration_tests/src/main/python/json_tuple_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ def test_json_tuple(json_str_pattern):
assert_gpu_and_cpu_are_equal_collect(
lambda spark: unary_op_df(spark, gen, length=10).selectExpr(
'json_tuple(a, "a", "email", "owner", "b", "b$", "b$$")'),
conf={'spark.sql.parser.escapedStringLiterals': 'true'})
conf={'spark.sql.parser.escapedStringLiterals': 'true',
'spark.rapids.sql.expression.JsonTuple': 'true'})

def test_json_tuple_select_non_generator_col():
gen = StringGen(pattern="{\"Zipcode\":\"abc\",\"ZipCodeType\":\"STANDARD\",\"City\":\"PARC PARQUE\",\"State\":\"PR\"}")
assert_gpu_and_cpu_are_equal_sql(
lambda spark : gen_df(spark, [('a', gen)]),
'table',
'select a, json_tuple(a, \"Zipcode\", \"ZipCodeType\", \"City\", \"State\") from table',
conf={'spark.sql.parser.escapedStringLiterals': 'true'})
conf={'spark.sql.parser.escapedStringLiterals': 'true',
'spark.rapids.sql.expression.JsonTuple': 'true'})

@allow_non_gpu('GenerateExec', 'JsonTuple')
@pytest.mark.parametrize('json_str_pattern', json_str_patterns, ids=idfn)
Expand All @@ -54,7 +56,8 @@ def test_json_tuple_with_large_number_of_fields_fallback(json_str_pattern):
"location", "city", "country", "zip", "code", "region", "state", "street", "block", "loc", \
"height", "h", "author", "title", "price", "isbn", "book", "rating", "score", "popular")'),
"JsonTuple",
conf={'spark.sql.parser.escapedStringLiterals': 'true'})
conf={'spark.sql.parser.escapedStringLiterals': 'true',
'spark.rapids.sql.expression.JsonTuple': 'true'})

@pytest.mark.parametrize('json_str_pattern', json_str_patterns, ids=idfn)
def test_json_tuple_with_special_characters(json_str_pattern):
Expand All @@ -64,7 +67,8 @@ def test_json_tuple_with_special_characters(json_str_pattern):
assert_gpu_and_cpu_are_equal_collect(
lambda spark: unary_op_df(spark, gen, length=10).selectExpr(
'json_tuple(a, "a", "a' + special_character + '")'),
conf={'spark.sql.parser.escapedStringLiterals': 'true'})
conf={'spark.sql.parser.escapedStringLiterals': 'true',
'spark.rapids.sql.expression.JsonTuple': 'true'})

def test_json_tuple_with_slash_backslash():
schema = StructType([StructField("jsonStr", StringType())])
Expand All @@ -75,4 +79,5 @@ def test_json_tuple_with_slash_backslash():
assert_gpu_and_cpu_are_equal_collect(
lambda spark: spark.createDataFrame(data, schema).selectExpr(
'json_tuple(jsonStr, "url", "info")'),
conf={'spark.sql.parser.escapedStringLiterals': 'true'})
conf={'spark.sql.parser.escapedStringLiterals': 'true',
'spark.rapids.sql.expression.JsonTuple': 'true'})

0 comments on commit 6b74922

Please sign in to comment.