Il s'agit d'un bogue avec SQL Server. Si une colonne est supprimée d'une table avec un index columnstore en cluster, puis qu'une nouvelle colonne est ajoutée avec le même nom, elle semble utiliser l'ancienne colonne supprimée pour le prédicat. Voici le MVCE:
Ce script commence par des 10000lignes avec statusIdde 1et statusId2de 5- puis supprime la statusIDcolonne et renomme statusId2en statusId. Donc, à la fin, toutes les lignes doivent avoir un statusId5.
Mais la requête suivante frappe l'index non cluster ...
select *
from example
where statusId = 1
    and total <= @filter
    and barcode = @barcode
    and id2 = @id2
... et retourne des 2lignes (avec la sélection statusIddifférente de celle impliquée par la WHEREclause) ...
+-------+---------+------+-------+----------+
|  id   | barcode | id2  | total | statusId |
+-------+---------+------+-------+----------+
|     5 |    5    | NULL |  5.00 |        5 |
| 10005 |    5    | NULL |  5.00 |        5 |
+-------+---------+------+-------+----------+
... alors que celui-ci accède au magasin de colonnes et renvoie correctement 0
select count(*) 
from example 
where statusId = 1
MVCE
/*Create table with clustered columnstore and non clustered rowstore*/
CREATE TABLE example
(
id        INT IDENTITY(1, 1),
barcode   CHAR(22),
id2       INT,
total     DECIMAL(10,2),
statusId  TINYINT,
statusId2 TINYINT,
INDEX cci_example CLUSTERED COLUMNSTORE,
INDEX ix_example (barcode, total)
);
/* Insert 10000 rows all with (statusId,statusId2) = (1,5) */
INSERT example
       (barcode,
        id2,
        total,
        statusId,
        statusId2)
SELECT TOP (10000) barcode = row_number() OVER (ORDER BY @@spid),
                   id2 = NULL,
                   total = row_number() OVER (ORDER BY @@spid),
                   statusId = 1,
                   statusId2 = 5
FROM   sys.all_columns c1, sys.all_columns c2;
ALTER TABLE example
  DROP COLUMN statusid
/* Now have 10000 rows with statusId2 = 5 */
EXEC sys.sp_rename
  @objname = N'dbo.example.statusId2',
  @newname = 'statusId',
  @objtype = 'COLUMN';
/* Now have 10000 rows with StatusID = 5 */
INSERT example
       (barcode,
        id2,
        total,
        statusId)
SELECT TOP (10000) barcode = row_number() OVER (ORDER BY @@spid),
                   id2 = NULL,
                   total = row_number() OVER (ORDER BY @@spid),
                   statusId = 5
FROM   sys.all_columns c1, sys.all_columns c2;
/* Now have 20000 rows with StatusID = 5 */
DECLARE @filter  DECIMAL = 5,
        @barcode CHAR(22) = '5',
        @id2     INT = NULL; 
/*This returns 2 rows from the NCI*/
SELECT *
FROM   example WITH (INDEX = ix_example)
WHERE  statusId = 1
       AND total <= @filter
       AND barcode = @barcode
       AND id2 = @id2;
/*This counts 0 rows from the Columnstore*/
SELECT COUNT(*)
FROM   example
WHERE  statusId = 1;
J'ai également soulevé un problème sur le portail de commentaires Azure :
Et pour tous ceux qui rencontrent cela, la reconstruction de l'index de clustered Columnstore résout le problème:
alter index cci_example on example rebuild
La reconstruction de la CCI ne corrige que les données existantes. Si de nouveaux enregistrements sont ajoutés, le problème se pose à nouveau sur ces enregistrements; donc actuellement le seul correctif connu pour la table est de la recréer entièrement.