Skip to content

bug: Timestream feature differences #11554

@yibo-long

Description

@yibo-long

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

when running with a MULTI table, I haven seen several discrepancies that blocks us using localstack as the integration test tool.

In the test we wrote several records to the table that each has different columns, and tried to aggregate them by time. Then we noticed those differences after some try and failures:

  • localstack doesn't support AVG on aggregation. If there is AVG in the SQL selection, the result will always be empty.
  • for Timestream's real implementation, aggregation on all columns will return nullValue if the column doesn't exist with the record. However for localstack it will return "0.0" scalar values instead.

Expected Behavior

After writing those 2 records:

val aRecord = Record.builder().apply {
    measureName("A")
    time(timestamp)
    timeUnit("MILLISECONDS")
    dimensions(
        listOf(
            Dimension.builder().name("primary_key").value("key1").build(),
        ),
    )
    measureValueType(MeasureValueType.MULTI)
    measureValues(
        MeasureValue.builder().apply {
            name("a_1")
            value("1.0")
            type(MeasureValueType.DOUBLE)
        }.build(),
        MeasureValue.builder().apply {
            name("a_2")
            value("0")
            type(MeasureValueType.DOUBLE)
        }.build(),
        MeasureValue.builder().apply {
            name("a_3")
            value("0.5")
            type(MeasureValueType.DOUBLE)
        }.build(),
    )
}.build()
val bRecord = Record.builder().apply {
    measureName("B")
    time(timestamp)
    timeUnit("MILLISECONDS")
    dimensions(
        listOf(
            Dimension.builder().name("primary_key").value("key2").build(),
        ),
    )
    measureValueType(MeasureValueType.MULTI)
    measureValues(
        MeasureValue.builder().apply {
            name("b_1")
            value("1.0")
            type(MeasureValueType.DOUBLE)
        }.build(),
        MeasureValue.builder().apply {
            name("b_2")
            value("0")
            type(MeasureValueType.DOUBLE)
        }.build(),
        MeasureValue.builder().apply {
            name("b_3")
            value("0.5")
            type(MeasureValueType.DOUBLE)
        }.build(),
    )
}.build()

I would expect the following SQL can be run:

SELECT primary_key, measure_name, bin(time, 15m) as time,
    SUM(a_1) AS a_1, SUM(a_2) AS a_2, AVG(a_3) AS a_3,
    SUM(b_1) AS b_1, SUM(b_2) AS b_2, AVG(b_3) AS b_3,
    MIN(time) as start_time, MAX(time) as end_time, COUNT(*) AS count
FROM "db"."table" 
WHERE time BETWEEN '2021-04-05 07:00:00' AND '2021-04-06 06:59:00'
AND primary_key IN ('key1', 'key2')
GROUP BY 1,2,3,4

How are you starting LocalStack?

Custom (please describe below)

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

using testcontainer with kotlin

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

awslocal s3 mb s3://mybucket

Environment

- OS:
- LocalStack:
  LocalStack version:
  LocalStack Docker image sha:
  LocalStack build date:
  LocalStack build git hash:

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions