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
How to identify the partitioned tables in getTables? #1590
Comments
Seems like something that would be useful. Are you up to providing a PR ? |
@davecramer Which approach do you prefer, exposing |
I think I'd like to see relkind and then have it return an enum of the different kinds. |
I would not said "expose" relkind, but extend current |
…eMetaData.getTables There is currently no way to distinguish between base tables and partitioned tables in the response from PgDatabadeMetaData.getTables. Fix this by adding PARTITIONED TABLE to the tableTypeClauses map and thus the TABLE_TYPE field in the query in getTables. Also update a test (testPartitionedTables) that was using TABLE_TYPE of TABLE to grab partitioned tables. This should close pgjdbc#1590. However, perhaps this could be considered a breaking change for anyone using getTables and expecting partitioned tables to show up for .getTables(s, s1, s2, new String[]{"TABLE"})?
…eMetaData.getTables (#1708) * feat: add way to distinguish base and partitioned tables in PgDatabaseMetaData.getTables There is currently no way to distinguish between base tables and partitioned tables in the response from PgDatabadeMetaData.getTables. Fix this by adding PARTITIONED TABLE to the tableTypeClauses map and thus the TABLE_TYPE field in the query in getTables. Also update a test (testPartitionedTables) that was using TABLE_TYPE of TABLE to grab partitioned tables. This should close #1590. However, perhaps this could be considered a breaking change for anyone using getTables and expecting partitioned tables to show up for .getTables(s, s1, s2, new String[]{"TABLE"})? * test: improve database metadata table type test
Thanks! |
Hi All, In the feature implemented 1708, we can do getTables for
While to get the regular tables we need to use getTables for But I want to get --> regular tables (non-partitions) + base tables. In the output of getTables, seems no way to find whether it is a partition or not, as the available columns are only,
So it is not possible to get regular tables (but not paritions) using JDBC metadata apis alone right? It seems from the postgres documentation, |
There is no JDBC API that provides this information as far as I know so as you surmised you would have to query pg_class on your own |
ok, thank you so much for the confirming, also thanks for the quick reply 🙏 |
We're using the
PgDatabaseMetadata
in order to list the tables in a given schema but since we're extensively using partitioned tables, it returns hundreds of tables. However; we only need the BASE table and discard the PARTITIONED tables under the BASE table but couldn't find any info about therelkind
inPgDatabaseMetadata
.Describe the issue
A clear and concise description of what the issue is.
Driver Version?
42.2.6
Java Version?
8
PostgreSQL Version?
12
Expected behavior
Ideally, we should either expose
relkind
inPgDatabaseMetadata
or provide a way for the developer to identify the partitioned tables.The text was updated successfully, but these errors were encountered: