[ 
https://issues.apache.org/jira/browse/PHOENIX-5937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17125725#comment-17125725
 ] 

Istvan Toth commented on PHOENIX-5937:
--------------------------------------

{noformat}
 
0: jdbc:phoenix:localhost:53265> CREATE TABLE IF NOT EXISTS us_population (
. . . . . . . . . . . . . . . )>       state CHAR(2) NOT NULL,
. . . . . . . . . . . . . . . )>       city VARCHAR NOT NULL,
. . . . . . . . . . . . . . . )>       population BIGINT
. . . . . . . . . . . . . . . )>       CONSTRAINT my_pk PRIMARY KEY (state, 
city));
No rows affected (0.013 seconds)
0: jdbc:phoenix:localhost:53265> select * from SYSTEM.CATALOG where TABLE_NAME 
= 'US_POPULATION';
+-----------+-------------+---------------+-------------+---------------+-------+
| TENANT_ID | TABLE_SCHEM |  TABLE_NAME   | COLUMN_NAME | COLUMN_FAMILY | TABLE 
|
+-----------+-------------+---------------+-------------+---------------+-------+
|           |             | US_POPULATION |             |               | 0     
|
|           |             | US_POPULATION |             | 0             | null  
|
|           |             | US_POPULATION | CITY        |               | null  
|
|           |             | US_POPULATION | POPULATION  | 0             | null  
|
|           |             | US_POPULATION | STATE       |               | null  
|
+-----------+-------------+---------------+-------------+---------------+-------+
5 rows selected (0.035 seconds)
0: jdbc:phoenix:localhost:53265> select * from SYSTEM.CATALOG where TABLE_NAME 
= 'US_POPULATION' order by ORDINAL_POSITION;
+-----------+-------------+---------------+-------------+---------------+-------+
| TENANT_ID | TABLE_SCHEM |  TABLE_NAME   | COLUMN_NAME | COLUMN_FAMILY | TABLE 
|
+-----------+-------------+---------------+-------------+---------------+-------+
|           |             | US_POPULATION | STATE       |               | null  
|
|           |             | US_POPULATION | CITY        |               | null  
|
|           |             | US_POPULATION | POPULATION  | 0             | null  
|
+-----------+-------------+---------------+-------------+---------------+-------+
3 rows selected (0.019 seconds)
0: jdbc:phoenix:localhost:53265> select COLUMN_NAME from SYSTEM.CATALOG where 
TABLE_NAME = 'US_POPULATION' order by ORDINAL_POSITION;;
+-------------+
| COLUMN_NAME |
+-------------+
|             |
|             |
| STATE       |
| CITY        |
| POPULATION  |
+-------------+
5 rows selected (0.017 seconds)

{noformat}
The table has actually 5 rows.

Adding the "order by" filters the result to three rows (only where the 
ORIDNAL_POSITIOSN is not null) - BAD

However, specifying a column in the select again gives the correct result. - 
GOOD

 

> Order by on nullable column sometimes filters rows
> --------------------------------------------------
>
>                 Key: PHOENIX-5937
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5937
>             Project: Phoenix
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.x, master
>            Reporter: Istvan Toth
>            Priority: Major
>
> When selecting using order by on a nullable column, the rows where the order 
> column is null are sometimes not returned.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to