== Abstract Syntax Tree ==
LogicalSink(table=[fluss.nexmark.output_5ff9c3541e364bd9ab61e2f751ae693f], fields=[auction, day, total_bids, rank1_bids, rank2_bids, rank3_bids, min_price, max_price, avg_price, sum_price])
+- LogicalAggregate(group=[{0, 1}], total_bids=[COUNT()], rank1_bids=[COUNT() FILTER $2], rank2_bids=[COUNT() FILTER $3], rank3_bids=[COUNT() FILTER $4], min_price=[MIN($5)], max_price=[MAX($5)], avg_price=[AVG($5)], sum_price=[SUM($5)])
   +- LogicalProject(auction=[$0], day=[DATE_FORMAT($5, _UTF-16LE'yyyy-MM-dd')], $f2=[IS TRUE(<($2, 10000))], $f3=[IS TRUE(SEARCH($2, Sarg[[10000..1000000)]))], $f4=[IS TRUE(>=($2, 1000000))], price=[$2])
      +- 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_5ff9c3541e364bd9ab61e2f751ae693f], fields=[auction, day, total_bids, rank1_bids, rank2_bids, rank3_bids, min_price, max_price, avg_price, sum_price])
+- GlobalGroupAggregate(groupBy=[auction, day], select=[auction, day, COUNT(count1$0) AS total_bids, COUNT(count1$1) AS rank1_bids, COUNT(count1$2) AS rank2_bids, COUNT(count1$3) AS rank3_bids, MIN(min$4) AS min_price, MAX(max$5) AS max_price, AVG((sum$6, count$7)) AS avg_price, SUM(sum$8) AS sum_price])
   +- Exchange(distribution=[hash[auction, day]])
      +- LocalGroupAggregate(groupBy=[auction, day], select=[auction, day, COUNT(*) AS count1$0, COUNT(*) FILTER $f2 AS count1$1, COUNT(*) FILTER $f3 AS count1$2, COUNT(*) FILTER $f4 AS count1$3, MIN(price) AS min$4, MAX(price) AS max$5, AVG(price) AS (sum$6, count$7), SUM(price) AS sum$8])
         +- Calc(select=[bid.auction AS auction, DATE_FORMAT(CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)), _UTF-16LE'yyyy-MM-dd') AS day, IS TRUE(<(bid.price, 10000)) AS $f2, IS TRUE(SEARCH(bid.price, Sarg[[10000..1000000)])) AS $f3, IS TRUE(>=(bid.price, 1000000)) AS $f4, bid.price AS price], 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_5ff9c3541e364bd9ab61e2f751ae693f], fields=[auction, day, total_bids, rank1_bids, rank2_bids, rank3_bids, min_price, max_price, avg_price, sum_price])
+- GlobalGroupAggregate(groupBy=[auction, day], select=[auction, day, COUNT(count1$0) AS total_bids, COUNT(count1$1) AS rank1_bids, COUNT(count1$2) AS rank2_bids, COUNT(count1$3) AS rank3_bids, MIN(min$4) AS min_price, MAX(max$5) AS max_price, AVG((sum$6, count$7)) AS avg_price, SUM(sum$8) AS sum_price])
   +- Exchange(distribution=[hash[auction, day]])
      +- LocalGroupAggregate(groupBy=[auction, day], select=[auction, day, COUNT(*) AS count1$0, COUNT(*) FILTER $f2 AS count1$1, COUNT(*) FILTER $f3 AS count1$2, COUNT(*) FILTER $f4 AS count1$3, MIN(price) AS min$4, MAX(price) AS max$5, AVG(price) AS (sum$6, count$7), SUM(price) AS sum$8])
         +- Calc(select=[bid.auction AS auction, DATE_FORMAT(CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)), 'yyyy-MM-dd') AS day, (bid.price < 10000) IS TRUE AS $f2, SEARCH(bid.price, Sarg[[10000..1000000)]) IS TRUE AS $f3, (bid.price >= 1000000) IS TRUE AS $f4, bid.price AS price], 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" : 3131,
    "type" : "Source: events[2129]",
    "pact" : "Data Source",
    "contents" : "[2129]: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" : 3132,
    "type" : "MiniBatchAssigner[2130]",
    "pact" : "Operator",
    "contents" : "[2130]:MiniBatchAssigner(interval=[2000ms], mode=[ProcTime])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3131,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3133,
    "type" : "Calc[2131]",
    "pact" : "Operator",
    "contents" : "[2131]:Calc(select=[bid.auction AS auction, DATE_FORMAT(CAST(Reinterpret(TO_TIMESTAMP_LTZ(dateTime, 3)) AS TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)), 'yyyy-MM-dd') AS day, (bid.price < 10000) IS TRUE AS $f2, SEARCH(bid.price, Sarg[[10000..1000000)]) IS TRUE AS $f3, (bid.price >= 1000000) IS TRUE AS $f4, bid.price AS price], where=[(event_type = 2)])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3132,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3134,
    "type" : "LocalGroupAggregate[2132]",
    "pact" : "Operator",
    "contents" : "[2132]:LocalGroupAggregate(groupBy=[auction, day], select=[auction, day, COUNT(*) AS count1$0, COUNT(*) FILTER $f2 AS count1$1, COUNT(*) FILTER $f3 AS count1$2, COUNT(*) FILTER $f4 AS count1$3, MIN(price) AS min$4, MAX(price) AS max$5, AVG(price) AS (sum$6, count$7), SUM(price) AS sum$8])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3133,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3136,
    "type" : "GlobalGroupAggregate[2134]",
    "pact" : "Operator",
    "contents" : "[2134]:GlobalGroupAggregate(groupBy=[auction, day], select=[auction, day, COUNT(count1$0) AS total_bids, COUNT(count1$1) AS rank1_bids, COUNT(count1$2) AS rank2_bids, COUNT(count1$3) AS rank3_bids, MIN(min$4) AS min_price, MAX(max$5) AS max_price, AVG((sum$6, count$7)) AS avg_price, SUM(sum$8) AS sum_price])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3134,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 3137,
    "type" : "ConstraintEnforcer[2135]",
    "pact" : "Operator",
    "contents" : "[2135]:ConstraintEnforcer[NotNullEnforcer(fields=[auction, day])]",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3136,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 3142,
    "type" : "Sink(nexmark.output_5ff9c3541e364bd9ab61e2f751ae693f): Writer",
    "pact" : "Operator",
    "contents" : "Sink(nexmark.output_5ff9c3541e364bd9ab61e2f751ae693f): Writer",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 3137,
      "ship_strategy" : "BUCKET",
      "side" : "second"
    } ]
  } ]
}