[
  {
    "Name": "TestNaturalJoin",
    "Cases": [
      {
        "SQL": "select * from t1 natural join t2",
        "Plan": [
          "HashJoin_7 12487.50 root  inner join, equal:[eq(test.t1.a, test.t2.a)]",
          "├─TableReader_14(Build) 9990.00 root  data:Selection_13",
          "│ └─Selection_13 9990.00 cop[tikv]  not(isnull(test.t2.a))",
          "│   └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
          "└─TableReader_11(Probe) 9990.00 root  data:Selection_10",
          "  └─Selection_10 9990.00 cop[tikv]  not(isnull(test.t1.a))",
          "    └─TableFullScan_9 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
        ],
        "Res": [
          "0 0 0",
          "1 2 3"
        ]
      },
      {
        "SQL": "select * from t1 natural left join t2 order by a",
        "Plan": [
          "Sort_6 12487.50 root  test.t1.a:asc",
          "└─HashJoin_9 12487.50 root  left outer join, equal:[eq(test.t1.a, test.t2.a)]",
          "  ├─TableReader_15(Build) 9990.00 root  data:Selection_14",
          "  │ └─Selection_14 9990.00 cop[tikv]  not(isnull(test.t2.a))",
          "  │   └─TableFullScan_13 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
          "  └─TableReader_12(Probe) 10000.00 root  data:TableFullScan_11",
          "    └─TableFullScan_11 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
        ],
        "Res": [
          "0 0 0",
          "1 2 3",
          "10 20 <nil>"
        ]
      },
      {
        "SQL": "select * from t1 natural right join t2 order by a",
        "Plan": [
          "Sort_6 12487.50 root  test.t2.a:asc",
          "└─Projection_8 12487.50 root  test.t2.a, test.t2.c, test.t1.b",
          "  └─HashJoin_9 12487.50 root  right outer join, equal:[eq(test.t1.a, test.t2.a)]",
          "    ├─TableReader_13(Build) 9990.00 root  data:Selection_12",
          "    │ └─Selection_12 9990.00 cop[tikv]  not(isnull(test.t1.a))",
          "    │   └─TableFullScan_11 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo",
          "    └─TableReader_15(Probe) 10000.00 root  data:TableFullScan_14",
          "      └─TableFullScan_14 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo"
        ],
        "Res": [
          "0 0 0",
          "1 3 2",
          "100 200 <nil>"
        ]
      },
      {
        "SQL": "SELECT * FROM t1 NATURAL LEFT JOIN t2 WHERE not(t1.a <=> t2.a)",
        "Plan": [
          "Projection_6 9990.00 root  test.t1.a, test.t1.b, test.t2.c",
          "└─Selection_7 9990.00 root  not(nulleq(test.t1.a, test.t2.a))",
          "  └─HashJoin_8 12487.50 root  left outer join, equal:[eq(test.t1.a, test.t2.a)]",
          "    ├─TableReader_14(Build) 9990.00 root  data:Selection_13",
          "    │ └─Selection_13 9990.00 cop[tikv]  not(isnull(test.t2.a))",
          "    │   └─TableFullScan_12 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
          "    └─TableReader_11(Probe) 10000.00 root  data:TableFullScan_10",
          "      └─TableFullScan_10 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
        ],
        "Res": [
          "10 20 <nil>"
        ]
      }
    ]
  },
  {
    "Name": "TestUsingAndNaturalJoinSchema",
    "Cases": [
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4);",
        "Res": [
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) join (t3 natural join t4) using (b);",
        "Res": [
          "10 1 2 1 1 3 11 3",
          "10 1 2 1 1 3 2 3",
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) join (t3 natural join t4) using (c);",
        "Res": [
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) join (t3 natural join t4) using (c,b);",
        "Res": [
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) left outer join (t3 natural join t4) using (b);",
        "Res": [
          "10 1 2 1 1 3 11 3",
          "10 1 2 1 1 3 2 3",
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) left outer join (t3 natural join t4) using (c);",
        "Res": [
          "10 1 2 1 <nil> <nil> <nil> <nil>",
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) left outer join (t3 natural join t4) using (c,b);",
        "Res": [
          "10 1 2 1 <nil> <nil> <nil> <nil>",
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) right outer join (t3 natural join t4) using (b);",
        "Res": [
          "10 1 2 1 1 3 11 3",
          "10 1 2 1 1 3 2 3",
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) right outer join (t3 natural join t4) using (c);",
        "Res": [
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) right outer join (t3 natural join t4) using (c,b);",
        "Res": [
          "3 1 2 1 1 3 11 3",
          "3 1 2 1 1 3 2 3"
        ]
      },
      {
        "SQL": "select * from (t1 natural join t2) natural join (t3 natural join t4);",
        "Res": [
          "1 3 2 11",
          "1 3 2 2"
        ]
      },
      {
        "SQL": "select * from (t1 natural join t2) join (t3 natural join t4) using (b);",
        "Res": [
          "1 10 2 3 11",
          "1 10 2 3 2",
          "1 3 2 3 11",
          "1 3 2 3 2"
        ]
      },
      {
        "SQL": "select * from (t1 natural join t2) left outer join (t3 natural join t4) using (b);",
        "Res": [
          "1 10 2 3 11",
          "1 10 2 3 2",
          "1 3 2 3 11",
          "1 3 2 3 2"
        ]
      },
      {
        "SQL": "select * from (t1 natural join t2) right outer join (t3 natural join t4) using (c,b);",
        "Res": [
          "3 1 11 2",
          "3 1 2 2"
        ]
      }
    ]
  },
  {
    "Name": "TestIndexScanWithYearCol",
    "Cases": [
      {
        "SQL": "select t1.c1, t2.c1 from t as t1 inner join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL",
        "Plan": [
          "MergeJoin_8 0.00 root  inner join, left key:test.t.c1, right key:test.t.c1",
          "├─TableDual_24(Build) 0.00 root  rows:0",
          "└─TableDual_23(Probe) 0.00 root  rows:0"
        ],
        "Res": null
      },
      {
        "SQL": "select * from t as t1 inner join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL",
        "Plan": [
          "MergeJoin_8 0.00 root  inner join, left key:test.t.c1, right key:test.t.c1",
          "├─TableDual_26(Build) 0.00 root  rows:0",
          "└─TableDual_25(Probe) 0.00 root  rows:0"
        ],
        "Res": null
      },
      {
        "SQL": "select count(*) from t as t1 inner join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL",
        "Plan": [
          "StreamAgg_10 1.00 root  funcs:count(1)->Column#7",
          "└─MergeJoin_11 0.00 root  inner join, left key:test.t.c1, right key:test.t.c1",
          "  ├─TableDual_27(Build) 0.00 root  rows:0",
          "  └─TableDual_26(Probe) 0.00 root  rows:0"
        ],
        "Res": [
          "0"
        ]
      },
      {
        "SQL": "select t1.c1, t2.c1 from t as t1 left join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL",
        "Plan": [
          "MergeJoin_7 0.00 root  left outer join, left key:test.t.c1, right key:test.t.c1",
          "├─TableDual_17(Build) 0.00 root  rows:0",
          "└─TableDual_16(Probe) 0.00 root  rows:0"
        ],
        "Res": null
      },
      {
        "SQL": "select * from t as t1 left join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL",
        "Plan": [
          "MergeJoin_7 0.00 root  left outer join, left key:test.t.c1, right key:test.t.c1",
          "├─TableDual_18(Build) 0.00 root  rows:0",
          "└─TableDual_17(Probe) 0.00 root  rows:0"
        ],
        "Res": null
      },
      {
        "SQL": "select count(*) from t as t1 left join t as t2 on t1.c1 = t2.c1 where t1.c1 != NULL",
        "Plan": [
          "StreamAgg_9 1.00 root  funcs:count(1)->Column#7",
          "└─MergeJoin_10 0.00 root  left outer join, left key:test.t.c1, right key:test.t.c1",
          "  ├─TableDual_20(Build) 0.00 root  rows:0",
          "  └─TableDual_19(Probe) 0.00 root  rows:0"
        ],
        "Res": [
          "0"
        ]
      },
      {
        "SQL": "select * from t as t1 left join t as t2 on t1.c1 = t2.c1 where t1.c1 is not NULL",
        "Plan": [
          "HashJoin_15 12487.50 root  left outer join, equal:[eq(test.t.c1, test.t.c1)]",
          "├─TableReader_33(Build) 9990.00 root  data:Selection_32",
          "│ └─Selection_32 9990.00 cop[tikv]  not(isnull(test.t.c1))",
          "│   └─TableFullScan_31 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo",
          "└─TableReader_27(Probe) 9990.00 root  data:Selection_26",
          "  └─Selection_26 9990.00 cop[tikv]  not(isnull(test.t.c1))",
          "    └─TableFullScan_25 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
        ],
        "Res": [
          "2001 1 2001 1"
        ]
      }
    ]
  }
]
