You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tajo.apache.org by "Keuntae Park (JIRA)" <ji...@apache.org> on 2014/12/18 07:56:13 UTC

[jira] [Updated] (TAJO-1257) ORDER BY with NULL FIRST misses some data

     [ https://issues.apache.org/jira/browse/TAJO-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Keuntae Park updated TAJO-1257:
-------------------------------
    Description: 
Even with TAJO-904 and TAJO-1239, ORDER BY NULL FIRST misses some data.
Below test code doesn't pass.
It seems that this problem comes from misbehaving setMaxRangeIfNull() method in TupleUtil.java, which places NULL in the range by only considering the existence of ASC/DESC.

{code} 
    KeyValueSet tableOptions = new KeyValueSet();
    tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);
    tableOptions.set(StorageConstants.TEXT_NULL, "\\\\N");

    Schema schema = new Schema();
    schema.addColumn("id", Type.INT4);
    schema.addColumn("name", Type.TEXT);
    String[] data = new String[]{ "1|111", "2|\\N", "3|333" };
    TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1);

    try {
      ResultSet res = executeString("select * from table11 order by name null first");
      String ascExpected = "id,name\n" +
          "-------------------------------\n" +
          "2,null\n" +
          "1,111\n" +
          "3,333\n";

      assertEquals(ascExpected, resultSetToString(res));
      res.close();

    } finally {
      executeString("DROP TABLE table11 PURGE");
    }
{code}

  was:
Even with TAJO-904 and 1239, ORDER BY NULL FIRST misses some data.
Below test code doesn't pass.
It seems that this problem comes from misbehaving setMaxRangeIfNull() method in TupleUtil.java, which places NULL in the range by only considering the existence of ASC/DESC.

{code} 
    KeyValueSet tableOptions = new KeyValueSet();
    tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);
    tableOptions.set(StorageConstants.TEXT_NULL, "\\\\N");

    Schema schema = new Schema();
    schema.addColumn("id", Type.INT4);
    schema.addColumn("name", Type.TEXT);
    String[] data = new String[]{ "1|111", "2|\\N", "3|333" };
    TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1);

    try {
      ResultSet res = executeString("select * from table11 order by name null first");
      String ascExpected = "id,name\n" +
          "-------------------------------\n" +
          "2,null\n" +
          "1,111\n" +
          "3,333\n";

      assertEquals(ascExpected, resultSetToString(res));
      res.close();

    } finally {
      executeString("DROP TABLE table11 PURGE");
    }
{code}


> ORDER BY with NULL FIRST misses some data
> -----------------------------------------
>
>                 Key: TAJO-1257
>                 URL: https://issues.apache.org/jira/browse/TAJO-1257
>             Project: Tajo
>          Issue Type: Bug
>            Reporter: Keuntae Park
>            Priority: Minor
>
> Even with TAJO-904 and TAJO-1239, ORDER BY NULL FIRST misses some data.
> Below test code doesn't pass.
> It seems that this problem comes from misbehaving setMaxRangeIfNull() method in TupleUtil.java, which places NULL in the range by only considering the existence of ASC/DESC.
> {code} 
>     KeyValueSet tableOptions = new KeyValueSet();
>     tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);
>     tableOptions.set(StorageConstants.TEXT_NULL, "\\\\N");
>     Schema schema = new Schema();
>     schema.addColumn("id", Type.INT4);
>     schema.addColumn("name", Type.TEXT);
>     String[] data = new String[]{ "1|111", "2|\\N", "3|333" };
>     TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1);
>     try {
>       ResultSet res = executeString("select * from table11 order by name null first");
>       String ascExpected = "id,name\n" +
>           "-------------------------------\n" +
>           "2,null\n" +
>           "1,111\n" +
>           "3,333\n";
>       assertEquals(ascExpected, resultSetToString(res));
>       res.close();
>     } finally {
>       executeString("DROP TABLE table11 PURGE");
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)