Hi Dremians,
Apache Calcite provides the capability to get primary / foreign keys:
I tested it and function getPrimaryKeys does not fail, but it does not provide primary keys stored in the database.
I test it against Postgres data source.
private fun primaryKeys(jdbcConnection: Connection, tableName: String) {
val resultSetPk = jdbcConnection.metaData.getPrimaryKeys(
"DREMIO",
"postgres_local_docker.tpch",
"lineitem"
)
while (resultSetPk.next()) {
val pkColumnName = resultSetPk.getString("COLUMN_NAME")
println("- primaryKey: $pkColumnName")
}
}
Should this work?
If not, is it on your radar?
Jan