== Abstract Syntax Tree ==
LogicalSink(table=[default_catalog.default_database.sink], fields=[name, city, state, id])
+- LogicalProject(name=[$11], city=[$14], state=[$15], id=[$0])
   +- LogicalFilter(condition=[AND(=($8, 10), OR(=($15, _UTF-16LE'OR'), =($15, _UTF-16LE'ID'), =($15, _UTF-16LE'CA')))])
      +- LogicalJoin(condition=[=($7, $10)], 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)])
         :     +- 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]])
         +- LogicalProject(id=[$1.id], name=[$1.name], emailAddress=[$1.emailAddress], creditCard=[$1.creditCard], city=[$1.city], state=[$1.state], dateTime=[$5], extra=[$1.extra])
            +- LogicalFilter(condition=[=($0, 0)])
               +- 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=[name, city, state, id])
+- Calc(select=[name, city, state, id])
   +- Join(joinType=[InnerJoin], where=[=(seller, id0)], select=[id, seller, id0, name, city, state], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
      :- Exchange(distribution=[hash[seller]])
      :  +- Calc(select=[auction.id AS id, auction.seller AS seller], where=[AND(=(event_type, 1), =(auction.category, 10:BIGINT))])
      :     +- 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])
      +- Exchange(distribution=[hash[id]])
         +- Calc(select=[person.id AS id, person.name AS name, person.city AS city, person.state AS state], where=[AND(=(event_type, 0), SEARCH(person.state, Sarg[_UTF-16LE'CA':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'ID':VARCHAR(2147483647) CHARACTER SET "UTF-16LE", _UTF-16LE'OR':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"]:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"))])
            +- 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=[name, city, state, id])
+- Calc(select=[name, city, state, id])
   +- Join(joinType=[InnerJoin], where=[(seller = id0)], select=[id, seller, id0, name, city, state], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])
      :- Exchange(distribution=[hash[seller]])
      :  +- Calc(select=[auction.id AS id, auction.seller AS seller], where=[((event_type = 1) AND (auction.category = 10))])
      :     +- 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])(reuse_id=[1])
      +- Exchange(distribution=[hash[id]])
         +- Calc(select=[person.id AS id, person.name AS name, person.city AS city, person.state AS state], where=[((event_type = 0) AND SEARCH(person.state, Sarg[_UTF-16LE'CA', _UTF-16LE'ID', _UTF-16LE'OR']))])
            +- Reused(reference_id=[1])

== Physical Execution Plan ==
{
  "nodes" : [ {
    "id" : 871,
    "type" : "Source: src[371]",
    "pact" : "Data Source",
    "contents" : "[371]: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" : 872,
    "type" : "Calc[372]",
    "pact" : "Operator",
    "contents" : "[372]:Calc(select=[auction.id AS id, auction.seller AS seller], where=[((event_type = 1) AND (auction.category = 10))])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 871,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 874,
    "type" : "Calc[374]",
    "pact" : "Operator",
    "contents" : "[374]:Calc(select=[person.id AS id, person.name AS name, person.city AS city, person.state AS state], where=[((event_type = 0) AND SEARCH(person.state, Sarg[_UTF-16LE'CA', _UTF-16LE'ID', _UTF-16LE'OR']))])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 871,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 876,
    "type" : "Join[376]",
    "pact" : "Operator",
    "contents" : "[376]:Join(joinType=[InnerJoin], where=[(seller = id0)], select=[id, seller, id0, name, city, state], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 872,
      "ship_strategy" : "HASH",
      "side" : "second"
    }, {
      "id" : 874,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 877,
    "type" : "Calc[377]",
    "pact" : "Operator",
    "contents" : "[377]:Calc(select=[name, city, state, id])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 876,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 878,
    "type" : "Map",
    "pact" : "Operator",
    "contents" : "Map",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 877,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 880,
    "type" : "Writer : table",
    "pact" : "Operator",
    "contents" : "Writer : table",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 878,
      "ship_strategy" : "shuffle by bucket",
      "side" : "second"
    } ]
  }, {
    "id" : 881,
    "type" : "Global Committer : table",
    "pact" : "Operator",
    "contents" : "Global Committer : table",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 880,
      "ship_strategy" : "REBALANCE",
      "side" : "second"
    } ]
  }, {
    "id" : 886,
    "type" : "end: Writer",
    "pact" : "Operator",
    "contents" : "end: Writer",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 881,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  } ]
}