Starting with TIBCO® Streaming 10.5.0, StreamBase Studio provides the Evaluate StreamBase Expression dialog.
This feature allows you to enter expressions in the StreamBase expression language to have their syntax validated and results calculated. This allows you to validate expressions in your EventFlow module without having to run a test module with Map operator to validate the syntax.
This feature is especially useful when defining custom functions written in the expression language, and allows you to append a parenthesized argument list to a function definition to test your defined function against those arguments.
This feature replaces the sbd --eval
functionality provided by the legacy StreamBase 7 series.
Open the Evaluate StreamBase Expression dialog as follows:
-
Open at any time, with
> .This results in a non-modal dialog that preserves access to Studio functionality. You can keep this dialog open and move it beside Studio or to a second monitor.
-
Open when editing an expression in an operator that accepts StreamBase expressions, such as in the Additional Expressions panel of a Map operator. In that context:
-
Press F2 twice to enter the Edit Expression window.
-
Press F2 again to open the Evaluate dialog.
Note
When using this triple F2 method, any expression currently in the Edit Expression window is NOT preserved. If you intend to evaluate the current expression, remember to copy it to the clipboard before the final F2 so that you can paste it into the Evaluate StreamBase Expression dialog.
This triple F2 method results in a modal dialog, because the Edit Expression window is still open underneath.
-
The Evaluate StreamBase Expression dialog has the following features.
- History
-
Studio preserves the last several unique expressions you evaluated so that you can select among them to continue editing. This history survives a restart of Studio, but is not preserved if you change Studio workspaces.
- Expression
-
When entering your StreamBase expression, color coding, multiple line editing, and support for comments is the same as in an Edit Expression window in a Map operator. Ctrl+Space autocomplete and Content Assistance features are also available.
Click the Chooser and Details sub-panels alongside the dialog, with the same functionality as in the Functions tab of the Properties view. Use these sub-panels to locate an expression language function of interest.
button in the lower left corner to toggle open or closed - Evaluate
-
Click the Enter to evaluate the current expression. Multiple evaluations of the same expression do not take up entries in the History list.
button or press - Context project
-
Use this control to select the Studio project you are working in. However, this does not provide access to the field names in that project.
- Result
-
The result of an evaluation are in two parts: data type and result values. Failed evaluations provide a detailed error message that helps you track down the source of the error.
- Copy Expr and Close
-
Click this control when your expression passes validation and you want to use it in an EventFlow component's Expressions field. Expressions are NOT automatically copied on exit.
- Copy Result and Close
-
You can use the Evaluate StreamBase Expression dialog as a calculator to evaluate a numerical expression, or as a way to format the results of an evaluation into StreamBase's CSV output format. In this case, use this button to preserve the results of your evaluation.
- Close
-
Use this button or the Esc key to close the dialog without preserving the current expression or current results.
Keep in mind the following limitations when using the Evaluate StreamBase Expression dialog:
-
The dialog does not have access to the field names in streams in the current EventFlow module, or to the field names in named schemas. While a typical expression would evaluate a field's contents at runtime, to use the Evaluator, you must substitute a placeholder value for purposes of evaluation.
For example, a field with type tuple could be replaced with the
tuple()
function that defines the same schema as the field of interest. A field with a numerical type (int, long, or double) could substitute an actual value. This is the approach that the Expressions page uses to show examples of expression language functions outside the context of a working EventFlow module. -
There are expression language functions that cannot be evaluated because they cannot access StreamBase Runtime values at authoring time. These include the
eval()
function and the functions in the Runtime and System categories of expression language functions. -
Evaluating aggregate functions requires an aggregate context that the dialog cannot provide. Thus, the Evaluate dialog is limited to simple, scalar expression language functions.