-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Openfga: use reference branches in intersection (#365)
- Loading branch information
Showing
7 changed files
with
254 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
29 changes: 29 additions & 0 deletions
29
src/FlowtideDotNet.Connector.OpenFGA/Internal/Models/ZanzibarRelationReference.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License") | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FlowtideDotNet.Connector.OpenFGA.Internal.Models | ||
{ | ||
internal class ZanzibarRelationReference : ZanzibarRelation | ||
{ | ||
public int ReferenceId { get; set; } | ||
public override T Accept<T, TState>(ZanzibarVisitor<T, TState> visitor, TState state) | ||
{ | ||
return visitor.VisitZanzibarRelationReference(this, state); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
160 changes: 160 additions & 0 deletions
160
src/FlowtideDotNet.Substrait/Modifier/ReferenceRemapVisitor.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License") | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using FlowtideDotNet.Substrait.Relations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FlowtideDotNet.Substrait.Modifier | ||
{ | ||
internal class ReferenceRemapVisitor : RelationVisitor<Relation, object?> | ||
{ | ||
private readonly Dictionary<int, int> idMap; | ||
|
||
public ReferenceRemapVisitor(Dictionary<int, int> idMap) | ||
{ | ||
this.idMap = idMap; | ||
} | ||
|
||
public override Relation VisitReadRelation(ReadRelation readRelation, object? state) | ||
{ | ||
return readRelation; | ||
} | ||
|
||
public override Relation VisitFilterRelation(FilterRelation filterRelation, object? state) | ||
{ | ||
filterRelation.Input = Visit(filterRelation.Input, state); | ||
return filterRelation; | ||
} | ||
|
||
public override Relation VisitJoinRelation(JoinRelation joinRelation, object? state) | ||
{ | ||
joinRelation.Left = Visit(joinRelation.Left, state); | ||
joinRelation.Right = Visit(joinRelation.Right, state); | ||
return joinRelation; | ||
} | ||
|
||
public override Relation VisitNormalizationRelation(NormalizationRelation normalizationRelation, object? state) | ||
{ | ||
normalizationRelation.Input = Visit(normalizationRelation.Input, state); | ||
return normalizationRelation; | ||
} | ||
|
||
public override Relation VisitProjectRelation(ProjectRelation projectRelation, object? state) | ||
{ | ||
projectRelation.Input = Visit(projectRelation.Input, state); | ||
return projectRelation; | ||
} | ||
|
||
public override Relation VisitWriteRelation(WriteRelation writeRelation, object? state) | ||
{ | ||
writeRelation.Input = Visit(writeRelation.Input, state); | ||
return writeRelation; | ||
} | ||
|
||
public override Relation VisitPlanRelation(PlanRelation planRelation, object? state) | ||
{ | ||
return planRelation; | ||
} | ||
|
||
public override Relation VisitReferenceRelation(ReferenceRelation referenceRelation, object? state) | ||
{ | ||
if (idMap.TryGetValue(referenceRelation.RelationId, out int newId)) | ||
{ | ||
referenceRelation.RelationId = newId; | ||
} | ||
return referenceRelation; | ||
} | ||
|
||
public override Relation VisitRootRelation(RootRelation rootRelation, object? state) | ||
{ | ||
rootRelation.Input = Visit(rootRelation.Input, state); | ||
return rootRelation; | ||
} | ||
|
||
public override Relation VisitSetRelation(SetRelation setRelation, object? state) | ||
{ | ||
for (int i = 0; i < setRelation.Inputs.Count; i++) | ||
{ | ||
setRelation.Inputs[i] = Visit(setRelation.Inputs[i], state); | ||
} | ||
return setRelation; | ||
} | ||
|
||
public override Relation VisitMergeJoinRelation(MergeJoinRelation mergeJoinRelation, object? state) | ||
{ | ||
mergeJoinRelation.Left = Visit(mergeJoinRelation.Left, state); | ||
mergeJoinRelation.Right = Visit(mergeJoinRelation.Right, state); | ||
return mergeJoinRelation; | ||
} | ||
|
||
public override Relation VisitAggregateRelation(AggregateRelation aggregateRelation, object? state) | ||
{ | ||
aggregateRelation.Input = Visit(aggregateRelation.Input, state); | ||
return aggregateRelation; | ||
} | ||
|
||
public override Relation VisitIterationRelation(IterationRelation iterationRelation, object? state) | ||
{ | ||
if (iterationRelation.Input != null) | ||
{ | ||
iterationRelation.Input = Visit(iterationRelation.Input, state); | ||
} | ||
iterationRelation.LoopPlan = Visit(iterationRelation.LoopPlan, state); | ||
|
||
return iterationRelation; | ||
} | ||
|
||
public override Relation VisitIterationReferenceReadRelation(IterationReferenceReadRelation iterationReferenceReadRelation, object? state) | ||
{ | ||
return iterationReferenceReadRelation; | ||
} | ||
|
||
public override Relation VisitUnwrapRelation(UnwrapRelation unwrapRelation, object? state) | ||
{ | ||
unwrapRelation.Input = Visit(unwrapRelation.Input, state); | ||
return unwrapRelation; | ||
} | ||
|
||
public override Relation VisitVirtualTableReadRelation(VirtualTableReadRelation virtualTableReadRelation, object? state) | ||
{ | ||
return virtualTableReadRelation; | ||
} | ||
|
||
public override Relation VisitBufferRelation(BufferRelation bufferRelation, object? state) | ||
{ | ||
bufferRelation.Input = Visit(bufferRelation.Input, state); | ||
return bufferRelation; | ||
} | ||
|
||
public override Relation VisitFetchRelation(FetchRelation fetchRelation, object? state) | ||
{ | ||
fetchRelation.Input = Visit(fetchRelation.Input, state); | ||
return fetchRelation; | ||
} | ||
|
||
public override Relation VisitSortRelation(SortRelation sortRelation, object? state) | ||
{ | ||
sortRelation.Input = Visit(sortRelation.Input, state); | ||
return sortRelation; | ||
} | ||
|
||
public override Relation VisitTopNRelation(TopNRelation topNRelation, object? state) | ||
{ | ||
topNRelation.Input = Visit(topNRelation.Input, state); | ||
return topNRelation; | ||
} | ||
} | ||
} |
This file contains 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