[
https://issues.apache.org/jira/browse/CALCITE-7708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18126208#comment-18126208
]
Vladimir Sitnikov commented on CALCITE-7708:
--------------------------------------------
With the protobuf serialization, any query that returns a MAP value fails,
whether the MAP is the column itself or an element of an ARRAY or MULTISET. The
same queries work with the JSON serialization.
Reproduced on Calcite main at 843f468405 (Avatica 1.29.0). Each line is
ResultSet.getString(1) for the query on the left. The remote connections use
jdbc:avatica:remote:factory=<a Service.Factory that wraps new
LocalService(CalciteMetaImpl.create(calciteConnection))> in LocalJsonService or
LocalProtobufService:
{noformat}
jdbc:calcite:
select map['a', 1] => {a=1}
select multiset[map['a', 1]] => [{a=1}]
select array[map['a', 1]] => [{a=1}]
LocalJsonService
select map['a', 1] => {a=1}
select multiset[map['a', 1]] => [{a=1}]
select array[map['a', 1]] => [{a=1}]
LocalProtobufService
select map['a', 1] => THROWS java.sql.SQLException: Error while executing SQL
"select map['a', 1]": Unhandled type in Frame: class java.util.LinkedHashMap
select multiset[map['a', 1]] => THROWS java.sql.SQLException: Error while
executing SQL "select multiset[map['a', 1]]": Unhandled type in Frame: class
java.util.LinkedHashMap
select array[map['a', 1]] => THROWS java.sql.SQLException: Error while
executing SQL "select array[map['a', 1]]": Unhandled type in Frame: class
java.util.LinkedHashMap
{noformat}
The exception is thrown on the server side, while the server serializes the
frame:
{noformat}
java.lang.RuntimeException: Unhandled type in Frame: class
java.util.LinkedHashMap
at org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:866)
at org.apache.calcite.avatica.Meta$Frame.serializeScalar(Meta.java:1004)
at org.apache.calcite.avatica.Meta$Frame.parseColumn(Meta.java:990)
at org.apache.calcite.avatica.Meta$Frame.toProto(Meta.java:959)
at
org.apache.calcite.avatica.remote.Service$FetchResponse.serialize(Service.java:1493)
at
org.apache.calcite.avatica.remote.Service$FetchResponse.serialize(Service.java:1452)
at
org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeResponse(ProtobufTranslationImpl.java:356)
{noformat}
I did not run PR #316, and what follows is from reading its diff. The PR adds
key_component and value_component to AvaticaType, so the client would learn the
MAP column type. It does not change TypedValue: message TypedValue in
common.proto has no field that can carry key-value pairs, and
TypedValue.toProto still throws for a java.util.Map. So the queries above would
fail the same way with the PR applied.
Should value serialization be part of this issue and PR #316, or should I file
it separately? A separate issue would need a protocol change of its own (a new
Rep value and new TypedValue fields), so it seems easier to change common.proto
once.
CALCITE-7849 reports the same message for a MULTISET nested in a MULTISET.
There the unhandled value is an Object[] (class [Ljava.lang.Object;), not a Map.
> Avatica does not support MAP types
> ----------------------------------
>
> Key: CALCITE-7708
> URL: https://issues.apache.org/jira/browse/CALCITE-7708
> Project: Calcite
> Issue Type: Bug
> Components: avatica
> Affects Versions: avatica-1.28
> Reporter: Mihai Budiu
> Priority: Minor
> Labels: pull-request-available
>
> Example:
> {code:java}
> try (Connection c = DriverManager.getConnection("jdbc:calcite:")) {
> ResultSet r = c.createStatement().executeQuery(
> "select map['k', date '2020-01-01'] as m from (values (1))");
> r.next();
> r.getString(1); // returns "{k=18262}", the epoch-day count
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)