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

Francesco Guardiani commented on FLINK-23933:
---------------------------------------------

> Can't this issue also just be solved by making sure that the JSON format can 
> cast to the expected schema?

This should already work, e.g.:
{code:java}
my ROW(nested ROW(data ROW<(structure TIMESTAMP(3))))
{code}
But this is very cumbersome to work with, and chances are that the user will 
end up creating either a VIEW or computed columns to translate this 
multidimensional data schema into a plain representation made of scalar 
columns. 

I think your point about "implicit" record is interesting. Without discussing 
about new syntax, let's pick this example:
{code:java}
CREATE TABLE input(
    a AS my.nested.data.structure
)
WITH ( 
    'format' = 'json',
    'json.timestamp-format.standard' = 'ISO-8601'
);
{code}
>From a very high point of view, the definition of a implicitly defines that 
>the record will contain the nested objects "my.nested.data" and then inside 
>that last object, it will have a field called "structure". What our syntax 
>misses here is a way to tell that the "structure" attribute is of type 
>TIMESTAMP(3). Implementation wise, walking through the data structure should 
>already be possible, as stated in the first part of the comment, so what it 
>would be nice to have is something like this implicit definition to reduce 
>friction when working with nested data structures.

> flink-json formats support a option to parse nested json as a String
> --------------------------------------------------------------------
>
>                 Key: FLINK-23933
>                 URL: https://issues.apache.org/jira/browse/FLINK-23933
>             Project: Flink
>          Issue Type: Improvement
>          Components: Formats (JSON, Avro, Parquet, ORC, SequenceFile)
>    Affects Versions: 1.13.2
>            Reporter: Shengnan YU
>            Priority: Major
>
> When use Flink SQL to read message with nested json, eg. \{"a":{"b":111, 
> "c":"xxx"}, "d":12345},The nested field must be specified ROW or MAP in the 
> table schema.
> {code:sql}
> CREATE TABLE input(
>     a ROW(`b`: BIGINT, `c` VARCHAR),
>     d BIGINT
> )
> WITH ( 
>     'format' = 'json',
>     // ... 
> );
> {code}
> I'd like to create a option to allow we read the json-object type value as a 
> String.
> {code:sql}
> CREATE TABLE input (
>     a VARCHAR,
>     d VARCHAR
> )
> WITH ( 
>  'format' = 'json',
>  'json.forceStringFields' = 'a,d'
>  // ... 
> );
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to