2013-11-26 113 views
1

我試圖運行使用蜂巢作爲基礎數據存儲的SQL查詢,查詢調用大小數功能,引發以下錯誤:在蜂巢方法不支持

org.apache.hadoop.hive.jdbc.HivePreparedStatement.setBigDecimal(HivePreparedStatement.java:317) 

不支持

方法這完全是因爲蜂巢不支持如下:

public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { 
    // TODO Auto-generated method stub 
    throw new SQLException("Method not supported"); 
    } 

請有什麼建議可以提供給對付這種問題的其他解決方法或修復

回答

4

最初的Hive JDBC驅動程序僅支持很少的JDBC接口,請參閱HIVE-48: Support JDBC connections for interoperability between Hive and RDBMS。因此,commit保留了自動生成的「不支持」代碼,用於接口CallableStatementPreparedStatement

隨着HIVE-2158: add the HivePreparedStatement implementation based on current HIVE supported data-type一些方法充實,請參閱commit。但是沒有添加像Blob,AsciiStream,二進制流和... bigDecimal這樣的類型。當HIVE-2158得到解決(2011-06-15)時,對Hive中的DECIMAL的支持不在,它在2013年1月17日發佈了HIVE-2693: Add DECIMAL data type。在添加對DECIMAL的支持時,看起來像JDBC驅動程序接口未更新。

所以基本上JDBC驅動程序需要使用支持的新類型進行更新。你應該爲此提交一份JIRA。解決方法:不要使用DECIMAL,也不要使用PrepareStatement。

+0

非常感謝您的快速響應。我希望這個補丁運行良好。 –

0

我與「.setObject」方法有類似的問題,但更新到版本1.2.1後,它已解決。 「.setBigDecimal」目前尚未實現。 Here is the implementation of the class。但是.setObject方法目前有這樣的線,實際上解決了這種情況。

if(value instanceof BigDecimal){ 
    st.setString(valueIndex, value.toString()); 
} 

這對我有效,但是如果沒有任何警告,您可能會失去精度!

一般來說,元模型似乎支持十進制很差。如果你得到像這樣的語句的所有列

Column[] columnNames = table.getColumns(); 

和其中一列是十進制的,你會注意到沒有關於精度的信息。