[
https://issues.apache.org/jira/browse/PHOENIX-5065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16713448#comment-16713448
]
William Shen commented on PHOENIX-5065:
---------------------------------------
This might highlight the issue more clearly. Seems like the IN operator might
have a bug?
{noformat}
0: jdbc:phoenix:labs-darth-journalnode-lv-101> SELECT COUNT(*) FROM
SYSTEM.CATALOG WHERE TENANT_ID IN ('');
+-----------+
| COUNT(1) |
+-----------+
| 0 |
+-----------+
1 row selected (0.01 seconds)
0: jdbc:phoenix:labs-darth-journalnode-lv-101> SELECT COUNT(*) FROM
SYSTEM.CATALOG WHERE TENANT_ID IN ('FOO');
+-----------+
| COUNT(1) |
+-----------+
| 0 |
+-----------+
1 row selected (0.012 seconds)
0: jdbc:phoenix:labs-darth-journalnode-lv-101> SELECT COUNT(*) FROM
SYSTEM.CATALOG WHERE TENANT_ID IN ('', 'FOO');
+-----------+
| COUNT(1) |
+-----------+
| 4112 |
+-----------+
1 row selected (0.191 seconds)
{noformat}
> Inconsistent treatment of NULL and empty string
> -----------------------------------------------
>
> Key: PHOENIX-5065
> URL: https://issues.apache.org/jira/browse/PHOENIX-5065
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.14.1
> Reporter: Geoffrey Jacoby
> Priority: Major
>
> Phoenix doesn't handle NULLs consistently with other SQL dialects, and it
> doesn't handle them consistently internally either.
> In PHOENIX-2422, [~jamestaylor] mentioned that Phoenix's intended behavior is
> for empty string and NULL to be equivalent. That's inconsistent with other
> SQL dialects (in which NULL is never equal to anything, including itself),
> but if that's our documented behavior, then that's fine unless PHOENIX-2422
> to change it is ever worked.
> But consider the following queries:
> {code:java}
> SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID = '';
> -- Returns 0 rows
> SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID IS NULL;
> -- Returns some number of rows. Call it N
> SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID IN ('');
> -- Returns 0 rows
> SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID IN ('', 'FOO');
> -- Returns N rows. Note that FOO does not exist, and is just a nonsense string
> SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE TENANT_ID = '' OR TENANT_ID = 'FOO'
> --Returns 0 rows, but slowly
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)