cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject [13/14] cassandra git commit: Merge branch cassandra-3.0 into cassandra-3.11
Date Fri, 07 Jul 2017 16:15:12 GMT
Merge branch cassandra-3.0 into cassandra-3.11


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/48ffad89
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/48ffad89
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/48ffad89

Branch: refs/heads/trunk
Commit: 48ffad89c14b09af6bac1d4b701374d5f65b72b5
Parents: b5df3b4 97fb4d1
Author: Benjamin Lerer <b.lerer@gmail.com>
Authored: Fri Jul 7 17:32:28 2017 +0200
Committer: Benjamin Lerer <b.lerer@gmail.com>
Committed: Fri Jul 7 17:32:28 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |   3 +-
 .../cassandra/db/marshal/AbstractType.java      |  11 +-
 .../apache/cassandra/db/marshal/EmptyType.java  |   7 +
 .../apache/cassandra/db/marshal/ListType.java   |   5 +-
 .../apache/cassandra/db/marshal/MapType.java    |   7 +-
 .../apache/cassandra/db/marshal/TupleType.java  |   3 +-
 .../org/apache/cassandra/cql3/CQLTester.java    |   6 +
 .../cql3/validation/entities/JsonTest.java      | 168 +++++++++-
 .../operations/SelectGroupByTest.java           |   7 -
 .../db/marshal/JsonConversionTest.java          | 320 +++++++++++++++++++
 10 files changed, 514 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 679d55b,8095e25..a66f4b3
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,52 -1,13 +1,53 @@@
 -3.0.15
 +3.11.1
 + * Properly evict pstmts from prepared statements cache (CASSANDRA-13641)
 +Merged from 3.0:
   * Allow different NUMACTL_ARGS to be passed in (CASSANDRA-13557)
 - * Allow native function calls in CQLSSTableWriter (CASSANDRA-12606)
   * Fix secondary index queries on COMPACT tables (CASSANDRA-13627)
   * Nodetool listsnapshots output is missing a newline, if there are no snapshots (CASSANDRA-13568)
 - Merged from 2.2:
 +Merged from 2.2:
-  * Fix nested Tuples/UDTs validation (CASSANDRA-13646)
+   * Fix toJSONString for the UDT, tuple and collection types (CASSANDRA-13592)
+   * Fix nested Tuples/UDTs validation (CASSANDRA-13646)
  
 -3.0.14
 +3.11.0
 + * Allow native function calls in CQLSSTableWriter (CASSANDRA-12606)
 + * Replace string comparison with regex/number checks in MessagingService test (CASSANDRA-13216)
 + * Fix formatting of duration columns in CQLSH (CASSANDRA-13549)
 + * Fix the problem with duplicated rows when using paging with SASI (CASSANDRA-13302)
 + * Allow CONTAINS statements filtering on the partition key and it’s parts (CASSANDRA-13275)
 + * Fall back to even ranges calculation in clusters with vnodes when tokens are distributed
