Typecheck error "no sub-field" after making child module non-hygienic

Typecheck error "no sub-field" after making child module non-hygienic

book

Article ID: KB0075742

calendar_today

Updated On:

Products Versions
TIBCO Streaming -

Description

In many cases when there is a schema difference between the input stream schema of the sub-module and the schema of the arc into the Module reference, this can be resolved by configuring the sub-module .sbapp to be non-hygienic. This change allows the calling module's arc schema to override the input schema of the sub-module input stream.

We had this error when the sub-module was marked hygienic:

Errors while typechecking stream InputStream: SchemaMismatchException: the field "payload" has type (a int, b int) in outer stream at file /project/src/main/eventflow/com/example/project/manager.sbapp element InputStream, but type (a int, b int, c int) in inner stream at file com.example.project.worker element InputStream.  Expected "(payload (a int, b int, c int))", got "(payload (a int, b int))"    manager.sbapp    /project/src/main/eventflow/com/example/project    com.example.project.worker at /project/src/main/eventflow/com/example/project/manager.sbapp:workerRef1    StreamBase Typecheck Problem

When we marked the sub-module .sbapp non-hygienic,
Annotation to mark .sbapp non-hygienic, allowing schema override
we saw this error instead:

payload has no sub-field named c, valid fields: [a, b]    manager.sbapp    /project/src/main/eventflow/com/example/project    com.example.project.worker:Map at /project/src/main/eventflow/com/example/project/manager.sbapp:workerRef1    StreamBase Typecheck Problem

If neither hygienic or non-hygienic resolves the problem, how do we correct this?

Resolution

The first error (when the sub-module was hygienic) simply reports the schema mismatch, but does not indicate that the missing field is otherwise required.

The second error (when the sub-module was non-hygienic) shows that the error was raised in " worker:Map", which says that the missing field was needed in a Map operator expression. 

In all cases if a field is used within a module, that field must be supplied, and ideally contains, when the application is running, a data value useful for the expression that references it.

If the missing fields are not important to the business purpose of the sub-module and may contain a 'null' value, there two common ways to enforce the schema on the arc to match the needed Named Schema.

A) Use a Union operator to merge a nearly complete schema with the expected schema from an unused input stream.
Schemas of the Union input and output arcs
B) Use a Map operator with a Named Schema to mutate the input tuple into a tuple with the Named Schema type using expression:
  Add, *, TheNamedSchema(input1.* as *)
For example:
Map expression using wildcards to map an input schema into a named schema

For correctness, the Named Schema should be a superset of the supplied but incomplete schema.

Issue/Introduction

Reconcile schemas using a named schema