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

INSERT JSON - numbers not accepted for smallint and tinyint

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 2.2.8, 3.0.9, 3.8
    • Legacy/CQL
    • Apache Cassandra 3.7 (provisioned by instaclustr.com, running on AWS)

    Description

      Contrary to what is written down on http://cassandra.apache.org/doc/latest/cql/json.html#json-encoding-of-cassandra-data-types, numbers are not an accepted format for tinyints and smallints.

      Steps to reproduce on CQLSH:

      > create table default.test(id text PRIMARY KEY, small smallint, tiny tinyint);

      > INSERT INTO default.test JSON '

      {"id":"123","small":11}

      ';
      InvalidRequest: Error from server: code=2200 [Invalid query] message="Error decoding JSON value for small: Expected a short value, but got a Integer: 11"

      > INSERT INTO default.test JSON '

      {"id":"123","tiny":11}

      ';
      InvalidRequest: Error from server: code=2200 [Invalid query] message="Error decoding JSON value for tiny: Expected a byte value, but got a Integer: 11"

      The good news is that when you wrap the numeric values into strings - it works like a charm.

      Attachments

        1. 12371-2.2.txt
          11 kB
          Paweł Rychlik

        Activity

          People

            pawelrychlik Paweł Rychlik
            pawelrychlik Paweł Rychlik
            Paweł Rychlik
            Tom Hobbs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: