throws QueryMetadataException, TeiidComponentException, QueryResolverException, QueryValidatorException {
String matViewName = metadata.getFullName(viewId);
String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
GroupSymbol group = new GroupSymbol(matViewName);
group.setMetadataID(viewId);
TempMetadataID id = tempMetadataStore.getTempGroupID(matTableName);
//define the table preserving the key/index information and ensure that only a single instance exists
if (id == null) {
synchronized (viewId) {
id = tempMetadataStore.getTempGroupID(matTableName);
if (id == null) {
id = tempMetadataStore.addTempGroup(matTableName, ResolverUtil.resolveElementsInGroup(group, metadata), false, true);
id.setQueryNode(metadata.getVirtualPlan(viewId));
id.setCardinality(metadata.getCardinality(viewId));
Object pk = metadata.getPrimaryKey(viewId);
if (pk != null) {
ArrayList<TempMetadataID> primaryKey = resolveIndex(metadata, id, pk);
id.setPrimaryKey(primaryKey);
}
Collection keys = metadata.getUniqueKeysInGroup(viewId);
for (Object key : keys) {
id.addUniqueKey(resolveIndex(metadata, id, key));
}
Collection indexes = metadata.getIndexesInGroup(viewId);
for (Object index : indexes) {
id.addIndex(resolveIndex(metadata, id, index));
}
}
}
}
updateCacheHint(viewId, metadata, group, id);