Skip to content

uniqTheta produces random results with multithreaded streams #45292

@den-crane

Description

@den-crane
SELECT
    count() AS cnt,
    uniq(number) AS uniq,
    (abs(uniq - cnt) / cnt) * 100 AS uniqError,
    uniqTheta(number) AS uniqTheta,
    (abs(uniqTheta - cnt) / cnt) * 100 AS ThetaError,
    g
FROM
(
    SELECT
        number,
        1 AS g
    FROM numbers_mt(1000000000.)
)
GROUP BY g

┌────────cnt─┬───────uniq─┬─uniqError─┬─uniqTheta─┬─ThetaError─┬─g─┐
│ 100000000010018037770.180377724419595275.58040481 │
└────────────┴────────────┴───────────┴───────────┴────────────┴───┘

┌────────cnt─┬───────uniq─┬─uniqError─┬─uniqTheta─┬─ThetaError─┬─g─┐
│ 100000000010018037770.180377749992212450.00778761 │
└────────────┴────────────┴───────────┴───────────┴────────────┴───┘

┌────────cnt─┬───────uniq─┬─uniqError─┬─uniqTheta─┬─ThetaError─┬─g─┐
│ 100000000010018037770.180377750073291149.92670891 │
└────────────┴────────────┴───────────┴───────────┴────────────┴───┘

-- let's use numbers, not numbers_mt

SELECT
    count() AS cnt,
    uniq(number) AS uniq,
    (abs(uniq - cnt) / cnt) * 100 AS uniqError,
    uniqTheta(number) AS uniqTheta,
    (abs(uniqTheta - cnt) / cnt) * 100 AS ThetaError,
    g
FROM
(
    SELECT
        number,
        1 AS g
    FROM numbers(1000000000.)
)
GROUP BY g

┌────────cnt─┬───────uniq─┬─uniqError─┬─uniqTheta─┬──────────ThetaError─┬─g─┐
│ 100000000010018037770.18037779958074220.419257799999999961 │
└────────────┴────────────┴───────────┴───────────┴─────────────────────┴───┘

┌────────cnt─┬───────uniq─┬─uniqError─┬─uniqTheta─┬──────────ThetaError─┬─g─┐
│ 100000000010018037770.18037779958074220.419257799999999961 │
└────────────┴────────────┴───────────┴───────────┴─────────────────────┴───┘

Metadata

Metadata

Assignees

No one assigned

    Labels

    not plannedKnown issue, no plans to fix it currenltyunexpected behaviourResult is unexpected, but not entirely wrong at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions