Apache Drill
  1. Apache Drill
  2. DRILL-863

query returns incorrect data when columns selected in the reverse order of their existence in the view

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.4.0
    • Component/s: SQL Parser
    • Labels:
      None

      Description

      I have a view beacon_aster, uid column appears before country and this works fine:
      : jdbc:drill:schema=dfs> SELECT uid, country FROM beacon_aster limit 1;
      ----------------------+

      uid country

      ----------------------+

      937021026 US

      ----------------------+
      1 row selected (6.52 seconds)

      But if select country first, it returns other columns after uid:
      0: jdbc:drill:schema=dfs> SELECT country, uid FROM beacon_aster limit 1;
      ----------------------+

      country uid

      ----------------------+

      US 937021026 2816d925-6902-2014-8017-113468677480 2012-09-25 00:00:27.132 20120906.02 60f2761d0e6192a88305054eb06877cb 1 -8 US 9

      Some cases it throws error:
      This works:
      0: jdbc:drill:schema=dfs> SELECT recorded, country FROM beacon_aster limit 1;
      ----------------------+

      recorded country

      ----------------------+

      2012-09-25T00:00:27.132-07:00 US

      ----------------------+
      1 row selected (8.279 seconds)

      But this throws IllegalArgumentException, recorded columns appears before country column:

      0: jdbc:drill:schema=dfs> SELECT country, recorded FROM beacon_aster limit 1;
      Query failed: org.apache.drill.exec.rpc.RpcException: Remote failure while running query.[error_id: "4cd5263c-039d-4e04-a4c7-2b31c5bd4139"
      endpoint

      { address: "mfs101.qa.lab" user_port: 31010 control_port: 31011 data_port: 31012 }

      error_type: 0
      message: "Failure while running fragment. < IllegalArgumentException:[ Invalid format: "2012-09-25 00:00:27.132 20120906.02 60f2761d0e6192a8830..." is malformed at " 20120906.02 60f2761d0e6192a8830..." ]"
      ]
      Error: exception while executing query (state=,code=0)

        Activity

        Hide
        Venki Korukanti added a comment -

        What is the view definition? Also selecting directly from the tables in view's definition repro this issue?

        Show
        Venki Korukanti added a comment - What is the view definition? Also selecting directly from the tables in view's definition repro this issue?
        Hide
        Vivian Summers added a comment -

        Here is what's returned if selecting directly from the table, it doesn't throw exception but hangs and doesn't return the sqlline prompt:
        0: jdbc:drill:schema=dfs> SELECT columns[31], columns[26] FROM `/user/root/cust-d1.tsv` limit 1;
        ----------------------+

        EXPR$0 EXPR$1

        ----------------------+

        US 2012-09-25 00:00:27.132 20120906.02 60f2761d0e6192a88305054eb06877cb 1 -8 US 90189 1001 ��a����

        The view definition for the columns is varchar for country and timestamp for recorded.

        Show
        Vivian Summers added a comment - Here is what's returned if selecting directly from the table, it doesn't throw exception but hangs and doesn't return the sqlline prompt: 0: jdbc:drill:schema=dfs> SELECT columns [31] , columns [26] FROM `/user/root/cust-d1.tsv` limit 1; ----------- -----------+ EXPR$0 EXPR$1 ----------- -----------+ US 2012-09-25 00:00:27.132 20120906.02 60f2761d0e6192a88305054eb06877cb 1 -8 US 90189 1001 ��a���� � The view definition for the columns is varchar for country and timestamp for recorded.
        Hide
        Steven Phillips added a comment -

        This is not a problem with views, but rather with the Text reader.

        There is a bug in project push down, where if the list of column IDs to select is not sorted, the text reader doesn't read the data and store the data correctly.

        the simplest solution is just to sort the column IDs when creating the reader. That seems to fix this issue.

        Show
        Steven Phillips added a comment - This is not a problem with views, but rather with the Text reader. There is a bug in project push down, where if the list of column IDs to select is not sorted, the text reader doesn't read the data and store the data correctly. the simplest solution is just to sort the column IDs when creating the reader. That seems to fix this issue.
        Hide
        Jacques Nadeau added a comment -

        fixed at or before 4198a17

        Show
        Jacques Nadeau added a comment - fixed at or before 4198a17
        Hide
        Jacques Nadeau added a comment -

        fixed within 4198a17~21

        Show
        Jacques Nadeau added a comment - fixed within 4198a17~21
        Hide
        Vivian Summers added a comment -

        Verified the fix in the latest build.

        Show
        Vivian Summers added a comment - Verified the fix in the latest build.

          People

          • Assignee:
            Steven Phillips
            Reporter:
            Vivian Summers
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development