Package org.teiid.api.exception.query

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


      Class[] types = new Class[args.length];
      for(int i=0; i<args.length; i++) {
          types[i] = args[i].getType();
          if(types[i] == null) {
            if(!(args[i] instanceof Reference)){
                  throw new QueryResolverException("ERR.015.008.0035", QueryPlugin.Util.getString("ERR.015.008.0035", new Object[] {args[i], function})); //$NON-NLS-1$ //$NON-NLS-2$
            }
              hasArgWithoutType = true;
          }
      }
 
      //special case handling for convert of an untyped reference
      if (FunctionLibrary.isConvert(function) && hasArgWithoutType) {
          Constant constant = (Constant)function.getArg(1);
          Class<?> type = DataTypeManager.getDataTypeClass((String)constant.getValue());
 
          setDesiredType(function.getArg(0), type, function);
          types[0] = type;
          hasArgWithoutType = false;
      }
 
      // Attempt to get exact match of function for this signature
      FunctionDescriptor fd = findWithImplicitConversions(library, function, args, types, hasArgWithoutType);
     
      // Function did not resolve - determine reason and throw exception
      if(fd == null) {
          FunctionForm form = library.findFunctionForm(function.getName(), args.length);
          if(form == null) {
              // Unknown function form
              throw new QueryResolverException("ERR.015.008.0039", QueryPlugin.Util.getString("ERR.015.008.0039", function)); //$NON-NLS-1$ //$NON-NLS-2$
          }
          // Known function form - but without type information
          if (hasArgWithoutType) {
              throw new QueryResolverException("ERR.015.008.0036", QueryPlugin.Util.getString("ERR.015.008.0036", function)); //$NON-NLS-1$ //$NON-NLS-2$
          }
          // Known function form - unable to find implicit conversions
          throw new QueryResolverException("ERR.015.008.0040", QueryPlugin.Util.getString("ERR.015.008.0040", function)); //$NON-NLS-1$ //$NON-NLS-2$
      }
     
      if(fd.getName().equalsIgnoreCase(FunctionLibrary.CONVERT) || fd.getName().equalsIgnoreCase(FunctionLibrary.CAST)) {
          String dataType = (String) ((Constant)args[1]).getValue();
          Class dataTypeClass = DataTypeManager.getDataTypeClass(dataType);
          fd = library.findTypedConversionFunction(args[0].getType(), dataTypeClass);
 
          // Verify that the type conversion from src to type is even valid
          Class srcTypeClass = args[0].getType();
          if(srcTypeClass != null && dataTypeClass != null &&
             !srcTypeClass.equals(dataTypeClass) &&
             !DataTypeManager.isTransformable(srcTypeClass, dataTypeClass)) {
 
              throw new QueryResolverException("ERR.015.008.0037", QueryPlugin.Util.getString("ERR.015.008.0037", new Object[] {DataTypeManager.getDataTypeName(srcTypeClass), dataType})); //$NON-NLS-1$ //$NON-NLS-2$
          }
      } else if(fd.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
      ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(function, metadata);
      fd = library.copyFunctionChangeReturnType(fd, lookup.getReturnElement().getType());
      }
