kayak / pypika

PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.
http://pypika.readthedocs.io/en/latest/
Apache License 2.0
2.43k stars 292 forks source link

Add support of SETTINGS ClickHouse clause #803

Open martijnthe opened 1 month ago

martijnthe commented 1 month ago

Summary

Clickhouse SQL has an optional SETTINGS clause with SELECTs which can be used to configure all kinds of options.

This PR adds a settings method to ClickHouseQueryBuilder to add these options to a SELECT query.

All current (Clickhouse 24.4) settings keys are snake-case. Therefore I opted to use the settings keys directly as kwargs to the settings method, allowing passing multiple settings pairs in one call in a Pythonic/ideomatic way.

Test Plan

Added a unit test to exercise the new function.

martijnthe commented 1 month ago

cc @AzisK -- tagging you because you reviewed a very similar PR (#707). Thanks for looking!