== Abstract Syntax Tree ==
LogicalSink(table=[fluss.nexmark.output_160a21b6d2e84a01b5b7f07125c6552b], fields=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, bid_dateTime, bid_extra])
+- LogicalProject(id=[$0], itemName=[$1], description=[$2], initialBid=[$3], reserve=[$4], dateTime=[$5], expires=[$6], seller=[$7], category=[$8], extra=[$9], auction=[$10], bidder=[$11], price=[$12], bid_dateTime=[$13], bid_extra=[$14])
   +- LogicalFilter(condition=[<=($15, 1)])
      +- LogicalProject(id=[$0], itemName=[$1], description=[$2], initialBid=[$3], reserve=[$4], dateTime=[$5], expires=[$6], seller=[$7], category=[$8], extra=[$9], auction=[$10], bidder=[$11], price=[$12], bid_dateTime=[$15], bid_extra=[$16], rownum=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $12 DESC NULLS LAST, $15 NULLS FIRST)])
         +- LogicalFilter(condition=[AND(=($0, $10), >=($15, $5), <=($15, $6))])
            +- LogicalJoin(condition=[true], joinType=[inner])
               :- LogicalProject(id=[$2.id], itemName=[$2.itemName], description=[$2.description], initialBid=[$2.initialBid], reserve=[$2.reserve], dateTime=[$5], expires=[TO_TIMESTAMP_LTZ($2.expires, 3)], seller=[$2.seller], category=[$2.category], extra=[$2.extra])
               :  +- LogicalFilter(condition=[=($0, 1)])
               :     +- 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(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_160a21b6d2e84a01b5b7f07125c6552b], fields=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])
+- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=1], partitionBy=[id], orderBy=[price DESC, dateTime0 ASC], select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])
   +- Exchange(distribution=[hash[id]])
      +- Calc(select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])
         +- Join(joinType=[InnerJoin], where=[AND(=(id, auction), >=(dateTime0, dateTime), <=(dateTime0, expires))], select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, channel, url, dateTime0, extra0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey], miniBatch=[true])
            :- Exchange(distribution=[hash[id]])
            :  +- Calc(select=[auction.id AS id, auction.itemName AS itemName, auction.description AS description, auction.initialBid AS initialBid, auction.reserve AS reserve, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, TO_TIMESTAMP_LTZ(auction.expires, 3) AS expires, auction.seller AS seller, auction.category AS category, auction.extra AS extra], where=[=(event_type, 1)])
            :     +- MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])
            :        +- TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, auction, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, auction, dateTime])
            +- Exchange(distribution=[hash[auction]])
               +- Calc(select=[bid.auction AS auction, bid.bidder AS bidder, bid.price AS price, bid.channel AS channel, bid.url AS url, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, bid.extra AS extra], where=[=(event_type, 2)])
                  +- MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])
                     +- 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_160a21b6d2e84a01b5b7f07125c6552b], fields=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])
+- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=1], partitionBy=[id], orderBy=[price DESC, dateTime0 ASC], select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])
   +- Exchange(distribution=[hash[id]])
      +- Calc(select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])
         +- Join(joinType=[InnerJoin], where=[((id = auction) AND (dateTime0 >= dateTime) AND (dateTime0 <= expires))], select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, channel, url, dateTime0, extra0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey], miniBatch=[true])
            :- Exchange(distribution=[hash[id]])
            :  +- Calc(select=[auction.id AS id, auction.itemName AS itemName, auction.description AS description, auction.initialBid AS initialBid, auction.reserve AS reserve, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, TO_TIMESTAMP_LTZ(auction.expires, 3) AS expires, auction.seller AS seller, auction.category AS category, auction.extra AS extra], where=[(event_type = 1)])
            :     +- MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])
            :        +- TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, auction, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, auction, dateTime])
            +- Exchange(distribution=[hash[auction]])
               +- Calc(select=[bid.auction AS auction, bid.bidder AS bidder, bid.price AS price, bid.channel AS channel, bid.url AS url, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, bid.extra AS extra], where=[(event_type = 2)])
                  +- MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])
                     +- 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" : 1989,
    "type" : "Source: events[1407]",
    "pact" : "Data Source",
    "contents" : "[1407]:TableSourceScan(table=[[fluss, nexmark, events, project=[event_type, auction, dateTime], watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic], filter=[]]], fields=[event_type, auction, dateTime])",
    "parallelism" : 4
  }, {
    "id" : 1990,
    "type" : "MiniBatchAssigner[1408]",
    "pact" : "Operator",
    "contents" : "[1408]:MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1989,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1991,
    "type" : "Calc[1409]",
    "pact" : "Operator",
    "contents" : "[1409]:Calc(select=[auction.id AS id, auction.itemName AS itemName, auction.description AS description, auction.initialBid AS initialBid, auction.reserve AS reserve, CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)) AS dateTime, TO_TIMESTAMP_LTZ(auction.expires, 3) AS expires, auction.seller AS seller, auction.category AS category, auction.extra AS extra], where=[(event_type = 1)])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1990,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1993,
    "type" : "Source: events[1411]",
    "pact" : "Data Source",
    "contents" : "[1411]: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" : 1994,
    "type" : "MiniBatchAssigner[1412]",
    "pact" : "Operator",
    "contents" : "[1412]:MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1993,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1995,
    "type" : "Calc[1413]",
    "pact" : "Operator",
    "contents" : "[1413]:Calc(select=[bid.auction AS auction, bid.bidder AS bidder, bid.price AS price, bid.channel AS channel, bid.url AS url, 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" : 1994,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 1997,
    "type" : "Join[1415]",
    "pact" : "Operator",
    "contents" : "[1415]:Join(joinType=[InnerJoin], where=[((id = auction) AND (dateTime0 >= dateTime) AND (dateTime0 <= expires))], select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, channel, url, dateTime0, extra0], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey], miniBatch=[true])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1991,
      "ship_strategy" : "HASH",
      "side" : "second"
    }, {
      "id" : 1995,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 1998,
    "type" : "Calc[1416]",
    "pact" : "Operator",
    "contents" : "[1416]:Calc(select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1997,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 2000,
    "type" : "Rank[1418]",
    "pact" : "Operator",
    "contents" : "[1418]:Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=1], partitionBy=[id], orderBy=[price DESC, dateTime0 ASC], select=[id, itemName, description, initialBid, reserve, dateTime, expires, seller, category, extra, auction, bidder, price, dateTime0, extra0])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 1998,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 2001,
    "type" : "ConstraintEnforcer[1419]",
    "pact" : "Operator",
    "contents" : "[1419]:ConstraintEnforcer[NotNullEnforcer(fields=[id])]",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 2000,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 2008,
    "type" : "Sink(nexmark.output_160a21b6d2e84a01b5b7f07125c6552b): Writer",
    "pact" : "Operator",
    "contents" : "Sink(nexmark.output_160a21b6d2e84a01b5b7f07125c6552b): Writer",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 2001,
      "ship_strategy" : "BUCKET",
      "side" : "second"
    } ]
  } ]
}