Skip to content

Conversation

@slgeliberty
Copy link

@slgeliberty slgeliberty commented Nov 22, 2025

Note

Adds end-to-end ClickHouse Null engine support (parsing, DDL/serialization, codegen, SDK validation), skips MV truncation for Null targets, and updates tests/templates.

  • ClickHouse engine support (Rust/CLI):
    • Add Null to ClickhouseEngine with string round‑trip, proto serialization, hashing, and DDL emission in create_table_query.
    • Extend engine parsing (TryFrom<&str>, regular engine parser) and SQL parser tests to recognize ENGINE = Null (case-insensitive).
    • Partial infra map: accept engine: "Null" via EngineConfig and map to ClickhouseEngine::Null.
    • Diff strategy: when auto-populating new materialized views in dev, skip truncation if target table uses Null; add helper to match MV target table.
  • Code generation:
    • Python generator: emit NullEngine(); TypeScript generator: emit engine: ClickHouseEngines.Null.
  • Python SDK (py-moose-lib):
    • Add ClickHouseEngines.Null and NullEngine config class.
    • Enforce that NullEngine rejects ORDER BY, PARTITION BY, and SAMPLE BY in OlapConfig.
    • Internal serialization: include Null in discriminated union and conversions.
  • TypeScript SDK (ts-moose-lib):
    • Add ClickHouseEngines.Null, NullEngineConfig, and NullConfig<T>; validate that Null forbids ORDER BY/PARTITION BY/SAMPLE BY.
    • Infra map builder outputs engine: "Null" for tables using Null.
  • Tests/templates:
    • Add NullEngineTest tables to TS/Python templates and schema expectations.
    • New tests for Null engine parsing/round‑trip and config handling in Rust/Python/TS.

Written by Cursor Bugbot for commit 88ef238. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Nov 22, 2025

Someone is attempting to deploy a commit to the Fiveonefour Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Null engine incorrectly allows PARTITION BY clause

The supports_partition_by matching at lines 2522-2532 doesn't include ClickhouseEngine::Null, which means Null engine tables will incorrectly permit PARTITION BY clauses. This is inconsistent with the Python validation in olap_table.py (lines 207-215) which correctly rejects PARTITION BY for NullEngine. ClickHouse's Null engine doesn't support PARTITION BY, so attempting to create such tables will fail at runtime despite passing Rust-side validation.

apps/framework-cli/src/infrastructure/olap/clickhouse/queries.rs#L2521-L2532

let supports_sample_by = table.engine.is_merge_tree_family();
let supports_partition_by = matches!(
table.engine,
ClickhouseEngine::MergeTree
| ClickhouseEngine::ReplacingMergeTree { .. }
| ClickhouseEngine::AggregatingMergeTree
| ClickhouseEngine::SummingMergeTree { .. }
| ClickhouseEngine::ReplicatedMergeTree { .. }
| ClickhouseEngine::ReplicatedReplacingMergeTree { .. }
| ClickhouseEngine::ReplicatedAggregatingMergeTree { .. }
| ClickhouseEngine::ReplicatedSummingMergeTree { .. }
| ClickhouseEngine::S3 { .. }

Fix in Cursor Fix in Web


@slgeliberty slgeliberty marked this pull request as draft November 22, 2025 10:36
@slgeliberty slgeliberty marked this pull request as ready for review November 22, 2025 11:24
Copy link
Collaborator

@callicles callicles left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the contribution!

Looks like this is directionality correct - you are missing the TS implementation though 🙂

@@ -0,0 +1,26 @@
language = "python" # Must be typescript or python
Copy link
Collaborator

Choose a reason for hiding this comment

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

Template definitions are in a different repo - looks like your AI mixed examples and templates.

We run templates/typescript-tests and templates/python-tests in the CI.

You could remove this example altogether and add it there for automated testing.

The prompt could be something along the lines of:

"The end-to-end test is being run by apps/framework-cli-e2e please add the null engine to the templates that are used in the tests: templates/typescript-tests and templates/python-tests"

Copy link
Author

Choose a reason for hiding this comment

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

@callicles:

  • TS implementation
  • Moved null-engine-example to template using framwork-cli-e2e
  • Avoid truncate behavior on null engine table link to olap change on null engine target table of materialized view

@slgeliberty
Copy link
Author

Error occurs while setting null engine table as target table of materialized view because the webserver is trying to apply TRUNCATE TABLE statement which is not possible on null engine tables.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Null engine missing from partition support check

The supports_partition_by check doesn't include ClickhouseEngine::Null in the match statement, which means it defaults to false correctly by the match else clause. However, the explicit enumeration pattern used for other engines should include Null for clarity and consistency with validation in the Python SDK which explicitly lists NullEngine in engines_without_partition_by. The Null engine doesn't support PARTITION BY, ORDER BY, or SAMPLE BY clauses.

apps/framework-cli/src/infrastructure/olap/clickhouse/queries.rs#L2521-L2531

let supports_sample_by = table.engine.is_merge_tree_family();
let supports_partition_by = matches!(
table.engine,
ClickhouseEngine::MergeTree
| ClickhouseEngine::ReplacingMergeTree { .. }
| ClickhouseEngine::AggregatingMergeTree
| ClickhouseEngine::SummingMergeTree { .. }
| ClickhouseEngine::ReplicatedMergeTree { .. }
| ClickhouseEngine::ReplicatedReplacingMergeTree { .. }
| ClickhouseEngine::ReplicatedAggregatingMergeTree { .. }
| ClickhouseEngine::ReplicatedSummingMergeTree { .. }

Fix in Cursor Fix in Web


@callicles
Copy link
Collaborator

@slgeliberty Nice Progress! This is going in the right direction 😄

) -> bool {
if table.name == target_table {
return true;
}
Copy link

Choose a reason for hiding this comment

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

Bug: Table matching ignores database when names match

The table_matches_mv_target function returns true when table names match without checking if databases also match. The early return at line 437-439 (if table.name == target_table { return true; }) bypasses all database checks. When a Null engine table exists with the same name as the MV target but in a different database, this incorrectly identifies it as the target. This causes target_is_null_engine to be true and should_truncate to be set to false when it should be true, potentially leading to incorrect materialized view population behavior.

Fix in Cursor Fix in Web

@callicles
Copy link
Collaborator

@slgeliberty Do you want to push this accross the finish line or do you want us to help?

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.

2 participants