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
This commit is contained in:
Andrés de la Peña 2023-03-14 13:20:26 +00:00
parent 58a3b12508
commit 3eb605b4db
16 changed files with 23 additions and 100 deletions

View File

@ -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)

View File

@ -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
-----------

View File

@ -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>
----

View File

@ -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).

View File

@ -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`)

View File

@ -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]]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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");

View File

@ -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

View File

@ -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()
{

View File

@ -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));
}

View File

@ -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

View File

@ -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]);
}

View File

@ -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");
}
/**