[ https://issues.apache.org/jira/browse/CALCITE-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114668#comment-16114668 ]
Julian Hyde commented on CALCITE-1927: -------------------------------------- So I guess some databases allow only {{BIT(1)}} and others allow {{BIT(m)}} for {{m}} up to some database-dependent limit. Safest thing seems to be to transmit the {{BIT(m)}} type as {{VARBINARY((m + 7) / 8)}}. Accessor methods should do something sensible if possible: * getBoolean should give a value if m <= 1, an error otherwise; * getInt should give a value if m <= 32, an error otherwise; * getLong should give a value if m <= 64, an error otherwise; * similarly getShort, getByte; * getBytes should give a value (padding with zero bits to fill up the last byte); * getString should return e.g. '101'; * getObject should return the same as getBytes; * other methods always throw. > Mapping for Types.BIT: boolean or BitSet? > ----------------------------------------- > > Key: CALCITE-1927 > URL: https://issues.apache.org/jira/browse/CALCITE-1927 > Project: Calcite > Issue Type: Bug > Components: avatica > Affects Versions: 1.13.0 > Reporter: Vladimir Sitnikov > Labels: pgjdbc, postgresql > > Currently Avatica implements `Types.BIT` as `Boolean` (see > https://github.com/apache/calcite-avatica/blob/4db1fb9c66db8ccebc9e96ce678154ec69c557f0/core/src/main/java/org/apache/calcite/avatica/AvaticaSite.java#L227-L230 > ) > Certain databases (e.g. PostgreSQL) have {{bit\(n)}} and {{varbit\(n)}} data > types that are "bit strings" (see > https://www.postgresql.org/docs/9.6/static/datatype-bit.html ) > If both used together, {{getObject}} just blows when trying to convert thing > like {{'01101'}} to a boolean. > I wonder what should be the behavior for {{Types.BIT}}. > The original discussion is here: https://github.com/pgjdbc/pgjdbc/issues/908 > PS. I'm not using Avatica + PostgreSQL + varbit combo yet, however I just > want to weight different implementation options, and make it simpler for > different JDBC implementations to talk to each other. -- This message was sent by Atlassian JIRA (v6.4.14#64029)