I'm working on Flink SQL client. Input data is json format and contains nested json. I'm trying to query the nested json from the table and expecting the output to be nested json instead of string. I've build the environment file to define a table schema as: format: type: json Sink table schema:
Queries Been trying the following queries Flink SQL> insert into nestedSink select nested.`inner` as `nested.inner` from nestedJsonStream; [INFO] Submitting SQL update statement to the cluster... [ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: Field types of query result and registered TableSink [nestedSink] do not match. Query result schema: [nested.inner: String] TableSink schema: [nested: Row] Flink SQL> insert into nestedSink select nested from nestedJsonStream; [INFO] Submitting SQL update statement to the cluster... [ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: Field types of query result and registered TableSink [nestedSink] do not match. Query result schema: [nested: Row] TableSink schema: [nested: Row] Flink SQL> insert into nestedSink select nested.`inner` as nested.`inner` from nestedJsonStream; [INFO] Submitting SQL update statement to the cluster... [ERROR] Could not execute SQL statement. Reason: org.apache.flink.sql.parser.impl.ParseException: Encountered "." at line 1, column 55. Was expecting one of: <EOF> "EXCEPT" ... "FETCH" ... "FROM" ... "INTERSECT" ... "LIMIT" ... "OFFSET" ... "ORDER" ... "MINUS" ... "UNION" ... "," ... Help me understand the problem with my schema/query? Also would like to add new columns and nested colums. Thanks Srikanth |
Hi, I did not understand what you are trying to achieve. Which field of the input table do you want to write to the output table? Flink SQL> insert into nestedSink select nested from nestedJsonStream; [INFO] Submitting SQL update statement to the cluster... [ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: Field types of query result and registered TableSink [nestedSink] do not match. Query result schema: [nested: Row] TableSink schema: [nested: Row] This does not work, because the nested schema of the query result and sink are not identical. The table sink has only one nested String field called inner. The query result looks like this: ROW<`inner` STRING, `nested1` ROW<`inner1` STRING>> You need to make sure that the schema of query result and sink table are exactly the same. Otherwise, Flink will throw those ValidationExceptions. Best, Fabian Am Do., 24. Okt. 2019 um 12:24 Uhr schrieb srikanth flink <[hidden email]>:
|
Free forum by Nabble | Edit this page |