Repository: influxdata/influxdb
File: influxdb3/tests/server/query.rs (Rust)

Code before:
        .write_lp_to_db(
            "foo",
            "cpu,host=a usage=0.9 1\n\
            cpu,host=a usage=0.89 2\n\
            cpu,host=a usage=0.85 3\n\
            mem,host=a usage=0.5 4\n\
            mem,host=a usage=0.6 5\n\
            mem,host=a usage=0.7 6",
            Precision::Second,
        )
        .await
        .unwrap();

    struct TestCase<'a> {
        database: Option<&'a str>,
        epoch: Option<&'a str>,
        query: &'a str,
        expected: Value,
    }

    let test_cases = [
        // Basic Query:
        TestCase {
            database: Some("foo"),
            epoch: None,
            query: "SELECT time, host, usage FROM cpu",
            expected: json!({
              "results": [
                {
                  "series": [
                    {
                      "columns": [
                        "time",
                        "host",
                        "usage"
                      ],
                      "name": "cpu",
                      "values": [
                        ["1970-01-01T00:00:01Z", "a", 0.9],
                        ["1970-01-01T00:00:02Z", "a", 0.89],
                        ["1970-01-01T00:00:03Z", "a", 0.85]
                      ]
                    }
                  ],
                  "statement_id": 0
                }
              ]
            }),
        },
        // Basic Query with multiple measurements:
        TestCase {

Review comment (suggestion):
unrelated to this PR, but we should look into changing the name of `iox::measurement` to `influxdb3::table`

Code after:
        .write_lp_to_db(
            "foo",
            "cpu,host=a,region=us-east usage=0.9 1
            cpu,host=b,region=us-east usage=0.50 1
            cpu,host=a,region=us-east usage=0.80 2
            cpu,host=b,region=us-east usage=0.60 2
            cpu,host=a,region=us-east usage=0.70 3
            cpu,host=b,region=us-east usage=0.70 3
            cpu,host=a,region=us-east usage=0.50 4
            cpu,host=b,region=us-east usage=0.80 4",
            Precision::Second,
        )
        .await
        .unwrap();

    struct TestCase<'a> {
        database: Option<&'a str>,
        query: &'a str,
        expected: String,
    }

    let test_cases = [
        TestCase {
            database: Some("foo"),
            query: "SELECT time, host, region, usage FROM cpu",
            expected: "{\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:01\",\"host\":\"a\",\"region\":\"us-east\",\"usage\":0.9}\n\
               {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:01\",\"host\":\"b\",\"region\":\"us-east\",\"usage\":0.5}\n\
                {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:02\",\"host\":\"a\",\"region\":\"us-east\",\"usage\":0.8}\n\
                {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:02\",\"host\":\"b\",\"region\":\"us-east\",\"usage\":0.6}\n\
                {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:03\",\"host\":\"a\",\"region\":\"us-east\",\"usage\":0.7}\n\
                {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:03\",\"host\":\"b\",\"region\":\"us-east\",\"usage\":0.7}\n\
                {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:04\",\"host\":\"a\",\"region\":\"us-east\",\"usage\":0.5}\n\
                {\"iox::measurement\":\"cpu\",\"time\":\"1970-01-01T00:00:04\",\"host\":\"b\",\"region\":\"us-east\",\"usage\":0.8}\n"
            .into(),
        },
        TestCase {
            database: Some("foo"),
            query: "SHOW MEASUREMENTS",
            expected: "{\"iox::measurement\":\"measurements\",\"name\":\"cpu\"}\n".into(),
        },
        TestCase {
            database: Some("foo"),
            query: "SHOW FIELD KEYS",
            expected: "{\"iox::measurement\":\"cpu\",\"fieldKey\":\"usage\",\"fieldType\":\"float\"}\n".into()
        },
        TestCase {
            database: Some("foo"),
            query: "SHOW TAG KEYS",
            expected:
                "{\"iox::measurement\":\"cpu\",\"tagKey\":\"host\"}\n\
                {\"iox::measurement\":\"cpu\",\"tagKey\":\"region\"}\n".into()