Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
Buildfile: /hive-0.8.0-SNAPSHOT/examples/test-plugin/build.xml

get-class-list:

test:
    [junit] Running org.apache.hive.pdk.PluginTest
    [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 38.955 sec

BUILD SUCCESSFUL

The example plugin is also built and tested as part of the main Hive build in order to verify that the PDK is operating as expected.

Your Own Plugin

To create your own plugin, you can follow the patterns from the example plugin. Let's take a closer look at it. First, the build.xml:

...

  1. Run top-level cleanup.sql (in case a previous test failed in the middle)
  2. Run top-level setup.sql
  3. For each class with @HivePdkUnitTests annotation
    1. Run class cleanup (if any)
    2. Run class setup (if any)
    3. For each @HivePdkUnitTest annotation
      1. Run query
    4. Run class cleanup (if any)
  4. Run top-level cleanup.sql

If you encounter problems during test execution, look in the file TEST-org.apache.hive.pdk.PluginTest.txt for details.

Futures

  • support annotations for other plugin types
  • add more annotations for automatically validating function parameters at runtime (instead of requiring the developer to write imperative Java code for this)
  • add Eclipse support
  • move Hive builtins to use PDK for more convenient testing
  • optimize test performance (invoking CLI over and over is very slow)