You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2023/04/04 14:10:15 UTC
[cassandra] branch trunk updated: Use snake case for the names of CQL native functions
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 d3c55ed8f8 Use snake case for the names of CQL native functions
d3c55ed8f8 is described below
commit d3c55ed8f82c601d188fedbecb62a464171ea624
Author: Andrés de la Peña <a....@gmail.com>
AuthorDate: Fri Mar 10 13:22:01 2023 +0000
Use snake case for the names of CQL native functions
patch by Andrés de la Peña; reviewed by Berenguer Blasi for CASSANDRA-18037
---
CHANGES.txt | 1 +
NEWS.txt | 3 +
doc/cql3/CQL.textile | 55 +--
doc/modules/cassandra/examples/CQL/as.cql | 8 +-
.../cassandra/examples/CQL/current_date.cql | 1 +
doc/modules/cassandra/examples/CQL/currentdate.cql | 1 -
.../cassandra/examples/CQL/timeuuid_min_max.cql | 4 +-
doc/modules/cassandra/pages/cql/changes.adoc | 1 +
.../cassandra/pages/cql/cql_singlefile.adoc | 54 +--
doc/modules/cassandra/pages/cql/functions.adoc | 44 +--
doc/modules/cassandra/pages/cql/json.adoc | 12 +-
.../pages/getting_started/quickstart.adoc | 4 +-
pylib/cqlshlib/test/test_keyspace_init.cql | 16 +-
.../cassandra/cql3/functions/AggregateFcts.java | 61 +--
.../cql3/functions/BytesConversionFcts.java | 110 +++---
.../apache/cassandra/cql3/functions/CastFcts.java | 101 +++--
.../cassandra/cql3/functions/FromJsonFct.java | 45 ++-
.../cassandra/cql3/functions/NativeFunction.java | 16 +
.../cassandra/cql3/functions/NativeFunctions.java | 19 +
.../apache/cassandra/cql3/functions/TimeFcts.java | 293 +++++++++-----
.../apache/cassandra/cql3/functions/ToJsonFct.java | 36 +-
.../cassandra/cql3/selection/Selectable.java | 2 +-
.../schema/SystemDistributedKeyspace.java | 14 +-
.../cassandra/distributed/test/FrozenUDTTest.java | 18 +-
.../distributed/test/OversizedMutationTest.java | 6 +-
.../cassandra/batchlog/BatchlogManagerTest.java | 6 +-
.../apache/cassandra/cql3/ViewFiltering1Test.java | 6 +-
.../unit/org/apache/cassandra/cql3/ViewPKTest.java | 6 +-
.../org/apache/cassandra/cql3/ViewSchemaTest.java | 234 ++++++------
test/unit/org/apache/cassandra/cql3/ViewTest.java | 8 +-
.../cassandra/cql3/functions/CastFctsTest.java | 10 +-
.../cql3/functions/NativeFunctionsTest.java | 202 ++++++++++
.../cql3/selection/SelectionColumnMappingTest.java | 22 +-
.../cql3/validation/entities/JsonTest.java | 424 ++++++++++-----------
.../validation/entities/SecondaryIndexTest.java | 56 +--
.../cql3/validation/entities/TimestampTest.java | 4 +-
.../cql3/validation/entities/TimeuuidTest.java | 8 +-
.../cql3/validation/entities/TypeTest.java | 4 +-
.../cql3/validation/entities/UFAuthTest.java | 4 +-
.../cassandra/cql3/validation/entities/UFTest.java | 10 +-
.../validation/miscellaneous/OverflowTest.java | 10 +-
.../validation/operations/AggregationTest.java | 18 +-
.../operations/CompactStorageSplit1Test.java | 4 +-
.../operations/CompactStorageSplit2Test.java | 126 +++---
.../cql3/validation/operations/DeleteTest.java | 28 +-
.../cql3/validation/operations/InsertTest.java | 2 +-
.../validation/operations/SelectGroupByTest.java | 2 +-
.../validation/operations/SelectOrderByTest.java | 40 +-
.../operations/SelectSingleColumnRelationTest.java | 4 +-
.../cql3/validation/operations/SelectTest.java | 146 +++----
.../cassandra/io/sstable/CQLSSTableWriterTest.java | 2 +-
51 files changed, 1368 insertions(+), 943 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index ee0a83f8ce..7e6669d6cb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
5.0
+ * Use snake case for the names of CQL native functions (CASSANDRA-18037)
* Use jdk-dependent checkstyle version to check the source code (CASSANDRA-18262)
* Provide summary of failed SessionInfo's in StreamResultFuture (CASSANDRA-17199)
* CEP-20: Dynamic Data Masking (CASSANDRA-17940)
diff --git a/NEWS.txt b/NEWS.txt
index 3d7a25eea9..848a0fa5ef 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -175,6 +175,9 @@ Deprecation
`getColumnIndexCacheSizeInKiB` and `setColumnIndexCacheSizeInKiB` respectively
- deprecate the getter/setter methods `getBatchSizeWarnThreshold` and `setBatchSizeWarnThreshold` in favor of
`getBatchSizeWarnThresholdInKiB` and `setBatchSizeWarnThresholdInKiB` respectively
+ - All native CQL functions names that don't use the snake case names are deprecated in favour of equivalent names
+ using snake casing. Thus, `totimestamp` is deprecated in favour of `to_timestamp`, `intasblob` in favour
+ of `int_as_blob`, `castAsInt` in favour of `cast_as_int`, etc.
4.1
===
diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile
index f5bb83807c..c1ce85ffa4 100644
--- a/doc/cql3/CQL.textile
+++ b/doc/cql3/CQL.textile
@@ -2118,21 +2118,21 @@ SELECT * FROM myTable WHERE t = now()
will never return any result by design, since the value returned by @now()@ is guaranteed to be unique.
-@currentTimeUUID@ is an alias of @now@.
+@current_timeuuid@ is an alias of @now@.
-h4. @minTimeuuid@ and @maxTimeuuid@
+h4. @min_timeuuid@ and @max_timeuuid@
-The @minTimeuuid@ (resp. @maxTimeuuid@) function takes a @timestamp@ value @t@ (which can be "either a timestamp or a date string":#usingtimestamps ) and return a _fake_ @timeuuid@ corresponding to the _smallest_ (resp. _biggest_) possible @timeuuid@ having for timestamp @t@. So for instance:
+The @min_timeuuid@ (resp. @max_timeuuid@) function takes a @timestamp@ value @t@ (which can be "either a timestamp or a date string":#usingtimestamps ) and return a _fake_ @timeuuid@ corresponding to the _smallest_ (resp. _biggest_) possible @timeuuid@ having for timestamp @t@. So for instance:
-bc(sample).
-SELECT * FROM myTable WHERE t > maxTimeuuid('2013-01-01 00:05+0000') AND t < minTimeuuid('2013-02-02 10:00+0000')
+bc(sample).
+SELECT * FROM myTable WHERE t > max_timeuuid('2013-01-01 00:05+0000') AND t < min_timeuuid('2013-02-02 10:00+0000')
-will select all rows where the @timeuuid@ column @t@ is strictly older than '2013-01-01 00:05+0000' but strictly younger than '2013-02-02 10:00+0000'. Please note that @t >= maxTimeuuid('2013-01-01 00:05+0000')@ would still _not_ select a @timeuuid@ generated exactly at '2013-01-01 00:05+0000' and is essentially equivalent to @t > maxTimeuuid('2013-01-01 00:05+0000')@.
+will select all rows where the @timeuuid@ column @t@ is strictly older than '2013-01-01 00:05+0000' but strictly younger than '2013-02-02 10:00+0000'. Please note that @t >= max_timeuuid('2013-01-01 00:05+0000')@ would still _not_ select a @timeuuid@ generated exactly at '2013-01-01 00:05+0000' and is essentially equivalent to @t > maxTimeuuid('2013-01-01 00:05+0000')@.
-_Warning_: We called the values generated by @minTimeuuid@ and @maxTimeuuid@ _fake_ UUID because they do no respect the Time-Based UUID generation process specified by the "RFC 4122":http://www.ietf.org/rfc/rfc4122.txt. In particular, the value returned by these 2 methods will not be unique. This means you should only use those methods for querying (as in the example above). Inserting the result of those methods is almost certainly _a bad idea_.
+_Warning_: We called the values generated by @min_timeuuid@ and @max_timeuuid@ _fake_ UUID because they do no respect the Time-Based UUID generation process specified by the "RFC 4122":http://www.ietf.org/rfc/rfc4122.txt. In particular, the value returned by these 2 methods will not be unique. This means you should only use those methods for querying (as in the example above). Inserting the result of those methods is almost certainly _a bad idea_.
h3(#datetimeFun). Datetime functions
@@ -2142,28 +2142,28 @@ h4(#curentDateTime). Retrieving the current date/time
The following functions can be used to retrieve the date/time at the time where the function is invoked:
|_. function name |_. output type |
-| @currentTimestamp@ | @timestamp@ |
-| @currentDate@ | @date@ |
-| @currentTime@ | @time@ |
-| @currentTimeUUID@ | @timeUUID@ |
+| @current_timestamp@ | @timestamp@ |
+| @current_date@ | @date@ |
+| @current_time@ | @time@ |
+| @current_timeuuid@ | @timeUUID@ |
For example the last 2 days of data can be retrieved using:
-bc(sample).
-SELECT * FROM myTable WHERE date >= currentDate() - 2d
+bc(sample).
+SELECT * FROM myTable WHERE date >= current_date() - 2d
h4(#timeFun). Time conversion functions
A number of functions are provided to "convert" a @timeuuid@, a @timestamp@ or a @date@ into another @native@ type.
|_. function name |_. input type |_. description|
-|@toDate@ |@timeuuid@ |Converts the @timeuuid@ argument into a @date@ type|
-|@toDate@ |@timestamp@ |Converts the @timestamp@ argument into a @date@ type|
-|@toTimestamp@ |@timeuuid@ |Converts the @timeuuid@ argument into a @timestamp@ type|
-|@toTimestamp@ |@date@ |Converts the @date@ argument into a @timestamp@ type|
-|@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|
+|@to_date@ |@timeuuid@ |Converts the @timeuuid@ argument into a @date@ type|
+|@to_date@ |@timestamp@ |Converts the @timestamp@ argument into a @date@ type|
+|@to_timestamp@ |@timeuuid@ |Converts the @timeuuid@ argument into a @timestamp@ type|
+|@to_timestamp@ |@date@ |Converts the @date@ argument into a @timestamp@ type|
+|@to_unix_timestamp@ |@timeuuid@ |Converts the @timeuuid@ argument into a @bigInt@ raw value|
+|@to_unix_timestamp@ |@timestamp@ |Converts the @timestamp@ argument into a @bigInt@ raw value|
+|@to_unix_timestamp@ |@date@ |Converts the @date@ argument into a @bigInt@ raw value|
h4(#floorFun). Floor function
@@ -2177,7 +2177,7 @@ Rounds date and time to the nearest value.
h3(#blobFun). Blob conversion functions
-A number of functions are provided to "convert" the native types into binary data (@blob@). For every @<native-type>@ @type@ supported by CQL3 (a notable exceptions is @blob@, for obvious reasons), the function @typeAsBlob@ takes a argument of type @type@ and return it as a @blob@. Conversely, the function @blobAsType@ takes a 64-bit @blob@ argument and convert it to a @bigint@ value. And so for instance, @bigintAsBlob(3)@ is @0x0000000000000003@ and @blobAsBigint(0x0000000000000003)@ is @3@.
+A number of functions are provided to "convert" the native types into binary data (@blob@). For every @<native-type>@ @type@ supported by CQL3 (a notable exceptions is @blob@, for obvious reasons), the function @type_as_blob@ takes a argument of type @type@ and return it as a @blob@. Conversely, the function @blob_as_type@ takes a 64-bit @blob@ argument and convert it to a @bigint@ value. And so for instance, @bigint_as_blob(3)@ is @0x0000000000000003@ and @blob_as_bigint(0x00000000000 [...]
h2(#aggregates). Aggregates
@@ -2386,7 +2386,7 @@ h3(#jsonEncoding). JSON Encoding of Cassandra Data Types
Where possible, Cassandra will represent and accept data types in their native @JSON@ representation. Cassandra will also accept string representations matching the CQL literal format for all single-field types. For example, floats, ints, UUIDs, and dates can be represented by CQL literal strings. However, compound types, such as collections, tuples, and user-defined types must be represented by native @JSON@ collections (maps and lists) or a JSON-encoded string representation of the [...]
-The following table describes the encodings that Cassandra will accept in @INSERT JSON@ values (and @fromJson()@ arguments) as well as the format Cassandra will use when returning data for @SELECT JSON@ statements (and @fromJson()@):
+The following table describes the encodings that Cassandra will accept in @INSERT JSON@ values (and @from_json()@ arguments) as well as the format Cassandra will use when returning data for @SELECT JSON@ statements (and @from_json()@):
|_. type |_. formats accepted |_. return format |_. notes|
|@ascii@ |string |string |Uses JSON's @\u@ character escape|
@@ -2414,13 +2414,13 @@ The following table describes the encodings that Cassandra will accept in @INSER
|@varchar@ |string |string |Uses JSON's @\u@ character escape|
|@varint@ |integer, string |integer |Variable length; may overflow 32 or 64 bit integers in client-side decoder|
-h3(#fromJson). The fromJson() Function
+h3(#from_json). The from_json() Function
-The @fromJson()@ function may be used similarly to @INSERT JSON@, but for a single column value. It may only be used in the @VALUES@ clause of an @INSERT@ statement or as one of the column values in an @UPDATE@, @DELETE@, or @SELECT@ statement. For example, it cannot be used in the selection clause of a @SELECT@ statement.
+The @from_json()@ function may be used similarly to @INSERT JSON@, but for a single column value. It may only be used in the @VALUES@ clause of an @INSERT@ statement or as one of the column values in an @UPDATE@, @DELETE@, or @SELECT@ statement. For example, it cannot be used in the selection clause of a @SELECT@ statement.
-h3(#toJson). The toJson() Function
+h3(#to_json). The to_json() Function
-The @toJson()@ function may be used similarly to @SELECT JSON@, but for a single column value. It may only be used in the selection clause of a @SELECT@ statement.
+The @to_json()@ function may be used similarly to @SELECT JSON@, but for a single column value. It may only be used in the selection clause of a @SELECT@ statement.
h2(#appendixA). Appendix A: CQL Keywords
@@ -2587,7 +2587,8 @@ 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@.
+* Remove deprecated functions @dateOf@ and @unixTimestampOf@, replaced by @to_timestamp@ and @to_unixtimestamp@ (see "CASSANDRA-18328":https://issues.apache.org/jira/browse/CASSANDRA-18328).
+* Adopt snake_case function names, deprecating all previous camelCase or alltogetherwithoutspaces function names (see "CASSANDRA-18037":https://issues.apache.org/jira/browse/CASSANDRA-18037).
h3. 3.4.6
diff --git a/doc/modules/cassandra/examples/CQL/as.cql b/doc/modules/cassandra/examples/CQL/as.cql
index a8b9f03568..7270526494 100644
--- a/doc/modules/cassandra/examples/CQL/as.cql
+++ b/doc/modules/cassandra/examples/CQL/as.cql
@@ -1,12 +1,12 @@
// Without alias
-SELECT intAsBlob(4) FROM t;
+SELECT int_as_blob(4) FROM t;
-// intAsBlob(4)
-// --------------
+// int_as_blob(4)
+// ----------------
// 0x00000004
// With alias
-SELECT intAsBlob(4) AS four FROM t;
+SELECT int_as_blob(4) AS four FROM t;
// four
// ------------
diff --git a/doc/modules/cassandra/examples/CQL/current_date.cql b/doc/modules/cassandra/examples/CQL/current_date.cql
new file mode 100644
index 0000000000..d82fb8039e
--- /dev/null
+++ b/doc/modules/cassandra/examples/CQL/current_date.cql
@@ -0,0 +1 @@
+SELECT * FROM myTable WHERE date >= current_date() - 2d;
diff --git a/doc/modules/cassandra/examples/CQL/currentdate.cql b/doc/modules/cassandra/examples/CQL/currentdate.cql
deleted file mode 100644
index 0bed1b2b9e..0000000000
--- a/doc/modules/cassandra/examples/CQL/currentdate.cql
+++ /dev/null
@@ -1 +0,0 @@
-SELECT * FROM myTable WHERE date >= currentDate() - 2d;
diff --git a/doc/modules/cassandra/examples/CQL/timeuuid_min_max.cql b/doc/modules/cassandra/examples/CQL/timeuuid_min_max.cql
index 81353f53d8..5a1fc511b4 100644
--- a/doc/modules/cassandra/examples/CQL/timeuuid_min_max.cql
+++ b/doc/modules/cassandra/examples/CQL/timeuuid_min_max.cql
@@ -1,3 +1,3 @@
SELECT * FROM myTable
- WHERE t > maxTimeuuid('2013-01-01 00:05+0000')
- AND t < minTimeuuid('2013-02-02 10:00+0000');
+ WHERE t > max_timeuuid('2013-01-01 00:05+0000')
+ AND t < min_timeuuid('2013-02-02 10:00+0000');
diff --git a/doc/modules/cassandra/pages/cql/changes.adoc b/doc/modules/cassandra/pages/cql/changes.adoc
index 7902791075..452a182230 100644
--- a/doc/modules/cassandra/pages/cql/changes.adoc
+++ b/doc/modules/cassandra/pages/cql/changes.adoc
@@ -9,6 +9,7 @@ The following describes the changes in each version of CQL.
* Add UNMASK permission (`18069`)
* Add SELECT_MASKED permission (`18070`)
* Add support for using UDFs as masking functions (`18071`)
+* Adopt snake_case function names, deprecating all previous camelCase or alltogetherwithoutspaces function names (`18037`)
== 3.4.6
diff --git a/doc/modules/cassandra/pages/cql/cql_singlefile.adoc b/doc/modules/cassandra/pages/cql/cql_singlefile.adoc
index a8db0b8976..702ac3a2b0 100644
--- a/doc/modules/cassandra/pages/cql/cql_singlefile.adoc
+++ b/doc/modules/cassandra/pages/cql/cql_singlefile.adoc
@@ -3075,27 +3075,27 @@ SELECT * FROM myTable WHERE t = now()
will never return any result by design, since the value returned by
`now()` is guaranteed to be unique.
-===== `minTimeuuid` and `maxTimeuuid`
+===== `min_timeuuid` and `max_timeuuid`
-The `minTimeuuid` (resp. `maxTimeuuid`) function takes a `timestamp`
+The `min_timeuuid` (resp. `max_timeuuid`) function takes a `timestamp`
value `t` (which can be link:#usingtimestamps[either a timestamp or a
date string] ) and return a _fake_ `timeuuid` corresponding to the
_smallest_ (resp. _biggest_) possible `timeuuid` having for timestamp
`t`. So for instance:
bc(sample). +
-SELECT * FROM myTable WHERE t > maxTimeuuid(`2013-01-01 00:05+0000') AND
-t < minTimeuuid(`2013-02-02 10:00+0000')
+SELECT * FROM myTable WHERE t > max_timeuuid(`2013-01-01 00:05+0000') AND
+t < min_timeuuid(`2013-02-02 10:00+0000')
will select all rows where the `timeuuid` column `t` is strictly older
than `2013-01-01 00:05+0000' but strictly younger than `2013-02-02
10:00+0000'. Please note that
-`t >= maxTimeuuid('2013-01-01 00:05+0000')` would still _not_ select a
+`t >= max_timeuuid('2013-01-01 00:05+0000')` would still _not_ select a
`timeuuid` generated exactly at `2013-01-01 00:05+0000' and is
-essentially equivalent to `t > maxTimeuuid('2013-01-01 00:05+0000')`.
+essentially equivalent to `t > max_timeuuid('2013-01-01 00:05+0000')`.
-_Warning_: We called the values generated by `minTimeuuid` and
-`maxTimeuuid` _fake_ UUID because they do no respect the Time-Based UUID
+_Warning_: We called the values generated by `min_timeuuid` and
+`max_timeuuid` _fake_ UUID because they do no respect the Time-Based UUID
generation process specified by the
http://www.ietf.org/rfc/rfc4122.txt[RFC 4122]. In particular, the value
returned by these 2 methods will not be unique. This means you should
@@ -3111,25 +3111,25 @@ A number of functions are provided to ``convert'' a `timeuuid`, a
[cols=",,",options="header",]
|===
|function name |input type |description
-|`toDate` |`timeuuid` |Converts the `timeuuid` argument into a `date`
+|`to_date` |`timeuuid` |Converts the `timeuuid` argument into a `date`
type
-|`toDate` |`timestamp` |Converts the `timestamp` argument into a `date`
+|`to_date` |`timestamp` |Converts the `timestamp` argument into a `date`
type
-|`toTimestamp` |`timeuuid` |Converts the `timeuuid` argument into a
+|`to_timestamp` |`timeuuid` |Converts the `timeuuid` argument into a
`timestamp` type
-|`toTimestamp` |`date` |Converts the `date` argument into a `timestamp`
+|`to_timestamp` |`date` |Converts the `date` argument into a `timestamp`
type
-|`toUnixTimestamp` |`timeuuid` |Converts the `timeuuid` argument into a
+|`to_unix_timestamp` |`timeuuid` |Converts the `timeuuid` argument into a
`bigInt` raw value
-|`toUnixTimestamp` |`timestamp` |Converts the `timestamp` argument into
+|`to_unix_timestamp` |`timestamp` |Converts the `timestamp` argument into
a `bigInt` raw value
-|`toUnixTimestamp` |`date` |Converts the `date` argument into a `bigInt`
+|`to_unix_timestamp` |`date` |Converts the `date` argument into a `bigInt`
raw value
|===
@@ -3139,10 +3139,10 @@ raw value
A number of functions are provided to ``convert'' the native types into
binary data (`blob`). For every `<native-type>` `type` supported by CQL3
(a notable exceptions is `blob`, for obvious reasons), the function
-`typeAsBlob` takes a argument of type `type` and return it as a `blob`.
-Conversely, the function `blobAsType` takes a 64-bit `blob` argument and
-convert it to a `bigint` value. And so for instance, `bigintAsBlob(3)`
-is `0x0000000000000003` and `blobAsBigint(0x0000000000000003)` is `3`.
+`type_as_blob` takes a argument of type `type` and return it as a `blob`.
+Conversely, the function `blob_as_type` takes a 64-bit `blob` argument and
+convert it to a `bigint` value. And so for instance, `bigint_as_blob(3)`
+is `0x0000000000000003` and `blob_as_bigint(0x0000000000000003)` is `3`.
=== Aggregates
@@ -3435,9 +3435,9 @@ collections (maps and lists) or a JSON-encoded string representation of
the collection.
The following table describes the encodings that Cassandra will accept
-in `INSERT JSON` values (and `fromJson()` arguments) as well as the
+in `INSERT JSON` values (and `from_json()` arguments) as well as the
format Cassandra will use when returning data for `SELECT JSON`
-statements (and `fromJson()`):
+statements (and `from_json()`):
[cols=",,,",options="header",]
|===
@@ -3504,19 +3504,19 @@ format
64 bit integers in client-side decoder
|===
-[[fromJson]]
-==== The fromJson() Function
+[[from_json]]
+==== The from_json() Function
-The `fromJson()` function may be used similarly to `INSERT JSON`, but
+The `from_json()` function may be used similarly to `INSERT JSON`, but
for a single column value. It may only be used in the `VALUES` clause of
an `INSERT` statement or as one of the column values in an `UPDATE`,
`DELETE`, or `SELECT` statement. For example, it cannot be used in the
selection clause of a `SELECT` statement.
-[[toJson]]
-==== The toJson() Function
+[[to_json]]
+==== The to_json() Function
-The `toJson()` function may be used similarly to `SELECT JSON`, but for
+The `to_json()` function may be used similarly to `SELECT JSON`, but for
a single column value. It may only be used in the selection clause of a
`SELECT` statement.
diff --git a/doc/modules/cassandra/pages/cql/functions.adoc b/doc/modules/cassandra/pages/cql/functions.adoc
index d564f854a7..6474b72cb5 100644
--- a/doc/modules/cassandra/pages/cql/functions.adoc
+++ b/doc/modules/cassandra/pages/cql/functions.adoc
@@ -149,13 +149,13 @@ include::example$CQL/timeuuid_now.cql[]
will not return a result, by design, since the value returned by
`now()` is guaranteed to be unique.
-`currentTimeUUID` is an alias of `now`.
+`current_timeuuid` is an alias of `now`.
-====== `minTimeuuid` and `maxTimeuuid`
+====== `min_timeuuid` and `max_timeuuid`
-The `minTimeuuid` function takes a `timestamp` value `t`, either a timestamp or a date string.
-It returns a _fake_ `timeuuid` corresponding to the _smallest_ possible `timeuuid` for timestamp `t`.
-The `maxTimeuuid` works similarly, but returns the _largest_ possible `timeuuid`.
+The `min_timeuuid` function takes a `timestamp` value `t`, either a timestamp or a date string.
+It returns a _fake_ `timeuuid` corresponding to the _smallest_ possible `timeuuid` for timestamp `t`.
+The `max_timeuuid` works similarly, but returns the _largest_ possible `timeuuid`.
For example:
@@ -170,8 +170,8 @@ The clause `t >= maxTimeuuid('2013-01-01 00:05+0000')` would still _not_ select
[NOTE]
.Note
====
-The values generated by `minTimeuuid` and `maxTimeuuid` are called _fake_ UUID because they do no respect the time-based UUID generation process
-specified by the http://www.ietf.org/rfc/rfc4122.txt[IETF RFC 4122].
+The values generated by `min_timeuuid` and `max_timeuuid` are called _fake_ UUID because they do no respect the time-based UUID generation process
+specified by the http://www.ietf.org/rfc/rfc4122.txt[IETF RFC 4122].
In particular, the value returned by these two methods will not be unique.
Thus, only use these methods for *querying*, not for *insertion*, to prevent possible data overwriting.
====
@@ -187,20 +187,20 @@ time where the function is invoked:
|===
|Function name |Output type
-| `currentTimestamp` | `timestamp`
+| `current_timestamp` | `timestamp`
-| `currentDate` | `date`
+| `current_date` | `date`
-| `currentTime` | `time`
+| `current_time` | `time`
-| `currentTimeUUID` | `timeUUID`
+| `current_timeuuid` | `timeUUID`
|===
For example the last two days of data can be retrieved using:
[source,cql]
----
-include::example$CQL/currentdate.cql[]
+include::example$CQL/current_date.cql[]
----
====== Time conversion functions
@@ -211,28 +211,28 @@ A number of functions are provided to convert a `timeuuid`, a `timestamp` or a `
|===
|Function name |Input type |Description
-| `toDate` | `timeuuid` | Converts the `timeuuid` argument into a `date` type
+| `to_date` | `timeuuid` | Converts the `timeuuid` argument into a `date` type
-| `toDate` | `timestamp` | Converts the `timestamp` argument into a `date` type
+| `to_date` | `timestamp` | Converts the `timestamp` argument into a `date` type
-| `toTimestamp` | `timeuuid` | Converts the `timeuuid` argument into a `timestamp` type
+| `to_timestamp` | `timeuuid` | Converts the `timeuuid` argument into a `timestamp` type
-| `toTimestamp` | `date` | Converts the `date` argument into a `timestamp` type
+| `to_timestamp` | `date` | Converts the `date` argument into a `timestamp` type
-| `toUnixTimestamp` | `timeuuid` | Converts the `timeuuid` argument into a `bigInt` raw value
+| `to_unix_timestamp` | `timeuuid` | Converts the `timeuuid` argument into a `bigInt` raw value
-| `toUnixTimestamp` | `timestamp` | Converts the `timestamp` argument into a `bigInt` raw value
+| `to_unix_timestamp` | `timestamp` | Converts the `timestamp` argument into a `bigInt` raw value
-| `toUnixTimestamp` | `date` | Converts the `date` argument into a `bigInt` raw value
+| `to_unix_timestamp` | `date` | Converts the `date` argument into a `bigInt` raw value
|===
===== Blob conversion functions
A number of functions are provided to convert the native types into
binary data, or a `blob`.
-For every xref:cql/types.adoc#native-types[type] supported by CQL, the function `typeAsBlob` takes a argument of type `type` and returns it as a `blob`.
-Conversely, the function `blobAsType` takes a 64-bit `blob` argument and converts it to a `bigint` value.
-For example, `bigintAsBlob(3)` returns `0x0000000000000003` and `blobAsBigint(0x0000000000000003)` returns `3`.
+For every xref:cql/types.adoc#native-types[type] supported by CQL, the function `type_as_blob` takes a argument of type `type` and returns it as a `blob`.
+Conversely, the function `blob_as_type` takes a 64-bit `blob` argument and converts it to a `bigint` value.
+For example, `bigint_as_blob(3)` returns `0x0000000000000003` and `blob_as_bigint(0x0000000000000003)` returns `3`.
===== Math Functions
diff --git a/doc/modules/cassandra/pages/cql/json.adoc b/doc/modules/cassandra/pages/cql/json.adoc
index 7d0aa268b0..d3462e81e3 100644
--- a/doc/modules/cassandra/pages/cql/json.adoc
+++ b/doc/modules/cassandra/pages/cql/json.adoc
@@ -51,9 +51,9 @@ collections (maps and lists) or a JSON-encoded string representation of
the collection.
The following table describes the encodings that Cassandra will accept
-in `INSERT JSON` values (and `fromJson()` arguments) as well as the
+in `INSERT JSON` values (and `from_json()` arguments) as well as the
format Cassandra will use when returning data for `SELECT JSON`
-statements (and `fromJson()`):
+statements (and `from_json()`):
[cols=",,,",options="header",]
|===
@@ -110,16 +110,16 @@ are returned.
| `varint` | integer, string | integer | Variable length; may overflow 32 or 64 bit integers in client-side decoder
|===
-== The fromJson() Function
+== The from_json() Function
-The `fromJson()` function may be used similarly to `INSERT JSON`, but
+The `from_json()` function may be used similarly to `INSERT JSON`, but
for a single column value. It may only be used in the `VALUES` clause of
an `INSERT` statement or as one of the column values in an `UPDATE`,
`DELETE`, or `SELECT` statement. For example, it cannot be used in the
selection clause of a `SELECT` statement.
-== The toJson() Function
+== The to_json() Function
-The `toJson()` function may be used similarly to `SELECT JSON`, but for
+The `to_json()` function may be used similarly to `SELECT JSON`, but for
a single column value. It may only be used in the selection clause of a
`SELECT` statement.
diff --git a/doc/modules/cassandra/pages/getting_started/quickstart.adoc b/doc/modules/cassandra/pages/getting_started/quickstart.adoc
index 69b55a6b53..963d269190 100644
--- a/doc/modules/cassandra/pages/getting_started/quickstart.adoc
+++ b/doc/modules/cassandra/pages/getting_started/quickstart.adoc
@@ -55,10 +55,10 @@ CREATE TABLE IF NOT EXISTS store.shopping_cart (
# Insert some data
INSERT INTO store.shopping_cart
(userid, item_count, last_update_timestamp)
-VALUES ('9876', 2, toTimeStamp(toDate(now))));
+VALUES ('9876', 2, to_timestamp(to_date(now))));
INSERT INTO store.shopping_cart
(userid, item_count, last_update_timestamp)
-VALUES (1234, 5, toTimeStamp(toDate(now))));
+VALUES (1234, 5, to_timestamp(toDate(now))));
----
You should now have a _cqlshrc_ file and _<currentdir>/scripts/data.cql_ file.
diff --git a/pylib/cqlshlib/test/test_keyspace_init.cql b/pylib/cqlshlib/test/test_keyspace_init.cql
index c795ecdb55..5ff4108131 100644
--- a/pylib/cqlshlib/test/test_keyspace_init.cql
+++ b/pylib/cqlshlib/test/test_keyspace_init.cql
@@ -69,9 +69,9 @@ VALUES (3, -2147483648, '''''''', -9223372036854775808, 0x80, false,
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, floatcol, smallintcol, textcol,
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol)
-VALUES (4, blobAsInt(0x), '', blobAsBigint(0x), 0x, blobAsBoolean(0x),
- blobAsDecimal(0x), blobAsDouble(0x), blobAsFloat(0x), blobAsSmallInt(0x0000), '',
- blobAsTimestamp(0x), blobAsTinyInt(0x00), blobAsUuid(0x), '', blobAsVarint(0x));
+VALUES (4, blob_as_int(0x), '', blob_as_bigint(0x), 0x, blob_as_boolean(0x),
+ blob_as_decimal(0x), blob_as_double(0x), blob_as_float(0x), blob_as_smallInt(0x0000), '',
+ blob_as_timestamp(0x), blob_as_tinyint(0x00), blob_as_uuid(0x), '', blob_as_varint(0x));
@@ -141,13 +141,13 @@ CREATE TABLE ascii_with_special_chars (
);
-- "newline:\n"
-INSERT INTO ascii_with_special_chars (k, val) VALUES (0, blobAsAscii(0x6e65776c696e653a0a));
+INSERT INTO ascii_with_special_chars (k, val) VALUES (0, blob_as_ascii(0x6e65776c696e653a0a));
-- "return\rand null\0!"
-INSERT INTO ascii_with_special_chars (k, val) VALUES (1, blobAsAscii(0x72657475726e0d616e64206e756c6c0021));
+INSERT INTO ascii_with_special_chars (k, val) VALUES (1, blob_as_ascii(0x72657475726e0d616e64206e756c6c0021));
-- "\x00\x01\x02\x03\x04\x05control chars\x06\x07"
-INSERT INTO ascii_with_special_chars (k, val) VALUES (2, blobAsAscii(0x000102030405636f6e74726f6c2063686172730607));
+INSERT INTO ascii_with_special_chars (k, val) VALUES (2, blob_as_ascii(0x000102030405636f6e74726f6c2063686172730607));
-- "fake special chars\\x00\\n"
-INSERT INTO ascii_with_special_chars (k, val) VALUES (3, blobAsAscii(0x66616b65207370656369616c2063686172735c7830305c6e));
+INSERT INTO ascii_with_special_chars (k, val) VALUES (3, blob_as_ascii(0x66616b65207370656369616c2063686172735c7830305c6e));
@@ -326,4 +326,4 @@ CREATE TABLE escape_quotes (
udt_data frozen<quote_udt>
);
-INSERT INTO escape_quotes (id, text_data, map_data, set_data, list_data, tuple_data, udt_data) values(1, 'I''m newb', {1:'I''m newb'}, {'I''m newb'}, ['I''m newb'], (1, 'I''m newb'), {data: 'I''m newb'});
\ No newline at end of file
+INSERT INTO escape_quotes (id, text_data, map_data, set_data, list_data, tuple_data, udt_data) values(1, 'I''m newb', {1:'I''m newb'}, {'I''m newb'}, ['I''m newb'], (1, 'I''m newb'), {data: 'I''m newb'});
diff --git a/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
index b3432996e6..ce8e8e12d4 100644
--- a/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/AggregateFcts.java
@@ -88,38 +88,51 @@ public abstract class AggregateFcts
* The function used to count the number of rows of a result set. This function is called when COUNT(*) or COUNT(1)
* is specified.
*/
- public static final NativeAggregateFunction countRowsFunction =
- new NativeAggregateFunction("countRows", LongType.instance)
- {
- public Aggregate newAggregate()
- {
- return new Aggregate()
- {
- private long count;
+ public static final CountRowsFunction countRowsFunction = new CountRowsFunction(false);
- public void reset()
- {
- count = 0;
- }
+ public static class CountRowsFunction extends NativeAggregateFunction
+ {
+ private CountRowsFunction(boolean useLegacyName)
+ {
+ super(useLegacyName ? "countRows" : "count_rows", LongType.instance);
+ }
- public ByteBuffer compute(ProtocolVersion protocolVersion)
- {
- return LongType.instance.decompose(count);
- }
+ @Override
+ public Aggregate newAggregate()
+ {
+ return new Aggregate()
+ {
+ private long count;
- public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
- {
- count++;
- }
- };
+ public void reset()
+ {
+ count = 0;
}
- @Override
- public String columnName(List<String> columnNames)
+ public ByteBuffer compute(ProtocolVersion protocolVersion)
+ {
+ return LongType.instance.decompose(count);
+ }
+
+ public void addInput(ProtocolVersion protocolVersion, List<ByteBuffer> values)
{
- return "count";
+ count++;
}
};
+ }
+
+ @Override
+ public String columnName(List<String> columnNames)
+ {
+ return "count";
+ }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new CountRowsFunction(true);
+ }
+ }
/**
* The SUM function for decimal values.
diff --git a/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java b/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
index 993025590f..8a8eb9c0c4 100644
--- a/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/BytesConversionFcts.java
@@ -18,92 +18,104 @@
package org.apache.cassandra.cql3.functions;
import java.nio.ByteBuffer;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.apache.cassandra.cql3.CQL3Type;
-import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.BytesType;
-import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.cassandra.transport.ProtocolVersion;
-import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.serializers.MarshalException;
+import org.apache.cassandra.transport.ProtocolVersion;
+import org.apache.cassandra.utils.ByteBufferUtil;
public abstract class BytesConversionFcts
{
public static void addFunctionsTo(NativeFunctions functions)
{
- // because text and varchar ends up being synonymous, our automatic makeToBlobFunction doesn't work
- // for varchar, so we special case it below. We also skip blob for obvious reasons.
- Set<AbstractType<?>> types = new HashSet<>();
for (CQL3Type type : CQL3Type.Native.values())
{
if (type == CQL3Type.Native.BLOB)
continue;
- AbstractType<?> udfType = type.getType().udfType();
- if (!types.add(udfType))
- continue;
- functions.add(makeToBlobFunction(type.getType().udfType()));
- functions.add(makeFromBlobFunction(type.getType().udfType()));
+ functions.add(new ToBlobFunction(type));
+ functions.add(new FromBlobFunction(type));
}
-
- functions.add(VarcharAsBlobFct);
- functions.add(BlobAsVarcharFct);
}
- // Most of the XAsBlob and blobAsX functions are basically no-op since everything is
+ // Most of the X_as_blob and blob_as_X functions are basically no-op since everything is
// bytes internally. They only "trick" the type system.
- public static NativeFunction makeToBlobFunction(AbstractType<?> fromType)
+ public static class ToBlobFunction extends NativeScalarFunction
{
- String name = fromType.asCQL3Type() + "asblob";
- return new NativeScalarFunction(name, BytesType.instance, fromType)
+ private final CQL3Type fromType;
+
+ public ToBlobFunction(CQL3Type fromType)
{
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- return parameters.get(0);
- }
- };
+ this(fromType, false);
+ }
+
+ private ToBlobFunction(CQL3Type fromType, boolean useLegacyName)
+ {
+ super(fromType + (useLegacyName ? "asblob" : "_as_blob"),
+ BytesType.instance,
+ fromType.getType().udfType());
+ this.fromType = fromType;
+ }
+
+ @Override
+ public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ {
+ return parameters.get(0);
+ }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new ToBlobFunction(fromType, true);
+ }
}
- public static NativeFunction makeFromBlobFunction(final AbstractType<?> toType)
+ public static class FromBlobFunction extends NativeScalarFunction
{
- final String name = "blobas" + toType.asCQL3Type();
- return new NativeScalarFunction(name, toType, BytesType.instance)
+ private final CQL3Type toType;
+
+ public FromBlobFunction(CQL3Type toType)
+ {
+ this(toType, false);
+ }
+
+ private FromBlobFunction(CQL3Type toType, boolean useLegacyName)
{
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException
+ super((useLegacyName ? "blobas" : "blob_as_") + toType,
+ toType.getType().udfType(),
+ BytesType.instance);
+ this.toType = toType;
+ }
+
+ @Override
+ public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ {
+ ByteBuffer val = parameters.get(0);
+
+ if (val != null)
{
- ByteBuffer val = parameters.get(0);
try
{
- if (val != null)
- toType.validate(val);
- return val;
+ toType.getType().validate(val);
}
catch (MarshalException e)
{
- throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
- name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
+ throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a " +
+ "valid binary representation for type %s",
+ name, ByteBufferUtil.bytesToHex(val), toType));
}
}
- };
- }
- public static final NativeFunction VarcharAsBlobFct = new NativeScalarFunction("varcharasblob", BytesType.instance, UTF8Type.instance)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- return parameters.get(0);
+ return val;
}
- };
- public static final NativeFunction BlobAsVarcharFct = new NativeScalarFunction("blobasvarchar", UTF8Type.instance, BytesType.instance)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ @Override
+ public NativeFunction withLegacyName()
{
- return parameters.get(0);
+ return new FromBlobFunction(toType, true);
}
- };
+ }
}
diff --git a/src/java/org/apache/cassandra/cql3/functions/CastFcts.java b/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
index 4ee89b1443..1761778f51 100644
--- a/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/CastFcts.java
@@ -46,7 +46,7 @@ import org.apache.cassandra.transport.ProtocolVersion;
import static org.apache.cassandra.cql3.functions.TimeFcts.*;
-import org.apache.commons.lang3.text.WordUtils;
+import org.apache.commons.lang3.StringUtils;
/**
* Casting functions
@@ -54,7 +54,11 @@ import org.apache.commons.lang3.text.WordUtils;
*/
public final class CastFcts
{
- private static final String FUNCTION_NAME_PREFIX = "castAs";
+ private static final String FUNCTION_NAME_PREFIX = "cast_as_";
+
+ // Until 5.0 we have used camel cased names for cast functions. That changed with CASSANDRA-18037, where we decided
+ // to adopt snake case for all native function names. However, we should still support the old came case names.
+ private static final String LEGACY_FUNCTION_NAME_PREFIX = "castAs";
public static void addFunctionsTo(NativeFunctions functions)
{
@@ -126,25 +130,38 @@ public final class CastFcts
}
/**
- * Creates the name of the cast function use to cast to the specified type.
+ * Creates the snake-cased name of the cast function used to cast to the specified type.
*
* @param outputType the output type
- * @return the name of the cast function use to cast to the specified type
+ * @return the name of the cast function used to cast to the specified type
*/
- public static String getFunctionName(AbstractType<?> outputType)
+ public static String getFunctionName(CQL3Type outputType)
{
- return getFunctionName(outputType.asCQL3Type());
+ return FUNCTION_NAME_PREFIX + toLowerCaseString(outputType);
}
/**
- * Creates the name of the cast function use to cast to the specified type.
+ * Creates the legacy camel-cased name of the cast function used to cast to the specified type.
*
* @param outputType the output type
- * @return the name of the cast function use to cast to the specified type
+ * @return the legacy camel-cased name of the cast function used to cast to the specified type
*/
- public static String getFunctionName(CQL3Type outputType)
+ private static String getLegacyFunctionName(CQL3Type outputType)
+ {
+ return LEGACY_FUNCTION_NAME_PREFIX + StringUtils.capitalize(toLowerCaseString(outputType));
+ }
+
+ /**
+ * Creates the name of the cast function used to cast to the specified type.
+ *
+ * @param outputType the output type
+ * @param legacy whether to use the old cameCase names, instead of the new snake_case names
+ * @return the name of the cast function used to cast to the specified type
+ */
+ private static String getFunctionName(AbstractType<?> outputType, boolean legacy)
{
- return FUNCTION_NAME_PREFIX + WordUtils.capitalize(toLowerCaseString(outputType));
+ CQL3Type type = outputType.asCQL3Type();
+ return legacy ? getLegacyFunctionName(type) : getFunctionName(type);
}
/**
@@ -165,9 +182,9 @@ public final class CastFcts
}
@SuppressWarnings("unchecked")
- private static <O, I> NativeFunction wrapJavaFunction(AbstractType<I> inputType,
- AbstractType<O> outputType,
- java.util.function.Function<I, O> converter)
+ private static <O, I> CastFunction<?, O> wrapJavaFunction(AbstractType<I> inputType,
+ AbstractType<O> outputType,
+ java.util.function.Function<I, O> converter)
{
return inputType.equals(CounterColumnType.instance)
? JavaCounterFunctionWrapper.create(outputType, (java.util.function.Function<Long, O>) converter)
@@ -187,9 +204,9 @@ public final class CastFcts
*/
private static abstract class CastFunction<I, O> extends NativeScalarFunction
{
- public CastFunction(AbstractType<I> inputType, AbstractType<O> outputType)
+ public CastFunction(AbstractType<I> inputType, AbstractType<O> outputType, boolean useLegacyName)
{
- super(getFunctionName(outputType), outputType, inputType);
+ super(getFunctionName(outputType, useLegacyName), outputType, inputType);
}
@Override
@@ -222,23 +239,30 @@ public final class CastFcts
/**
* The java function used to convert the input type into the output one.
*/
- private final java.util.function.Function<I, O> converter;
+ protected final java.util.function.Function<I, O> converter;
public static <I, O> JavaFunctionWrapper<I, O> create(AbstractType<I> inputType,
AbstractType<O> outputType,
java.util.function.Function<I, O> converter)
{
- return new JavaFunctionWrapper<I, O>(inputType, outputType, converter);
+ return new JavaFunctionWrapper<>(inputType, outputType, converter, false);
}
protected JavaFunctionWrapper(AbstractType<I> inputType,
AbstractType<O> outputType,
- java.util.function.Function<I, O> converter)
+ java.util.function.Function<I, O> converter,
+ boolean useLegacyName)
{
- super(inputType, outputType);
+ super(inputType, outputType, useLegacyName);
this.converter = converter;
}
+ @Override
+ public JavaFunctionWrapper<I, O> withLegacyName()
+ {
+ return new JavaFunctionWrapper<>(inputType(), outputType(), converter, true);
+ }
+
public final ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
{
ByteBuffer bb = parameters.get(0);
@@ -267,13 +291,20 @@ public final class CastFcts
public static <O> JavaFunctionWrapper<Long, O> create(AbstractType<O> outputType,
java.util.function.Function<Long, O> converter)
{
- return new JavaCounterFunctionWrapper<O>(outputType, converter);
+ return new JavaCounterFunctionWrapper<>(outputType, converter, false);
}
protected JavaCounterFunctionWrapper(AbstractType<O> outputType,
- java.util.function.Function<Long, O> converter)
+ java.util.function.Function<Long, O> converter,
+ boolean useLegacyName)
{
- super(CounterColumnType.instance, outputType, converter);
+ super(CounterColumnType.instance, outputType, converter, useLegacyName);
+ }
+
+ @Override
+ public JavaCounterFunctionWrapper<O> withLegacyName()
+ {
+ return new JavaCounterFunctionWrapper<>(outputType(), converter, true);
}
protected Long compose(ByteBuffer bb)
@@ -299,19 +330,26 @@ public final class CastFcts
AbstractType<O> outputType,
NativeScalarFunction delegate)
{
- return new CassandraFunctionWrapper<I, O>(inputType, outputType, delegate);
+ return new CassandraFunctionWrapper<>(inputType, outputType, delegate, false);
}
private CassandraFunctionWrapper(AbstractType<I> inputType,
AbstractType<O> outputType,
- NativeScalarFunction delegate)
+ NativeScalarFunction delegate,
+ boolean useLegacyName)
{
- super(inputType, outputType);
+ super(inputType, outputType, useLegacyName);
assert delegate.argTypes().size() == 1 && inputType.equals(delegate.argTypes().get(0));
assert outputType.equals(delegate.returnType());
this.delegate = delegate;
}
+ @Override
+ public CassandraFunctionWrapper<I, O> withLegacyName()
+ {
+ return new CassandraFunctionWrapper<>(inputType(), outputType(), delegate, true);
+ }
+
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
{
return delegate.execute(protocolVersion, parameters);
@@ -329,13 +367,18 @@ public final class CastFcts
public static <I> CastAsTextFunction<I> create(AbstractType<I> inputType,
AbstractType<String> outputType)
{
- return new CastAsTextFunction<I>(inputType, outputType);
+ return new CastAsTextFunction<>(inputType, outputType, false);
}
- private CastAsTextFunction(AbstractType<I> inputType,
- AbstractType<String> outputType)
+ private CastAsTextFunction(AbstractType<I> inputType, AbstractType<String> outputType, boolean useLegacyName)
+ {
+ super(inputType, outputType, useLegacyName);
+ }
+
+ @Override
+ public CastAsTextFunction<I> withLegacyName()
{
- super(inputType, outputType);
+ return new CastAsTextFunction<>(inputType(), outputType(), true);
}
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
diff --git a/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java b/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
index f6b416d678..95e38b130c 100644
--- a/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
+++ b/src/java/org/apache/cassandra/cql3/functions/FromJsonFct.java
@@ -32,31 +32,31 @@ import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.serializers.MarshalException;
import org.apache.cassandra.transport.ProtocolVersion;
+import static java.lang.String.format;
+
public class FromJsonFct extends NativeScalarFunction
{
- public static final FunctionName NAME = FunctionName.nativeFunction("fromjson");
-
private static final Map<AbstractType<?>, FromJsonFct> instances = new ConcurrentHashMap<>();
- public static FromJsonFct getInstance(AbstractType<?> returnType)
+ public static FromJsonFct getInstance(FunctionName name, AbstractType<?> returnType)
{
FromJsonFct func = instances.get(returnType);
if (func == null)
{
- func = new FromJsonFct(returnType);
+ func = new FromJsonFct(name, returnType);
instances.put(returnType, func);
}
return func;
}
- private FromJsonFct(AbstractType<?> returnType)
+ private FromJsonFct(FunctionName name, AbstractType<?> returnType)
{
- super("fromjson", returnType, UTF8Type.instance);
+ super(name.name, returnType, UTF8Type.instance);
}
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
{
- assert parameters.size() == 1 : "Unexpectedly got " + parameters.size() + " arguments for fromJson()";
+ assert parameters.size() == 1 : format("Unexpectedly got %d arguments for %s()", parameters.size(), name.name);
ByteBuffer argument = parameters.get(0);
if (argument == null)
return null;
@@ -71,8 +71,9 @@ public class FromJsonFct extends NativeScalarFunction
}
catch (IOException exc)
{
- throw FunctionExecutionException.create(NAME, Collections.singletonList("text"),
- String.format("Could not decode JSON string '%s': %s", jsonArg, exc));
+ throw FunctionExecutionException.create(name(),
+ Collections.singletonList("text"),
+ format("Could not decode JSON string '%s': %s", jsonArg, exc));
}
catch (MarshalException exc)
{
@@ -82,16 +83,24 @@ public class FromJsonFct extends NativeScalarFunction
public static void addFunctionsTo(NativeFunctions functions)
{
- functions.add(new FunctionFactory(NAME.name, FunctionParameter.fixed(CQL3Type.Native.TEXT))
+ functions.add(new Factory("from_json"));
+ functions.add(new Factory("fromjson"));
+ }
+
+ private static class Factory extends FunctionFactory
+ {
+ private Factory(String name)
{
- @Override
- protected NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType)
- {
- if (receiverType == null)
- throw new InvalidRequestException("fromJson() cannot be used in the selection clause of a SELECT statement");
+ super(name, FunctionParameter.fixed(CQL3Type.Native.TEXT));
+ }
+
+ @Override
+ protected NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType)
+ {
+ if (receiverType == null)
+ throw new InvalidRequestException(format("%s() cannot be used in the selection clause of a SELECT statement", name.name));
- return FromJsonFct.getInstance(receiverType);
- }
- });
+ return FromJsonFct.getInstance(name, receiverType);
+ }
}
}
diff --git a/src/java/org/apache/cassandra/cql3/functions/NativeFunction.java b/src/java/org/apache/cassandra/cql3/functions/NativeFunction.java
index c13d5e8013..285cf639a0 100644
--- a/src/java/org/apache/cassandra/cql3/functions/NativeFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/NativeFunction.java
@@ -19,6 +19,8 @@ package org.apache.cassandra.cql3.functions;
import java.util.Arrays;
+import javax.annotation.Nullable;
+
import org.apache.cassandra.db.marshal.AbstractType;
/**
@@ -43,4 +45,18 @@ public abstract class NativeFunction extends AbstractFunction
// Most of our functions are pure, the other ones should override this
return true;
}
+
+ /**
+ * Returns a copy of this function using its old pre-5.0 name before the adoption of snake-cased function names.
+ * Those naming conventions were adopted in 5.0, but we still need to support the old names for
+ * compatibility. See CASSANDRA-18037 for further details.
+ *
+ * @return a copy of this function using its old pre-5.0 deprecated name, or {@code null} if the pre-5.0 function
+ * name already satisfied the naming conventions.
+ */
+ @Nullable
+ public NativeFunction withLegacyName()
+ {
+ return null;
+ }
}
diff --git a/src/java/org/apache/cassandra/cql3/functions/NativeFunctions.java b/src/java/org/apache/cassandra/cql3/functions/NativeFunctions.java
index e1ddf68197..02939e9896 100644
--- a/src/java/org/apache/cassandra/cql3/functions/NativeFunctions.java
+++ b/src/java/org/apache/cassandra/cql3/functions/NativeFunctions.java
@@ -58,6 +58,9 @@ public class NativeFunctions
public void add(NativeFunction function)
{
functions.put(function.name(), function);
+ NativeFunction legacyFunction = function.withLegacyName();
+ if (legacyFunction != null)
+ functions.put(legacyFunction.name(), legacyFunction);
}
public void addAll(NativeFunction... functions)
@@ -82,6 +85,14 @@ public class NativeFunctions
return functions.get(name);
}
+ /**
+ * @return all the registered pre-built functions.
+ */
+ public Collection<NativeFunction> getFunctions()
+ {
+ return functions.values();
+ }
+
/**
* Returns all the registered functions factories with the specified name.
*
@@ -93,6 +104,14 @@ public class NativeFunctions
return factories.get(name);
}
+ /**
+ * @return all the registered functions factories.
+ */
+ public Collection<FunctionFactory> getFactories()
+ {
+ return factories.values();
+ }
+
/**
* Returns whether there is a function factory with the specified name.
*
diff --git a/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java b/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java
index 791ed44107..e1557e6ce5 100644
--- a/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java
+++ b/src/java/org/apache/cassandra/cql3/functions/TimeFcts.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.cql3.functions;
import java.nio.ByteBuffer;
import java.util.List;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,11 +39,11 @@ public abstract class TimeFcts
public static void addFunctionsTo(NativeFunctions functions)
{
- functions.addAll(now("now", TimeUUIDType.instance),
- now("currenttimeuuid", TimeUUIDType.instance),
- now("currenttimestamp", TimestampType.instance),
- now("currentdate", SimpleDateType.instance),
- now("currenttime", TimeType.instance),
+ functions.addAll(new NowFunction("now", TimeUUIDType.instance),
+ new NowFunction("current_timeuuid", TimeUUIDType.instance),
+ new NowFunction("current_timestamp", TimestampType.instance),
+ new NowFunction("current_date", SimpleDateType.instance),
+ new NowFunction("current_time", TimeType.instance),
minTimeuuidFct,
maxTimeuuidFct,
toDate(TimeUUIDType.instance),
@@ -61,26 +62,46 @@ public abstract class TimeFcts
floorTime);
}
- public static final NativeFunction now(final String name, final TemporalType<?> type)
+ private static class NowFunction extends NativeScalarFunction
{
- return new NativeScalarFunction(name, type)
+ private final TemporalType<?> type;
+
+ public NowFunction(String name, TemporalType<?> type)
{
- @Override
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- return type.now();
- }
-
- @Override
- public boolean isPure()
- {
- return false; // as it returns non-identical results for identical arguments
- }
- };
- };
-
- public static final NativeFunction minTimeuuidFct = new NativeScalarFunction("mintimeuuid", TimeUUIDType.instance, TimestampType.instance)
+ super(name, type);
+ this.type = type;
+ }
+
+ @Override
+ public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ {
+ return type.now();
+ }
+
+ @Override
+ public boolean isPure()
+ {
+ return false; // as it returns non-identical results for identical arguments
+ }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ String name = name().name;
+ return name.contains("current") ? new NowFunction(StringUtils.remove(name, '_'), type) : null;
+ }
+ }
+
+ public static final NativeFunction minTimeuuidFct = new MinTimeuuidFunction(false);
+
+ private static final class MinTimeuuidFunction extends NativeScalarFunction
{
+ public MinTimeuuidFunction(boolean legacy)
+ {
+ super(legacy ? "mintimeuuid" : "min_timeuuid", TimeUUIDType.instance, TimestampType.instance);
+ }
+
+ @Override
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
{
ByteBuffer bb = parameters.get(0);
@@ -89,10 +110,24 @@ public abstract class TimeFcts
return TimeUUID.minAtUnixMillis(TimestampType.instance.compose(bb).getTime()).toBytes();
}
- };
- public static final NativeFunction maxTimeuuidFct = new NativeScalarFunction("maxtimeuuid", TimeUUIDType.instance, TimestampType.instance)
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new MinTimeuuidFunction(true);
+ }
+ }
+
+ public static final NativeFunction maxTimeuuidFct = new MaxTimeuuidFunction(false);
+
+ private static final class MaxTimeuuidFunction extends NativeScalarFunction
{
+ public MaxTimeuuidFunction(boolean legacy)
+ {
+ super(legacy ? "maxtimeuuid" : "max_timeuuid", TimeUUIDType.instance, TimestampType.instance);
+ }
+
+ @Override
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
{
ByteBuffer bb = parameters.get(0);
@@ -101,86 +136,146 @@ public abstract class TimeFcts
return TimeUUID.maxAtUnixMillis(TimestampType.instance.compose(bb).getTime()).toBytes();
}
- };
-
- /**
- * Creates a function that convert a value of the specified type into a <code>DATE</code>.
- * @param type the temporal type
- * @return a function that convert a value of the specified type into a <code>DATE</code>.
- */
- public static final NativeScalarFunction toDate(final TemporalType<?> type)
- {
- return new NativeScalarFunction("todate", SimpleDateType.instance, type)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null || !bb.hasRemaining())
- return null;
-
- long millis = type.toTimeInMillis(bb);
- return SimpleDateType.instance.fromTimeInMillis(millis);
- }
-
- @Override
- public boolean isMonotonic()
- {
- return true;
- }
- };
- }
-
- /**
- * Creates a function that convert a value of the specified type into a <code>TIMESTAMP</code>.
- * @param type the temporal type
- * @return a function that convert a value of the specified type into a <code>TIMESTAMP</code>.
- */
- public static final NativeScalarFunction toTimestamp(final TemporalType<?> type)
- {
- return new NativeScalarFunction("totimestamp", TimestampType.instance, type)
- {
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null || !bb.hasRemaining())
- return null;
-
- long millis = type.toTimeInMillis(bb);
- return TimestampType.instance.fromTimeInMillis(millis);
- }
-
- @Override
- public boolean isMonotonic()
- {
- return true;
- }
- };
- }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new MaxTimeuuidFunction(true);
+ }
+ }
+
+ /**
+ * Creates a function that converts a value of the specified type into a {@code DATE}.
+ *
+ * @param type the temporal type
+ * @return a function that convert a value of the specified type into a <code>DATE</code>.
+ */
+ public static NativeScalarFunction toDate(TemporalType<?> type)
+ {
+ return new ToDateFunction(type, false);
+ }
+
+ private static class ToDateFunction extends NativeScalarFunction
+ {
+ private final TemporalType<?> type;
+
+ public ToDateFunction(TemporalType<?> type, boolean useLegacyName)
+ {
+ super(useLegacyName ? "todate" : "to_date", SimpleDateType.instance, type);
+ this.type = type;
+ }
+
+ @Override
+ public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ {
+ ByteBuffer bb = parameters.get(0);
+ if (bb == null || !bb.hasRemaining())
+ return null;
+
+ long millis = type.toTimeInMillis(bb);
+ return SimpleDateType.instance.fromTimeInMillis(millis);
+ }
+
+ @Override
+ public boolean isMonotonic()
+ {
+ return true;
+ }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new ToDateFunction(type, true);
+ }
+ }
/**
- * Creates a function that convert a value of the specified type into an UNIX timestamp.
+ * Creates a function that converts a value of the specified type into a {@code TIMESTAMP}.
+ *
* @param type the temporal type
- * @return a function that convert a value of the specified type into an UNIX timestamp.
+ * @return a function that convert a value of the specified type into a {@code TIMESTAMP}.
*/
- public static final NativeScalarFunction toUnixTimestamp(final TemporalType<?> type)
+ public static NativeScalarFunction toTimestamp(TemporalType<?> type)
{
- return new NativeScalarFunction("tounixtimestamp", LongType.instance, type)
+ return new ToTimestampFunction(type, false);
+ }
+
+ private static class ToTimestampFunction extends NativeScalarFunction
+ {
+ private final TemporalType<?> type;
+
+ public ToTimestampFunction(TemporalType<?> type, boolean useLegacyName)
{
- public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
- {
- ByteBuffer bb = parameters.get(0);
- if (bb == null || !bb.hasRemaining())
- return null;
-
- return ByteBufferUtil.bytes(type.toTimeInMillis(bb));
- }
-
- @Override
- public boolean isMonotonic()
- {
- return true;
- }
- };
+ super(useLegacyName ? "totimestamp" : "to_timestamp", TimestampType.instance, type);
+ this.type = type;
+ }
+
+ @Override
+ public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ {
+ ByteBuffer bb = parameters.get(0);
+ if (bb == null || !bb.hasRemaining())
+ return null;
+
+ long millis = type.toTimeInMillis(bb);
+ return TimestampType.instance.fromTimeInMillis(millis);
+ }
+
+ @Override
+ public boolean isMonotonic()
+ {
+ return true;
+ }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new ToTimestampFunction(type, true);
+ }
+ }
+
+ /**
+ * Creates a function that converts a value of the specified type into a UNIX timestamp.
+ *
+ * @param type the temporal type
+ * @return a function that convert a value of the specified type into a UNIX timestamp.
+ */
+ public static NativeScalarFunction toUnixTimestamp(TemporalType<?> type)
+ {
+ return new ToUnixTimestampFunction(type, false);
+ }
+
+ private static class ToUnixTimestampFunction extends NativeScalarFunction
+ {
+ private final TemporalType<?> type;
+
+ private ToUnixTimestampFunction(TemporalType<?> type, boolean useLegacyName)
+ {
+ super(useLegacyName ? "tounixtimestamp" : "to_unix_timestamp", LongType.instance, type);
+ this.type = type;
+ }
+
+ @Override
+ public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters)
+ {
+ ByteBuffer bb = parameters.get(0);
+ if (bb == null || !bb.hasRemaining())
+ return null;
+
+ return ByteBufferUtil.bytes(type.toTimeInMillis(bb));
+ }
+
+ @Override
+ public boolean isMonotonic()
+ {
+ return true;
+ }
+
+ @Override
+ public NativeFunction withLegacyName()
+ {
+ return new ToUnixTimestampFunction(type, true);
+ }
}
/**
@@ -188,7 +283,7 @@ public abstract class TimeFcts
*/
private static abstract class FloorFunction extends NativeScalarFunction
{
- private static final Long ZERO = Long.valueOf(0);
+ private static final Long ZERO = 0L;
protected FloorFunction(AbstractType<?> returnType,
AbstractType<?>... argsType)
diff --git a/src/java/org/apache/cassandra/cql3/functions/ToJsonFct.java b/src/java/org/apache/cassandra/cql3/functions/ToJsonFct.java
index e2149e8f19..8dd7fd722d 100644
--- a/src/java/org/apache/cassandra/cql3/functions/ToJsonFct.java
+++ b/src/java/org/apache/cassandra/cql3/functions/ToJsonFct.java
@@ -28,33 +28,35 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import static java.lang.String.format;
+
public class ToJsonFct extends NativeScalarFunction
{
private static final Map<AbstractType<?>, ToJsonFct> instances = new ConcurrentHashMap<>();
- public static ToJsonFct getInstance(List<AbstractType<?>> argTypes) throws InvalidRequestException
+ public static ToJsonFct getInstance(String name, List<AbstractType<?>> argTypes) throws InvalidRequestException
{
if (argTypes.size() != 1)
- throw new InvalidRequestException(String.format("toJson() only accepts one argument (got %d)", argTypes.size()));
+ throw new InvalidRequestException(format("%s() only accepts one argument (got %d)", name, argTypes.size()));
AbstractType<?> fromType = argTypes.get(0);
ToJsonFct func = instances.get(fromType);
if (func == null)
{
- func = new ToJsonFct(fromType);
+ func = new ToJsonFct(name, fromType);
instances.put(fromType, func);
}
return func;
}
- private ToJsonFct(AbstractType<?> argType)
+ private ToJsonFct(String name, AbstractType<?> argType)
{
- super("tojson", UTF8Type.instance, argType);
+ super(name, UTF8Type.instance, argType);
}
public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException
{
- assert parameters.size() == 1 : "Expected 1 argument for toJson(), but got " + parameters.size();
+ assert parameters.size() == 1 : format("Expected 1 argument for %s(), but got %d", name.name, parameters.size());
ByteBuffer parameter = parameters.get(0);
if (parameter == null)
return ByteBufferUtil.bytes("null");
@@ -64,13 +66,21 @@ public class ToJsonFct extends NativeScalarFunction
public static void addFunctionsTo(NativeFunctions functions)
{
- functions.add(new FunctionFactory("tojson", FunctionParameter.anyType(false))
+ functions.add(new Factory("to_json"));
+ functions.add(new Factory("tojson")); // deprecated pre-5.0 name
+ }
+
+ private static class Factory extends FunctionFactory
+ {
+ public Factory(String name)
{
- @Override
- protected NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType)
- {
- return ToJsonFct.getInstance(argTypes);
- }
- });
+ super(name, FunctionParameter.anyType(false));
+ }
+
+ @Override
+ protected NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType)
+ {
+ return ToJsonFct.getInstance(name.name, argTypes);
+ }
}
}
diff --git a/src/java/org/apache/cassandra/cql3/selection/Selectable.java b/src/java/org/apache/cassandra/cql3/selection/Selectable.java
index 7115bcc000..7cb9dc2fb7 100644
--- a/src/java/org/apache/cassandra/cql3/selection/Selectable.java
+++ b/src/java/org/apache/cassandra/cql3/selection/Selectable.java
@@ -156,7 +156,7 @@ public interface Selectable extends AssignmentTestable
/*
* expectedType will be null if we have no constraint on what the type should be. For instance, if this term is a bind marker:
* - it will be null if we do "SELECT ? FROM foo"
- * - it won't be null (and be LongType) if we do "SELECT bigintAsBlob(?) FROM foo" because the function constrain it.
+ * - it won't be null (and be LongType) if we do "SELECT bigint_as_blob(?) FROM foo" because the function constrain it.
*
* In the first case, we have to error out: we need to infer the type of the metadata of a SELECT at preparation time, which we can't
* here (users will have to do "SELECT (varint)? FROM foo" for instance).
diff --git a/src/java/org/apache/cassandra/schema/SystemDistributedKeyspace.java b/src/java/org/apache/cassandra/schema/SystemDistributedKeyspace.java
index dc40093d4d..c11b2c4c94 100644
--- a/src/java/org/apache/cassandra/schema/SystemDistributedKeyspace.java
+++ b/src/java/org/apache/cassandra/schema/SystemDistributedKeyspace.java
@@ -174,7 +174,7 @@ public final class SystemDistributedKeyspace
{
Collection<Range<Token>> ranges = options.getRanges();
String query = "INSERT INTO %s.%s (parent_id, keyspace_name, columnfamily_names, requested_ranges, started_at, options)"+
- " VALUES (%s, '%s', { '%s' }, { '%s' }, toTimestamp(now()), { %s })";
+ " VALUES (%s, '%s', { '%s' }, { '%s' }, to_timestamp(now()), { %s })";
String fmtQry = format(query,
SchemaConstants.DISTRIBUTED_KEYSPACE_NAME,
PARENT_REPAIR_HISTORY,
@@ -206,7 +206,7 @@ public final class SystemDistributedKeyspace
public static void failParentRepair(TimeUUID parent_id, Throwable t)
{
- String query = "UPDATE %s.%s SET finished_at = toTimestamp(now()), exception_message=?, exception_stacktrace=? WHERE parent_id=%s";
+ String query = "UPDATE %s.%s SET finished_at = to_timestamp(now()), exception_message=?, exception_stacktrace=? WHERE parent_id=%s";
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -218,7 +218,7 @@ public final class SystemDistributedKeyspace
public static void successfulParentRepair(TimeUUID parent_id, Collection<Range<Token>> successfulRanges)
{
- String query = "UPDATE %s.%s SET finished_at = toTimestamp(now()), successful_ranges = {'%s'} WHERE parent_id=%s";
+ String query = "UPDATE %s.%s SET finished_at = to_timestamp(now()), successful_ranges = {'%s'} WHERE parent_id=%s";
String fmtQuery = format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, PARENT_REPAIR_HISTORY, Joiner.on("','").join(successfulRanges), parent_id.toString());
processSilent(fmtQuery);
}
@@ -241,10 +241,10 @@ public final class SystemDistributedKeyspace
String query =
"INSERT INTO %s.%s (keyspace_name, columnfamily_name, id, parent_id, range_begin, range_end, coordinator, coordinator_port, participants, participants_v2, status, started_at) " +
- "VALUES ( '%s', '%s', %s, %s, '%s', '%s', '%s', %d, { '%s' }, { '%s' }, '%s', toTimestamp(now()))";
+ "VALUES ( '%s', '%s', %s, %s, '%s', '%s', '%s', %d, { '%s' }, { '%s' }, '%s', to_timestamp(now()))";
String queryWithoutNewColumns =
"INSERT INTO %s.%s (keyspace_name, columnfamily_name, id, parent_id, range_begin, range_end, coordinator, participants, status, started_at) " +
- "VALUES ( '%s', '%s', %s, %s, '%s', '%s', '%s', { '%s' }, '%s', toTimestamp(now()))";
+ "VALUES ( '%s', '%s', %s, %s, '%s', '%s', '%s', { '%s' }, '%s', to_timestamp(now()))";
for (String cfname : cfnames)
{
@@ -292,7 +292,7 @@ public final class SystemDistributedKeyspace
public static void successfulRepairJob(TimeUUID id, String keyspaceName, String cfname)
{
- String query = "UPDATE %s.%s SET status = '%s', finished_at = toTimestamp(now()) WHERE keyspace_name = '%s' AND columnfamily_name = '%s' AND id = %s";
+ String query = "UPDATE %s.%s SET status = '%s', finished_at = to_timestamp(now()) WHERE keyspace_name = '%s' AND columnfamily_name = '%s' AND id = %s";
String fmtQuery = format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, REPAIR_HISTORY,
RepairState.SUCCESS.toString(),
keyspaceName,
@@ -303,7 +303,7 @@ public final class SystemDistributedKeyspace
public static void failedRepairJob(TimeUUID id, String keyspaceName, String cfname, Throwable t)
{
- String query = "UPDATE %s.%s SET status = '%s', finished_at = toTimestamp(now()), exception_message=?, exception_stacktrace=? WHERE keyspace_name = '%s' AND columnfamily_name = '%s' AND id = %s";
+ String query = "UPDATE %s.%s SET status = '%s', finished_at = to_timestamp(now()), exception_message=?, exception_stacktrace=? WHERE keyspace_name = '%s' AND columnfamily_name = '%s' AND id = %s";
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
diff --git a/test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java b/test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java
index 3b54398406..3314c2a6ba 100644
--- a/test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/FrozenUDTTest.java
@@ -65,14 +65,14 @@ public class FrozenUDTTest extends TestBaseImpl
{
cluster.schemaChange("create type " + KEYSPACE + ".a (foo text)");
cluster.schemaChange("create table " + KEYSPACE + ".x (id int, ck frozen<a>, i int, primary key (id, ck))");
- cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.fromjson('{\"foo\":\"\"}'), 1)", ConsistencyLevel.ALL);
- cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.fromjson('{\"foo\":\"a\"}'), 2)", ConsistencyLevel.ALL);
+ cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.from_json('{\"foo\":\"\"}'), 1)", ConsistencyLevel.ALL);
+ cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.from_json('{\"foo\":\"a\"}'), 2)", ConsistencyLevel.ALL);
cluster.forEach(i -> i.flush(KEYSPACE));
Runnable check = () -> {
- assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"\"}')", ConsistencyLevel.ALL),
+ assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.from_json('{\"foo\":\"\"}')", ConsistencyLevel.ALL),
row(1));
- assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"a\"}')", ConsistencyLevel.ALL),
+ assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.from_json('{\"foo\":\"a\"}')", ConsistencyLevel.ALL),
row(2));
};
@@ -80,10 +80,10 @@ public class FrozenUDTTest extends TestBaseImpl
cluster.schemaChange("alter type " + KEYSPACE + ".a add bar text");
check.run();
- assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"\",\"bar\":\"\"}')", ConsistencyLevel.ALL));
- cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.fromjson('{\"foo\":\"\",\"bar\":\"\"}'), 3)", ConsistencyLevel.ALL);
+ assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.from_json('{\"foo\":\"\",\"bar\":\"\"}')", ConsistencyLevel.ALL));
+ cluster.coordinator(1).execute("insert into " + KEYSPACE + ".x (id, ck, i) VALUES (1, system.from_json('{\"foo\":\"\",\"bar\":\"\"}'), 3)", ConsistencyLevel.ALL);
check.run();
- assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.fromjson('{\"foo\":\"\",\"bar\":\"\"}')", ConsistencyLevel.ALL),
+ assertRows(cluster.coordinator(1).execute("select i from " + KEYSPACE + ".x WHERE id = 1 and ck = system.from_json('{\"foo\":\"\",\"bar\":\"\"}')", ConsistencyLevel.ALL),
row(3));
}
}
@@ -143,11 +143,11 @@ public class FrozenUDTTest extends TestBaseImpl
private String json(int i)
{
- return String.format("system.fromjson('{\"foo\":\"%d\"}')", i);
+ return String.format("system.from_json('{\"foo\":\"%d\"}')", i);
}
private String json(int i, int j)
{
- return String.format("system.fromjson('{\"foo\":\"%d\", \"bar\":\"%d\"}')", i, j);
+ return String.format("system.from_json('{\"foo\":\"%d\", \"bar\":\"%d\"}')", i, j);
}
}
diff --git a/test/distributed/org/apache/cassandra/distributed/test/OversizedMutationTest.java b/test/distributed/org/apache/cassandra/distributed/test/OversizedMutationTest.java
index 2b0d0a0a3e..fcd600c88b 100644
--- a/test/distributed/org/apache/cassandra/distributed/test/OversizedMutationTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/OversizedMutationTest.java
@@ -36,7 +36,7 @@ public class OversizedMutationTest extends TestBaseImpl
{
cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (key int PRIMARY KEY, val blob)"));
String payload = StringUtils.repeat('1', 1024 * 49);
- String query = "INSERT INTO %s.t (key, val) VALUES (1, textAsBlob('" + payload + "'))";
+ String query = "INSERT INTO %s.t (key, val) VALUES (1, text_as_blob('" + payload + "'))";
Assertions.assertThatThrownBy(() -> cluster.coordinator(1).execute(withKeyspace(query), ALL))
.hasMessageContaining("Rejected an oversized mutation (")
.hasMessageContaining("/49152) for keyspace: distributed_test_keyspace. Top keys are: t.1");
@@ -53,8 +53,8 @@ public class OversizedMutationTest extends TestBaseImpl
cluster.schemaChange(withKeyspace("CREATE TABLE ks1.t (key int PRIMARY KEY, val blob)"));
String payload = StringUtils.repeat('1', 1024 * 48);
String query = "BEGIN BATCH\n" +
- "INSERT INTO ks1.t (key, val) VALUES (1, textAsBlob('" + payload + "'))\n" +
- "INSERT INTO ks1.t (key, val) VALUES (2, textAsBlob('222'))\n" +
+ "INSERT INTO ks1.t (key, val) VALUES (1, text_as_blob('" + payload + "'))\n" +
+ "INSERT INTO ks1.t (key, val) VALUES (2, text_as_blob('222'))\n" +
"APPLY BATCH";
Assertions.assertThatThrownBy(() -> cluster.coordinator(1).execute(withKeyspace(query), ALL))
.hasMessageContaining("Rejected an oversized mutation (")
diff --git a/test/unit/org/apache/cassandra/batchlog/BatchlogManagerTest.java b/test/unit/org/apache/cassandra/batchlog/BatchlogManagerTest.java
index 1fb37352da..90a1d73c2a 100644
--- a/test/unit/org/apache/cassandra/batchlog/BatchlogManagerTest.java
+++ b/test/unit/org/apache/cassandra/batchlog/BatchlogManagerTest.java
@@ -170,7 +170,7 @@ public class BatchlogManagerTest
for (int i = 0; i < 100; i++)
{
- String query = String.format("SELECT * FROM \"%s\".\"%s\" WHERE key = intAsBlob(%d)", KEYSPACE1, CF_STANDARD1, i);
+ String query = String.format("SELECT * FROM \"%s\".\"%s\" WHERE key = int_as_blob(%d)", KEYSPACE1, CF_STANDARD1, i);
UntypedResultSet result = executeInternal(query);
assertNotNull(result);
if (i < 50)
@@ -248,7 +248,7 @@ public class BatchlogManagerTest
// We should see half of Standard2-targeted mutations written after the replay and all of Standard3 mutations applied.
for (int i = 0; i < 1000; i++)
{
- UntypedResultSet result = executeInternal(String.format("SELECT * FROM \"%s\".\"%s\" WHERE key = intAsBlob(%d)", KEYSPACE1, CF_STANDARD2,i));
+ UntypedResultSet result = executeInternal(String.format("SELECT * FROM \"%s\".\"%s\" WHERE key = int_as_blob(%d)", KEYSPACE1, CF_STANDARD2,i));
assertNotNull(result);
if (i >= 500)
{
@@ -264,7 +264,7 @@ public class BatchlogManagerTest
for (int i = 0; i < 1000; i++)
{
- UntypedResultSet result = executeInternal(String.format("SELECT * FROM \"%s\".\"%s\" WHERE key = intAsBlob(%d)", KEYSPACE1, CF_STANDARD3, i));
+ UntypedResultSet result = executeInternal(String.format("SELECT * FROM \"%s\".\"%s\" WHERE key = int_as_blob(%d)", KEYSPACE1, CF_STANDARD3, i));
assertNotNull(result);
assertEquals(ByteBufferUtil.bytes(i), result.one().getBytes("key"));
assertEquals("name" + i, result.one().getString("name"));
diff --git a/test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java b/test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java
index 47d5b8e237..dac730cb16 100644
--- a/test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewFiltering1Test.java
@@ -363,7 +363,7 @@ public class ViewFiltering1Test extends ViewAbstractParameterizedTest
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND b IS NOT NULL AND d is NOT NULL PRIMARY KEY ((a, b), c, d)",
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a IS NOT NULL AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = ? AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
- "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = blobAsInt(?) AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
+ "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = blob_as_int(?) AND b IS NOT NULL AND c is NOT NULL PRIMARY KEY ((a, b), c, d)",
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s PRIMARY KEY (a, b, c, d)"
);
@@ -391,7 +391,7 @@ public class ViewFiltering1Test extends ViewAbstractParameterizedTest
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND (c, d) > (1, 1) PRIMARY KEY ((a, b), c, d)",
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = 1 AND b = 1 AND (c, d) IN ((1, 1), (2, 2)) PRIMARY KEY ((a, b), c, d)",
"CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = (int) 1 AND b = 1 AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)",
- "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = blobAsInt(intAsBlob(1)) AND b = 1 AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)"
+ "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE a = blob_as_int(int_as_blob(1)) AND b = 1 AND c = 1 AND d = 1 PRIMARY KEY ((a, b), c, d)"
);
for (int i = 0; i < goodStatements.size(); i++)
@@ -462,7 +462,7 @@ public class ViewFiltering1Test extends ViewAbstractParameterizedTest
execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 1, 1, 3);
createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s " +
- "WHERE a = blobAsInt(intAsBlob(1)) AND b IS NOT NULL " +
+ "WHERE a = blob_as_int(int_as_blob(1)) AND b IS NOT NULL " +
"PRIMARY KEY (a, b)");
assertRows(executeView("SELECT a, b, c FROM %s"),
diff --git a/test/unit/org/apache/cassandra/cql3/ViewPKTest.java b/test/unit/org/apache/cassandra/cql3/ViewPKTest.java
index 6ab27ef5e9..1c2b9a6bb1 100644
--- a/test/unit/org/apache/cassandra/cql3/ViewPKTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewPKTest.java
@@ -253,8 +253,8 @@ public class ViewPKTest extends ViewAbstractTest
}
}
- updateView("INSERT INTO %s (k, asciival, bigintval) VALUES (?, ?, fromJson(?))", 0, "ascii text", "123123123123");
- updateView("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii text\"");
+ updateView("INSERT INTO %s (k, asciival, bigintval) VALUES (?, ?, from_json(?))", 0, "ascii text", "123123123123");
+ updateView("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"ascii text\"");
assertRows(execute("SELECT bigintval FROM %s WHERE k = ? and asciival = ?", 0, "ascii text"), row(123123123123L));
//Check the MV
@@ -265,7 +265,7 @@ public class ViewPKTest extends ViewAbstractTest
//UPDATE BASE
- updateView("INSERT INTO %s (k, asciival, bigintval) VALUES (?, ?, fromJson(?))", 0, "ascii text", "1");
+ updateView("INSERT INTO %s (k, asciival, bigintval) VALUES (?, ?, from_json(?))", 0, "ascii text", "1");
assertRows(execute("SELECT bigintval FROM %s WHERE k = ? and asciival = ?", 0, "ascii text"), row(1L));
//Check the MV
diff --git a/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java b/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java
index 09d7e15e07..b58777e5a9 100644
--- a/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java
@@ -254,313 +254,313 @@ public class ViewSchemaTest extends ViewAbstractTest
}
}
- // fromJson() can only be used when the receiver type is known
- assertInvalidMessage("fromJson() cannot be used in the selection clause", "SELECT fromJson(asciival) FROM %s", 0, 0);
+ // from_json() can only be used when the receiver type is known
+ assertInvalidMessage("from_json() cannot be used in the selection clause", "SELECT from_json(asciival) FROM %s", 0, 0);
String func1 = createFunction(KEYSPACE, "int", "CREATE FUNCTION %s (a int) CALLED ON NULL INPUT RETURNS text LANGUAGE java AS $$ return a.toString(); $$");
createFunctionOverload(func1, "int", "CREATE FUNCTION %s (a text) CALLED ON NULL INPUT RETURNS text LANGUAGE java AS $$ return new String(a); $$");
// ================ ascii ================
- updateView("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii text\"");
+ updateView("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"ascii text\"");
assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii \\\" text\"");
+ updateView("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"ascii \\\" text\"");
assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0), row(0, "ascii \" text"));
- // test that we can use fromJson() in other valid places in queries
- assertRows(execute("SELECT asciival FROM %s WHERE k = fromJson(?)", "0"), row("ascii \" text"));
+ // test that we can use from_json() in other valid places in queries
+ assertRows(execute("SELECT asciival FROM %s WHERE k = from_json(?)", "0"), row("ascii \" text"));
//Check the MV
assertRows(execute("SELECT k, udtval from mv_asciival WHERE asciival = ?", "ascii text"));
assertRows(execute("SELECT k, udtval from mv_asciival WHERE asciival = ?", "ascii \" text"), row(0, null));
- updateView("UPDATE %s SET asciival = fromJson(?) WHERE k = fromJson(?)", "\"ascii \\\" text\"", "0");
+ updateView("UPDATE %s SET asciival = from_json(?) WHERE k = from_json(?)", "\"ascii \\\" text\"", "0");
assertRows(execute("SELECT k, udtval from mv_asciival WHERE asciival = ?", "ascii \" text"), row(0, null));
- updateView("DELETE FROM %s WHERE k = fromJson(?)", "0");
+ updateView("DELETE FROM %s WHERE k = from_json(?)", "0");
assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0));
assertRows(execute("SELECT k, udtval from mv_asciival WHERE asciival = ?", "ascii \" text"));
- updateView("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii text\"");
+ updateView("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"ascii text\"");
assertRows(execute("SELECT k, udtval from mv_asciival WHERE asciival = ?", "ascii text"), row(0, null));
// ================ bigint ================
- updateView("INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "123123123123");
+ updateView("INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "123123123123");
assertRows(execute("SELECT k, bigintval FROM %s WHERE k = ?", 0), row(0, 123123123123L));
assertRows(execute("SELECT k, asciival from mv_bigintval WHERE bigintval = ?", 123123123123L), row(0, "ascii text"));
// ================ blob ================
- updateView("INSERT INTO %s (k, blobval) VALUES (?, fromJson(?))", 0, "\"0x00000001\"");
+ updateView("INSERT INTO %s (k, blobval) VALUES (?, from_json(?))", 0, "\"0x00000001\"");
assertRows(execute("SELECT k, blobval FROM %s WHERE k = ?", 0), row(0, ByteBufferUtil.bytes(1)));
assertRows(execute("SELECT k, asciival from mv_blobval WHERE blobval = ?", ByteBufferUtil.bytes(1)), row(0, "ascii text"));
// ================ boolean ================
- updateView("INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "true");
+ updateView("INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "true");
assertRows(execute("SELECT k, booleanval FROM %s WHERE k = ?", 0), row(0, true));
assertRows(execute("SELECT k, asciival from mv_booleanval WHERE booleanval = ?", true), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "false");
+ updateView("INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "false");
assertRows(execute("SELECT k, booleanval FROM %s WHERE k = ?", 0), row(0, false));
assertRows(execute("SELECT k, asciival from mv_booleanval WHERE booleanval = ?", true));
assertRows(execute("SELECT k, asciival from mv_booleanval WHERE booleanval = ?", false), row(0, "ascii text"));
// ================ date ================
- updateView("INSERT INTO %s (k, dateval) VALUES (?, fromJson(?))", 0, "\"1987-03-23\"");
+ updateView("INSERT INTO %s (k, dateval) VALUES (?, from_json(?))", 0, "\"1987-03-23\"");
assertRows(execute("SELECT k, dateval FROM %s WHERE k = ?", 0), row(0, SimpleDateSerializer.dateStringToDays("1987-03-23")));
- assertRows(execute("SELECT k, asciival from mv_dateval WHERE dateval = fromJson(?)", "\"1987-03-23\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_dateval WHERE dateval = from_json(?)", "\"1987-03-23\""), row(0, "ascii text"));
// ================ decimal ================
- updateView("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "123123.123123");
+ updateView("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "123123.123123");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("123123.123123")));
- assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = fromJson(?)", "123123.123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = from_json(?)", "123123.123123"), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "123123");
+ updateView("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("123123")));
- assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = fromJson(?)", "123123.123123"));
- assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = fromJson(?)", "123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = from_json(?)", "123123.123123"));
+ assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = from_json(?)", "123123"), row(0, "ascii text"));
// accept strings for numbers that cannot be represented as doubles
- updateView("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "\"123123.123123\"");
+ updateView("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "\"123123.123123\"");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("123123.123123")));
- updateView("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "\"-1.23E-12\"");
+ updateView("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "\"-1.23E-12\"");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("-1.23E-12")));
- assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = fromJson(?)", "\"-1.23E-12\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_decimalval WHERE decimalval = from_json(?)", "\"-1.23E-12\""), row(0, "ascii text"));
// ================ double ================
- updateView("INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "123123.123123");
+ updateView("INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "123123.123123");
assertRows(execute("SELECT k, doubleval FROM %s WHERE k = ?", 0), row(0, 123123.123123d));
- assertRows(execute("SELECT k, asciival from mv_doubleval WHERE doubleval = fromJson(?)", "123123.123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_doubleval WHERE doubleval = from_json(?)", "123123.123123"), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "123123");
+ updateView("INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, doubleval FROM %s WHERE k = ?", 0), row(0, 123123.0d));
- assertRows(execute("SELECT k, asciival from mv_doubleval WHERE doubleval = fromJson(?)", "123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_doubleval WHERE doubleval = from_json(?)", "123123"), row(0, "ascii text"));
// ================ float ================
- updateView("INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "123123.123123");
+ updateView("INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "123123.123123");
assertRows(execute("SELECT k, floatval FROM %s WHERE k = ?", 0), row(0, 123123.123123f));
- assertRows(execute("SELECT k, asciival from mv_floatval WHERE floatval = fromJson(?)", "123123.123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_floatval WHERE floatval = from_json(?)", "123123.123123"), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "123123");
+ updateView("INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, floatval FROM %s WHERE k = ?", 0), row(0, 123123.0f));
- assertRows(execute("SELECT k, asciival from mv_floatval WHERE floatval = fromJson(?)", "123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_floatval WHERE floatval = from_json(?)", "123123"), row(0, "ascii text"));
// ================ inet ================
- updateView("INSERT INTO %s (k, inetval) VALUES (?, fromJson(?))", 0, "\"127.0.0.1\"");
+ updateView("INSERT INTO %s (k, inetval) VALUES (?, from_json(?))", 0, "\"127.0.0.1\"");
assertRows(execute("SELECT k, inetval FROM %s WHERE k = ?", 0), row(0, InetAddress.getByName("127.0.0.1")));
- assertRows(execute("SELECT k, asciival from mv_inetval WHERE inetval = fromJson(?)", "\"127.0.0.1\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_inetval WHERE inetval = from_json(?)", "\"127.0.0.1\""), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, inetval) VALUES (?, fromJson(?))", 0, "\"::1\"");
+ updateView("INSERT INTO %s (k, inetval) VALUES (?, from_json(?))", 0, "\"::1\"");
assertRows(execute("SELECT k, inetval FROM %s WHERE k = ?", 0), row(0, InetAddress.getByName("::1")));
- assertRows(execute("SELECT k, asciival from mv_inetval WHERE inetval = fromJson(?)", "\"127.0.0.1\""));
- assertRows(execute("SELECT k, asciival from mv_inetval WHERE inetval = fromJson(?)", "\"::1\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_inetval WHERE inetval = from_json(?)", "\"127.0.0.1\""));
+ assertRows(execute("SELECT k, asciival from mv_inetval WHERE inetval = from_json(?)", "\"::1\""), row(0, "ascii text"));
// ================ int ================
- updateView("INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "123123");
+ updateView("INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, intval FROM %s WHERE k = ?", 0), row(0, 123123));
- assertRows(execute("SELECT k, asciival from mv_intval WHERE intval = fromJson(?)", "123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_intval WHERE intval = from_json(?)", "123123"), row(0, "ascii text"));
// ================ text (varchar) ================
- updateView("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"some \\\" text\"");
+ updateView("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"some \\\" text\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, "some \" text"));
- updateView("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"\\u2013\"");
+ updateView("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"\\u2013\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, "\u2013"));
- assertRows(execute("SELECT k, asciival from mv_textval WHERE textval = fromJson(?)", "\"\\u2013\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_textval WHERE textval = from_json(?)", "\"\\u2013\""), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"abcd\"");
+ updateView("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"abcd\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, "abcd"));
- assertRows(execute("SELECT k, asciival from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, "ascii text"));
// ================ time ================
- updateView("INSERT INTO %s (k, timeval) VALUES (?, fromJson(?))", 0, "\"07:35:07.000111222\"");
+ updateView("INSERT INTO %s (k, timeval) VALUES (?, from_json(?))", 0, "\"07:35:07.000111222\"");
assertRows(execute("SELECT k, timeval FROM %s WHERE k = ?", 0), row(0, TimeSerializer.timeStringToLong("07:35:07.000111222")));
- assertRows(execute("SELECT k, asciival from mv_timeval WHERE timeval = fromJson(?)", "\"07:35:07.000111222\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_timeval WHERE timeval = from_json(?)", "\"07:35:07.000111222\""), row(0, "ascii text"));
// ================ timestamp ================
- updateView("INSERT INTO %s (k, timestampval) VALUES (?, fromJson(?))", 0, "123123123123");
+ updateView("INSERT INTO %s (k, timestampval) VALUES (?, from_json(?))", 0, "123123123123");
assertRows(execute("SELECT k, timestampval FROM %s WHERE k = ?", 0), row(0, new Date(123123123123L)));
- assertRows(execute("SELECT k, asciival from mv_timestampval WHERE timestampval = fromJson(?)", "123123123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_timestampval WHERE timestampval = from_json(?)", "123123123123"), row(0, "ascii text"));
- updateView("INSERT INTO %s (k, timestampval) VALUES (?, fromJson(?))", 0, "\"2014-01-01\"");
+ updateView("INSERT INTO %s (k, timestampval) VALUES (?, from_json(?))", 0, "\"2014-01-01\"");
assertRows(execute("SELECT k, timestampval FROM %s WHERE k = ?", 0), row(0, new SimpleDateFormat("y-M-d").parse("2014-01-01")));
- assertRows(execute("SELECT k, asciival from mv_timestampval WHERE timestampval = fromJson(?)", "\"2014-01-01\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_timestampval WHERE timestampval = from_json(?)", "\"2014-01-01\""), row(0, "ascii text"));
// ================ timeuuid ================
- updateView("INSERT INTO %s (k, timeuuidval) VALUES (?, fromJson(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
+ updateView("INSERT INTO %s (k, timeuuidval) VALUES (?, from_json(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
assertRows(execute("SELECT k, timeuuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- updateView("INSERT INTO %s (k, timeuuidval) VALUES (?, fromJson(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
+ updateView("INSERT INTO %s (k, timeuuidval) VALUES (?, from_json(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
assertRows(execute("SELECT k, timeuuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- assertRows(execute("SELECT k, asciival from mv_timeuuidval WHERE timeuuidval = fromJson(?)", "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_timeuuidval WHERE timeuuidval = from_json(?)", "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\""), row(0, "ascii text"));
// ================ uuidval ================
- updateView("INSERT INTO %s (k, uuidval) VALUES (?, fromJson(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
+ updateView("INSERT INTO %s (k, uuidval) VALUES (?, from_json(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
assertRows(execute("SELECT k, uuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- updateView("INSERT INTO %s (k, uuidval) VALUES (?, fromJson(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
+ updateView("INSERT INTO %s (k, uuidval) VALUES (?, from_json(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
assertRows(execute("SELECT k, uuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- assertRows(execute("SELECT k, asciival from mv_uuidval WHERE uuidval = fromJson(?)", "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_uuidval WHERE uuidval = from_json(?)", "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\""), row(0, "ascii text"));
// ================ varint ================
- updateView("INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "123123123123");
+ updateView("INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "123123123123");
assertRows(execute("SELECT k, varintval FROM %s WHERE k = ?", 0), row(0, new BigInteger("123123123123")));
- assertRows(execute("SELECT k, asciival from mv_varintval WHERE varintval = fromJson(?)", "123123123123"), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_varintval WHERE varintval = from_json(?)", "123123123123"), row(0, "ascii text"));
// accept strings for numbers that cannot be represented as longs
- updateView("INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "\"1234567890123456789012345678901234567890\"");
+ updateView("INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "\"1234567890123456789012345678901234567890\"");
assertRows(execute("SELECT k, varintval FROM %s WHERE k = ?", 0), row(0, new BigInteger("1234567890123456789012345678901234567890")));
- assertRows(execute("SELECT k, asciival from mv_varintval WHERE varintval = fromJson(?)", "\"1234567890123456789012345678901234567890\""), row(0, "ascii text"));
+ assertRows(execute("SELECT k, asciival from mv_varintval WHERE varintval = from_json(?)", "\"1234567890123456789012345678901234567890\""), row(0, "ascii text"));
// ================ lists ================
- updateView("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[1, 2, 3]");
+ updateView("INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[1, 2, 3]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(1, 2, 3)));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(1, 2, 3)));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(1, 2, 3)));
- updateView("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[1]");
+ updateView("INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[1]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(1)));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(1)));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(1)));
- updateView("UPDATE %s SET listval = listval + fromJson(?) WHERE k = ?", "[2]", 0);
+ updateView("UPDATE %s SET listval = listval + from_json(?) WHERE k = ?", "[2]", 0);
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(1, 2)));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(1, 2)));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(1, 2)));
- updateView("UPDATE %s SET listval = fromJson(?) + listval WHERE k = ?", "[0]", 0);
+ updateView("UPDATE %s SET listval = from_json(?) + listval WHERE k = ?", "[0]", 0);
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(0, 1, 2)));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(0, 1, 2)));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(0, 1, 2)));
- updateView("UPDATE %s SET listval[1] = fromJson(?) WHERE k = ?", "10", 0);
+ updateView("UPDATE %s SET listval[1] = from_json(?) WHERE k = ?", "10", 0);
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(0, 10, 2)));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(0, 10, 2)));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(0, 10, 2)));
updateView("DELETE listval[1] FROM %s WHERE k = ?", 0);
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(0, 2)));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(0, 2)));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(0, 2)));
- updateView("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[]");
+ updateView("INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, null));
- assertRows(execute("SELECT k, listval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, null));
+ assertRows(execute("SELECT k, listval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, null));
// frozen
- updateView("INSERT INTO %s (k, frozenlistval) VALUES (?, fromJson(?))", 0, "[1, 2, 3]");
+ updateView("INSERT INTO %s (k, frozenlistval) VALUES (?, from_json(?))", 0, "[1, 2, 3]");
assertRows(execute("SELECT k, frozenlistval FROM %s WHERE k = ?", 0), row(0, list(1, 2, 3)));
- assertRows(execute("SELECT k, frozenlistval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(1, 2, 3)));
- assertRows(execute("SELECT k, textval from mv_frozenlistval where frozenlistval = fromJson(?)", "[1, 2, 3]"), row(0, "abcd"));
+ assertRows(execute("SELECT k, frozenlistval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(1, 2, 3)));
+ assertRows(execute("SELECT k, textval from mv_frozenlistval where frozenlistval = from_json(?)", "[1, 2, 3]"), row(0, "abcd"));
- updateView("INSERT INTO %s (k, frozenlistval) VALUES (?, fromJson(?))", 0, "[3, 2, 1]");
+ updateView("INSERT INTO %s (k, frozenlistval) VALUES (?, from_json(?))", 0, "[3, 2, 1]");
assertRows(execute("SELECT k, frozenlistval FROM %s WHERE k = ?", 0), row(0, list(3, 2, 1)));
- assertRows(execute("SELECT k, textval from mv_frozenlistval where frozenlistval = fromJson(?)", "[1, 2, 3]"));
- assertRows(execute("SELECT k, textval from mv_frozenlistval where frozenlistval = fromJson(?)", "[3, 2, 1]"), row(0, "abcd"));
- assertRows(execute("SELECT k, frozenlistval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list(3, 2, 1)));
+ assertRows(execute("SELECT k, textval from mv_frozenlistval where frozenlistval = from_json(?)", "[1, 2, 3]"));
+ assertRows(execute("SELECT k, textval from mv_frozenlistval where frozenlistval = from_json(?)", "[3, 2, 1]"), row(0, "abcd"));
+ assertRows(execute("SELECT k, frozenlistval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list(3, 2, 1)));
- updateView("INSERT INTO %s (k, frozenlistval) VALUES (?, fromJson(?))", 0, "[]");
+ updateView("INSERT INTO %s (k, frozenlistval) VALUES (?, from_json(?))", 0, "[]");
assertRows(execute("SELECT k, frozenlistval FROM %s WHERE k = ?", 0), row(0, list()));
- assertRows(execute("SELECT k, frozenlistval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, list()));
+ assertRows(execute("SELECT k, frozenlistval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, list()));
// ================ sets ================
- updateView("INSERT INTO %s (k, setval) VALUES (?, fromJson(?))",
+ updateView("INSERT INTO %s (k, setval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- assertRows(execute("SELECT k, setval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, setval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))));
// duplicates are okay, just like in CQL
- updateView("INSERT INTO %s (k, setval) VALUES (?, fromJson(?))",
+ updateView("INSERT INTO %s (k, setval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- assertRows(execute("SELECT k, setval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, setval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))));
- updateView("UPDATE %s SET setval = setval + fromJson(?) WHERE k = ?", "[\"6bddc89a-5644-0000-97fc-56847afe9799\"]", 0);
+ updateView("UPDATE %s SET setval = setval + from_json(?) WHERE k = ?", "[\"6bddc89a-5644-0000-97fc-56847afe9799\"]", 0);
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-0000-97fc-56847afe9799"), UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- assertRows(execute("SELECT k, setval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, setval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, set(UUID.fromString("6bddc89a-5644-0000-97fc-56847afe9799"), UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))));
- updateView("UPDATE %s SET setval = setval - fromJson(?) WHERE k = ?", "[\"6bddc89a-5644-0000-97fc-56847afe9799\"]", 0);
+ updateView("UPDATE %s SET setval = setval - from_json(?) WHERE k = ?", "[\"6bddc89a-5644-0000-97fc-56847afe9799\"]", 0);
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- assertRows(execute("SELECT k, setval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, setval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))));
- updateView("INSERT INTO %s (k, setval) VALUES (?, fromJson(?))", 0, "[]");
+ updateView("INSERT INTO %s (k, setval) VALUES (?, from_json(?))", 0, "[]");
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0), row(0, null));
- assertRows(execute("SELECT k, setval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, setval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, null));
// frozen
- updateView("INSERT INTO %s (k, frozensetval) VALUES (?, fromJson(?))",
+ updateView("INSERT INTO %s (k, frozensetval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, frozensetval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- assertRows(execute("SELECT k, frozensetval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, frozensetval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))));
- updateView("INSERT INTO %s (k, frozensetval) VALUES (?, fromJson(?))",
+ updateView("INSERT INTO %s (k, frozensetval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-0000-11e4-97fc-56847afe9799\", \"6bddc89a-5644-11e4-97fc-56847afe9798\"]");
assertRows(execute("SELECT k, frozensetval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-0000-11e4-97fc-56847afe9799"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"))))
);
- assertRows(execute("SELECT k, frozensetval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, frozensetval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, set(UUID.fromString("6bddc89a-0000-11e4-97fc-56847afe9799"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798")))));
// ================ maps ================
- updateView("INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": 2}");
+ updateView("INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": 2}");
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0), row(0, map("a", 1, "b", 2)));
- assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""), row(0, map("a", 1, "b", 2)));
+ assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = from_json(?)", "\"abcd\""), row(0, map("a", 1, "b", 2)));
updateView("UPDATE %s SET mapval[?] = ? WHERE k = ?", "c", 3, 0);
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0),
row(0, map("a", 1, "b", 2, "c", 3))
);
- assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, map("a", 1, "b", 2, "c", 3)));
updateView("UPDATE %s SET mapval[?] = ? WHERE k = ?", "b", 10, 0);
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0),
row(0, map("a", 1, "b", 10, "c", 3))
);
- assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, map("a", 1, "b", 10, "c", 3)));
updateView("DELETE mapval[?] FROM %s WHERE k = ?", "b", 0);
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0),
row(0, map("a", 1, "c", 3))
);
- assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, map("a", 1, "c", 3)));
- updateView("INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "{}");
+ updateView("INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "{}");
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0), row(0, null));
- assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = fromJson(?)", "\"abcd\""),
+ assertRows(execute("SELECT k, mapval from mv_textval WHERE textval = from_json(?)", "\"abcd\""),
row(0, null));
// frozen
- updateView("INSERT INTO %s (k, frozenmapval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": 2}");
+ updateView("INSERT INTO %s (k, frozenmapval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": 2}");
assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, map("a", 1, "b", 2)));
- assertRows(execute("SELECT k, textval FROM mv_frozenmapval WHERE frozenmapval = fromJson(?)", "{\"a\": 1, \"b\": 2}"), row(0, "abcd"));
+ assertRows(execute("SELECT k, textval FROM mv_frozenmapval WHERE frozenmapval = from_json(?)", "{\"a\": 1, \"b\": 2}"), row(0, "abcd"));
- updateView("INSERT INTO %s (k, frozenmapval) VALUES (?, fromJson(?))", 0, "{\"b\": 2, \"a\": 3}");
+ updateView("INSERT INTO %s (k, frozenmapval) VALUES (?, from_json(?))", 0, "{\"b\": 2, \"a\": 3}");
assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, map("a", 3, "b", 2)));
assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, map("a", 3, "b", 2)));
// ================ tuples ================
- updateView("INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))", 0, "[1, \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
+ updateView("INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))", 0, "[1, \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, tupleval FROM %s WHERE k = ?", 0),
row(0, tuple(1, "foobar", UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))
);
assertRows(execute("SELECT k, textval FROM mv_tupleval WHERE tupleval = ?", tuple(1, "foobar", UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))),
row(0, "abcd"));
- updateView("INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))", 0, "[1, null, \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
+ updateView("INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))", 0, "[1, null, \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, tupleval FROM %s WHERE k = ?", 0),
row(0, tuple(1, null, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))
);
@@ -569,37 +569,37 @@ public class ViewSchemaTest extends ViewAbstractTest
row(0, "abcd"));
// ================ UDTs ================
- updateView("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
+ updateView("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("bar", "foo"))
);
- assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = fromJson(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"),
+ assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = from_json(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"),
row(0, "abcd"));
// order of fields shouldn't matter
- updateView("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"a\": 1, \"c\": [\"foo\", \"bar\"]}");
+ updateView("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"a\": 1, \"c\": [\"foo\", \"bar\"]}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("bar", "foo"))
);
- assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = fromJson(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"),
+ assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = from_json(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"),
row(0, "abcd"));
// test nulls
- updateView("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
+ updateView("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, null, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("bar", "foo"))
);
- assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = fromJson(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"));
- assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = fromJson(?)", "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"),
+ assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = from_json(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"));
+ assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = from_json(?)", "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"),
row(0, "abcd"));
// test missing fields
- updateView("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\"}");
+ updateView("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\"}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), null)
);
- assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = fromJson(?)", "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"));
- assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = fromJson(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\"}"),
+ assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = from_json(?)", "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}"));
+ assertRows(execute("SELECT k, textval FROM mv_udtval WHERE udtval = from_json(?)", "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\"}"),
row(0, "abcd"));
}
diff --git a/test/unit/org/apache/cassandra/cql3/ViewTest.java b/test/unit/org/apache/cassandra/cql3/ViewTest.java
index d82fd322e1..a2793fd9fb 100644
--- a/test/unit/org/apache/cassandra/cql3/ViewTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ViewTest.java
@@ -232,12 +232,12 @@ public class ViewTest extends ViewAbstractTest
createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE k IS NOT NULL AND intval IS NOT NULL PRIMARY KEY (intval, k)");
- updateView("INSERT INTO %s (k, intval, listval) VALUES (?, ?, fromJson(?))", 0, 0, "[1, 2, 3]");
+ updateView("INSERT INTO %s (k, intval, listval) VALUES (?, ?, from_json(?))", 0, 0, "[1, 2, 3]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(1, 2, 3)));
assertRows(executeView("SELECT k, listval from %s WHERE intval = ?", 0), row(0, list(1, 2, 3)));
updateView("INSERT INTO %s (k, intval) VALUES (?, ?)", 1, 1);
- updateView("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 1, "[1, 2, 3]");
+ updateView("INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 1, "[1, 2, 3]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 1), row(1, list(1, 2, 3)));
assertRows(executeView("SELECT k, listval from %s WHERE intval = ?", 1), row(1, list(1, 2, 3)));
}
@@ -249,7 +249,7 @@ public class ViewTest extends ViewAbstractTest
createView("CREATE MATERIALIZED VIEW %s AS SELECT * FROM %s WHERE k IS NOT NULL AND listval IS NOT NULL PRIMARY KEY (k, listval)");
- updateView("INSERT INTO %s (k, intval, listval) VALUES (?, ?, fromJson(?))",
+ updateView("INSERT INTO %s (k, intval, listval) VALUES (?, ?, from_json(?))",
0,
0,
"[[\"a\",\"1\"], [\"b\",\"2\"], [\"c\",\"3\"]]");
@@ -261,7 +261,7 @@ public class ViewTest extends ViewAbstractTest
row(0, list(tuple("a", "1"), tuple("b", "2"), tuple("c", "3"))));
// update listval with the same value and it will be compared in view generator
- updateView("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))",
+ updateView("INSERT INTO %s (k, listval) VALUES (?, from_json(?))",
0,
"[[\"a\",\"1\"], [\"b\",\"2\"], [\"c\",\"3\"]]");
// verify result
diff --git a/test/unit/org/apache/cassandra/cql3/functions/CastFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/CastFctsTest.java
index 6efbdc0438..7fe3b61699 100644
--- a/test/unit/org/apache/cassandra/cql3/functions/CastFctsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/functions/CastFctsTest.java
@@ -326,7 +326,7 @@ public class CastFctsTest extends CQLTester
assertRows(execute("SELECT v FROM %s"), row(3));
// Cast of placeholder without type hint
- assertInvalidRequestMessage("Ambiguous call to function system.castAsInt",
+ assertInvalidRequestMessage("Ambiguous call to function system.cast_as_int",
"INSERT INTO %s (k, v) VALUES (1, CAST(? AS int))", 3.4f);
// Type hint of cast
@@ -363,7 +363,7 @@ public class CastFctsTest extends CQLTester
assertRows(execute("SELECT v FROM %s"), row(3));
// Cast of placeholder without type hint
- assertInvalidRequestMessage("Ambiguous call to function system.castAsInt",
+ assertInvalidRequestMessage("Ambiguous call to function system.cast_as_int",
"UPDATE %s SET v = CAST(? AS int) WHERE k = 1", 3.4f);
// Type hint of cast
@@ -405,7 +405,7 @@ public class CastFctsTest extends CQLTester
assertRows(execute("SELECT v FROM %s WHERE k = ?", 3), row(3));
// Cast of placeholder without type hint
- assertInvalidRequestMessage("Ambiguous call to function system.castAsInt",
+ assertInvalidRequestMessage("Ambiguous call to function system.cast_as_int",
"UPDATE %s SET v = ? WHERE k = CAST(? AS int)", 3, 3.4f);
// Type hint of cast
@@ -444,7 +444,7 @@ public class CastFctsTest extends CQLTester
assertRows(execute("SELECT k FROM %s WHERE k = CAST((float) ? AS int)", 3.4f), row(3));
// Cast of placeholder without type hint
- assertInvalidRequestMessage("Ambiguous call to function system.castAsInt",
+ assertInvalidRequestMessage("Ambiguous call to function system.cast_as_int",
"SELECT k FROM %s WHERE k = CAST(? AS int)", 3.4f);
// Type hint of cast
@@ -483,7 +483,7 @@ public class CastFctsTest extends CQLTester
assertEmpty(execute("SELECT * FROM %s WHERE k = ?", 3));
// Cast of placeholder without type hint
- assertInvalidRequestMessage("Ambiguous call to function system.castAsInt",
+ assertInvalidRequestMessage("Ambiguous call to function system.cast_as_int",
"DELETE FROM %s WHERE k = CAST(? AS int)", 3.4f);
// Type hint of cast
diff --git a/test/unit/org/apache/cassandra/cql3/functions/NativeFunctionsTest.java b/test/unit/org/apache/cassandra/cql3/functions/NativeFunctionsTest.java
new file mode 100644
index 0000000000..3bf3543ef6
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/functions/NativeFunctionsTest.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.cql3.functions;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+
+import org.apache.cassandra.schema.SchemaConstants;
+import org.assertj.core.api.Assertions;
+
+public class NativeFunctionsTest
+{
+ /**
+ * Map associating old functions that don't satisfy the naming conventions adopted by CASSANDRA-18037 to their
+ * new names according to those conventions.
+ */
+ private static final Map<String, String> LEGACY_FUNCTION_NAMES = new HashMap<String, String>()
+ {
+ {
+ put("castAsAscii", "cast_as_ascii");
+ put("castAsBigint", "cast_as_bigint");
+ put("castAsDate", "cast_as_date");
+ put("castAsDecimal", "cast_as_decimal");
+ put("castAsDouble", "cast_as_double");
+ put("castAsFloat", "cast_as_float");
+ put("castAsInt", "cast_as_int");
+ put("castAsSmallint", "cast_as_smallint");
+ put("castAsText", "cast_as_text");
+ put("castAsTimestamp", "cast_as_timestamp");
+ put("castAsTinyint", "cast_as_tinyint");
+ put("castAsVarint", "cast_as_varint");
+ put("blobasascii", "blob_as_ascii");
+ put("blobasbigint", "blob_as_bigint");
+ put("blobasboolean", "blob_as_boolean");
+ put("blobascounter", "blob_as_counter");
+ put("blobasdate", "blob_as_date");
+ put("blobasdecimal", "blob_as_decimal");
+ put("blobasdouble", "blob_as_double");
+ put("blobasduration", "blob_as_duration");
+ put("blobasempty", "blob_as_empty");
+ put("blobasfloat", "blob_as_float");
+ put("blobasinet", "blob_as_inet");
+ put("blobasint", "blob_as_int");
+ put("blobassmallint", "blob_as_smallint");
+ put("blobastext", "blob_as_text");
+ put("blobastime", "blob_as_time");
+ put("blobastimestamp", "blob_as_timestamp");
+ put("blobastimeuuid", "blob_as_timeuuid");
+ put("blobastinyint", "blob_as_tinyint");
+ put("blobasuuid", "blob_as_uuid");
+ put("blobasvarchar", "blob_as_varchar");
+ put("blobasvarint", "blob_as_varint");
+ put("asciiasblob", "ascii_as_blob");
+ put("bigintasblob", "bigint_as_blob");
+ put("booleanasblob", "boolean_as_blob");
+ put("counterasblob", "counter_as_blob");
+ put("dateasblob", "date_as_blob");
+ put("decimalasblob", "decimal_as_blob");
+ put("doubleasblob", "double_as_blob");
+ put("durationasblob", "duration_as_blob");
+ put("emptyasblob", "empty_as_blob");
+ put("floatasblob", "float_as_blob");
+ put("inetasblob", "inet_as_blob");
+ put("intasblob", "int_as_blob");
+ put("smallintasblob", "smallint_as_blob");
+ put("textasblob", "text_as_blob");
+ put("timeasblob", "time_as_blob");
+ put("timestampasblob", "timestamp_as_blob");
+ put("timeuuidasblob", "timeuuid_as_blob");
+ put("tinyintasblob", "tinyint_as_blob");
+ put("uuidasblob", "uuid_as_blob");
+ put("varcharasblob", "varchar_as_blob");
+ put("varintasblob", "varint_as_blob");
+ put("countRows", "count_rows");
+ put("maxtimeuuid", "max_timeuuid");
+ put("mintimeuuid", "min_timeuuid");
+ put("currentdate", "current_date");
+ put("currenttime", "current_time");
+ put("currenttimestamp", "current_timestamp");
+ put("currenttimeuuid", "current_timeuuid");
+ put("todate", "to_date");
+ put("totimestamp", "to_timestamp");
+ put("tounixtimestamp", "to_unix_timestamp");
+ }
+ };
+
+ /**
+ * Map associating old functions factories that don't satisfy the naming conventions adopted by CASSANDRA-18037 to
+ * their new names according to those conventions.
+ */
+ private static final Map<String, String> LEGACY_FUNCTION_FACTORY_NAMES = new HashMap<String, String>()
+ {
+ {
+ put("tojson", "to_json");
+ put("fromjson", "from_json");
+ }
+ };
+
+ /**
+ * Verify that the old functions that don't satisfy the naming conventions adopted by CASSANDRA-18037 have a
+ * replacement function that satisfies those conventions.
+ */
+ @Test
+ public void testDeprectedFunctionNames()
+ {
+ NativeFunctions nativeFunctions = NativeFunctions.instance;
+ LEGACY_FUNCTION_NAMES.forEach((oldName, newName) -> {
+ Assertions.assertThat(nativeFunctions.getFunctions(FunctionName.nativeFunction(oldName))).isNotEmpty();
+ Assertions.assertThat(nativeFunctions.getFunctions(FunctionName.nativeFunction(newName))).isNotEmpty();
+ });
+
+ for (NativeFunction function : nativeFunctions.getFunctions())
+ {
+ String name = function.name.name;
+
+ if (satisfiesConventions(function.name))
+ continue;
+
+ Assertions.assertThat(LEGACY_FUNCTION_NAMES).containsKey(name);
+ FunctionName newName = FunctionName.nativeFunction(LEGACY_FUNCTION_NAMES.get(name));
+
+ Function newFunction = FunctionResolver.get(SchemaConstants.SYSTEM_KEYSPACE_NAME,
+ newName,
+ function.argTypes,
+ null,
+ null,
+ function.returnType);
+
+ Assertions.assertThat(newFunction).isNotNull();
+ Assertions.assertThat(function).isNotEqualTo(newFunction);
+ Assertions.assertThat(function).isEqualTo(((NativeFunction) newFunction).withLegacyName());
+ Assertions.assertThat(function.argTypes()).isEqualTo(newFunction.argTypes());
+ Assertions.assertThat(function.returnType()).isEqualTo(newFunction.returnType());
+ Assertions.assertThat(function.getClass()).isEqualTo(newFunction.getClass());
+ Assertions.assertThat(function.name().name.toLowerCase())
+ .isEqualTo(StringUtils.remove(newFunction.name().name, '_'));
+ }
+ }
+
+ /**
+ * Verify that the old functions function factories that don't satisfy the naming conventions adopted by
+ * CASSANDRA-18037 have a replacement function factory that satisfies those conventions.
+ */
+ @Test
+ public void testDeprectedFunctionFactoryNames()
+ {
+ NativeFunctions nativeFunctions = NativeFunctions.instance;
+ LEGACY_FUNCTION_FACTORY_NAMES.forEach((oldName, newName) -> {
+ Assertions.assertThat(nativeFunctions.getFactories(FunctionName.nativeFunction(oldName))).isNotEmpty();
+ Assertions.assertThat(nativeFunctions.getFactories(FunctionName.nativeFunction(newName))).isNotEmpty();
+ });
+
+ for (FunctionFactory factory : nativeFunctions.getFactories())
+ {
+ String name = factory.name.name;
+
+ if (satisfiesConventions(factory.name))
+ continue;
+
+ Assertions.assertThat(LEGACY_FUNCTION_FACTORY_NAMES).containsKey(name);
+ FunctionName newName = FunctionName.nativeFunction(LEGACY_FUNCTION_FACTORY_NAMES.get(name));
+ Collection<FunctionFactory> newFactories = NativeFunctions.instance.getFactories(newName);
+
+ Assertions.assertThat(newFactories).hasSize(1);
+ FunctionFactory newFactory = newFactories.iterator().next();
+
+ Assertions.assertThat(factory).isNotEqualTo(newFactory);
+ Assertions.assertThat(factory.name).isNotEqualTo(newFactory.name);
+ Assertions.assertThat(factory.parameters).isEqualTo(newFactory.parameters);
+ Assertions.assertThat(factory.getClass()).isEqualTo(newFactory.getClass());
+ Assertions.assertThat(factory.name().name.toLowerCase())
+ .isEqualTo(StringUtils.remove(newFactory.name().name, '_'));
+ }
+ }
+
+ private static boolean satisfiesConventions(FunctionName functionName)
+ {
+ String name = functionName.name;
+ return name.equals(name.toLowerCase()) &&
+ !LEGACY_FUNCTION_NAMES.containsKey(name);
+ }
+}
diff --git a/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java b/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
index 659f34a737..6800a15bcf 100644
--- a/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
+++ b/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
@@ -227,14 +227,14 @@ public class SelectionColumnMappingTest extends CQLTester
private void testFunction() throws Throwable
{
- // a function such as intasblob(<col>) is represented in ResultSet.Metadata
+ // a function such as int_as_blob(<col>) is represented in ResultSet.Metadata
// by a ColumnSpecification with the function name plus args and the type set
// to the function's return type
- ColumnSpecification fnSpec = columnSpecification("system.intasblob(v1)", BytesType.instance);
+ ColumnSpecification fnSpec = columnSpecification("system.int_as_blob(v1)", BytesType.instance);
SelectionColumnMapping expected = SelectionColumnMapping.newMapping()
.addMapping(fnSpec, columnDefinition("v1"));
- verify(expected, "SELECT intasblob(v1) FROM %s");
+ verify(expected, "SELECT int_as_blob(v1) FROM %s");
}
private void testNoArgFunction() throws Throwable
@@ -326,7 +326,7 @@ public class SelectionColumnMappingTest extends CQLTester
SelectionColumnMapping expected = SelectionColumnMapping.newMapping()
.addMapping(fnSpec, columnDefinition("v1"));
- verify(expected, "SELECT intasblob(v1) AS fn_alias FROM %s");
+ verify(expected, "SELECT int_as_blob(v1) AS fn_alias FROM %s");
}
public void testNoArgumentFunction() throws Throwable
@@ -341,19 +341,19 @@ public class SelectionColumnMappingTest extends CQLTester
public void testNestedFunctionsWithArguments() throws Throwable
{
SelectionColumns expected = SelectionColumnMapping.newMapping()
- .addMapping(columnSpecification("system.blobasint(system.intasblob(v1))",
+ .addMapping(columnSpecification("system.blob_as_int(system.int_as_blob(v1))",
Int32Type.instance),
columnDefinition("v1"));
- verify(expected, "SELECT blobasint(intasblob(v1)) FROM %s");
+ verify(expected, "SELECT blob_as_int(int_as_blob(v1)) FROM %s");
}
public void testNestedFunctions() throws Throwable
{
SelectionColumns expected = SelectionColumnMapping.newMapping()
- .addMapping(columnSpecification("system.tounixtimestamp(system.now())",
+ .addMapping(columnSpecification("system.to_unix_timestamp(system.now())",
LongType.instance),
NULL_DEF);
- verify(expected, "SELECT tounixtimestamp(now()) FROM %s");
+ verify(expected, "SELECT to_unix_timestamp(now()) FROM %s");
}
public void testDuplicateFunctionsWithoutAliases() throws Throwable
@@ -361,11 +361,11 @@ public class SelectionColumnMappingTest extends CQLTester
// where duplicate functions are present, the ColumnSpecification list will
// contain an entry per-duplicate but the mappings will be deduplicated (i.e.
// a single mapping k/v pair regardless of the number of duplicates)
- ColumnSpecification spec = columnSpecification("system.intasblob(v1)", BytesType.instance);
+ ColumnSpecification spec = columnSpecification("system.int_as_blob(v1)", BytesType.instance);
SelectionColumns expected = SelectionColumnMapping.newMapping()
.addMapping(spec, columnDefinition("v1"))
.addMapping(spec, columnDefinition("v1"));
- verify(expected, "SELECT intasblob(v1), intasblob(v1) FROM %s");
+ verify(expected, "SELECT int_as_blob(v1), int_as_blob(v1) FROM %s");
}
public void testDuplicateFunctionsWithAliases() throws Throwable
@@ -378,7 +378,7 @@ public class SelectionColumnMappingTest extends CQLTester
columnDefinition("v1"))
.addMapping(columnSpecification("blob_2", BytesType.instance),
columnDefinition("v1"));
- verify(expected, "SELECT intasblob(v1) AS blob_1, intasblob(v1) AS blob_2 FROM %s");
+ verify(expected, "SELECT int_as_blob(v1) AS blob_1, int_as_blob(v1) AS blob_2 FROM %s");
}
public void testSelectDistinct() throws Throwable
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
index 3f5408fed4..93904bafef 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
@@ -80,8 +80,8 @@ public class JsonTest extends CQLTester
row("{\"k1\": [\"" + uuid + "\", 2], \"c1\": [\"" + uuid + "\", 3], \"value\": 3}"),
row("{\"k1\": [\"" + uuid + "\", 2], \"c1\": [\"" + uuid + "\", 4], \"value\": 4}"));
- // SELECT toJson(column)
- assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value) FROM %s", pageSize),
+ // SELECT to_json(column)
+ assertRowsNet(executeNetWithPaging("SELECT to_json(k1), to_json(c1), to_json(value) FROM %s", pageSize),
row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 1]", "1"),
row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 2]", "2"),
row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 3]", "3"),
@@ -110,8 +110,8 @@ public class JsonTest extends CQLTester
row("{\"k1\": {\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\", 2]}, \"c1\": [\"" + uuid + "\", 3], \"value\": 3}"),
row("{\"k1\": {\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\", 2]}, \"c1\": [\"" + uuid + "\", 4], \"value\": 4}"));
- // SELECT toJson(column)
- assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value) FROM %s", pageSize),
+ // SELECT to_json(column)
+ assertRowsNet(executeNetWithPaging("SELECT to_json(k1), to_json(c1), to_json(value) FROM %s", pageSize),
row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\", 2]}", "[\"" + uuid + "\", 1]", "1"),
row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\", 2]}", "[\"" + uuid + "\", 2]", "2"),
row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\", 2]}", "[\"" + uuid + "\", 3]", "3"),
@@ -140,8 +140,8 @@ public class JsonTest extends CQLTester
row("{\"k1\": [[[1, 2], 1], [[2, 3], 2]], \"c1\": [\"" + uuid + "\", 3], \"value\": 3}"),
row("{\"k1\": [[[1, 2], 1], [[2, 3], 2]], \"c1\": [\"" + uuid + "\", 4], \"value\": 4}"));
- // SELECT toJson(column)
- assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value) FROM %s", pageSize),
+ // SELECT to_json(column)
+ assertRowsNet(executeNetWithPaging("SELECT to_json(k1), to_json(c1), to_json(value) FROM %s", pageSize),
row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 1]", "1"),
row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 2]", "2"),
row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 3]", "3"),
@@ -170,8 +170,8 @@ public class JsonTest extends CQLTester
row("{\"k1\": [[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]], \"c1\": [\"" + uuid + "\", 3], \"value\": 3}"),
row("{\"k1\": [[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]], \"c1\": [\"" + uuid + "\", 4], \"value\": 4}"));
- // SELECT toJson(column)
- assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value) FROM %s", pageSize),
+ // SELECT to_json(column)
+ assertRowsNet(executeNetWithPaging("SELECT to_json(k1), to_json(c1), to_json(value) FROM %s", pageSize),
row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid + "\", 1]", "1"),
row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid + "\", 2]", "2"),
row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid + "\", 3]", "3"),
@@ -202,8 +202,8 @@ public class JsonTest extends CQLTester
row("{\"k1\": {\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}, \"c1\": [\"" + uuid + "\", 3], \"value\": 3}"),
row("{\"k1\": {\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}, \"c1\": [\"" + uuid + "\", 4], \"value\": 4}"));
- // SELECT toJson(column)
- assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value) FROM %s", pageSize),
+ // SELECT to_json(column)
+ assertRowsNet(executeNetWithPaging("SELECT to_json(k1), to_json(c1), to_json(value) FROM %s", pageSize),
row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid + "\", 1]", "1"),
row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid + "\", 2]", "2"),
row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid + "\", 3]", "3"),
@@ -246,468 +246,468 @@ public class JsonTest extends CQLTester
"udtval frozen<" + typeName + ">," +
"durationval duration)");
- // fromJson() can only be used when the receiver type is known
- assertInvalidMessage("fromJson() cannot be used in the selection clause", "SELECT fromJson(textval) FROM %s", 0, 0);
+ // from_json() can only be used when the receiver type is known
+ assertInvalidMessage("from_json() cannot be used in the selection clause", "SELECT from_json(textval) FROM %s", 0, 0);
String func1 = createFunction(KEYSPACE, "int", "CREATE FUNCTION %s (a int) CALLED ON NULL INPUT RETURNS text LANGUAGE java AS $$ return a.toString(); $$");
createFunctionOverload(func1, "int", "CREATE FUNCTION %s (a text) CALLED ON NULL INPUT RETURNS text LANGUAGE java AS $$ return new String(a); $$");
assertInvalidMessage("Ambiguous call to function",
- "INSERT INTO %s (k, textval) VALUES (?, " + func1 + "(fromJson(?)))", 0, "123");
+ "INSERT INTO %s (k, textval) VALUES (?, " + func1 + "(from_json(?)))", 0, "123");
// fails JSON parsing
assertInvalidMessage("Could not decode JSON string '\u038E\u0394\u03B4\u03E0'",
- "INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\u038E\u0394\u03B4\u03E0");
+ "INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\u038E\u0394\u03B4\u03E0");
// handle nulls
- execute("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, null);
+ execute("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, null);
assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0), row(0, null));
- execute("INSERT INTO %s (k, frozenmapval) VALUES (?, fromJson(?))", 0, null);
+ execute("INSERT INTO %s (k, frozenmapval) VALUES (?, from_json(?))", 0, null);
assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, null));
- execute("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, null);
+ execute("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, null);
assertRows(execute("SELECT k, udtval FROM %s WHERE k = ?", 0), row(0, null));
// ================ ascii ================
- execute("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii text\"");
+ execute("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"ascii text\"");
assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0), row(0, "ascii text"));
- execute("INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"ascii \\\" text\"");
+ execute("INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"ascii \\\" text\"");
assertRows(execute("SELECT k, asciival FROM %s WHERE k = ?", 0), row(0, "ascii \" text"));
assertInvalidMessage("Invalid ASCII character in string literal",
- "INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "\"\\u1fff\\u2013\\u33B4\\u2014\"");
+ "INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "\"\\u1fff\\u2013\\u33B4\\u2014\"");
assertInvalidMessage("Expected an ascii string, but got a Integer",
- "INSERT INTO %s (k, asciival) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, asciival) VALUES (?, from_json(?))", 0, "123");
- // test that we can use fromJson() in other valid places in queries
- assertRows(execute("SELECT asciival FROM %s WHERE k = fromJson(?)", "0"), row("ascii \" text"));
- execute("UPDATE %s SET asciival = fromJson(?) WHERE k = fromJson(?)", "\"ascii \\\" text\"", "0");
- execute("DELETE FROM %s WHERE k = fromJson(?)", "0");
+ // test that we can use from_json() in other valid places in queries
+ assertRows(execute("SELECT asciival FROM %s WHERE k = from_json(?)", "0"), row("ascii \" text"));
+ execute("UPDATE %s SET asciival = from_json(?) WHERE k = from_json(?)", "\"ascii \\\" text\"", "0");
+ execute("DELETE FROM %s WHERE k = from_json(?)", "0");
// ================ bigint ================
- execute("INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "123123123123");
+ execute("INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "123123123123");
assertRows(execute("SELECT k, bigintval FROM %s WHERE k = ?", 0), row(0, 123123123123L));
// strings are also accepted
- execute("INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "\"123123123123\"");
+ execute("INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "\"123123123123\"");
assertRows(execute("SELECT k, bigintval FROM %s WHERE k = ?", 0), row(0, 123123123123L));
// overflow (Long.MAX_VALUE + 1)
assertInvalidMessage("Expected a bigint value, but got a",
- "INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "9223372036854775808");
+ "INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "9223372036854775808");
assertInvalidMessage("Expected a bigint value, but got a",
- "INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "123.456");
+ "INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "123.456");
assertInvalidMessage("Unable to make long from",
- "INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "\"abc\"");
+ "INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "\"abc\"");
assertInvalidMessage("Expected a bigint value, but got a",
- "INSERT INTO %s (k, bigintval) VALUES (?, fromJson(?))", 0, "[\"abc\"]");
+ "INSERT INTO %s (k, bigintval) VALUES (?, from_json(?))", 0, "[\"abc\"]");
// ================ blob ================
- execute("INSERT INTO %s (k, blobval) VALUES (?, fromJson(?))", 0, "\"0x00000001\"");
+ execute("INSERT INTO %s (k, blobval) VALUES (?, from_json(?))", 0, "\"0x00000001\"");
assertRows(execute("SELECT k, blobval FROM %s WHERE k = ?", 0), row(0, ByteBufferUtil.bytes(1)));
assertInvalidMessage("Value 'xyzz' is not a valid blob representation",
- "INSERT INTO %s (k, blobval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, blobval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("String representation of blob is missing 0x prefix: 123",
- "INSERT INTO %s (k, blobval) VALUES (?, fromJson(?))", 0, "\"123\"");
+ "INSERT INTO %s (k, blobval) VALUES (?, from_json(?))", 0, "\"123\"");
assertInvalidMessage("Value '0x123' is not a valid blob representation",
- "INSERT INTO %s (k, blobval) VALUES (?, fromJson(?))", 0, "\"0x123\"");
+ "INSERT INTO %s (k, blobval) VALUES (?, from_json(?))", 0, "\"0x123\"");
assertInvalidMessage("Value '123' is not a valid blob representation",
- "INSERT INTO %s (k, blobval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, blobval) VALUES (?, from_json(?))", 0, "123");
// ================ boolean ================
- execute("INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "true");
+ execute("INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "true");
assertRows(execute("SELECT k, booleanval FROM %s WHERE k = ?", 0), row(0, true));
- execute("INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "false");
+ execute("INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "false");
assertRows(execute("SELECT k, booleanval FROM %s WHERE k = ?", 0), row(0, false));
// strings are also accepted
- execute("INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "\"false\"");
+ execute("INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "\"false\"");
assertRows(execute("SELECT k, booleanval FROM %s WHERE k = ?", 0), row(0, false));
assertInvalidMessage("Unable to make boolean from",
- "INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "\"abc\"");
+ "INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "\"abc\"");
assertInvalidMessage("Expected a boolean value, but got a Integer",
- "INSERT INTO %s (k, booleanval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, booleanval) VALUES (?, from_json(?))", 0, "123");
// ================ date ================
- execute("INSERT INTO %s (k, dateval) VALUES (?, fromJson(?))", 0, "\"1987-03-23\"");
+ execute("INSERT INTO %s (k, dateval) VALUES (?, from_json(?))", 0, "\"1987-03-23\"");
assertRows(execute("SELECT k, dateval FROM %s WHERE k = ?", 0), row(0, SimpleDateSerializer.dateStringToDays("1987-03-23")));
assertInvalidMessage("Expected a string representation of a date",
- "INSERT INTO %s (k, dateval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, dateval) VALUES (?, from_json(?))", 0, "123");
assertInvalidMessage("Unable to coerce 'xyz' to a formatted date",
- "INSERT INTO %s (k, dateval) VALUES (?, fromJson(?))", 0, "\"xyz\"");
+ "INSERT INTO %s (k, dateval) VALUES (?, from_json(?))", 0, "\"xyz\"");
// ================ decimal ================
- execute("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "123123.123123");
+ execute("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "123123.123123");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("123123.123123")));
- execute("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "123123");
+ execute("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("123123")));
// accept strings for numbers that cannot be represented as doubles
- execute("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "\"123123.123123\"");
+ execute("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "\"123123.123123\"");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("123123.123123")));
- execute("INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "\"-1.23E-12\"");
+ execute("INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "\"-1.23E-12\"");
assertRows(execute("SELECT k, decimalval FROM %s WHERE k = ?", 0), row(0, new BigDecimal("-1.23E-12")));
assertInvalidMessage("Value 'xyzz' is not a valid representation of a decimal value",
- "INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Value 'true' is not a valid representation of a decimal value",
- "INSERT INTO %s (k, decimalval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, decimalval) VALUES (?, from_json(?))", 0, "true");
// ================ double ================
- execute("INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "123123.123123");
+ execute("INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "123123.123123");
assertRows(execute("SELECT k, doubleval FROM %s WHERE k = ?", 0), row(0, 123123.123123d));
- execute("INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "123123");
+ execute("INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, doubleval FROM %s WHERE k = ?", 0), row(0, 123123.0d));
// strings are also accepted
- execute("INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "\"123123\"");
+ execute("INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "\"123123\"");
assertRows(execute("SELECT k, doubleval FROM %s WHERE k = ?", 0), row(0, 123123.0d));
assertInvalidMessage("Unable to make double from",
- "INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Expected a double value, but got",
- "INSERT INTO %s (k, doubleval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, doubleval) VALUES (?, from_json(?))", 0, "true");
// ================ float ================
- execute("INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "123123.123123");
+ execute("INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "123123.123123");
assertRows(execute("SELECT k, floatval FROM %s WHERE k = ?", 0), row(0, 123123.123123f));
- execute("INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "123123");
+ execute("INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, floatval FROM %s WHERE k = ?", 0), row(0, 123123.0f));
// strings are also accepted
- execute("INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "\"123123.0\"");
+ execute("INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "\"123123.0\"");
assertRows(execute("SELECT k, floatval FROM %s WHERE k = ?", 0), row(0, 123123.0f));
assertInvalidMessage("Unable to make float from",
- "INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Expected a float value, but got a",
- "INSERT INTO %s (k, floatval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, floatval) VALUES (?, from_json(?))", 0, "true");
// ================ inet ================
- execute("INSERT INTO %s (k, inetval) VALUES (?, fromJson(?))", 0, "\"127.0.0.1\"");
+ execute("INSERT INTO %s (k, inetval) VALUES (?, from_json(?))", 0, "\"127.0.0.1\"");
assertRows(execute("SELECT k, inetval FROM %s WHERE k = ?", 0), row(0, InetAddress.getByName("127.0.0.1")));
- execute("INSERT INTO %s (k, inetval) VALUES (?, fromJson(?))", 0, "\"::1\"");
+ execute("INSERT INTO %s (k, inetval) VALUES (?, from_json(?))", 0, "\"::1\"");
assertRows(execute("SELECT k, inetval FROM %s WHERE k = ?", 0), row(0, InetAddress.getByName("::1")));
assertInvalidMessage("Unable to make inet address from 'xyzz'",
- "INSERT INTO %s (k, inetval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, inetval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Expected a string representation of an inet value, but got a Integer",
- "INSERT INTO %s (k, inetval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, inetval) VALUES (?, from_json(?))", 0, "123");
// ================ int ================
- execute("INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "123123");
+ execute("INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "123123");
assertRows(execute("SELECT k, intval FROM %s WHERE k = ?", 0), row(0, 123123));
// strings are also accepted
- execute("INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "\"123123\"");
+ execute("INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "\"123123\"");
assertRows(execute("SELECT k, intval FROM %s WHERE k = ?", 0), row(0, 123123));
// int overflow (2 ^ 32, or Integer.MAX_INT + 1)
assertInvalidMessage("Expected an int value, but got a",
- "INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "2147483648");
+ "INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "2147483648");
assertInvalidMessage("Expected an int value, but got a",
- "INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "123.456");
+ "INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "123.456");
assertInvalidMessage("Unable to make int from",
- "INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Expected an int value, but got a",
- "INSERT INTO %s (k, intval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, intval) VALUES (?, from_json(?))", 0, "true");
// ================ smallint ================
- execute("INSERT INTO %s (k, smallintval) VALUES (?, fromJson(?))", 0, "32767");
+ execute("INSERT INTO %s (k, smallintval) VALUES (?, from_json(?))", 0, "32767");
assertRows(execute("SELECT k, smallintval FROM %s WHERE k = ?", 0), row(0, (short) 32767));
// strings are also accepted
- execute("INSERT INTO %s (k, smallintval) VALUES (?, fromJson(?))", 0, "\"32767\"");
+ execute("INSERT INTO %s (k, smallintval) VALUES (?, from_json(?))", 0, "\"32767\"");
assertRows(execute("SELECT k, smallintval FROM %s WHERE k = ?", 0), row(0, (short) 32767));
// smallint overflow (Short.MAX_VALUE + 1)
assertInvalidMessage("Unable to make short from",
- "INSERT INTO %s (k, smallintval) VALUES (?, fromJson(?))", 0, "32768");
+ "INSERT INTO %s (k, smallintval) VALUES (?, from_json(?))", 0, "32768");
assertInvalidMessage("Unable to make short from",
- "INSERT INTO %s (k, smallintval) VALUES (?, fromJson(?))", 0, "123.456");
+ "INSERT INTO %s (k, smallintval) VALUES (?, from_json(?))", 0, "123.456");
assertInvalidMessage("Unable to make short from",
- "INSERT INTO %s (k, smallintval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, smallintval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Expected a short value, but got a Boolean",
- "INSERT INTO %s (k, smallintval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, smallintval) VALUES (?, from_json(?))", 0, "true");
// ================ tinyint ================
- execute("INSERT INTO %s (k, tinyintval) VALUES (?, fromJson(?))", 0, "127");
+ execute("INSERT INTO %s (k, tinyintval) VALUES (?, from_json(?))", 0, "127");
assertRows(execute("SELECT k, tinyintval FROM %s WHERE k = ?", 0), row(0, (byte) 127));
// strings are also accepted
- execute("INSERT INTO %s (k, tinyintval) VALUES (?, fromJson(?))", 0, "\"127\"");
+ execute("INSERT INTO %s (k, tinyintval) VALUES (?, from_json(?))", 0, "\"127\"");
assertRows(execute("SELECT k, tinyintval FROM %s WHERE k = ?", 0), row(0, (byte) 127));
// tinyint overflow (Byte.MAX_VALUE + 1)
assertInvalidMessage("Unable to make byte from",
- "INSERT INTO %s (k, tinyintval) VALUES (?, fromJson(?))", 0, "128");
+ "INSERT INTO %s (k, tinyintval) VALUES (?, from_json(?))", 0, "128");
assertInvalidMessage("Unable to make byte from",
- "INSERT INTO %s (k, tinyintval) VALUES (?, fromJson(?))", 0, "123.456");
+ "INSERT INTO %s (k, tinyintval) VALUES (?, from_json(?))", 0, "123.456");
assertInvalidMessage("Unable to make byte from",
- "INSERT INTO %s (k, tinyintval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, tinyintval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Expected a byte value, but got a Boolean",
- "INSERT INTO %s (k, tinyintval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, tinyintval) VALUES (?, from_json(?))", 0, "true");
// ================ text (varchar) ================
- execute("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"\"");
+ execute("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, ""));
- execute("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"abcd\"");
+ execute("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"abcd\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, "abcd"));
- execute("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"some \\\" text\"");
+ execute("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"some \\\" text\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, "some \" text"));
- execute("INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "\"\\u2013\"");
+ execute("INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "\"\\u2013\"");
assertRows(execute("SELECT k, textval FROM %s WHERE k = ?", 0), row(0, "\u2013"));
assertInvalidMessage("Expected a UTF-8 string, but got a Integer",
- "INSERT INTO %s (k, textval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, textval) VALUES (?, from_json(?))", 0, "123");
// ================ time ================
- execute("INSERT INTO %s (k, timeval) VALUES (?, fromJson(?))", 0, "\"07:35:07.000111222\"");
+ execute("INSERT INTO %s (k, timeval) VALUES (?, from_json(?))", 0, "\"07:35:07.000111222\"");
assertRows(execute("SELECT k, timeval FROM %s WHERE k = ?", 0), row(0, TimeSerializer.timeStringToLong("07:35:07.000111222")));
assertInvalidMessage("Expected a string representation of a time value",
- "INSERT INTO %s (k, timeval) VALUES (?, fromJson(?))", 0, "123456");
+ "INSERT INTO %s (k, timeval) VALUES (?, from_json(?))", 0, "123456");
assertInvalidMessage("Unable to coerce 'xyz' to a formatted time",
- "INSERT INTO %s (k, timeval) VALUES (?, fromJson(?))", 0, "\"xyz\"");
+ "INSERT INTO %s (k, timeval) VALUES (?, from_json(?))", 0, "\"xyz\"");
// ================ timestamp ================
- execute("INSERT INTO %s (k, timestampval) VALUES (?, fromJson(?))", 0, "123123123123");
+ execute("INSERT INTO %s (k, timestampval) VALUES (?, from_json(?))", 0, "123123123123");
assertRows(execute("SELECT k, timestampval FROM %s WHERE k = ?", 0), row(0, new Date(123123123123L)));
- execute("INSERT INTO %s (k, timestampval) VALUES (?, fromJson(?))", 0, "\"2014-01-01\"");
+ execute("INSERT INTO %s (k, timestampval) VALUES (?, from_json(?))", 0, "\"2014-01-01\"");
assertRows(execute("SELECT k, timestampval FROM %s WHERE k = ?", 0), row(0, new SimpleDateFormat("y-M-d").parse("2014-01-01")));
assertInvalidMessage("Expected a long or a datestring representation of a timestamp value, but got a Double",
- "INSERT INTO %s (k, timestampval) VALUES (?, fromJson(?))", 0, "123.456");
+ "INSERT INTO %s (k, timestampval) VALUES (?, from_json(?))", 0, "123.456");
assertInvalidMessage("Unable to parse a date/time from 'abcd'",
- "INSERT INTO %s (k, timestampval) VALUES (?, fromJson(?))", 0, "\"abcd\"");
+ "INSERT INTO %s (k, timestampval) VALUES (?, from_json(?))", 0, "\"abcd\"");
// ================ timeuuid ================
- execute("INSERT INTO %s (k, timeuuidval) VALUES (?, fromJson(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
+ execute("INSERT INTO %s (k, timeuuidval) VALUES (?, from_json(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
assertRows(execute("SELECT k, timeuuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- execute("INSERT INTO %s (k, timeuuidval) VALUES (?, fromJson(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
+ execute("INSERT INTO %s (k, timeuuidval) VALUES (?, from_json(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
assertRows(execute("SELECT k, timeuuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
assertInvalidMessage("TimeUUID supports only version 1 UUIDs",
- "INSERT INTO %s (k, timeuuidval) VALUES (?, fromJson(?))", 0, "\"00000000-0000-0000-0000-000000000000\"");
+ "INSERT INTO %s (k, timeuuidval) VALUES (?, from_json(?))", 0, "\"00000000-0000-0000-0000-000000000000\"");
assertInvalidMessage("Expected a string representation of a timeuuid, but got a Integer",
- "INSERT INTO %s (k, timeuuidval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, timeuuidval) VALUES (?, from_json(?))", 0, "123");
// ================ uuidval ================
- execute("INSERT INTO %s (k, uuidval) VALUES (?, fromJson(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
+ execute("INSERT INTO %s (k, uuidval) VALUES (?, from_json(?))", 0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\"");
assertRows(execute("SELECT k, uuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- execute("INSERT INTO %s (k, uuidval) VALUES (?, fromJson(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
+ execute("INSERT INTO %s (k, uuidval) VALUES (?, from_json(?))", 0, "\"6BDDC89A-5644-11E4-97FC-56847AFE9799\"");
assertRows(execute("SELECT k, uuidval FROM %s WHERE k = ?", 0), row(0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
assertInvalidMessage("Unable to make UUID from",
- "INSERT INTO %s (k, uuidval) VALUES (?, fromJson(?))", 0, "\"00000000-0000-0000-zzzz-000000000000\"");
+ "INSERT INTO %s (k, uuidval) VALUES (?, from_json(?))", 0, "\"00000000-0000-0000-zzzz-000000000000\"");
assertInvalidMessage("Expected a string representation of a uuid, but got a Integer",
- "INSERT INTO %s (k, uuidval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, uuidval) VALUES (?, from_json(?))", 0, "123");
// ================ varint ================
- execute("INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "123123123123");
+ execute("INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "123123123123");
assertRows(execute("SELECT k, varintval FROM %s WHERE k = ?", 0), row(0, new BigInteger("123123123123")));
// accept strings for numbers that cannot be represented as longs
- execute("INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "\"1234567890123456789012345678901234567890\"");
+ execute("INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "\"1234567890123456789012345678901234567890\"");
assertRows(execute("SELECT k, varintval FROM %s WHERE k = ?", 0), row(0, new BigInteger("1234567890123456789012345678901234567890")));
assertInvalidMessage("Value '123123.123' is not a valid representation of a varint value",
- "INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "123123.123");
+ "INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "123123.123");
assertInvalidMessage("Value 'xyzz' is not a valid representation of a varint value",
- "INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "\"xyzz\"");
+ "INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "\"xyzz\"");
assertInvalidMessage("Value '' is not a valid representation of a varint value",
- "INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "\"\"");
+ "INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "\"\"");
assertInvalidMessage("Value 'true' is not a valid representation of a varint value",
- "INSERT INTO %s (k, varintval) VALUES (?, fromJson(?))", 0, "true");
+ "INSERT INTO %s (k, varintval) VALUES (?, from_json(?))", 0, "true");
// ================ lists ================
- execute("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[1, 2, 3]");
+ execute("INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[1, 2, 3]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, list(1, 2, 3)));
- execute("INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[]");
+ execute("INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[]");
assertRows(execute("SELECT k, listval FROM %s WHERE k = ?", 0), row(0, null));
assertInvalidMessage("Expected a list, but got a Integer",
- "INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "123");
assertInvalidMessage("Unable to make int from",
- "INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[\"abc\"]");
+ "INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[\"abc\"]");
assertInvalidMessage("Invalid null element in list",
- "INSERT INTO %s (k, listval) VALUES (?, fromJson(?))", 0, "[null]");
+ "INSERT INTO %s (k, listval) VALUES (?, from_json(?))", 0, "[null]");
// frozen
- execute("INSERT INTO %s (k, frozenlistval) VALUES (?, fromJson(?))", 0, "[1, 2, 3]");
+ execute("INSERT INTO %s (k, frozenlistval) VALUES (?, from_json(?))", 0, "[1, 2, 3]");
assertRows(execute("SELECT k, frozenlistval FROM %s WHERE k = ?", 0), row(0, list(1, 2, 3)));
// ================ sets ================
- execute("INSERT INTO %s (k, setval) VALUES (?, fromJson(?))",
+ execute("INSERT INTO %s (k, setval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
// duplicates are okay, just like in CQL
- execute("INSERT INTO %s (k, setval) VALUES (?, fromJson(?))",
+ execute("INSERT INTO %s (k, setval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- execute("INSERT INTO %s (k, setval) VALUES (?, fromJson(?))", 0, "[]");
+ execute("INSERT INTO %s (k, setval) VALUES (?, from_json(?))", 0, "[]");
assertRows(execute("SELECT k, setval FROM %s WHERE k = ?", 0), row(0, null));
assertInvalidMessage("Expected a list (representing a set), but got a Integer",
- "INSERT INTO %s (k, setval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, setval) VALUES (?, from_json(?))", 0, "123");
assertInvalidMessage("Unable to make UUID from",
- "INSERT INTO %s (k, setval) VALUES (?, fromJson(?))", 0, "[\"abc\"]");
+ "INSERT INTO %s (k, setval) VALUES (?, from_json(?))", 0, "[\"abc\"]");
assertInvalidMessage("Invalid null element in set",
- "INSERT INTO %s (k, setval) VALUES (?, fromJson(?))", 0, "[null]");
+ "INSERT INTO %s (k, setval) VALUES (?, from_json(?))", 0, "[null]");
// frozen
- execute("INSERT INTO %s (k, frozensetval) VALUES (?, fromJson(?))",
+ execute("INSERT INTO %s (k, frozensetval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, frozensetval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
- execute("INSERT INTO %s (k, frozensetval) VALUES (?, fromJson(?))",
+ execute("INSERT INTO %s (k, frozensetval) VALUES (?, from_json(?))",
0, "[\"6bddc89a-5644-11e4-97fc-56847afe9799\", \"6bddc89a-5644-11e4-97fc-56847afe9798\"]");
assertRows(execute("SELECT k, frozensetval FROM %s WHERE k = ?", 0),
row(0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))))
);
// ================ maps ================
- execute("INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": 2}");
+ execute("INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": 2}");
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0), row(0, map("a", 1, "b", 2)));
- execute("INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "{}");
+ execute("INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "{}");
assertRows(execute("SELECT k, mapval FROM %s WHERE k = ?", 0), row(0, null));
assertInvalidMessage("Expected a map, but got a Integer",
- "INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "123");
+ "INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "123");
assertInvalidMessage("Invalid ASCII character in string literal",
- "INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "{\"\\u1fff\\u2013\\u33B4\\u2014\": 1}");
+ "INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "{\"\\u1fff\\u2013\\u33B4\\u2014\": 1}");
assertInvalidMessage("Invalid null value in map",
- "INSERT INTO %s (k, mapval) VALUES (?, fromJson(?))", 0, "{\"a\": null}");
+ "INSERT INTO %s (k, mapval) VALUES (?, from_json(?))", 0, "{\"a\": null}");
// frozen
- execute("INSERT INTO %s (k, frozenmapval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": 2}");
+ execute("INSERT INTO %s (k, frozenmapval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": 2}");
assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, map("a", 1, "b", 2)));
- execute("INSERT INTO %s (k, frozenmapval) VALUES (?, fromJson(?))", 0, "{\"b\": 2, \"a\": 1}");
+ execute("INSERT INTO %s (k, frozenmapval) VALUES (?, from_json(?))", 0, "{\"b\": 2, \"a\": 1}");
assertRows(execute("SELECT k, frozenmapval FROM %s WHERE k = ?", 0), row(0, map("a", 1, "b", 2)));
// ================ tuples ================
- execute("INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))", 0, "[1, \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
+ execute("INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))", 0, "[1, \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, tupleval FROM %s WHERE k = ?", 0),
row(0, tuple(1, "foobar", UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))
);
- execute("INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))", 0, "[1, null, \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
+ execute("INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))", 0, "[1, null, \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
assertRows(execute("SELECT k, tupleval FROM %s WHERE k = ?", 0),
row(0, tuple(1, null, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")))
);
assertInvalidMessage("Tuple contains extra items",
- "INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))",
+ "INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))",
0, "[1, \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\", 1, 2, 3]");
assertInvalidMessage("Tuple is missing items",
- "INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))",
+ "INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))",
0, "[1, \"foobar\"]");
assertInvalidMessage("Unable to make int from",
- "INSERT INTO %s (k, tupleval) VALUES (?, fromJson(?))",
+ "INSERT INTO %s (k, tupleval) VALUES (?, from_json(?))",
0, "[\"not an int\", \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]");
// ================ UDTs ================
- execute("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
+ execute("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("bar", "foo"))
);
// ================ duration ================
- execute("INSERT INTO %s (k, durationval) VALUES (?, fromJson(?))", 0, "\"53us\"");
+ execute("INSERT INTO %s (k, durationval) VALUES (?, from_json(?))", 0, "\"53us\"");
assertRows(execute("SELECT k, durationval FROM %s WHERE k = ?", 0), row(0, Duration.newInstance(0, 0, 53000L)));
- execute("INSERT INTO %s (k, durationval) VALUES (?, fromJson(?))", 0, "\"P2W\"");
+ execute("INSERT INTO %s (k, durationval) VALUES (?, from_json(?))", 0, "\"P2W\"");
assertRows(execute("SELECT k, durationval FROM %s WHERE k = ?", 0), row(0, Duration.newInstance(0, 14, 0)));
assertInvalidMessage("Unable to convert 'xyz' to a duration",
- "INSERT INTO %s (k, durationval) VALUES (?, fromJson(?))", 0, "\"xyz\"");
+ "INSERT INTO %s (k, durationval) VALUES (?, from_json(?))", 0, "\"xyz\"");
// order of fields shouldn't matter
- execute("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"a\": 1, \"c\": [\"foo\", \"bar\"]}");
+ execute("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"a\": 1, \"c\": [\"foo\", \"bar\"]}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("bar", "foo"))
);
// test nulls
- execute("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
+ execute("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": null, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"foo\", \"bar\"]}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, null, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("bar", "foo"))
);
// test missing fields
- execute("INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\"}");
+ execute("INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\"}");
assertRows(execute("SELECT k, udtval.a, udtval.b, udtval.c FROM %s WHERE k = ?", 0),
row(0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), null)
);
- assertInvalidMessage("Unknown field", "INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"xxx\": 1}");
+ assertInvalidMessage("Unknown field", "INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"xxx\": 1}");
assertInvalidMessage("Unable to make int from",
- "INSERT INTO %s (k, udtval) VALUES (?, fromJson(?))", 0, "{\"a\": \"foobar\"}");
+ "INSERT INTO %s (k, udtval) VALUES (?, from_json(?))", 0, "{\"a\": \"foobar\"}");
}
@Test
@@ -745,224 +745,224 @@ public class JsonTest extends CQLTester
"udtval frozen<" + typeName + ">," +
"durationval duration)");
- // toJson() can be used out of the selection clause (with literals)
- execute("INSERT INTO %s (k, textval) VALUES (?, toJson(1234))", 0);
+ // to_json() can be used out of the selection clause (with literals)
+ execute("INSERT INTO %s (k, textval) VALUES (?, to_json(1234))", 0);
assertRows(execute("SELECT textval FROM %s WHERE k = ?", 0), row("1234"));
- assertRows(execute("SELECT textval FROM %s WHERE textval = toJson(1234) ALLOW FILTERING"), row("1234"));
- execute("UPDATE %s SET textval = toJson(-1234) WHERE k = ?", 0);
+ assertRows(execute("SELECT textval FROM %s WHERE textval = to_json(1234) ALLOW FILTERING"), row("1234"));
+ execute("UPDATE %s SET textval = to_json(-1234) WHERE k = ?", 0);
assertRows(execute("SELECT textval FROM %s WHERE k = ?", 0), row("-1234"));
- assertRows(execute("SELECT textval FROM %s WHERE textval = toJson(-1234) ALLOW FILTERING"), row("-1234"));
- execute("DELETE FROM %s WHERE k = fromJson(toJson(0))");
+ assertRows(execute("SELECT textval FROM %s WHERE textval = to_json(-1234) ALLOW FILTERING"), row("-1234"));
+ execute("DELETE FROM %s WHERE k = from_json(to_json(0))");
assertEmpty(execute("SELECT textval FROM %s WHERE k = ?", 0));
- // toJson() can be used out of the selection clause (with markers)
- execute("INSERT INTO %s (k, textval) VALUES (?, toJson((int) ?))", 0, 123123);
+ // to_json() can be used out of the selection clause (with markers)
+ execute("INSERT INTO %s (k, textval) VALUES (?, to_json((int) ?))", 0, 123123);
assertRows(execute("SELECT textval FROM %s WHERE k = ?", 0), row("123123"));
- assertRows(execute("SELECT textval FROM %s WHERE textval = toJson((int) ?) ALLOW FILTERING", 123123), row("123123"));
- execute("UPDATE %s SET textval = toJson((int) ?) WHERE k = ?", -123123, 0);
+ assertRows(execute("SELECT textval FROM %s WHERE textval = to_json((int) ?) ALLOW FILTERING", 123123), row("123123"));
+ execute("UPDATE %s SET textval = to_json((int) ?) WHERE k = ?", -123123, 0);
assertRows(execute("SELECT textval FROM %s WHERE k = ?", 0), row("-123123"));
- assertRows(execute("SELECT textval FROM %s WHERE textval = toJson((int) ?) ALLOW FILTERING", -123123), row("-123123"));
- execute("DELETE FROM %s WHERE k = fromJson(toJson((int) ?))", 0);
+ assertRows(execute("SELECT textval FROM %s WHERE textval = to_json((int) ?) ALLOW FILTERING", -123123), row("-123123"));
+ execute("DELETE FROM %s WHERE k = from_json(to_json((int) ?))", 0);
assertEmpty(execute("SELECT textval FROM %s WHERE k = ?", 0));
// ================ ascii ================
execute("INSERT INTO %s (k, asciival) VALUES (?, ?)", 0, "ascii text");
- assertRows(execute("SELECT k, toJson(asciival) FROM %s WHERE k = ?", 0), row(0, "\"ascii text\""));
+ assertRows(execute("SELECT k, to_json(asciival) FROM %s WHERE k = ?", 0), row(0, "\"ascii text\""));
execute("INSERT INTO %s (k, asciival) VALUES (?, ?)", 0, "");
- assertRows(execute("SELECT k, toJson(asciival) FROM %s WHERE k = ?", 0), row(0, "\"\""));
+ assertRows(execute("SELECT k, to_json(asciival) FROM %s WHERE k = ?", 0), row(0, "\"\""));
// ================ bigint ================
execute("INSERT INTO %s (k, bigintval) VALUES (?, ?)", 0, 123123123123L);
- assertRows(execute("SELECT k, toJson(bigintval) FROM %s WHERE k = ?", 0), row(0, "123123123123"));
+ assertRows(execute("SELECT k, to_json(bigintval) FROM %s WHERE k = ?", 0), row(0, "123123123123"));
execute("INSERT INTO %s (k, bigintval) VALUES (?, ?)", 0, 0L);
- assertRows(execute("SELECT k, toJson(bigintval) FROM %s WHERE k = ?", 0), row(0, "0"));
+ assertRows(execute("SELECT k, to_json(bigintval) FROM %s WHERE k = ?", 0), row(0, "0"));
execute("INSERT INTO %s (k, bigintval) VALUES (?, ?)", 0, -123123123123L);
- assertRows(execute("SELECT k, toJson(bigintval) FROM %s WHERE k = ?", 0), row(0, "-123123123123"));
+ assertRows(execute("SELECT k, to_json(bigintval) FROM %s WHERE k = ?", 0), row(0, "-123123123123"));
// ================ blob ================
execute("INSERT INTO %s (k, blobval) VALUES (?, ?)", 0, ByteBufferUtil.bytes(1));
- assertRows(execute("SELECT k, toJson(blobval) FROM %s WHERE k = ?", 0), row(0, "\"0x00000001\""));
+ assertRows(execute("SELECT k, to_json(blobval) FROM %s WHERE k = ?", 0), row(0, "\"0x00000001\""));
execute("INSERT INTO %s (k, blobval) VALUES (?, ?)", 0, ByteBufferUtil.EMPTY_BYTE_BUFFER);
- assertRows(execute("SELECT k, toJson(blobval) FROM %s WHERE k = ?", 0), row(0, "\"0x\""));
+ assertRows(execute("SELECT k, to_json(blobval) FROM %s WHERE k = ?", 0), row(0, "\"0x\""));
// ================ boolean ================
execute("INSERT INTO %s (k, booleanval) VALUES (?, ?)", 0, true);
- assertRows(execute("SELECT k, toJson(booleanval) FROM %s WHERE k = ?", 0), row(0, "true"));
+ assertRows(execute("SELECT k, to_json(booleanval) FROM %s WHERE k = ?", 0), row(0, "true"));
execute("INSERT INTO %s (k, booleanval) VALUES (?, ?)", 0, false);
- assertRows(execute("SELECT k, toJson(booleanval) FROM %s WHERE k = ?", 0), row(0, "false"));
+ assertRows(execute("SELECT k, to_json(booleanval) FROM %s WHERE k = ?", 0), row(0, "false"));
// ================ date ================
execute("INSERT INTO %s (k, dateval) VALUES (?, ?)", 0, SimpleDateSerializer.dateStringToDays("1987-03-23"));
- assertRows(execute("SELECT k, toJson(dateval) FROM %s WHERE k = ?", 0), row(0, "\"1987-03-23\""));
+ assertRows(execute("SELECT k, to_json(dateval) FROM %s WHERE k = ?", 0), row(0, "\"1987-03-23\""));
// ================ decimal ================
execute("INSERT INTO %s (k, decimalval) VALUES (?, ?)", 0, new BigDecimal("123123.123123"));
- assertRows(execute("SELECT k, toJson(decimalval) FROM %s WHERE k = ?", 0), row(0, "123123.123123"));
+ assertRows(execute("SELECT k, to_json(decimalval) FROM %s WHERE k = ?", 0), row(0, "123123.123123"));
execute("INSERT INTO %s (k, decimalval) VALUES (?, ?)", 0, new BigDecimal("-1.23E-12"));
- assertRows(execute("SELECT k, toJson(decimalval) FROM %s WHERE k = ?", 0), row(0, "-1.23E-12"));
+ assertRows(execute("SELECT k, to_json(decimalval) FROM %s WHERE k = ?", 0), row(0, "-1.23E-12"));
// ================ double ================
execute("INSERT INTO %s (k, doubleval) VALUES (?, ?)", 0, 123123.123123d);
- assertRows(execute("SELECT k, toJson(doubleval) FROM %s WHERE k = ?", 0), row(0, "123123.123123"));
+ assertRows(execute("SELECT k, to_json(doubleval) FROM %s WHERE k = ?", 0), row(0, "123123.123123"));
execute("INSERT INTO %s (k, doubleval) VALUES (?, ?)", 0, 123123d);
- assertRows(execute("SELECT k, toJson(doubleval) FROM %s WHERE k = ?", 0), row(0, "123123.0"));
+ assertRows(execute("SELECT k, to_json(doubleval) FROM %s WHERE k = ?", 0), row(0, "123123.0"));
// ================ float ================
execute("INSERT INTO %s (k, floatval) VALUES (?, ?)", 0, 123.123f);
- assertRows(execute("SELECT k, toJson(floatval) FROM %s WHERE k = ?", 0), row(0, "123.123"));
+ assertRows(execute("SELECT k, to_json(floatval) FROM %s WHERE k = ?", 0), row(0, "123.123"));
execute("INSERT INTO %s (k, floatval) VALUES (?, ?)", 0, 123123f);
- assertRows(execute("SELECT k, toJson(floatval) FROM %s WHERE k = ?", 0), row(0, "123123.0"));
+ assertRows(execute("SELECT k, to_json(floatval) FROM %s WHERE k = ?", 0), row(0, "123123.0"));
// ================ inet ================
execute("INSERT INTO %s (k, inetval) VALUES (?, ?)", 0, InetAddress.getByName("127.0.0.1"));
- assertRows(execute("SELECT k, toJson(inetval) FROM %s WHERE k = ?", 0), row(0, "\"127.0.0.1\""));
+ assertRows(execute("SELECT k, to_json(inetval) FROM %s WHERE k = ?", 0), row(0, "\"127.0.0.1\""));
execute("INSERT INTO %s (k, inetval) VALUES (?, ?)", 0, InetAddress.getByName("::1"));
- assertRows(execute("SELECT k, toJson(inetval) FROM %s WHERE k = ?", 0), row(0, "\"0:0:0:0:0:0:0:1\""));
+ assertRows(execute("SELECT k, to_json(inetval) FROM %s WHERE k = ?", 0), row(0, "\"0:0:0:0:0:0:0:1\""));
// ================ int ================
execute("INSERT INTO %s (k, intval) VALUES (?, ?)", 0, 123123);
- assertRows(execute("SELECT k, toJson(intval) FROM %s WHERE k = ?", 0), row(0, "123123"));
+ assertRows(execute("SELECT k, to_json(intval) FROM %s WHERE k = ?", 0), row(0, "123123"));
execute("INSERT INTO %s (k, intval) VALUES (?, ?)", 0, 0);
- assertRows(execute("SELECT k, toJson(intval) FROM %s WHERE k = ?", 0), row(0, "0"));
+ assertRows(execute("SELECT k, to_json(intval) FROM %s WHERE k = ?", 0), row(0, "0"));
execute("INSERT INTO %s (k, intval) VALUES (?, ?)", 0, -123123);
- assertRows(execute("SELECT k, toJson(intval) FROM %s WHERE k = ?", 0), row(0, "-123123"));
+ assertRows(execute("SELECT k, to_json(intval) FROM %s WHERE k = ?", 0), row(0, "-123123"));
// ================ smallint ================
execute("INSERT INTO %s (k, smallintval) VALUES (?, ?)", 0, (short) 32767);
- assertRows(execute("SELECT k, toJson(smallintval) FROM %s WHERE k = ?", 0), row(0, "32767"));
+ assertRows(execute("SELECT k, to_json(smallintval) FROM %s WHERE k = ?", 0), row(0, "32767"));
execute("INSERT INTO %s (k, smallintval) VALUES (?, ?)", 0, (short) 0);
- assertRows(execute("SELECT k, toJson(smallintval) FROM %s WHERE k = ?", 0), row(0, "0"));
+ assertRows(execute("SELECT k, to_json(smallintval) FROM %s WHERE k = ?", 0), row(0, "0"));
execute("INSERT INTO %s (k, smallintval) VALUES (?, ?)", 0, (short) -32768);
- assertRows(execute("SELECT k, toJson(smallintval) FROM %s WHERE k = ?", 0), row(0, "-32768"));
+ assertRows(execute("SELECT k, to_json(smallintval) FROM %s WHERE k = ?", 0), row(0, "-32768"));
// ================ tinyint ================
execute("INSERT INTO %s (k, tinyintval) VALUES (?, ?)", 0, (byte) 127);
- assertRows(execute("SELECT k, toJson(tinyintval) FROM %s WHERE k = ?", 0), row(0, "127"));
+ assertRows(execute("SELECT k, to_json(tinyintval) FROM %s WHERE k = ?", 0), row(0, "127"));
execute("INSERT INTO %s (k, tinyintval) VALUES (?, ?)", 0, (byte) 0);
- assertRows(execute("SELECT k, toJson(tinyintval) FROM %s WHERE k = ?", 0), row(0, "0"));
+ assertRows(execute("SELECT k, to_json(tinyintval) FROM %s WHERE k = ?", 0), row(0, "0"));
execute("INSERT INTO %s (k, tinyintval) VALUES (?, ?)", 0, (byte) -128);
- assertRows(execute("SELECT k, toJson(tinyintval) FROM %s WHERE k = ?", 0), row(0, "-128"));
+ assertRows(execute("SELECT k, to_json(tinyintval) FROM %s WHERE k = ?", 0), row(0, "-128"));
// ================ text (varchar) ================
execute("INSERT INTO %s (k, textval) VALUES (?, ?)", 0, "");
- assertRows(execute("SELECT k, toJson(textval) FROM %s WHERE k = ?", 0), row(0, "\"\""));
+ assertRows(execute("SELECT k, to_json(textval) FROM %s WHERE k = ?", 0), row(0, "\"\""));
execute("INSERT INTO %s (k, textval) VALUES (?, ?)", 0, "abcd");
- assertRows(execute("SELECT k, toJson(textval) FROM %s WHERE k = ?", 0), row(0, "\"abcd\""));
+ assertRows(execute("SELECT k, to_json(textval) FROM %s WHERE k = ?", 0), row(0, "\"abcd\""));
execute("INSERT INTO %s (k, textval) VALUES (?, ?)", 0, "\u8422");
- assertRows(execute("SELECT k, toJson(textval) FROM %s WHERE k = ?", 0), row(0, "\"\u8422\""));
+ assertRows(execute("SELECT k, to_json(textval) FROM %s WHERE k = ?", 0), row(0, "\"\u8422\""));
execute("INSERT INTO %s (k, textval) VALUES (?, ?)", 0, "\u0000");
- assertRows(execute("SELECT k, toJson(textval) FROM %s WHERE k = ?", 0), row(0, "\"\\u0000\""));
+ assertRows(execute("SELECT k, to_json(textval) FROM %s WHERE k = ?", 0), row(0, "\"\\u0000\""));
// ================ time ================
execute("INSERT INTO %s (k, timeval) VALUES (?, ?)", 0, 123L);
- assertRows(execute("SELECT k, toJson(timeval) FROM %s WHERE k = ?", 0), row(0, "\"00:00:00.000000123\""));
+ assertRows(execute("SELECT k, to_json(timeval) FROM %s WHERE k = ?", 0), row(0, "\"00:00:00.000000123\""));
- execute("INSERT INTO %s (k, timeval) VALUES (?, fromJson(?))", 0, "\"07:35:07.000111222\"");
- assertRows(execute("SELECT k, toJson(timeval) FROM %s WHERE k = ?", 0), row(0, "\"07:35:07.000111222\""));
+ execute("INSERT INTO %s (k, timeval) VALUES (?, from_json(?))", 0, "\"07:35:07.000111222\"");
+ assertRows(execute("SELECT k, to_json(timeval) FROM %s WHERE k = ?", 0), row(0, "\"07:35:07.000111222\""));
// ================ timestamp ================
SimpleDateFormat sdf = new SimpleDateFormat("y-M-d");
sdf.setTimeZone(TimeZone.getTimeZone("UDT"));
execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, sdf.parse("2014-01-01"));
- assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000Z\""));
+ assertRows(execute("SELECT k, to_json(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000Z\""));
// ================ timeuuid ================
execute("INSERT INTO %s (k, timeuuidval) VALUES (?, ?)", 0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"));
- assertRows(execute("SELECT k, toJson(timeuuidval) FROM %s WHERE k = ?", 0), row(0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\""));
+ assertRows(execute("SELECT k, to_json(timeuuidval) FROM %s WHERE k = ?", 0), row(0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\""));
// ================ uuidval ================
execute("INSERT INTO %s (k, uuidval) VALUES (?, ?)", 0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"));
- assertRows(execute("SELECT k, toJson(uuidval) FROM %s WHERE k = ?", 0), row(0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\""));
+ assertRows(execute("SELECT k, to_json(uuidval) FROM %s WHERE k = ?", 0), row(0, "\"6bddc89a-5644-11e4-97fc-56847afe9799\""));
// ================ varint ================
execute("INSERT INTO %s (k, varintval) VALUES (?, ?)", 0, new BigInteger("123123123123123123123"));
- assertRows(execute("SELECT k, toJson(varintval) FROM %s WHERE k = ?", 0), row(0, "123123123123123123123"));
+ assertRows(execute("SELECT k, to_json(varintval) FROM %s WHERE k = ?", 0), row(0, "123123123123123123123"));
// ================ lists ================
execute("INSERT INTO %s (k, listval) VALUES (?, ?)", 0, list(1, 2, 3));
- assertRows(execute("SELECT k, toJson(listval) FROM %s WHERE k = ?", 0), row(0, "[1, 2, 3]"));
+ assertRows(execute("SELECT k, to_json(listval) FROM %s WHERE k = ?", 0), row(0, "[1, 2, 3]"));
execute("INSERT INTO %s (k, listval) VALUES (?, ?)", 0, list());
- assertRows(execute("SELECT k, toJson(listval) FROM %s WHERE k = ?", 0), row(0, "null"));
+ assertRows(execute("SELECT k, to_json(listval) FROM %s WHERE k = ?", 0), row(0, "null"));
// frozen
execute("INSERT INTO %s (k, frozenlistval) VALUES (?, ?)", 0, list(1, 2, 3));
- assertRows(execute("SELECT k, toJson(frozenlistval) FROM %s WHERE k = ?", 0), row(0, "[1, 2, 3]"));
+ assertRows(execute("SELECT k, to_json(frozenlistval) FROM %s WHERE k = ?", 0), row(0, "[1, 2, 3]"));
// ================ sets ================
execute("INSERT INTO %s (k, setval) VALUES (?, ?)",
0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))));
- assertRows(execute("SELECT k, toJson(setval) FROM %s WHERE k = ?", 0),
+ assertRows(execute("SELECT k, to_json(setval) FROM %s WHERE k = ?", 0),
row(0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]")
);
execute("INSERT INTO %s (k, setval) VALUES (?, ?)", 0, set());
- assertRows(execute("SELECT k, toJson(setval) FROM %s WHERE k = ?", 0), row(0, "null"));
+ assertRows(execute("SELECT k, to_json(setval) FROM %s WHERE k = ?", 0), row(0, "null"));
// frozen
execute("INSERT INTO %s (k, frozensetval) VALUES (?, ?)",
0, set(UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9798"), (UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"))));
- assertRows(execute("SELECT k, toJson(frozensetval) FROM %s WHERE k = ?", 0),
+ assertRows(execute("SELECT k, to_json(frozensetval) FROM %s WHERE k = ?", 0),
row(0, "[\"6bddc89a-5644-11e4-97fc-56847afe9798\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]")
);
// ================ maps ================
execute("INSERT INTO %s (k, mapval) VALUES (?, ?)", 0, map("a", 1, "b", 2));
- assertRows(execute("SELECT k, toJson(mapval) FROM %s WHERE k = ?", 0), row(0, "{\"a\": 1, \"b\": 2}"));
+ assertRows(execute("SELECT k, to_json(mapval) FROM %s WHERE k = ?", 0), row(0, "{\"a\": 1, \"b\": 2}"));
execute("INSERT INTO %s (k, mapval) VALUES (?, ?)", 0, map());
- assertRows(execute("SELECT k, toJson(mapval) FROM %s WHERE k = ?", 0), row(0, "null"));
+ assertRows(execute("SELECT k, to_json(mapval) FROM %s WHERE k = ?", 0), row(0, "null"));
// frozen
execute("INSERT INTO %s (k, frozenmapval) VALUES (?, ?)", 0, map("a", 1, "b", 2));
- assertRows(execute("SELECT k, toJson(frozenmapval) FROM %s WHERE k = ?", 0), row(0, "{\"a\": 1, \"b\": 2}"));
+ assertRows(execute("SELECT k, to_json(frozenmapval) FROM %s WHERE k = ?", 0), row(0, "{\"a\": 1, \"b\": 2}"));
// ================ tuples ================
execute("INSERT INTO %s (k, tupleval) VALUES (?, ?)", 0, tuple(1, "foobar", UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799")));
- assertRows(execute("SELECT k, toJson(tupleval) FROM %s WHERE k = ?", 0),
+ assertRows(execute("SELECT k, to_json(tupleval) FROM %s WHERE k = ?", 0),
row(0, "[1, \"foobar\", \"6bddc89a-5644-11e4-97fc-56847afe9799\"]")
);
execute("INSERT INTO %s (k, tupleval) VALUES (?, ?)", 0, tuple(1, "foobar", null));
- assertRows(execute("SELECT k, toJson(tupleval) FROM %s WHERE k = ?", 0),
+ assertRows(execute("SELECT k, to_json(tupleval) FROM %s WHERE k = ?", 0),
row(0, "[1, \"foobar\", null]")
);
// ================ UDTs ================
execute("INSERT INTO %s (k, udtval) VALUES (?, {a: ?, b: ?, c: ?})", 0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"), set("foo", "bar"));
- assertRows(execute("SELECT k, toJson(udtval) FROM %s WHERE k = ?", 0),
+ assertRows(execute("SELECT k, to_json(udtval) FROM %s WHERE k = ?", 0),
row(0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": [\"bar\", \"foo\"]}")
);
execute("INSERT INTO %s (k, udtval) VALUES (?, {a: ?, b: ?})", 0, 1, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"));
- assertRows(execute("SELECT k, toJson(udtval) FROM %s WHERE k = ?", 0),
+ assertRows(execute("SELECT k, to_json(udtval) FROM %s WHERE k = ?", 0),
row(0, "{\"a\": 1, \"b\": \"6bddc89a-5644-11e4-97fc-56847afe9799\", \"c\": null}")
);
// ================ duration ================
execute("INSERT INTO %s (k, durationval) VALUES (?, 12µs)", 0);
- assertRows(execute("SELECT k, toJson(durationval) FROM %s WHERE k = ?", 0), row(0, "\"12us\""));
+ assertRows(execute("SELECT k, to_json(durationval) FROM %s WHERE k = ?", 0), row(0, "\"12us\""));
execute("INSERT INTO %s (k, durationval) VALUES (?, P1Y1M2DT10H5M)", 0);
- assertRows(execute("SELECT k, toJson(durationval) FROM %s WHERE k = ?", 0), row(0, "\"1y1mo2d10h5m\""));
+ assertRows(execute("SELECT k, to_json(durationval) FROM %s WHERE k = ?", 0), row(0, "\"1y1mo2d10h5m\""));
}
@Test
@@ -1036,8 +1036,8 @@ public class JsonTest extends CQLTester
row("{\"foo\": 2}")
);
- assertRows(execute("SELECT JSON toJson(blobAsInt(intAsBlob(v))) FROM %s LIMIT 1"),
- row("{\"system.tojson(system.blobasint(system.intasblob(v)))\": \"0\"}")
+ assertRows(execute("SELECT JSON to_json(blob_as_int(int_as_blob(v))) FROM %s LIMIT 1"),
+ row("{\"system.to_json(system.blob_as_int(system.int_as_blob(v)))\": \"0\"}")
);
}
@@ -1369,11 +1369,11 @@ public class JsonTest extends CQLTester
};
ExecutorService executor = Executors.newFixedThreadPool(numThreads);
- List<Future> futures = new ArrayList<>();
+ List<Future<?>> futures = new ArrayList<>();
for (int i = 0; i < numThreads; i++)
futures.add(executor.submit(worker));
- for (Future future : futures)
+ for (Future<?> future : futures)
future.get(30, TimeUnit.SECONDS);
executor.shutdown();
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index 34b805dc9f..77c611be1a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@ -1184,39 +1184,39 @@ public class SecondaryIndexTest extends CQLTester
beforeAndAfterFlush(() -> {
// Test clustering columns restrictions
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) = (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) = (text_as_blob(''));"));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) IN ((textAsBlob('')), (textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) IN ((text_as_blob('')), (text_as_blob('1')));"),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("1")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) <= (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) <= (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) < (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) < (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('') AND c < textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('') AND c < text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) > (textAsBlob('')) AND (c) < (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) > (text_as_blob('')) AND (c) < (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"));
});
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
@@ -1224,50 +1224,50 @@ public class SecondaryIndexTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) = (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) = (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) IN ((textAsBlob('')), (textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) IN ((text_as_blob('')), (text_as_blob('1')));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) <= (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) <= (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) < (textAsBlob('')) AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) < (text_as_blob('')) AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('') AND c < textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('') AND c < text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob('')) AND c < textAsBlob('') AND v = textAsBlob('1') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob('')) AND c < text_as_blob('') AND v = text_as_blob('1') ALLOW FILTERING;"));
// Test restrictions on non-primary key value
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('');"));
});
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
@@ -1275,7 +1275,7 @@ public class SecondaryIndexTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('');"),
row(bytes("foo123"), bytes("3"), EMPTY_BYTE_BUFFER));
});
}
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/TimestampTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/TimestampTest.java
index 7c6cd8f9ea..94baf82e53 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/TimestampTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TimestampTest.java
@@ -71,7 +71,7 @@ public class TimestampTest extends CQLTester
// wrap writetime(), ttl() in other functions (test for CASSANDRA-8451)
- res = getRows(execute("SELECT k, c, blobAsBigint(bigintAsBlob(writetime(c))), ttl(c) FROM %s"));
+ res = getRows(execute("SELECT k, c, blob_as_bigint(bigint_as_blob(writetime(c))), ttl(c) FROM %s"));
Assert.assertEquals(2, res.length);
for (Object[] r : res)
@@ -83,7 +83,7 @@ public class TimestampTest extends CQLTester
assertTrue(r[3] instanceof Integer || r[2] instanceof Long);
}
- res = getRows(execute("SELECT k, c, writetime(c), blobAsInt(intAsBlob(ttl(c))) FROM %s"));
+ res = getRows(execute("SELECT k, c, writetime(c), blob_as_int(int_as_blob(ttl(c))) FROM %s"));
Assert.assertEquals(2, res.length);
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 e29389fc95..133ed4ea7a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TimeuuidTest.java
@@ -56,17 +56,17 @@ public class TimeuuidTest extends CQLTester
assertRowCount(execute("SELECT * FROM %s WHERE k = 0 AND t = ?", rows[0][1]), 1);
assertInvalidMessage("k cannot be passed as argument 0 of function",
- "SELECT minTimeuuid(k) FROM %s WHERE k = 0 AND t = ?", rows[0][1]);
+ "SELECT min_timeuuid(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 toTimestamp(t), toUnixTimestamp(t) FROM %s WHERE k = 0 AND t = ?", rows[i][1]),
+ assertRows(execute("SELECT to_timestamp(t), to_unix_timestamp(t) FROM %s WHERE k = 0 AND t = ?", rows[i][1]),
row(new Date(timestamp), timestamp));
}
- assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1234567) AND t < minTimeuuid('2012-11-07 18:18:22-0800')"));
- assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1564830182000) AND t < minTimeuuid('2012-11-07 18:18:22-0800')"));
+ assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > max_timeuuid(1234567) AND t < min_timeuuid('2012-11-07 18:18:22-0800')"));
+ assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > max_timeuuid(1564830182000) AND t < min_timeuuid('2012-11-07 18:18:22-0800')"));
}
/**
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 95aaf88da0..119a0fe0f5 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/TypeTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/TypeTest.java
@@ -49,8 +49,8 @@ public class TypeTest extends CQLTester
{
createTable("CREATE TABLE %s (a int, b timestamp, c bigint, d varint, PRIMARY KEY (a, b, c, d))");
- 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())");
+ execute("INSERT INTO %s (a, b, c, d) VALUES (0, to_unix_timestamp(now()), to_timestamp(now()), to_timestamp(now()))");
+ UntypedResultSet results = execute("SELECT * FROM %s WHERE a=0 AND b <= to_unix_timestamp(now())");
assertEquals(1, results.size());
}
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java
index f65f2f6b19..9681827493 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java
@@ -311,14 +311,14 @@ public class UFAuthTest extends CQLTester
public void systemFunctionsRequireNoExplicitPrivileges() throws Throwable
{
// with terminal arguments, so evaluated at prepare time
- String cql = String.format("UPDATE %s SET v2 = 0 WHERE k = blobasint(intasblob(0)) and v1 = 0",
+ String cql = String.format("UPDATE %s SET v2 = 0 WHERE k = blob_as_int(int_as_blob(0)) and v1 = 0",
KEYSPACE + "." + currentTable());
getStatement(cql).authorize(clientState);
// with non-terminal arguments, so evaluated at execution
String functionName = createSimpleFunction();
grantExecuteOnFunction(functionName);
- cql = String.format("UPDATE %s SET v2 = 0 WHERE k = blobasint(intasblob(%s)) and v1 = 0",
+ cql = String.format("UPDATE %s SET v2 = 0 WHERE k = blob_as_int(int_as_blob(%s)) and v1 = 0",
KEYSPACE + "." + currentTable(),
functionCall(functionName));
getStatement(cql).authorize(clientState);
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java
index bd1383eb11..1a9e6d2e20 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java
@@ -438,7 +438,7 @@ public class UFTest extends CQLTester
execute("DROP FUNCTION IF EXISTS " + fSin);
// can't drop native functions
- assertInvalidMessage("System keyspace 'system' is not user-modifiable", "DROP FUNCTION totimestamp");
+ assertInvalidMessage("System keyspace 'system' is not user-modifiable", "DROP FUNCTION to_timestamp");
assertInvalidMessage("System keyspace 'system' is not user-modifiable", "DROP FUNCTION uuid");
// sin() no longer exists
@@ -665,7 +665,7 @@ public class UFTest extends CQLTester
@Test
public void testFunctionInSystemKS() throws Throwable
{
- execute("CREATE OR REPLACE FUNCTION " + KEYSPACE + ".totimestamp(val timeuuid) " +
+ execute("CREATE OR REPLACE FUNCTION " + KEYSPACE + ".to_timestamp(val timeuuid) " +
"RETURNS NULL ON NULL INPUT " +
"RETURNS timestamp " +
"LANGUAGE JAVA\n" +
@@ -679,7 +679,7 @@ public class UFTest extends CQLTester
"LANGUAGE JAVA\n" +
"AS 'return null;';");
assertInvalidMessage("System keyspace 'system' is not user-modifiable",
- "CREATE OR REPLACE FUNCTION system.totimestamp(val timeuuid) " +
+ "CREATE OR REPLACE FUNCTION system.to_timestamp(val timeuuid) " +
"RETURNS NULL ON NULL INPUT " +
"RETURNS timestamp " +
"LANGUAGE JAVA\n" +
@@ -696,7 +696,7 @@ public class UFTest extends CQLTester
"LANGUAGE JAVA\n" +
"AS 'return null;';");
assertInvalidMessage("System keyspace 'system' is not user-modifiable",
- "CREATE OR REPLACE FUNCTION totimestamp(val timeuuid) " +
+ "CREATE OR REPLACE FUNCTION to_timestamp(val timeuuid) " +
"RETURNS NULL ON NULL INPUT " +
"RETURNS timestamp " +
"LANGUAGE JAVA\n" +
@@ -907,7 +907,7 @@ public class UFTest extends CQLTester
public void testEmptyString() throws Throwable
{
createTable("CREATE TABLE %s (key int primary key, sval text, aval ascii, bval blob, empty_int int)");
- execute("INSERT INTO %s (key, sval, aval, bval, empty_int) VALUES (?, ?, ?, ?, blobAsInt(0x))", 1, "", "", ByteBuffer.allocate(0));
+ execute("INSERT INTO %s (key, sval, aval, bval, empty_int) VALUES (?, ?, ?, ?, blob_as_int(0x))", 1, "", "", ByteBuffer.allocate(0));
String fNameSRC = createFunction(KEYSPACE_PER_TEST, "text",
"CREATE OR REPLACE FUNCTION %s(val text) " +
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 71723b0a35..9092f9456e 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/OverflowTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/OverflowTest.java
@@ -170,8 +170,8 @@ public class OverflowTest extends CQLTester
{
createTable("CREATE TABLE %s (k int PRIMARY KEY, i varint, b blob)");
- execute("INSERT INTO %s (k, i, b) VALUES (0, blobAsVarint(bigintAsBlob(3)), textAsBlob('foobar'))");
- assertRows(execute("SELECT i, blobAsText(b) FROM %s WHERE k = 0"),
+ execute("INSERT INTO %s (k, i, b) VALUES (0, blob_as_varint(bigint_as_blob(3)), text_as_blob('foobar'))");
+ assertRows(execute("SELECT i, blob_as_text(b) FROM %s WHERE k = 0"),
row(BigInteger.valueOf(3), "foobar"));
}
@@ -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 toTimestamp(t) FROM %s WHERE k=0"));
+ Object[][] rows = getRows(execute("SELECT to_timestamp(t) FROM %s WHERE k=0"));
assertNull(rows[0][0]);
}
@@ -288,9 +288,9 @@ public class OverflowTest extends CQLTester
createTable("CREATE TABLE %s (k int PRIMARY KEY, v int)");
// A blob that is not 4 bytes should be rejected
- assertInvalid("INSERT INTO %s (k, v) VALUES (0, blobAsInt(0x01))");
+ assertInvalid("INSERT INTO %s (k, v) VALUES (0, blob_as_int(0x01))");
- execute("INSERT INTO %s (k, v) VALUES (0, blobAsInt(0x00000001))");
+ execute("INSERT INTO %s (k, v) VALUES (0, blob_as_int(0x00000001))");
assertRows(execute("select v from %s where k=0"), row(1));
}
}
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
index b078694dd6..fb37f3f5c8 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/AggregationTest.java
@@ -477,25 +477,25 @@ public class AggregationTest extends CQLTester
"LANGUAGE JAVA " +
"AS 'return Double.valueOf(Math.copySign(magnitude, sign));';");
- assertColumnNames(execute("SELECT max(a), max(toUnixTimestamp(b)) FROM %s"), "system.max(a)", "system.max(system.tounixtimestamp(b))");
- assertRows(execute("SELECT max(a), max(toUnixTimestamp(b)) FROM %s"), row(null, null));
- assertColumnNames(execute("SELECT max(a), toUnixTimestamp(max(b)) FROM %s"), "system.max(a)", "system.tounixtimestamp(system.max(b))");
- assertRows(execute("SELECT max(a), toUnixTimestamp(max(b)) FROM %s"), row(null, null));
+ assertColumnNames(execute("SELECT max(a), max(to_unix_timestamp(b)) FROM %s"), "system.max(a)", "system.max(system.to_unix_timestamp(b))");
+ assertRows(execute("SELECT max(a), max(to_unix_timestamp(b)) FROM %s"), row(null, null));
+ assertColumnNames(execute("SELECT max(a), to_unix_timestamp(max(b)) FROM %s"), "system.max(a)", "system.to_unix_timestamp(system.max(b))");
+ assertRows(execute("SELECT max(a), to_unix_timestamp(max(b)) FROM %s"), row(null, null));
assertColumnNames(execute("SELECT max(" + copySign + "(c, d)) FROM %s"), "system.max(" + copySign + "(c, d))");
assertRows(execute("SELECT max(" + copySign + "(c, d)) FROM %s"), row((Object) null));
- execute("INSERT INTO %s (a, b, c, d) VALUES (1, maxTimeuuid('2011-02-03 04:05:00+0000'), -1.2, 2.1)");
- execute("INSERT INTO %s (a, b, c, d) VALUES (2, maxTimeuuid('2011-02-03 04:06:00+0000'), 1.3, -3.4)");
- execute("INSERT INTO %s (a, b, c, d) VALUES (3, maxTimeuuid('2011-02-03 04:10:00+0000'), 1.4, 1.2)");
+ execute("INSERT INTO %s (a, b, c, d) VALUES (1, max_timeuuid('2011-02-03 04:05:00+0000'), -1.2, 2.1)");
+ execute("INSERT INTO %s (a, b, c, d) VALUES (2, max_timeuuid('2011-02-03 04:06:00+0000'), 1.3, -3.4)");
+ execute("INSERT INTO %s (a, b, c, d) VALUES (3, max_timeuuid('2011-02-03 04:10:00+0000'), 1.4, 1.2)");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = format.parse("2011-02-03 04:10:00");
date = DateUtils.truncate(date, Calendar.MILLISECOND);
- assertRows(execute("SELECT max(a), max(toUnixTimestamp(b)) FROM %s"), row(3, date.getTime()));
- assertRows(execute("SELECT max(a), toUnixTimestamp(max(b)) FROM %s"), row(3, date.getTime()));
+ assertRows(execute("SELECT max(a), max(to_unix_timestamp(b)) FROM %s"), row(3, date.getTime()));
+ assertRows(execute("SELECT max(a), to_unix_timestamp(max(b)) FROM %s"), row(3, date.getTime()));
assertRows(execute("SELECT " + copySign + "(max(c), min(c)) FROM %s"), row(-1.4));
assertRows(execute("SELECT " + copySign + "(c, d) FROM %s"), row(1.2), row(-1.3), row(1.4));
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit1Test.java b/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit1Test.java
index 80bf51c03f..214d7766c3 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit1Test.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit1Test.java
@@ -778,11 +778,11 @@ public class CompactStorageSplit1Test extends CQLTester
execute("INSERT INTO %s (pk, v) VALUES (?, ?)", bytes("foo123"), bytes("1"));
// Test restrictions on non-primary key value
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('');"));
execute("INSERT INTO %s (pk, v) VALUES (?, ?)", bytes("foo124"), EMPTY_BYTE_BUFFER);
- assertRows(execute("SELECT * FROM %s WHERE v = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE v = text_as_blob('');"),
row(bytes("foo124"), EMPTY_BYTE_BUFFER));
}
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit2Test.java b/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit2Test.java
index e399feb103..1c4feb3840 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit2Test.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/CompactStorageSplit2Test.java
@@ -1639,49 +1639,49 @@ public class CompactStorageSplit2Test extends CQLTester
beforeAndAfterFlush(() -> {
- assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk = textAsBlob('');");
- assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk IN (textAsBlob(''), textAsBlob('1'));");
+ assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk = text_as_blob('');");
+ assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk IN (text_as_blob(''), text_as_blob('1'));");
assertInvalidMessage("Key may not be empty",
"INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
EMPTY_BYTE_BUFFER, bytes("2"), bytes("2"));
// Test clustering columns restrictions
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) = (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) = (text_as_blob(''));"));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) IN ((textAsBlob('')), (textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) IN ((text_as_blob('')), (text_as_blob('1')));"),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) > (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) > (text_as_blob(''));"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob(''));"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) <= (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) <= (text_as_blob(''));"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) < (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) < (text_as_blob(''));"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('') AND c < text_as_blob('');"));
});
if (options.contains("COMPACT"))
@@ -1696,60 +1696,60 @@ public class CompactStorageSplit2Test extends CQLTester
bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4"));
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) = (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) = (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) IN ((textAsBlob('')), (textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) IN ((text_as_blob('')), (text_as_blob('1')));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) > (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) > (text_as_blob(''));"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) <= (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) <= (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) < (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) < (text_as_blob(''));"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('') AND c < text_as_blob('');"));
});
}
// Test restrictions on non-primary key value
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('') ALLOW FILTERING;"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
bytes("foo123"), bytes("3"), EMPTY_BYTE_BUFFER);
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('') ALLOW FILTERING;"),
row(bytes("foo123"), bytes("3"), EMPTY_BYTE_BUFFER));
});
}
@@ -1764,76 +1764,76 @@ public class CompactStorageSplit2Test extends CQLTester
beforeAndAfterFlush(() -> {
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) = (textAsBlob('1'), textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) = (text_as_blob('1'), text_as_blob(''));"));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) IN ((textAsBlob(''), textAsBlob('1')), (textAsBlob('1'), textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) IN ((text_as_blob(''), text_as_blob('1')), (text_as_blob('1'), text_as_blob('1')));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 >= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 >= text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 <= textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 <= text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) <= (textAsBlob('1'), textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) <= (text_as_blob('1'), text_as_blob(''));"));
});
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)",
bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4"));
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('') AND c2 = textAsBlob('1');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('') AND c2 = text_as_blob('1');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) = (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) = (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) IN ((textAsBlob(''), textAsBlob('1')), (textAsBlob('1'), textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) IN ((text_as_blob(''), text_as_blob('1')), (text_as_blob('1'), text_as_blob('1')));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) >= (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) >= (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) <= (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) <= (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) < (textAsBlob(''), textAsBlob('1'));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) < (text_as_blob(''), text_as_blob('1'));"));
});
}
@@ -1857,17 +1857,17 @@ public class CompactStorageSplit2Test extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('')" + orderingClause));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('')" + orderingClause));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('')" + orderingClause));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('')" + orderingClause));
});
assertInvalidMessage("Invalid empty or null value for column c",
@@ -1892,19 +1892,19 @@ public class CompactStorageSplit2Test extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 >= textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 >= text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
});
@@ -1914,19 +1914,19 @@ public class CompactStorageSplit2Test extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) IN ((textAsBlob(''), textAsBlob('1')), (textAsBlob('1'), textAsBlob('1')))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) IN ((text_as_blob(''), text_as_blob('1')), (text_as_blob('1'), text_as_blob('1')))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) >= (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) >= (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
index 980b791e77..645becd94c 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/DeleteTest.java
@@ -1171,12 +1171,12 @@ public class DeleteTest extends CQLTester
createTable("CREATE TABLE %s (pk blob, c blob, v blob, PRIMARY KEY (pk, c))");
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');");
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));");
assertEmpty(execute("SELECT * FROM %s"));
@@ -1184,27 +1184,27 @@ public class DeleteTest extends CQLTester
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), bytes("1"), bytes("1"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), bytes("2"), bytes("2"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('')");
assertRows(execute("SELECT * FROM %s"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1")));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('')");
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), bytes("1"), bytes("1"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), bytes("2"), bytes("2"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('')");
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), bytes("1"), bytes("1"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)", bytes("foo123"), bytes("2"), bytes("2"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('')");
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('')");
assertRows(execute("SELECT * FROM %s"),
row(bytes("foo123"), bytes("1"), bytes("1")),
@@ -1217,12 +1217,12 @@ public class DeleteTest extends CQLTester
createTable("CREATE TABLE %s (pk blob, c1 blob, c2 blob, v blob, PRIMARY KEY (pk, c1, c2))");
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("1"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('');");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('');");
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("1"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1');");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1');");
assertEmpty(execute("SELECT * FROM %s"));
@@ -1230,27 +1230,27 @@ public class DeleteTest extends CQLTester
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), bytes("1"), bytes("1"), bytes("1"));
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), bytes("1"), bytes("2"), bytes("3"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 > textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 > text_as_blob('')");
assertRows(execute("SELECT * FROM %s"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("0")));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 >= textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 >= text_as_blob('')");
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), bytes("1"), bytes("1"), bytes("1"));
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), bytes("1"), bytes("2"), bytes("3"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 > textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 > text_as_blob('')");
assertEmpty(execute("SELECT * FROM %s"));
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), bytes("1"), bytes("1"), bytes("1"));
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)", bytes("foo123"), bytes("1"), bytes("2"), bytes("3"));
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 <= textAsBlob('')");
- execute("DELETE FROM %s WHERE pk = textAsBlob('foo123') AND c1 < textAsBlob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 <= text_as_blob('')");
+ execute("DELETE FROM %s WHERE pk = text_as_blob('foo123') AND c1 < text_as_blob('')");
assertRows(execute("SELECT * FROM %s"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
index 0093764b0c..de9c67bd29 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertTest.java
@@ -60,7 +60,7 @@ public class InsertTest extends CQLTester
assertInvalidMessage("Invalid unset value for column k", "UPDATE %s SET i = 0 WHERE k = ?", unset());
assertInvalidMessage("Invalid unset value for column k", "DELETE FROM %s WHERE k = ?", unset());
- assertInvalidMessage("Invalid unset value for argument in call to function blobasint", "SELECT * FROM %s WHERE k = blobAsInt(?)", unset());
+ assertInvalidMessage("Invalid unset value for argument in call to function blob_as_int", "SELECT * FROM %s WHERE k = blob_as_int(?)", unset());
}
@Test
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectGroupByTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectGroupByTest.java
index f46783b14b..0a0aecb7e8 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectGroupByTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectGroupByTest.java
@@ -2251,7 +2251,7 @@ public class SelectGroupByTest extends CQLTester
row(2, toTimestamp("2016-09-27 16:25:00 UTC"), 10, 10, 1L),
row(2, toTimestamp("2016-09-27 16:30:00 UTC"), 11, 11, 1L));
- assertRows(execute("SELECT pk, floor(toTimestamp(time), 5m" + startingTime + "), min(v), max(v), count(v) FROM %s GROUP BY pk, floor(toTimestamp(time), 5m" + startingTime + ")"),
+ assertRows(execute("SELECT pk, floor(to_timestamp(time), 5m" + startingTime + "), min(v), max(v), count(v) FROM %s GROUP BY pk, floor(to_timestamp(time), 5m" + startingTime + ")"),
row(1, toTimestamp("2016-09-27 16:10:00 UTC"), 1, 3, 3L),
row(1, toTimestamp("2016-09-27 16:15:00 UTC"), 4, 4, 1L),
row(1, toTimestamp("2016-09-27 16:20:00 UTC"), 5, 6, 2L),
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
index 8a3ae03d9e..0cbe221beb 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
@@ -73,17 +73,17 @@ public class SelectOrderByTest extends CQLTester
beforeAndAfterFlush(() -> {
// order by the only column in the selection
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
row(0), row(1), row(2));
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
row(2), row(1), row(0));
// order by a column not in the selection
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b ASC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c)) FROM %s WHERE a=? ORDER BY b ASC", 0),
row(0), row(1), row(2));
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c)) FROM %s WHERE a=? ORDER BY b DESC", 0),
row(2), row(1), row(0));
assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c ASC", 0);
@@ -109,7 +109,7 @@ public class SelectOrderByTest extends CQLTester
assertRows(execute("SELECT c.a FROM %s WHERE a=? ORDER BY b DESC", 0),
row(2), row(1), row(0));
- assertRows(execute("SELECT blobAsInt(intAsBlob(c.a)) FROM %s WHERE a=? ORDER BY b DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c.a)) FROM %s WHERE a=? ORDER BY b DESC", 0),
row(2), row(1), row(0));
});
dropTable("DROP TABLE %s");
@@ -198,39 +198,39 @@ public class SelectOrderByTest extends CQLTester
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 2, 5);
beforeAndAfterFlush(() -> {
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY c ASC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY c DESC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC, c DESC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC, c ASC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY d ASC", 0);
+ assertInvalid("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY c ASC", 0);
+ assertInvalid("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY c DESC", 0);
+ assertInvalid("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b ASC, c DESC", 0);
+ assertInvalid("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b DESC, c ASC", 0);
+ assertInvalid("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY d ASC", 0);
// select and order by b
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
row(0), row(0), row(0), row(1), row(1), row(1));
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
row(1), row(1), row(1), row(0), row(0), row(0));
- assertRows(execute("SELECT b, blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
+ assertRows(execute("SELECT b, blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
row(0, 0), row(0, 0), row(0, 0), row(1, 1), row(1, 1), row(1, 1));
- assertRows(execute("SELECT b, blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
+ assertRows(execute("SELECT b, blob_as_int(int_as_blob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
row(1, 1), row(1, 1), row(1, 1), row(0, 0), row(0, 0), row(0, 0));
// select c, order by b
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b ASC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c)) FROM %s WHERE a=? ORDER BY b ASC", 0),
row(0), row(1), row(2), row(0), row(1), row(2));
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c)) FROM %s WHERE a=? ORDER BY b DESC", 0),
row(2), row(1), row(0), row(2), row(1), row(0));
// select c, order by b, c
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c)) FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
row(0), row(1), row(2), row(0), row(1), row(2));
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(c)) FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
row(2), row(1), row(0), row(2), row(1), row(0));
// select d, order by b, c
- assertRows(execute("SELECT blobAsInt(intAsBlob(d)) FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(d)) FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
row(0), row(1), row(2), row(3), row(4), row(5));
- assertRows(execute("SELECT blobAsInt(intAsBlob(d)) FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
+ assertRows(execute("SELECT blob_as_int(int_as_blob(d)) FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
row(5), row(4), row(3), row(2), row(1), row(0));
});
}
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
index 17c7e87323..ae316e0191 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
@@ -541,8 +541,8 @@ public class SelectSingleColumnRelationTest extends CQLTester
assertInvalidMessage("Invalid unset value for argument in call to function token",
"SELECT * FROM %s WHERE token(k) >= token(?)", unset());
- assertInvalidMessage("Invalid unset value for argument in call to function blobasint",
- "SELECT * FROM %s WHERE k = blobAsInt(?)", unset());
+ assertInvalidMessage("Invalid unset value for argument in call to function blob_as_int",
+ "SELECT * FROM %s WHERE k = blob_as_int(?)", unset());
}
@Test
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 622fc2b78c..8e3a75666f 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 toTimestamp(t) FROM %s");
+ execute("SELECT to_timestamp(t) FROM %s");
}
/**
@@ -959,7 +959,7 @@ public class SelectTest extends CQLTester
assertTrue(ttl == 9 || ttl == 10);
// test aliasing a regular function
- rs = execute("SELECT intAsBlob(id) AS id_blob FROM %s WHERE id = 0");
+ rs = execute("SELECT int_as_blob(id) AS id_blob FROM %s WHERE id = 0");
assertEquals("id_blob", rs.metadata().get(0).name.toString());
assertEquals(ByteBuffer.wrap(new byte[4]), rs.one().getBlob(rs.metadata().get(0).name.toString()));
@@ -1110,7 +1110,7 @@ public class SelectTest extends CQLTester
createTable("CREATE TABLE %s ( k int, v int, PRIMARY KEY (k, v))");
execute("INSERT INTO %s (k, v) VALUES (0, 0)");
-
+
flush();
assertRows(execute("SELECT v FROM %s WHERE k=0 AND v IN (1, 0)"),
@@ -1255,7 +1255,7 @@ public class SelectTest extends CQLTester
execute("DELETE FROM %s WHERE a = 2 AND b = 2");
beforeAndAfterFlush(() -> {
-
+
// Checks filtering
assertInvalidMessage(StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE,
"SELECT * FROM %s WHERE c = 4 AND d = 8");
@@ -2328,7 +2328,7 @@ public class SelectTest extends CQLTester
// Test for CASSANDRA-11310 compatibility with 2i
createTable("CREATE TABLE %s (a text, b int, c text, d int, PRIMARY KEY (a, b, c));");
createIndex("CREATE INDEX ON %s(c)");
-
+
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", "a", 0, "b", 1);
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", "a", 1, "b", 2);
execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", "a", 2, "b", 3);
@@ -2513,49 +2513,49 @@ public class SelectTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk = textAsBlob('');");
- assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk IN (textAsBlob(''), textAsBlob('1'));");
+ assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk = text_as_blob('');");
+ assertInvalidMessage("Key may not be empty", "SELECT * FROM %s WHERE pk IN (text_as_blob(''), text_as_blob('1'));");
assertInvalidMessage("Key may not be empty",
"INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
EMPTY_BYTE_BUFFER, bytes("2"), bytes("2"));
// Test clustering columns restrictions
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) = (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) = (text_as_blob(''));"));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) IN ((textAsBlob('')), (textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) IN ((text_as_blob('')), (text_as_blob('1')));"),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) > (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) > (text_as_blob(''));"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob(''));"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) <= (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) <= (text_as_blob(''));"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) < (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) < (text_as_blob(''));"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('') AND c < text_as_blob('');"));
});
@@ -2563,59 +2563,59 @@ public class SelectTest extends CQLTester
bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4"));
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c = text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) = (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) = (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) IN ((textAsBlob('')), (textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) IN ((text_as_blob('')), (text_as_blob('1')));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) > (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) > (text_as_blob(''));"),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) >= (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) >= (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) <= (textAsBlob(''));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) <= (text_as_blob(''));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c) < (textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c) < (text_as_blob(''));"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('') AND c < textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('') AND c < text_as_blob('');"));
});
// Test restrictions on non-primary key value
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('') ALLOW FILTERING;"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('') ALLOW FILTERING;"));
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
bytes("foo123"), bytes("3"), EMPTY_BYTE_BUFFER);
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND v = textAsBlob('') ALLOW FILTERING;"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND v = text_as_blob('') ALLOW FILTERING;"),
row(bytes("foo123"), bytes("3"), EMPTY_BYTE_BUFFER));
});
}
@@ -2629,76 +2629,76 @@ public class SelectTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 = textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 = text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) = (textAsBlob('1'), textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) = (text_as_blob('1'), text_as_blob(''));"));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 IN (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 IN (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) IN ((textAsBlob(''), textAsBlob('1')), (textAsBlob('1'), textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) IN ((text_as_blob(''), text_as_blob('1')), (text_as_blob('1'), text_as_blob('1')));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 > textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 > text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 >= textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 >= text_as_blob('');"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 <= textAsBlob('');"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 <= text_as_blob('');"));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) <= (textAsBlob('1'), textAsBlob(''));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) <= (text_as_blob('1'), text_as_blob(''));"));
});
execute("INSERT INTO %s (pk, c1, c2, v) VALUES (?, ?, ?, ?)",
bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4"));
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('') AND c2 = textAsBlob('1');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('') AND c2 = text_as_blob('1');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) = (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) = (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1');"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1');"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) IN ((textAsBlob(''), textAsBlob('1')), (textAsBlob('1'), textAsBlob('1')));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) IN ((text_as_blob(''), text_as_blob('1')), (text_as_blob('1'), text_as_blob('1')));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) >= (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) >= (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) <= (textAsBlob(''), textAsBlob('1'));"),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) <= (text_as_blob(''), text_as_blob('1'));"),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) < (textAsBlob(''), textAsBlob('1'));"));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) < (text_as_blob(''), text_as_blob('1'));"));
});
}
@@ -2722,17 +2722,17 @@ public class SelectTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('')" + orderingClause));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('')" + orderingClause));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('')" + orderingClause));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('')" + orderingClause));
});
execute("INSERT INTO %s (pk, c, v) VALUES (?, ?, ?)",
@@ -2740,22 +2740,22 @@ public class SelectTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c IN (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c IN (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c >= textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c >= text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
- assertEmpty(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c < textAsBlob('')" + orderingClause));
+ assertEmpty(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c < text_as_blob('')" + orderingClause));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c <= textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c <= text_as_blob('')" + orderingClause),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("4")));
});
}
@@ -2775,19 +2775,19 @@ public class SelectTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 > textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 > text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 = textAsBlob('1') AND c2 >= textAsBlob('')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 = text_as_blob('1') AND c2 >= text_as_blob('')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
});
@@ -2797,19 +2797,19 @@ public class SelectTest extends CQLTester
beforeAndAfterFlush(() -> {
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND c1 IN (textAsBlob(''), textAsBlob('1')) AND c2 = textAsBlob('1')" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND c1 IN (text_as_blob(''), text_as_blob('1')) AND c2 = text_as_blob('1')" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) IN ((textAsBlob(''), textAsBlob('1')), (textAsBlob('1'), textAsBlob('1')))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) IN ((text_as_blob(''), text_as_blob('1')), (text_as_blob('1'), text_as_blob('1')))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) > (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) > (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")));
- assertRows(execute("SELECT * FROM %s WHERE pk = textAsBlob('foo123') AND (c1, c2) >= (textAsBlob(''), textAsBlob('1'))" + orderingClause),
+ assertRows(execute("SELECT * FROM %s WHERE pk = text_as_blob('foo123') AND (c1, c2) >= (text_as_blob(''), text_as_blob('1'))" + orderingClause),
row(bytes("foo123"), bytes("1"), bytes("2"), bytes("2")),
row(bytes("foo123"), bytes("1"), bytes("1"), bytes("1")),
row(bytes("foo123"), EMPTY_BYTE_BUFFER, bytes("1"), bytes("4")));
diff --git a/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java b/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java
index 19e578bd7e..5d81d6ccfa 100644
--- a/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java
@@ -854,7 +854,7 @@ public class CQLSSTableWriterTest
CQLSSTableWriter writer = CQLSSTableWriter.builder()
.inDirectory(dataDir)
.forTable(schema)
- .using("INSERT INTO " + qualifiedTable + " (k, c1, c2, v) VALUES (?, ?, ?, textAsBlob(?))")
+ .using("INSERT INTO " + qualifiedTable + " (k, c1, c2, v) VALUES (?, ?, ?, text_as_blob(?))")
.build();
writer.addRow(1, 2, 3, "abc");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org