You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2024/03/02 10:17:07 UTC

(phoenix-queryserver) branch master updated: PHOENIX-7246 Crash Due to Unhandled JDBC Type Code 0 for NULL Values

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

stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-queryserver.git


The following commit(s) were added to refs/heads/master by this push:
     new a5af0c9  PHOENIX-7246 Crash Due to Unhandled JDBC Type Code 0 for NULL Values
a5af0c9 is described below

commit a5af0c9bf33554f3740587bf47d0e0b77f00908a
Author: Satya Kommula <sa...@ymail.com>
AuthorDate: Sat Mar 2 09:40:04 2024 +0530

    PHOENIX-7246 Crash Due to Unhandled JDBC Type Code 0 for NULL Values
---
 python-phoenixdb/phoenixdb/tests/test_types.py | 5 +++++
 python-phoenixdb/phoenixdb/types.py            | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/python-phoenixdb/phoenixdb/tests/test_types.py b/python-phoenixdb/phoenixdb/tests/test_types.py
index 5d6cf8d..9354cc5 100644
--- a/python-phoenixdb/phoenixdb/tests/test_types.py
+++ b/python-phoenixdb/phoenixdb/tests/test_types.py
@@ -378,3 +378,8 @@ class TypesTest(DatabaseTestCase):
                 [4, [True, True, True]],
                 [5, None]
             ])
+
+    def test_select_null(self):
+        with self.conn.cursor() as cursor:
+            cursor.execute("SELECT NULL")
+            self.assertEqual(cursor.fetchall(), [[None]])
diff --git a/python-phoenixdb/phoenixdb/types.py b/python-phoenixdb/phoenixdb/types.py
index 21421b5..80f8fe8 100644
--- a/python-phoenixdb/phoenixdb/types.py
+++ b/python-phoenixdb/phoenixdb/types.py
@@ -166,6 +166,9 @@ FIELD_MAP = {
     'double_value': [
         (common_pb2.DOUBLE, float, float),
         (common_pb2.PRIMITIVE_DOUBLE, float, float)
+    ],
+    "null_value": [
+        (common_pb2.NULL, None, None)
     ]
 }
 """The master map that describes how to handle types, keyed by TypedData field"""
@@ -206,6 +209,7 @@ JDBC_TO_REP = dict([
     (13, common_pb2.SHORT),  # UNSIGNED_SMALLINT
     (20, common_pb2.JAVA_SQL_TIMESTAMP),  # UNSIGNED_TIMESTAMP
     (11, common_pb2.BYTE),  # UNSIGNED_TINYINT
+    (0, common_pb2.NULL),  # NULL
     # The following are not used by Phoenix, but some of these are used by Avaticafor
     # parameter types
     (-7, common_pb2.BOOLEAN),  # BIT
@@ -222,9 +226,8 @@ JDBC_TO_REP = dict([
     (2011, common_pb2.STRING),  # NCLOB
     (2009, common_pb2.STRING),  # SQLXML
     # Returned by Avatica for Arrays in EMPTY resultsets
-    (2000, common_pb2.BYTE_STRING)  # JAVA_OBJECT
+    (2000, common_pb2.BYTE_STRING),  # JAVA_OBJECT
     # These are defined by JDBC, but cannot be mapped
-    # NULL
     # OTHER
     # DISTINCT
     # STRUCT