Skip to content

Binding value of type STRING is not yet supported for expected Arrow type Int(64, false) #5671

@kczimm

Description

@kczimm

Describe the bug

Prepared statement fails from Scala app when using placeholder in IN clause.

[error] (Compile / run) org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: Binding value of type STRING is not yet supported for expected Arrow type Int(64, false)

To Reproduce

Steps to reproduce the behavior:

build.sbt

name := "binding-value-not-supported"

version := "0.1"

scalaVersion := "2.13.12"

libraryDependencies ++= Seq(
  "org.jdbi" % "jdbi" % "2.78",
  "org.antlr" % "stringtemplate" % "3.2",
  "org.apache.arrow" % "flight-sql-jdbc-driver" % "18.1.0",
  "org.slf4j" % "slf4j-simple" % "2.0.16"
)

spicepod.yaml

datasets:
  - from: file://my_table.csv
    name: my_table
    params:
      file_format: csv

my_table.csv

A,B
'1',2
'4',5

src/main/scala/TestApp.scala

import org.skife.jdbi.v2.sqlobject.{Bind, SqlQuery}
import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator
import org.skife.jdbi.v2.{DBI, Handle}
import org.skife.jdbi.v2.tweak.ResultSetMapper
import scala.jdk.CollectionConverters._

case class Row(A: String, B: Int)

@UseStringTemplate3StatementLocator
trait TestAppDao {
  @SqlQuery("SELECT * FROM my_table WHERE :x IN (SELECT A FROM my_table WHERE B > 3) LIMIT :y;")
  def getRow(@Bind("x") x: String, @Bind("y") y: Int): java.util.List[Row]
}

object TestApp {
  def main(args: Array[String]): Unit = {
    val dbi = new DBI("jdbc:arrow-flight-sql://localhost:50051?useEncryption=false", "", "")
    
    dbi.registerMapper(new ResultSetMapper[Row] {
      def map(index: Int, rs: java.sql.ResultSet, ctx: org.skife.jdbi.v2.StatementContext): Row =
        Row(rs.getString("A"), rs.getInt("B"))
    })

    dbi.onDemand(classOf[TestAppDao]).getRow("1", 1).asScala.foreach(println)
  }
}

Run sbt clean compile; sbt run

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions