== Abstract Syntax Tree ==
LogicalSink(table=[fluss.nexmark.output_8b92d4c388934bcca1ad7c5c4b4cfd72], fields=[auction, price, bidder, dateTime, extra])
+- LogicalProject(auction=[$0], price=[$2], bidder=[$1], dateTime=[$5], extra=[$6])
   +- LogicalFilter(condition=[AND(>=($5, -($8, 10000:INTERVAL SECOND)), <=($5, $8))])
      +- LogicalJoin(condition=[=($2, $7)], joinType=[inner])
         :- LogicalProject(auction=[$3.auction], bidder=[$3.bidder], price=[$3.price], channel=[$3.channel], url=[$3.url], dateTime=[$5], extra=[$3.extra])
         :  +- LogicalFilter(condition=[=($0, 2)])
         :     +- LogicalProject(event_type=[$0], person=[$1], auction=[$2], bid=[$3], dateTime=[$4], rowtime=[$5])
         :        +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($5, 4000:INTERVAL SECOND)])
         :           +- LogicalProject(event_type=[$0], person=[$1], auction=[$2], bid=[$3], dateTime=[$4], rowtime=[TO_TIMESTAMP_LTZ($4, 3)])
         :              +- LogicalTableScan(table=[[fluss, nexmark, events]])
         +- LogicalProject(maxprice=[$2], dateTime=[$1])
            +- LogicalAggregate(group=[{0, 1}], maxprice=[MAX($2)])
               +- LogicalProject(window_start=[$7], dateTime=[$8], price=[$2])
                  +- LogicalTableFunctionScan(invocation=[TUMBLE(TABLE(#0), DESCRIPTOR(_UTF-16LE'dateTime'), 10000:INTERVAL SECOND)], rowType=[RecordType(BIGINT auction, BIGINT bidder, BIGINT price, VARCHAR(2147483647) channel, VARCHAR(2147483647) url, TIMESTAMP_LTZ(3) *ROWTIME* dateTime, VARCHAR(2147483647) extra, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIMESTAMP_LTZ(3) *ROWTIME* window_time)])
                     +- LogicalProject(auction=[$0], bidder=[$1], price=[$2], channel=[$3], url=[$4], dateTime=[$5], extra=[$6])
                        +- LogicalProject(auction=[$3.auction], bidder=[$3.bidder], price=[$3.price], channel=[$3.channel], url=[$3.url], dateTime=[$5], extra=[$3.extra])
                           +- LogicalFilter(condition=[=($0, 2)])
                              +- LogicalProject(event_type=[$0], person=[$1], auction=[$2], bid=[$3], dateTime=[$4], rowtime=[$5])
                                 +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($5, 4000:INTERVAL SECOND)])
                                    +- LogicalProject(event_type=[$0], person=[$1], auction=[$2], bid=[$3], dateTime=[$4], rowtime=[TO_TIMESTAMP_LTZ($4, 3)])
                                       +- LogicalTableScan(table=[[fluss, nexmark, events]])

== Optimized Physical Plan ==
Sink(table=[fluss.nexmark.output_8b92d4c388934bcca1ad7c5c4b4cfd72], fields=[auction, price, bidder, dateTime, extra])
+- Calc(select=[auction, price, bidder, dateTime, extra])
   +- Join(joinType=[InnerJoin], where=[AND(=(price, maxprice), >=(dateTime, -(dateTime0, 10000:INTERVAL SECOND)), <=(dateTime, dateTime0))], select=[auction, bidder, price, dateTime, extra, maxprice, dateTime0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
      :- Exchange(distribution=[hash[price]])
      :  +- Calc(select=[bid.auction AS auction, bid.bidder AS bidder, bid.price AS price, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, bid.extra AS extra], where=[=(event_type, 2)])
      :     +- TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, bid, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, bid, dateTime])
      +- Exchange(distribution=[hash[maxprice]])
         +- Calc(select=[maxprice, window_end AS dateTime])
            +- GlobalWindowAggregate(window=[TUMBLE(slice_end=[$slice_end], size=[10 s])], select=[MAX(max$0) AS maxprice, start('w$) AS window_start, end('w$) AS window_end])
               +- Exchange(distribution=[single])
                  +- LocalWindowAggregate(window=[TUMBLE(time_col=[dateTime], size=[10 s])], select=[MAX(price) AS max$0, slice_end('w$) AS $slice_end])
                     +- Calc(select=[bid.price AS price, Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS dateTime], where=[=(event_type, 2)])
                        +- TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, bid, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, bid, dateTime])

== Optimized Execution Plan ==
Sink(table=[fluss.nexmark.output_8b92d4c388934bcca1ad7c5c4b4cfd72], fields=[auction, price, bidder, dateTime, extra])
+- Calc(select=[auction, price, bidder, dateTime, extra])
   +- Join(joinType=[InnerJoin], where=[((price = maxprice) AND (dateTime >= (dateTime0 - 10000:INTERVAL SECOND)) AND (dateTime <= dateTime0))], select=[auction, bidder, price, dateTime, extra, maxprice, dateTime0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
      :- Exchange(distribution=[hash[price]])
      :  +- Calc(select=[bid.auction AS auction, bid.bidder AS bidder, bid.price AS price, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, bid.extra AS extra], where=[(event_type = 2)])
      :     +- TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, bid, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, bid, dateTime])(reuse_id=[1])
      +- Exchange(distribution=[hash[maxprice]])
         +- Calc(select=[maxprice, window_end AS dateTime])
            +- GlobalWindowAggregate(window=[TUMBLE(slice_end=[$slice_end], size=[10 s])], select=[MAX(max$0) AS maxprice, start('w$) AS window_start, end('w$) AS window_end])
               +- Exchange(distribution=[single])
                  +- LocalWindowAggregate(window=[TUMBLE(time_col=[dateTime], size=[10 s])], select=[MAX(price) AS max$0, slice_end('w$) AS $slice_end])
                     +- Calc(select=[bid.price AS price, Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS dateTime], where=[(event_type = 2)])
                        +- Reused(reference_id=[1])

== Physical Execution Plan ==
{
  "nodes" : [ {
    "id" : 1061,
    "type" : "Source: events[715]",
    "pact" : "Data Source",
    "contents" : "[715]:TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, bid, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, bid, dateTime])",
    "parallelism" : 4
  }, {
    "id" : 1062,
    "type" : "Calc[716]",
    "pact" : "Operator",
    "contents" : "[716]:Calc(select=[bid.auction AS auction, bid.bidder AS bidder, bid.price AS price, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, bid.extra AS extra], where=[(event_type = 2)])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1061,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1064,
    "type" : "Calc[718]",
    "pact" : "Operator",
    "contents" : "[718]:Calc(select=[bid.price AS price, Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS dateTime], where=[(event_type = 2)])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1061,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1065,
    "type" : "LocalWindowAggregate[719]",
    "pact" : "Operator",
    "contents" : "[719]:LocalWindowAggregate(window=[TUMBLE(time_col=[dateTime], size=[10 s])], select=[MAX(price) AS max$0, slice_end('w$) AS $slice_end])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1064,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1067,
    "type" : "GlobalWindowAggregate[721]",
    "pact" : "Operator",
    "contents" : "[721]:GlobalWindowAggregate(window=[TUMBLE(slice_end=[$slice_end], size=[10 s])], select=[MAX(max$0) AS maxprice, start('w$) AS window_start, end('w$) AS window_end])",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 1065,
      "ship_strategy" : "GLOBAL",
      "side" : "second"
    } ]
  }, {
    "id" : 1068,
    "type" : "Calc[722]",
    "pact" : "Operator",
    "contents" : "[722]:Calc(select=[maxprice, window_end AS dateTime])",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 1067,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1070,
    "type" : "Join[724]",
    "pact" : "Operator",
    "contents" : "[724]:Join(joinType=[InnerJoin], where=[((price = maxprice) AND (dateTime >= (dateTime0 - 10000:INTERVAL SECOND)) AND (dateTime <= dateTime0))], select=[auction, bidder, price, dateTime, extra, maxprice, dateTime0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1062,
      "ship_strategy" : "HASH",
      "side" : "second"
    }, {
      "id" : 1068,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 1071,
    "type" : "Calc[725]",
    "pact" : "Operator",
    "contents" : "[725]:Calc(select=[auction, price, bidder, dateTime, extra])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1070,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1076,
    "type" : "Sink(nexmark.output_8b92d4c388934bcca1ad7c5c4b4cfd72): Writer",
    "pact" : "Operator",
    "contents" : "Sink(nexmark.output_8b92d4c388934bcca1ad7c5c4b4cfd72): Writer",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1071,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  } ]
}