Thank you for the quick response, Julian. I'll implement your advice. -Val
On Fri, Jun 14, 2019 at 11:34 AM Julian Hyde <[email protected]> wrote: > It looks as if there is a Hive bug logged for this issue: > https://issues.apache.org/jira/browse/HIVE-4806 < > https://issues.apache.org/jira/browse/HIVE-4806> and it has a patch that > has not been accepted. But there could be a much simpler patch - > nullsAreSortedLow should return true, and the other nullsAreSortedXxx > method should return false. See also > https://issues.apache.org/jira/browse/HIVE-12994 < > https://issues.apache.org/jira/browse/HIVE-12994>. > > > > > On Jun 14, 2019, at 11:21 AM, Valeriy Trofimov <[email protected]> > wrote: > > > > Hi All, > > > > I'm using Calcite to connect to Hive DB via JDBC adapter that connects to > > Thrift JDBC server running on a VM with Spark and Hive installed there. > The > > schema looks like this: > > > > { > > name: 'thrift', > > type: 'custom', > > factory: 'org.apache.calcite.adapter.jdbc.JdbcSchema$Factory', > > operand: { > > jdbcDriver: 'org.apache.hive.jdbc.HiveDriver', > > jdbcUrl: 'jdbc:hive2://127.0.0.1:10000/default', // please use > > VirtualBox port forwarding to the VM with Thrift server running > > jdbcUser: '', > > jdbcPassword: '' > > } > > } > > > > I get an error about null collation though. > > > > The error is caused by the Hive’s > > HiveDatabaseMetadata.nullsAreSortedAtEnd() method: > > > > public boolean nullsAreSortedAtEnd() throws SQLException { > > throw new SQLException("Method not supported"); > > } > > > > This method is called by the Calcite’s > > SqlDialectFactoryImpl.getNullCollation() method: > > > > private NullCollation getNullCollation(DatabaseMetaData > databaseMetaData) { > > try { > > if (databaseMetaData.nullsAreSortedAtEnd()) { > > return NullCollation.LAST; > > } else if (databaseMetaData.nullsAreSortedAtStart()) { > > return NullCollation.FIRST; > > } else if (databaseMetaData.nullsAreSortedLow()) { > > return NullCollation.LOW; > > } else if (databaseMetaData.nullsAreSortedHigh()) { > > return NullCollation.HIGH; > > } else { > > throw new IllegalArgumentException("cannot deduce null > collation"); > > } > > } catch (SQLException var3) { > > throw new IllegalArgumentException("cannot deduce null > > collation", var3); > > } > > } > > > > Which means that Calcite requires to know the null collation of the DB > but > > Hive doesn’t have it. > > > > Does it mean that Calcite doesn't support connecting to Hive via JDBC or > am > > I missing something? > > > > > > Thanks, > > > > Val > >
