{
  "comments": [
    "You can specify multiple statements per test case, i.e., to set up the various streams needed",
    "for joins etc, but currently only the final topology will be verified. This should be enough",
    "for most tests as we can simulate the outputs from previous stages into the final stage. If we",
    "take a modular approach to testing we can still verify that it all works correctly, i.e, if we",
    "verify the output of a select or aggregate is correct, we can use simulated output to feed into",
    "a join or another aggregate."
  ],
  "tests": [
   {
      "name": "stream stream inner join with ts",
      "format": ["AVRO", "JSON"],
      "statements": [
        "CREATE STREAM S1 (ID bigint, NAME varchar, TS bigint) WITH (timestamp='TS', kafka_topic='s1', value_format='{FORMAT}', key='ID');",
        "CREATE STREAM S2 (ID bigint, F1 varchar, F2 varchar) WITH (kafka_topic='s2', value_format='{FORMAT}', key='ID');",
        "CREATE STREAM S1_JOIN_S2 WITH(timestamp='TS') as SELECT S1.id as id, S1.name as name, S1.ts as ts, s2.f1, s2.f2 from S1 join S2 WITHIN 11 SECONDS ON s1.id = s2.id;"
      ],
      "inputs": [
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0}, "timestamp": 0},
        {"topic": "s2", "key": 0, "value": {"ID": 0, "F1": "blah", "F2": "foo"}, "timestamp": 10000},
        {"topic": "s2", "key": 10, "value": {"ID": 10, "F1": "foo", "F2": "bar"}, "timestamp": 13000},
        {"topic": "s1", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000}, "timestamp": 22000},
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000}, "timestamp": 33000}
      ],
      "outputs": [
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0, "F1": "blah", "F2": "foo"}, "timestamp": 10000},
        {"topic": "S1_JOIN_S2", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000, "F1": "foo", "F2": "bar"}, "timestamp": 11000},
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000, "F1": "blah", "F2": "foo"}, "timestamp": 8000}
      ]
    },
    {
      "name": "stream stream inner join with ts extractor both sides",
      "format": ["AVRO", "JSON"],
      "statements": [
        "CREATE STREAM S1 (ID bigint, NAME varchar, TS bigint) WITH (timestamp='TS', kafka_topic='s1', value_format='{FORMAT}', key='ID');",
        "CREATE STREAM S2 (ID bigint, F1 varchar, F2 varchar, RTS bigint) WITH (timestamp='RTS', kafka_topic='s2', value_format='{FORMAT}', key='ID');",
        "CREATE STREAM S1_JOIN_S2 WITH(timestamp='TS') as SELECT S1.id as id, S1.name as name, S1.ts as ts, s2.f1, s2.f2 from S1 join S2 WITHIN 11 SECONDS ON s1.id = s2.id;"
      ],
      "inputs": [
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0}, "timestamp": 0},
        {"topic": "s2", "key": 0, "value": {"ID": 0, "F1": "blah", "F2": "foo", "RTS": 10000}, "timestamp": 0},
        {"topic": "s2", "key": 10, "value": {"ID": 10, "F1": "foo", "F2": "bar", "RTS": 13000}, "timestamp": 0},
        {"topic": "s1", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000}, "timestamp": 0},
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000}, "timestamp": 0}
      ],
      "outputs": [
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0, "F1": "blah", "F2": "foo"}, "timestamp": 10000},
        {"topic": "S1_JOIN_S2", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000, "F1": "foo", "F2": "bar"}, "timestamp": 11000},
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000, "F1": "blah", "F2": "foo"}, "timestamp": 8000}
      ]
    },
    {
      "name": "stream table join with ts extractor both sides",
      "format": ["AVRO", "JSON"],
      "statements": [
        "CREATE STREAM S1 (ID bigint, NAME varchar, TS bigint) WITH (timestamp='TS', kafka_topic='s1', value_format='{FORMAT}', key='ID');",
        "CREATE TABLE  T1 (ID bigint, F1 varchar, F2 varchar, RTS bigint) WITH (timestamp='RTS', kafka_topic='t1', value_format='{FORMAT}', key='ID');",
        "CREATE STREAM S1_JOIN_T1 WITH(timestamp='TS') as SELECT S1.id as id, S1.name as name, S1.ts as ts, T1.f1, T1.f2 from S1 inner join T1 ON s1.id = t1.id;"
      ],
      "inputs": [
        {"topic": "t1", "key": 0, "value": {"ID": 0, "F1": "blah", "F2": "foo", "RTS": 10000}, "timestamp": 10000},
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0}, "timestamp": 10000},
        {"topic": "t1", "key": 10, "value": {"ID": 10, "F1": "foo", "F2": "bar", "RTS": 13000}, "timestamp": 90000},
        {"topic": "s1", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000}, "timestamp": 800000},
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000}, "timestamp": 0}
      ],
      "outputs": [
        {"topic": "S1_JOIN_T1", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0, "F1": "blah", "F2": "foo"}, "timestamp": 0},
        {"topic": "S1_JOIN_T1", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000, "F1": "foo", "F2": "bar"}, "timestamp": 11000},
        {"topic": "S1_JOIN_T1", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000, "F1": "blah", "F2": "foo"}, "timestamp": 8000}
      ]
    },
    {
      "name": "table table inner join with ts",
      "format": ["AVRO", "JSON"],
      "statements": [
        "CREATE TABLE S1 (ID bigint, NAME varchar, TS bigint) WITH (timestamp='TS', kafka_topic='s1', value_format='{FORMAT}', key='ID');",
        "CREATE TABLE S2 (ID bigint, F1 varchar, F2 varchar) WITH (kafka_topic='s2', value_format='{FORMAT}', key='ID');",
        "CREATE TABLE S1_JOIN_S2 WITH(timestamp='TS') as SELECT S1.id as id, S1.name as name, S1.ts as ts, s2.f1, s2.f2 from S1 join S2 ON s1.id = s2.id;"
      ],
      "inputs": [
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0}, "timestamp": 0},
        {"topic": "s2", "key": 0, "value": {"ID": 0, "F1": "blah", "F2": "foo"}, "timestamp": 10000},
        {"topic": "s2", "key": 10, "value": {"ID": 10, "F1": "foo", "F2": "bar"}, "timestamp": 13000},
        {"topic": "s1", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000}, "timestamp": 22000},
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000}, "timestamp": 33000}
      ],
      "outputs": [
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0, "F1": "blah", "F2": "foo"}, "timestamp": 10000},
        {"topic": "S1_JOIN_S2", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000, "F1": "foo", "F2": "bar"}, "timestamp": 11000},
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000, "F1": "blah", "F2": "foo"}, "timestamp": 8000}
      ]
    },
    {
      "name": "table table inner join with ts extractor both sides",
      "format": ["AVRO", "JSON"],
      "statements": [
        "CREATE TABLE S1 (ID bigint, NAME varchar, TS bigint) WITH (timestamp='TS', kafka_topic='s1', value_format='{FORMAT}', key='ID');",
        "CREATE TABLE S2 (ID bigint, F1 varchar, F2 varchar, RTS bigint) WITH (timestamp='RTS', kafka_topic='s2', value_format='{FORMAT}', key='ID');",
        "CREATE TABLE S1_JOIN_S2 WITH(timestamp='TS') as SELECT S1.id as id, S1.name as name, S1.ts as ts, s2.f1, s2.f2 from S1 join S2 ON s1.id = s2.id;"
      ],
      "inputs": [
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0}, "timestamp": 0},
        {"topic": "s2", "key": 0, "value": {"ID": 0, "F1": "blah", "F2": "foo", "RTS": 10000}, "timestamp": 0},
        {"topic": "s2", "key": 10, "value": {"ID": 10, "F1": "foo", "F2": "bar", "RTS": 13000}, "timestamp": 0},
        {"topic": "s1", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000}, "timestamp": 0},
        {"topic": "s1", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000}, "timestamp": 0}
      ],
      "outputs": [
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "zero", "TS": 0, "F1": "blah", "F2": "foo"}, "timestamp": 10000},
        {"topic": "S1_JOIN_S2", "key": 10, "value": {"ID": 10, "NAME": "100", "TS": 11000, "F1": "foo", "F2": "bar"}, "timestamp": 11000},
        {"topic": "S1_JOIN_S2", "key": 0, "value": {"ID": 0, "NAME": "jan", "TS": 8000, "F1": "blah", "F2": "foo"}, "timestamp": 8000}
      ]
    }
  ]
}