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

remove addRowkeyElement in mutation op #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GroundWu
Copy link
Contributor

Summary

remove addRowkeyElement in mutation interface

Solution Description

In mutation interface, there will call addRowkeyElement implicit. This will caused error in scene following:

create table test_demo (
 c1 int not null,
 c2 int not null,
 c3 varchar(255) not null,
 primary(c1,c2),
 key idx(c1, c3) local) partition by key(c1) partitions 3;

tableapi case:

String tableName = "test_demo"
// insert with mutate
Row rowKey = row(colVal("c1", 1), colVal("c2", "c2_col")));
Row row = row();
row.add(colVal("c3", "c3_col"));
client.insert(tableName).setRowKey(rowKey).addMutateRow(row).execute();

// query with local by old interface
// it will cause exception:
TableQuery query = client.query(tableName).indexName("idx").setScanRangeColumns("c1", "c3");
query.addScanRange(new Object[]{1, ObObj.getMin()}, new Object[]{"1", ObObj.getMax()});
QueryResultSet resultSet = query.execute()

In table test_demo,the partition key is "c1", and the addRowkeyElement must be set as "c1" so that the query can be executed. But in mutation interface, it will call addRowkeyElement and set it to "c1,c2" which cause query execution throw exception.
In this PR, we remove addRowkeyElement in mutation interface and user must call addRowkeyElement to set the partion key before doing operation, like following case:

String tableName = "test_demo"
 ((ObTableClient) client).addRowKeyElement(tableName, new String[]{"c1"});
// insert with mutate
Row rowKey = row(colVal("c1", 1), colVal("c2", "c2_col")));
Row row = row();
row.add(colVal("c3", "c3_col"));
client.insert(tableName).setRowKey(rowKey).addMutateRow(row).execute();

TableQuery query = client.query(tableName).indexName("idx").setScanRangeColumns("c1", "c3");
query.addScanRange(new Object[]{1, ObObj.getMin()}, new Object[]{"1", ObObj.getMax()});
QueryResultSet resultSet = query.execute()

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.

1 participant