kfaraz commented on code in PR #12404:
URL: https://github.com/apache/druid/pull/12404#discussion_r898699077
##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataStorageActionHandler.java:
##########
@@ -571,43 +567,43 @@ private String
getWhereClauseForActiveStatusesQuery(String dataSource)
return sql;
}
- class TaskMetadataInfoMapperFromPayload implements
ResultSetMapper<TaskInfo<TaskMetadata, StatusType>>
+ private class TaskStatusMapperFromPayload implements
ResultSetMapper<TaskInfo<TaskIdentifier, StatusType>>
{
private final ObjectMapper objectMapper;
- TaskMetadataInfoMapperFromPayload(ObjectMapper objectMapper)
+ TaskStatusMapperFromPayload(ObjectMapper objectMapper)
{
this.objectMapper = objectMapper;
}
@Override
- public TaskInfo<TaskMetadata, StatusType> map(int index, ResultSet
resultSet, StatementContext context)
+ public TaskInfo<TaskIdentifier, StatusType> map(int index, ResultSet
resultSet, StatementContext context)
throws SQLException
{
- return toTaskMetadataInfo(objectMapper, resultSet, true);
+ return toTaskIdentifierInfo(objectMapper, resultSet, true);
}
}
- class TaskMetadataInfoMapper implements
ResultSetMapper<TaskInfo<TaskMetadata, StatusType>>
+ private class TaskStatusMapper implements
ResultSetMapper<TaskInfo<TaskIdentifier, StatusType>>
{
private final ObjectMapper objectMapper;
- TaskMetadataInfoMapper(ObjectMapper objectMapper)
+ TaskStatusMapper(ObjectMapper objectMapper)
{
this.objectMapper = objectMapper;
}
@Override
- public TaskInfo<TaskMetadata, StatusType> map(int index, ResultSet
resultSet, StatementContext context)
+ public TaskInfo<TaskIdentifier, StatusType> map(int index, ResultSet
resultSet, StatementContext context)
throws SQLException
{
- return toTaskMetadataInfo(objectMapper, resultSet, false);
+ return toTaskIdentifierInfo(objectMapper, resultSet, false);
}
}
- private TaskInfo<TaskMetadata, StatusType> toTaskMetadataInfo(ObjectMapper
objectMapper,
-
ResultSet resultSet,
- boolean
usePayload
+ private TaskInfo<TaskIdentifier, StatusType>
toTaskIdentifierInfo(ObjectMapper objectMapper,
Review Comment:
Nit: start the args in a newline as they are not going to fit in the same
line anyway.
##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -327,6 +331,29 @@ tableName, getPayloadType()
)
);
}
+
+ public boolean tableContainsColumn(Handle handle, String table, String
column)
Review Comment:
Still seems to be public.
##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java:
##########
@@ -241,4 +243,20 @@ default <ContextValueType> ContextValueType
getContextValue(String key, ContextV
final ContextValueType value = getContextValue(key);
return value == null ? defaultValue : value;
}
+
+ default TaskIdentifier getMetadata()
Review Comment:
Nit: Rename to `getTaskIdentifier`.
##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -350,6 +377,43 @@ tableName, getPayloadType(), getCollation()
);
}
+ public void alterEntryTable(final String tableName)
+ {
+ try {
+ retryWithHandle(
+ new HandleCallback<Void>()
+ {
+ @Override
+ public Void withHandle(Handle handle)
+ {
+ final Batch batch = handle.createBatch();
+ if (!tableContainsColumn(handle, tableName, "type")) {
+ log.info("Adding column: type to table[%s]", tableName);
+ batch.add(StringUtils.format("ALTER TABLE %1$s ADD COLUMN type
VARCHAR(255)", tableName));
+ }
+ if (!tableContainsColumn(handle, tableName, "group_id")) {
+ log.info("Adding column: group_id to table[%s]", tableName);
+ batch.add(StringUtils.format("ALTER TABLE %1$s ADD COLUMN
group_id VARCHAR(255)", tableName));
+ }
+ batch.execute();
Review Comment:
In this case, it seems to be.
```
public int[] execute()
{
// short circuit empty batch
if (parts.size() == 0) {
return new int[] {};
}
...
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]