Skip to content

[fix](doc) note that DATE_TRUNC time_unit must be a string constant#3734

Merged
morningman merged 1 commit into
apache:masterfrom
boluor:fix-date-trunc-constant-2673
May 22, 2026
Merged

[fix](doc) note that DATE_TRUNC time_unit must be a string constant#3734
morningman merged 1 commit into
apache:masterfrom
boluor:fix-date-trunc-constant-2673

Conversation

@boluor
Copy link
Copy Markdown
Contributor

@boluor boluor commented May 22, 2026

Summary

DATE_TRUNC accepts both argument orders — (<datetime>, <time_unit>) and (<time_unit>, <datetime>) — but the time unit must be a string constant; it cannot be a column or a non-constant expression. Passing a column there fails with the ... parameter of date_trunc function must be a string constant.

Added that constraint to the <time_unit> parameter description on the current/4.x EN and zh pages so the requirement is explicit.

Reported in #2673.

Test plan

  • Confirmed in FE source (DateTrunc.checkLegalityBeforeTypeCoercion requires a string-literal time unit).
  • Dead-link check passes.
  • CI build.

Closes #2673

DATE_TRUNC accepts both `(<datetime>, <time_unit>)` and
`(<time_unit>, <datetime>)`, but the time unit must be a string constant —
it cannot be a column or non-constant expression. Users hit
"the ... parameter of date_trunc function must be a string constant" when
passing a column there. Note this constraint in the time_unit parameter
description on the current/4.x EN and zh pages.

Reported in apache#2673.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@morningman morningman merged commit 4c09fc7 into apache:master May 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DATE_TRUNC Function not suppot DATE_TRUNC(<time_unit>, <datetime>)

2 participants