cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Holmberg (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-13549) Cqlsh throws and error when querying a duration data type
Date Wed, 24 May 2017 17:58:04 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-13549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16023342#comment-16023342
] 

Adam Holmberg commented on CASSANDRA-13549:
-------------------------------------------

Historically we would only have one formatter because it is assumed that the combination of
bundled driver, and protocol version in use is fixed for a given version of cqlsh. I could
see making the case for two if you don't want to upgrade now, but want to be defensive about
changes in driver version, or possibly to maintain parity in `cqlshlib.formatting` across
branches. I don't know of anything that would preclude updating the bundled driver at this
point.

I'm still a little perplexed by what changed if there was no driver upgrade, but I haven't
gone looking.

To answer the earlier question:
bq. how to package the new driver into the source code.
See https://wiki.apache.org/cassandra/HowToContribute#Bundled_Drivers

> Cqlsh throws and error when querying a duration data type
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-13549
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13549
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>         Environment: Cassandra 3.10 dev environment running on a MacOS Sierra
>            Reporter: Akhil Mehra
>            Assignee: Benjamin Lerer
>
> h3. Overview
> Querying duration related data from the cqlsh prompt results in an error.
> Consider the following create table and insert statement.
> {code:title=Table and insert statement with duration data type|borderStyle=solid}
> CREATE TABLE duration_test (
>   primary_key text,
>   col20 duration,
>   PRIMARY KEY (primary_key)
> );
> INSERT INTO duration_test (primary_key, col20) VALUES ('primary_key_example', 1y5mo89h4m48s);
> {code}
> On executing a select query on col20 in cqlsh I get an error "Failed to format value
'"\x00\xfe\x02GS\xfc\xa5\xc0\x00' : 'ascii' codec can't decode byte 0xfe in position 2: ordinal
not in range(128)"
> {code:title=Duration Query|borderStyle=solid}
> Select  col20 from duration_test;
> {code}
> h3. Investigation
> On investigating this further I found that the current python Cassandra driver used found
in lib/cassandra-driver-internal-only-3.7.0.post0-2481531.zip does not seem to support duration
data type. This was added in Jan this year https://github.com/datastax/python-driver/pull/689.
> So I downloaded the latest driver release https://github.com/datastax/python-driver/releases/tag/3.9.0.
I embedded the latest driver into cassandra-driver-internal-only-3.7.0.post0-2481531.zip.
This fixed the driver related issue but there was still a formatting issue. 
> I then went on to modify the format_value_duration methos in the pylib/cqlshlib/formatting.py.
Diff posted below
> {code}
>  @formatter_for('Duration')
>  def format_value_duration(val, colormap, **_):
> -    buf = six.iterbytes(val)
> -    months = decode_vint(buf)
> -    days = decode_vint(buf)
> -    nanoseconds = decode_vint(buf)
> -    return format_python_formatted_type(duration_as_str(months, days, nanoseconds),
colormap, 'duration')
> +    return format_python_formatted_type(duration_as_str(val.months, val.days, val.nanoseconds),
colormap, 'duration')
> {code}
> This resulted in fixing the issue and duration types are now correctly displayed.
> Happy to fix the issue if I can get some guidance on:
> # If this is a valid issue. Tried searching JIRA but did not find anything reported.

> # If my assumptions are correct i.e. this is actually a bug
> # how to package the new driver into the source code. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message