Examples of QueryResolverException


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

                        || (sourceExpression instanceof Constant && convertConstant(sourceTypeName, targetTypeName, (Constant)sourceExpression) != null)) {
            return getConversion(sourceExpression, sourceTypeName, targetTypeName, true, metadata.getFunctionLibrary());
        }

        //Expression is wrong type and can't convert
        throw new QueryResolverException("ERR.015.008.0041", QueryPlugin.Util.getString("ERR.015.008.0041", new Object[] {targetTypeName, sourceExpression, sourceTypeName})); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

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

    public static void setDesiredType(Expression expression, Class<?> targetType, LanguageObject surroundingExpression) throws QueryResolverException {
        if (expression instanceof Reference) {
          Reference ref = (Reference)expression;
          if (ref.isPositional() && ref.getType() == null) {
            if (targetType == null) {
              throw new QueryResolverException("ERR.015.008.0026", QueryPlugin.Util.getString("ERR.015.008.0026", surroundingExpression)); //$NON-NLS-1$ //$NON-NLS-2$
            }
              ref.setType(targetType);
          }
        } else if (expression instanceof Function) {
          Function f = (Function)expression;
View Full Code Here

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

                continue;
              }
                  // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
                  if(matchedSymbol != null) {
                    if (!matchedSymbol.equals(knownElements.get(j))) {
                      throw new QueryResolverException("ERR.015.008.0042", QueryPlugin.Util.getString("ERR.015.008.0042", symbolName)); //$NON-NLS-1$ //$NON-NLS-2$
                    }
                    continue;
                  }
                  matchedSymbol = knownElements.get(j);
                  position = j;
            }
            if (matchedSymbol != null) {
                TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
                symbol.setMetadataID(tempMetadataID);
                symbol.setType(matchedSymbol.getType());
            }
                    if (position != -1) {
                        orderBy.setExpressionPosition(i, position);
                        continue;
                    }
            }
          } else if (sortKey instanceof ExpressionSymbol) {
            // check for legacy positional
          ExpressionSymbol es = (ExpressionSymbol)sortKey;
            if (es.getExpression() instanceof Constant) {
                Constant c = (Constant)es.getExpression();
                int elementOrder = Integer.valueOf(c.getValue().toString()).intValue();
                // adjust for the 1 based index.
                if (elementOrder > knownElements.size() || elementOrder < 1) {
                    throw new QueryResolverException(QueryPlugin.Util.getString("SQLParser.non_position_constant", c)); //$NON-NLS-1$
                }
                orderBy.setExpressionPosition(i, elementOrder - 1);
                continue;
            }
          }
          //handle order by expressions         
          if (command instanceof SetQuery) {
          throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.setquery_order_expression", sortKey)); //$NON-NLS-1$  
        }
          for (ElementSymbol symbol : ElementCollectorVisitor.getElements(sortKey, false)) {
            try {
                ResolverVisitor.resolveLanguageObject(symbol, fromClauseGroups, command.getExternalGroupContexts(), metadata);
              } catch(QueryResolverException e) {
                throw new QueryResolverException(e, "ERR.015.008.0043", QueryPlugin.Util.getString("ERR.015.008.0043", symbol.getName()) );//$NON-NLS-1$ //$NON-NLS-2$
              }
      }
            ResolverVisitor.resolveLanguageObject(sortKey, metadata);
           
            int index = expressions.indexOf(SymbolMap.getExpression(sortKey));
            if (index == -1 && !isSimpleQuery) {
              throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.invalid_unrelated", sortKey)); //$NON-NLS-1$
          }
          orderBy.setExpressionPosition(i, index);
        }
    }
View Full Code Here

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

      Class<?> type = symbol.getType();
   
        Object defaultValue = metadata.getDefaultValue(mid);
       
        if (defaultValue == null && !metadata.elementSupports(mid, SupportConstants.Element.NULL)) {
            throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.required_param", symbol.getOutputName())); //$NON-NLS-1$
        }
       
        return getProperlyTypedConstant(defaultValue, type);
  }   
View Full Code Here

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

    throws QueryResolverException{
        try {
            Object newValue = DataTypeManager.transformValue(defaultValue, parameterType);
            return new Constant(newValue, parameterType);
        } catch (TransformationException e) {
            throw new QueryResolverException(e, QueryPlugin.Util.getString("ResolverUtil.error_converting_value_type", defaultValue, defaultValue.getClass(), parameterType)); //$NON-NLS-1$
        }
    }
