-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add config to specify metastore catalog name #24235
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
Merged
ZacBlanco
merged 1 commit into
prestodb:master
from
AnuragKDwivedi:catalog-name-to-metastore
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
presto-hive-common/src/test/java/com/facebook/presto/hive/TestMetadataUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.facebook.presto.hive; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import static com.facebook.presto.hive.MetadataUtils.constructSchemaName; | ||
| import static org.testng.Assert.assertNull; | ||
| import static org.testng.Assert.assertTrue; | ||
|
|
||
| public class TestMetadataUtils | ||
| { | ||
| @Test | ||
| public void testWithCatalogAndValidSchema() | ||
| { | ||
| String result = constructSchemaName(Optional.of("testCatalog"), "testSchema"); | ||
| assertTrue(result.equals("@testCatalog#testSchema")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWithCatalogAndDefaultSchema() | ||
| { | ||
| String result = constructSchemaName(Optional.of("testCatalog"), "default"); | ||
| assertTrue(result.equals("default")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWithCatalogAndSchemaContainingSeparator() | ||
| { | ||
| String result = constructSchemaName(Optional.of("testCatalog"), "schema#with#dot"); | ||
| assertTrue(result.equals("schema#with#dot")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWithoutCatalog() | ||
| { | ||
| String result = constructSchemaName(Optional.empty(), "testSchema"); | ||
| assertTrue(result.equals("testSchema")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWithNullSchema() | ||
| { | ||
| String result = constructSchemaName(Optional.empty(), null); | ||
|
AnuragKDwivedi marked this conversation as resolved.
|
||
| assertNull(result); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWithoutCatalogNameAndEmptySchemaName() | ||
| { | ||
| String result = constructSchemaName(Optional.empty(), ""); | ||
| assertTrue(result.isEmpty()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWithCatalogNameAndEmptySchemaName() | ||
| { | ||
| String result = constructSchemaName(Optional.of("testCatalog"), ""); | ||
| assertTrue(result.equals("@testCatalog#!")); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 feel like a sane default would be the name of the presto catalog. Would it be possible to set that 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.
If we set a default value here, Presto will start sending the catalog name even when the configuration is not explicitly defined in the properties. This could cause issues with different metastores that do not support catalog names as input. The intention was to keep this configurable and only pass it when the metastore can handle it.
Could you share the advantages you see in adding a default value 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.
The advantage is that users would not have to specify it in the first place when using HMS. Consider two hive catalog configured through
hive1.propertiesandhive2.properties. If they were configured to use the same HMS, then inside the config files then in the catalog configuration you would need to set this property ashive.metastore.catalog.name=hive1, etc. If presto already has the catalog name available, it would seem to make sense to default the catalog name to the configured presto catalog nameI do however understand the desire for passing the catalog name to be optional for the case where a metastore doesn't support the "catalog" feature. I'm not sure what the best course of action is other than adding a boolean flag in addition to this one to support both having a sane default and verifying that the feature is enabled
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.
Won't using a boolean
hive.metastore.send-catalog-name=truein the core.config suffice?