Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.12.0
Description
I am using phoenix QueryServer upsert data in batch,the code as follows:
@Test public void preparedStatementArrayTest() throws Exception { final String tableName = "TEST"; try (Connection conn = DriverManager.getConnection("jdbc:phoenix:thin:http://localhost:8765"); Statement stmt = conn.createStatement()) { conn.setAutoCommit(false); assertFalse(stmt.execute("DROP TABLE IF EXISTS " + tableName)); assertFalse(stmt.execute("CREATE TABLE " + tableName + " (" + "pk VARCHAR NOT NULL PRIMARY KEY, " + "histogram INTEGER[])") ); conn.commit(); int numRows = 10; int numEvenElements = 4; int numOddElements = 6; try (PreparedStatement pstmt = conn.prepareStatement("UPSERT INTO " + tableName + " values(?, ?)")) { for (int i = 0; i < numRows; i++) { pstmt.setString(1, Integer.toString(i)); int arrayLength = i % 2 == 0 ? numEvenElements : numOddElements; Object[] arrayData = new Object[arrayLength]; for (int arrayOffset = 0; arrayOffset < arrayLength; arrayOffset++) { arrayData[arrayOffset] = Integer.toString(getArrayValueForOffset(arrayOffset)); } pstmt.setArray(2, conn.createArrayOf("VARCHAR", arrayData)); pstmt.addBatch(); pstmt.executeBatch(); } conn.commit(); } }
When encounter Array type, I get an error NPE:
java.lang.NullPointerException at org.apache.calcite.avatica.remote.TypedValue.serialToJdbc(TypedValue.java:362) at org.apache.calcite.avatica.remote.TypedValue.protoToJdbc(TypedValue.java:895) at org.apache.calcite.avatica.jdbc.JdbcMeta.executeBatchProtobuf(JdbcMeta.java:986) at org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:363) at org.apache.calcite.avatica.remote.Service$ExecuteBatchRequest.accept(Service.java:2990) at org.apache.calcite.avatica.remote.Service$ExecuteBatchRequest.accept(Service.java:2942) at org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:94)
Attachments
Attachments
Issue Links
- links to