== Abstract Syntax Tree ==
LogicalSink(table=[fluss.nexmark.output_4bf75dd7c052486aba77d5424b347807], fields=[auction, bidder, price, channel, url, dateTime, extra])
+- LogicalProject(auction=[$0], bidder=[$1], price=[$2], channel=[$3], url=[$4], dateTime=[$5], extra=[$6])
   +- LogicalFilter(condition=[<=($7, 1)])
      +- LogicalProject(auction=[$0], bidder=[$1], price=[$2], channel=[$3], url=[$4], dateTime=[$5], extra=[$6], rank_number=[ROW_NUMBER() OVER (PARTITION BY $1, $0 ORDER BY $5 DESC NULLS LAST)])
         +- 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_4bf75dd7c052486aba77d5424b347807], fields=[auction, bidder, price, channel, url, dateTime, extra])
+- Calc(select=[$1 AS auction, $2 AS bidder, $3 AS price, $4 AS channel, $5 AS url, rowtime AS dateTime, $6 AS extra])
   +- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=1], partitionBy=[$1, $2], orderBy=[ROWTIME rowtime DESC], select=[rowtime, $1, $2, $3, $4, $5, $6])
      +- Exchange(distribution=[hash[$1, $2]])
         +- Calc(select=[Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS rowtime, bid.auction AS $1, bid.bidder AS $2, bid.price AS $3, bid.channel AS $4, bid.url AS $5, bid.extra AS $6], where=[=(event_type, 2)])
            +- MiniBatchAssigner(interval=[2000ms], mode=[RowTime])
               +- 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_4bf75dd7c052486aba77d5424b347807], fields=[auction, bidder, price, channel, url, dateTime, extra])
+- Calc(select=[$1 AS auction, $2 AS bidder, $3 AS price, $4 AS channel, $5 AS url, rowtime AS dateTime, $6 AS extra])
   +- Deduplicate(keep=[LastRow], key=[$1, $2], order=[ROWTIME], outputInsertOnly=[false])
      +- Exchange(distribution=[hash[$1, $2]])
         +- Calc(select=[Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS rowtime, bid.auction AS $1, bid.bidder AS $2, bid.price AS $3, bid.channel AS $4, bid.url AS $5, bid.extra AS $6], where=[(event_type = 2)])
            +- MiniBatchAssigner(interval=[2000ms], mode=[RowTime])
               +- 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])

== Physical Execution Plan ==
{
  "nodes" : [ {
    "id" : 3351,
    "type" : "Source: events[2249]",
    "pact" : "Data Source",
    "contents" : "[2249]: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" : 3352,
    "type" : "MiniBatchAssigner[2250]",
    "pact" : "Operator",
    "contents" : "[2250]:MiniBatchAssigner(interval=[2000ms], mode=[RowTime])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3351,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3353,
    "type" : "Calc[2251]",
    "pact" : "Operator",
    "contents" : "[2251]:Calc(select=[Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS rowtime, bid.auction AS $1, bid.bidder AS $2, bid.price AS $3, bid.channel AS $4, bid.url AS $5, bid.extra AS $6], where=[(event_type = 2)])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3352,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3355,
    "type" : "Deduplicate[2253]",
    "pact" : "Operator",
    "contents" : "[2253]:Deduplicate(keep=[LastRow], key=[$1, $2], order=[ROWTIME], outputInsertOnly=[false])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3353,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 3356,
    "type" : "Calc[2254]",
    "pact" : "Operator",
    "contents" : "[2254]:Calc(select=[$1 AS auction, $2 AS bidder, $3 AS price, $4 AS channel, $5 AS url, rowtime AS dateTime, $6 AS extra])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3355,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3357,
    "type" : "ConstraintEnforcer[2255]",
    "pact" : "Operator",
    "contents" : "[2255]:ConstraintEnforcer[NotNullEnforcer(fields=[auction, bidder])]",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3356,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3358,
    "type" : "StreamRecordTimestampInserter[2255]",
    "pact" : "Operator",
    "contents" : "[2255]:StreamRecordTimestampInserter(rowtime field: 5)",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3357,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3363,
    "type" : "Sink(nexmark.output_4bf75dd7c052486aba77d5424b347807): Writer",
    "pact" : "Operator",
    "contents" : "Sink(nexmark.output_4bf75dd7c052486aba77d5424b347807): Writer",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3358,
      "ship_strategy" : "BUCKET",
      "side" : "second"
    } ]
  } ]
}