unevenly (CASSANDRA-13229)
 + * Fix duration type validation to prevent overflow (CASSANDRA-13218)
 + * Forbid unsupported creation of SASI indexes over partition key columns (CASSANDRA-13228)
 + * Reject multiple values for a key in CQL grammar. (CASSANDRA-13369)
 + * UDA fails without input rows (CASSANDRA-13399)
 + * Fix compaction-stress by using daemonInitialization (CASSANDRA-13188)
 + * V5 protocol flags decoding broken (CASSANDRA-13443)
 + * Use write lock not read lock for removing sstables from compaction strategies. (CASSANDRA-13422)
 + * Use corePoolSize equal to maxPoolSize in JMXEnabledThreadPoolExecutors (CASSANDRA-13329)
 + * Avoid rebuilding SASI indexes containing no values (CASSANDRA-12962)
 + * Add charset to Analyser input stream (CASSANDRA-13151)
 + * Fix testLimitSSTables flake caused by concurrent flush (CASSANDRA-12820)
 + * cdc column addition strikes again (CASSANDRA-13382)
 + * Fix static column indexes (CASSANDRA-13277)
 + * DataOutputBuffer.asNewBuffer broken (CASSANDRA-13298)
 + * unittest CipherFactoryTest failed on MacOS (CASSANDRA-13370)
 + * Forbid SELECT restrictions and CREATE INDEX over non-frozen UDT columns (CASSANDRA-13247)
 + * Default logging we ship will incorrectly print "?:?" for "%F:%L" pattern (CASSANDRA-13317)
 + * Possible AssertionError in UnfilteredRowIteratorWithLowerBound (CASSANDRA-13366)
 + * Support unaligned memory access for AArch64 (CASSANDRA-13326)
 + * Improve SASI range iterator efficiency on intersection with an empty range (CASSANDRA-12915).
 + * Fix equality comparisons of columns using the duration type (CASSANDRA-13174)
 + * Obfuscate password in stress-graphs (CASSANDRA-12233)
 + * Move to FastThreadLocalThread and FastThreadLocal (CASSANDRA-13034)
 + * nodetool stopdaemon errors out (CASSANDRA-13030)
 + * Tables in system_distributed should not use gcgs of 0 (CASSANDRA-12954)
 + * Fix primary index calculation for SASI (CASSANDRA-12910)
 + * More fixes to the TokenAllocator (CASSANDRA-12990)
 + * NoReplicationTokenAllocator should work with zero replication factor (CASSANDRA-12983)
 + * Address message coalescing regression (CASSANDRA-12676)
 + * Delete illegal character from StandardTokenizerImpl.jflex (CASSANDRA-13417)
 + * Fix cqlsh automatic protocol downgrade regression (CASSANDRA-13307)
 + * Tracing payload not passed from QueryMessage to tracing session (CASSANDRA-12835)
 +Merged from 3.0:
   * Ensure int overflow doesn't occur when calculating large partition warning size (CASSANDRA-13172)
   * Ensure consistent view of partition columns between coordinator and replica in ColumnFilter
(CASSANDRA-13004)
   * Failed unregistering mbean during drop keyspace (CASSANDRA-13346)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/src/java/org/apache/cassandra/db/marshal/AbstractType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/marshal/AbstractType.java
index 6176494,77e0971..9586040
--- a/src/java/org/apache/cassandra/db/marshal/AbstractType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
@@@ -141,8 -138,17 +141,17 @@@ public abstract class AbstractType<T> i
       **/
      public abstract Term fromJSONObject(Object parsed) throws MarshalException;
  
-     /** Converts a value to a JSON string. */
+     /**
+      * Converts the specified value into its JSON representation.
+      * <p>
+      * The buffer position will stay the same.
+      * </p>
+      *
+      * @param buffer the value to convert
+      * @param protocolVersion the protocol version to use for the conversion
+      * @return a JSON string representing the specified value
+      */
 -    public String toJSONString(ByteBuffer buffer, int protocolVersion)
 +    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
      {
          return '"' + getSerializer().deserialize(buffer).toString() + '"';
      }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/src/java/org/apache/cassandra/db/marshal/EmptyType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/marshal/EmptyType.java
index c653084,806d160..659ff81
--- a/src/java/org/apache/cassandra/db/marshal/EmptyType.java
+++ b/src/java/org/apache/cassandra/db/marshal/EmptyType.java
@@@ -23,6 -23,6 +23,7 @@@ import org.apache.cassandra.cql3.CQL3Ty
  import org.apache.cassandra.cql3.Constants;
  import org.apache.cassandra.cql3.Term;
  import org.apache.cassandra.serializers.TypeSerializer;
++import org.apache.cassandra.transport.ProtocolVersion;
  import org.apache.cassandra.serializers.EmptySerializer;
  import org.apache.cassandra.serializers.MarshalException;
  import org.apache.cassandra.utils.ByteBufferUtil;
