Fixes some createtable bugs:#5990
Conversation
- Fixes bugs with --copy-config (-cc) and --no-default-iterators (-ndi) options of createtable Shell command: - Changes to default iterator settings on src table are now carried over to dest table using -cc - ndi option did not work. Tables were still created with default iterator props. Now works as expected. - Results of using -cc and -ndi in conjunction were incorrect (e.g., copy config of src table (which has default iters) to dest table (specify -ndi) would result in a table with default iters) - New tests to verify expected functionality of createtable command with -cc and -ndi, creating tables with same config as another table via Java API, and NewTableConfiguration with iterator conflicts with default iterators
| @Test | ||
| public void testTablePropsEqual() throws Exception { | ||
| // Want to ensure users can somehow create a table via the Java API that has exactly | ||
| // the same properties of another table (including changes to default properties), similar to | ||
| // the copy config option of the create table Shell command. Cloning the table is expected to | ||
| // be one way and modifying the properties after creation is expected to be another way. |
There was a problem hiding this comment.
Wanted to test the Java API equivalent to --copy-config but doesn't seem like there is one. NewTableConfiguration doesn't appear to have any such functionality (closest is setProperties() but that isn't quite the same), and no TableOperation to create the table with same config as another table. Best way I could think of accomplishing --copy-config via the Java API is modifying the props after the table is created or clone (but obviously clone does more than just copy the config).
There was a problem hiding this comment.
Its super confusing, but there may be a way. I made another comment w/ a suggestion on how to do this. Maybe we could improve this API in 4.0 to make it less confusing.
There was a problem hiding this comment.
Added suggestion in 797e391. Leaving unresolved for now in case we want to open 4.0 issue for new API
There was a problem hiding this comment.
This could be a follow on issue, looking at this PR I think we should impose the following restrictions on the create table shell command options.
- the
--copy-configoption is mutually exclusive with any other option that sets per table props (like--propFile, --prop,--iter`, etc) - the
--propFileoption is mutually exclusive with any other option that sets per table props.
Thinking this would be good for the same reason mentioned on another comment, that the behavior is non-deterministic. It depends on the order that the shell command applies these options to a shared map and that order could changes. This leads to the possibility that the command could behave differently for the same input and options over time which makes it hard to reason about. Otherwise we should document the order that options are applied and test it, but I do not think that is worthwhile.
Going for the behavior that --copy-config or --propFile exactly specify the tables initial config w/ no surprises or caveats.
| @Test | ||
| public void testTablePropsEqual() throws Exception { | ||
| // Want to ensure users can somehow create a table via the Java API that has exactly | ||
| // the same properties of another table (including changes to default properties), similar to | ||
| // the copy config option of the create table Shell command. Cloning the table is expected to | ||
| // be one way and modifying the properties after creation is expected to be another way. |
There was a problem hiding this comment.
Its super confusing, but there may be a way. I made another comment w/ a suggestion on how to do this. Maybe we could improve this API in 4.0 to make it less confusing.
| Set<String> initialProps = IteratorConfigUtil.generateInitialTableProperties(true).keySet(); | ||
| // handles if default props were copied over | ||
| Set<String> initialProps = IteratorConfigUtil.getInitialTableProperties().keySet(); | ||
| initialProps.forEach(initProperties::remove); |
There was a problem hiding this comment.
This behavior is so confusing that I think we would be better off throwing an exception here. I think the intent of this property is not to add default iterators to a new table, but removing them makes this command non deterministic. Would be good to be able to always predict what the create table command will do for a given set of options. Seems to me throwing an exception would be better than being unpredictable. Also throwing an exception does not silently change the behavior of the command in the background which is really hard to detect for any automation using this command.
| initialProps.forEach(initProperties::remove); | |
| if(!Collections.disjoint(initialProps, initProperties.keySet())){ | |
| throw //something | |
| } |
There was a problem hiding this comment.
I agree. This code was broken before these changes, and using -ndi and -cc in conjunction is a bit contradictory and confusing anyways.
|
The two options |
* NewTableConfiguration now considers conflicts with default iterators and those attached via attachIterator. Previously could attach an iterator with the same priority or name as the default iterator (VersioningIterator). * Deprecated NewTableConfiguration.withoutDefaultIterators() in favor of new NewTableConfiguration.withoutDefaults() which function the same, but withoutDefaults() better describes the functionality. * Test changes Co-authored-by: Keith Turner <kturner@apache.org>
|
I believe all the remaining comments pertain to enforcing mutual exclusion for some of the createtable ops and also #5990 (comment). These should probably be done in a separate issue/PR, so I think this PR is good for re-review |
PR apache#5990 intruduced stricter checks to NewTableConfiguration to check that properties or iterators set on the NewTableConfiguration do not conflict with default table properties or iterators. These tests were setting properties which did conflict.
PR #5990 introduced stricter checks to NewTableConfiguration to check that properties or iterators set on the NewTableConfiguration do not conflict with default table properties or iterators. These tests were setting properties which did conflict.
--copy-config(-cc) and--no-default-iterators(-ndi) options ofcreatetableShell command:-cc-ndioption did not work. Tables were still created with default iterator props. Now works as expected.-ccand-ndiin conjunction were incorrect (e.g., copy config of src table (which has default iters) to dest table (specify-ndi) would result in a table with default iters)-ndiin favor of new--no-default-table-props(-ndtp) which functions the same, but better describes the functionality.NewTableConfigurationNewTableConfigurationnow considers conflicts with default iterators and iterators set (either throughattachIterator()orsetProperties()). Previously could set an iterator with the same priority or name as the default iterator (VersioningIterator).NewTableConfiguration.withoutDefaultIterators()in favor of newNewTableConfiguration.withoutDefaults()which functions the same, but better describes the functionality.-ccand-ndi, creating tables with same config as another table via Java API, andNewTableConfigurationwith iterator conflicts with default iteratorscloses #5976