Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class MySQLDialect extends JdbcDialect {
statement
}

override def getSchemasOperation(catalog: String, schema: String): String = {
return "select database()"
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
return "select database()"
"select database()"

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The method accepts catalog and schema parameters but doesn't use them. This implementation ignores the parameters entirely, which may not be the expected behavior for all use cases. Consider documenting this behavior or validating if the parameters should influence the query.

Suggested change
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 uses AI. Check for mistakes.
}

override def getTablesQuery(
catalog: String,
schema: String,
Expand All @@ -60,8 +64,11 @@ class MySQLDialect extends JdbcDialect {
filters += s"$TABLE_CATALOG = '$catalog'"
}

if (StringUtils.isNotBlank(schema)) {
// when DBeaver connect use %, kyuubi to return all tables from all other databases.
Copy link

Copilot AI Jan 15, 2026

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.'

Suggested change
// when DBeaver connect use %, kyuubi to return all tables from all other databases.
// when DBeaver connects using %, Kyuubi returns all tables from all databases.

Copilot uses AI. Check for mistakes.
if (StringUtils.isNotBlank(schema) && !"%".equals(schema)) {
Copy link
Member

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

Copy link
Author

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 所有库下的所有的表。

  1. 和session配置的DB 不符,用户看到了其他数据库下的表(所有表);
  2. Dbeaver 在执行查询时,schema 不对,查询报错;

When connecting with Dbeaver, it uses '%' as a parameter, which may cause Dbeaver to return tables from all databases.

  1. The database configuration may differ from the session's database, resulting in tables from other databases being displayed;
  2. Dbeaver may encounter query errors due to an incorrect schema.

Copy link
Author

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.

filters += s"$TABLE_SCHEMA LIKE '$schema'"
} else {
filters += s"$TABLE_SCHEMA = database()"
Comment on lines +68 to +71
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
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'"

Copilot uses AI. Check for mistakes.
}

if (StringUtils.isNotBlank(tableName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ class StarRocksDialect extends MySQLDialect {

override def getSchemaHelper(): SchemaHelper = new StarRocksSchemaHelper


Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

There is an unnecessary blank line before this method. Remove the extra blank line to maintain consistent spacing with other methods in the class.

Suggested change

Copilot uses AI. Check for mistakes.
override def getCatalogsOperation(): String = {
return "show catalogs"
}
Comment on lines +30 to +32
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
override def getCatalogsOperation(): String = {
return "show catalogs"
}
override def getCatalogsOperation(): String = "show catalogs"

Copilot uses AI. Check for mistakes.
}
Loading