== 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" : 837,
    "type" : "Source: src[353]",
    "pact" : "Data Source",
    "contents" : "[353]: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" : 838,
    "type" : "Calc[354]",
    "pact" : "Operator",
    "contents" : "[354]:Calc(select=[auction.id AS id, auction.seller AS seller], where=[((event_type = 1) AND (auction.category = 10))])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 837,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 840,
    "type" : "Calc[356]",
    "pact" : "Operator",
    "contents" : "[356]: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" : 837,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 842,
    "type" : "Join[358]",
    "pact" : "Operator",
    "contents" : "[358]:Join(joinType=[InnerJoin], where=[(seller = id0)], select=[id, seller, id0, name, city, state], leftInputSpec=[NoUniqueKey], rightInputSpec=[NoUniqueKey])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 838,
      "ship_strategy" : "HASH",
      "side" : "second"
    }, {
      "id" : 840,
      "ship_strategy" : "HASH",
      "side" : "second"
    } ]
  }, {
    "id" : 843,
    "type" : "Calc[359]",
    "pact" : "Operator",
    "contents" : "[359]:Calc(select=[name, city, state, id])",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 842,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 844,
    "type" : "Map",
    "pact" : "Operator",
    "contents" : "Map",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 843,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  }, {
    "id" : 846,
    "type" : "Writer : table",
    "pact" : "Operator",
    "contents" : "Writer : table",
    "parallelism" : 4,
    "predecessors" : [ {
      "id" : 844,
      "ship_strategy" : "shuffle by bucket",
      "side" : "second"
    } ]
  }, {
    "id" : 847,
    "type" : "Global Committer : table",
    "pact" : "Operator",
    "contents" : "Global Committer : table",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 846,
      "ship_strategy" : "REBALANCE",
      "side" : "second"
    } ]
  }, {
    "id" : 852,
    "type" : "end: Writer",
    "pact" : "Operator",
    "contents" : "end: Writer",
    "parallelism" : 1,
    "predecessors" : [ {
      "id" : 847,
      "ship_strategy" : "FORWARD",
      "side" : "second"
    } ]
  } ]
}