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

Elasticsearch Adapter fails to execute a prepared statement with a bind variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.29.0
    • None
    • elasticsearch-adapter
    • None

    Description

      When running the following test in AggregationTest:

      @Test void testPrepare() {
          String sql = "select * from view where cat5=?";
          CalciteAssert.that()
              .with(newConnectionFactory())
              .query(sql)
              // currently, it doesn't work with or without the following PrepareStatementConsumer
              .consumesPreparedStatement(p -> p.setInt(1, 1))
              .returns("a");
        }
      

      I got such exception:

      Suppressed: org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$PredicateAnalyzerException: Unexpected combination of expressions [left: org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$NamedFieldExpression@4a325e09] [right: null]
      org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$Visitor.swap(PredicateAnalyzer.java:506)
      org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$Visitor.binary(PredicateAnalyzer.java:353)
      org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$Visitor.visitCall(PredicateAnalyzer.java:243)
      org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$Visitor.visitCall(PredicateAnalyzer.java:127)
      org.apache.calcite.rex.RexCall.accept(RexCall.java:189)
      org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer.analyze(PredicateAnalyzer.java:112)
      org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$PredicateAnalyzerTranslator.translateMatch(ElasticsearchFilter.java:102)
      org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter.implement(ElasticsearchFilter.java:67)
      org.apache.calcite.adapter.elasticsearch.ElasticsearchRel$Implementor.visitChild(ElasticsearchRel.java:129)
      org.apache.calcite.adapter.elasticsearch.ElasticsearchProject.implement(ElasticsearchProject.java:62)
      org.apache.calcite.adapter.elasticsearch.ElasticsearchRel$Implementor.visitChild(ElasticsearchRel.java:129)
      org.apache.calcite.adapter.elasticsearch.ElasticsearchToEnumerableConverter.implement(ElasticsearchToEnumerableConverter.java:67)
      org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:111)
      

      Useful reference in JDBC Adapter: see https://issues.apache.org/jira/browse/CALCITE-563

      Attachments

        Activity

          People

            VAE ZheHu
            VAE ZheHu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: