Athena JDBC Driver (v42_2.0.31): Calling .getSchema() returns empty schema, must use internal methods?

Viewed 25

I've noticed that even when setting a JDBC URL that specifies the Schema property as the manual says, if you call .getSchema() on the Connection, it's null:

Class.forName("com.simba.athena.jdbc42.Driver")
val athenaDs = com.simba.athena.jdbc42.DataSource()

val region = "us-east-1"
val catalog = "AwsDataCatalog"
val schema = "chinook"
val user = "access_key"
val password = "secret_key"
val s3Output = "s3://my-bucket/my-folder"

val jdbcUrl = "jdbc:awsathena://AwsRegion=$region;Catalog=$catalog;Schema=$schema;User=$user;Password=$password;S3OutputLocation=$s3Output"
athenaDs.setURL(jdbcUrl)

val conn = athenaDs.connection
val s42Connection = conn.unwrap(com.simba.athena.jdbc.jdbc42.S42Connection::class.java)
val schemaSetting =  com.simba.athena.support.SettingReader.readSetting("SCHEMA")
val supportsSchema = com.simba.athena.dsi.core.utilities.PropertyUtilities.hasSchemaSupport(s42Connection.connection)

println(
    """
    Catalog: ${conn.catalog}
    Schema (conn.schema): ${conn.schema}
    Schema (SettingReader): $schemaSetting
    PropertyUtilities.hasSchemaSupport(conn): $supportsSchema
    """
)

Output:

Catalog: AwsDataCatalog
Schema (conn.schema): 
Schema (SettingReader): chinook
PropertyUtilities.hasSchemaSupport(conn): true

I've decompiled the driver using Recaf and looked at the source, that was how I found out about the hack to use SettingReader.readSetting("SCHEMA") to get the schema

But this doesn't feel right and I'm wondering:

  • Why doesn't Connection#getSchema() work
  • Is there a cleaner way to do this?
0 Answers
Related