Search in sources :

Example 6 with LanguageVisitor

use of org.teiid.query.sql.LanguageVisitor in project teiid by teiid.

the class QueryRewriter method removeAlias.

/**
 * For backwards compatibility we strip the alias from delete/update
 * @param command
 * @param group
 */
private void removeAlias(ProcedureContainer command, GroupSymbol group) {
    AliasGenerator ag = new AliasGenerator(true);
    ag.setCorrelationGroups(Arrays.asList(group.getDefinition()));
    command.acceptVisitor(ag);
    final GroupSymbol clone = group.clone();
    DeepPostOrderNavigator.doVisit(command, new LanguageVisitor() {

        public void visit(GroupSymbol obj) {
            if (obj.equals(clone) && obj.getMetadataID() == group.getMetadataID()) {
                obj.setName(obj.getDefinition());
                obj.setDefinition(null);
            }
        }
    });
}
Also used : LanguageVisitor(org.teiid.query.sql.LanguageVisitor) AliasGenerator(org.teiid.query.optimizer.relational.AliasGenerator)

Aggregations

LanguageVisitor (org.teiid.query.sql.LanguageVisitor)6 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)1 TeiidComponentException (org.teiid.core.TeiidComponentException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1 FunctionDescriptor (org.teiid.query.function.FunctionDescriptor)1 AliasGenerator (org.teiid.query.optimizer.relational.AliasGenerator)1 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)1 LanguageObject (org.teiid.query.sql.LanguageObject)1 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)1 Criteria (org.teiid.query.sql.lang.Criteria)1 DependentSetCriteria (org.teiid.query.sql.lang.DependentSetCriteria)1 AttributeComparison (org.teiid.query.sql.lang.DependentSetCriteria.AttributeComparison)1 IsNullCriteria (org.teiid.query.sql.lang.IsNullCriteria)1 SetCriteria (org.teiid.query.sql.lang.SetCriteria)1