Skip to content

[doc] RETENTION examples: example 4 references a non-existent column; example 3 expected output contradicts its INSERT #3904

Description

@boluor

Verifying the RETENTION aggregate-function page (sql-manual/sql-functions/aggregate-functions/retention.md) on a live cluster (master daily; same text in version-3.x / version-4.x) surfaced two doc bugs. The page creates its own tables, so these are content errors, not missing setup.

Bug 1 — example 4 queries a column that doesn't exist (errors instead of returning NULL)

SELECT RETENTION(date = '2022-10-12') AS r FROM retention_test2 where uid is NULL;

retention_test2 is defined as (uid int, flag boolean, flag2 boolean) — there is no date column, so this fails with:
errCode = 2, detailMessage = Unknown column 'date' in 'table list'.
The example's intent ("empty aggregation returns NULL") would be shown correctly with a column that exists, e.g. SELECT RETENTION(flag) AS r FROM retention_test2 WHERE uid IS NULL; (the WHERE uid IS NULL already filters to zero rows → NULL).

Bug 2 — example 3 printed output contradicts its own INSERT

INSERT into retention_test2 values (0, false, false), (1, true, NULL);
SELECT * from retention_test2;

The doc prints:

| uid  | flag | flag2 |
|    0 |    1 |  NULL |
|    1 |    0 |     0 |

but the inserted rows are (0, false, false) and (1, true, NULL), i.e. the actual result is (0, 0, 0) and (1, 1, NULL). The printed flag/flag2 values don't match the INSERT (they look transposed). The expected output should be corrected to match the data.

Both reproduce on a fresh single-BE cluster. Happy to send a PR correcting example 4's column and example 3's expected output if that direction is agreed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions