[ 
https://issues.apache.org/jira/browse/FLINK-8038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16251994#comment-16251994
 ] 

ASF GitHub Bot commented on FLINK-8038:
---------------------------------------

GitHub user walterddr opened a pull request:

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

    [FLINK-8038][Table API] Support MAP value constructor

    ## What is the purpose of the change
    
    This pull request makes creates Map value constructor support for Table and 
SQL API. 
    This is to enable creating Map literals or fields combination, such as:
    ```
    MAP('a', '1', 'b', f4, 'c', intField.cast(STRING)) // Table API
    MAP['a', '1', 'b', stringField. 'c', CAST(intField AS VARCHAR(65536)) // 
SQL API
    ```
    It also supports accessing a particular value within a MAP object, such as:
    ```
    MAP('foo', 'bar').getValue('foo') // Table API
    MAP['foo', 'bar']['foo'] // SQL API, field access is already supported in 
FLINK-6377 
    ```
    
    ## Brief change log
    
    Changes includes:
      - Created map case class in flink table expression to support map 
generation and get value operation
      - Created `getValue` and `map` in ExpressionDsl
      - added `generateMap` in CodeGenerator
      - define `generateOperator` and `generateMap` impl in ScalarOperators
      - added in expression parsing logic to feed type information in 
ExpressionParser
    
    ## Verifying this change
    
    Added in various Map operator tests in MapTypeTest and SqlExpressionTest.
    
    ## Does this pull request potentially affect one of the following parts:
    
    Not that I know of.
    
    ## Documentation
    
      - Does this pull request introduce a new feature? yes
      - If yes, how is the feature documented? (not documented, please advise)


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

    $ git pull https://github.com/walterddr/flink FLINK-8038

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

    https://github.com/apache/flink/pull/5015.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 #5015
    
----
commit 64f37583b9fda9ecd691a7245be250f4f7531c04
Author: Rong Rong <ro...@uber.com>
Date:   2017-11-14T18:48:16Z

        initial support for Map literals, there are several literal operations 
not supported, such as
        MAP('a', 1, 'b', 2).getValue('a') is supported but .get('a') is not 
supported as MapTypeInfo is not a compositeType
        MAP('a', 1, 'b', 2).cardinality() is not supported as cardinality now 
is only supported by ObjectArrayTypeInfo
        MAP('a', 1, 'b', 2).keySet/valueSet is not supported yet
        implicity Type casting is not available yet as it has not been 
supported on ObjectArrayType either

----


> Support MAP value constructor
> -----------------------------
>
>                 Key: FLINK-8038
>                 URL: https://issues.apache.org/jira/browse/FLINK-8038
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API & SQL
>            Reporter: Rong Rong
>            Assignee: Rong Rong
>
> Similar to https://issues.apache.org/jira/browse/FLINK-4554
> We want to support Map value constructor which is supported by Calcite:
> https://calcite.apache.org/docs/reference.html#value-constructors
> {code:sql}
> SELECT
>   MAP['key1', f0, 'key2', f1] AS stringKeyedMap,
>   MAP['key', 'value'] AS literalMap,
>   MAP[f0, f1] AS fieldMap
> FROM
>   table
> {code}
> This should enable users to construct MapTypeInfo, one of the CompositeType.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to