Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

468 Nulls instead of correct values in query results with LIMIT #24791

Open
krisislis opened this issue Jan 24, 2025 · 1 comment
Open

468 Nulls instead of correct values in query results with LIMIT #24791

krisislis opened this issue Jan 24, 2025 · 1 comment

Comments

@krisislis
Copy link

krisislis commented Jan 24, 2025

When I execute Query 1, starting from the N-th row, I get nulls in part of columns (all columns from t2, t3) of the result.
If I replace the subquery t1 with a table, the query result is complete.

Query 1:

WITH t1 AS (
    SELECT
        trim(u.purchaseDateTime) AS pdate,
        u.purchaseID AS pid,
        u.purchaseRevenue AS revenue,
        u.purchasecurrency AS currency
    FROM (
        SELECT distinct
              REPLACE(REPLACE(REPLACE("ym:s:purchaseDateTime", '[', ''), ']', ''), '\''', '') AS purchaseDateTime
            , REPLACE(REPLACE(REPLACE("ym:s:purchaseID", '[', ''), ']', ''), '''', '') AS purchaseID
            , REPLACE(REPLACE("ym:s:purchaseRevenue", '[', ''), ']', '') AS purchaseRevenue
            , REPLACE(REPLACE("ym:s:purchasecurrency", '[', ''), ']', '') AS purchasecurrency
        FROM visits_data
        WHERE REGEXP_LIKE("ym:s:goalsid", '140196988')
    ) d
    CROSS JOIN UNNEST(SPLIT(d.purchaseDateTime, ','), SPLIT(d.purchaseID, ','), SPLIT(d.purchaseRevenue, ','), SPLIT(d.purchasecurrency, ',')) 
        AS u (purchaseDateTime, purchaseID, purchaseRevenue, purchasecurrency)
    WHERE trim(u.purchaseDateTime) != ''
)
SELECT
    CAST(pdate AS TIMESTAMP) AS pdate,
    pid,
    revenue,
    yam.currency,
    t2.purchase_date        AS purchase_date,
    t2.purchase_sum,
    t2.platform,
    t2.city_from_name,
    t3.purchase_date         AS purchase_date_t3,
    t3.purchase_sum          AS purchase_sum_t3,
    t3.city_from_name        AS city_from_name_t3
FROM t1
    LEFT JOIN t2
        ON CAST(t2.purchase_id AS VARCHAR) = CAST(pid AS VARCHAR)
    LEFT JOIN t3
        ON CAST(t3.purchase_id AS VARCHAR) = pid
LIMIT 200;

Environment:
Trino 468
Iceberg connector
Rest catalog

@ebyhr
Copy link
Member

ebyhr commented Jan 28, 2025

Could you share the entire steps to reproduce with simple table definition and SELECT query?

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

No branches or pull requests

2 participants