Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4232

Elasticsearch IN Query is not supported

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      IN clause is required in multiple queries to fetch  documents that contain more than one exact terms in a provided field.

      SQL Query

      name IN ("kimchy", "james")

       RelNode for same-

      rexb.makeCall(SqlStdOperatorTable.IN, builder.field("name"), rexb.makeLiteral("kimchy"), rexb.makeLiteral("james"))

       

        Problem : Calcite for above RelNode throws

      java.sql.SQLException : Error while preparing statement [null]

      Suppressed: java.lang.UnsupportedOperationException: Can't handle partial QueryExpression: org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$CompoundQueryExpression@3e782f91
      at org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer.analyze(PredicateAnalyzer.java:114)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$PredicateAnalyzerTranslator.translateMatch(ElasticsearchFilter.java:99)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter.implement(ElasticsearchFilter.java:64)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchRel$Implementor.visitChild(ElasticsearchRel.java:140)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchProject.implement(ElasticsearchProject.java:59)

      Expected Elasticsearch Query - 

      GET /_search
      {
        "query": {
          "terms": {
            "name": [
              "kimchy",
              "james"
            ]
          }
        }
      }
      

      Solution: Extend IN SQLTableOperator support in elasticsearch adapters to use Terms Query Builder which is already present in elasticsearch adapters.

       

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            shlok7296 Shlok Srivastava

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 20m
                2h 20m

                Slack

                  Issue deployment