Skip to content

Commit 0248503

Browse files
authored
Added UploadedTimestamp when adding package to spark pool by 'Update-AzSynapseSparkPool' (#17982)
1 parent c4f4848 commit 0248503

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/Synapse/Synapse/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

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

2324
## Version 1.3.0
2425
* Added support for Synapse Azure Active Directory (Azure AD) only authentication

src/Synapse/Synapse/Commands/ManagementCommands/SparkPool/UpdateAzureSynapseSparkPool.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2323
using Microsoft.Azure.Management.Synapse.Models;
2424
using Microsoft.WindowsAzure.Commands.Utilities.Common;
25+
using System;
2526
using System.Collections;
2627
using System.Collections.Generic;
2728
using System.IO;
@@ -242,9 +243,9 @@ public override void ExecuteCmdlet()
242243
Name = psPackage?.Name,
243244
Type = psPackage?.PackageType,
244245
Path = psPackage?.Path,
245-
ContainerName = psPackage?.ContainerName
246-
// TODO: set uploadedTimeStamp property after upgrading SDK otherwise we will see a incorrect property value from Azure portal.
247-
})).ToList();
246+
ContainerName = psPackage?.ContainerName,
247+
UploadedTimestamp = DateTime.Parse(psPackage?.UploadedTimestamp).ToUniversalTime()
248+
}), new LibraryComparer()).ToList();
248249
}
249250
else if (this.PackageAction == SynapseConstants.PackageActionType.Remove)
250251
{
@@ -296,5 +297,34 @@ private SparkConfigProperties CreateSparkConfigProperties()
296297
Content = this.ReadFileAsText(powerShellDestinationPath)
297298
};
298299
}
300+
301+
private class LibraryComparer : IEqualityComparer<LibraryInfo>
302+
{
303+
public bool Equals(LibraryInfo x, LibraryInfo y)
304+
{
305+
//Check whether the compared objects reference the same data.
306+
if (Object.ReferenceEquals(x, y)) return true;
307+
308+
//Check whether any of the compared objects is null.
309+
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
310+
return false;
311+
312+
return x.Name == y.Name
313+
&& x.Path == y.Path
314+
&& x.ContainerName == y.ContainerName
315+
&& x.UploadedTimestamp == y.UploadedTimestamp
316+
&& x.Type == y.Type;
317+
318+
}
319+
public int GetHashCode(LibraryInfo obj)
320+
{
321+
//Check whether the object is null
322+
if (Object.ReferenceEquals(obj, null)) return 0;
323+
324+
//Get hash code for the object if it is not null.
325+
int hCode = obj.Name.GetHashCode() ^ obj.Path.GetHashCode() ^ obj.ContainerName.GetHashCode() ^ obj.UploadedTimestamp.GetHashCode() ^ obj.Type.GetHashCode();
326+
return hCode;
327+
}
328+
}
299329
}
300330
}

0 commit comments

Comments
 (0)