Skip to content

Support allowMaterializedViewsWithoutRowLevelSecurity when creating materialized views#148

Merged
ashleyvansp merged 2 commits intomainfrom
ashleyvansp/allowMaterializedViewsWithoutRowLevelSecurity2
Feb 27, 2026
Merged

Support allowMaterializedViewsWithoutRowLevelSecurity when creating materialized views#148
ashleyvansp merged 2 commits intomainfrom
ashleyvansp/allowMaterializedViewsWithoutRowLevelSecurity2

Conversation

@ashleyvansp
Copy link
Contributor

@ashleyvansp ashleyvansp commented Feb 27, 2026

This PR adds support for the allowMaterializedViewsWithoutRowLevelSecurity flag when creating materialized views. This allows materialized views to be created on tables with row level security policies enabled.

cc https://github.com/github/data/issues/9480

Copilot AI review requested due to automatic review settings February 27, 2026 17:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for the allowMaterializedViewsWithoutRowLevelSecurity property when creating materialized views in Kusto. This property allows materialized views to be created without row-level security policies, which is necessary in certain scenarios where row-level security would otherwise be required.

Changes:

  • Added AllowMaterializedViewsWithoutRowLevelSecurity boolean property to the MaterializedView class
  • Modified script generation logic to include the property when creating new materialized views
  • Added propagation logic in DatabaseChanges to copy the property from desired state to cluster state to avoid phantom diffs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
KustoSchemaTools/Model/MaterializedView.cs Added new boolean property and logic to include it in materialized view creation scripts when isNew=true
KustoSchemaTools/Changes/DatabaseChanges.cs Added propagation logic to copy the AllowMaterializedViewsWithoutRowLevelSecurity flag from new state to old state to prevent phantom diffs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

&& oldState.MaterializedViews.ContainsKey(mv.Key))
{
oldState.MaterializedViews[mv.Key].AllowMaterializedViewsWithoutRowLevelSecurity = true;
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The propagation logic only handles the direct AllowMaterializedViewsWithoutRowLevelSecurity property on MaterializedView, but not the same property in mv.Value.Policies.AllowMaterializedViewsWithoutRowLevelSecurity. Similar to the table propagation logic (lines 53-61), this should also propagate the Policies property to avoid phantom diffs when row-level security is configured. Consider adding:

if (mv.Value.Policies?.AllowMaterializedViewsWithoutRowLevelSecurity == true
    && oldState.MaterializedViews.ContainsKey(mv.Key)
    && oldState.MaterializedViews[mv.Key].Policies != null)
{
    oldState.MaterializedViews[mv.Key].Policies.AllowMaterializedViewsWithoutRowLevelSecurity = true;
}
Suggested change
}
}
if (mv.Value.Policies?.AllowMaterializedViewsWithoutRowLevelSecurity == true
&& oldState.MaterializedViews.ContainsKey(mv.Key)
&& oldState.MaterializedViews[mv.Key].Policies != null)
{
oldState.MaterializedViews[mv.Key].Policies.AllowMaterializedViewsWithoutRowLevelSecurity = true;
}

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +62
if (AllowMaterializedViewsWithoutRowLevelSecurity && isNew)
{
properties = string.IsNullOrEmpty(properties)
? "allowMaterializedViewsWithoutRowLevelSecurity=true"
: $"{properties}, allowMaterializedViewsWithoutRowLevelSecurity=true";
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new AllowMaterializedViewsWithoutRowLevelSecurity property lacks test coverage. Consider adding tests that verify:

  1. The property is correctly excluded from automatic property reflection (line 41)
  2. The property is correctly added to the script when creating a new materialized view with AllowMaterializedViewsWithoutRowLevelSecurity=true and isNew=true
  3. The property is NOT added when isNew=false (updating an existing materialized view)
  4. The property is correctly appended to existing properties with proper comma separation
  5. The property works correctly when there are no other properties

Similar to the test pattern in YamlDatabaseHandlerTests.cs line 169, you could test the generated scripts from CreateScripts.

Copilot uses AI. Check for mistakes.
@ashleyvansp ashleyvansp merged commit f06f9ac into main Feb 27, 2026
9 checks passed
@ashleyvansp ashleyvansp deleted the ashleyvansp/allowMaterializedViewsWithoutRowLevelSecurity2 branch February 27, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants