[jira] [Commented] (CALCITE-1198) Wrong rep type returned for date, time and timestamps in column metadata

2016-04-12 Thread Francis Chuang (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15238634#comment-15238634
 ] 

Francis Chuang commented on CALCITE-1198:
-

Found the answer to my question in this piece of code: 
https://github.com/apache/calcite/blob/master/avatica/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java#L112

> Wrong rep type returned for date, time and timestamps in column metadata
> 
>
> Key: CALCITE-1198
> URL: https://issues.apache.org/jira/browse/CALCITE-1198
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: avatica-1.7.1
> Environment: Phoenix 4.7.0
>Reporter: Francis Chuang
>
> To reproduce the problem:
> 1. Create a table containing date, time and timestamp columns using 
> SquirrelSQL or similiar:
> {code}
> CREATE TABLE test (id INTEGER PRIMARY KEY, tm TIME,dt DATE,tmstmp TIMESTAMP) 
> TRANSACTIONAL=false
> {code}
> 2. Use curl to query the phoenix query server/avatica:
> {code}
> curl localhost:8765 -XPOST --data '{"request": 
> "openConnection","connectionId": "my-conn"}'
> curl localhost:8765 -XPOST --data '{"request": "prepare","connectionId": 
> "my-conn","sql": "SELECT * FROM test","maxRowCount": 1}'
> {code}
> This is the result of the prepare request:
> {code}
> {
>    "response": "prepare",
>    "statement": {
>   "connectionId": "my-conn",
>   "id": 27,
>   "signature": {
>  "columns": [
> {
>    "ordinal": 0,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 0,
>    "signed": true,
>    "displaySize": 40,
>    "label": "ID",
>    "columnName": "ID",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 4,
>   "name": "INTEGER",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.lang.Integer"
> },
> {
>    "ordinal": 1,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 23,
>    "label": "TM",
>    "columnName": "TM",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 92,
>   "name": "TIME",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.sql.Time"
> },
> {
>    "ordinal": 2,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 23,
>    "label": "DT",
>    "columnName": "DT",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 91,
>   "name": "DATE",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.sql.Date"
> },
> {
>    "ordinal": 3,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 40,
>    "label": "TMSTMP",
>    "columnName": "TMSTMP",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>   

[jira] [Commented] (CALCITE-1198) Wrong rep type returned for date, time and timestamps in column metadata

2016-04-12 Thread Francis Chuang (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15238587#comment-15238587
 ] 

Francis Chuang commented on CALCITE-1198:
-

Ah, I see! That makes sense.

How do I unserialize the date and time?

If I have time and date inserted as '2016-04-13 02:13:15', '2016-04-13 
02:13:15'.

They are coming back (via avatica) as 2 ints: 7995000, 16904

> Wrong rep type returned for date, time and timestamps in column metadata
> 
>
> Key: CALCITE-1198
> URL: https://issues.apache.org/jira/browse/CALCITE-1198
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: avatica-1.7.1
> Environment: Phoenix 4.7.0
>Reporter: Francis Chuang
>
> To reproduce the problem:
> 1. Create a table containing date, time and timestamp columns using 
> SquirrelSQL or similiar:
> {code}
> CREATE TABLE test (id INTEGER PRIMARY KEY, tm TIME,dt DATE,tmstmp TIMESTAMP) 
> TRANSACTIONAL=false
> {code}
> 2. Use curl to query the phoenix query server/avatica:
> {code}
> curl localhost:8765 -XPOST --data '{"request": 
> "openConnection","connectionId": "my-conn"}'
> curl localhost:8765 -XPOST --data '{"request": "prepare","connectionId": 
> "my-conn","sql": "SELECT * FROM test","maxRowCount": 1}'
> {code}
> This is the result of the prepare request:
> {code}
> {
>    "response": "prepare",
>    "statement": {
>   "connectionId": "my-conn",
>   "id": 27,
>   "signature": {
>  "columns": [
> {
>    "ordinal": 0,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 0,
>    "signed": true,
>    "displaySize": 40,
>    "label": "ID",
>    "columnName": "ID",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 4,
>   "name": "INTEGER",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.lang.Integer"
> },
> {
>    "ordinal": 1,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 23,
>    "label": "TM",
>    "columnName": "TM",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 92,
>   "name": "TIME",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.sql.Time"
> },
> {
>    "ordinal": 2,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 23,
>    "label": "DT",
>    "columnName": "DT",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 91,
>   "name": "DATE",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.sql.Date"
> },
> {
>    "ordinal": 3,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 40,
>    "label": "TMSTMP",
>    "columnName": "TMSTMP",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    

[jira] [Commented] (CALCITE-1198) Wrong rep type returned for date, time and timestamps in column metadata

2016-04-12 Thread Josh Elser (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15238582#comment-15238582
 ] 

Josh Elser commented on CALCITE-1198:
-

bq. time and date has a rep of PRIMITIVE_INT and timestamp has a rep type of 
PRIMITIVE_LONG

No, I'm pretty sure that's correct. It's implying how the data is being 
serialized (as an integer and long value, respectively).

> Wrong rep type returned for date, time and timestamps in column metadata
> 
>
> Key: CALCITE-1198
> URL: https://issues.apache.org/jira/browse/CALCITE-1198
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: avatica-1.7.1
> Environment: Phoenix 4.7.0
>Reporter: Francis Chuang
>
> To reproduce the problem:
> 1. Create a table containing date, time and timestamp columns using 
> SquirrelSQL or similiar:
> {code}
> CREATE TABLE test (id INTEGER PRIMARY KEY, tm TIME,dt DATE,tmstmp TIMESTAMP) 
> TRANSACTIONAL=false
> {code}
> 2. Use curl to query the phoenix query server/avatica:
> {code}
> curl localhost:8765 -XPOST --data '{"request": 
> "openConnection","connectionId": "my-conn"}'
> curl localhost:8765 -XPOST --data '{"request": "prepare","connectionId": 
> "my-conn","sql": "SELECT * FROM test","maxRowCount": 1}'
> {code}
> This is the result of the prepare request:
> {code}
> {
>    "response": "prepare",
>    "statement": {
>   "connectionId": "my-conn",
>   "id": 27,
>   "signature": {
>  "columns": [
> {
>    "ordinal": 0,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 0,
>    "signed": true,
>    "displaySize": 40,
>    "label": "ID",
>    "columnName": "ID",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 4,
>   "name": "INTEGER",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.lang.Integer"
> },
> {
>    "ordinal": 1,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 23,
>    "label": "TM",
>    "columnName": "TM",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 92,
>   "name": "TIME",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.sql.Time"
> },
> {
>    "ordinal": 2,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 23,
>    "label": "DT",
>    "columnName": "DT",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>    "catalogName": "",
>    "type": {
>   "type": "scalar",
>   "id": 91,
>   "name": "DATE",
>   "rep": "PRIMITIVE_INT"
>    },
>    "readOnly": true,
>    "writable": false,
>    "definitelyWritable": false,
>    "columnClassName": "java.sql.Date"
> },
> {
>    "ordinal": 3,
>    "autoIncrement": false,
>    "caseSensitive": false,
>    "searchable": true,
>    "currency": false,
>    "nullable": 1,
>    "signed": false,
>    "displaySize": 40,
>    "label": "TMSTMP",
>    "columnName": "TMSTMP",
>    "schemaName": "",
>    "precision": 0,
>    "scale": 0,
>    "tableName": "TEST",
>