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

JDBC getColumns does not get all available data types #1380

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

alitaker
Copy link

@alitaker alitaker commented Feb 9, 2021

When calling getMetaData().getColumns to get the columns of a table from the information schema, only the first column gets returned.

Example snippet

Connection con;
Class loaded = Class.forName("org.duckdb.DuckDBDriver");
Properties config = new Properties();
config.setProperty("duckdb.read_only", "true");
con = DriverManager.getConnection("jdbc:duckdb:C:\\Temp\\duckdb_test", config);
ResultSet rs = con.getMetaData().getColumns(null, null, "weather", null);

It turns out that the issue is due to the fact that to optimize the retrieval, the information schema is first queried with all the possible column types, but that Resultset is not cycled through: only the first record is used.

Adding a while cycle fixes the problem.

@hannes hannes self-assigned this Feb 9, 2021
@hannes hannes added the JDBC label Feb 9, 2021
@hannes
Copy link
Member

hannes commented Feb 9, 2021

Good catch! Could you also have a look at the JDBC tests and see that they pass please?

@alitaker
Copy link
Author

alitaker commented Feb 9, 2021

The JDBC tests were not completing successfully because the getColumn test was expecting only one record for the queried columns, but there are two.
I didn't add a second check, but just passed the first table (which has one column) in the parameters, so the test is passed now.

@hannes hannes merged commit cadfbf1 into duckdb:master Feb 12, 2021
@hannes
Copy link
Member

hannes commented Feb 12, 2021

Looks great, thanks.

hawkfish added a commit to hawkfish/duckdb that referenced this pull request Feb 17, 2024
Trap integer overflows onverting weeks to days.
hawkfish added a commit to hawkfish/duckdb that referenced this pull request Feb 17, 2024
Mytherin added a commit that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants