Skip to content

Added support for custom timestamp format - #755

Draft
jprakash-db wants to merge 2 commits into
mainfrom
jprakash-db/custom-timestamp-format
Draft

Added support for custom timestamp format#755
jprakash-db wants to merge 2 commits into
mainfrom
jprakash-db/custom-timestamp-format

Conversation

@jprakash-db

Copy link
Copy Markdown
Contributor

Added support for custom timestamp format

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Other

Description

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

Related Tickets & Documents

CopilotAI review requested due to automatic review settings March 16, 2026 08:56
@github-actions

Copy link
Copy Markdown

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an optional, user-supplied timestamp parsing format that’s threaded from Connection config through result fetching and into the non-Arrow conversion paths, with unit tests covering the new behavior.

Changes:

  • Added parse_timestamp() helper and plumbed an optional timestamp_format through Thrift column-based result conversion.
  • Added non_arrow_timestamp_format connection option and passed it into both Thrift and SEA non-Arrow timestamp conversions.
  • Added unit tests for explicit-format parsing and fallback to dateutil parsing.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/databricks/sql/utils.pyAdds parse_timestamp() and wires timestamp_format into column-table timestamp conversion and queue-building.
src/databricks/sql/client.pyAdds non_arrow_timestamp_format connection attribute sourced from **kwargs.
src/databricks/sql/result_set.pyPasses connection timestamp format into Thrift queue/fetch paths.
src/databricks/sql/backend/thrift_backend.pyThreads timestamp_format into build_queue() during fetch_results().
src/databricks/sql/backend/sea/utils/conversion.pyRoutes SEA TIMESTAMP conversion through parse_timestamp() with optional format.
src/databricks/sql/backend/sea/result_set.pyPasses connection timestamp format into SEA row conversion.
tests/unit/test_util.pyAdds parse_timestamp() and column-table conversion tests with/without format.
tests/unit/test_sea_conversion.pyAdds SEA timestamp conversion tests with format + fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +75 to +77
return datetime.datetime.strptime(value, timestamp_format).replace(
tzinfo=pytz.UTC
)
Comment on lines +167 to 171
elif sql_type == SqlType.TIMESTAMP:
timestamp_format = kwargs.get("timestamp_format", None)
return parse_timestamp(value, timestamp_format)
else:
return converter_func(value)
Comment on lines 295 to 299
self.disable_pandas = kwargs.get("_disable_pandas", False)
self.lz4_compression = kwargs.get("enable_query_result_lz4_compression", True)
self.use_cloud_fetch = kwargs.get("use_cloud_fetch", True)
self.non_arrow_timestamp_format = kwargs.get("non_arrow_timestamp_format", None)
self._cursors = [] # type: List[Cursor]
@github-actions

Copy link
Copy Markdown

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

@jprakash-db
jprakash-db marked this pull request as draft March 16, 2026 09:13
Sign up for freeto 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

@jprakash-db