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
Filtering by a Specific Date in Snowflake will bring inaccurate results #39769
Comments
This appears to happen also in SQL Server. However, I was not able to reproduce. For reference, here is the conversation with the customer. |
This comment was marked as spam.
This comment was marked as spam.
@camsaul I don't think this was fixed: I still get the same behaviour in both dashboard and the question ... I am running 1.49.6 and if i convert the question to SQL then it works as expected |
The same question converted to SQL does not have this issue |
So in the repo on stats, the SQL we're generating is
|
Ok apparently it's actually running SELECT
"PUBLIC"."orders"."id" AS "id",
"PUBLIC"."orders"."created_at" AS "created_at"
FROM
"2024_04_25_e15f5997_60ab_4c7d_8fde_164a001da04c_test-data"."PUBLIC"."orders"
WHERE
("PUBLIC"."orders"."created_at" >= ?)
AND ("PUBLIC"."orders"."created_at" < ?)
ORDER BY
"PUBLIC"."orders"."id" ASC
LIMIT
1048575 with {:params (#t "2019-02-11T00:00-08:00" #t "2019-02-12T00:00-08:00")} and this is definitely not working correctly |
So we're passing these parameters as
|
🤦 So it seems like I already fixed this four years ago (or at least thought I did) but we inadvertently broke the fix at some point in the past because these methods are never actually used, these methods are for Open question why the #11036 tests are still passing |
Apparently I'm a dumb dumb and fixed it for parameters/ZonedDateTime but not for OffsetDateTime or OffsetTime 🤦 |
Describe the bug
Filtering by "Specific date" filter in Snowflake will bring wrong results
To Reproduce
SQL for creating table and adding data with date time column
CREATE TABLE sample_table (
id INTEGER,
user_name VARCHAR,
created_at TIMESTAMP
);
-- Insert sample data for each hour of each day from November 10 to November 15
INSERT INTO sample_table (id, user_name, created_at)
SELECT
ROW_NUMBER() OVER (ORDER BY day, hour) AS id,
'User_' || ROW_NUMBER() OVER (ORDER BY day, hour) AS user_name,
DATEADD('MINUTE', (hour + day * 24) * 60, '2023-11-10 00:00:00') AS created_at
FROM
(
SELECT 0 AS day UNION ALL
SELECT 1 UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5
) AS days
CROSS JOIN
(
SELECT 0 AS hour UNION ALL
SELECT 1 UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5 UNION ALL
SELECT 6 UNION ALL
SELECT 7 UNION ALL
SELECT 8 UNION ALL
SELECT 9 UNION ALL
SELECT 10 UNION ALL
SELECT 11 UNION ALL
SELECT 12 UNION ALL
SELECT 13 UNION ALL
SELECT 14 UNION ALL
SELECT 15 UNION ALL
SELECT 16 UNION ALL
SELECT 17 UNION ALL
SELECT 18 UNION ALL
SELECT 19 UNION ALL
SELECT 20 UNION ALL
SELECT 21 UNION ALL
SELECT 22 UNION ALL
SELECT 23
) AS hours;
Expected behavior
Should only bring the results from that day
Logs
query in snowflake
Information about your Metabase installation
- Metabase 48.8
Severity
P2
Additional context
No response
The text was updated successfully, but these errors were encountered: