Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAST from timestamp to string not same as Cassandra on zero milliseconds #14518

Closed
nyh opened this issue Jul 5, 2023 · 1 comment
Closed

Comments

@nyh
Copy link
Contributor

nyh commented Jul 5, 2023

This issue was previously noted in the discussion on pull request #13588 and in issue #7997, but we didn't have a separate issue about this until now.

When x is a timestamp column, and we use SELECT CAST(x AS text), the format of the output looks like 2017-12-27T11:57:42.500Z

It turns out that if the millseconds part is zero (the timestamp is a whole second), Scylla drops the ".000Z" entirely - i.e., drops both the zero milliseconds and also the timezone part ("Z"). This makes little sense (why drop the timezone only on whole second) and incompatible with Cassandra.

The following translated Cassandra unit test reproduces this issue:

  • cassandra_tests/functions/cast_fcts_test.py::testTimeCastsInSelectionClause
nyh added a commit to nyh/scylla that referenced this issue Jul 5, 2023
This is a translation of Cassandra's CQL unit test source file
functions/CastFctsTest.java into our cql-pytest framework.

There are 13 tests, 9 of them currently xfail.

The failures are caused by one recently-discovered issue:

Refs scylladb#14501: Cannot Cast Counter To Double

and by three previously unknown or undocumented issues:

Refs scylladb#14508: SELECT CAST column names should match Cassandra's
Refs scylladb#14518: CAST from timestamp to string not same as Cassandra on zero
             milliseconds
Refs scylladb#14522: Support CAST function not only in SELECT

Curiously, the careful translation of this test also caused me to
find a bug in Cassandra https://issues.apache.org/jira/browse/CASSANDRA-18647
which the test in Java missed because it made the same mistake as the
implementation.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
denesb pushed a commit that referenced this issue Jul 12, 2023
This is a translation of Cassandra's CQL unit test source file
functions/CastFctsTest.java into our cql-pytest framework.

There are 13 tests, 9 of them currently xfail.

The failures are caused by one recently-discovered issue:

Refs #14501: Cannot Cast Counter To Double

and by three previously unknown or undocumented issues:

Refs #14508: SELECT CAST column names should match Cassandra's
Refs #14518: CAST from timestamp to string not same as Cassandra on zero
             milliseconds
Refs #14522: Support CAST function not only in SELECT

Curiously, the careful translation of this test also caused me to
find a bug in Cassandra https://issues.apache.org/jira/browse/CASSANDRA-18647
which the test in Java missed because it made the same mistake as the
implementation.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>

Closes #14528
alezzqz added a commit to soft-stech/scylladb that referenced this issue Jul 17, 2023
When x is a timestamp column, and we use SELECT CAST(x AS text), the
format of the output looks must be like 2017-12-27T11:57:42.500Z

Fixes scylladb#14518
alezzqz added a commit to soft-stech/scylladb that referenced this issue Jul 18, 2023
When x is a timestamp column, and we use SELECT CAST(x AS text), the
format of the output looks must be like 2017-12-27T11:57:42.500Z

Fixes scylladb#14518
alezzqz added a commit to soft-stech/scylladb that referenced this issue Jul 20, 2023
when we convert timestamp into string it must look like: 2017-12-27T11:57:42.500Z
it concerns any conversion and affects JSON timestamp format as well - always contains milliseconds and timezone specification

Fixes scylladb#14518, scylladb#7997
alezzqz added a commit to soft-stech/scylladb that referenced this issue Jul 21, 2023
when we convert timestamp into string it must look like: 2017-12-27T11:57:42.500Z
it concerns any conversion and affects JSON timestamp format as well - always contains milliseconds and timezone specification

Fixes scylladb#14518
Fixes scylladb#7997
alezzqz added a commit to soft-stech/scylladb that referenced this issue Jul 25, 2023
when we convert timestamp into string it must look like: '2017-12-27T11:57:42.500Z'
it concerns any conversion except JSON timestamp format
JSON string has space as time separator and must look like: '2017-12-27 11:57:42.500Z'
both formats always contain milliseconds and timezone specification

Fixes scylladb#14518
Fixes scylladb#7997
nyh added a commit that referenced this issue Aug 13, 2023
This is a translation of Cassandra's CQL unit test source file
functions/CastFctsTest.java into our cql-pytest framework.

There are 13 tests, 9 of them currently xfail.

The failures are caused by one recently-discovered issue:

Refs #14501: Cannot Cast Counter To Double

and by three previously unknown or undocumented issues:

Refs #14508: SELECT CAST column names should match Cassandra's
Refs #14518: CAST from timestamp to string not same as Cassandra on zero
             milliseconds
Refs #14522: Support CAST function not only in SELECT

Curiously, the careful translation of this test also caused me to
find a bug in Cassandra https://issues.apache.org/jira/browse/CASSANDRA-18647
which the test in Java missed because it made the same mistake as the
implementation.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>

Closes #14528

(cherry picked from commit f08bc83)
nyh added a commit that referenced this issue Aug 13, 2023
This is a translation of Cassandra's CQL unit test source file
functions/CastFctsTest.java into our cql-pytest framework.

There are 13 tests, 9 of them currently xfail.

The failures are caused by one recently-discovered issue:

Refs #14501: Cannot Cast Counter To Double

and by three previously unknown or undocumented issues:

Refs #14508: SELECT CAST column names should match Cassandra's
Refs #14518: CAST from timestamp to string not same as Cassandra on zero
             milliseconds
Refs #14522: Support CAST function not only in SELECT

Curiously, the careful translation of this test also caused me to
find a bug in Cassandra https://issues.apache.org/jira/browse/CASSANDRA-18647
which the test in Java missed because it made the same mistake as the
implementation.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>

Closes #14528

(cherry picked from commit f08bc83)
(cherry picked from commit e03c21a)
@DoronArazii DoronArazii added this to the 5.4 milestone Aug 29, 2023
@denesb
Copy link
Contributor

denesb commented Dec 15, 2023

This is a minor compatibility improvement in CQL, which can even break clients, not backporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants