-
Notifications
You must be signed in to change notification settings - Fork 981
[KYUUBI #7305] Fix DBeaver connect returned all tables. return tables… #7307
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,10 @@ class MySQLDialect extends JdbcDialect { | |||||||||||||||||||||||
| statement | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| override def getSchemasOperation(catalog: String, schema: String): String = { | ||||||||||||||||||||||||
| return "select database()" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| return "select database()" | |
| // MySQLDialect currently returns only the current database as the schema. | |
| // The catalog and schema parameters are accepted for interface compatibility | |
| // but do not influence the generated query. | |
| if (StringUtils.isNotBlank(catalog) || StringUtils.isNotBlank(schema)) { | |
| // Parameters are intentionally ignored; behavior is to always return the current database. | |
| } | |
| "select database()" |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected grammar in comment: 'use' should be 'uses', and the sentence structure should be improved for clarity. Suggested: 'when DBeaver connects using %, Kyuubi returns all tables from all databases.'
| // when DBeaver connect use %, kyuubi to return all tables from all other databases. | |
| // when DBeaver connects using %, Kyuubi returns all tables from all databases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change, I suppose WHERE $TABLE_SCHEMA LIKE '%' has the same effect as an empty condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like MySQLDialect(mysql, doris, starrocks) use:
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE,
TABLE_ROWS, AVG_ROW_LENGTH, DATA_LENGTH,
CREATE_TIME, UPDATE_TIME, TABLE_COLLATION, TABLE_COMMENT
FROM INFORMATION_SCHEMA.TABLES
当 Dbeaver 连接时,会采用 % 作为参数,这样或造成返回给 Dbeaver 所有库下的所有的表。
- 和session配置的DB 不符,用户看到了其他数据库下的表(所有表);
- Dbeaver 在执行查询时,schema 不对,查询报错;
When connecting with Dbeaver, it uses '%' as a parameter, which may cause Dbeaver to return tables from all databases.
- The database configuration may differ from the session's database, resulting in tables from other databases being displayed;
- Dbeaver may encounter query errors due to an incorrect schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can see issue: #7305
My StarRocks database "dataeye_starpony" only has 2 tables. However, DBeaver shows many more tables, and these extra tables cannot be queried.
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition combines two separate cases: when schema is blank and when schema is '%'. This logic would be clearer if split into separate conditions to distinguish between 'schema is blank' and 'schema is %' cases. Consider restructuring as: if blank -> database(), else if '%' -> database(), else -> LIKE schema.
| if (StringUtils.isNotBlank(schema) && !"%".equals(schema)) { | |
| filters += s"$TABLE_SCHEMA LIKE '$schema'" | |
| } else { | |
| filters += s"$TABLE_SCHEMA = database()" | |
| if (StringUtils.isBlank(schema)) { | |
| // No schema provided: default to current database | |
| filters += s"$TABLE_SCHEMA = database()" | |
| } else if ("%".equals(schema)) { | |
| // '%' means all schemas: do not add TABLE_SCHEMA filter | |
| } else { | |
| filters += s"$TABLE_SCHEMA LIKE '$schema'" |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,4 +26,8 @@ class StarRocksDialect extends MySQLDialect { | |||||||||
|
|
||||||||||
| override def getSchemaHelper(): SchemaHelper = new StarRocksSchemaHelper | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
||||||||||
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit return statements are not idiomatic in Scala. Remove the 'return' keyword and let the expression be the implicit return value.
| override def getCatalogsOperation(): String = { | |
| return "show catalogs" | |
| } | |
| override def getCatalogsOperation(): String = "show catalogs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit return statements are not idiomatic in Scala. Remove the 'return' keyword and let the expression be the implicit return value.