Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.Command


    }
   
    @Test public void testStripAliases1() throws Exception {
      String sql = "select intkey as a, stringkey as b from BQT1.SmallA ORDER BY a, b"; //$NON-NLS-1$
        String expected = "SELECT BQT1.SmallA.intkey, BQT1.SmallA.stringkey FROM BQT1.SmallA ORDER BY BQT1.SmallA.intkey, BQT1.SmallA.stringkey"; //$NON-NLS-1$
        Command command = helpTest(sql, expected, false, true, FakeMetadataFactory.exampleBQTCached());
        LanguageBridgeFactory lbf = new LanguageBridgeFactory(FakeMetadataFactory.exampleBQTCached());
        org.teiid.language.Command c = lbf.translate(command);
        assertEquals("SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY SmallA.IntKey, SmallA.StringKey", c.toString());
    }
View Full Code Here


    throws QueryMetadataException, QueryResolverException, TeiidComponentException {
     
        // Resolve group so we can tell whether it is an update procedure
        GroupSymbol group = procCommand.getGroup();

        Command subCommand = null;
       
        String plan = getPlan(metadata, procCommand);
       
        if (plan == null) {
            return null;
View Full Code Here

              break;
            }
      case Statement.TYPE_COMMAND:
            {
        CommandStatement cmdStmt = (CommandStatement) statement;
                Command command = cmdStmt.getCommand();
        ProcessorPlan commandPlan = cmdStmt.getCommand().getProcessorPlan();               
               
        if (command.getType() == Command.TYPE_DYNAMIC){
          instruction = new ExecDynamicSqlInstruction(parentProcCommand,((DynamicCommand)command), metadata, idGenerator, capFinder );
        }else{
          instruction = new CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan,
              command.getType() == Command.TYPE_INSERT
              || command.getType() == Command.TYPE_UPDATE
              || command.getType() == Command.TYPE_DELETE);
          //handle stored procedure calls
          if (command.getType() == Command.TYPE_STORED_PROCEDURE) {
            StoredProcedure sp = (StoredProcedure)command;
            if (sp.isCallableStatement()) {
              Map<ElementSymbol, ElementSymbol> assignments = new LinkedHashMap<ElementSymbol, ElementSymbol>();
              for (SPParameter param : sp.getParameters()) {
                if (param.getParameterType() == SPParameter.RESULT_SET
View Full Code Here

            } else {
              results = getResults();
            }
            //check for update events
            if (index == 0 && this.dtm.detectChangeEvents()) {
              Command command = aqr.getCommand();
              int commandIndex = 0;
              if (RelationalNodeUtil.isUpdate(command)) {
                long ts = System.currentTimeMillis();
                checkForUpdates(results, command, dtm.getEventDistributor(), commandIndex, ts);
              } else if (command instanceof BatchedUpdateCommand) {
View Full Code Here

  private void updateCacheHint(Object viewId,
      QueryMetadataInterface metadata, GroupSymbol group,
      TempMetadataID id) throws TeiidComponentException,
      QueryMetadataException, QueryResolverException,
      QueryValidatorException {
    Command c = QueryResolver.resolveView(group, metadata.getVirtualPlan(viewId), SQLConstants.Reserved.SELECT, metadata).getCommand();
    CacheHint hint = c.getCacheHint();
    id.setCacheHint(hint);
  }
View Full Code Here

      QueryCommand queryCommand = (QueryCommand)command;
      final HashSet<String> names = new HashSet<String>();
      if (queryCommand.getWith() != null) {
            withList = queryCommand.getWith();
            for (WithQueryCommand with : queryCommand.getWith()) {
              Command subCommand = with.getCommand();
                  ProcessorPlan procPlan = QueryOptimizer.optimizePlan(subCommand, metadata, idGenerator, capFinder, analysisRecord, context);
                  subCommand.setProcessorPlan(procPlan);
                  QueryCommand withCommand = CriteriaCapabilityValidatorVisitor.getQueryCommand(procPlan);
                  if (withCommand != null && supportsWithPushdown) {
                    modelID = CriteriaCapabilityValidatorVisitor.validateCommandPushdown(modelID, metadata, capFinder, withCommand);
                }
                  if (modelID == null) {
View Full Code Here

     * @return New Command object
     * @throws QueryPlannerException If an error occurred
     * @since 4.3
     */
    static Command getQuery(String groupName, QueryNode queryNode, XMLPlannerEnvironment env) throws QueryPlannerException {
        Command query = queryNode.getCommand();
       
        if (query == null) {
            try {
                query = QueryParser.getQueryParser().parseCommand(queryNode.getQuery());
                QueryResolver.resolveWithBindingMetadata(query, env.getGlobalMetadata().getDesignTimeMetadata(), queryNode, true);
View Full Code Here

       
    static Command getQueryFromQueryNode(String groupName, XMLPlannerEnvironment planEnv)
        throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
       
        QueryNode queryNode = QueryUtil.getQueryNode(groupName, planEnv.getGlobalMetadata());
        Command command = QueryUtil.getQuery(groupName, queryNode, planEnv);
        return command;
    }    
View Full Code Here

            if (node.getType() == NodeConstants.Types.JOIN) {
              localGroupSymbols = getGroupSymbols(node);
            }
            for (SubqueryContainer container : subqueryContainers) {
                //a clone is needed here because the command could get modified during planning
                Command subCommand = (Command)container.getCommand().clone();
                ArrayList<Reference> correlatedReferences = new ArrayList<Reference>();
                CorrelatedReferenceCollectorVisitor.collectReferences(subCommand, localGroupSymbols, correlatedReferences);
                ProcessorPlan procPlan = QueryOptimizer.optimizePlan(subCommand, metadata, idGenerator, capFinder, analysisRecord, context);
                container.getCommand().setProcessorPlan(procPlan);
                if (!correlatedReferences.isEmpty()) {
View Full Code Here

      if (sp.getProcedureID() instanceof Procedure) {
        context.accessedPlanningObject(sp.getProcedureID());
      }
    }
    String cacheString = "transformation/" + container.getClass().getSimpleName().toUpperCase(); //$NON-NLS-1$
    Command c = (Command)metadata.getFromMetadataCache(metadataId, cacheString);
    if (c == null) {
      c = QueryResolver.expandCommand(container, metadata, analysisRecord);
      if (c != null) {
            Request.validateWithVisitor(new ValidationVisitor(), metadata, c);
            metadata.addToMetadataCache(metadataId, cacheString, c.clone());
      }
    } else {
      c = (Command)c.clone();
      if (c instanceof CreateUpdateProcedureCommand) {
        ((CreateUpdateProcedureCommand)c).setUserCommand(container);
      }
    }
    if (c != null) {
      if (c instanceof TriggerAction) {
        TriggerAction ta = (TriggerAction)c;
        ProcessorPlan plan = new TriggerActionPlanner().optimize(container, ta, idGenerator, metadata, capFinder, analysisRecord, context);
          sourceNode.setProperty(NodeConstants.Info.PROCESSOR_PLAN, plan);
          return true;
      }
      if (c.getCacheHint() != null) {
        if (container instanceof StoredProcedure) {
          boolean noCache = isNoCacheGroup(metadata, ((StoredProcedure) container).getProcedureID(), option);
          if (!noCache) {
            if (context.isResultSetCacheEnabled() && container.areResultsCachable() && LobManager.getLobIndexes(new ArrayList<ElementSymbol>(container.getProcedureParameters().keySet())) == null) {
              container.getGroup().setGlobalTable(true);
              container.setCacheHint(c.getCacheHint());
              recordAnnotation(analysisRecord, Annotation.CACHED_PROCEDURE, Priority.LOW, "SimpleQueryResolver.procedure_cache_used", container.getGroup()); //$NON-NLS-1$
              return false;
            }
            recordAnnotation(analysisRecord, Annotation.CACHED_PROCEDURE, Priority.MEDIUM, "SimpleQueryResolver.procedure_cache_not_usable", container.getGroup()); //$NON-NLS-1$
          } else {
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.