Skip to main content
Available for Enterprise Edition only.
This page provides information about how gems are written in code. Reference this page when you are building or editing custom gems.

Requirements

Some options require a specific gemLibsVersion. To update this, you must manually change the gemLibsVersion value inside pbt_project.yml in your project Git repository.

Mode

There are a few different types of gems that you can create. The table below describes each mode you can choose.

Classes

The following classes must be included in all Spark gems. Each class extends a base class that Prophecy has defined.
  • A class where you inherit the representation of the overall gem.
  • A class that contains the properties to be made available to the user for this particular gem.
  • A class that defines the Spark code that needs to run on your Spark cluster.

Functions

The following functions can be used to customize Spark gems.

Examples

Parent Class

Properties Classes

Dialog (UI)

After the Dialog object is defined, it is serialized as JSON and rendered in the UI. When you preview this visual interface of the example code above, it appears like this: Dialog Various UI components can be added to this function such as scroll boxes, tabs, buttons, and more. You can also group these components into different panels. Column Selector: This is a special property that you should add if you want to select the columns from UI and then highlight the used columns using the onChange function.

Validation

State Changes

Component Code

If you want to test your Spark code, you can modify properties in the visual preview and save the changes. Then, you can see the generated Spark code which will eventually run on your cluster.
To keep gems generally compatible with each other, they must conform to a common interface. Therefore, as defined in the apply() method, gems must accept and produce DataFrame objects at the input and output ports.
To assist the Spark Catalyst Optimizer to build scalable code, Prophecy performs some minor optimizations to the code generated by the apply() method.

Dataset Format example

The previous examples were for Transformation gems. The following example is the code for a Dataset Format gem.