View Full Code Here

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

                                    GroupSymbol symbol,
                                    List<? extends SingleElementSymbol> symbols, boolean tempTable) throws QueryResolverException {
        HashSet<String> names = new HashSet<String>();
        for (SingleElementSymbol ses : symbols) {
            if (!names.add(ses.getShortCanonicalName())) {
                throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.duplicateName", symbol, ses.getShortName())); //$NON-NLS-1$
            }
        }
       
        if (tempTable) {
            resolveNullLiterals(symbols);
View Full Code Here

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

 
    // Check that type of the expression is same as the type of the
    // single projected symbol of the subquery
    Class exprType = expression.getType();
    if(exprType == null) {
          throw new QueryResolverException("ERR.015.008.0030", QueryPlugin.Util.getString("ERR.015.008.0030", expression)); //$NON-NLS-1$ //$NON-NLS-2$
    }
    String exprTypeName = DataTypeManager.getDataTypeName(exprType);
 
    Collection<SingleElementSymbol> projectedSymbols = crit.getCommand().getProjectedSymbols();
    if (projectedSymbols.size() != 1){
          throw new QueryResolverException("ERR.015.008.0032", QueryPlugin.Util.getString("ERR.015.008.0032", crit.getCommand())); //$NON-NLS-1$ //$NON-NLS-2$
    }
    Class<?> subqueryType = projectedSymbols.iterator().next().getType();
    String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
    Expression result = null;
      try {
          result = convertExpression(expression, exprTypeName, subqueryTypeName, metadata);
      } catch (QueryResolverException qre) {
          throw new QueryResolverException(qre, "ERR.015.008.0033", QueryPlugin.Util.getString("ERR.015.008.0033", crit)); //$NON-NLS-1$ //$NON-NLS-2$
      }
      return result;
  }
View Full Code Here

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

  public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, TeiidComponentException {
    Expression[] args = lookup.getArgs();
    ResolvedLookup result = new ResolvedLookup();
      // Special code to handle setting return type of the lookup function to match the type of the return element
      if( !(args[0] instanceof Constant) || !(args[1] instanceof Constant) || !(args[2] instanceof Constant)) {
        throw new QueryResolverException("ERR.015.008.0063", QueryPlugin.Util.getString("ERR.015.008.0063")); //$NON-NLS-1$ //$NON-NLS-2$
      }
        // If code table name in lookup function refers to temp group throw exception
    GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
    try {
      groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
      if (groupSym.getMetadataID() instanceof TempMetadataID) {
        throw new QueryResolverException("ERR.015.008.0065", QueryPlugin.Util.getString("ERR.015.008.0065", ((Constant)args[0]).getValue())); //$NON-NLS-1$ //$NON-NLS-2$
      }
    } catch(QueryMetadataException e) {
      throw new QueryResolverException("ERR.015.008.0062", QueryPlugin.Util.getString("ERR.015.008.0062", ((Constant)args[0]).getValue())); //$NON-NLS-1$ //$NON-NLS-2$
    }
    result.setGroup(groupSym);
   
    List<GroupSymbol> groups = Arrays.asList(groupSym);
   
    String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
    ElementSymbol returnElement = new ElementSymbol(returnElementName);
        try {
            ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
        } catch(QueryMetadataException e) {
            throw new QueryResolverException("ERR.015.008.0062", QueryPlugin.Util.getString("ERR.015.008.0062", returnElementName)); //$NON-NLS-1$ //$NON-NLS-2$
        }
    result.setReturnElement(returnElement);
       
        String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
        ElementSymbol keyElement = new ElementSymbol(keyElementName);
        try {
            ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
        } catch(QueryMetadataException e) {
            throw new QueryResolverException("ERR.015.008.0062", QueryPlugin.Util.getString("ERR.015.008.0062", keyElementName)); //$NON-NLS-1$ //$NON-NLS-2$
        }
    result.setKeyElement(keyElement);
    args[3] = convertExpression(args[3], DataTypeManager.getDataTypeName(keyElement.getType()), metadata);
    return result;
  }
View Full Code Here

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

    return result;
  }

  private static QueryResolverException handleUnresolvedGroup(GroupSymbol symbol, String description) {
    UnresolvedSymbolDescription usd = new UnresolvedSymbolDescription(symbol.toString(), description);
      QueryResolverException e = new QueryResolverException(usd.getDescription()+": "+usd.getSymbol()); //$NON-NLS-1$
      e.setUnresolvedSymbols(Arrays.asList(usd));
      return e;
  }
View Full Code Here

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

       
        String sqlType = DataTypeManager.getDataTypeName(dynamicCmd.getSql().getType());
        String targetType = DataTypeManager.DefaultDataTypes.STRING;
       
        if (!targetType.equals(sqlType) && !DataTypeManager.isImplicitConversion(sqlType, targetType)) {
            throw new QueryResolverException(QueryPlugin.Util.getString("DynamicCommandResolver.SQL_String", sqlType)); //$NON-NLS-1$
        }
       
        if (dynamicCmd.getUsing() != null && !dynamicCmd.getUsing().isEmpty()) {
            for (SetClause clause : dynamicCmd.getUsing().getClauses()) {
                ElementSymbol id = clause.getSymbol();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.