[
https://issues.apache.org/jira/browse/CALCITE-6170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798695#comment-17798695
]
Julian Hyde commented on CALCITE-6170:
--------------------------------------
The bug is probably in Calcite, not Avatica-Go. Or rather, it is a feature
request to deduce that {{?}} has type {{VARCHAR}} because it is being passed to
the {{LOWER}} function.
> DruidException: Illegal use of dynamic parameter with 'LOWER(?)'
> -----------------------------------------------------------------
>
> Key: CALCITE-6170
> URL: https://issues.apache.org/jira/browse/CALCITE-6170
> Project: Calcite
> Issue Type: Bug
> Components: avatica-go
> Affects Versions: 1.23.0
> Reporter: Egor Ryashin
> Assignee: Francis Chuang
> Priority: Major
>
> Apache Druid with Calcite and Avatica-Protobuf integration doesn't correctly
> validate 'LOWER(?)'
> The current workaround: 'LOWER(CAST(? AS VARCHAR))'
> Versions:
> {code:java}
> <calcite.version>1.35.0</calcite.version>
> <avatica.version>1.23.0</avatica.version> {code}
>
> The following Go code will produce an exception:
> {code:java}
> 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()
> }{code}
> {code:java}
> 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 {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)