You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/07/23 06:08:47 UTC

(datafusion) 01/01: test: improve `sha` function SQL test coverage (#23758)

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

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-23758-a4f11089e7c59be35e5cb1c38f1793592e6cfc09
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 2180253926d8d403033de0e1c955a153db68f7a5
Author: Yongting You <20...@gmail.com>
AuthorDate: Thu Jul 23 14:08:30 2026 +0800

    test: improve `sha` function SQL test coverage (#23758)
    
    ## Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax. For example
    `Closes #123` indicates that this PR will close issue #123.
    -->
    
    - Closes #.
    
    ## Rationale for this change
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    Codecov reports low test coverage for this function, so this PR adds
    more SLT tests for it.
    
    The tests were AI-generated, and I manually verified that the results
    are correct.
    
    See `Codecov` bot comment -> `☔ View full report in Codecov by Harness`
    -> `Indirect Changes` for the updated test coverage.
    
    ## What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    ## Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    -->
    
    ## Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    -->
    
    <!--
    If there are any breaking changes to public APIs, please add the `api
    change` label.
    -->
---
 datafusion/sqllogictest/test_files/expr.slt | 75 +++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/datafusion/sqllogictest/test_files/expr.slt b/datafusion/sqllogictest/test_files/expr.slt
index 228cce4cfa..ba4e4d03b3 100644
--- a/datafusion/sqllogictest/test_files/expr.slt
+++ b/datafusion/sqllogictest/test_files/expr.slt
@@ -1618,6 +1618,31 @@ SELECT sha224(NULL);
 ----
 NULL
 
+# sha224 string and binary array inputs
+query BBBBBB
+SELECT
+  sha224(column1) = sha224('tom'),
+  sha224(arrow_cast(column1, 'LargeUtf8')) = sha224('tom'),
+  sha224(arrow_cast(column1, 'Utf8View')) = sha224('tom'),
+  sha224(arrow_cast(column1, 'Binary')) = sha224('tom'),
+  sha224(arrow_cast(column1, 'LargeBinary')) = sha224('tom'),
+  sha224(arrow_cast(column1, 'BinaryView')) = sha224('tom')
+FROM (VALUES ('tom'), (NULL), ('mot')) AS t(column1);
+----
+true true true true true true
+NULL NULL NULL NULL NULL NULL
+false false false false false false
+
+# invalid argument count and type
+query error DataFusion error:
+SELECT sha224();
+
+query error DataFusion error:
+SELECT sha224('tom', 'extra');
+
+query error DataFusion error:
+SELECT sha224(1);
+
 query ?
 SELECT digest(NULL,'sha224');
 ----
@@ -1678,6 +1703,31 @@ SELECT sha384(NULL);
 ----
 NULL
 
+# sha384 string and binary array inputs
+query BBBBBB
+SELECT
+  sha384(column1) = sha384('tom'),
+  sha384(arrow_cast(column1, 'LargeUtf8')) = sha384('tom'),
+  sha384(arrow_cast(column1, 'Utf8View')) = sha384('tom'),
+  sha384(arrow_cast(column1, 'Binary')) = sha384('tom'),
+  sha384(arrow_cast(column1, 'LargeBinary')) = sha384('tom'),
+  sha384(arrow_cast(column1, 'BinaryView')) = sha384('tom')
+FROM (VALUES ('tom'), (NULL), ('mot')) AS t(column1);
+----
+true true true true true true
+NULL NULL NULL NULL NULL NULL
+false false false false false false
+
+# invalid argument count and type
+query error DataFusion error:
+SELECT sha384();
+
+query error DataFusion error:
+SELECT sha384('tom', 'extra');
+
+query error DataFusion error:
+SELECT sha384(1);
+
 query ?
 SELECT digest(NULL,'sha384');
 ----
@@ -1708,6 +1758,31 @@ SELECT sha512(NULL);
 ----
 NULL
 
+# sha512 string and binary array inputs
+query BBBBBB
+SELECT
+  sha512(column1) = sha512('tom'),
+  sha512(arrow_cast(column1, 'LargeUtf8')) = sha512('tom'),
+  sha512(arrow_cast(column1, 'Utf8View')) = sha512('tom'),
+  sha512(arrow_cast(column1, 'Binary')) = sha512('tom'),
+  sha512(arrow_cast(column1, 'LargeBinary')) = sha512('tom'),
+  sha512(arrow_cast(column1, 'BinaryView')) = sha512('tom')
+FROM (VALUES ('tom'), (NULL), ('mot')) AS t(column1);
+----
+true true true true true true
+NULL NULL NULL NULL NULL NULL
+false false false false false false
+
+# invalid argument count and type
+query error DataFusion error:
+SELECT sha512();
+
+query error DataFusion error:
+SELECT sha512('tom', 'extra');
+
+query error DataFusion error:
+SELECT sha512(1);
+
 query ?
 SELECT digest(NULL,'sha512');
 ----


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org