Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-2514

Even with ORDER BY clause the LIMIT does not work correctly with salted tables containing many records.

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 4.5.1
    • None
    • None
    • HBase-0.98.14

    • Patch, Important

    Description

      A query such as SELECT CURRENT_TIMESTAMP FROM TBL ORDER BY CURRENT_TIMESTAMP DESC LIMIT 1 does not really return the MAX(CURRENT_TIMESTAMP). The table is salted and has 200272 records.

      select current_timestamp from TBL order by current_timestamp desc limit 1;
      ------------------------------------------

      CURRENT_TIMESTAMP

      ------------------------------------------

      1448815328556

      ------------------------------------------

      select max(current_timestamp) from TBL;
      ------------------------------------------

      MAX("CURRENT_TIMESTAMP")

      ------------------------------------------

      1449732792090

      ------------------------------------------

      The results are different. MAX is of course, returning the right record.

      The above query is one example. There are other queries which also seem to be returning incorrect record with ORDER BY and LIMIT.

      Is this also correct that when there is a WHERE clause limiting the number of projected records, then LIMIT seems to work fine? I seem to be noticing that also.

      The table DDL is:
      CREATE TABLE IF NOT EXISTS TBL
      (CURRENT_TIMESTAMP BIGINT NOT NULL, ID VARCHAR(96), CURR_EXDOC VARCHAR, CURR_CHECKSUM VARCHAR(32), SUMMARY VARCHAR,
      CONSTRAINT PK PRIMARY KEY(CURRENT_TIMESTAMP, ID))
      BLOCKCACHE=FALSE, COMPRESSION=SNAPPY, SALT_BUCKETS=8

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sumit.nigam Sumit Nigam

            Dates

              Created:
              Updated:

              Slack

                Issue deployment