Skip to content

MSSQL snapshot names exceed the 128 character object name length and break plans #5525

@codykonior-hsi

Description

@codykonior-hsi

I received this error while doing a plan today on an existing model with schema length of 3 and name length of 103:

Error: (103, b"The identifier that starts with 'xxx__xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx___4034064078_schema_' is too long. Maximum length is 128.DB-Lib error message 20018, severity 15:\nGeneral SQL Server error: Check messages from the SQL Server\n")

In MSSQL the maximum length of each part of the identifier is 128 characters and it seems that sqlmesh isn't following that for its internal snapshot naming.

I noticed that the max identifier length setting is missing from mssql.py:

MAX_IDENTIFIER_LENGTH = 128

But adding this just provides a prettier error message that you're sticking _tmp onto the end in _migrate_target_table and this is what is breaking it:

Error: Identifier name 'xxx__xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx___4034064078_schema_tmp' (length 131) exceeds Tsql's max identifier limit of 128 characters

Also, reducing that to 120 still gives the same error, so it appears that setting isn't being used to limit your snapshot naming length either.

I can't find where you actually construct your snapshot names or how to shorten it to within these limits.

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