View Full Code Here


            Create create = (Create)command;
            GroupSymbol group = create.getTable();
           
            //assuming that all temp table creates are local, the user must use a local name
            if (group.getName().indexOf(ElementSymbol.SEPARATOR) != -1) {
                throw new QueryResolverException(QueryPlugin.Util.getString("TempTableResolver.unqualified_name_required", group.getName())); //$NON-NLS-1$
            }

            //this will only check non-temp groups
            Collection exitsingGroups = metadata.getMetadata().getGroupsForPartialName(group.getName());
            if(!exitsingGroups.isEmpty()) {
                throw new QueryResolverException(QueryPlugin.Util.getString("TempTableResolver.table_already_exists", group.getName())); //$NON-NLS-1$
            }
          if (metadata.getMetadata().hasProcedure(group.getName())) {
            throw new QueryResolverException(QueryPlugin.Util.getString("TempTableResolver.table_already_exists", group.getName())); //$NON-NLS-1$
          }
           
            //now we will be more specific for temp groups
            TempMetadataID id = metadata.getMetadataStore().getTempGroupID(group.getName());
            if (id != null && !metadata.isTemporaryTable(id)) {
                throw new QueryResolverException(QueryPlugin.Util.getString("TempTableResolver.table_already_exists", group.getName())); //$NON-NLS-1$       
            }
            //if we get here then either the group does not exist or has already been defined as a temp table
            //if it has been defined as a temp table, that's ok we'll use this as the new definition and throw an
            //exception at runtime if the user has not dropped the previous table yet
            TempMetadataID tempTable = ResolverUtil.addTempTable(metadata, group, create.getColumnSymbols());
View Full Code Here

          criteria.setExpression(ResolverUtil.convertExpression(exp, expTypeName, commonType, metadata));
          criteria.setLowerExpression(ResolverUtil.convertExpression(lower, lowerTypeName, commonType, metadata));
          criteria.setUpperExpression(ResolverUtil.convertExpression(upper, upperTypeName, commonType, metadata));
      } else {
          // Couldn't find a common type to implicitly convert to
          throw new QueryResolverException("ERR.015.008.0027", QueryPlugin.Util.getString("ERR.015.008.0027", expTypeName, lowerTypeName, criteria)); //$NON-NLS-1$ //$NON-NLS-2$
      }
      // invariants: exp.getType() == lower.getType() == upper.getType()
  }
View Full Code Here

 
    String commonType = ResolverUtil.getCommonType(new String[] {leftTypeName, rightTypeName});
   
    if (commonType == null) {
          // Neither are aggs, but types can't be reconciled
          throw new QueryResolverException("ERR.015.008.0027", QueryPlugin.Util.getString("ERR.015.008.0027", new Object[] { leftTypeName, rightTypeName, ccrit })); //$NON-NLS-1$ //$NON-NLS-2$
    }
    ccrit.setLeftExpression(ResolverUtil.convertExpression(leftExpression, leftTypeName, commonType, metadata) );
    ccrit.setRightExpression(ResolverUtil.convertExpression(rightExpression, rightTypeName, commonType, metadata) );
  }
View Full Code Here

              } else if (ResolverUtil.canImplicitlyConvert(type, DataTypeManager.DefaultDataTypes.CLOB)){
                     
                  result = ResolverUtil.convertExpression(expr, type, DataTypeManager.DefaultDataTypes.CLOB, metadata);
 
              } else {
                  throw new QueryResolverException("ERR.015.008.0029", QueryPlugin.Util.getString("ERR.015.008.0029", mcrit)); //$NON-NLS-1$ //$NON-NLS-2$
              }
          }
      }
      return result;
  }
