fix: correct WideWorldImporters Data Warehouse table creation scripts#1494
Open
mchristopher wants to merge 1 commit into
Open
fix: correct WideWorldImporters Data Warehouse table creation scripts#1494mchristopher wants to merge 1 commit into
mchristopher wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: WideWorldImportersDW fact tables fail to publish with Msg 35316 (columnstore not partition-aligned)
Summary
Publishing the
WideWorldImportersDWSSDT project to a fresh database fails when creating the partitioned fact tables. This PR makes the five partitioned fact tables declare their partition scheme at the table level so their clustered columnstore indexes are partition-aligned with the base table.Problem
Deploying the project (SSDT / SqlPackage publish, or building the DACPAC and deploying) fails on the first partitioned fact table with:
Root cause
Each partitioned fact table (
Transaction,Movement,Sale,Order,Purchase) declares itsPRIMARY KEY NONCLUSTEREDand its nonclustered indexesON [PS_Date] (...), but theCREATE TABLEitself has no table-level partition placement. With no clustered rowstore index, the table's rows are created in an unpartitioned heap on the default filegroup.A partitioned clustered columnstore index requires the base table to already be partitioned on the same scheme — you cannot build a partitioned clustered columnstore index directly over an unpartitioned heap. So the final
CREATE CLUSTERED COLUMNSTORE INDEX ... ON [PS_Date] (...)fails with Msg 35316.Fix
Add a table-level
ON [PS_Date] (<date key column>)to theCREATE TABLEof each partitioned fact table, using that table's existing partition column. The base table is then created as a partitioned heap, and the nonclustered PK/indexes and the clustered columnstore index are all partition-aligned toPS_Date.Fact.Transaction[Date Key]Fact.Movement[Date Key]Fact.Purchase[Date Key]Fact.Sale[Invoice Date Key]Fact.Order[Order Date Key]Fact.Stock Holdingis intentionally not changed: it is not partitioned (no date column; its clustered columnstore index has no partition scheme), so it deploys correctly as-is.Example (
Fact/Tables/Transaction.sql):Files changed
samples/databases/wide-world-importers/wwi-dw-ssdt/wwi-dw-ssdt/Fact/Tables/Transaction.sqlsamples/databases/wide-world-importers/wwi-dw-ssdt/wwi-dw-ssdt/Fact/Tables/Movement.sqlsamples/databases/wide-world-importers/wwi-dw-ssdt/wwi-dw-ssdt/Fact/Tables/Purchase.sqlsamples/databases/wide-world-importers/wwi-dw-ssdt/wwi-dw-ssdt/Fact/Tables/Sale.sqlsamples/databases/wide-world-importers/wwi-dw-ssdt/wwi-dw-ssdt/Fact/Tables/Order.sqlCompatibility / risk
ON <partition_scheme>(<column>)is standard T-SQL and has been valid since table partitioning was introduced, so this does not raise the project's platform requirement.How to verify
Build the
WideWorldImportersDWSSDT project (resolves cleanly — noSQL71501unresolved-column errors).Publish to a fresh database; publish now completes without
Msg 35316.Confirm the fact tables are partitioned: