[jira] [Created] (CALCITE-6170) Invalid
Egor Ryashin created CALCITE-6170: - Summary: Invalid 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 Apache Druid with Calcite and Avatica-Protobuf integration doesn't correctly validate 'LOWER(?)' The current workaround: 'LOWER(CAST(? AS VARCHAR))' Versions: {code:java} 1.35.0 1.23.0 {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)
[jira] [Created] (CALCITE-6139) Avatica-Go sends the same offset for the FetchRequest
Egor Ryashin created CALCITE-6139: - Summary: Avatica-Go sends the same offset for the FetchRequest Key: CALCITE-6139 URL: https://issues.apache.org/jira/browse/CALCITE-6139 Project: Calcite Issue Type: Bug Components: avatica-go Affects Versions: avatica-go-5.2.0 Reporter: Egor Ryashin Assignee: Francis Chuang This exception happens when *Apache Druid Avatica* protobuf endpoint is used: {_}"Druid can only fetch forward. Requested offset”{_}. I tried to debug that and saw that any simple query fails if it triggers fetching of multiple frames. I speculate that when the first *ExucuteRequest* is sent {code:java} msg := { StatementHandle: s.handle, ParameterValues: s.parametersToTypedValues(args), FirstFrameMaxSize: s.conn.config.frameMaxSize, HasParameterValues: true, }{code} and the result set is created after {code:java} rsets = append(rsets, { columns: columns, done: frame.Done, offset: frame.Offset, data: data, }){code} then for the next frame *FetchRequest* is sent but it uses the same 0 offset (the data for that offset was returned with the {*}ExecuteRequest{*}) res, err := r.conn.httpClient.post(context.Background(), { {code:java} ConnectionId: r.conn.connectionId, StatementId: r.statementID, Offset: resultSet.offset, FrameMaxSize: r.conn.config.frameMaxSize, }){code} So, in short, I think *Avatica-Go* sends 2 requests with the same offset that makes Druid to fail. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (CALCITE-6108) SQL request to Avatica-Go returns 0s for float types
Egor Ryashin created CALCITE-6108: - Summary: SQL request to Avatica-Go returns 0s for float types Key: CALCITE-6108 URL: https://issues.apache.org/jira/browse/CALCITE-6108 Project: Calcite Issue Type: Bug Components: avatica, avatica-go, druid-adapter Affects Versions: 1.35.0 Reporter: Egor Ryashin Assignee: Francis Chuang Attachments: image-2023-11-11-20-42-55-846.png, image-2023-11-11-20-43-33-198.png, image-2023-11-11-20-43-49-485.png I have zeros for float types in Go client result set with Calcite 1.35 update in Apache Druid. It worked with an older version. From what I see in the debugger TypedValue.NumberValue = 0 but DoubleValue = 1. Not sure where's the bug exactly - Druid/Avatica. This is how it can be reproduced: {code:java} package main import ( "database/sql" "fmt" _ "github.com/apache/calcite-avatica-go/v5" ) func main() { jdbcUrl := "https://localhost/druid/v2/sql/avatica-protobuf; db, err := sql.Open("avatica", jdbcUrl) if err != nil { panic(err) } defer db.Close() sql4 := ` SELECT cast(1.0 as double) m3 ` rows, err := db.Query(sql4) if err != nil { panic(err) } defer rows.Close() var m1 float32 for rows.Next() { err := rows.Scan() if err != nil { panic(err) } fmt.Println(m1) } } {code} What I see in the debugger right now: !image-2023-11-11-20-43-49-485.png! This is what I see in the Druid debugger: !image-2023-11-11-20-42-55-846.png! -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (CALCITE-6067) Casting to FLOAT data type fails
Egor Ryashin created CALCITE-6067: - Summary: Casting to FLOAT data type fails Key: CALCITE-6067 URL: https://issues.apache.org/jira/browse/CALCITE-6067 Project: Calcite Issue Type: Bug Components: avatica Affects Versions: 1.17.0 Reporter: Egor Ryashin Attachments: image-2023-10-23-13-45-59-828.png I have a strange error using Apache Druid avatica protobuf endpoint. I send this query: SELECT "user", cast("added" as float) m3 from "wikipedia" limit 10 and I get this without a stacktrace: ClassCastException: class java.lang.Long cannot be cast to class java.lang.Float (java.lang.Long and java.lang.Float are in module java.base of loader 'bootstrap') I works with `double` though: SELECT cast(1.0 as double) m3 from "wikipedia" The screenshot shows the exception is thrown here: !image-2023-10-23-13-45-59-828.png! -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (CALCITE-3002) Case statement fails with: SqlValidatorException: Cannot apply '=' to arguments of type ' = '.
Egor Ryashin created CALCITE-3002: - Summary: Case statement fails with: SqlValidatorException: Cannot apply '=' to arguments of type ' = '. Key: CALCITE-3002 URL: https://issues.apache.org/jira/browse/CALCITE-3002 Project: Calcite Issue Type: Bug Components: csv-adapter, druid Affects Versions: 1.19.0 Reporter: Egor Ryashin Query like {code:java} select (case empno when empno > 1 then 1 else empno end) from emps{code} produces an error: {noformat} java.lang.RuntimeException: java.sql.SQLException: Error while executing SQL "select (case empno when empno > 1 then 1 else empno end) from emps": From line 1, column 9 to line 1, column 55: Cannot apply '=' to arguments of type ' = '. Supported form(s): ' = ' at org.apache.calcite.test.CsvTest$Fluent.ok(CsvTest.java:1021) at org.apache.calcite.test.CsvTest.testSelectSingleProjectCase(CsvTest.java:188) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.sql.SQLException: Error while executing SQL "select (case empno when empno > 1 then 1 else empno end) from emps": From line 1, column 9 to line 1, column 55: Cannot apply '=' to arguments of type ' = '. Supported form(s): ' = ' at org.apache.calcite.avatica.Helper.createException(Helper.java:56) at org.apache.calcite.avatica.Helper.createException(Helper.java:41) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227) at org.apache.calcite.test.CsvTest.checkSql(CsvTest.java:358) at org.apache.calcite.test.CsvTest.access$300(CsvTest.java:67) at org.apache.calcite.test.CsvTest$Fluent.ok(CsvTest.java:1018) ... 28 more Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 9 to line 1, column 55: Cannot apply '=' to arguments of type ' = '. Supported form(s): ' = ' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4776) at org.apache.calcite.sql.SqlCallBinding.newValidationSignatureError(SqlCallBinding.java:280) at org.apache.calcite.sql.type.ComparableOperandTypeChecker.checkOperandTypes(ComparableOperandTypeChecker.java:66) at org.apache.calcite.sql.SqlOperator.checkOperandTypes(SqlOperator.java:659) at