Package org.teiid.api.exception.query

Examples of org.teiid.api.exception.query.QueryProcessingException


            if(group.isImplicitTempGroupSymbol()) {
                columns = insert.getVariables();
            }
        }
        if (columns == null) {
          throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableStore.table_doesnt_exist_error", tempTableID)); //$NON-NLS-1$
        }
        Create create = new Create();
        create.setTable(new GroupSymbol(tempTableID));
        create.setElementSymbolsAsColumns(columns);
        return addTempTable(tempTableID, create, buffer, true);      
View Full Code Here


        }
      if (command instanceof Create) {
        Create create = (Create)command;
        String tempTableName = create.getTable().getCanonicalName();
        if (contextStore.hasTempTable(tempTableName)) {
                throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
            }
        contextStore.addTempTable(tempTableName, create, bufferManager, true);
            return CollectionTupleSource.createUpdateCountTupleSource(0)
      }
      if (command instanceof Drop) {
View Full Code Here

    } else if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEWROW)) {
      Object groupID = validateMatView(metadata, proc);
      Object pk = metadata.getPrimaryKey(groupID);
      String matViewName = metadata.getFullName(groupID);
      if (pk == null) {
        throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_pk", matViewName)); //$NON-NLS-1$
      }
      List<?> ids = metadata.getElementIDsInKey(pk);
      if (ids.size() > 1) {
        throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_composite", matViewName)); //$NON-NLS-1$
      }
      String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
      MatTableInfo info = globalStore.getMatTableInfo(matTableName);
      if (!info.isValid()) {
        return CollectionTupleSource.createUpdateCountTupleSource(-1);
      }
      TempTable tempTable = globalStore.getOrCreateTempTable(matTableName, new Query(), bufferManager, false);
      if (!tempTable.isUpdatable()) {
        throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.row_refresh_updatable", matViewName)); //$NON-NLS-1$
      }
      Constant key = (Constant)proc.getParameter(2).getExpression();
      LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryPlugin.Util.getString("TempTableDataManager.row_refresh", matViewName, key)); //$NON-NLS-1$
      String queryString = Reserved.SELECT + " * " + Reserved.FROM + ' ' + matViewName + ' ' + Reserved.WHERE + ' ' + //$NON-NLS-1$
        metadata.getFullName(ids.iterator().next()) + " = ?" + ' ' + Reserved.OPTION + ' ' + Reserved.NOCACHE; //$NON-NLS-1$
View Full Code Here

      TeiidProcessingException {
    String name = (String)((Constant)proc.getParameter(1).getExpression()).getValue();
    try {
      Object groupID = metadata.getGroupID(name);
      if (!metadata.hasMaterialization(groupID) || metadata.getMaterialization(groupID) != null) {
        throw new QueryProcessingException(QueryPlugin.Util.getString("TempTableDataManager.not_implicit_matview", name)); //$NON-NLS-1$
      }
      return groupID;
    } catch (QueryMetadataException e) {
      throw new TeiidProcessingException(e);
    }
View Full Code Here

    try {
      Object value = procEnv.evaluateExpression(dynamicCommand.getSql());

      if (value == null) {
        throw new QueryProcessingException(QueryPlugin.Util
            .getString("ExecDynamicSqlInstruction.0")); //$NON-NLS-1$
      }

      LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP,
          new Object[] { "Executing dynamic sql ", value }); //$NON-NLS-1$

      Command command = QueryParser.getQueryParser().parseCommand(value.toString());
      command.setExternalGroupContexts(dynamicCommand.getExternalGroupContexts());
      command.setTemporaryMetadata(dynamicCommand.getTemporaryMetadata());
      updateContextWithUsingValues(procEnv, localContext);
     
      Map tempMetadata = command.getTemporaryMetadata();
      final TempMetadataStore metadataStore = new TempMetadataStore(tempMetadata);
           
            if (dynamicCommand.getUsing() != null
                            && !dynamicCommand.getUsing().isEmpty()) {
                metadataStore.addTempGroup(Reserved.USING, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
                GroupSymbol using = new GroupSymbol(Reserved.USING);
                using.setMetadataID(metadataStore.getTempGroupID(Reserved.USING));
                command.addExternalGroupToContext(using);
                metadataStore.addTempGroup(ProcedureReservedWords.DVARS, new LinkedList(dynamicCommand.getUsing().getClauseMap().keySet()));
                using = new GroupSymbol(ProcedureReservedWords.DVARS);
                using.setMetadataID(metadataStore.getTempGroupID(ProcedureReservedWords.DVARS));
                command.addExternalGroupToContext(using);
            }

      // Resolve any groups
      if (parentProcCommand.isUpdateProcedure()) {
        ResolveVirtualGroupCriteriaVisitor.resolveCriteria(command,
            parentProcCommand.getVirtualGroup(), metadata);
      }

      QueryResolver.resolveCommand(command, metadata.getDesignTimeMetadata());

      validateDynamicCommand(procEnv, command);

      // create a new set of variables including vars
      Map<ElementSymbol, Expression> nameValueMap = createVariableValuesMap(localContext);
            nameValueMap.putAll(QueryResolver.getVariableValues(parentProcCommand.getUserCommand(), false, metadata));
            ValidationVisitor visitor = new ValidationVisitor();
            visitor.setUpdateProc(parentProcCommand);
            Request.validateWithVisitor(visitor, metadata, command);

            if (dynamicCommand.getAsColumns() != null
          && !dynamicCommand.getAsColumns().isEmpty()) {
            command = QueryRewriter.createInlineViewQuery(new GroupSymbol("X"), command, metadata, dynamicCommand.getAsColumns()); //$NON-NLS-1$
        if (dynamicCommand.getIntoGroup() != null) {
          Insert insert = new Insert(dynamicCommand.getIntoGroup(), dynamicCommand.getAsColumns(), Collections.emptyList());
          insert.setQueryExpression((Query)command);
          command = insert;
        }
      }
           
      command = QueryRewriter.rewrite(command, parentProcCommand, metadata,
          procEnv.getContext(), nameValueMap, parentProcCommand.getUserCommand().getType());

            ProcessorPlan commandPlan = QueryOptimizer.optimizePlan(command, metadata,
          idGenerator, capFinder, AnalysisRecord
              .createNonRecordingRecord(), procEnv
              .getContext());
           
      CreateCursorResultSetInstruction inst = new CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan, dynamicCommand.getIntoGroup() != null) {
        @Override
        public void process(ProcedurePlan procEnv)
            throws BlockedException, TeiidComponentException,
            TeiidProcessingException {
          super.process(procEnv);
          procEnv.getContext().popCall();
        }
      };

            dynamicProgram = new Program();
            dynamicProgram.addInstruction(inst);

            if (dynamicCommand.getIntoGroup() != null) {
                String groupName = dynamicCommand.getIntoGroup().getCanonicalName();
                if (!procEnv.getTempTableStore().getAllTempTables().contains(groupName)) {
                    procEnv.getTempContext().add(groupName);
                }
            }

            procEnv.push(dynamicProgram);
    } catch (TeiidProcessingException e) {
      Object[] params = {dynamicCommand, dynamicCommand.getSql(), e.getMessage()};
      throw new QueryProcessingException(e, QueryPlugin.Util.getString("ExecDynamicSqlInstruction.couldnt_execute", params)); //$NON-NLS-1$
    }
  }
