Skip to content

feat: Add support for date.to_text for BigQuery#5712

Merged
max-sixty merged 2 commits intoPRQL:mainfrom
segv:to-text-for-bigquery
Mar 17, 2026
Merged

feat: Add support for date.to_text for BigQuery#5712
max-sixty merged 2 commits intoPRQL:mainfrom
segv:to-text-for-bigquery

Conversation

@segv
Copy link
Copy Markdown
Contributor

@segv segv commented Mar 15, 2026

No description provided.

use crate::{Error, Result};

/// Convert a chrono format `Item` back to its strftime string representation.
fn chrono_item_to_strftime(item: &Item) -> String {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in the BigQuery error message to make it easy to see exactly which part of the format is breaking the query:

    Error:
       ╭─[ :6:33 ]
       │
     6 │       d_str = (d | date.to_text "%-m/%d/%Y")
       │                                 ─────┬─────
       │                                      ╰─────── format specifier `%-m` is not supported for BigQuery
    ───╯

otherwise it wouldn't be clear if the culprit was %-m, %d, or %Y.

I have only added this to the BigQuery error message to keep the changes in this PR to a minimum. More than happy to make this change for all dialects if you're ok with this.

@segv segv force-pushed the to-text-for-bigquery branch from 7513e68 to 9e97e8c Compare March 15, 2026 21:28
@segv segv marked this pull request as ready for review March 15, 2026 21:30
@segv segv force-pushed the to-text-for-bigquery branch from 9e97e8c to 3a4d00c Compare March 15, 2026 21:39
// -- chrono_item_to_strftime tests --

#[test]
fn chrono_item_to_strftime_numerics_zero_pad() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced these tests add a lot of value and personally I would drop 90% of them and just leave a few in as spot checks.

However the coverage tool wants high coverage, so I've just gone ahead and covered every code path. Happy to drop this if that's ok.

@segv segv force-pushed the to-text-for-bigquery branch from 78f6054 to e33e4ba Compare March 16, 2026 08:43
@max-sixty max-sixty merged commit 92095f9 into PRQL:main Mar 17, 2026
36 checks passed
@max-sixty
Copy link
Copy Markdown
Member

thank you @segv ! overall this seems very reasonable.

no stress on the tests; I agree re the narrow focus on coverage. but no harm in them either.

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.

2 participants