use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class LanguageBridgeFactory method translate.
public NamedTable translate(GroupSymbol symbol) {
String alias = null;
String fullGroup = symbol.getOutputName();
if (symbol.getOutputDefinition() != null) {
alias = symbol.getOutputName();
fullGroup = symbol.getOutputDefinition();
if (remappedGroups != null) {
GroupSymbol remappedGroup = remappedGroups.get(symbol.getMetadataID());
if (remappedGroup != null && remappedGroup != symbol) {
fullGroup = remappedGroup.getName();
}
}
}
fullGroup = removeSchemaName(fullGroup);
NamedTable group = new NamedTable(fullGroup, alias, null);
try {
group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
} catch (QueryMetadataException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30487, e);
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30488, e);
}
return group;
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class AuthorizationValidationVisitor method validateEntitlements.
/**
* Validate query entitlements
*/
protected void validateEntitlements(Query obj) {
// If query contains SELECT INTO, validate INTO portion
Into intoObj = obj.getInto();
if (intoObj != null) {
GroupSymbol intoGroup = intoObj.getGroup();
Collection<LanguageObject> intoElements = new LinkedList<LanguageObject>();
intoElements.add(intoGroup);
try {
intoElements.addAll(ResolverUtil.resolveElementsInGroup(intoGroup, getMetadata()));
} catch (QueryMetadataException err) {
handleException(err, intoGroup);
} catch (TeiidComponentException err) {
handleException(err, intoGroup);
}
validateEntitlements(intoElements, DataPolicy.PermissionType.CREATE, Context.INSERT);
}
// Validate this query's entitlements
Collection<LanguageObject> entitledObjects = new ArrayList<LanguageObject>(GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj, true));
entitledObjects.addAll(ElementCollectorVisitor.getElements(obj, true));
if (entitledObjects.size() == 0) {
return;
}
validateEntitlements(entitledObjects, DataPolicy.PermissionType.READ, Context.QUERY);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class AuthorizationValidationVisitor method addToNameMap.
static void addToNameMap(Object metadataID, LanguageObject symbol, Map<String, LanguageObject> nameToSymbolMap, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
String fullName = metadata.getFullName(metadataID);
Object modelId = metadata.getModelID(metadataID);
String modelName = metadata.getFullName(modelId);
if (!isSystemSchema(modelName)) {
// foreign temp table full names are not schema qualified by default
if (!metadata.isVirtualModel(modelId)) {
GroupSymbol group = null;
if (symbol instanceof ElementSymbol) {
group = ((ElementSymbol) symbol).getGroupSymbol();
} else if (symbol instanceof GroupSymbol) {
group = (GroupSymbol) symbol;
}
if (group != null && group.isTempGroupSymbol() && !group.isGlobalTable()) {
fullName = modelName + AbstractMetadataRecord.NAME_DELIM_CHAR + modelId;
}
}
nameToSymbolMap.put(fullName, symbol);
}
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class CachingTupleSource method nextTuple.
@Override
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
if (dtts.scope == Scope.NONE || tb == null) {
removeTupleBuffer();
return ts.nextTuple();
}
// TODO: the cache directive object needs synchronized for consistency
List<?> tuple = super.nextTuple();
if (tuple == null && !dtts.errored) {
synchronized (cd) {
if (dtts.scope == Scope.NONE) {
removeTupleBuffer();
return tuple;
}
CachedResults cr = new CachedResults();
cr.setResults(tb, null);
if (!Boolean.FALSE.equals(cd.getUpdatable())) {
if (accessedGroups != null) {
for (GroupSymbol gs : accessedGroups) {
cr.getAccessInfo().addAccessedObject(gs.getMetadataID());
}
}
} else {
cr.getAccessInfo().setSensitiveToMetadataChanges(false);
}
if (parameterObject.limit > 0 && parameterObject.limit == rowNumber) {
cr.setRowLimit(rowNumber);
}
tb.setPrefersMemory(Boolean.TRUE.equals(cd.getPrefersMemory()));
Determinism determinismLevel = getDeterminismLevel(this.dtts.scope);
this.dataTierManagerImpl.requestMgr.getRsCache().put(cid, determinismLevel, cr, cd.getTtl());
tb = null;
}
}
return tuple;
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestResolver method test11716.
@Test
public void test11716() throws Exception {
// $NON-NLS-1$
String sql = "SELECT e1 FROM pm1.g1 where e1='1'";
Map externalMetadata = new HashMap();
// $NON-NLS-1$
GroupSymbol inputSet = new GroupSymbol("INPUT");
List inputSetElements = new ArrayList();
// $NON-NLS-1$
ElementSymbol inputSetElement = new ElementSymbol("INPUT.e1");
inputSetElements.add(inputSetElement);
externalMetadata.put(inputSet, inputSetElements);
Query command = (Query) helpParse(sql);
QueryResolver.resolveCommand(command, metadata);
Collection groups = GroupCollectorVisitor.getGroups(command, false);
assertFalse(groups.contains(inputSet));
}
Aggregations