Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-1042

SDK : Add support for RAW in the SDK for N1QL queries

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 2.4.0, 2.4.1
    • None
    • N1QL
    • None

    Description

      Doesn't look like we are supporting RAW as a part of the SDK - Query interaction,

       

      This works -> select count from `inv_skuinventory`

      This doesn't -> select  RAW count from `inv_skuinventory 

       

      I understand the failure reason, however from a supporting N1QL standpoint I believe we should address the RAW keyword. There might be places where customers use it.

       

       

      Exception in thread "main" java.lang.IllegalStateException: Expecting Object as root level object, was: VALUE_NUMBER_INT

      at com.couchbase.client.java.transcoder.JacksonTransformers$JsonObjectDeserializer.deserialize(JacksonTransformers.java:154)

      at com.couchbase.client.java.transcoder.JacksonTransformers$JsonObjectDeserializer.deserialize(JacksonTransformers.java:146)

      at com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736)

      at com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2819)

      at com.couchbase.client.java.query.DefaultAsyncN1qlQueryRow.value(DefaultAsyncN1qlQueryRow.java:58)

      at com.couchbase.client.java.query.DefaultN1qlQueryRow.value(DefaultN1qlQueryRow.java:48)

      at com.couchbase.client.java.query.DefaultN1qlQueryRow.toString(DefaultN1qlQueryRow.java:53)

      at java.lang.String.valueOf(String.java:2994)

      at java.lang.StringBuilder.append(StringBuilder.java:131)

      at com.cb.testing.DeleteTestSync.testParallel(DeleteTestSync.java:121)

      at com.cb.testing.DeleteTestSync.main(DeleteTestSync.java:55)

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            I think this one is a bit more SDK specific.  The RAW keyword is supported, but the challenge is that the format returned is, by definition, not uniform.  I'll move this to Java and will check to see if there are concerns in other SDKs.

            ingenthr Matt Ingenthron added a comment - I think this one is a bit more SDK specific.  The RAW keyword is supported, but the challenge is that the format returned is, by definition, not uniform.  I'll move this to Java and will check to see if there are concerns in other SDKs.

            The Java SDK supports this already, you just can't use "value" since value is a JsonObject. If you use RAW you need to use "byteValue" and do the conversion on your own since we can't infer the type at compile time. Here is an example that works:

            Cluster cluster = CouchbaseCluster.create();
            Bucket bucket = cluster.openBucket("travel-sample");
             
            N1qlQueryResult res = bucket.query(N1qlQuery.simple("select raw count(*) from `travel-sample`"));
            for (N1qlQueryRow row : res) {
                System.out.println(new String(row.byteValue(), Charset.forName("UTF-8")));
            }
            

            Prints 31591

            We are working to add this to the documentation. I also saw that toString() doesn't work well either, but thats minor annoyance and I'll get it fixed.

            daschl Michael Nitschinger added a comment - The Java SDK supports this already, you just can't use "value" since value is a JsonObject. If you use RAW you need to use "byteValue" and do the conversion on your own since we can't infer the type at compile time. Here is an example that works: Cluster cluster = CouchbaseCluster.create(); Bucket bucket = cluster.openBucket("travel-sample");   N1qlQueryResult res = bucket.query(N1qlQuery.simple("select raw count(*) from `travel-sample`")); for (N1qlQueryRow row : res) { System.out.println(new String(row.byteValue(), Charset.forName("UTF-8"))); } Prints 31591 We are working to add this to the documentation. I also saw that toString() doesn't work well either, but thats minor annoyance and I'll get it fixed.

            People

              daschl Michael Nitschinger
              asif.kazi Asif Kazi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty