4

There is a jdbc driver for hive but seems not fully functioning. I used the default doobie Transactor to connect to it like

val xa = Transactor.fromDriverManager[IO](
  "org.apache.hive.jdbc.HiveDriver", url, username, pass
)

myQuery.transact(xa).unsafeRunSync

And I got an error message that

[error] Exception in thread "main" java.sql.SQLFeatureNotSupportedException: Method not supported [error] at org.apache.hive.jdbc.HiveConnection.rollback(HiveConnection.java:1327) [error] at doobie.free.KleisliInterpreter$ConnectionInterpreter$$anonfun$rollback$1.apply(kleisliinterpreter.scala:643) [error] at doobie.free.KleisliInterpreter$ConnectionInterpreter$$anonfun$rollback$1.apply(kleisliinterpreter.scala:643) [error] at doobie.free.KleisliInterpreter$$anonfun$primitive$1$$anonfun$apply$1.apply(kleisliinterpreter.scala:99)

How do I connect to Hive using Doobie?

KailuoWang
  • 1,304
  • 1
  • 12
  • 24

1 Answers1

6

You need to disable the "after" and "oops" in the Transactor through a new strategy. Here is how

    import doobie.free.connection.unit
    import doobie.util.transactor.Strategy

    val hiveStrategy = Strategy.default.copy(
                        after = unit, oops = unit)

    val xa = Transactor.strategy.set(
               Transactor.fromDriverManager[IO](
                 "org.apache.hive.jdbc.HiveDriver", url, username, pass), 
               hiveStrategy)

    myQuery.transact(xa).unsafeRunSync
KailuoWang
  • 1,304
  • 1
  • 12
  • 24