@@@ -72,6 -72,11 +73,12 @@@ public class EmptyType extends Abstract
          return CQL3Type.Native.EMPTY;
      }
  
 -    public String toJSONString(ByteBuffer buffer, int protocolVersion)
++    @Override
++    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
+     {
+         return "\"\"";
+     }
+ 
      public TypeSerializer<Void> getSerializer()
      {
          return EmptySerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/src/java/org/apache/cassandra/db/marshal/ListType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/marshal/ListType.java
index e4c20e2,29e75bd..c03f866
--- a/src/java/org/apache/cassandra/db/marshal/ListType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ListType.java
@@@ -224,10 -205,11 +224,11 @@@ public class ListType<T> extends Collec
          return new Lists.DelayedValue(terms);
      }
  
 -    public static String setOrListToJsonString(ByteBuffer buffer, AbstractType elementsType,
int protocolVersion)
 +    public static String setOrListToJsonString(ByteBuffer buffer, AbstractType elementsType,
ProtocolVersion protocolVersion)
      {
+         ByteBuffer value = buffer.duplicate();
          StringBuilder sb = new StringBuilder("[");
-         int size = CollectionSerializer.readCollectionSize(buffer, protocolVersion);
+         int size = CollectionSerializer.readCollectionSize(value, protocolVersion);
          for (int i = 0; i < size; i++)
          {
              if (i > 0)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/src/java/org/apache/cassandra/db/marshal/MapType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/marshal/MapType.java
index 48e90a0,9c9cda9..1817f31
--- a/src/java/org/apache/cassandra/db/marshal/MapType.java
+++ b/src/java/org/apache/cassandra/db/marshal/MapType.java
@@@ -256,10 -232,11 +256,11 @@@ public class MapType<K, V> extends Coll
      }
  
      @Override
 -    public String toJSONString(ByteBuffer buffer, int protocolVersion)
 +    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
      {
+         ByteBuffer value = buffer.duplicate();
          StringBuilder sb = new StringBuilder("{");
-         int size = CollectionSerializer.readCollectionSize(buffer, protocolVersion);
+         int size = CollectionSerializer.readCollectionSize(value, protocolVersion);
          for (int i = 0; i < size; i++)
          {
              if (i > 0)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/src/java/org/apache/cassandra/db/marshal/TupleType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/marshal/TupleType.java
index 034ad53,2d6363e..495338c
--- a/src/java/org/apache/cassandra/db/marshal/TupleType.java
+++ b/src/java/org/apache/cassandra/db/marshal/TupleType.java
@@@ -312,8 -255,9 +312,9 @@@ public class TupleType extends Abstract
      }
  
      @Override
 -    public String toJSONString(ByteBuffer buffer, int protocolVersion)
 +    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
      {
+         ByteBuffer duplicated = buffer.duplicate();
          StringBuilder sb = new StringBuilder("[");
          for (int i = 0; i < types.size(); i++)
          {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/test/unit/org/apache/cassandra/cql3/CQLTester.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/CQLTester.java
index ffb7910,11d9e19..2dbcfff
--- a/test/unit/org/apache/cassandra/cql3/CQLTester.java
+++ b/test/unit/org/apache/cassandra/cql3/CQLTester.java
@@@ -38,8 -39,8 +38,9 @@@ import org.slf4j.Logger
  import org.slf4j.LoggerFactory;
  
  import com.datastax.driver.core.*;
 +import com.datastax.driver.core.DataType;
  import com.datastax.driver.core.ResultSet;
+ 
  import org.apache.cassandra.SchemaLoader;
  import org.apache.cassandra.concurrent.ScheduledExecutors;
  import org.apache.cassandra.config.CFMetaData;
@@@ -725,10 -721,15 +726,15 @@@ public abstract class CQLTeste
  
      protected Session sessionNet()
      {
 -        return sessionNet(PROTOCOL_VERSIONS.get(PROTOCOL_VERSIONS.size() - 1));
 +        return sessionNet(getDefaultVersion());
      }
  
+     protected com.datastax.driver.core.ResultSet executeNetWithPaging(String query, int
pageSize) throws Throwable
+     {
+         return sessionNet().execute(new SimpleStatement(formatQuery(query)).setFetchSize(pageSize));
+     }
+ 
 -    protected Session sessionNet(int protocolVersion)
 +    protected Session sessionNet(ProtocolVersion protocolVersion)
      {
          requireNetwork();
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48ffad89/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
index dadbeb0,94b2087..2bd95be
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
@@@ -17,13 -17,14 +17,14 @@@
   */
  package org.apache.cassandra.cql3.validation.entities;
  
- import org.apache.cassandra.config.DatabaseDescriptor;
  import org.apache.cassandra.cql3.Json;
 -import org.apache.cassandra.dht.ByteOrderedPartitioner;
 -import org.apache.cassandra.config.DatabaseDescriptor;
  import org.apache.cassandra.cql3.CQLTester;
 +import org.apache.cassandra.cql3.Duration;
 +import org.apache.cassandra.dht.ByteOrderedPartitioner;
+ 
  import org.apache.cassandra.serializers.SimpleDateSerializer;
  import org.apache.cassandra.serializers.TimeSerializer;
+ import org.apache.cassandra.service.StorageService;
  import org.apache.cassandra.utils.ByteBufferUtil;
  
  import org.junit.Assert;
@@@ -47,7 -44,158 +44,159 @@@ public class JsonTest extends CQLTeste
      @BeforeClass
      public static void setUp()
      {
-         DatabaseDescriptor.setPartitionerUnsafe(ByteOrderedPartitioner.instance);
+         StorageService.instance.setPartitionerUnsafe(ByteOrderedPartitioner.instance);
+     }
+ 
+     @Test
+     public void testSelectJsonWithPagingWithFrozenTuple() throws Throwable
+     {
+         final UUID uuid = UUID.fromString("2dd2cd62-6af3-4cf6-96fc-91b9ab62eedc");
+         final Object partitionKey = tuple(uuid, 2);
+ 
+         createTable("CREATE TABLE %s (k1 FROZEN<TUPLE<uuid, int>>, c1 frozen<tuple<uuid,
int>>, value int, PRIMARY KEY (k1, c1))");
+ 
+         // prepare data
+         for (int i = 1; i < 5; i++)
+             execute("INSERT INTO %s (k1, c1, value) VALUES (?, ?, ?)", partitionKey, tuple(uuid,
i), i);
+ 
+         for (int pageSize = 1; pageSize < 6; pageSize++)
+         {
+             // SELECT JSON
+             assertRowsNet(executeNetWithPaging("SELECT JSON * FROM %s", pageSize),
+                            row("{\"k1\": [\"" + uuid + "\", 2], \"c1\": [\"" + uuid + "\",
1], \"value\": 1}"),
+                            row("{\"k1\": [\"" + uuid + "\", 2], \"c1\": [\"" + uuid + "\",
2], \"value\": 2}"),
+                            row("{\"k1\": [\"" + uuid + "\", 2], \"c1\": [\"" + uuid + "\",
3], \"value\": 3}"),
+                            row("{\"k1\": [\"" + uuid + "\", 2], \"c1\": [\"" + uuid + "\",
4], \"value\": 4}"));
+ 
+             // SELECT toJson(column)
+             assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value)
FROM %s", pageSize),
+                           row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 1]", "1"),
+                           row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 2]", "2"),
+                           row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 3]", "3"),
+                           row("[\"" + uuid + "\", 2]", "[\"" + uuid + "\", 4]", "4"));
+         }
+     }
+ 
+     @Test
+     public void testSelectJsonWithPagingWithFrozenMap() throws Throwable
+     {
+         final UUID uuid = UUID.fromString("2dd2cd62-6af3-4cf6-96fc-91b9ab62eedc");
+         final Object partitionKey = map(1, tuple(uuid, 1), 2, tuple(uuid, 2));
+ 
+         createTable("CREATE TABLE %s (k1 FROZEN<map<int, tuple<uuid, int>>>,
c1 frozen<tuple<uuid, int>>, value int, PRIMARY KEY (k1, c1))");
+ 
+         // prepare data
+         for (int i = 1; i < 5; i++)
+             execute("INSERT INTO %s (k1, c1, value) VALUES (?, ?, ?)", partitionKey, tuple(uuid,
i), i);
+ 
+         for (int pageSize = 1; pageSize < 6; pageSize++)
+         {
+             // SELECT JSON
+             assertRowsNet(executeNetWithPaging("SELECT JSON * FROM %s", pageSize),
+                           row("{\"k1\": {\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid
+ "\", 2]}, \"c1\": [\"" + uuid + "\", 1], \"value\": 1}"),
+                           row("{\"k1\": {\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid
+ "\", 2]}, \"c1\": [\"" + uuid + "\", 2], \"value\": 2}"),
+                           row("{\"k1\": {\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid
+ "\", 2]}, \"c1\": [\"" + uuid + "\", 3], \"value\": 3}"),
+                           row("{\"k1\": {\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid
+ "\", 2]}, \"c1\": [\"" + uuid + "\", 4], \"value\": 4}"));
+ 
+             // SELECT toJson(column)
+             assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value)
FROM %s", pageSize),
+                           row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\",
2]}", "[\"" + uuid + "\", 1]", "1"),
+                           row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\",
2]}", "[\"" + uuid + "\", 2]", "2"),
+                           row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\",
2]}", "[\"" + uuid + "\", 3]", "3"),
+                           row("{\"1\": [\"" + uuid + "\", 1], \"2\": [\"" + uuid + "\",
2]}", "[\"" + uuid + "\", 4]", "4"));
+         }
+     }
+ 
+     @Test
+     public void testSelectJsonWithPagingWithFrozenSet() throws Throwable
+     {
+         final UUID uuid = UUID.fromString("2dd2cd62-6af3-4cf6-96fc-91b9ab62eedc");
+         final Object partitionKey = set(tuple(list(1, 2), 1), tuple(list(2, 3), 2));
+ 
+         createTable("CREATE TABLE %s (k1 frozen<set<tuple<list<int>, int>>>,
c1 frozen<tuple<uuid, int>>, value int, PRIMARY KEY (k1, c1))");
+ 
+         // prepare data
+         for (int i = 1; i < 5; i++)
+             execute("INSERT INTO %s (k1, c1, value) VALUES (?, ?, ?)", partitionKey, tuple(uuid,
i), i);
+ 
+         for (int pageSize = 1; pageSize < 6; pageSize++)
+         {
+             // SELECT JSON
+             assertRowsNet(executeNetWithPaging("SELECT JSON * FROM %s", pageSize),
+                           row("{\"k1\": [[[1, 2], 1], [[2, 3], 2]], \"c1\": [\"" + uuid
+ "\", 1], \"value\": 1}"),
+                           row("{\"k1\": [[[1, 2], 1], [[2, 3], 2]], \"c1\": [\"" + uuid
+ "\", 2], \"value\": 2}"),
+                           row("{\"k1\": [[[1, 2], 1], [[2, 3], 2]], \"c1\": [\"" + uuid
+ "\", 3], \"value\": 3}"),
+                           row("{\"k1\": [[[1, 2], 1], [[2, 3], 2]], \"c1\": [\"" + uuid
+ "\", 4], \"value\": 4}"));
+ 
+             // SELECT toJson(column)
+             assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value)
FROM %s", pageSize),
+                           row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 1]", "1"),
+                           row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 2]", "2"),
+                           row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 3]", "3"),
+                           row("[[[1, 2], 1], [[2, 3], 2]]", "[\"" + uuid + "\", 4]", "4"));
+         }
+     }
+ 
+     @Test
+     public void testSelectJsonWithPagingWithFrozenList() throws Throwable
+     {
+         final UUID uuid = UUID.fromString("2dd2cd62-6af3-4cf6-96fc-91b9ab62eedc");
+         final Object partitionKey = list(tuple(uuid, 2), tuple(uuid, 3));
+ 
+         createTable("CREATE TABLE %s (k1 frozen<list<tuple<uuid, int>>>,
c1 frozen<tuple<uuid, int>>, value int, PRIMARY KEY (k1, c1))");
+ 
+         // prepare data
+         for (int i = 1; i < 5; i++)
+             execute("INSERT INTO %s (k1, c1, value) VALUES (?, ?, ?)", partitionKey, tuple(uuid,
i), i);
+ 
+         for (int pageSize = 1; pageSize < 6; pageSize++)
+         {
+         // SELECT JSON
+         assertRowsNet(executeNetWithPaging("SELECT JSON * FROM %s", pageSize),
+                       row("{\"k1\": [[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]], \"c1\":
[\"" + uuid + "\", 1], \"value\": 1}"),
+                       row("{\"k1\": [[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]], \"c1\":
[\"" + uuid + "\", 2], \"value\": 2}"),
+                       row("{\"k1\": [[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]], \"c1\":
[\"" + uuid + "\", 3], \"value\": 3}"),
+                       row("{\"k1\": [[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]], \"c1\":
[\"" + uuid + "\", 4], \"value\": 4}"));
+ 
+         // SELECT toJson(column)
+         assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value)
FROM %s", pageSize),
+                       row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid
+ "\", 1]", "1"),
+                       row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid
+ "\", 2]", "2"),
+                       row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid
+ "\", 3]", "3"),
+                       row("[[\"" + uuid + "\", 2], [\"" + uuid + "\", 3]]", "[\"" + uuid
+ "\", 4]", "4"));
+         }
+     }
+ 
+     @Test
+     public void testSelectJsonWithPagingWithFrozenUDT() throws Throwable
+     {
+         final UUID uuid = UUID.fromString("2dd2cd62-6af3-4cf6-96fc-91b9ab62eedc");
 -        final Object partitionKey = userType(1, 2, list("1", "2"));
+ 
+         String typeName = createType("CREATE TYPE %s (a int, b int, c list<text>)");
+         createTable("CREATE TABLE %s (k1 frozen<" + typeName + ">, c1 frozen<tuple<uuid,
int>>, value int, PRIMARY KEY (k1, c1))");
+ 
++        final Object partitionKey = userType("a", 1, "b", 2, "c", list("1", "2"));
++
+         // prepare data
+         for (int i = 1; i < 5; i++)
+         execute("INSERT INTO %s (k1, c1, value) VALUES (?, ?, ?)", partitionKey, tuple(uuid,
i), i);
+ 
+         for (int pageSize = 1; pageSize < 6; pageSize++)
+         {
+             // SELECT JSON
+             assertRowsNet(executeNetWithPaging("SELECT JSON * FROM %s", pageSize),
+                           row("{\"k1\": {\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}, \"c1\":
[\"" + uuid + "\", 1], \"value\": 1}"),
+                           row("{\"k1\": {\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}, \"c1\":
[\"" + uuid + "\", 2], \"value\": 2}"),
+                           row("{\"k1\": {\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}, \"c1\":
[\"" + uuid + "\", 3], \"value\": 3}"),
+                           row("{\"k1\": {\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}, \"c1\":
[\"" + uuid + "\", 4], \"value\": 4}"));
+ 
+             // SELECT toJson(column)
+             assertRowsNet(executeNetWithPaging("SELECT toJson(k1), toJson(c1), toJson(value)
FROM %s", pageSize),
+                           row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid
+ "\", 1]", "1"),
+                           row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid
+ "\", 2]", "2"),
+                           row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid
+ "\", 3]", "3"),
+                           row("{\"a\": 1, \"b\": 2, \"c\": [\"1\", \"2\"]}", "[\"" + uuid
+ "\", 4]", "4"));
+         }
      }
  
      @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message