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

JDBC adapter generates SQL missing parentheses when comparing 3 values with the same precedence like (a=b)=c

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.37.0
    • 1.38.0
    • core

    Description

      Running the following unit test in JdbcAdapterTest fails with

      @Test void testOperatorInWhere() {
          CalciteAssert.model(FoodmartSchema.FOODMART_MODEL)
              .query("select * from \"sales_fact_1997\" "
                  + "where (\"product_id\" = 1) = ?")
              .consumesPreparedStatement(p -> p.setBoolean(1, true))
              .runs();
        }
      
      Caused by: java.sql.SQLSyntaxErrorException: unexpected token: = : line: 3 in statement [SELECT *
      FROM "foodmart"."sales_fact_1997"
      WHERE "product_id" = 1 = ?
      

      Attachments

        Activity

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

          People

            nobigo xiong duan
            kramerul Ulrich Kramer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment