Skip to content

Add hyperbolic functions: sinh, cosh, tanh.#118

Open
aturingprogramming wants to merge 1 commit into
Snowflake-Labs:mainfrom
aturingprogramming:pushdown-hyperbolic2-funcs
Open

Add hyperbolic functions: sinh, cosh, tanh.#118
aturingprogramming wants to merge 1 commit into
Snowflake-Labs:mainfrom
aturingprogramming:pushdown-hyperbolic2-funcs

Conversation

@aturingprogramming
Copy link
Copy Markdown

Add Hyperbolic Functions: sinh, cosh, tanh

Description

This PR adds support for the following hyperbolic functions:

  • sinh
  • cosh
  • tanh

The following changes are included:

  • Implemented C++ scalar functions for sinh, cosh and tanh.
  • Registered the functions in the function loader.
  • Added SQL wrappers for each function in lake__internal__nsp.
  • Added pytest cases to verify correctness and pushdown behavior.

Signed-off-by: elias <eliaskamadis@gmail.com>
@aturingprogramming aturingprogramming marked this pull request as draft December 31, 2025 19:49
@aturingprogramming aturingprogramming marked this pull request as ready for review December 31, 2025 20:26
Copy link
Copy Markdown
Collaborator

@sfc-gh-okalaci sfc-gh-okalaci left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and sorry for the late review!

I don't think we should re-write the functions, they have the exact equivalents in DuckDB, so we should let it pushdown as is. Re-writing is required when there is no 1-1 mapping between the functions in DuckDB and Postgres. It seems all 3 functions have equivalents in DuckDB, and they produce the same results for all the inputs.

So, basically we don't need to create functions in duckdb_pglake, such as SinhPG or function in Postgres like __lake__internal__nsp__.sinh_pg.

Extending the pg_lake_engine/src/pgduck/shippable_builtin_functions.c and adding the test should be sufficient.

nd they produce the same results for all the inputs.

Though, please make sure the functions produce the same results for all possible input values (e.g., negative values, values between -1 and 1, etc), as our experience show that sometimes there are some minor behavioral differences between Postgres and DuckDB in such functions. If that's the case, it requires some more detailed investigation on how to map the functions.

@sfc-gh-mslot
Copy link
Copy Markdown
Collaborator

yeh, seems like the DuckDB docs are stale and these functions are actually supported.

D select sinh(3);
┌────────────────────┐
│      sinh(3)       │
│       double       │
├────────────────────┤
│ 10.017874927409903 │
└────────────────────┘

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.

3 participants