[ 
https://issues.apache.org/jira/browse/CASSANDRA-13799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16213153#comment-16213153
 ] 

Jeff Jirsa commented on CASSANDRA-13799:
----------------------------------------

Thanks for the follow-up [~malcolmt] ! That looks like an appropriate fix.

There's also some unit tests (e.g. {{OperationFctsTest}} ) that rely on the 
old, incorrect logged strings. 

For that, I've made these changes, if you're ok with them:

{code}
diff --git 
a/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java 
b/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
index 49c9e30..d27b746 100644
--- a/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
@@ -292,17 +292,17 @@ public class OperationFctsTest extends CQLTester
                    row(2, (byte) 2, (short) 2, "test"));

         // tinyint, smallint and int could be used there so we need to 
disambiguate
-        assertInvalidMessage("Ambiguous '+' operation: use type casts to 
disambiguate",
+        assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use 
type casts to disambiguate",
                              "SELECT * FROM %s WHERE pk = ? + 1 AND c1 = 2", 
1);

-        assertInvalidMessage("Ambiguous '+' operation: use type casts to 
disambiguate",
+        assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use 
type casts to disambiguate",
                              "SELECT * FROM %s WHERE pk = 2 AND c1 = 2 AND c2 
= 1 * (? + 1)", 1);

         assertRows(execute("SELECT 1 + 1, v FROM %s WHERE pk = 2 AND c1 = 2"),
                    row(2, "test"));

         // As the output type is unknown the ? type cannot be determined
-        assertInvalidMessage("Ambiguous '+' operation: use type casts to 
disambiguate",
+        assertInvalidMessage("Ambiguous '+' operation with args 1 and ?: use 
type casts to disambiguate",
                              "SELECT 1 + ?, v FROM %s WHERE pk = 2 AND c1 = 
2", 1);

         // As the prefered type for the constants is int, the returned type 
will be int
@@ -310,7 +310,7 @@ public class OperationFctsTest extends CQLTester
                    row(150, "test"));

         // As the output type is unknown the ? type cannot be determined
-        assertInvalidMessage("Ambiguous '+' operation: use type casts to 
disambiguate",
+        assertInvalidMessage("Ambiguous '+' operation with args ? and 50: use 
type casts to disambiguate",
                              "SELECT ? + 50, v FROM %s WHERE pk = 2 AND c1 = 
2", 100);

         createTable("CREATE TABLE %s (a tinyint, b smallint, c int, d bigint, 
e float, f double, g varint, h decimal, PRIMARY KEY(a, b))"
@@ -672,7 +672,7 @@ public class OperationFctsTest extends CQLTester
     public void testWithNanAndInfinity() throws Throwable
     {
         createTable("CREATE TABLE %s (a int PRIMARY KEY, b double, c 
decimal)");
-        assertInvalidMessage("Ambiguous '+' operation: use type casts to 
disambiguate",
+        assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use 
type casts to disambiguate",
                              "INSERT INTO %S (a, b, c) VALUES (? + 1, ?, ?)", 
0, Double.NaN, BigDecimal.valueOf(1));

         execute("INSERT INTO %S (a, b, c) VALUES ((int) ? + 1, -?, ?)", 0, 
Double.NaN, BigDecimal.valueOf(1));{code}

And:

{code}
diff --git 
a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
 
b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
index da5c3bd..a0ae214 100644
--- 
a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
+++ 
b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
@@ -2038,13 +2038,13 @@ public class InsertUpdateIfConditionTest extends 
CQLTester
     {
         createTable(" CREATE TABLE %s (k int PRIMARY KEY, v int, d duration)");

-        assertInvalidMessage("Slice conditions are not supported on durations",
+        assertInvalidMessage("Slice conditions ( > ) are not supported on 
durations",
                              "UPDATE %s SET v = 3 WHERE k = 0 IF d > 1s");
-        assertInvalidMessage("Slice conditions are not supported on durations",
+        assertInvalidMessage("Slice conditions ( >= ) are not supported on 
durations",
                              "UPDATE %s SET v = 3 WHERE k = 0 IF d >= 1s");
-        assertInvalidMessage("Slice conditions are not supported on durations",
+        assertInvalidMessage("Slice conditions ( <= ) are not supported on 
durations",
                              "UPDATE %s SET v = 3 WHERE k = 0 IF d <= 1s");
-        assertInvalidMessage("Slice conditions are not supported on durations",
+        assertInvalidMessage("Slice conditions ( < ) are not supported on 
durations",
                              "UPDATE %s SET v = 3 WHERE k = 0 IF d < 1s");

         execute("INSERT INTO %s (k, v, d) VALUES (1, 1, 2s)");
@@ -2100,13 +2100,13 @@ public class InsertUpdateIfConditionTest extends 
CQLTester

             assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, 
list(Duration.from("5s"), Duration.from("10s")), 6));

-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( > ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] > 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( >= ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] >= 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( <= ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] <= 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( < ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] < 
1s");

             assertRows(execute("UPDATE %s SET v = 4 WHERE k = 1 IF l[0] = 
2s"), row(false, list(Duration.from("5s"), Duration.from("10s"))));
@@ -2218,13 +2218,13 @@ public class InsertUpdateIfConditionTest extends 
CQLTester

             assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, map(1, 
Duration.from("5s"), 2, Duration.from("10s")), 6));

-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( > ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] > 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( >= ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] >= 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( <= ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] <= 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( < ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] < 
1s");

             assertRows(execute("UPDATE %s SET v = 4 WHERE k = 1 IF m[1] = 
2s"), row(false, map(1, Duration.from("5s"), 2, Duration.from("10s"))));
@@ -2338,13 +2338,13 @@ public class InsertUpdateIfConditionTest extends 
CQLTester

             assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, 
userType("i", 1, "d", Duration.from("10s")), 6));

-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( > ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF u.d > 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( >= ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF u.d >= 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( <= ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF u.d <= 
1s");
-            assertInvalidMessage("Slice conditions are not supported on 
durations",
+            assertInvalidMessage("Slice conditions ( < ) are not supported on 
durations",
                                  "UPDATE %s SET v = 3 WHERE k = 0 IF u.d < 
1s");

             assertRows(execute("UPDATE %s SET v = 4 WHERE k = 1 IF u.d = 2s"), 
row(false, userType("i", 1, "d", Duration.from("10s"))));
{code}



> Fix some alerts raised by lgtm.com
> ----------------------------------
>
>                 Key: CASSANDRA-13799
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-13799
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Malcolm Taylor
>            Assignee: Malcolm Taylor
>             Fix For: 4.x
>
>         Attachments: 13799-trunk.txt
>
>
> lgtm.com has identified a number of issues  where there may be scope for 
> improving the code 
> ([https://lgtm.com/projects/g/apache/cassandra/alerts/?mode=tree&severity=error]).
>  This issue is to address some of the more straightforward cases.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to