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 2021/10/25 14:24:05 UTC
[cassandra] branch trunk updated: Remove duplicate toCQLString in
ReadCommand
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams 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 60e0da1 Remove duplicate toCQLString in ReadCommand
60e0da1 is described below
commit 60e0da1bd0f8271f7bbba300695d67b9ad0a497f
Author: Kanthi Subramanian <su...@gmail.com>
AuthorDate: Fri Oct 22 11:55:23 2021 -0400
Remove duplicate toCQLString in ReadCommand
Patch by Kanthi Subramanian; reviewed by brandonwilliams and maedhroz
for CASSANDRA-17023
---
CHANGES.txt | 1 +
src/java/org/apache/cassandra/db/ReadCommand.java | 30 ----------------------
.../org/apache/cassandra/db/ReadCommandTest.java | 13 ++++++++++
3 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 3208ff8..68aeb04 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.1
+ * Remove duplicate toCQLString in ReadCommand (CASSANDRA-17023)
* Ensure hint window is persistent across restarts of a node (CASSANDRA-14309)
* Allow to GRANT or REVOKE multiple permissions in a single statement (CASSANDRA-17030)
* Allow to grant permission for all tables in a keyspace (CASSANDRA-17027)
diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java b/src/java/org/apache/cassandra/db/ReadCommand.java
index fd4636e..f14240b 100644
--- a/src/java/org/apache/cassandra/db/ReadCommand.java
+++ b/src/java/org/apache/cassandra/db/ReadCommand.java
@@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory;
import io.netty.util.concurrent.FastThreadLocal;
import org.apache.cassandra.config.*;
-import org.apache.cassandra.cql3.ColumnIdentifier;
import org.apache.cassandra.db.filter.*;
import org.apache.cassandra.net.MessageFlag;
import org.apache.cassandra.net.ParamType;
@@ -782,35 +781,6 @@ public abstract class ReadCommand extends AbstractReadQuery
}
/**
- * Recreate the CQL string corresponding to this query.
- * <p>
- * Note that in general the returned string will not be exactly the original user string, first
- * because there isn't always a single syntax for a given query, but also because we don't have
- * all the information needed (we know the non-PK columns queried but not the PK ones as internally
- * we query them all). So this shouldn't be relied too strongly, but this should be good enough for
- * debugging purpose which is what this is for.
- */
- public String toCQLString()
- {
- StringBuilder sb = new StringBuilder().append("SELECT ")
- .append(columnFilter().toCQLString())
- .append(" FROM ")
- .append(ColumnIdentifier.maybeQuote(metadata().keyspace))
- .append('.')
- .append(ColumnIdentifier.maybeQuote(metadata().name));
-
- appendCQLWhereClause(sb);
-
- if (limits() != DataLimits.NONE)
- sb.append(' ').append(limits());
-
- // ALLOW FILTERING might not be strictly necessary
- sb.append(" ALLOW FILTERING");
-
- return sb.toString();
- }
-
- /**
* Return the queried token(s) for logging
*/
public abstract String loggableTokens();
diff --git a/test/unit/org/apache/cassandra/db/ReadCommandTest.java b/test/unit/org/apache/cassandra/db/ReadCommandTest.java
index 52a92b4..69b8c37 100644
--- a/test/unit/org/apache/cassandra/db/ReadCommandTest.java
+++ b/test/unit/org/apache/cassandra/db/ReadCommandTest.java
@@ -1191,6 +1191,19 @@ public class ReadCommandTest
ReplicaUtils.full(addr, token)));
}
+ @Test
+ public void testToCQLString()
+ {
+ ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(CF2);
+ DecoratedKey key = Util.dk("key");
+
+ ReadCommand readCommand = Util.cmd(cfs, key).build();
+
+ String result = readCommand.toCQLString();
+
+ assertEquals(result, String.format("SELECT * FROM \"ReadCommandTest\".\"Standard2\" WHERE key = 0x%s ALLOW FILTERING", ByteBufferUtil.bytesToHex(key.getKey())));
+ }
+
private void testRepairedDataTracking(ColumnFamilyStore cfs, ReadCommand readCommand)
{
cfs.truncateBlocking();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org