Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please implement com.clickhouse.jdbc.ClickHouseDatabaseMetaData.getPrimaryKeys() #1625

Open
lukaseder opened this issue May 2, 2024 · 1 comment
Labels

Comments

@lukaseder
Copy link

The current implementation of com.clickhouse.jdbc.ClickHouseDatabaseMetaData.getPrimaryKeys() in com.clickhouse:clickhouse-jdbc:0.6.0-patch4 just returns an empty ResultSet, though I think it would be relatively simple to implement this correctly.

For my own purposes, I run a query like this one:

select
  system.tables.database,
  system.tables.name,
  (('KEY_' || system.tables.name) || '_PRIMARY') constraint_name,
  trim(c.1) column_name,
  c.2 column_index
from system.tables 
  array join arrayZip(splitByChar(',', primary_key), arrayEnumerate(splitByChar(',', primary_key))) as c
where (
  system.tables.primary_key <> ''
  and system.tables.database in ('default')
)

It generates a synthetic constraint name, because apparently the original name isn't stored in the catalog. Feel free to re-use this in some way in the driver.

@chernser
Copy link
Contributor

chernser commented May 5, 2024

@lukaseder thank you for reporting the issue. We will look into how to implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants