-
Notifications
You must be signed in to change notification settings - Fork 383
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
Conversation
ec4af86
to
1b13072
Compare
@zhoukangcn |
@yuqi1129 yes, please review this PR. Thanks. |
@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 = ?"; |
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.
Can the user has the privilege to access system table like MySQL?
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.
Is Doris case-sensitive?
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.
@diqiu50 Doris is case-insensitive
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.
@yuqi1129 yes, user has default privilege to use database, and can list all tables.
...ris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
Outdated
Show resolved
Hide resolved
expression -> { | ||
Preconditions.checkArgument( | ||
Arrays.stream(columns) | ||
.anyMatch(column -> column.name().equalsIgnoreCase(expression.toString())), |
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.
So, is the Doris column name case-insensitive?
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.
yes, Doris column name is case-insensitive, and will convert to lowercase
...ris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
Outdated
Show resolved
Hide resolved
...ris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
Outdated
Show resolved
Hide resolved
...ris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
Show resolved
Hide resolved
} else if (change instanceof TableChange.UpdateColumnType) { | ||
lazyLoadTable = getOrCreateTable(databaseName, tableName, lazyLoadTable); | ||
TableChange.UpdateColumnType updateColumnType = (TableChange.UpdateColumnType) change; | ||
alterSql.add(updateColumnTypeFieldDefinition(updateColumnType, lazyLoadTable)); |
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.
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';"; |
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.
Is using SELECT 1
better?
package com.datastrato.gravitino.catalog.doris.operation; | ||
|
||
/** Test class for {@link DorisTableOperations}. */ | ||
public class TestDorisTableOperations {} |
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.
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 |
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.
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() + ")"; |
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.
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 = ?"; |
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.
Is Doris case-sensitive?
|
||
/** Table operations for Doris. */ | ||
public class DorisTableOperations extends JdbcTableOperations { | ||
public static final String BACK_QUOTE = "`"; |
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.
Similarly, does the database name require the BACK_QUOTE
5ed0a7d
to
18d7baf
Compare
case DATE: | ||
return Types.DateType.get(); | ||
case DATETIME: | ||
return Types.TimeType.get(); |
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.
DATETIME
should convert to timestamp
?
} else if (type instanceof Types.DateType) { | ||
return DATE; | ||
} else if (type instanceof Types.TimeType) { | ||
return DATETIME; |
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.
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."); |
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.
doris
-> Doris
6734dca
to
d146085
Compare
public class TestDorisUtils { | ||
@Test | ||
public void generatePropertiesSql() { | ||
// Test When properties is null |
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.
typo: When -> when
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