blerer commented on a change in pull request #1368:
URL: https://github.com/apache/cassandra/pull/1368#discussion_r776667972
##########
File path: test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java
##########
@@ -36,15 +36,15 @@
@Test
public void testSingleOperations() throws Throwable
{
- createTable("CREATE TABLE %s (a tinyint, b smallint, c int, d bigint,
e float, f double, g varint, h decimal, PRIMARY KEY(a, b, c))");
- execute("INSERT INTO %S (a, b, c, d, e, f, g, h) VALUES (1, 2, 3, 4,
5.5, 6.5, 7, 8.5)");
+ createTable("CREATE TABLE %s (a tinyint, b smallint, c int, d bigint,
e float, f double, g varint, h decimal, i text, j ascii, PRIMARY KEY(a, b,
c))");
+ execute("INSERT INTO %S (a, b, c, d, e, f, g, h, i, j) VALUES (1, 2,
3, 4, 5.5, 6.5, 7, 8.5, 'जॉन', 'Doe')");
// Test additions
- assertColumnNames(execute("SELECT a + a, b + a, c + a, d + a, e + a, f
+ a, g + a, h + a FROM %s WHERE a = 1 AND b = 2 AND c = 1 + 2"),
- "a + a", "b + a", "c + a", "d + a", "e + a", "f +
a", "g + a", "h + a");
+ assertColumnNames(execute("SELECT a + a, b + a, c + a, d + a, e + a, f
+ a, g + a, h + a, i + i, i + j, j + i, j + j FROM %s WHERE a = 1 AND b = 2 AND
c = 1 + 2"),
+ "a + a", "b + a", "c + a", "d + a", "e + a", "f +
a", "g + a", "h + a", "i + i", "i + j", "j + i", "j + j");
- assertRows(execute("SELECT a + a, b + a, c + a, d + a, e + a, f + a, g
+ a, h + a FROM %s WHERE a = 1 AND b = 2 AND c = 1 + 2"),
- row((byte) 2, (short) 3, 4, 5L, 6.5F, 7.5,
BigInteger.valueOf(8), BigDecimal.valueOf(9.5)));
+ assertRows(execute("SELECT a + a, b + a, c + a, d + a, e + a, f + a, g
+ a, h + a, i + ' ' + i, i + ' ' + j, j + ' ' + i, j + ' ' + j FROM %s WHERE a
= 1 AND b = 2 AND c = 1 + 2"),
+ row((byte) 2, (short) 3, 4, 5L, 6.5F, 7.5,
BigInteger.valueOf(8), BigDecimal.valueOf(9.5), "जॉन जॉन", "जॉन Doe", "Doe
जॉन", "Doe Doe"));
Review comment:
I would have separated the tests for String concatenation into a
separate test method. This test is already pretty heavy with all the numeric
types
##########
File path: src/java/org/apache/cassandra/cql3/Constants.java
##########
@@ -44,7 +45,19 @@
public enum Type
{
- STRING,
+ STRING
+ {
+ public AbstractType<?> getPreferedTypeFor(String text)
+ {
+ if(Charset.forName("US-ASCII").newEncoder().canEncode(text))
+ {
+ return AsciiType.instance;
+ } else
Review comment:
nit: The `else` should be on the next line. You can also choose to
remove the `else` as it is not needed do to the `return`.
--
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]