Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-15857

Frozen RawTuple is not annotated with frozen in the toString method

    XMLWordPrintableJSON

Details

    Description

      All raw types (e.g. RawCollection, RawUT) that supports freezing wraps the type name with 'frozen<>' in the toString method, except RawTuple.

      Therefore, the RawTuple::toString output misses the frozen wrapper.

      Tuple is always frozen. However since CASSANDRA-15035, it throws when the inner tuple is not explicitly wrapped with frozen within a collection.

      The method, CQL3Type.Raw::toString, is referenced at multiple places in the source. For example, referenced in CreateTypeStatement.Raw and involved in CQLSSTableWriter. Another example is that it is called to produce the SchemaChange at several AlterSchemaStatement implementations.

      A test can prove that missing the frozen wrapper causes exception when building CQLSSTableWriter for user types defined like below. Note that the inner tuple is wrapped with frozen in the initial CQL statement.

      CREATE TYPE ks.fooType ( f list<frozen<tuple<text, text>>> )
      
      org.apache.cassandra.exceptions.InvalidRequestException: Non-frozen tuples are not allowed inside collections: list<tuple<text, text>>
      	at org.apache.cassandra.cql3.CQL3Type$Raw$RawCollection.throwNestedNonFrozenError(CQL3Type.java:710)
      	at org.apache.cassandra.cql3.CQL3Type$Raw$RawCollection.prepare(CQL3Type.java:669)
      	at org.apache.cassandra.cql3.CQL3Type$Raw$RawCollection.prepareInternal(CQL3Type.java:661)
      	at org.apache.cassandra.schema.Types$RawBuilder$RawUDT.lambda$prepare$1(Types.java:341)
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
      	at org.apache.cassandra.schema.Types$RawBuilder$RawUDT.prepare(Types.java:342)
      	at org.apache.cassandra.schema.Types$RawBuilder.build(Types.java:291)
      	at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.createTypes(CQLSSTableWriter.java:551)
      	at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.build(CQLSSTableWriter.java:527)
      

      Attachments

        Issue Links

          Activity

            People

              yifanc Yifan Cai
              yifanc Yifan Cai
              Yifan Cai
              Robert Stupp
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m