Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception raised when Type is null #102

Closed
sebbrochet opened this issue Jun 21, 2022 · 1 comment
Closed

Exception raised when Type is null #102

sebbrochet opened this issue Jun 21, 2022 · 1 comment

Comments

@sebbrochet
Copy link

Get a Null Reference Exception inside DeltaKustoLib.KustoModel.MappingModel.MappingElement.Equals method when other.DataType is Null.

delta-kusto 0.10.2

Activating Client...
Client Activated
Newer clients available:  0.10.2.109
Loading parameters at 'XXX\rev-engineer-parameters.yaml'
2 jobs
Job 'download-dev':

Compute Delta...
829 commands in delta
Processing delta commands...
Delta processed / Job completed

Job 'delta-dev':

Compute Delta...
Exception registered with Session ID '142c3da0-d32f-4040-8f2f-ca94eef05edd'
Exception encountered:  System.NullReferenceException ; Object reference not set to an instance of an object.
Stack trace:     at DeltaKustoLib.KustoModel.MappingModel.MappingElement.Equals(Object obj) in C:\repos\delta-kusto\code\DeltaKustoLib\KustoModel\MappingModel.cs:line 79
   at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second)
   at DeltaKustoLib.KustoModel.MappingModel.MappingAsJsonEquals(QuotedText otherMappingAsJson) in C:\repos\delta-kusto\code\DeltaKustoLib\KustoModel\MappingModel.cs:line 180
   at DeltaKustoLib.KustoModel.MappingModel.Equals(Object obj) in C:\repos\delta-kusto\code\DeltaKustoLib\KustoModel\MappingModel.cs:line 120
   at DeltaKustoLib.DeltaHelper.GetUpdated[M,K](IEnumerable`1 currents, IEnumerable`1 targets, Func`2 keyExtractor)+MoveNext() in C:\repos\delta-kusto\code\DeltaKustoLib\DeltaHelper.cs:line 50
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at DeltaKustoLib.KustoModel.TableModel.ComputeDelta(TableModel targetModel)+MoveNext() in C:\repos\delta-kusto\code\DeltaKustoLib\KustoModel\TableModel.cs:line 334
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.ConcatNIterator`1.LazyToArray()
   at System.Linq.Enumerable.ConcatNIterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at DeltaKustoLib.KustoModel.DatabaseModel.ComputeDelta(DatabaseModel targetModel) in C:\repos\delta-kusto\code\DeltaKustoLib\KustoModel\DatabaseModel.cs:line 191
   at delta_kusto.DeltaOrchestration.ProcessJobAsync(MainParameterization parameters, IKustoManagementGatewayFactory kustoGatewayFactory, IFileGateway localFileGateway, String jobName, JobParameterization job) in C:\repos\delta-kusto\code\delta-kusto\DeltaOrchestration.cs:line 143
   at delta_kusto.DeltaOrchestration.ComputeDeltaAsync(String parameterFilePath, IEnumerable`1 pathOverrides) in C:\repos\delta-kusto\code\delta-kusto\DeltaOrchestration.cs:line 82
   at delta_kusto.DeltaOrchestration.ComputeDeltaAsync(String parameterFilePath, IEnumerable`1 pathOverrides) in C:\repos\delta-kusto\code\delta-kusto\DeltaOrchestration.cs:line 106
   at delta_kusto.DeltaOrchestration.ComputeDeltaAsync(String parameterFilePath, IEnumerable`1 pathOverrides) in C:\repos\delta-kusto\code\delta-kusto\DeltaOrchestration.cs:line 110
   at delta_kusto.Program.RunOptionsAsync(CommandLineOptions options) in C:\repos\delta-kusto\code\delta-kusto\Program.cs:line 120
   at CommandLine.ParserResultExtensions.WithParsedAsync[T](ParserResult`1 result, Func`2 action)
   at delta_kusto.Program.Main(String[] args) in C:\repos\delta-kusto\code\delta-kusto\Program.cs:line 51

Was able to work around it with this "fix":

public override bool Equals(object? obj)
{
    var other = obj as MappingElement;
    var result = other != null
        && other.Column.Equals(Column)
        && other.DataType != null && other.DataType.Equals(DataType)
        && other.Properties.Equals(Properties);

    return result;
}
sebbrochet added a commit to sebbrochet/delta-kusto that referenced this issue Jun 21, 2022
@vplauzon
Copy link
Contributor

Good catch. Fixed in 0.10.3.

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

No branches or pull requests

2 participants