{
  "tests": [
    {
      "name": "validate JSON fails without elements",
      "statements": [
        "CREATE STREAM TEST WITH (kafka_topic='test_topic', value_format='JSON');"
      ],
      "expectedException": {
        "type": "io.confluent.ksql.util.KsqlException",
        "message": "The statement or topic schema does not define any columns."
      }
    },
    {
      "name": "validate DELIMITED fails without elements",
      "statements": [
        "CREATE STREAM TEST WITH (kafka_topic='test_topic', value_format='DELIMITED');"
      ],
      "expectedException": {
        "type": "io.confluent.ksql.util.KsqlException",
        "message": "The statement or topic schema does not define any columns."
      }
    },
    {
      "name": "validate AVRO ok without elements",
      "statements": [
        "CREATE STREAM TEST WITH (kafka_topic='input', value_format='AVRO');",
        "CREATE STREAM S as SELECT * FROM test;"
      ],
      "topics": [
        {
          "name": "input",
          "schema": {"name": "blah", "type": "record", "fields": [{"name": "c1", "type": "int"}]},
          "format": "AVRO"
        },
        {
          "name": "S",
          "format": "AVRO",
          "partitions": 4
        }
      ],
      "inputs": [{"topic": "input", "value": {"c1": 4}}],
      "outputs": [{"topic": "S", "value": {"C1": 4}}]
    },
    {
      "name": "validate AVRO ok with elements",
      "statements": [
        "CREATE STREAM TEST (c1 INT) WITH (kafka_topic='input', value_format='AVRO');",
        "CREATE STREAM S as SELECT * FROM test;"
      ],
      "topics": [
        {
          "name": "input",
          "schema": {"name": "blah", "type": "record", "fields": [{"name": "c1", "type": "int"}]},
          "format": "AVRO"
        },
        {
          "name": "S",
          "format": "AVRO",
          "partitions": 4
        }
      ],
      "inputs": [{"topic": "input", "value": {"c1": 4}}],
      "outputs": [{"topic": "S", "value": {"C1": 4}}]
    },
    {
      "name": "validate AVRO uses null for unknown element",
      "statements": [
        "CREATE STREAM TEST (c1 INT, unknown INT) WITH (kafka_topic='input', value_format='AVRO');",
        "CREATE STREAM S as SELECT * FROM test;"
      ],
      "topics": [
        {
          "name": "input",
          "schema": {"name": "blah", "type": "record", "fields": [{"name": "c1", "type": "int"}]},
          "format": "AVRO"
        },
        {
          "name": "S",
          "format": "AVRO",
          "partitions": 4
        }
      ],
      "inputs": [{"topic": "input", "value": {"c1": 4}}],
      "outputs": [{"topic": "S", "value": {"UNKNOWN": null, "C1": 4}}]
    },
    {
      "name": "validate AVRO fails on incompatible schema evolution",
      "statements": [
        "CREATE STREAM TEST (c1 INT) WITH (kafka_topic='input', value_format='AVRO');",
        "CREATE STREAM S as SELECT * FROM test;"
      ],
      "expectedException": {
        "type": "io.confluent.ksql.util.KsqlStatementException",
        "message": "Cannot register avro schema for S as the schema registry rejected it, (maybe schema evolution issues?)"
      },
      "topics": [
        {
          "name": "input",
          "schema": {"name": "blah", "type": "record", "fields": [{"name": "c1", "type": "int"}]},
          "format": "AVRO"
        },
        {
          "name": "S",
          "schema": {"name": "blah", "type": "record", "fields": [{"name": "C1", "type": "double"}]},
          "format": "AVRO",
          "partitions": 4
        }
      ]
    }
  ]
}