View Full Code Here

      throws QueryResolverException {
 
      // Check that each of the values are the same type as expression
      Class exprType = scrit.getExpression().getType();
      if(exprType == null) {
          throw new QueryResolverException("ERR.015.008.0030", QueryPlugin.Util.getString("ERR.015.008.0030", scrit.getExpression())); //$NON-NLS-1$ //$NON-NLS-2$
      }
 
      String exprTypeName = DataTypeManager.getDataTypeName(exprType);
      boolean changed = false;
      List newVals = new ArrayList();
 
      boolean convertLeft = false;
      Class setType = null;
 
      Iterator valIter = scrit.getValues().iterator();
      while(valIter.hasNext()) {
          Expression value = (Expression) valIter.next();
          setDesiredType(value, exprType, scrit);
          if(! value.getType().equals(exprType)) {
              // try to apply cast
              String valTypeName = DataTypeManager.getDataTypeName(value.getType());
              if(ResolverUtil.canImplicitlyConvert(valTypeName, exprTypeName)) {
                  // Apply cast and replace current value
                  newVals.add(ResolverUtil.convertExpression(value, valTypeName, exprTypeName, metadata) );
                  changed = true;
              } else {
                  convertLeft = true;
                  setType = value.getType();
                  break;
              }
          } else {
              newVals.add(value);
          }
      }
 
      // If no convert found for first element, check whether everything in the
      // set is the same and the convert can be placed on the left side
      if(convertLeft) {
          // Is there a possible conversion from left to right?
          String setTypeName = DataTypeManager.getDataTypeName(setType);
          if(ResolverUtil.canImplicitlyConvert(exprTypeName, setTypeName)) {
              valIter = scrit.getValues().iterator();
              while(valIter.hasNext()) {
                  Expression value = (Expression) valIter.next();
                  if(value.getType() == null) {
                      throw new QueryResolverException("ERR.015.008.0030", QueryPlugin.Util.getString("ERR.015.008.0030", value)); //$NON-NLS-1$ //$NON-NLS-2$
                  } else if(! value.getType().equals(setType)) {
                      throw new QueryResolverException("ERR.015.008.0031", QueryPlugin.Util.getString("ERR.015.008.0031", scrit)); //$NON-NLS-1$ //$NON-NLS-2$
                  }
              }
 
              // Convert left expression to type of values in the set
              scrit.setExpression(ResolverUtil.convertExpression(scrit.getExpression(), exprTypeName, setTypeName, metadata));
 
          } else {
              throw new QueryResolverException("ERR.015.008.0031", QueryPlugin.Util.getString("ERR.015.008.0031", scrit)); //$NON-NLS-1$ //$NON-NLS-2$
          }
      }
 
      if(changed) {
          scrit.setValues(newVals);
View Full Code Here

      // Invariants: all the expressions' types are non-null
 
      // 3. Perform implicit type conversions
      String whenTypeName = ResolverUtil.getCommonType((String[])whenTypeNames.toArray(new String[whenTypeNames.size()]));
      if (whenTypeName == null) {
          throw new QueryResolverException("ERR.015.008.0068", QueryPlugin.Util.getString("ERR.015.008.0068", "WHEN", obj)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      String thenTypeName = ResolverUtil.getCommonType((String[])thenTypeNames.toArray(new String[thenTypeNames.size()]));
      if (thenTypeName == null) {
          throw new QueryResolverException("ERR.015.008.0068", QueryPlugin.Util.getString("ERR.015.008.0068", "THEN/ELSE", obj)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), whenTypeName, metadata));
      ArrayList whens = new ArrayList(whenCount);
      ArrayList thens = new ArrayList(whenCount);
      for (int i = 0; i < whenCount; i++) {
View Full Code Here

      if (f.getFunctionDescriptor() != null) {
        return;
      }
          unresolvedFunctions.remove(obj);
      obj.acceptVisitor(this);
      QueryResolverException e = unresolvedFunctions.get(obj);
      if (e != null) {
        throw e;
      }
    }
  }
View Full Code Here

      // Invariants: all the expressions' types are non-null
 
      // 3. Perform implicit type conversions
      String thenTypeName = ResolverUtil.getCommonType((String[])thenTypeNames.toArray(new String[thenTypeNames.size()]));
      if (thenTypeName == null) {
          throw new QueryResolverException("ERR.015.008.0068", QueryPlugin.Util.getString("ERR.015.008.0068", "THEN/ELSE", obj)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      ArrayList thens = new ArrayList(whenCount);
      for (int i = 0; i < whenCount; i++) {
          thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName, metadata));
      }
View Full Code Here

                                  Set<GroupSymbol> groups) throws TeiidComponentException,
                                             QueryResolverException {
        try {
            resolveList(insert.getVariables(), metadata, null, groups);
        } catch (QueryResolverException e) {
            throw new QueryResolverException(e, QueryPlugin.Util.getString("ERR.015.012.0054", insert.getGroup(), e.getUnresolvedSymbols())); //$NON-NLS-1$
        }
    }
View Full Code Here

TOP

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

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.