Skip to content

Commit

Permalink
Added UploadedTimestamp when adding package to spark pool by 'Update-…
Browse files Browse the repository at this point in the history
…AzSynapseSparkPool' (#17982)
  • Loading branch information
yanjungao718 authored May 6, 2022
1 parent c4f4848 commit 0248503
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Synapse/Synapse/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Set UploadedTimestamp when adding package to spark pool by `Update-AzSynapseSparkPool`

## Version 1.3.0
* Added support for Synapse Azure Active Directory (Azure AD) only authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Synapse.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -242,9 +243,9 @@ public override void ExecuteCmdlet()
Name = psPackage?.Name,
Type = psPackage?.PackageType,
Path = psPackage?.Path,
ContainerName = psPackage?.ContainerName
// TODO: set uploadedTimeStamp property after upgrading SDK otherwise we will see a incorrect property value from Azure portal.
})).ToList();
ContainerName = psPackage?.ContainerName,
UploadedTimestamp = DateTime.Parse(psPackage?.UploadedTimestamp).ToUniversalTime()
}), new LibraryComparer()).ToList();
}
else if (this.PackageAction == SynapseConstants.PackageActionType.Remove)
{
Expand Down Expand Up @@ -296,5 +297,34 @@ private SparkConfigProperties CreateSparkConfigProperties()
Content = this.ReadFileAsText(powerShellDestinationPath)
};
}

private class LibraryComparer : IEqualityComparer<LibraryInfo>
{
public bool Equals(LibraryInfo x, LibraryInfo y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;

//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;

return x.Name == y.Name
&& x.Path == y.Path
&& x.ContainerName == y.ContainerName
&& x.UploadedTimestamp == y.UploadedTimestamp
&& x.Type == y.Type;

}
public int GetHashCode(LibraryInfo obj)
{
//Check whether the object is null
if (Object.ReferenceEquals(obj, null)) return 0;

//Get hash code for the object if it is not null.
int hCode = obj.Name.GetHashCode() ^ obj.Path.GetHashCode() ^ obj.ContainerName.GetHashCode() ^ obj.UploadedTimestamp.GetHashCode() ^ obj.Type.GetHashCode();
return hCode;
}
}
}
}

0 comments on commit 0248503

Please sign in to comment.