Skip to content

Commit 353cd2c

Browse files
* Update id logic returned from the engine (#441)
1 parent 6f26e71 commit 353cd2c

File tree

4 files changed

+63
-4
lines changed

4 files changed

+63
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [7.0.3] - 2025-09-16
8+
9+
### Fixed
10+
- Added type safe conversion of Id to UUID where response from TableEntity is a string on IngestionStatus.
11+
712
## [7.0.2] - 2025-07-24
813

914
### Fixed

ingest/src/main/java/com/microsoft/azure/kusto/ingest/result/IngestionStatus.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
package com.microsoft.azure.kusto.ingest.result;
55

66
import com.azure.data.tables.models.TableEntity;
7+
import com.microsoft.azure.kusto.data.StringUtils;
78

89
import java.time.Instant;
910
import java.time.OffsetDateTime;
1011
import java.util.HashMap;
1112
import java.util.Map;
1213
import java.util.UUID;
1314

15+
import org.slf4j.Logger;
16+
import org.slf4j.LoggerFactory;
17+
import reactor.util.annotation.Nullable;
18+
19+
import java.io.Serializable;
20+
import java.lang.invoke.MethodHandles;
21+
import java.net.URISyntaxException;
22+
1423
/// <summary>
1524
/// This class represents an ingestion status.
1625
/// </summary>
@@ -23,6 +32,7 @@ public class IngestionStatus {
2332
/// during the ingestion's process
2433
/// and will be updated as soon as the ingestion completes.
2534
/// </summary>
35+
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
2636
public OperationStatus status;
2737
private Map<String, Object> ingestionInfo = new HashMap<>();
2838

@@ -210,16 +220,30 @@ public Map<String, Object> getEntityProperties() {
210220
return ingestionInfo;
211221
}
212222

223+
static UUID fromId(Object id) {
224+
if (id instanceof String && StringUtils.isNotBlank((String) id)) {
225+
try {
226+
return UUID.fromString((String) id);
227+
} catch (IllegalArgumentException e) {
228+
log.warn("Failed to parse id [{}] to UUID,set to id set to null", id);
229+
return null;
230+
}
231+
} else if (id instanceof UUID) {
232+
return (UUID) id;
233+
}
234+
return null;
235+
}
236+
213237
public static IngestionStatus fromEntity(TableEntity tableEntity) {
214238
IngestionStatus ingestionStatus = new IngestionStatus();
215239
Object ingestionSourceId = tableEntity.getProperty("IngestionSourceId");
216-
ingestionStatus.setIngestionSourceId(ingestionSourceId == null ? null : (UUID) ingestionSourceId);
240+
ingestionStatus.setIngestionSourceId(fromId(ingestionSourceId));
217241

218242
ingestionStatus.setDatabase((String) tableEntity.getProperty("Database"));
219243
ingestionStatus.setTable((String) tableEntity.getProperty("Table"));
220244

221245
Object operationId = tableEntity.getProperty("OperationId");
222-
ingestionStatus.setOperationId(ingestionSourceId == null ? null : (UUID) operationId);
246+
ingestionStatus.setOperationId(operationId == null ? null : fromId(operationId));
223247

224248
Object status = tableEntity.getProperty("Status");
225249
if (status instanceof String) {
@@ -229,7 +253,7 @@ public static IngestionStatus fromEntity(TableEntity tableEntity) {
229253
}
230254

231255
Object activityId = tableEntity.getProperty("ActivityId");
232-
ingestionStatus.setActivityId(ingestionSourceId == null ? null : (UUID) activityId);
256+
ingestionStatus.setActivityId(ingestionSourceId == null ? null : fromId(activityId));
233257

234258
ingestionStatus.setFailureStatus((String) tableEntity.getProperty("FailureStatus"));
235259

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.microsoft.azure.kusto.ingest.result;
2+
3+
import com.azure.data.tables.models.TableEntity;
4+
import java.util.UUID;
5+
import java.util.stream.Stream;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.params.ParameterizedTest;
8+
import org.junit.jupiter.params.provider.MethodSource;
9+
10+
class IngestionStatusTest {
11+
static Stream<Object[]> fromIdTestCases() {
12+
UUID uuid = UUID.randomUUID();
13+
return Stream.of(
14+
//happy path
15+
new Object[]{uuid.toString(), uuid},
16+
new Object[]{uuid, uuid},
17+
//edge cases
18+
new Object[]{"", null},
19+
new Object[]{null, null},
20+
new Object[]{"not-a-uuid", null}
21+
);
22+
}
23+
24+
@ParameterizedTest
25+
@MethodSource("fromIdTestCases")
26+
void testFromId(Object input, UUID expected) {
27+
UUID result = IngestionStatus.fromId(input);
28+
Assertions.assertEquals(expected, result);
29+
}
30+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</developers>
3333

3434
<properties>
35-
<revision>7.0.2</revision> <!-- CHANGE THIS to adjust project version-->
35+
<revision>7.0.3</revision> <!-- CHANGE THIS to adjust project version-->
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3737
<java.version>1.8</java.version>
3838
<azure-bom-version>1.2.28</azure-bom-version>

0 commit comments

Comments
 (0)