Search in sources :

Example 46 with GroupSymbol

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;
}
Also used : GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) TeiidComponentException(org.teiid.core.TeiidComponentException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException)

Example 47 with GroupSymbol

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);
}
Also used : GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException) LanguageObject(org.teiid.query.sql.LanguageObject)

Example 48 with GroupSymbol

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);
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) LanguageObject(org.teiid.query.sql.LanguageObject)

Example 49 with GroupSymbol

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;
}
Also used : Determinism(org.teiid.metadata.FunctionMethod.Determinism) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol)

Example 50 with GroupSymbol

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));
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) XMLQuery(org.teiid.query.sql.symbol.XMLQuery) HashMap(java.util.HashMap) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) SymbolMap(org.teiid.query.sql.util.SymbolMap) Test(org.junit.Test)

Aggregations

GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)299 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)146 Test (org.junit.Test)108 ArrayList (java.util.ArrayList)92 MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)59 Expression (org.teiid.query.sql.symbol.Expression)52 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)50 Constant (org.teiid.query.sql.symbol.Constant)48 List (java.util.List)43 HashSet (java.util.HashSet)32 Query (org.teiid.query.sql.lang.Query)31 From (org.teiid.query.sql.lang.From)29 SymbolMap (org.teiid.query.sql.util.SymbolMap)29 Select (org.teiid.query.sql.lang.Select)26 Criteria (org.teiid.query.sql.lang.Criteria)22 TempMetadataID (org.teiid.query.metadata.TempMetadataID)21 LinkedList (java.util.LinkedList)20 Command (org.teiid.query.sql.lang.Command)20 Set (java.util.Set)17 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)17