How do I convert a tuple with a wide schema to a narrower subset schema?

How do I convert a tuple with a wide schema to a narrower subset schema?

book

Article ID: KB0076146

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7

Description

How do I convert a tuple with a wide schema to a narrower subset schema?

And how do I do it in such a way that I don't have to explicitly remove all the fields that aren't in Little schema one by one?

I have LittleSchema (int a, int b, int c) and I have BigSchema (int a, int b, int c, int d, int e). That is, BigSchema is a subtype of LittleSchema.

I want to take in BigSchema tuples from input stream BigSchemaIn, convert each BigSchema tuple to a LittleSchema tuple by omitting all the fields not in LittleSchema, and sending the resulting tuples to output stream LittleSchemaOut.

Issue/Introduction

How do I convert a tuple with a wide schema to a narrower subset schema?

Resolution

Use new_tuple_subset_loose() in a Map operator to create a tuple field with the target schema, then in a second Map operator promote all the sub-tuple fields back to the top level fields in the stream.

The Map expression is (for example):
  Add, smallTuple, new_tuple_subset_loose(LittleSchema(), BigSchemaIn.* AS *)

To promote, set the Map to NOT include any fields from the input stream and use expression:
  Add, *, smallTuple.*

Attachments

How do I convert a tuple with a wide schema to a narrower subset schema? get_app