Runtime Schema Cast Operator Sample

About This Sample

The Runtime Schema Cast operator casts its input schema to its configured target output schema at run time. This operator is used in nested modules to expand the subfields within a capture field, either by flattening or nesting the captured subfields. Flattened subfields appear as top-level fields of the target schema, while nested fields appear as subfields of a top-level tuple field whose name matches that of the captured field.

See Using the Runtime Schema Cast Operator for more on possible uses for this operator.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter cast in the search field to narrow the list of options.

  • Select Runtime Schema Cast Operator from the Data Constructs and Operators category,

  • Click Import Now.

StreamBase Studio creates a single project containing the sample files.

Running This Sample in StreamBase Studio

  1. In the Project Explorer view, open this sample's folder.

    Keep an eye on the bottom right status bar of the Studio window. Make sure any Updating, Downloading, Building, or Rebuild project messages finish before you proceed.

  2. Open the src/main/eventflow/packageName folder.

  3. Double-click to open the runtime-cast-example-outer.sbapp module. Make sure the module is the currently active tab in the EventFlow Editor.

  4. Click the Run

  5. Wait for the Waiting for fragment to initialize message to clear.

  6. In the Manual Input view, click Send Data to send the default null

  7. In the Console view, observe the tuples before and after being flattened by the FlattenCaptureFields operator and again after being un-flattened by the UnflattenCaptureFields:

    • In the tuple logged by the LogBeforeFlatten operator, the captured fields are displayed as subfields of the InstrumentFields top-level field.

    • In the tuple logged by the LogAfterFlatten operator, the captured fields are displayed as top-level fields.

    • Finally, in the tuple logged by the LogAfterUnflatten operator, the captured fields are displayed once again as subfields of the InstrumentFields top-level field.

  8. Press F9 or click the Terminate EventFlow Fragment button.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:

studio-workspace/sample_runtime-cast-operator

See Default Installation Directories for the default location of studio-workspace on your system.