-
Notifications
You must be signed in to change notification settings - Fork 37
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
Create namespace metadata when importing tables #1260
Conversation
b02222a
to
6ac0faa
Compare
6ac0faa
to
8f1495f
Compare
public void importTable(String namespace, String table, Map<String, String> options) | ||
throws ExecutionException { | ||
try (Connection connection = dataSource.getConnection()) { | ||
TableMetadata tableMetadata = getImportTableMetadata(namespace, table); | ||
createNamespacesTableIfNotExists(connection); | ||
upsertIntoNamespacesTable(connection, namespace); | ||
addTableMetadata(connection, namespace, table, tableMetadata, true, false); | ||
} catch (SQLException | ExecutionException e) { |
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.
For the JdbcAdmin, Metadata for the namespace is created when importing a table.
@@ -231,8 +231,8 @@ public void importTable(String namespace, String table) throws ExecutionExceptio | |||
} | |||
|
|||
// add ScalarDB metadata | |||
admin.repairTable( | |||
namespace, table, buildTransactionTableMetadata(tableMetadata), ImmutableMap.of()); | |||
admin.repairNamespace(namespace, options); |
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.
For the ConsensusCommitAdmin, we create the namespace metadata using repair
@@ -79,7 +79,6 @@ protected abstract Map<String, TableMetadata> createExistingDatabaseWithAllDataT | |||
@Test | |||
public void importTable_ShouldWorkProperly() throws Exception { | |||
// Arrange | |||
admin.repairNamespace(getNamespace(), getCreationOptions()); |
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.
Remove several admin.repairNamespace()
or admin.createNamespace()
call from the DistributedStorageAdminImportTableIntegrationTestBase.java
and DistributedTransactionAdminImportTableIntegrationTestBase.java
that were put as a temporary measure for these tests to run.
@@ -1,60 +0,0 @@ | |||
package com.scalar.db.transaction.jdbc; |
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 JDBC transaction admin will be deleted in this release so we can remove this test class.
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! 👍
@@ -413,9 +414,9 @@ public void importTables(List<ImportTableSchema> tableSchemaList) throws SchemaL | |||
String table = tableSchema.getTable(); | |||
try { | |||
if (tableSchema.isTransactionTable()) { | |||
transactionAdmin.get().importTable(namespace, table); | |||
transactionAdmin.get().importTable(namespace, table, Collections.emptyMap()); |
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 we should add Map<String, String> options
to ImportTableSchema
, and pass it to importTable()
as the third argument. What do you think?
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.
Ok.
Similarly to TableSchema
, we could define custom options for each table in the schema file or pass options globally via CLI argument that will be applied to each table.
I realized that setting a given option via the CLI and also in the schema file will throw an exception because of this (the same option key will be added twice in the list builder and this is not allowed by default). I don't know if this behavior is intended eventually. If an option is set globally as CLI argument and in the schema file, using the value specified in the schema file is more user-friendly in my opinion.
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.
If an option is set globally as CLI argument and in the schema file, using the value specified in the schema file is more user-friendly in my opinion.
I agree. That's more user-friendly behavior.
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 added the options handling for the Schema Loader --import
command in b6e16cf and it follows this principle.
If an option is set globally as CLI argument and in the schema file, using the value specified in the schema file is more user-friendly in my opinion.
I will update the options handling for the other commands besides --import
to follow this principle (all using the TableSchema
class) in another PR.
Thanks for your comment and PTAL when you get the chance.
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! Thank you!
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! Thank you!
6bc2078
to
7e7b95b
Compare
7e7b95b
to
b6e16cf
Compare
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! Thank you!
Description
In the table importing feature, we need to create namespace metadata if they do not exist when importing a table.
Related issues and/or PRs
Changes made
JdbcAdmin
andConsensuCommitAdmin
importTable()
method to create the metadata of the imported table namespace.admin.importTable(String namespace, String table, Map<String, String> options)
: theoptions
parameter is added. This parameter is required to pass specific options when creating namespace metadata for the Cassandra and Dynamo Admin. Even though the import feature is not supported for these storages as of now, we update the signature to be future-proof.Checklist
Additional notes (optional)
N/A
Release notes
N/A