Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Optional;

import static io.airlift.configuration.ConditionalModule.conditionalModule;
import static io.airlift.configuration.ConfigBinder.configBinder;

public class HiveMetastoreModule
extends AbstractConfigurationAwareModule
Expand All @@ -42,9 +43,8 @@ protected void setup(Binder binder)
{
if (metastore.isPresent()) {
binder.bind(HiveMetastoreFactory.class).annotatedWith(RawHiveMetastoreFactory.class).toInstance(HiveMetastoreFactory.ofInstance(metastore.get()));
MetastoreTypeConfig metastoreTypeConfig = new MetastoreTypeConfig();
metastoreTypeConfig.setMetastoreType("provided");
binder.bind(MetastoreTypeConfig.class).toInstance(metastoreTypeConfig);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was intentionally like this

configBinder(binder).bindConfigDefaults(MetastoreTypeConfig.class, config -> config.setMetastoreType("provided"));
configBinder(binder).bindConfig(MetastoreTypeConfig.class);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is wrong. Here the code intention is not to expose any configurable properties

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked with @homar about this and was under the impression that this was done this way because there was no better way. I kinda understand why it's like this, but the current way is wrong too :)

Here the code intention is not to expose any configurable properties

I get that. But this code path is only used when HiveQueryRunner is used, so I added an assertion there to prevent setting this property. I was hoping this would have the same effect 🤷

}
else {
bindMetastoreModule("thrift", new ThriftMetastoreModule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;

public final class HiveQueryRunner
Expand Down Expand Up @@ -138,6 +139,9 @@ public SELF setSkipTimezoneSetup(boolean skipTimezoneSetup)

public SELF setHiveProperties(Map<String, String> hiveProperties)
{
assertThat(hiveProperties)
.withFailMessage("Setting hive.metastore is not allowed in HiveQueryRunner")
.doesNotContainKey("hive.metastore");
this.hiveProperties = ImmutableMap.<String, String>builder()
.putAll(requireNonNull(hiveProperties, "hiveProperties is null"));
return self();
Expand Down