Skip to content

Commit

Permalink
add override
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Oct 29, 2024
1 parent ac3a0ac commit 02114c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Rdmp.Core/DataLoad/Modules/Attachers/RemoteAttacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public RemoteAttacher() : base(true) { }
[DemandsInitialization("Which column in the remote table can be used to perform time-based data selection")]
public string RemoteTableDateColumn { get; set; }

[DemandsInitialization("Option name for the Date colunn table within RDMP if it differs from the remote table e.g Due to joins")]
public string RawTableDateColumn { get; set; }

private readonly string RemoteTableDateFormat = "yyyy-MM-dd HH:mm:ss.fff";

[DemandsInitialization("Earliest date when using a custom fetch duration")]
Expand Down Expand Up @@ -173,9 +176,14 @@ private bool IsThisRemoteAttacher(IProcessTask task)
return true;
}

public void FindMostRecentDateInLoadedData(IQuerySyntaxHelper syntaxFrom, DatabaseType dbType, string table, IDataLoadJob job)
public void FindMostRecentDateInLoadedData(IQuerySyntaxHelper syntaxFrom, DatabaseType dbType, string table, IDataLoadJob job, bool userOverrideColumn = false)
{
var maxDateSql = $"SELECT MAX({RemoteTableDateColumn}) FROM {syntaxFrom.EnsureWrapped(table)} {SqlHistoricalDataFilter(job.LoadMetadata, dbType)}";
var column = RemoteTableDateColumn;
if (userOverrideColumn && !string.IsNullOrWhiteSpace(RawTableDateColumn))
{
column = RawTableDateColumn;
}
var maxDateSql = $"SELECT MAX({column}) FROM {syntaxFrom.EnsureWrapped(table)} {SqlHistoricalDataFilter(job.LoadMetadata, dbType)}";

using var con = _dbInfo.Server.GetConnection();
using var dt = new DataTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public override ExitCodeType Attach(IDataLoadJob job, GracefulCancellationToken

if (SetDeltaReadingToLatestSeenDatePostLoad)
{
FindMostRecentDateInLoadedData(rawSyntax, _dbInfo.Server.DatabaseType, rawTableName, job);
FindMostRecentDateInLoadedData(rawSyntax, _dbInfo.Server.DatabaseType, rawTableName, job,true);
}


Expand Down

0 comments on commit 02114c8

Please sign in to comment.