GitHub user kmurra opened a pull request:

    https://github.com/apache/flink/pull/4746

    [FLINK-7657] [Table] Adding logic to convert RexLiteral to expected SQL 
Date/Time/Timestamp classes

    ## What is the purpose of the change
    
    This change fixes handling of date, time, and timestamp literal expressions.
    
    A ClassCastException occurs if you have a date, time, or timestamp literal 
included in the where clause of a SQL query.  When Calcite trees are converted 
to an Expression, Literal values are not properly converted to the expected 
types by the RegNodeToExpressionConverter.
    
    See https://issues.apache.org/jira/browse/FLINK-7657 for more information.
    
    ## Brief change log
    
    - Added a method that takes a RexLiteral in the Literal object and applies 
the appropriate transforms to date & time related fields.
    - Have a default fallback that works using the old behavior for other field 
types.  
        - Note that handling of other types are incorrect per the public 
documentation, but fixes are out of scope for this JIRA
    - Added comments that explained handling of values (specifically why we're 
shifting them based on time zones)
    
    ## Verifying this change
    
    This change added tests and can be verified as follows:
    - Unit test cases were added covering changes
      - Added unit test case to RexProgramExtractorTest.scala to test that 
literal conversions are of the appropriate type.
      - Added unit test case to TableSourceTest.scala to confirm that received 
Expressions in a table source extending from FilterableTableSource do not cause 
exceptions and have expected values
    - Note: Other unit test cases cover possible regressions in output values 
from the Literal->RexNode conversion
    
    ## Does this pull request potentially affect one of the following parts:
    
      - Dependencies (does it add or upgrade a dependency): no
      - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
      - The serializers: no
      - The runtime per-record code paths (performance sensitive): no
      - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: no
    
    ## Documentation
    
      - Does this pull request introduce a new feature? no
      - If yes, how is the feature documented? not applicable
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kmurra/flink kmurra-expression-timestamp-fix

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/4746.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4746
    
----
commit d8477977694614ed51ad53de55104df10ac55ad4
Author: Kent Murra <[email protected]>
Date:   2017-09-27T20:48:55Z

    [FLINK-7657] Adding logic to convert RexLiteral to expected SQL 
Date/Time/Timestamp classes, preventing ClassCastException

----


---

Reply via email to