Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-227

Extend extract function to support DateTime data types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      Currently extract() function only supports extracting time units from an Interval data type. This patch extends the extract() function to support DateTime.

      In StandardConvertletTable() we reinterpret the extract() function to be a '/' expression based on the input data types. The problem is for Drill we cannot rewrite the extract() function this early because the data types are still 'ANY' and we cannot determine the multiplier to be used in the '/' expression while rewriting it.

      Drill will extend the StandardConvertletTable() and override the convertExtract() method to simply treat it like a regular function and not rewrite it.

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/pull/227
      Created by: mehant
      Labels:
      Created at: Wed Apr 02 23:57:46 CEST 2014
      State: closed

        Activity

        Hide
        github-import GitHub Import added a comment -

        [Date: Thu Apr 03 00:06:50 CEST 2014, Author: julianhyde]

        Can you add some tests to `SqlOperatorBaseTest` (maybe add a method below `testExtractFunc`). Then we can see that this function produces the right results.

        Show
        github-import GitHub Import added a comment - [Date: Thu Apr 03 00:06:50 CEST 2014, Author: julianhyde ] Can you add some tests to `SqlOperatorBaseTest` (maybe add a method below `testExtractFunc`). Then we can see that this function produces the right results.
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu Apr 03 01:03:40 CEST 2014, Author: mehant]

        "Can you add some tests to SqlOperatorBaseTest (maybe add a method below testExtractFunc). Then we can see that this function produces the right results."

        Did you want me to add negative tests, because StandardConvertletTable.convertExtract() will currently throw an exception if the second input is a DATETIME type. Or did you want me to modify StandardConvertletTable, because the current multipliers in convertExtract() wouldn't work with DATETIME types.

        Show
        github-import GitHub Import added a comment - [Date: Thu Apr 03 01:03:40 CEST 2014, Author: mehant ] "Can you add some tests to SqlOperatorBaseTest (maybe add a method below testExtractFunc). Then we can see that this function produces the right results." Did you want me to add negative tests, because StandardConvertletTable.convertExtract() will currently throw an exception if the second input is a DATETIME type. Or did you want me to modify StandardConvertletTable, because the current multipliers in convertExtract() wouldn't work with DATETIME types.
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu Apr 03 01:14:04 CEST 2014, Author: julianhyde]

        Can you write a test. If you can't easily get it to pass then you can add @Ignore.

        In the long run, it will benefit you Drill developers, when you get round to calling SqlOperatorTest on your own operator implementations.

        Show
        github-import GitHub Import added a comment - [Date: Thu Apr 03 01:14:04 CEST 2014, Author: julianhyde ] Can you write a test. If you can't easily get it to pass then you can add @Ignore. In the long run, it will benefit you Drill developers, when you get round to calling SqlOperatorTest on your own operator implementations.
        Hide
        github-import GitHub Import added a comment -

        [Date: Thu Apr 03 01:50:32 CEST 2014, Author: mehant]

        Thanks for the quick reply. I've added tests to SqlOperatorBaseTest. convertExtract() function in StandardConvertletTable will need to be enhanced to handle DATETIME types. I can create a separate issue to address this and work on it.

        Made the other changes suggested by you.

        Show
        github-import GitHub Import added a comment - [Date: Thu Apr 03 01:50:32 CEST 2014, Author: mehant ] Thanks for the quick reply. I've added tests to SqlOperatorBaseTest. convertExtract() function in StandardConvertletTable will need to be enhanced to handle DATETIME types. I can create a separate issue to address this and work on it. Made the other changes suggested by you.

          People

          • Assignee:
            Unassigned
            Reporter:
            github-import GitHub Import
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development