== Abstract Syntax Tree ==
LogicalSink(table=[default_catalog.default_database.sink], fields=[auction, bidder, price, channel, url, dateTime, extra, rank_number])
+- LogicalProject(auction=[$0], bidder=[$1], price=[$2], channel=[$3], url=[$4], dateTime=[$5], extra=[$6], rank_number=[$7])
   +- LogicalFilter(condition=[<=($7, 10)])
      +- LogicalProject(auction=[$0], bidder=[$1], price=[$2], channel=[$3], url=[$4], dateTime=[$5], extra=[$6], rank_number=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $2 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)])
               +- 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=[[default_catalog, default_database, src]])

== Optimized Physical Plan ==
Sink(table=[default_catalog.default_database.sink], fields=[auction, bidder, price, channel, url, dateTime, extra, rank_number])
+- Calc(select=[$1 AS auction, $2 AS bidder, $3 AS price, $4 AS channel, $5 AS url, rowtime AS dateTime, $6 AS extra, rank_number])
   +- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=10], partitionBy=[$1], orderBy=[$3 DESC], select=[rowtime, $1, $2, $3, $4, $5, $6, rank_number])
      +- Exchange(distribution=[hash[$1]])
         +- 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)])
            +- TableSourceScan(table=[[default_catalog, default_database, src, watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic]]], fields=[event_type, person, auction, bid, dateTime])

== Optimized Execution Plan ==
Sink(table=[default_catalog.default_database.sink], fields=[auction, bidder, price, channel, url, dateTime, extra, rank_number])
+- Calc(select=[$1 AS auction, $2 AS bidder, $3 AS price, $4 AS channel, $5 AS url, rowtime AS dateTime, $6 AS extra, rank_number])
   +- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=10], partitionBy=[$1], orderBy=[$3 DESC], select=[rowtime, $1, $2, $3, $4, $5, $6, rank_number])
      +- Exchange(distribution=[hash[$1]])
         +- 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)])
            +- TableSourceScan(table=[[default_catalog, default_database, src, watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic]]], fields=[event_type, person, auction, bid, dateTime])

== Physical Execution Plan ==
{
  "nodes" : [ {
    "id" : 5147,
    "type" : "Source: src[2341]",
    "pact" : "Data Source",
    "contents" : "[2341]:TableSourceScan(table=[[default_catalog, default_database, src, watermark=[-(TO_TIMESTAMP_LTZ(dateTime, 3), 4000:INTERVAL SECOND)], watermarkEmitStrategy=[on-periodic]]], fields=[event_type, person, auction, bid, dateTime])",
    "parallelism" : 4
  }, {
    "id" : 5148,
    "type" : "Calc[2342]",
    "pact" : "Operator",
    "contents" : "[2342]: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" : 5147,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5150,
    "type" : "Rank[2344]",
    "pact" : "Operator",
    "contents" : "[2344]:Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=10], partitionBy=[$1], orderBy=[$3 DESC], select=[rowtime, $1, $2, $3, $4, $5, $6, rank_number])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5148,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 5151,
    "type" : "Calc[2345]",
    "pact" : "Operator",
    "contents" : "[2345]:Calc(select=[$1 AS auction, $2 AS bidder, $3 AS price, $4 AS channel, $5 AS url, rowtime AS dateTime, $6 AS extra, rank_number])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5150,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5152,
    "type" : "ConstraintEnforcer[2346]",
    "pact" : "Operator",
    "contents" : "[2346]:ConstraintEnforcer[NotNullEnforcer(fields=[auction, rank_number])]",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5151,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5153,
    "type" : "StreamRecordTimestampInserter[2346]",
    "pact" : "Operator",
    "contents" : "[2346]:StreamRecordTimestampInserter(rowtime field: 5)",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5152,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5154,
    "type" : "Map",
    "pact" : "Operator",
    "contents" : "Map",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5153,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5156,
    "type" : "Writer : table",
    "pact" : "Operator",
    "contents" : "Writer : table",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5154,
      "ship_strategy" : "shuffle by bucket",
      "side" : "second"
    } ]
  }, {
    "id" : 5157,
    "type" : "Global Committer : table",
    "pact" : "Operator",
    "contents" : "Global Committer : table",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 5156,
      "ship_strategy" : "REBALANCE",
      "side" : "second"
    } ]
  }, {
    "id" : 5161,
    "type" : "end: Writer",
    "pact" : "Operator",
    "contents" : "end: Writer",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 5157,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  } ]
}