== 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" : 5279,
    "type" : "Source: src[2397]",
    "pact" : "Data Source",
    "contents" : "[2397]: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" : 5280,
    "type" : "Calc[2398]",
    "pact" : "Operator",
    "contents" : "[2398]: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" : 5279,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5282,
    "type" : "Rank[2400]",
    "pact" : "Operator",
    "contents" : "[2400]: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" : 5280,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 5283,
    "type" : "Calc[2401]",
    "pact" : "Operator",
    "contents" : "[2401]: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" : 5282,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5284,
    "type" : "ConstraintEnforcer[2402]",
    "pact" : "Operator",
    "contents" : "[2402]:ConstraintEnforcer[NotNullEnforcer(fields=[auction, rank_number])]",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5283,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5285,
    "type" : "StreamRecordTimestampInserter[2402]",
    "pact" : "Operator",
    "contents" : "[2402]:StreamRecordTimestampInserter(rowtime field: 5)",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5284,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5286,
    "type" : "Map",
    "pact" : "Operator",
    "contents" : "Map",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5285,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 5288,
    "type" : "Writer : table",
    "pact" : "Operator",
    "contents" : "Writer : table",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 5286,
      "ship_strategy" : "shuffle by bucket",
      "side" : "second"
    } ]
  }, {
    "id" : 5289,
    "type" : "Global Committer : table",
    "pact" : "Operator",
    "contents" : "Global Committer : table",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 5288,
      "ship_strategy" : "REBALANCE",
      "side" : "second"
    } ]
  }, {
    "id" : 5293,
    "type" : "end: Writer",
    "pact" : "Operator",
    "contents" : "end: Writer",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 5289,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  } ]
}