Skip to content

Map EXTRACT() to date_part()#31

Merged
theory merged 1 commit into
mainfrom
issue-24
Nov 4, 2025
Merged

Map EXTRACT() to date_part()#31
theory merged 1 commit into
mainfrom
issue-24

Conversation

@theory
Copy link
Copy Markdown
Collaborator

@theory theory commented Nov 3, 2025

Add the EXTRACT OIDs to the list of OIDs mapped to CF_DATE_PART, which deparse.c converts to ClickHouse equivalents. This allows EXTRACT() to function just like date_part().

Also add the OIDs for extracting values from dates; it previously worked with date_part() for some reason, but did not for EXTRACT(). So include them both for completeness.

Add tests for these patterns. Closes #24.

While at it, date_part() results to numbers in tests. The date_part() function returns double precision values, so compare to numeric values rather than strings.

@theory theory requested a review from serprex November 3, 2025 23:40
@theory theory self-assigned this Nov 3, 2025
@theory theory added the enhancement New feature or request label Nov 3, 2025
@theory theory marked this pull request as ready for review November 3, 2025 23:41
Add the `EXTRACT` OIDs to the list of OIDs mapped to `CF_DATE_PART`,
which `deparse.c` converts to ClickHouse equivalents. This allows
`EXTRACT()` to function just like `date_part()`.

Also add the OIDs for extracting values from dates; it previously worked
with `date_part()` for some reason, but did not for `EXTRACT()`. So
include them both for completeness.

Add tests for these patterns. Closes #24.
@theory theory merged commit fe2d232 into main Nov 4, 2025
32 checks passed
@theory theory deleted the issue-24 branch November 4, 2025 18:12
theory added a commit to theory/HouseClick that referenced this pull request Nov 4, 2025
Currently dupes the regular Postgres queries but replaces the
`uk_price_paid` table with `uk_price_paid_synthetic`. Left some comments
for where it should be able to use aggregate tables, but they're not
currently accessible to the `demo` user in
`sql-clickhouse.clickhouse.com` so not available to the FDW, either.

Update the `SelectArea()` function to enable the medium/large buttons
for both FDW and CLickHouse, and update `getQuery()` to fetch the large
FDW queries when wanted.

While at it, remove some trailing spaces from files and restore the
`EXTRACT()` function to the Postgres queries, since it was fixed by
ClickHouse/pg_clickhouse#31.
theory added a commit to theory/HouseClick that referenced this pull request Nov 4, 2025
Currently dupes the regular Postgres queries but replaces the
`uk_price_paid` table with `uk_price_paid_synthetic`. Left some comments
for where it should be able to use aggregate tables, but they're not
currently accessible to the `demo` user in
`sql-clickhouse.clickhouse.com` so not available to the FDW, either.

Update the `SelectArea()` function to enable the medium/large buttons
for both FDW and CLickHouse, and update `getQuery()` to fetch the large
FDW queries when wanted.

While at it, remove some trailing spaces from files and restore the
`EXTRACT()` function to the Postgres queries, since it was fixed by
ClickHouse/pg_clickhouse#31.
theory added a commit to theory/HouseClick that referenced this pull request Nov 14, 2025
Currently dupes the regular Postgres queries but replaces the some of
the table names to use the ClickHouse materialized views.

Update the `SelectArea()` function to enable the medium/large buttons
for both FDW and CLickHouse, and update `getQuery()` to fetch the large
FDW queries when wanted.

Add DDL to `schemas/postgres.sql` to create the `clickhouse_fdw`
extension and import the tables from the demo database so that they're
accessible to HouseClick. This won't work without `clickhouse_fdw`, so
add a placeholder to `README.md` for forthcoming installation
instructions.

While at it, remove some trailing spaces from files and restore the
`EXTRACT()` function to the Postgres queries, since it was fixed by
ClickHouse/pg_clickhouse#31.
theory added a commit to theory/HouseClick that referenced this pull request Nov 14, 2025
Currently dupes the regular Postgres queries but replaces the some of
the table names to use the ClickHouse materialized views.

Update the `SelectArea()` function to enable the medium/large buttons
for both FDW and CLickHouse, and update `getQuery()` to fetch the large
FDW queries when wanted.

Add DDL to `schemas/postgres.sql` to create the `clickhouse_fdw`
extension and import the tables from the demo database so that they're
accessible to HouseClick. This won't work without `clickhouse_fdw`, so
add a placeholder to `README.md` for forthcoming installation
instructions.

While at it, expand and reorder the configs in `.env.example` and`
remove some trailing spaces from files and restore the `EXTRACT()`
function to the Postgres queries, since it was fixed by
ClickHouse/pg_clickhouse#31.
theory added a commit to theory/HouseClick that referenced this pull request Nov 18, 2025
Currently dupes the regular Postgres queries but replaces the some of
the table names to use the ClickHouse materialized views.

Update the `SelectArea()` function to enable the medium/large buttons
for both FDW and CLickHouse, and update `getQuery()` to fetch the large
FDW queries when wanted.

Add DDL to `schemas/postgres.sql` to create the `clickhouse_fdw`
extension and import the tables from the demo database so that they're
accessible to HouseClick. This won't work without `clickhouse_fdw`, so
add a placeholder to `README.md` for forthcoming installation
instructions.

Update `README.md` to suggest running the pg_clickhouse Docker image,
and move the configuration description just prior to creating the
Postgres tables, since the import script can use the variables there.

While at it, expand and reorder the configs in `.env.example` and`
remove some trailing spaces from files and restore the `EXTRACT()`
function to the Postgres queries, since it was fixed by
ClickHouse/pg_clickhouse#31.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support extract() the same as date_part()

2 participants