Repository navigation
Conversation
defaultDatabase instead of default-namespace config. defaultDatabase instead of default-namespace config.
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
ping @manuzhang |
# Conflicts: # spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
defaultDatabase instead of default-namespace config. defaultNamespace call to wrapped catalog in SparkSessionCatalog
…ase for Spark 3.5
…tStaticCatalogConfigs.java for Spark 3.5
RussellSpitzer
left a comment
There was a problem hiding this comment.
I think the fix here is fine, I still have no idea why we hard coded the default database there but the tests here need a bit of rethinking. It's a huge amount of overhead to just check that we are calling the right method. As is this will start up a whole new metastore and Spark context just to test that we are correctly calling an underlying method.
Instead let's mock the sessionCatalog and just make sure that our mock defaultDatabase method is called correctly.
For an example and we also should probably just put the test in that file as well.
Fair enough, but my test was more of an integration test, checking if the Let me know what you think. Edit: Looks like I might have caused tests to get flaky by changing the global SQLConfig. I'll look into this. |
|
PING @RussellSpitzer |
I still think we should simplify this. The new test is mostly exercising Spark, and it leans on implementation details we don't control. The The The fix in this PR is " So for example @Test
public void defaultNamespaceDelegatesToSessionCatalog() {
TableCatalog sessionCatalog = sessionCatalogWithViews();
SupportsNamespaces sessionNamespaces = (SupportsNamespaces) sessionCatalog;
when(sessionNamespaces.defaultNamespace()).thenReturn(new String[] {"session_default"});
SparkSessionCatalog<?> catalog = new NoViewCatalog<>();
catalog.initialize("spark_catalog", new CaseInsensitiveStringMap(Collections.emptyMap()));
catalog.setDelegateCatalog(sessionCatalog);
assertThat(catalog.defaultNamespace()).containsExactly("session_default");
verify(sessionNamespaces).defaultNamespace();
}Now if you want to skip the test entirely I think that's also fair. This test is really just preserving our intent incase someone changes the method in the future for whatever reason. We don't really do this for any of our other fallbacks so it's probably fine. |
|
@RussellSpitzer In the end I decided against writing any tests for this. I figure, if someone wants to change this one specific line, they probably understand what they are doing. I guess this is now ready to merge. While I have you here, could you take a look at #18221 from a philosophical perspective? If we decide to go ahead with it, I will re-write the tests there. |
Closes #14424.
After a discussion with @manuzhang, I've trimmed down this PR to focus only on fixing the hard-coded namespace in the
SparkSessionCatalog. The proposed change to deprecate thedefault-namespaceconfig in favor of Spark'sdefaultDatabaseis in #18222.What this does is basically just pass the
defaultNamespacecall to the wrappedSessionCatalogthat correctly picks upspark.sql.catalog.spark_catalog.defaultDatabase. Setting this config always worked in the sense that table operations would be executed in the proper Spark namespace, but the caller todefaultNamespace()would never see it. The PR also properly documents which config key is to be used with each type of catalog.On Slack I've expressed concern that someone somewhere might be relying on this hard-coded behavior, and while I can't say for certain that it's not an issue (
catalogAndIdentifierinSpark3Util.javauses it), I can't imagine a scenario where everything would be properly put indefaultDatabase, while the user somehow relied on the hard-coded value "default".