Column has a data type that cannot participate in a columnstore index

Column has a data type that cannot participate in a columnstore index

If you are seeing this post that means you might have encountered the error, Column xxx has a data type that cannot participate in columnstore index while creating a table or copying a table to SQL server or Azure Synapse Data warehouse.

Column cannot participate in columnstore index

How to fix Column has a data type that cannot participate in a columnstore index?

  1. Go through the below links to know the limitations of columnstore index of SQL server and Azure Synapse DW.

https://learn.microsoft.com/en-us/sql/t-sql/statements/create-columnstore-index-transact-sql?view=azure-sqldw-latest#LimitRest

https://learn.microsoft.com/en-us/sql/t-sql/statements/create-columnstore-index-transact-sql?view=sql-server-2017#LimitRest

If you have a conflicting data type, replace with a similar one. Example: Suppose you have nvarchar(max) which is not supported in both SQL Server and Azure Synapse DW try to replace with nvarchar(4000) by properly checking data that no column values exceed 4000. In most of the cases, when we give auto create option to create tables in Synapse Analytics, it will default create string columns with nvarchar(max) in these case reduce the varchar size will help to eliminate the issue.

2. Change table option. Clustered columnstore index is the default for Azure Synapse Analytics. If you are using below, select into statement to copy table.

SELECT * INTO  FROM

Replace it with CTAS because using select into we can’t change the distribution or the index option. Example CTAS statement.

CREATE TABLE <new table name>
WITH
(
 DISTRIBUTION = ROUND_ROBIN
 ,HEAP
)
AS
SELECT  *
FROM  <old table name>

In the above statement, we are using HEAP as our storage strategy.

3. If you have faced this issue while writing data from Azure Databricks to Azure SQL Data warehouse. Your code might be something like

dataframe.format(‘jdbc’).option(<databasedetails>).save()

Here also we need to change our storage strategy. You can use tableOptions option to add the distribution and storage strategy.

4. If you have faced this issue while using copy activity in Azure Data Factory. Change the copy method from Copy Command to PolyBase.

Copy strategy : Copy command
Copy Command
Copy strategy : Polybase
PolyBase

Feel free to comment for questions and clarifications.

© 2023 – 2022, Datalieve . All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page