View Full Code Here

    List dynamicExpectedColumns = dynamicCommand.getAsColumns();
    List<SingleElementSymbol> sourceProjectedSymbolList = command.getProjectedSymbols();

    if (dynamicExpectedColumns != null && !dynamicExpectedColumns.isEmpty()) {
      if (dynamicExpectedColumns.size() != sourceProjectedSymbolList.size()) {
        throw new QueryProcessingException(QueryPlugin.Util
            .getString("ExecDynamicSqlInstruction.4")); //$NON-NLS-1$
      }
      // If there is only one project symbol, we won't validate the name.

      Iterator dynamicIter = dynamicExpectedColumns.iterator();
      Iterator<SingleElementSymbol> sourceIter = sourceProjectedSymbolList.iterator();
      // Check for proper element name and datatype definition in the
      // dynamic SQL
      // If the projected symbol list equal to 1, we won't bother checking
      // the name.
      while (dynamicIter.hasNext()) {
        SingleElementSymbol dynamicSymbol = (SingleElementSymbol) dynamicIter.next();
        Class<?> sourceSymbolDatatype = sourceIter.next().getType();

        // Check if the the dynamic sql element types are equal or
        // implicitly convertible to the source types
        Class<?> dynamicType = dynamicSymbol.getType();
        String dynamicTypeName = DataTypeManager
            .getDataTypeName(dynamicType);
        String sourceTypeName = DataTypeManager
            .getDataTypeName(sourceSymbolDatatype);
        if (!dynamicTypeName.equals(sourceTypeName)
            && // If the types aren't the same, and...
            !DataTypeManager.isImplicitConversion(sourceTypeName,
                dynamicTypeName)) { // if there's no implicit
          // conversion between the
          // two
          Object[] params = new Object[] { sourceTypeName,
              dynamicSymbol.getShortName(),
              dynamicTypeName };
          throw new QueryProcessingException(QueryPlugin.Util
              .getString("ExecDynamicSqlInstruction.6", params)); //$NON-NLS-1$
        }
      }
    }
View Full Code Here

    public void pushCall(String value) throws QueryProcessingException {
        if (recursionStack == null) {
            recursionStack = new LinkedList<String>();
        } else if (recursionStack.contains(value)) {
      throw new QueryProcessingException(QueryPlugin.Util.getString("ExecDynamicSqlInstruction.3", value)); //$NON-NLS-1$
        }
       
        recursionStack.push(value);
    }
View Full Code Here

TOP

Related Classes of org.teiid.api.exception.query.QueryProcessingException

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.