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

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

commit a29319e4b9db0b104b3c4656e8610cd84f82039f
Author: Riza Suminto <[email protected]>
AuthorDate: Wed Apr 16 13:43:29 2025 -0700

    IMPALA-13970: Add NaN and Infinity parsing in ImpylaHS2ResultSet
    
    This patch adds NaN, Infinity, and boolean parsing in ImpylaHS2ResultSet
    to match with beeswax result. TestQueriesJsonTables is changed to test
    all client protocol.
    
    Testing:
    Run and pass TestQueriesJsonTables.
    
    Change-Id: I739a88e9dfa418d3a3c2d9d4181b4add34bc6b93
    Reviewed-on: http://gerrit.cloudera.org:8080/22785
    Reviewed-by: Riza Suminto <[email protected]>
    Tested-by: Riza Suminto <[email protected]>
---
 tests/common/impala_connection.py | 11 ++++++++++-
 tests/query_test/test_queries.py  |  9 ++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/common/impala_connection.py 
b/tests/common/impala_connection.py
index 8559cd321..caca64e35 100644
--- a/tests/common/impala_connection.py
+++ b/tests/common/impala_connection.py
@@ -23,6 +23,7 @@ from __future__ import absolute_import, division, 
print_function
 import abc
 import getpass
 import logging
+import math
 import re
 import time
 
@@ -980,7 +981,15 @@ class ImpylaHS2ResultSet(object):
       return 'NULL'
     if type(val) == float:
       # Same format as what Beeswax uses in the backend.
-      return "{:.16g}".format(val)
+      if math.isnan(val):
+        return 'NaN'
+      elif math.isinf(val):
+        if val < 0:
+          return '-Infinity'
+        else:
+          return 'Infinity'
+      else:
+        return "{:.16g}".format(val)
     elif col_type == 'BOOLEAN':
       # Beeswax return 'false' or 'true' for boolean column.
       # HS2 return 'False' or 'True'.
diff --git a/tests/query_test/test_queries.py b/tests/query_test/test_queries.py
index c8fdb4353..94801670a 100644
--- a/tests/query_test/test_queries.py
+++ b/tests/query_test/test_queries.py
@@ -37,7 +37,6 @@ from tests.common.test_dimensions import (
     extend_exec_option_dimension,
     FILE_FORMAT_TO_STORED_AS_MAP,
 )
-from tests.common.test_vector import BEESWAX
 from tests.util.filesystem_utils import get_fs_path
 
 
@@ -264,15 +263,11 @@ class TestQueriesTextTables(ImpalaTestSuite):
 # format that is supported, or the tests don't exercise the file format.
 class TestQueriesJsonTables(ImpalaTestSuite):
 
-  @classmethod
-  def default_test_protocol(cls):
-    # Some assertions in this test relies on beeswax-specific return values 
such as
-    # Infinity, NaN, false, and true. HS2 returns inf, nan, False, and True 
instead.
-    return BEESWAX
-
   @classmethod
   def add_test_dimensions(cls):
     super(TestQueriesJsonTables, cls).add_test_dimensions()
+    # Test that all protocol works.
+    cls.ImpalaTestMatrix.add_dimension(create_client_protocol_dimension())
     cls.ImpalaTestMatrix.add_dimension(
         create_uncompressed_json_dimension(cls.get_workload()))
     add_exec_option_dimension(cls, 'disable_optimized_json_count_star', [0, 1])

Reply via email to