This is an automated email from the ASF dual-hosted git repository. adelapena pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push: new 3eb605b4db Remove deprecated CQL functions dateOf and unixTimestampOf 3eb605b4db is described below commit 3eb605b4db0fa6b1ab67b85724a9cfbf00aae7de Author: Andrés de la Peña <a.penya.gar...@gmail.com> AuthorDate: Tue Mar 14 13:20:26 2023 +0000 Remove deprecated CQL functions dateOf and unixTimestampOf patch by Andrés de la Peña; reviewed by Berenguer Blasi and Stefan Miklosovic for CASSANDRA-18328 --- CHANGES.txt | 1 + NEWS.txt | 2 + README.asc | 2 +- doc/cql3/CQL.textile | 8 ++-- doc/modules/cassandra/pages/cql/changes.adoc | 4 ++ .../cassandra/pages/cql/cql_singlefile.adoc | 5 -- doc/modules/cassandra/pages/cql/functions.adoc | 4 -- doc/modules/cassandra/pages/new/virtualtables.adoc | 4 +- .../cassandra/pages/operating/virtualtables.adoc | 4 +- .../org/apache/cassandra/cql3/QueryProcessor.java | 2 +- .../apache/cassandra/cql3/functions/TimeFcts.java | 55 ---------------------- .../cassandra/cql3/functions/TimeFctsTest.java | 19 -------- .../cql3/validation/entities/TimeuuidTest.java | 5 +- .../cql3/validation/entities/TypeTest.java | 4 -- .../validation/miscellaneous/OverflowTest.java | 2 +- .../cql3/validation/operations/SelectTest.java | 2 +- 16 files changed, 23 insertions(+), 100 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 344d60b2ed..cc277dbcc6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 5.0 + * Remove deprecated CQL functions dateOf and unixTimestampOf (CASSANDRA-18328) * Remove DateTieredCompactionStrategy (CASSANDRA-18043) * Add system_views.max_sstable_size and system_views.max_sstable_duration tables (CASSANDRA-18333) * Extend implicit allow-filtering for virtual tables to clustering columns (CASSANDRA-18331) diff --git a/NEWS.txt b/NEWS.txt index f23a518d3d..e414d66500 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -148,6 +148,8 @@ Upgrading - Added API for alternative sstable implementations. For details, see src/java/org/apache/cassandra/io/sstable/SSTable_API.md - DateTieredCompactionStrategy was removed. Please change the compaction strategy for the tables using this strategy to TimeWindowCompactionStrategy before upgrading to this version. + - The deprecated functions `dateOf` and `unixTimestampOf` have been removed. They were deprecated and replaced by + `toTimestamp` and `toUnixTimestamp` in Cassandra 2.2. Deprecation ----------- diff --git a/README.asc b/README.asc index 8810f579f2..a2101a6e3a 100644 --- a/README.asc +++ b/README.asc @@ -41,7 +41,7 @@ be sitting in front of a prompt: ---- Connected to Test Cluster at localhost:9160. -[cqlsh 6.2.0 | Cassandra 5.0-SNAPSHOT | CQL spec 3.4.6 | Native protocol v5] +[cqlsh 6.2.0 | Cassandra 5.0-SNAPSHOT | CQL spec 3.4.7 | Native protocol v5] Use HELP for help. cqlsh> ---- diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile index bd16a43ed4..0147caa322 100644 --- a/doc/cql3/CQL.textile +++ b/doc/cql3/CQL.textile @@ -18,7 +18,7 @@ # --> -h1. Cassandra Query Language (CQL) v3.4.6 +h1. Cassandra Query Language (CQL) v3.4.7 @@ -2149,8 +2149,6 @@ A number of functions are provided to "convert" a @timeuuid@, a @timestamp@ or a |@toUnixTimestamp@ |@timeuuid@ |Converts the @timeuuid@ argument into a @bigInt@ raw value| |@toUnixTimestamp@ |@timestamp@ |Converts the @timestamp@ argument into a @bigInt@ raw value| |@toUnixTimestamp@ |@date@ |Converts the @date@ argument into a @bigInt@ raw value| -|@dateOf@ |@timeuuid@ |Similar to @toTimestamp(timeuuid)@ (DEPRECATED)| -|@unixTimestampOf@ |@timeuuid@ |Similar to @toUnixTimestamp(timeuuid)@ (DEPRECATED)| h4(#floorFun). Floor function @@ -2569,6 +2567,10 @@ h2(#changes). Changes The following describes the changes in each version of CQL. +h3. 3.4.7 + +* Remove deprecated functions @dateOf@ and @unixTimestampOf@, replaced by @toTimestamp@ and @toUnixTimestamp@. + h3. 3.4.6 * Add support for @IF EXISTS@ and @IF NOT EXISTS@ in @ALTER@ statements (see "CASSANDRA-16916":https://issues.apache.org/jira/browse/CASSANDRA-16916). diff --git a/doc/modules/cassandra/pages/cql/changes.adoc b/doc/modules/cassandra/pages/cql/changes.adoc index df99a39ef6..814da772f9 100644 --- a/doc/modules/cassandra/pages/cql/changes.adoc +++ b/doc/modules/cassandra/pages/cql/changes.adoc @@ -2,6 +2,10 @@ The following describes the changes in each version of CQL. +== 3.4.7 + +* Remove deprecated functions `dateOf` and `unixTimestampOf`, replaced by `toTimestamp` and `toUnixTimestamp` (`18328`) + == 3.4.6 * Add support for IF EXISTS and IF NOT EXISTS in ALTER statements (`16916`) diff --git a/doc/modules/cassandra/pages/cql/cql_singlefile.adoc b/doc/modules/cassandra/pages/cql/cql_singlefile.adoc index 73bb4626fa..30da0ec7bd 100644 --- a/doc/modules/cassandra/pages/cql/cql_singlefile.adoc +++ b/doc/modules/cassandra/pages/cql/cql_singlefile.adoc @@ -3117,11 +3117,6 @@ a `bigInt` raw value |`toUnixTimestamp` |`date` |Converts the `date` argument into a `bigInt` raw value - -|`dateOf` |`timeuuid` |Similar to `toTimestamp(timeuuid)` (DEPRECATED) - -|`unixTimestampOf` |`timeuuid` |Similar to `toUnixTimestamp(timeuuid)` -(DEPRECATED) |=== [[blobFun]] diff --git a/doc/modules/cassandra/pages/cql/functions.adoc b/doc/modules/cassandra/pages/cql/functions.adoc index 4a660e2f28..19d1267867 100644 --- a/doc/modules/cassandra/pages/cql/functions.adoc +++ b/doc/modules/cassandra/pages/cql/functions.adoc @@ -224,10 +224,6 @@ A number of functions are provided to convert a `timeuuid`, a `timestamp` or a ` | `toUnixTimestamp` | `timestamp` | Converts the `timestamp` argument into a `bigInt` raw value | `toUnixTimestamp` | `date` | Converts the `date` argument into a `bigInt` raw value - -| `dateOf` | `timeuuid` | Similar to `toTimestamp(timeuuid)` (DEPRECATED) - -| `unixTimestampOf` | `timeuuid` | Similar to `toUnixTimestamp(timeuuid)` (DEPRECATED) |=== ===== Blob conversion functions diff --git a/doc/modules/cassandra/pages/new/virtualtables.adoc b/doc/modules/cassandra/pages/new/virtualtables.adoc index 7a7a4befa7..22262c1b14 100644 --- a/doc/modules/cassandra/pages/new/virtualtables.adoc +++ b/doc/modules/cassandra/pages/new/virtualtables.adoc @@ -124,7 +124,7 @@ cqlsh> SELECT * FROM system_views.clients; ------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- address | 127.0.0.1 port | 50687 - client_options | {'CQL_VERSION': '3.4.6', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} + client_options | {'CQL_VERSION': '3.4.7', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} connection_stage | ready driver_name | DataStax Python Driver driver_version | 3.25.0 @@ -140,7 +140,7 @@ cqlsh> SELECT * FROM system_views.clients; ------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- address | 127.0.0.1 port | 50688 - client_options | {'CQL_VERSION': '3.4.6', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} + client_options | {'CQL_VERSION': '3.4.7', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} connection_stage | ready driver_name | DataStax Python Driver driver_version | 3.25.0 diff --git a/doc/modules/cassandra/pages/operating/virtualtables.adoc b/doc/modules/cassandra/pages/operating/virtualtables.adoc index d5fd85de8c..3a0bcb3589 100644 --- a/doc/modules/cassandra/pages/operating/virtualtables.adoc +++ b/doc/modules/cassandra/pages/operating/virtualtables.adoc @@ -125,7 +125,7 @@ cqlsh> SELECT * FROM system_views.clients; ------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- address | 127.0.0.1 port | 50687 - client_options | {'CQL_VERSION': '3.4.6', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} + client_options | {'CQL_VERSION': '3.4.7', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} connection_stage | ready driver_name | DataStax Python Driver driver_version | 3.25.0 @@ -141,7 +141,7 @@ cqlsh> SELECT * FROM system_views.clients; ------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- address | 127.0.0.1 port | 50688 - client_options | {'CQL_VERSION': '3.4.6', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} + client_options | {'CQL_VERSION': '3.4.7', 'DRIVER_NAME': 'DataStax Python Driver', 'DRIVER_VERSION': '3.25.0'} connection_stage | ready driver_name | DataStax Python Driver driver_version | 3.25.0 diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java index 3c1bfd96ce..794e70d3e8 100644 --- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java +++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java @@ -79,7 +79,7 @@ import static org.apache.cassandra.utils.Clock.Global.nanoTime; public class QueryProcessor implements QueryHandler { - public static final CassandraVersion CQL_VERSION = new CassandraVersion("3.4.6"); + public static final CassandraVersion CQL_VERSION = new CassandraVersion("3.4.7"); // See comments on QueryProcessor #prepare public static final CassandraVersion NEW_PREPARED_STATEMENT_BEHAVIOUR_SINCE_30 = new CassandraVersion("3.0.26"); diff --git a/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java b/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java index 9a6957db4b..791ed44107 100644 --- a/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java +++ b/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java @@ -30,8 +30,6 @@ import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.TimeUUID; import org.apache.cassandra.utils.UUIDGen; -import static java.util.concurrent.TimeUnit.MILLISECONDS; - import static org.apache.cassandra.cql3.statements.RequestValidations.invalidRequest; public abstract class TimeFcts @@ -47,8 +45,6 @@ public abstract class TimeFcts now("currenttime", TimeType.instance), minTimeuuidFct, maxTimeuuidFct, - dateOfFct, - unixTimestampOfFct, toDate(TimeUUIDType.instance), toTimestamp(TimeUUIDType.instance), toUnixTimestamp(TimeUUIDType.instance), @@ -107,57 +103,6 @@ public abstract class TimeFcts } }; - /** - * Function that convert a value of <code>TIMEUUID</code> into a value of type <code>TIMESTAMP</code>. - * @deprecated Replaced by the {@link #toTimestamp} function - */ - public static final NativeScalarFunction dateOfFct = new NativeScalarFunction("dateof", TimestampType.instance, TimeUUIDType.instance) - { - private volatile boolean hasLoggedDeprecationWarning; - - public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) - { - if (!hasLoggedDeprecationWarning) - { - hasLoggedDeprecationWarning = true; - logger.warn("The function 'dateof' is deprecated." + - " Use the function 'toTimestamp' instead."); - } - - ByteBuffer bb = parameters.get(0); - if (bb == null) - return null; - - long timeInMillis = TimeUUID.deserialize(bb).unix(MILLISECONDS); - return ByteBufferUtil.bytes(timeInMillis); - } - }; - - /** - * Function that convert a value of type <code>TIMEUUID</code> into an UNIX timestamp. - * @deprecated Replaced by the {@link #toUnixTimestamp} function - */ - public static final NativeScalarFunction unixTimestampOfFct = new NativeScalarFunction("unixtimestampof", LongType.instance, TimeUUIDType.instance) - { - private volatile boolean hasLoggedDeprecationWarning; - - public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) - { - if (!hasLoggedDeprecationWarning) - { - hasLoggedDeprecationWarning = true; - logger.warn("The function 'unixtimestampof' is deprecated." + - " Use the function 'toUnixTimestamp' instead."); - } - - ByteBuffer bb = parameters.get(0); - if (bb == null) - return null; - - return ByteBufferUtil.bytes(TimeUUID.deserialize(bb).unix(MILLISECONDS)); - } - }; - /** * Creates a function that convert a value of the specified type into a <code>DATE</code>. * @param type the temporal type diff --git a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java index a124e60e33..b0cc1e03ae 100644 --- a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java +++ b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java @@ -87,16 +87,6 @@ public class TimeFctsTest assertEquals(TimeUUID.maxAtUnixMillis(timeInMillis), TimeUUIDType.instance.compose(output)); } - @Test - public void testDateOf() - { - - long timeInMillis = DATE_TIME.toInstant().toEpochMilli(); - ByteBuffer input = ByteBuffer.wrap(atUnixMillisAsBytes(timeInMillis, 0)); - ByteBuffer output = executeFunction(TimeFcts.dateOfFct, input); - assertEquals(Date.from(DATE_TIME.toInstant()), TimestampType.instance.compose(output)); - } - @Test public void testTimeUuidToTimestamp() { @@ -106,15 +96,6 @@ public class TimeFctsTest assertEquals(Date.from(DATE_TIME.toInstant()), TimestampType.instance.compose(output)); } - @Test - public void testUnixTimestampOfFct() - { - long timeInMillis = DATE_TIME.toInstant().toEpochMilli(); - ByteBuffer input = ByteBuffer.wrap(atUnixMillisAsBytes(timeInMillis, 0)); - ByteBuffer output = executeFunction(TimeFcts.unixTimestampOfFct, input); - assertEquals(timeInMillis, LongType.instance.compose(output).longValue()); - } - @Test public void testTimeUuidToUnixTimestamp() { diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java index 931451e42d..e29389fc95 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java @@ -55,12 +55,13 @@ public class TimeuuidTest extends CQLTester assertRowCount(execute("SELECT * FROM %s WHERE k = 0 AND t = ?", rows[0][1]), 1); - assertInvalid("SELECT dateOf(k) FROM %s WHERE k = 0 AND t = ?", rows[0][1]); + assertInvalidMessage("k cannot be passed as argument 0 of function", + "SELECT minTimeuuid(k) FROM %s WHERE k = 0 AND t = ?", rows[0][1]); for (int i = 0; i < 4; i++) { long timestamp = ((TimeUUID) rows[i][1]).unix(MILLISECONDS); - assertRows(execute("SELECT dateOf(t), unixTimestampOf(t) FROM %s WHERE k = 0 AND t = ?", rows[i][1]), + assertRows(execute("SELECT toTimestamp(t), toUnixTimestamp(t) FROM %s WHERE k = 0 AND t = ?", rows[i][1]), row(new Date(timestamp), timestamp)); } diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/TypeTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/TypeTest.java index ceb96b607a..95aaf88da0 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/TypeTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TypeTest.java @@ -52,10 +52,6 @@ public class TypeTest extends CQLTester execute("INSERT INTO %s (a, b, c, d) VALUES (0, toUnixTimestamp(now()), toTimestamp(now()), toTimestamp(now()))"); UntypedResultSet results = execute("SELECT * FROM %s WHERE a=0 AND b <= toUnixTimestamp(now())"); assertEquals(1, results.size()); - - execute("INSERT INTO %s (a, b, c, d) VALUES (1, unixTimestampOf(now()), dateOf(now()), dateOf(now()))"); - results = execute("SELECT * FROM %s WHERE a=1 AND b <= toUnixTimestamp(now())"); - assertEquals(1, results.size()); } @Test diff --git a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/OverflowTest.java b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/OverflowTest.java index 0d9e043935..71723b0a35 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/OverflowTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/OverflowTest.java @@ -230,7 +230,7 @@ public class OverflowTest extends CQLTester createTable("CREATE TABLE %s (k int PRIMARY KEY, t timeuuid,)"); execute("INSERT INTO %s (k) VALUES (0)"); - Object[][] rows = getRows(execute("SELECT dateOf(t) FROM %s WHERE k=0")); + Object[][] rows = getRows(execute("SELECT toTimestamp(t) FROM %s WHERE k=0")); assertNull(rows[0][0]); } diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java index 7bb20977c9..622fc2b78c 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java @@ -923,7 +923,7 @@ public class SelectTest extends CQLTester for (int i = 0; i < 5; i++) execute("INSERT INTO %s (k, t) VALUES (?, now())", i); - execute("SELECT dateOf(t) FROM %s"); + execute("SELECT toTimestamp(t) FROM %s"); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org