This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new af45052981b8 [SPARK-49373][PROTOBUF][TESTS] Fix 
`ProtobufFunctionsSuite` to be environment-independent
af45052981b8 is described below

commit af45052981b83c8c24d681be0c9328e042d51da4
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Fri Aug 23 13:32:55 2024 -0700

    [SPARK-49373][PROTOBUF][TESTS] Fix `ProtobufFunctionsSuite` to be 
environment-independent
    
    ### What changes were proposed in this pull request?
    
    This patch modifies `ProtobufFunctionsSuite`'s test case `SPARK-49121: 
from_protobuf and to_protobuf SQL functions` to check the stop index depending 
on the file path length.
    
    ### Why are the changes needed?
    
    During debugging CI failure in https://github.com/apache/spark/pull/47843, 
we found that `ProtobufFunctionsSuite`'s test case `SPARK-49121: from_protobuf 
and to_protobuf SQL functions` is environment-dependent.
    In the test, it checks the start and stop indices of SQL text fragment but 
the fragment length depends on the repo name of the author of a PR.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No, test only.
    
    ### How was this patch tested?
    
    Unit test
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #47859 from viirya/fix_protobuf_test.
    
    Authored-by: Liang-Chi Hsieh <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../sql/protobuf/ProtobufFunctionsSuite.scala      | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git 
a/connector/protobuf/src/test/scala/org/apache/spark/sql/protobuf/ProtobufFunctionsSuite.scala
 
b/connector/protobuf/src/test/scala/org/apache/spark/sql/protobuf/ProtobufFunctionsSuite.scala
index ddc9381dc8df..ec57ffa699d9 100644
--- 
a/connector/protobuf/src/test/scala/org/apache/spark/sql/protobuf/ProtobufFunctionsSuite.scala
+++ 
b/connector/protobuf/src/test/scala/org/apache/spark/sql/protobuf/ProtobufFunctionsSuite.scala
@@ -2085,6 +2085,7 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
       )
 
       // Negative tests for to_protobuf.
+      var fragment = s"to_protobuf(complex_struct, 42, '$testFileDescFile', 
map())"
       checkError(
         exception = intercept[AnalysisException](sql(
           s"""
@@ -2099,9 +2100,9 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
             "string representing the Protobuf message name"),
           "hint" -> ""),
         queryContext = Array(ExpectedContext(
-          fragment = s"to_protobuf(complex_struct, 42, '$testFileDescFile', 
map())",
+          fragment = fragment,
           start = 10,
-          stop = 153))
+          stop = fragment.length + 9))
       )
       checkError(
         exception = intercept[AnalysisException](sql(
@@ -2121,6 +2122,7 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
           start = 10,
           stop = 73))
       )
+      fragment = s"to_protobuf(complex_struct, 'SimpleMessageJavaTypes', 
'$testFileDescFile', 42)"
       checkError(
         exception = intercept[AnalysisException](sql(
           s"""
@@ -2137,13 +2139,13 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
             "to Protobuf format"),
           "hint" -> ""),
         queryContext = Array(ExpectedContext(
-          fragment =
-            s"to_protobuf(complex_struct, 'SimpleMessageJavaTypes', 
'$testFileDescFile', 42)",
+          fragment = fragment,
           start = 10,
-          stop = 172))
+          stop = fragment.length + 9))
       )
 
       // Negative tests for from_protobuf.
+      fragment = s"from_protobuf(protobuf_data, 42, '$testFileDescFile', 
map())"
       checkError(
         exception = intercept[AnalysisException](sql(
           s"""
@@ -2157,9 +2159,9 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
             "string representing the Protobuf message name"),
           "hint" -> ""),
         queryContext = Array(ExpectedContext(
-          fragment = s"from_protobuf(protobuf_data, 42, '$testFileDescFile', 
map())",
+          fragment = fragment,
           start = 8,
-          stop = 152))
+          stop = fragment.length + 7))
       )
       checkError(
         exception = intercept[AnalysisException](sql(
@@ -2178,6 +2180,7 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
           start = 8,
           stop = 72))
       )
+      fragment = s"from_protobuf(protobuf_data, 'SimpleMessageJavaTypes', 
'$testFileDescFile', 42)"
       checkError(
         exception = intercept[AnalysisException](sql(
           s"""
@@ -2194,10 +2197,9 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
             "from Protobuf format"),
           "hint" -> ""),
         queryContext = Array(ExpectedContext(
-          fragment =
-            s"from_protobuf(protobuf_data, 'SimpleMessageJavaTypes', 
'$testFileDescFile', 42)",
+          fragment = fragment,
           start = 10,
-          stop = 173))
+          stop = fragment.length + 9))
       )
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to