use of com.yahoo.elide.datastores.aggregation.metadata.TableContext in project elide by yahoo.
the class JoinExpressionExtractor method constructTableOrSubselect.
/**
* Get the SELECT SQL or tableName for given entity.
* @param columnCtx {@link ColumnContext}.
* @param cls Entity class.
* @return resolved tableName or sql in Subselect/FromSubquery.
*/
private String constructTableOrSubselect(ColumnContext columnCtx, Type<?> cls) {
if (hasSql(cls)) {
// Resolve any table arguments with in FromSubquery or Subselect
TableContext context = TableContext.builder().tableArguments(columnCtx.getTableArguments()).build();
String selectSql = context.resolve(resolveTableOrSubselect(dictionary, cls));
return OPEN_BRACKET + selectSql + CLOSE_BRACKET;
}
return applyQuotes(resolveTableOrSubselect(dictionary, cls), columnCtx.getQueryable().getDialect());
}
use of com.yahoo.elide.datastores.aggregation.metadata.TableContext in project elide by yahoo.
the class QueryTranslator method visitQueryable.
@Override
public NativeQuery.NativeQueryBuilder visitQueryable(Queryable table) {
NativeQuery.NativeQueryBuilder builder = NativeQuery.builder();
Type<?> tableCls = dictionary.getEntityClass(table.getName(), table.getVersion());
String tableAlias = applyQuotes(table.getAlias());
TableContext context = TableContext.builder().tableArguments(clientQuery.getArguments()).build();
String tableStatement = tableCls.isAnnotationPresent(FromSubquery.class) ? "(" + context.resolve(tableCls.getAnnotation(FromSubquery.class).sql()) + ")" : tableCls.isAnnotationPresent(FromTable.class) ? applyQuotes(tableCls.getAnnotation(FromTable.class).name()) : applyQuotes(table.getName());
return builder.fromClause(getFromClause(tableStatement, tableAlias, dialect));
}
Aggregations