sqlmesh icon indicating copy to clipboard operation
sqlmesh copied to clipboard

MSSQL: Order change in model columns definition crashed model plan

Open ebremst3dt opened this issue 1 year ago • 1 comments

Version used: 0.159.0 Engine: MSSQL

Example:

@model(
    columns={'chgdat': 'varchar(max)',
 'chgusr': 'varchar(max)',
 'compny': 'varchar(max)',
 'credat': 'varchar(max)',
 'creusr': 'varchar(max)',
 'digcod': 'varchar(max)',
 'dignam': 'varchar(max)',
 'migcod': 'varchar(max)',
 'sigcod': 'varchar(max)',
 'srtnam': 'varchar(max)',
 'srtnum': 'varchar(max)',
 'txtdsc': 'varchar(max)',
 'data_modified': 'date',
  'source_catalog': 'varchar(max)'
 
  }

In this model definition, the order is

  1. data_modified
  2. source_catalog

In my query it was:

  1. source_catalog
  2. data_modified

This results in MSSQLDatabaseException: (0, b'Unknown Error)

Having the same order makes the query run just fine.

I guess that the query informs how the dataframe is created, im just thinking sqlmesh should be able to pair the key values anyway, regardless of the order.

ebremst3dt avatar Feb 27 '25 08:02 ebremst3dt

@treysp can you please have a look

izeigerman avatar Mar 11 '25 18:03 izeigerman

This is fixed as of v0.182.0

erindru avatar May 26 '25 21:05 erindru