@@ -136,6 +136,9 @@ def get_df_from_reader_and_file_format(reader, file_format):
136136
137137@pytest .fixture (scope = "module" , autouse = True )
138138def setup (session , resources_path , local_testing_mode ):
139+ # TODO SNOW-2098847: remove this workaround after fixing the issue
140+ session ._use_scoped_temp_objects = False
141+
139142 test_files = TestFiles (resources_path )
140143 if not local_testing_mode :
141144 Utils .create_stage (session , tmp_stage_name1 , is_temporary = True )
@@ -399,7 +402,7 @@ def test_read_csv(session, mode):
399402 )
400403 with pytest .raises (SnowparkSQLException ) as ex_info :
401404 df3 .collect ()
402- assert "is out of range" in str (ex_info . value )
405+ assert "is out of range" in str (ex_info )
403406
404407
405408@pytest .mark .xfail (
@@ -590,7 +593,7 @@ def test_read_csv_incorrect_schema(session, mode):
590593 df = reader .option ("purge" , False ).schema (incorrect_schema ).csv (test_file_on_stage )
591594 with pytest .raises (SnowparkSQLException ) as ex_info :
592595 df .collect ()
593- assert "Number of columns in file (3) does not match" in str (ex_info . value )
596+ assert "Number of columns in file (3) does not match" in str (ex_info )
594597
595598
596599@pytest .mark .skipif (
@@ -1971,10 +1974,6 @@ def test_read_multiple_csvs(session):
19711974 "config.getoption('local_testing_mode', default=False)" ,
19721975 reason = "xml not supported in local testing mode" ,
19731976)
1974- @pytest .mark .skipif (
1975- IS_IN_STORED_PROC ,
1976- reason = "SNOW-2044853: Flaky in stored procedure test" ,
1977- )
19781977@pytest .mark .parametrize (
19791978 "file,row_tag,expected_row_count,expected_column_count" ,
19801979 [
@@ -1997,10 +1996,6 @@ def test_read_xml_row_tag(
19971996 "config.getoption('local_testing_mode', default=False)" ,
19981997 reason = "xml not supported in local testing mode" ,
19991998)
2000- @pytest .mark .skipif (
2001- IS_IN_STORED_PROC ,
2002- reason = "SNOW-2044853: Flaky in stored procedure test" ,
2003- )
20041999def test_read_xml_no_xxe (session ):
20052000 row_tag = "bar"
20062001 stage_file_path = f"@{ tmp_stage_name1 } /{ test_file_xxe_xml } "
@@ -2012,10 +2007,6 @@ def test_read_xml_no_xxe(session):
20122007 "config.getoption('local_testing_mode', default=False)" ,
20132008 reason = "xml not supported in local testing mode" ,
20142009)
2015- @pytest .mark .skipif (
2016- IS_IN_STORED_PROC ,
2017- reason = "SNOW-2044853: Flaky in stored procedure test" ,
2018- )
20192010def test_read_xml_query_nested_data (session ):
20202011 row_tag = "tag"
20212012 df = session .read .option ("rowTag" , row_tag ).xml (
@@ -2046,10 +2037,6 @@ def test_read_xml_non_existing_file(session):
20462037 "config.getoption('local_testing_mode', default=False)" ,
20472038 reason = "xml not supported in local testing mode" ,
20482039)
2049- @pytest .mark .skipif (
2050- IS_IN_STORED_PROC ,
2051- reason = "SNOW-2044853: Flaky in stored procedure test" ,
2052- )
20532040@pytest .mark .parametrize (
20542041 "file" ,
20552042 (
@@ -2060,12 +2047,13 @@ def test_read_xml_non_existing_file(session):
20602047)
20612048def test_read_malformed_xml (session , file ):
20622049 row_tag = "record"
2050+ file_path = f"@{ tmp_stage_name1 } /{ file } "
20632051
20642052 # permissive mode
20652053 df = (
20662054 session .read .option ("rowTag" , row_tag )
20672055 .option ("mode" , "permissive" )
2068- .xml (f"@ { tmp_stage_name1 } / { file } " )
2056+ .xml (file_path )
20692057 )
20702058 result = df .collect ()
20712059 assert len (result ) == 2
@@ -2079,17 +2067,37 @@ def test_read_malformed_xml(session, file):
20792067 df = (
20802068 session .read .option ("rowTag" , row_tag )
20812069 .option ("mode" , "dropmalformed" )
2082- .xml (f"@ { tmp_stage_name1 } / { test_file_malformed_no_closing_tag_xml } " )
2070+ .xml (file_path )
20832071 )
20842072 result = df .collect ()
20852073 assert len (result ) == 1
20862074 assert len (result [0 ]) == 3
20872075
20882076 # failfast mode
20892077 df = (
2090- session .read .option ("rowTag" , row_tag )
2091- .option ("mode" , "failfast" )
2092- .xml (f"@{ tmp_stage_name1 } /{ test_file_malformed_no_closing_tag_xml } " )
2078+ session .read .option ("rowTag" , row_tag ).option ("mode" , "failfast" ).xml (file_path )
20932079 )
20942080 with pytest .raises (SnowparkSQLException , match = "Malformed XML record at bytes" ):
20952081 df .collect ()
2082+
2083+
2084+ @pytest .mark .skipif (
2085+ "config.getoption('local_testing_mode', default=False)" ,
2086+ reason = "xml not supported in local testing mode" ,
2087+ )
2088+ def test_read_xml_row_tag_not_found (session ):
2089+ row_tag = "non-existing-tag"
2090+ df = session .read .option ("rowTag" , row_tag ).xml (
2091+ f"@{ tmp_stage_name1 } /{ test_file_books_xml } "
2092+ )
2093+
2094+ with pytest .raises (
2095+ SnowparkDataframeReaderException , match = "Cannot find the row tag"
2096+ ):
2097+ df .collect ()
2098+
2099+ # also works for nested query plan
2100+ with pytest .raises (
2101+ SnowparkDataframeReaderException , match = "Cannot find the row tag"
2102+ ):
2103+ df .filter (lit (True )).collect ()
0 commit comments