We have support for nested rows so this should be easy. The .withMetadata
would reify the struct, moving from Row to WindowedValue<Row> if I
understand it...

SqlTransform.query("SELECT field1 from PCOLLECTION"):

    Schema = {
      field1: type1,
      field2: type2
    }

    SqlTransform.query(...)

SqlTransform.withMetadata().query("SELECT event_timestamp, value.field1
FROM PCOLLECTION")

    Derived schema = {
      event_timestamp: TIMESTAMP,
      pane_info: { ... }
      value: {
        field1: type1,
        field2: type2,
        ...
      }
    }

SqlTransform would expand into a different composite, and it would be a
straightforward ParDo to adjust the data, possibly automatic via the new
schema conversions.

Embedding the window would be a bit wonky, something like { end_of_window:
TIMESTAMP, encoded_window: bytes } which would be expensive due to
encoding. But timestamp and pane info not so bad.

Kenn

*From: *Anton Kedin <[EMAIL PROTECTED]>
*Date: *Tue, May 14, 2019 at 9:17 AM
*To: * <[EMAIL PROTECTED]>

Reza, can you share more thoughts on how you think this can work