Skip to content

Commit 43d860d

Browse files
author
Jonathan P Moraes
committed
Implementing complex mapper
1 parent 5a0e71f commit 43d860d

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2018-2024 contributors to the Marquez project
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package marquez.db.mappers;
7+
8+
import java.sql.ResultSet;
9+
import java.sql.SQLException;
10+
import java.util.UUID;
11+
import lombok.NonNull;
12+
import org.apache.commons.lang3.tuple.Pair;
13+
import org.jdbi.v3.core.mapper.RowMapper;
14+
import org.jdbi.v3.core.statement.StatementContext;
15+
16+
public final class ComplexDatasetFieldPairMapper implements RowMapper<Pair<Pair<String, Pair<String, String>>, UUID>> {
17+
@Override
18+
public Pair<Pair<String, Pair<String, String>>, UUID> map(@NonNull ResultSet results, @NonNull StatementContext context)
19+
throws SQLException {
20+
// Map the columns to the complex Pair structure
21+
String namespaceName = results.getString("namespace_name");
22+
String datasetName = results.getString("dataset_name");
23+
String fieldName = results.getString("name");
24+
UUID uuid = results.getObject("uuid", UUID.class);
25+
26+
// Construct the nested Pair structure
27+
Pair<String, String> datasetPair = Pair.of(datasetName, fieldName);
28+
Pair<String, Pair<String, String>> identifierPair = Pair.of(namespaceName, datasetPair);
29+
30+
// Return the final Pair with UUID
31+
return Pair.of(identifierPair, uuid);
32+
}
33+
}

0 commit comments

Comments
 (0)