dcapwell commented on code in PR #2310: URL: https://github.com/apache/cassandra/pull/2310#discussion_r1194070525
########## test/unit/org/apache/cassandra/cql3/validation/operations/CQLVectorTest.java: ########## @@ -0,0 +1,142 @@ +/* + * 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.validation.operations; + +import org.junit.Test; + +import org.apache.cassandra.cql3.CQLTester; + +public class CQLVectorTest extends CQLTester.InMemory +{ + @Test + public void select() + { + createTable(KEYSPACE, "CREATE TABLE %s (pk vector<int, 2> primary key)"); + + execute("INSERT INTO %s (pk) VALUES ([1, 2])"); + + assertRows(execute("SELECT * FROM %s WHERE pk = [1, 2]"), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk = ?", vector(1, 2)), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk = [1, 1 + 1]"), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk = [1, ?]", 2), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk = [1, (int) ?]", 2), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk = [1, 1 + (int) ?]", 1), row(list(1, 2))); + + assertRows(execute("SELECT * FROM %s WHERE pk IN ([1, 2])"), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk IN ([1, 2], [1, 2])"), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk IN (?)", vector(1, 2)), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk IN ([1, 1 + 1])"), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk IN ([1, ?])", 2), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk IN ([1, (int) ?])", 2), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE pk IN ([1, 1 + (int) ?])", 1), row(list(1, 2))); + + assertRows(execute("SELECT * FROM %s WHERE pk > [0, 0] AND pk < [1, 3] ALLOW FILTERING"), row(list(1, 2))); + assertRows(execute("SELECT * FROM %s WHERE token(pk) = token([1, 2])"), row(list(1, 2))); Review Comment: > do we need some more test cases when element type is not just int ,decimal,collection type or udt (if not suporrt now an exception is need )? See `org.apache.cassandra.cql3.RandomSchemaTest` > and for compare order , pk > [0, 0] and <[1, 3] which means (the first index element in array is big than 0 and less than 1 )& (the secondary index element is big than 0 and less than 3) I wouldn't say that... from CQL point of view I am saying to compare specific values, so is similar to the case where `pk` is a `int` and do `pk > 0 AND pk < 3`. For the type, the ordering is similar to list and based off the elements... so the following would also match: `[0, 1]`, and `[1, 2]`, and `[0, 10991038080]` > I think we should declaring these relationships clearly I feel this is very clear, what would you recommend to improve? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

