-
Notifications
You must be signed in to change notification settings - Fork 504
implement lookup insert if not exists on the client side #2573
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
Conversation
| .build(); | ||
| TableDescriptor tableDescriptor = TableDescriptor.builder().schema(schema).build(); | ||
| createTable(tablePath, tableDescriptor, false); | ||
| Table invalid_table = conn.getTable(tablePath); |
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.
Error: src/test/java/org/apache/fluss/client/table/FlussTableITCase.java:[651,15] (naming) LocalVariableName: Name 'invalid_table' must match pattern '^[a-z][a-zA-Z0-9]*$'.
| return request; | ||
| } | ||
|
|
||
| public static LookupRequest makeLookupRequest( |
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.
May be two functions makeLookupRequestWithInsertIfNotExists and makeLookupRequest can be merged.
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.
comments addressed. please take a look.
| * | ||
| * @return a new Lookup instance with insert-if-not-exists enabled | ||
| */ | ||
| Lookup enableInsertIfNotExists(); |
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.
Lookup.enableInsertIfNotExists() doesn't document:
Auto-increment column handling, Nullable column restriction.
platinumhamburg
left a comment
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.
LGTM, just a few minor issues.
| .createLookuper()) | ||
| .isInstanceOf(IllegalArgumentException.class) | ||
| .hasMessageContaining("insertIfNotExists can not be used with prefix lookup"); | ||
| assertThatThrownBy( |
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 is a duplicate assertion. Moreover, the test schema contains only one primary key column, 'b', so creating a lookuper with lookupBy("b") should not result in a PrefixKeyLookuper. This issue was not introduced by this PR; rather, the test has exposed an incompleteness in the semantic implementation of TableLookup.
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.
updated.
|
|
||
| @Override | ||
| public Lookup enableInsertIfNotExists() { | ||
| if (lookupColumnNames != 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.
This check can be uniformly moved to createLookuper().
|
|
||
| @Override | ||
| public Lookup lookupBy(List<String> lookupColumnNames) { | ||
| if (insertIfNotExists) { |
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.
Ditto, this check can be uniformly moved to createLookuper().
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.
good suggestion. done.
| @Internal | ||
| public enum LookupType { | ||
| LOOKUP, | ||
| LOOKUP_WITH_INSERT_IF_NOT_EXISTS, |
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.
I think there's no need to extend the enum definition here.
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.
We need to group the different lookups in the lookupQueue into different batches in https://github.com/apache/fluss/blob/main/fluss-client/src/main/java/org/apache/fluss/client/lookup/LookupSender.java#L152 so I introduced this new type
wuchong
left a comment
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.
Thanks @xx789633 , the implemenation looks clean and good to me. I only left 2 minor comments about the copying problem. I have appended a commit to fix it. So I will merge it once CI is passed.
| public Lookup lookupBy(List<String> lookupColumnNames) { | ||
| return new TableLookup( | ||
| tableInfo, schemaGetter, metadataUpdater, lookupClient, lookupColumnNames); | ||
| tableInfo, schemaGetter, metadataUpdater, lookupClient, lookupColumnNames, false); |
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.
We should copy with the existing insertIfNotExists, rather than override it to false.
|
|
||
| @Override | ||
| public Lookup enableInsertIfNotExists() { | ||
| return new TableLookup(tableInfo, schemaGetter, metadataUpdater, lookupClient, null, true); |
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.
We should copy with the existing lookupColumnNames, rather than override it to null.
Purpose
Linked issue: close #2591
Brief change log
Tests
API and Format
Documentation