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
[#3282] improvement: Support sort order when create the Doris table. #3283
base: main
Are you sure you want to change the base?
Conversation
@zhoukangcn |
@@ -109,6 +111,10 @@ protected String generateCreateTableSql( | |||
Preconditions.checkArgument( | |||
Distributions.NONE.equals(distribution), "PostgreSQL does not support distribution"); | |||
|
|||
Preconditions.checkArgument( | |||
null == sortOrders || sortOrders.length == 0, |
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.
use ArrayUtils.isNotEmpty(sortOrders)
instead ?
In fact, sortOrders will not be null because DTOConverters
has converted it.
gravitino/common/src/main/java/com/datastrato/gravitino/dto/util/DTOConverters.java
Line 519 in bd28288
return new SortOrderDTO[0]; |
} | ||
|
||
Preconditions.checkArgument( | ||
Distributions.NONE.equals(distribution), "MySQL does not support distribution"); | ||
|
||
Preconditions.checkArgument( | ||
null == sortOrders || sortOrders.length == 0, "MySQL catalog does not support sort orders"); |
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 same to postgres
@@ -91,6 +94,7 @@ public void testBasicTableOperation() { | |||
createProperties(), | |||
null, | |||
distribution, | |||
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.
Just like MysqlTableIT and PostgresTableIT, use SortOrders.EMPTY_SORT_ORDERS
?
JdbcColumn.builder().withName("col_3").withType(VARCHAR_255).withComment("col_3").build(); | ||
columns.add(col_3); | ||
|
||
Distribution distribution = Distributions.hash(32, NamedReference.field("col_1")); |
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.
use DEFAULT_BUCKET_SIZE
sortColumns.add(BACK_QUOTE + fieldReference.fieldName()[0] + BACK_QUOTE); | ||
} | ||
|
||
sqlBuilder.append(" DUPLICATE KEY(").append(Joiner.on(",").join(sortColumns)).append(")"); |
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.
This SQL uses DUPLICATE KEY
, how to specify AGGREGATE KEY
and UNIQUE KEY
?
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.
No, I only found out that DUPLICATE KEY
have similar functionality the identical to sort order
. As far as I known, AGGREGATE KEY and UNIQUE KEY look like SQL constraints and will verify the data to be inserted satisfy this constraints.
|
||
SortOrder[] sortOrders = | ||
new SortOrder[] { | ||
SortOrders.of(NamedReference.field("col_1"), SortDirection.ASCENDING), |
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 DUPLICATE key seems to not support SortDirection, should we use another concept to pass this parameter?
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, It will use the default sort direction ASCENDING
.
After discussion with @zhoukangcn , this PR should be holds until we confirm that the syntax of |
What changes were proposed in this pull request?
sortorder
logic into the corresponding implementation fromJdbcTableOperation
SortOrder
when create a Doris table.Why are the changes needed?
Doris supports creating a sorted table, we need to implement it in Gravitino API.
Close: #3282
Does this PR introduce any user-facing change?
N/A.
How was this patch tested?
Add test
testSortOrderTable