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

Add view list for metadata getTables method #262

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

cdmikechen
Copy link
Contributor

Linked issue: #261

@@ -889,6 +886,20 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
buildFilters(sql, filters);
sql.append("\nORDER BY table_type, table_catalog, table_schema, table_name");

if (types == null || types.length == 0 || Arrays.stream(types).allMatch(t -> t.equalsIgnoreCase("VIEW"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, using table as the default table type is better and has much better compatibility。

@rad-pat
Copy link
Contributor

rad-pat commented Aug 26, 2024

I think views will be listed with latest Databend, they were incorrectly excluded from the information_schema.tables at one point: databendlabs/databend#16039

@hantmac
Copy link
Member

hantmac commented Aug 26, 2024

I think views will be listed with latest Databend, they were incorrectly excluded from the information_schema.tables at one point: datafuselabs/databend#16039

@rad-pat Aha,thanks for reminding. This pr databendlabs/databend#16058 has made table and view both in information_scham.tables.

@cdmikechen
Copy link
Contributor Author

cdmikechen commented Aug 27, 2024

@hantmac
I use databend v1.2.538-nightly. Does it mean I need to update databend to lastest version?

@hantmac
Copy link
Member

hantmac commented Aug 28, 2024

@hantmac I use databend v1.2.538-nightly. Does it mean I need to update databend to lastest version?

@hantmac I use databend v1.2.538-nightly. Does it mean I need to update databend to lastest version?

@cdmikechen Maybe we can use table as default type and merge this pr. It will back capability. Some users do not want to upgrade databend. What do you think ?

@rad-pat
Copy link
Contributor

rad-pat commented Aug 28, 2024

I think that on current, or older versions where the bug does not exist, the user will get 2 views returned, one from the table query and one from the view query. The test in this PR is not accurate, it only tests that at least one view is returned. In the SQLAlchemy library, I had to allow for the bug in certain versions: https://github.com/datafuselabs/databend-sqlalchemy/blob/3226f10e0f8b6aa85185208583977037b33ec99f/databend_sqlalchemy/databend_dialect.py#L819

@hantmac
Copy link
Member

hantmac commented Aug 29, 2024

I think that on current, or older versions where the bug does not exist, the user will get 2 views returned, one from the table query and one from the view query. The test in this PR is not accurate, it only tests that at least one view is returned. In the SQLAlchemy library, I had to allow for the bug in certain versions: https://github.com/datafuselabs/databend-sqlalchemy/blob/3226f10e0f8b6aa85185208583977037b33ec99f/databend_sqlalchemy/databend_dialect.py#L819

There is a condition https://github.com/datafuselabs/databend-jdbc/pull/262/files#diff-edd43fca3337c0ab2e0fa92af785f7021454a5485f2aea20e11b73fc50ae51d4R889, only if the type == view the SQL will return from view query.

@cdmikechen
Copy link
Contributor Author

I think that on current, or older versions where the bug does not exist, the user will get 2 views returned, one from the table query and one from the view query. The test in this PR is not accurate, it only tests that at least one view is returned. In the SQLAlchemy library, I had to allow for the bug in certain versions: https://github.com/datafuselabs/databend-sqlalchemy/blob/3226f10e0f8b6aa85185208583977037b33ec99f/databend_sqlalchemy/databend_dialect.py#L819

There is a condition https://github.com/datafuselabs/databend-jdbc/pull/262/files#diff-edd43fca3337c0ab2e0fa92af785f7021454a5485f2aea20e11b73fc50ae51d4R889, only if the type == view the SQL will return from view query.

I'll be reworking the codes this week to make it as compatible and adaptable as possible with different versions of databend.

@hantmac
Copy link
Member

hantmac commented Sep 30, 2024

@cdmikechen Hi bro , what's the pr progressing?

@cdmikechen
Copy link
Contributor Author

@hantmac
I'm sorry things have been a little busy lately. I will try to take care of this pr when I have time recently.

@cdmikechen cdmikechen requested a review from hantmac October 29, 2024 06:09
Copy link
Member

@hantmac hantmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hantmac hantmac merged commit 875f4e9 into databendlabs:main Oct 29, 2024
2 checks passed
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.

3 participants