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

[#3282] improvement: Support sort order when create the Doris table. #3283

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yuqi1129
Copy link
Contributor

@yuqi1129 yuqi1129 commented May 6, 2024

What changes were proposed in this pull request?

  1. Move check sortorder logic into the corresponding implementation from JdbcTableOperation
  2. Support 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

@yuqi1129 yuqi1129 self-assigned this May 6, 2024
@yuqi1129 yuqi1129 added the need backport Issues that need to backport to another branch label May 6, 2024
@yuqi1129
Copy link
Contributor Author

yuqi1129 commented May 9, 2024

@zhoukangcn
Could you kindly review it for me?

@qqqttt123 qqqttt123 changed the title [#3282] Support sort order when create the Doris table. [#3282] feat: Support sort order when create the Doris table. May 9, 2024
@qqqttt123 qqqttt123 changed the title [#3282] feat: Support sort order when create the Doris table. [#3282] improvement: Support sort order when create the Doris table. May 9, 2024
@@ -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,
Copy link
Contributor

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.

}

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");
Copy link
Contributor

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,
Copy link
Contributor

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"));
Copy link
Contributor

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(")");
Copy link
Contributor

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?

Copy link
Contributor Author

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),
Copy link
Contributor

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?

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, It will use the default sort direction ASCENDING.

@yuqi1129
Copy link
Contributor Author

After discussion with @zhoukangcn , this PR should be holds until we confirm that the syntax of DUPLICATE KEY equals to Sort order. It seems that SR does not have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-0.5 need backport Issues that need to backport to another branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Support SortOrder for Doris catalog
2 participants