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

Fix NaN values handling in the progressPercentage property #13

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JetBrains Rider
.idea/
*.sln.iml

# NuGet
*.nupkg
*.snupkg
Expand Down
3 changes: 3 additions & 0 deletions trino-csharp/Trino.Client.Test/Trino.Client.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<None Update="scripts\zero_rows.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="scripts\nan_progress.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions trino-csharp/Trino.Client.Test/TrinoClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ public void TestReadZeroRows()
}
}

/// <summary>
/// Test NaN values handling in the response
/// </summary>
[TestMethod]
public async Task TestNanProgress()
{
using (TrinoTestServer server = TrinoTestServer.Create("nan_progress.txt"))
{
var properties = server.GetConnectionProperties();
properties.Catalog = "memory";

using (TrinoConnection tc = new(properties))
{
using (TrinoCommand trinoCommand = new(tc, "INSERT INSERT memory.default.target_table (Id) SELECT Id FROM memory.default.target_table"))
{
var result = await trinoCommand.ExecuteNonQueryAsync(CancellationToken.None);
Assert.AreEqual(result, 0);
}
}
}
}

/// <summary>
/// Test that after cancellation schema can still be retrieved.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions trino-csharp/Trino.Client.Test/scripts/nan_progress.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Date=Tue, 05 Mar 2024 06:13:02 GMT|Connection=keep-alive|X-Content-Type-Options=nosniff|Vary=Accept-Encoding|Strict-Transport-Security=max-age=15724800; includeSubDomains|
{"id":"20250221_095950_00006_p6xi8","infoUri":"http://localhost/ui/query.html?20250221_095950_00006_p6xi8","nextUri":"http://localhost/v1/statement/executing/20250221_095950_00006_p6xi8/y45d228b42fc52c29776a876c0ab50e531346be8a/1","columns":[{"name":"rows","type":"bigint","typeSignature":{"rawType":"bigint","arguments":[]}}],"data":[[0]],"stats":{"state":"FINISHED","queued":false,"scheduled":true,"progressPercentage":"NaN","runningPercentage":"NaN","nodes":1,"totalSplits":18,"queuedSplits":0,"runningSplits":0,"completedSplits":18,"planningTimeMillis":446,"analysisTimeMillis":53,"cpuTimeMillis":277,"wallTimeMillis":338,"queuedTimeMillis":3,"elapsedTimeMillis":19819,"finishingTimeMillis":18102,"physicalInputTimeMillis":0,"processedRows":0,"processedBytes":0,"physicalInputBytes":0,"physicalWrittenBytes":0,"internalNetworkInputBytes":177,"peakMemoryBytes":265474,"spilledBytes":0,"rootStage":{"stageId":"0","state":"FINISHED","done":true,"nodes":1,"totalSplits":9,"queuedSplits":0,"runningSplits":0,"completedSplits":9,"cpuTimeMillis":35,"wallTimeMillis":59,"processedRows":2,"processedBytes":177,"physicalInputBytes":0,"failedTasks":0,"coordinatorOnly":true,"subStages":[{"stageId":"1","state":"FINISHED","done":true,"nodes":1,"totalSplits":9,"queuedSplits":0,"runningSplits":0,"completedSplits":9,"cpuTimeMillis":242,"wallTimeMillis":279,"processedRows":0,"processedBytes":0,"physicalInputBytes":0,"failedTasks":0,"coordinatorOnly":false,"subStages":[{"stageId":"2","state":"FINISHED","done":true,"nodes":1,"totalSplits":0,"queuedSplits":0,"runningSplits":0,"completedSplits":0,"cpuTimeMillis":0,"wallTimeMillis":0,"processedRows":0,"processedBytes":0,"physicalInputBytes":0,"failedTasks":0,"coordinatorOnly":false,"subStages":[]}]}]}},"warnings":[],"updateType":"INSERT","updateCount":0}
Date=Tue, 05 Mar 2024 06:13:02 GMT|Connection=keep-alive|X-Content-Type-Options=nosniff|Vary=Accept-Encoding|Strict-Transport-Security=max-age=15724800; includeSubDomains|
{"id":"20250221_095950_00006_p6xi8","infoUri":"http://localhost/ui/query.html?20250221_095950_00006_p6xi8","columns":[{"name":"rows","type":"bigint","typeSignature":{"rawType":"bigint","arguments":[]}}],"stats":{"state":"FINISHED","queued":false,"scheduled":true,"progressPercentage":"NaN","runningPercentage":"NaN","nodes":1,"totalSplits":18,"queuedSplits":0,"runningSplits":0,"completedSplits":18,"planningTimeMillis":446,"analysisTimeMillis":53,"cpuTimeMillis":277,"wallTimeMillis":338,"queuedTimeMillis":3,"elapsedTimeMillis":19819,"finishingTimeMillis":18102,"physicalInputTimeMillis":0,"processedRows":0,"processedBytes":0,"physicalInputBytes":0,"physicalWrittenBytes":0,"internalNetworkInputBytes":177,"peakMemoryBytes":265474,"spilledBytes":0,"rootStage":{"stageId":"0","state":"FINISHED","done":true,"nodes":1,"totalSplits":9,"queuedSplits":0,"runningSplits":0,"completedSplits":9,"cpuTimeMillis":35,"wallTimeMillis":59,"processedRows":2,"processedBytes":177,"physicalInputBytes":0,"failedTasks":0,"coordinatorOnly":true,"subStages":[{"stageId":"1","state":"FINISHED","done":true,"nodes":1,"totalSplits":9,"queuedSplits":0,"runningSplits":0,"completedSplits":9,"cpuTimeMillis":242,"wallTimeMillis":279,"processedRows":0,"processedBytes":0,"physicalInputBytes":0,"failedTasks":0,"coordinatorOnly":false,"subStages":[{"stageId":"2","state":"FINISHED","done":true,"nodes":1,"totalSplits":0,"queuedSplits":0,"runningSplits":0,"completedSplits":0,"cpuTimeMillis":0,"wallTimeMillis":0,"processedRows":0,"processedBytes":0,"physicalInputBytes":0,"failedTasks":0,"coordinatorOnly":false,"subStages":[]}]}]}},"warnings":[],"updateType":"INSERT","updateCount":0}
2 changes: 1 addition & 1 deletion trino-csharp/Trino.Client/Model/StatementV1/TrinoStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public bool scheduled
public long processedBytes { get; set; }
public long peakMemoryBytes { get; set; }
public long spilledBytes { get; set; }
public long progressPercentage { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate commit .. and also why are you removing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's unused and there are other properties that are also missing here, I decided that the simplest fix is to remove it. However, I can also change its type to double, as defined here: QueryProgressStats.java#L34

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm ok either way, do we know why it's unused in Java? Is this a Presto legacy? I'd keep it as it's optional until it's removed from the Java

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt @wendigo @electrum .. should we remove here and also in the JDBC driver?

public double progressPercentage { get; set; }

/// <summary>
/// Get the query execution progress percentage as a ratio
Expand Down