Search in sources :

Example 1 with ColumnMetadata

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();
}
Also used : ColumnMetadata(org.hypertrace.entity.query.service.v1.ColumnMetadata) Value(org.hypertrace.entity.query.service.v1.Value) Row(org.hypertrace.entity.query.service.v1.Row)

Example 2 with ColumnMetadata

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();
}
Also used : ConversionException(org.hypertrace.entity.query.service.converter.ConversionException) Function(org.hypertrace.entity.query.service.v1.Function) ColumnMetadata(org.hypertrace.entity.query.service.v1.ColumnMetadata) RelationalExpression(org.hypertrace.core.documentstore.expression.impl.RelationalExpression) ConstantExpression(org.hypertrace.core.documentstore.expression.impl.ConstantExpression) IdentifierExpression(org.hypertrace.core.documentstore.expression.impl.IdentifierExpression) Expression(org.hypertrace.entity.query.service.v1.Expression) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) ColumnIdentifier(org.hypertrace.entity.query.service.v1.ColumnIdentifier)

Aggregations

ColumnMetadata (org.hypertrace.entity.query.service.v1.ColumnMetadata)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 ConstantExpression (org.hypertrace.core.documentstore.expression.impl.ConstantExpression)1 IdentifierExpression (org.hypertrace.core.documentstore.expression.impl.IdentifierExpression)1 RelationalExpression (org.hypertrace.core.documentstore.expression.impl.RelationalExpression)1 ConversionException (org.hypertrace.entity.query.service.converter.ConversionException)1 ColumnIdentifier (org.hypertrace.entity.query.service.v1.ColumnIdentifier)1 Expression (org.hypertrace.entity.query.service.v1.Expression)1 Function (org.hypertrace.entity.query.service.v1.Function)1 Row (org.hypertrace.entity.query.service.v1.Row)1 Value (org.hypertrace.entity.query.service.v1.Value)1