Skip to content

Conversation

KR-bluejay
Copy link

…ort for CSV (draft)

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

Summary (mandatory):
This PR introduces support for temporal formatting options (DATE_FORMAT, DATETIME_FORMAT, TIMESTAMP_FORMAT) in the COPY TO statement for CSV exports.

Details:

  • Added parsing of the new WITH options into CsvFormat.
  • Forwarded these options to the Arrow CSV writer, enabling custom formatting of date/datetime/timestamp columns during export.
  • Currently implemented only for CSV. JSON and Parquet are untouched.

Limitations / Open Questions:

  1. Validation: Chrono patterns need validation. Existing to_date / to_char functions already handle this; we may want to reuse that logic.
  2. JSON format: Arrow’s JSON writer does not currently support custom temporal formatting. Should we raise an error, ignore the option, or implement a fallback?
  3. Datetime vs Timestamp: The current design keeps both options (DATETIME_FORMAT and TIMESTAMP_FORMAT), but their distinction might need clarification (especially since Arrow internally treats datetime as timestamp).

PR Checklist

Please convert it to a draft if some of the following conditions are not met.

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.
  • API changes are backward compatible.
  • Schema or data changes are backward compatible.

@github-actions github-actions bot added size/XS docs-not-required This change does not impact docs. labels Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant