-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Changed RunDao to use simple RunRow rather than ExtendedRunRow where possible Signed-off-by: Michael Collado <collado.mike@gmail.com> * Remove need to query JobRow on run completion Signed-off-by: Michael Collado <collado.mike@gmail.com>
- Loading branch information
1 parent
ccbdb96
commit ee44ae0
Showing
15 changed files
with
159 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2018-2022 contributors to the Marquez project | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package marquez.db.mappers; | ||
|
||
import static marquez.db.Columns.stringOrNull; | ||
import static marquez.db.Columns.timestampOrNull; | ||
import static marquez.db.Columns.timestampOrThrow; | ||
import static marquez.db.Columns.uuidOrNull; | ||
import static marquez.db.Columns.uuidOrThrow; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import lombok.NonNull; | ||
import marquez.common.Utils; | ||
import marquez.common.models.DatasetVersionId; | ||
import marquez.db.Columns; | ||
import marquez.db.models.RunRow; | ||
import org.jdbi.v3.core.mapper.RowMapper; | ||
import org.jdbi.v3.core.statement.StatementContext; | ||
|
||
public final class RunRowMapper implements RowMapper<RunRow> { | ||
@Override | ||
public RunRow map(@NonNull ResultSet results, @NonNull StatementContext context) | ||
throws SQLException { | ||
Set<String> columnNames = MapperUtils.getColumnNames(results.getMetaData()); | ||
|
||
return new RunRow( | ||
uuidOrThrow(results, Columns.ROW_UUID), | ||
timestampOrThrow(results, Columns.CREATED_AT), | ||
timestampOrThrow(results, Columns.UPDATED_AT), | ||
uuidOrNull(results, Columns.JOB_UUID), | ||
uuidOrNull(results, Columns.JOB_VERSION_UUID), | ||
uuidOrNull(results, Columns.PARENT_RUN_UUID), | ||
uuidOrThrow(results, Columns.RUN_ARGS_UUID), | ||
timestampOrNull(results, Columns.NOMINAL_START_TIME), | ||
timestampOrNull(results, Columns.NOMINAL_END_TIME), | ||
stringOrNull(results, Columns.CURRENT_RUN_STATE), | ||
columnNames.contains(Columns.STARTED_AT) | ||
? timestampOrNull(results, Columns.STARTED_AT) | ||
: null, | ||
uuidOrNull(results, Columns.START_RUN_STATE_UUID), | ||
columnNames.contains(Columns.ENDED_AT) ? timestampOrNull(results, Columns.ENDED_AT) : null, | ||
uuidOrNull(results, Columns.END_RUN_STATE_UUID)); | ||
} | ||
|
||
private List<DatasetVersionId> toDatasetVersion(ResultSet rs, String column) throws SQLException { | ||
String dsString = rs.getString(column); | ||
if (dsString == null) { | ||
return Collections.emptyList(); | ||
} | ||
return Utils.fromJson(dsString, new TypeReference<List<DatasetVersionId>>() {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.