diff --git a/src/Synapse/Synapse/ChangeLog.md b/src/Synapse/Synapse/ChangeLog.md index 2eb4b1822a94..30ba5f56b369 100644 --- a/src/Synapse/Synapse/ChangeLog.md +++ b/src/Synapse/Synapse/ChangeLog.md @@ -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 diff --git a/src/Synapse/Synapse/Commands/ManagementCommands/SparkPool/UpdateAzureSynapseSparkPool.cs b/src/Synapse/Synapse/Commands/ManagementCommands/SparkPool/UpdateAzureSynapseSparkPool.cs index 8bcf18674323..a441297a0bbf 100644 --- a/src/Synapse/Synapse/Commands/ManagementCommands/SparkPool/UpdateAzureSynapseSparkPool.cs +++ b/src/Synapse/Synapse/Commands/ManagementCommands/SparkPool/UpdateAzureSynapseSparkPool.cs @@ -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; @@ -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) { @@ -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; + } + } } }