Skip to content

Flyway ClickHouse plugin does not support parameterised views #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dilipsabherwal opened this issue May 2, 2025 · 0 comments
Open

Comments

@dilipsabherwal
Copy link

Summary

ClickHouse supports parameterized views, which allow view definitions to include placeholders such as {timezone:String} that are dynamically passed at query time. However, Flyway (via flyway-database-clickhouse) fails to preserve these placeholders — they are either stripped, misinterpreted as Flyway placeholders, or wrapped incorrectly — making it impossible to define parameterized views via Flyway migrations.

Environment

flyway-database-clickhouse version: 10.16.4
ClickHouse version: 24.12.1.18266
Flyway execution method: flyway-maven-plugin
Migration type: SQL

Steps to Reproduce

Create a view like this in a Flyway SQL migration file:

CREATE VIEW IF NOT EXISTS my_view
AS
SELECT
  toDate(timestamp, {timezone:String}) AS day,
  count() AS total
FROM my_table;

Run the migration via the Flyway Maven plugin.

Observe that:

[ERROR] SQL State  : 07000
[ERROR] Error Code : 62
[ERROR] Message    : Code: 62. DB::Exception: Syntax error: failed at position 

This happens because Flyway interprets {timezone:String} as a Flyway placeholder and attempts to replace or remove it, resulting in invalid ClickHouse SQL.

Expected Behavior

The SQL should be passed to ClickHouse as-is, preserving {timezone:String} in the view definition so the view can be used like this:

SELECT * FROM my_view(timezone = 'UTC');

Request

Please consider adding support for preserving {param:Type} syntax as-is when passed to ClickHouse, or provide a mechanism to escape or disable Flyway's placeholder parsing in specific migrations.

This would allow us to use parameterized views — a native ClickHouse feature — directly within managed Flyway migrations.

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

No branches or pull requests

1 participant