Uploaded image for project: 'Couchbase Ruby client library'
  1. Couchbase Ruby client library
  2. RCBC-311

Analytics query with scope doesn't work

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.2.0
    • None
    • None
    • 1

    Description

      While documenting DOC-7628 https://github.com/couchbase/docs-sdk-ruby/pull/20 it looks like the Analytics query under Scope fails with an error like:

      .../.rvm/gems/ruby-3.0.0/gems/couchbase-3.0.3/lib/couchbase/scope.rb:102:in `analytics_query': uninitialized constant Couchbase::Scope::AnalyticsResult (NameError)
      	from modules/howtos/examples/analytics.rb:91:in `<main>' 

      This is with the following dataverses created;

      CREATE DATAVERSE `travel-sample.inventory`;
        USE `travel-sample.inventory`;
        CREATE DATASET `airports-collection` ON `travel-sample`.inventory.airport; 

      That seems to match the RFC, and looks like it's what's implemented in the Java SDK, so raising as bug - although it could be my misunderstanding of how the feature should work?

      (In either case, the relevant documentation section is commented out for now).

      Attachments

        Issue Links

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

          Activity

            Hi Sergey Avseyev I've clarified my understanding of the Analytics and I think my sample code was wrong, but there's still a minor bug in how the Dataverse name is constructed by the SDK:

            See e.g. https://github.com/osfameron/docs-sdk-ruby/commit/c7052596db63cc910192dd872f3d358a73c8b5f9

            This call ends with the error "Cannot find dataverse with name `travel-sample.inventory`"

            However, as https://blog.couchbase.com/collections-simplify-your-analysis-with-couchbase-analytics/ shows, the dataverse name is created as "`travel-sample`.inventory" (e.g. backtick quoted because the bucket name has a - in it).

            hakim.cassimally Hakim Cassimally added a comment - Hi Sergey Avseyev  I've clarified my understanding of the Analytics and I think my sample code was wrong, but there's still a minor bug in how the Dataverse name is constructed by the SDK: See e.g. https://github.com/osfameron/docs-sdk-ruby/commit/c7052596db63cc910192dd872f3d358a73c8b5f9 This call ends with the error "Cannot find dataverse with name `travel-sample.inventory`" However, as https://blog.couchbase.com/collections-simplify-your-analysis-with-couchbase-analytics/  shows, the dataverse name is created as "`travel-sample`.inventory" (e.g. backtick quoted because the bucket name has a - in it).
            avsej Sergey Avseyev added a comment - http://review.couchbase.org/c/couchbase-ruby-client/+/149172

            Hi Sergey - sorry, the initial report would indeed be fixed by the RCBC-314 fix...

            But the sample code still does not work, see my https://github.com/couchbase/docs-sdk-ruby/pull/20 for DOC-7628 and the first comment above where I get error  "Cannot find dataverse with name `travel-sample.inventory`"

            (e.g. I think the dataverse name is badly constructed, compared to how other SDKs such as Java do it, and from how I've understood the RFC).

            This is having installed latest HEAD, with following version output:

            {:sdk=>"3.1.1.snapshot", :backend=>"1.4.1", :build_timestamp=>"2021-04-08 11:04:05", :revision=>"56ca50445a57fe4e1555b54f5f8d9de6c6e9dcf1", :platform=>"Darwin-19.6.0", :cpu=>"x86_64", :cc=>"AppleClang 12.0.0.12000032", :cxx=>"AppleClang 12.0.0.12000032", :ruby=>"3.0.0", :spdlog=>"1.8.1", :asio=>"1.18.0", :snappy=>"1.1.8", :http_parser=>"2.9.4", :openssl_headers=>"OpenSSL 1.1.1i 8 Dec 2020", :openssl_runtime=>"OpenSSL 1.1.1i 8 Dec 2020"}

            Can you have another look?

            hakim.cassimally Hakim Cassimally added a comment - Hi Sergey - sorry, the initial report would indeed be fixed by the RCBC-314 fix... But the sample code still does not work, see my https://github.com/couchbase/docs-sdk-ruby/pull/20  for DOC-7628 and the first comment above where I get error  "Cannot find dataverse with name `travel-sample.inventory`" (e.g. I think the dataverse name is badly constructed, compared to how other SDKs such as Java do it, and from how I've understood the RFC). This is having installed latest HEAD, with following version output: {:sdk=>" 3.1.1.snapshot ", :backend=>"1.4.1", :build_timestamp=>"2021-04-08 11:04:05", :revision=>"56ca50445a57fe4e1555b54f5f8d9de6c6e9dcf1", :platform=>"Darwin-19.6.0", :cpu=>"x86_64", :cc=>"AppleClang 12.0.0.12000032", :cxx=>"AppleClang 12.0.0.12000032", :ruby=>"3.0.0", :spdlog=>"1.8.1", :asio=>"1.18.0", :snappy=>"1.1.8", :http_parser=>"2.9.4", :openssl_headers=>"OpenSSL 1.1.1i 8 Dec 2020", :openssl_runtime=>"OpenSSL 1.1.1i 8 Dec 2020"} Can you have another look?

            Hakim Cassimally, thanks for noticing it. It looks like the server side has changed decoding. I've adjusted the client.

            avsej Sergey Avseyev added a comment - Hakim Cassimally , thanks for noticing it. It looks like the server side has changed decoding. I've adjusted the client.

            Thanks Sergey Avseyev I've confirmed that fixes the issue!

            NB: in the sample test, it did cause the following section to time out. I assume it's something in my setup, and is unrelated to my issue, so I'm not pursuing, but mentioning to you in case it looks at all suspicious to you   

            puts "scanconsistency"
            # tag::scanconsistency[]
            options = Cluster::AnalyticsOptions.new
            options.scan_consistency = :request_plus
            result = cluster.analytics_query(
              'SELECT * FROM airports WHERE country = "France" LIMIT 10',
              options)
            # end::scanconsistency[] 

            hakim.cassimally Hakim Cassimally added a comment - Thanks Sergey Avseyev  I've confirmed that fixes the issue! NB: in the sample test, it did cause the following section to time out. I assume it's something in my setup, and is unrelated to my issue, so I'm not pursuing, but mentioning to you in case it looks at all suspicious to you    puts "scanconsistency" # tag::scanconsistency[] options = Cluster::AnalyticsOptions. new options.scan_consistency = :request_plus result = cluster.analytics_query( 'SELECT * FROM airports WHERE country = "France" LIMIT 10' , options) # end::scanconsistency[]

            People

              avsej Sergey Avseyev
              hakim.cassimally Hakim Cassimally
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty