Skip to content

feat(query): support DATE_TRUNC('WEEK', EXPR)->DATE #17407

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

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/query/sql/src/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3004,6 +3004,16 @@ impl<'a> TypeChecker<'a> {
&[date],
)
}
ASTIntervalKind::Week => {
self.resolve_function(
span,
"to_start_of_week", vec![],
&[date, &Expr::Literal {
span: None,
value: Literal::UInt64(1)
}],
)
}
ASTIntervalKind::Day => {
self.resolve_function(
span,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ SELECT max(MONTHS_BETWEEN(mine_date, birth_date))/12 as demo_age FROM t GROUP BY
statement ok
drop table if exists t;

query T
select date_trunc('month', '2025-02-05 00:01:00');
----
2025-02-01

query T
select date_trunc('week', '2025-02-05 00:01:00');
----
2025-02-03

query FF
SELECT
MONTHS_BETWEEN('2019-03-15'::DATE,
Expand Down