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

DruidException: Illegal use of dynamic parameter with 'LOWER(?)'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.23.0
    • None
    • avatica-go
    • None

    Description

      Apache Druid with Calcite and Avatica-Protobuf integration doesn't correctly validate 'LOWER'

      The current workaround: 'LOWER(CAST(? AS VARCHAR))'

      Versions:

      <calcite.version>1.35.0</calcite.version> <avatica.version>1.23.0</avatica.version> 

       
      The following Go code will produce an exception:

      package main
      
      
      import (
        "context"
        "database/sql"
        "fmt"
      
        _ "github.com/apache/calcite-avatica-go/v5"
      )
      
      
      func main() {
        jdbcUrl := "http://localhost:8082/druid/v2/sql/avatica-protobuf"
      
        db, err := sql.Open("avatica", jdbcUrl)
        if err != nil {
          panic(err)
        }
        defer func() {
          err = db.Close()
          if err != nil {
            fmt.Println(err)
            panic(err)
          }
        }()
      
        sql := "select any_value(browser) from test where (lower(browser) like lower(?)) limit 10"
      
      
        rows, err := db.QueryContext(context.Background(), sql, "%a%")
        if err != nil {
          panic(err)
        }
        rows.Close()
      }
      panic: An error was encountered while processing your request: QueryInterruptedException: Illegal use of dynamic parameter (line [1], column [73]) -> DruidException: Illegal use of dynamic parameter (line [1], column [73]) -> ValidationException: org.apache.calcite.runtime.CalciteContextException: At line 1, column 73: Illegal use of dynamic parameter -> CalciteContextException: At line 1, column 73: Illegal use of dynamic parameter -> SqlValidatorException: Illegal use of dynamic parameter 

      Attachments

        Activity

          People

            Unassigned Unassigned
            egrs Egor Ryashin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: