Uploaded image for project: 'Couchbase Spark Connector'
  1. Couchbase Spark Connector
  2. SPARKC-41

No results returned when invoking sqlContext.read.couchbase()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.2.0
    • None
    • Spark SQL
    • None
    • Couchbase version 4.1.0
      Spark Connector version 1.1.0
      Scala 2.10

    Description

      Bug originally reported in forums here.

      Couchbase schema filter is being set to null in case no where clause is specified

      I'm using spark connector 1.1.0 for scala 2.10. If I invoke sqlContext.read.couchbase() without the schemaFilter option inside couchbase(),like this:
       
      val airline = sqlContext.read
      .option("bucket","travel-sample")
      .option("schemaFilter", "type = 'airline'")
      .couchbase()
       
      I think it should be something like select * from travel-sample where type = 'airline', but in fact there will be no result returned because the N1QL generated is:
      INFO N1QLRelation: Executing generated query: 'SELECT FROM travel-sample WHERE null'.
      

      @cjycjy so you are saying if you do it like
       
      val airline = sql.read.couchbase(schemaFilter = EqualTo("type", "airline"))
      it works, but when you do it like
       
      val airline = sqlContext.read
      .option("bucket","travel-sample")
      .option("schemaFilter", "type = 'airline'")
      .couchbase()
      then the underlying N1QL query is generated wrongly and as a result you can't get the records?
      

      Exactly. couchase() will invoke buildFrame(null, null, None) and it will cover the original schemaFilter with null. So the underlying N1QL query will be wrong.
      

      The problem is that in the class N1QLRealation, when the queryFilter is constructed like
       
      val queryFilter = if (parameters.get("schemaFilter").isDefined) {
      "WHERE " + parameters.get("schemaFilter").get
      } else {
      ""
      }
       
      when the couchbase() is invoked with no schemaFilter, the ("schemaFilter"->null) will be set. So the if condition above will be true because it's value is null.
       
      
      

      Attachments

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

        Activity

          People

            daschl Michael Nitschinger
            will.gardella Will Gardella (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty