Skip to content

[Enhancement] we should handle mv column name prefix restriction more friendly #53172

@wenzhenghu

Description

@wenzhenghu

Search before asking

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

Description

        if (columnName.startsWith(CreateMaterializedViewStmt.MATERIALIZED_VIEW_NAME_PREFIX)
                || columnName.startsWith(CreateMaterializedViewStmt.MATERIALIZED_VIEW_AGGREGATE_NAME_PREFIX)) {
            throw new AnalysisException(
                    "Incorrect column name " + columnName + ", column name can't start with 'mv_'/'mva_'");
        }

we currently could not create column start with 'mv_'/'mva_'. it is true that i can:

  • Avoid naming conflicts: Prevents user column names from conflicting with system-generated materialized view column names
  • System consistency: Ensures proper functioning of internal materialized view mechanisms

but:

  • Poor user experience: Users may legitimately need to create columns starting with mv_, making this restriction too strict
  • Prefix too short: mv_ and mva_ are too short and easily conflict with users' normal naming conventions

Solution

Better Handling Methods

  1. Use Longer System Prefixes or Use Special Character Prefixes
  2. Add Escaping Mechanism or Add Configuration Control

example:

  1. Use Longer System Prefixes
public static final String MATERIALIZED_VIEW_NAME_PREFIX = "__doris_internal_mv_";
public static final String MATERIALIZED_VIEW_AGGREGATE_NAME_PREFIX = "__doris_internal_mva_";

Advantages:

  • Greatly reduces conflict probability with user column names
  • Keeps existing logic simple
  1. Configuration Control
// Add configuration items in Config
public static boolean enable_mv_column_name_prefix_check = true;

Advantages:

  • Allow users to decide if they need to apply limitations

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions