Skip to content

[Bug] Stream scan under CTE may skip NormalizeOlapTableStreamScan #65469

Description

@yujun777

Search before asking

  • I had searched in the issues and found no similar issues.

Version

master

What's Wrong?

When a stream scan is placed inside a CTE, NormalizeOlapTableStreamScan may not run in the old rewrite placement. The stream virtual columns are then left as scan outputs instead of being lowered into parent project aliases, and later rewrite steps treat them as real scan slots.

This breaks hidden stream column resolution in the incremental refresh path and can fail IVM planning.

What You Expected?

Stream scans should be normalized consistently whether they appear directly in the query tree or under a CTE.

How to Reproduce?

A minimal reproduction pattern is:

WITH cte AS (
    SELECT * FROM stream_table
)
SELECT * FROM cte;

In the broken path, the stream scan under the CTE is not lowered into an OLAP/binlog scan plus parent project aliases for the virtual stream columns.

Anything Else?

Related PR: #65468

The fix being proposed preserves LogicalOlapTableStreamScan during deep copy/CTE rewrite and moves NormalizeOlapTableStreamScan into the CTE children rewrite pipeline before OperativeColumnDerive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions