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

SELECT JSON generates invalid JSON for the duration type

Agile BoardAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Currently, Apache Cassandra generates invalid JSON for the "duration" type.

      cqlsh> CREATE KEYSPACE ks1 WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
      cqlsh> CREATE TABLE ks1.data (id int, d duration, PRIMARY KEY (id));

      cqlsh> INSERT INTO ks1.data (id, d) VALUES (1, 6h40m);
      cqlsh> SELECT JSON d FROM ks1.data WHERE id = 1;

      [json]
      --------------
      {"d": 6h40m}

      That is, the duration is not quoted and is therefore invalid according to https://jsonlint.com/, for example.

       

      Fix the problem by quoting the formatted duration type properly:

      cqlsh> INSERT INTO ks1.data (id, d) VALUES (1, 6h40m);
      cqlsh> SELECT JSON d FROM ks1.data WHERE id = 1;

      [json]
      ----------------
      {"d": "6h40m"}

      (1 rows)

       

      The problem is fixed by the following patch:

      0001-Fix-SELECT-JSON-formatting-for-the-duration-type.patch

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            penberg Pekka Enberg Assign to me
            penberg Pekka Enberg
            Pekka Enberg
            Marcus Eriksson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment