Skip to content

Add toUnixTimestamp and fromUnixTimestamp functions#36

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-timestamp-functions
Draft

Add toUnixTimestamp and fromUnixTimestamp functions#36
Copilot wants to merge 4 commits intomainfrom
copilot/add-timestamp-functions

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Implements two ClickHouse timestamp conversion functions missing from the extension.

Changes

  • toUnixTimestamp(date_expression): Converts timestamp to Unix epoch seconds (BIGINT) using EXTRACT(EPOCH FROM date_expression)
  • fromUnixTimestamp(unix_timestamp): Converts Unix epoch seconds to timestamp using to_timestamp(unix_timestamp)

Both macros added to chsql_extension.cpp following existing date/time function patterns.

Usage

SELECT toUnixTimestamp('2023-05-15 10:30:45'::TIMESTAMP);
-- Returns: 1684147845

SELECT fromUnixTimestamp(1684147845);
-- Returns: 2023-05-15 10:30:45

Tests added to validate round-trip conversion correctness.

Original prompt

This section details on the original issue you should resolve

<issue_title>Missing timestamp funcitons</issue_title>
<issue_description>- toUnixTimestamp

  • fromUnixTimestamp

https://clickhouse.com/docs/sql-reference/functions/date-time-functions#fromUnixTimestamp

I'll try to add a PR that implements these functions.</issue_description>

<agent_instructions>Attempt implementing the requested new macros and add tests to validate them</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLAassistant commented Feb 17, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ lmangani
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits February 17, 2026 17:26
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot AI changed the title [WIP] Add missing timestamp functions to date-time functions Add toUnixTimestamp and fromUnixTimestamp functions Feb 17, 2026
Copilot AI requested a review from lmangani February 17, 2026 17:27
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.

Missing timestamp funcitons

3 participants