-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add support for external db for schema management in mongodb connector #8956
Add support for external db for schema management in mongodb connector #8956
Conversation
@hashhar Kindly have a look over the draft changes done. |
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.
Some initial comments.
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
Re: #8956 (comment) I see this is for the collection names. Earlier it was just We need to preserve backcompat (which is possible by not setting the db-name). I think the cleanest solution is to make If collection-name is specified then the code behaves as the old impl where each DB has one collection with the name specified in collection-name. |
@hashhar I see your point. Let me make the changes and commit. |
One more question : different DBs can have collections with the same name. How does it work with the new mechanism you are adding? |
So this should be fine actually. For example, you have have database X and database Y and a meta data database META. Inside meta 2 collections will be created with the same name as database names. META will have 2 collections X and Y. Lets say X and Y both have a same table name sample. So inside META we only query in X collection where tableName="sample" for sample table of X and for Y we query in Y collection. Both tables with same name but have entries in different collections in meta data database because they are from different databases. Hope i was able to explain ? |
@hashhar Did some changes. Please have a look once you get time :) |
@@ -59,6 +59,7 @@ Property Name Description | |||
``mongodb.write-concern`` The write concern | |||
``mongodb.required-replica-set`` The required replica set name | |||
``mongodb.cursor-batch-size`` The number of elements to return in a batch | |||
``mongodb.schema-database`` The database to use for schema management |
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 property should actually be placed right after
mongodb.schema-collection
. - Since we are improving the metadata management, there should be a point in both that only either of these will be used. Not both.
mongodb.schema-collection
should be marked as deprecated. And we better remove it after couple of releases.
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.
mongodb.schema-collection should be marked as deprecated. And we better remove it after couple of releases.
I disagree. I don't think we would like to break the backward compatibility.
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.
mongodb.schema-collection should be marked as deprecated. And we better remove it after couple of releases.
I disagree. I don't think we would like to break the backward compatibility.
Alright. Makes sense.
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 below comment isn't addressed. I think right "before" is better considering the hierarchy.
This property should actually be placed right after mongodb.schema-collection.
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.
Done :)
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
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.
Please fix TestMongoClientConfig
and add some tests.
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
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.
Some more comments.
The impl looks good now. Can you also add some add tests too to make this is working as intended?
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoSession.java
Outdated
Show resolved
Hide resolved
Added the fixes for the test cases |
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.
Please separate into two commits, index-option and external-db.
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
@@ -59,6 +59,7 @@ Property Name Description | |||
``mongodb.write-concern`` The write concern | |||
``mongodb.required-replica-set`` The required replica set name | |||
``mongodb.cursor-batch-size`` The number of elements to return in a batch | |||
``mongodb.schema-database`` The database to use for schema management |
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 below comment isn't addressed. I think right "before" is better considering the hierarchy.
This property should actually be placed right after mongodb.schema-collection.
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
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.
Almost good to me. Please squash and separate into 2 commits (create-index and schema-database) when applying comments.
plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
plugin/trino-mongodb/src/main/java/io/trino/plugin/mongodb/MongoClientConfig.java
Outdated
Show resolved
Hide resolved
d659486
to
f2f8beb
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.
Let's add TestMongoExternalDatabaseConnectorSmokeTest
that extends BaseMongoConnectorSmokeTest with mongodb.schema-database
config property.
``mongodb.schema-collection`` A collection which contains schema information | ||
``mongodb.create-index-for-schema.enabled``Create an index for schema collection when it doesn't exist |
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.
Please check build failure.
@@ -91,7 +91,7 @@ | |||
|
|||
public class MongoSession | |||
{ | |||
private static final Logger log = Logger.get(MongoSession.class); | |||
private static final Logger log = Logger.get(io.trino.plugin.mongodb.MongoSession.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.
Revert unrelated change.
@@ -147,6 +151,7 @@ public void shutdown() | |||
public List<String> getAllSchemas() | |||
{ | |||
return ImmutableList.copyOf(client.listDatabaseNames()).stream() | |||
.filter(name -> schemaDatabase.map(s -> !name.equals(s)).orElse(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.
Rename s
to schema
.
@@ -54,6 +56,7 @@ public void testExplicitPropertyMappings() | |||
{ | |||
Map<String, String> properties = new ImmutableMap.Builder<String, String>() | |||
.put("mongodb.schema-collection", "_my_schema") | |||
.put("mongodb.enable-schema-create-index", "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.
Please correct the property name.
{ | ||
Map<String, String> properties = new ImmutableMap.Builder<String, String>() | ||
.put("mongodb.schema-database", "trino_meta_data_db") | ||
.put("mongodb.enable-schema-create-index", "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.
Same as the above comment.
👋 @academy-codex - this PR has become inactive. If you're still interested in working on it, please let us know. We're working on closing out old and inactive PRs, so if you're too busy or this has too many merge conflicts to be worth picking back up, we'll be making another pass to close it out in a few weeks. |
Closing this one out due to inactivity, but please reopen if you would like to pick this back up. |
Hey! I want to pick this back up :) |
2e051dc
to
6a4e483
Compare
You can reopen the PR .. and then we can continue |
Aim: Fixes #8887
Description: