Skip to content

HIVE-24551: Hive should include transitive dependencies from calcite after shading it #1792

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
merged 5 commits into from
Dec 21, 2020

Conversation

sunchao
Copy link
Member

@sunchao sunchao commented Dec 17, 2020

What changes were proposed in this pull request?

This includes calcite-core's transitive dependencies:

  • net.hydromatic:eigenbase-properties
  • org.codehaus.janino:janino
  • org.codehaus.janino:commons-compiler
  • org.pentaho:pentaho-aggdesigner-algorithm

in the fat hive-exec jar.

Why are the changes needed?

Currently as part of effort of shading Guava from Hive, we shade Calcite and exclude all its artifacts from the binary distribution. However, this also removes all its transitive dependencies which will still needed at runtime. Without these, Hive queries will fail with error like:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eigenbase/util/property/BooleanProperty
        at org.apache.calcite.util.SaffronProperties.<init>(SaffronProperties.java:66)
        at org.apache.calcite.util.SaffronProperties.instance(SaffronProperties.java:134)
        at org.apache.calcite.util.Util.getDefaultCharset(Util.java:769)
        at org.apache.calcite.rel.type.RelDataTypeFactoryImpl.getDefaultCharset(RelDataTypeFactoryImpl.java:565)
        at org.apache.calcite.sql.type.SqlTypeUtil.addCharsetAndCollation(SqlTypeUtil.java:1070)
        at org.apache.calcite.sql.type.SqlTypeFactoryImpl.createSqlType(SqlTypeFactoryImpl.java:65)
        at org.apache.calcite.rex.RexBuilder.<init>(RexBuilder.java:114)
        at org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:991)
        at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:149)
        at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:106)
        at org.apache.hadoop.hive.ql.parse.CalcitePlanner.logicalPlan(CalcitePlanner.java:1069)
        at org.apache.hadoop.hive.ql.parse.CalcitePlanner.getOptimizedAST(CalcitePlanner.java:1085)
        at org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:364)
        at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:11138)
        at org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:286)
        at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:258)
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:512)
        at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1317)
        at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1457)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1237)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1227)
        at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:233)
        at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:184)
        at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:403)
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:821)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:759)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:686)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:234)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
Caused by: java.lang.ClassNotFoundException: org.eigenbase.util.property.BooleanProperty
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 33 more

Does this PR introduce any user-facing change?

No

How was this patch tested?

Verified that the classes are included in the hive-exec jars with the change. I also manually tested this by launching a HS2 and run a simple query against it. It passed while previous was failing due to the above error.

@sunchao
Copy link
Member Author

sunchao commented Dec 17, 2020

cc @viirya @dongjoon-hyun @szehon-ho

ql/pom.xml Outdated
Comment on lines 883 to 888
<!-- include all of calcite's transitive dependencies as well since
otherwise they'll be removed in assembly packaging -->
<include>net.hydromatic:eigenbase-properties</include>
<include>org.codehaus.janino:janino</include>
<include>org.codehaus.janino:commons-compiler</include>
<include>org.pentaho:pentaho-aggdesigner-algorithm</include>
Copy link
Member

Choose a reason for hiding this comment

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

One question. Will this be flaky? Once calcite changes transitive dependencies, seems we also need to update this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's the downside of it - whenever we upgrade calcite we should check its dependencies and update here as well. I'm not sure if there is an easy way to include an artifact and all its transitive dependencies in the maven-shade-plugin

Copy link
Member

Choose a reason for hiding this comment

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

BTW, I remember in the latest branch, the shading guava PR doesn't include transitive dependencies like that. Do we also need to do it for the branch?

Copy link
Member Author

@sunchao sunchao Dec 17, 2020

Choose a reason for hiding this comment

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

I still need to verify whether there is issue in master/4.0.0 as well - it uses calcite 1.21 which no longer depend on eigenbase that is causing the issue in our case, but I think it might be good to always include transitive dependencies anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

So I tried master branch and didn't hit the issue. However I think I may still open another PR for it since we don't really when the transitive dependencies will be needed at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh actually in master we already handles this here, as part of HIVE-22126. I think we should follow the same approach and explicitly add the transitive dependency in Hive's top-level pom. I think this is also how Spark manages its transitive dependencies? it might be better than pulling out the classes and putting them in the fat jar.

@dongjoon-hyun
Copy link
Member

Thank you for pinging me, @sunchao .

@sunchao
Copy link
Member Author

sunchao commented Dec 21, 2020

Updated the PR to fix a hanging issue when testing org.apache.hadoop.hive.cli.TestAccumuloCliDriver. Right now Hive is using Accumulo version 1.6.0 which depends on Thrift 0.9.0. However Hive uses Thrift 0.9.3 and because of this Accumulo TabletServer may fail with the following exception:

2020-12-20T12:02:18,577 ERROR [ClientPool 1[]] util.NamingThreadFactory: Thread "ClientPool 1" died tried to access field org.apache.thrift.server.AbstractNonblockingServer$FrameBuffer.trans_     from class org.apache.accumulo.server.util.TServerUtils$THsHaServer$Invocation
java.lang.IllegalAccessError: tried to access field org.apache.thrift.server.AbstractNonblockingServer$FrameBuffer.trans_ from class org.apache.accumulo.server.util.                               TServerUtils$THsHaServer$Invocation

which caused the test to hang. After upgrading Accumulo version to 1.7.3 (which is the same version used by Hive 3.0+) the issue is resolved.

@sunchao sunchao merged commit 52a4ab8 into apache:branch-2.3 Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants