use of org.hypertrace.entity.query.service.v1.ColumnMetadata in project entity-service by hypertrace.
the class DocumentConverterImpl method buildRow.
private Row buildRow(final ResultSetMetadata resultSetMetadata, final Map<String, Value> valueMap) {
final Row.Builder builder = Row.newBuilder();
final Value defaultValue = getNullPlaceholderValue();
for (final ColumnMetadata columnMetadata : resultSetMetadata.getColumnMetadataList()) {
final Value value = valueMap.getOrDefault(columnMetadata.getColumnName(), defaultValue);
builder.addColumn(value);
}
return builder.build();
}
use of org.hypertrace.entity.query.service.v1.ColumnMetadata in project entity-service by hypertrace.
the class EntityQueryServiceImpl method buildMetadataForSelections.
private ResultSetMetadata buildMetadataForSelections(List<Expression> selections) throws ConversionException {
final AliasProvider<ColumnIdentifier> identifierAliasProvider = getIdentifierAliasProvider();
final AliasProvider<Function> aggregateExpressionAliasProvider = getAggregateExpressionAliasProvider();
final List<ColumnMetadata> list = new ArrayList<>();
for (final Expression selection : selections) {
final String columnName;
if (selection.hasFunction()) {
columnName = aggregateExpressionAliasProvider.getAlias(selection.getFunction());
} else if (selection.hasColumnIdentifier()) {
columnName = identifierAliasProvider.getAlias(selection.getColumnIdentifier());
} else {
throw new ConversionException(String.format("Selection of non-identifier and non-aggregation is not supported. Found: %s", selection));
}
ColumnMetadata build = ColumnMetadata.newBuilder().setColumnName(columnName).build();
list.add(build);
}
return ResultSetMetadata.newBuilder().addAllColumnMetadata(list).build();
}
Aggregations