You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2022/11/10 19:43:57 UTC
[cassandra] branch cassandra-4.0 updated: Fix error message about type hints (CASSANDRA-17915)
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-4.0 by this push:
new 35826b7447 Fix error message about type hints (CASSANDRA-17915)
35826b7447 is described below
commit 35826b7447b0c3233ca3dacad2e44de082e76896
Author: Natnael Adere <na...@apple.com>
AuthorDate: Wed Oct 19 14:34:05 2022 -0400
Fix error message about type hints (CASSANDRA-17915)
Patch by Natnael Adere; reviewed by blerer and brandonwilliams for
CASSANDRA-17915
---
CHANGES.txt | 1 +
.../org/apache/cassandra/cql3/functions/FunctionResolver.java | 2 +-
.../org/apache/cassandra/cql3/functions/OperationFctsTest.java | 10 +++++-----
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index c65c518641..d358361178 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.0.8
+ * Fix error message about type hints (CASSANDRA-17915)
* Fix possible race condition on repair snapshots (CASSANDRA-17955)
* Fix ASM bytecode version inconsistency (CASSANDRA-17873)
Merged from 3.11:
diff --git a/src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java b/src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java
index ae5d17eff6..40d68f2fb8 100644
--- a/src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java
+++ b/src/java/org/apache/cassandra/cql3/functions/FunctionResolver.java
@@ -177,7 +177,7 @@ public final class FunctionResolver
return toTest;
}
}
- throw invalidRequest("Ambiguous '%s' operation with args %s and %s: use type casts to disambiguate",
+ throw invalidRequest("Ambiguous '%s' operation with args %s and %s: use type hint to disambiguate, example '(int) ?'",
OperationFcts.getOperator(name), providedArgs.get(0), providedArgs.get(1));
}
diff --git a/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
index 053283dad6..1648a55658 100644
--- a/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
+++ b/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
@@ -304,17 +304,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 with args ? and 1: use type casts to disambiguate",
+ assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type hint to disambiguate, example '(int) ?'",
"SELECT * FROM %s WHERE pk = ? + 1 AND c1 = 2", 1);
- assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type casts to disambiguate",
+ assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type hint to disambiguate, example '(int) ?'",
"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 with args 1 and ?: use type casts to disambiguate",
+ assertInvalidMessage("Ambiguous '+' operation with args 1 and ?: use type hint to disambiguate, example '(int) ?'",
"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
@@ -322,7 +322,7 @@ public class OperationFctsTest extends CQLTester
row(150, "test"));
// As the output type is unknown the ? type cannot be determined
- assertInvalidMessage("Ambiguous '+' operation with args ? and 50: use type casts to disambiguate",
+ assertInvalidMessage("Ambiguous '+' operation with args ? and 50: use type hint to disambiguate, example '(int) ?'",
"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))"
@@ -696,7 +696,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 with args ? and 1: use type casts to disambiguate",
+ assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type hint to disambiguate, example '(int) ?'",
"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));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org