Skip to content

Commit

Permalink
Fix streaming ingestion policy error
Browse files Browse the repository at this point in the history
  • Loading branch information
vplauzon committed Oct 16, 2023
1 parent e97138e commit 5c83163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,10 @@ public override string ToScript(ScriptingContext? context = null)
var entityType = ExtractEntityType(commandBlock);
var nameReferences = commandBlock.GetDescendants<NameReference>();
var entityNameReference = nameReferences.Last();
// Weird parser behaviour: if the db (or db + cluster) is used
// in the name, the policy body is encoded differently
var policyText = nameReferences.Count == 1
? QuotedText.FromLiteral(
commandBlock.GetUniqueDescendant<LiteralExpression>(
"StreamingIngestion",
e => e.NameInParent == "StreamingIngestionPolicy"))
: QuotedText.FromText(
commandBlock
.GetUniqueDescendant<SkippedTokens>(
"StreamingIngestion")
.ToString());
var policyText = QuotedText.FromLiteral(
commandBlock.GetUniqueDescendant<LiteralExpression>(
"StreamingIngestion",
e => e.NameInParent == "StreamingIngestionPolicy"));
var policy = Deserialize<JsonDocument>(policyText.Text);

if (policy == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public void DbComposedTableName()
{
var command = ParseOneCommand(@$"
.alter table mydb.mytable policy streamingingestion
```
{{
""IsEnabled"":true
}}");
}}
```");

Assert.IsType<AlterStreamingIngestionPolicyCommand>(command);

Expand All @@ -43,10 +45,12 @@ public void ClusterComposedTableName()
{
var command = ParseOneCommand(@$"
.alter table mycluster.['my db'].mytable policy streamingingestion
```
{{
""IsEnabled"":true,
""HintAllocatedRate"":4.5
}}");
}}
```");

Assert.IsType<AlterStreamingIngestionPolicyCommand>(command);

Expand Down

0 comments on commit 5c83163

Please sign in to comment.