[jira] [Created] (CALCITE-2743) TimeStamp confused in avatica jdbc
shining created CALCITE-2743: Summary: TimeStamp confused in avatica jdbc Key: CALCITE-2743 URL: https://issues.apache.org/jira/browse/CALCITE-2743 Project: Calcite Issue Type: Bug Components: avatica Affects Versions: 1.10.0 Reporter: shining I use Phoenix Query Server through avatica, Operation is as follows: 1. create table with sqlline-thin CREATE TABLE test_timezone(log_time TIMESTAMP NOT NULL PRIMARY KEY, id VARCHAR(40)); 2. Upset data upsert into test_timezone values('2018-11-27 11:01:59.000','1’); 3. Query 0: jdbc:phoenix:thin:url=http://localhost:876> select * from test_timezone; +--+-+ | LOG_TIME | ID | +-+--+ | 2018-11-27 03:01:59 | 1 | +--+——+ My local timeZone is GMT+8, and configured Phoenix “phoenix.query.dateFormatTimeZone=GMT+8” I also view code of avatica, when the timezone is GMT+8, getTimeStamp method will lose 8 hours: public Timestamp getTimestamp(Calendar calendar) throws SQLException { java.util.Date date = (java.util.Date) getObject(); if (date == null) { return null; } long v = date.getTime(); if (calendar != null) { v -= calendar.getTimeZone().getOffset(v); } return new Timestamp(v); } sqlline-thin use getString() method get the timestamp,it pass a null timezone to timestampAsString() So I have two doubtful places here: 1)I get correct time from phoenixResultSet, why reduce 8 hours ? 2)Can getString method be returned by getTimeStamp().toString(): public String getString() throws SQLException { final long v = getLong(); if (v == 0 && wasNull()) { return null; } return getTimeStamp(v, null).toString(); } -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2763) avatica-go process null
shining created CALCITE-2763: Summary: avatica-go process null Key: CALCITE-2763 URL: https://issues.apache.org/jira/browse/CALCITE-2763 Project: Calcite Issue Type: Bug Components: avatica-go Affects Versions: avatica-go-3.2.0 Reporter: shining Assignee: Francis Chuang Attachments: image-2019-01-03-19-17-56-961.png I use avatica-go client write data through phoenix queryserver, Here is my code: {code:java} package main import "database/sql" import _ "github.com/apache/calcite-avatica-go/v3" func main() { db, err := sql.Open("avatica", "http://localhost:8765";) checkErr(err) stmt, err := db.Prepare("upsert into PHOENIX_TEST (id , TITLE , date , ts , time , f)values(?, ?, ?, ?, ?, ?)") if err != nil { checkErr(err) } {color:red} _, err = stmt.Exec(0, sql.NullString{}, 1546409889000, 1546409889000, 1546409889000,33 ) {color} if err != nil { checkErr(err) } db.Close() } func checkErr(err error) { if err != nil { panic(err) } } {code} this will take an error : {noformat} IllegalArgumentException: cannot convert false (class java.lang.Boolean) to PRIMITIVE_BOOLEAN {noformat} Why phoenix queryserver receive a boolean value? -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2882) ConnectionProperties lose effectiveness when connection reopen after expired
shining created CALCITE-2882: Summary: ConnectionProperties lose effectiveness when connection reopen after expired Key: CALCITE-2882 URL: https://issues.apache.org/jira/browse/CALCITE-2882 Project: Calcite Issue Type: Bug Components: avatica Affects Versions: 1.12.0 Environment: Phoenix 5.1 avatca 1.12 Reporter: shining Attachments: image-2019-02-28-17-25-39-478.png, image-2019-02-28-17-28-31-926.png When use avatica connect Phoenix QueryServer, I create an AvaticaConnection: {code:java} Connection conntion = DriverManage.getConnection(url); connection.setAutoCommit(true); {code} Avatica keep PhoenixConnection alive in the Cache, which will be expired after 10min by default. I still use the older AvaticaConnection , it will reopen an PhoenixConnection, but the ConnectionProperties is loss, such as AutoCommit. I use sqlline-thin.py to reappear the problem: 1) sqlline-thin.py http://localhost:8765 2) upsert one row and select !image-2019-02-28-17-25-39-478.png! 3) after 10 min, upsert again, the connection will be recreate, but select null !image-2019-02-28-17-28-31-926.png! -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-2939) NPE Array Type serialToJdbc in TypedValue when executeBatch
shining created CALCITE-2939: Summary: NPE Array Type serialToJdbc in TypedValue when executeBatch Key: CALCITE-2939 URL: https://issues.apache.org/jira/browse/CALCITE-2939 Project: Calcite Issue Type: Bug Components: avatica Affects Versions: 1.12.0 Reporter: shining I am using phoenix QueryServer upsert data in batch,the code as follows: {code:java} @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(); } } {code} When encounter Array type, I get an error NPE: {code:java} 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) {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)