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

[#1339] feat(jdbc-doris): Support Apache Doris Catalog #2491

Closed
wants to merge 5 commits into from

Conversation

zhoukangcn
Copy link
Contributor

What changes were proposed in this pull request?

Support Apache Doris as a type of data source.

Why are the changes needed?

Fix: #1339

Does this PR introduce any user-facing change?

N/A

How was this patch tested?

UT & IT

@zhoukangcn zhoukangcn force-pushed the f-1339 branch 3 times, most recently from ec4af86 to 1b13072 Compare March 10, 2024 15:26
@yuqi1129
Copy link
Contributor

@zhoukangcn
Is it ready for review?

@zhoukangcn
Copy link
Contributor Author

@yuqi1129 yes, please review this PR. Thanks.

catalogs/catalog-jdbc-doris/build.gradle.kts Show resolved Hide resolved
@Override
public JdbcSchema load(String databaseName) throws NoSuchSchemaException {
try (final Connection connection = this.dataSource.getConnection()) {
String query = "SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = ?";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the user has the privilege to access system table like MySQL?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is Doris case-sensitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diqiu50 Doris is case-insensitive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yuqi1129 yes, user has default privilege to use database, and can list all tables.

expression -> {
Preconditions.checkArgument(
Arrays.stream(columns)
.anyMatch(column -> column.name().equalsIgnoreCase(expression.toString())),
Copy link
Contributor

Choose a reason for hiding this comment

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

So, is the Doris column name case-insensitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, Doris column name is case-insensitive, and will convert to lowercase

} else if (change instanceof TableChange.UpdateColumnType) {
lazyLoadTable = getOrCreateTable(databaseName, tableName, lazyLoadTable);
TableChange.UpdateColumnType updateColumnType = (TableChange.UpdateColumnType) change;
alterSql.add(updateColumnTypeFieldDefinition(updateColumnType, lazyLoadTable));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please review the backquote issues regarding column names, table names, etc in the whole PR carefully.

Connection connection = DriverManager.getConnection(dorisMySQLUrl, USER_NAME, "");

// execute `SHOW PROC '/backends';` to check if backends is ready
String query = "SHOW PROC '/backends';";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is using SELECT 1 better?

package com.datastrato.gravitino.catalog.doris.operation;

/** Test class for {@link DorisTableOperations}. */
public class TestDorisTableOperations {}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this class?

# jdbc-user: strato
# jdbc-password: strato
# jdbc-driver: com.mysql.jdbc.Driver
# jdbc-driver: com.mysql.cj.jdbc.Driver
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file still useful?

} else if (type instanceof Types.VarCharType) {
return VARCHAR + "(" + ((Types.VarCharType) type).length() + ")";
} else if (type instanceof Types.FixedCharType) {
return CHAR + "(" + ((Types.FixedCharType) type).length() + ")";
Copy link
Contributor

Choose a reason for hiding this comment

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

How to handle the CharType length limitation?

@Override
public JdbcSchema load(String databaseName) throws NoSuchSchemaException {
try (final Connection connection = this.dataSource.getConnection()) {
String query = "SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = ?";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is Doris case-sensitive?


/** Table operations for Doris. */
public class DorisTableOperations extends JdbcTableOperations {
public static final String BACK_QUOTE = "`";
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, does the database name require the BACK_QUOTE

@zhoukangcn zhoukangcn force-pushed the f-1339 branch 9 times, most recently from 5ed0a7d to 18d7baf Compare March 14, 2024 06:19
case DATE:
return Types.DateType.get();
case DATETIME:
return Types.TimeType.get();
Copy link
Contributor

Choose a reason for hiding this comment

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

DATETIME should convert to timestamp?

} else if (type instanceof Types.DateType) {
return DATE;
} else if (type instanceof Types.TimeType) {
return DATETIME;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong convert too?

String databaseName, String comment, Map<String, String> properties) {
if (StringUtils.isNotEmpty(comment)) {
LOG.warn(
"Ignoring comment option on database create. doris does not support comment option on database create.");
Copy link
Contributor

Choose a reason for hiding this comment

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

doris -> Doris

@zhoukangcn zhoukangcn force-pushed the f-1339 branch 2 times, most recently from 6734dca to d146085 Compare March 15, 2024 01:32
public class TestDorisUtils {
@Test
public void generatePropertiesSql() {
// Test When properties is null

Choose a reason for hiding this comment

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

typo: When -> when

@zhoukangcn zhoukangcn closed this Mar 15, 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.

[FEATURE] Support Apache Doris Catalog
5 participants