[ 
https://issues.apache.org/jira/browse/FLINK-41334?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ramin Gharib updated FLINK-41334:
---------------------------------
    Description: 
The SQL Gateway serializes result rows with the {{json}} format converters, and 
those have no {{UUID}} case. {{rowFormat=JSON}} is the default of the 
fetch-results endpoint, and the JDBC driver always requests it. A query that 
returns a {{UUID}} column therefore fails for REST clients and for JDBC.

{code:sql}
SELECT UUID_V4();
{code}

||Client||Row format||Result||
|SQL Client|{{PLAIN_TEXT}}|works, prints the canonical string|
|REST fetch-results without {{rowFormat}}|{{JSON}}, the 
default|{{UnsupportedOperationException: Not support to parse type: UUID}}|
|JDBC driver|{{JSON}}|same error. The driver has no {{UUID}} mapping either|

I serialized a {{ResultInfo}} with one {{UUID}} column through 
{{ResultInfoSerializer}} on 2.4-SNAPSHOT. {{PLAIN_TEXT}} round-trips and 
{{JSON}} throws the error above.

h3. What is missing

# {{RowDataToJsonConverters}} and {{JsonToRowDataConverters}} in flink-json 
have no {{UUID}} case. The gateway uses them in {{ResultInfoSerializer}} and 
{{ResultInfoDeserializer}}.
# In the JDBC driver, {{ColumnInfo.fromLogicalType}} throws {{Not supported 
type\[UUID\]}}, and {{FlinkResultSet.convertToJavaObject}} has no {{UUID}} case.

The gateway's own {{LogicalTypeJsonSerializer}} already handles {{UUID}}, so 
the column metadata is fine.

h3. Proposal

* Write a {{UUID}} as its canonical string in both JSON converters and read it 
back the same way. FLIP-604 already names the canonical string as the JSON 
mapping. The {{json}} format uses the same converters and would accept {{UUID}} 
columns too. That needs its own tests and docs.
* In the JDBC driver, report {{Types.OTHER}}, return {{java.util.UUID}} from 
{{getObject}} and the canonical string from {{getString}}.

{{VARIANT}} has the same gap in {{ColumnInfo.fromLogicalType}}. That is out of 
scope here.

  was:
The SQL Gateway serializes result rows with the {{json}} format converters, and 
those have no {{UUID}} case. {{rowFormat=JSON}} is the default of the 
fetch-results endpoint, and the JDBC driver always requests it. A query that 
returns a {{UUID}} column therefore fails for REST clients and for JDBC.

{code:sql}
SELECT UUID_V4();
{code}

||Client||Row format||Result||
|SQL Client|{{PLAIN_TEXT}}|works, prints the canonical string|
|REST fetch-results without {{rowFormat}}|{{JSON}}, the 
default|{{UnsupportedOperationException: Not support to parse type: UUID}}|
|JDBC driver|{{JSON}}|same error. The driver has no {{UUID}} mapping either|

I serialized a {{ResultInfo}} with one {{UUID}} column through 
{{ResultInfoSerializer}} on 2.4-SNAPSHOT. {{PLAIN_TEXT}} round-trips and 
{{JSON}} throws the error above.

h3. What is missing

# {{RowDataToJsonConverters}} and {{JsonToRowDataConverters}} in flink-json 
have no {{UUID}} case. The gateway uses them in {{ResultInfoSerializer}} and 
{{ResultInfoDeserializer}}.
# In the JDBC driver, {{ColumnInfo.fromLogicalType}} throws {{Not supported 
type[UUID]}}, and {{FlinkResultSet.convertToJavaObject}} has no {{UUID}} case.

The gateway's own {{LogicalTypeJsonSerializer}} already handles {{UUID}}, so 
the column metadata is fine.

h3. Proposal

* Write a {{UUID}} as its canonical string in both JSON converters and read it 
back the same way. FLIP-604 already names the canonical string as the JSON 
mapping. The {{json}} format uses the same converters and would accept {{UUID}} 
columns too. That needs its own tests and docs.
* In the JDBC driver, report {{Types.OTHER}}, return {{java.util.UUID}} from 
{{getObject}} and the canonical string from {{getString}}.

{{VARIANT}} has the same gap in {{ColumnInfo.fromLogicalType}}. That is out of 
scope here.


> SQL Gateway JSON results and the JDBC driver cannot return a UUID column
> ------------------------------------------------------------------------
>
>                 Key: FLINK-41334
>                 URL: https://issues.apache.org/jira/browse/FLINK-41334
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Formats (JSON, Avro, Parquet, ORC, SequenceFile), Table 
> SQL / Gateway, Table SQL / JDBC
>    Affects Versions: 2.4.0
>            Reporter: Ramin Gharib
>            Priority: Major
>
> The SQL Gateway serializes result rows with the {{json}} format converters, 
> and those have no {{UUID}} case. {{rowFormat=JSON}} is the default of the 
> fetch-results endpoint, and the JDBC driver always requests it. A query that 
> returns a {{UUID}} column therefore fails for REST clients and for JDBC.
> {code:sql}
> SELECT UUID_V4();
> {code}
> ||Client||Row format||Result||
> |SQL Client|{{PLAIN_TEXT}}|works, prints the canonical string|
> |REST fetch-results without {{rowFormat}}|{{JSON}}, the 
> default|{{UnsupportedOperationException: Not support to parse type: UUID}}|
> |JDBC driver|{{JSON}}|same error. The driver has no {{UUID}} mapping either|
> I serialized a {{ResultInfo}} with one {{UUID}} column through 
> {{ResultInfoSerializer}} on 2.4-SNAPSHOT. {{PLAIN_TEXT}} round-trips and 
> {{JSON}} throws the error above.
> h3. What is missing
> # {{RowDataToJsonConverters}} and {{JsonToRowDataConverters}} in flink-json 
> have no {{UUID}} case. The gateway uses them in {{ResultInfoSerializer}} and 
> {{ResultInfoDeserializer}}.
> # In the JDBC driver, {{ColumnInfo.fromLogicalType}} throws {{Not supported 
> type\[UUID\]}}, and {{FlinkResultSet.convertToJavaObject}} has no {{UUID}} 
> case.
> The gateway's own {{LogicalTypeJsonSerializer}} already handles {{UUID}}, so 
> the column metadata is fine.
> h3. Proposal
> * Write a {{UUID}} as its canonical string in both JSON converters and read 
> it back the same way. FLIP-604 already names the canonical string as the JSON 
> mapping. The {{json}} format uses the same converters and would accept 
> {{UUID}} columns too. That needs its own tests and docs.
> * In the JDBC driver, report {{Types.OTHER}}, return {{java.util.UUID}} from 
> {{getObject}} and the canonical string from {{getString}}.
> {{VARIANT}} has the same gap in {{ColumnInfo.fromLogicalType}}. That is out 
> of scope here.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to