[teiid-commits] teiid SVN: r2754 - in trunk: api/src/main/java/org/teiid/translator and 55 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Dec 3 13:46:04 EST 2010


Author: rareddy
Date: 2010-12-03 13:46:01 -0500 (Fri, 03 Dec 2010)
New Revision: 2754

Added:
   trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
   trunk/api/src/main/java/org/teiid/metadata/FunctionParameter.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
   trunk/connectors/translator-portfolioview/
   trunk/connectors/translator-portfolioview/.classpath
   trunk/connectors/translator-portfolioview/.project
   trunk/connectors/translator-portfolioview/.settings/
   trunk/connectors/translator-portfolioview/.settings/org.eclipse.jdt.core.prefs
   trunk/connectors/translator-portfolioview/.settings/org.maven.ide.eclipse.prefs
   trunk/connectors/translator-portfolioview/pom.xml
   trunk/connectors/translator-portfolioview/src/
   trunk/connectors/translator-portfolioview/src/main/
   trunk/connectors/translator-portfolioview/src/main/java/
   trunk/connectors/translator-portfolioview/src/main/java/com/
   trunk/connectors/translator-portfolioview/src/main/java/com/citi/
   trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/
   trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/dap/
   trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/dap/PortfolioViewExecutionFactory.java
   trunk/connectors/translator-portfolioview/src/main/resources/
   trunk/connectors/translator-portfolioview/src/main/resources/META-INF/
   trunk/connectors/translator-portfolioview/src/main/resources/META-INF/jboss-beans.xml
   trunk/connectors/translator-portfolioview/target/
   trunk/connectors/translator-portfolioview/target/classes/
   trunk/connectors/translator-portfolioview/target/classes/META-INF/
   trunk/connectors/translator-portfolioview/target/classes/META-INF/jboss-beans.xml
   trunk/connectors/translator-portfolioview/target/classes/com/
   trunk/connectors/translator-portfolioview/target/classes/com/citi/
   trunk/connectors/translator-portfolioview/target/classes/com/citi/translator/
   trunk/connectors/translator-portfolioview/target/classes/com/citi/translator/dap/
   trunk/connectors/translator-portfolioview/target/classes/com/citi/translator/dap/PortfolioViewExecutionFactory.class
   trunk/connectors/translator-portfolioview/target/test-classes/
   trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
Removed:
   trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
Modified:
   trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
   trunk/api/src/main/java/org/teiid/metadata/Schema.java
   trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
   trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
   trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
   trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
   trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
   trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
   trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java
   trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
   trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
   trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
   trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java
   trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
   trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
   trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
   trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
   trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
   trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
   trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
   trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java
   trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
   trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
   trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
   trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
   trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
   trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
   trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
   trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
   trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
   trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
   trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
Log:
TEIID-231: Adding function support for Dynamic VDB based schema stores and Translators. Functions added through these mechanism will be automatically added to the FunctionLibrary, thus do not need to be added to separately as currently being done with UDF models. This change also adds additional API classes into Teiid API to support functions.

Added: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java	                        (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,484 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.teiid.core.util.HashCodeUtil;
+
+
+/**
+ * <p>This class represents information about a particular function signature.  
+ * Function signatures are unique with respect to their name, # of arguments, 
+ * and type of arguments. Return type and argument names are not uniqueness
+ * factors.  This class makes no attempt to validate the data put into it, 
+ * particularly with respect to null values.  The 
+ * {@link FunctionMetadataValidator} can be used to validate this object.</p>
+ *
+ * Attributes:
+ * <UL>
+ * <LI>name - Name of the function</LI>
+ * <LI>description - Description of the function</LI>
+ * <LI>category - Function category containing this function</LI>
+ * <LI>pushdown - Determine whether this function can, cannot, or must be pushed down to a source</LI>
+ * <LI>invocationClass - Class containing method implementing this function</LI>
+ * <LI>invocationMethod - Method implementing this function</LI>
+ * <LI>inputParameters - 0 or more input parameters</LI>
+ * <LI>outputParameter - 1 output parameter</LI>
+ * <LI>determinism - specifies whether the function is deterministic or not. Various levels are provided
+ * <LI>nullOnNull - Specifies whether the function is called if any of the input arguments is null. The result is the null value.
+ * </UL>
+ *
+ * @see FunctionParameter
+ */
+public class FunctionMethod extends AbstractMetadataRecord implements Serializable {
+	private static final long serialVersionUID = -8039086494296455152L;
+
+	private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
+	private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
+	private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
+
+	/**
+	 * Function Pushdown
+	 * CAN_PUSHDOWN = If the source supports the function, then it will be pushed down. Must supply the Java impl
+	 * CANNOT_PUSHDOWN = It will not be pushed down, evaluated in Teiid. Must supply the Java impl
+	 * MUST_PUSHDOWN = Function must be pushed to source, no need to supply Java impl.
+	 * SYNTHETIC = system functions?
+	 */
+	public enum PushDown {CAN_PUSHDOWN, CANNOT_PUSHDOWN, MUST_PUSHDOWN, SYNTHETIC};
+    
+    /**
+     * DETERMINISTIC -> normal deterministic functions
+     * vdb -> lookup (however lookup values can be flushed at any time), current_database
+     * session -> env, user
+     * command -> command payload
+     * never -> rand, etc.
+     * 
+     * Anything at a session level and above is treated as deterministic.
+     * This is not quite correct for lookup or env.  Only in extremely rare
+     * circumstances would that be a problem.
+     * 
+     * For now the commandPayload function is treated as a special case, like lookup, in
+     * that it is considered deterministic, but will be delayed in its evaluation until
+     * processing time.
+     */
+    public enum Determinism{
+    	DETERMINISTIC(0),VDB_DETERMINISTIC(1),USER_DETERMINISTIC(2),SESSION_DETERMINISTIC(3),COMMAND_DETERMINISTIC(4),NONDETERMINISTIC(5);
+    	private int value;
+    	
+    	Determinism(int value){
+    		this.value = value;
+    	}
+    	
+    	public boolean isRestrictiveThan(Determinism that) {
+    		return this.value > that.value;
+    	}
+    	
+    	public boolean isRestrictiveThanOrEqual(Determinism that) {
+    		return this.value >= that.value;
+    	}    	
+    	
+    	public static Determinism restrictiveOf(Determinism scopeOne, Determinism scopeTwo) {
+    		return (scopeOne.value > scopeTwo.value)?scopeOne:scopeTwo;
+    	}
+    }
+    
+
+    private String description;
+    private String category;
+    private PushDown pushdown = PushDown.CAN_PUSHDOWN;
+    private String invocationClass;
+    private String invocationMethod;
+    private boolean nullDependent;
+    
+    private Determinism determinism = Determinism.DETERMINISTIC;
+        
+    private FunctionParameter[] inputParameters;
+    private FunctionParameter outputParameter;
+    
+    protected FunctionMethod() {
+    }
+       
+    public FunctionMethod(String name, String description, String category, FunctionParameter[] inputParams, FunctionParameter outputParam) {
+    	this(name, description, category, PushDown.MUST_PUSHDOWN, null, null, inputParams, outputParam, true, Determinism.DETERMINISTIC);
+    }
+    
+    public FunctionMethod(String name,
+                          String description,
+                          String category,
+                          PushDown pushdown,
+                          String invocationClass,
+                          String invocationMethod,
+                          FunctionParameter[] inputParams,
+                          FunctionParameter outputParam,
+                          boolean nullOnNull,
+                          Determinism deterministic) {
+        
+        setName(name);
+        setDescription(description);
+        setCategory(category);
+        setPushdown(pushdown);
+        setInvocationClass(invocationClass);
+        setInvocationMethod(invocationMethod);
+        setInputParameters(inputParams);
+        setOutputParameter(outputParam); 
+        setNullOnNull(nullOnNull);
+        setDeterminism(deterministic);
+    }
+    
+    /**
+     * Return name of method
+     * @return Name
+     */
+    @XmlAttribute
+    public String getName() {
+        return super.getName();
+    }
+    
+    /**
+     * Set name of method
+     * @param name Name
+     */
+    public void setName(String name) { 
+        super.setName(name);
+    }
+    
+    @Override
+	public String getFullName() {
+    	if (this.category != null) {
+    		return this.category + NAME_DELIM_CHAR + getName();
+    	}
+		return getName(); 
+	}
+    
+    
+    /**
+     * Get description of method
+     * @return Description
+     */
+    @XmlAttribute
+    public String getDescription() { 
+        return this.description;
+    }        
+    
+    /**
+     * Set description of method
+     * @param description Description
+     */
+    public void setDescription(String description) { 
+        this.description = description;
+    }
+
+    /**
+     * Get category of method
+     * @return Category
+     * @see FunctionCategoryConstants
+     */
+    @XmlAttribute
+    public String getCategory() { 
+        return this.category;
+    }        
+    
+    /**
+     * Set category of method
+     * @param category Category
+     * @see FunctionCategoryConstants
+     */
+    public void setCategory(String category) { 
+        this.category = category;
+    }
+    
+    /**
+     * Get pushdown property of method
+     * @return One of the FunctionMethod constants for pushdown
+     */
+    public PushDown getPushdown() {
+        return pushdown;
+    }
+
+    /**
+     * Set pushdown property of method
+     * @param pushdown One of the FunctionMethod constants for pushdown
+     */
+    public void setPushdown(PushDown pushdown) {
+        this.pushdown = pushdown;
+    }
+    
+    @XmlAttribute
+    public void setPushDown(String pushdown) {
+    	if (pushdown != null) {
+			if (pushdown.equals(REQUIRED)) {
+				this.pushdown = PushDown.MUST_PUSHDOWN;
+			} else if (pushdown.equals(ALLOWED)) {
+				this.pushdown = PushDown.CAN_PUSHDOWN;
+			} else if (pushdown.equals(NOT_ALLOWED)) {
+				this.pushdown = PushDown.CANNOT_PUSHDOWN;
+			}
+		} else {
+			this.pushdown = PushDown.CAN_PUSHDOWN;
+		}
+    }
+    
+    /**
+     * Get invocation class name
+     * @return Invocation class name
+     */
+    @XmlAttribute
+    public String getInvocationClass() { 
+        return this.invocationClass;
+    }        
+    
+    /**
+     * Set invocation class name
+     * @param invocationClass Invocation class name
+     */
+    public void setInvocationClass(String invocationClass) { 
+        this.invocationClass = invocationClass;
+    }
+    
+    /**
+     * Get invocation method name
+     * @return Invocation method name
+     */
+    @XmlAttribute
+    public String getInvocationMethod() { 
+        return this.invocationMethod;
+    }        
+    
+    /**
+     * Set invocation method name
+     * @param invocationMethod Invocation method name
+     */
+    public void setInvocationMethod(String invocationMethod) { 
+        this.invocationMethod = invocationMethod;
+    }
+    
+    /**
+     * Get a count of the input parameters.
+     * @return Number of input parameters
+     */
+    public int getInputParameterCount() {
+        if(this.inputParameters == null) { 
+            return 0;
+        }
+        return this.inputParameters.length;
+    }
+    
+    /**
+     * Get input parameters
+     * @return Array of input parameters, may be null if 0 parameters
+     */
+    @XmlElement
+    public FunctionParameter[] getInputParameters() { 
+        return this.inputParameters;
+    }
+    
+    /**
+     * Set input parameters.
+     * @param params Input parameters
+     */
+    public void setInputParameters(FunctionParameter[] params) { 
+        this.inputParameters = params;
+    }
+    
+    /**
+     * Get ouput parameter.
+     * @return Output parameter or return argument
+     */
+    @XmlElement(name="returnParameter")
+    public FunctionParameter getOutputParameter() { 
+        return this.outputParameter;
+    }
+    
+    /**
+     * Set ouput parameter.
+     * @param param Output Parameter
+     */
+    public void setOutputParameter(FunctionParameter param) {
+    	if (param != null) {
+    		param.setName(FunctionParameter.OUTPUT_PARAMETER_NAME);
+    	}
+        this.outputParameter = param;
+    }
+    
+    /**
+     * Get hash code for this object.  The hash code is based on the name 
+     * and input parameters.  <B>WARNING: Changing the name or input parameters
+     * will change the hash code.</B>  If this occurs after the object has been
+     * placed in a HashSet or HashMap, the object will be lost!!!!  In that 
+     * case, the object must be added to the hashed collection again.
+     * @return Hash code, based on name and input parameters
+     */
+    public int hashCode() { 
+        int hash = HashCodeUtil.hashCode(0, super.getName());
+        if(inputParameters != null) { 
+            hash = HashCodeUtil.hashCode(hash, Arrays.hashCode(inputParameters));
+        }             
+        return hash;
+    }
+    
+    /**
+     * Compare other object for equality.  This object is equal to another 
+     * FunctionMethod if 1) Name of function matches (case-insensitive), 
+     * 2) number of input parameters matches and 3) types of input parameters
+     * match.
+     * @return True if object equals this object according to conditions
+     */
+    public boolean equals(Object obj) {
+        if(obj == this) { 
+            return true;
+        } 
+        if(obj instanceof FunctionMethod) { 
+            FunctionMethod other = (FunctionMethod) obj;
+
+            // Compare # of parameters - do this first as it is much faster than name compare
+            if(getInputParameterCount() != other.getInputParameterCount()) {
+                return false;
+            }
+
+            // Compare function names - case insensitive
+            if(other.getName() == null || this.getName() == null) { 
+                return false;
+            }
+            if(! other.getName().equalsIgnoreCase(this.getName()) ) {
+                return false;
+            }
+            
+            // Compare types of parameters
+            FunctionParameter[] thisInputs = this.getInputParameters();
+            if(thisInputs != null && thisInputs.length > 0) { 
+                // If thisInputs is not null and >0 and other parameter
+                // count matched this parameter count, otherInputs MUST be 
+                // non null to have more than one parameter - so we don't 
+                // need to check it here.
+                FunctionParameter[] otherInputs = other.getInputParameters();
+                
+                for(int i=0; i<thisInputs.length; i++) { 
+                    boolean paramMatch = compareWithNull(thisInputs[i], otherInputs[i]);
+                    if(! paramMatch) { 
+                        return false;
+                    }    
+                }   
+            }    
+            
+            // Found no discrepancies, must be equal
+            return true;            
+        } 
+        return false;
+    }    
+    
+    /**
+     * Compare two objects that may or may not be null and consider null==null
+     * as true.
+     * @param o1 Object 1
+     * @param o2 Object 2
+     * @return True if o1 and o2 are null or if they both aren't and they are equal
+     */
+    private boolean compareWithNull(Object o1, Object o2) {
+        if(o1 == null) { 
+            if(o2 == null) { 
+                return true;
+            }
+            return false;
+        }
+        if(o2 == null) { 
+            return false;
+        }
+        return o1.equals(o2);
+    }
+    
+    /**
+     * Return string version for debugging purposes
+     * @return String representation of function method
+     */ 
+    public String toString() { 
+        StringBuffer str = new StringBuffer();
+        if(getName() != null) { 
+            str.append(getName());
+        } else {
+            str.append("<unknown>"); //$NON-NLS-1$
+        } 
+        
+        // Print parameters
+        str.append("("); //$NON-NLS-1$
+        if(inputParameters != null) { 
+            for(int i=0; i<inputParameters.length; i++) {
+                if(inputParameters[i] != null) { 
+                    str.append(inputParameters[i].toString());                   
+                } else {
+                    str.append("<unknown>"); //$NON-NLS-1$
+                }
+                
+                if(i < (inputParameters.length-1)) { 
+                    str.append(", "); //$NON-NLS-1$
+                }
+            }    
+        }                                
+        str.append(") : "); //$NON-NLS-1$
+        
+        // Print return type
+        if(outputParameter != null) { 
+            str.append(outputParameter.toString());
+        } else {
+            str.append("<unknown>"); //$NON-NLS-1$
+        }
+        
+        return str.toString();
+    }
+
+    /**
+     * Returns true if the function can produce a non-null output from a null parameter
+     */
+    public boolean isNullOnNull() {
+        return this.nullDependent;
+    }
+    
+    public void setNullOnNull(boolean nullSafe) {
+        this.nullDependent = nullSafe;
+    }
+
+    public Determinism getDeterminism() {
+        return this.determinism;
+    }
+    
+    @XmlAttribute(name="deterministic")
+    public void setDeterministicBoolean(boolean deterministic) {
+    	this.determinism = deterministic ? Determinism.DETERMINISTIC : Determinism.NONDETERMINISTIC;
+    }
+    
+    public void setDeterminism(Determinism determinism) {
+        this.determinism = determinism;
+    }
+    
+    public boolean isVarArgs() {
+    	if (this.inputParameters != null && this.inputParameters.length > 0) {
+    		return inputParameters[inputParameters.length - 1].isVarArg();
+    	}
+    	return false;
+    }
+     
+}


Property changes on: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: trunk/api/src/main/java/org/teiid/metadata/FunctionParameter.java (from rev 2683, trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java)
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionParameter.java	                        (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionParameter.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+
+/**
+ * A function parameter defines the name and description of an input or output
+ * parameter for a function.  The name should not be null, but that is not 
+ * verified by this class.  Validation of this object can be done with the 
+ * {@link FunctionMetadataValidator}.  The type string used in the function
+ * parameter should be one of the standard type names defined in 
+ * {@link org.teiid.core.types.DataTypeManager.DefaultDataTypes}.
+ */
+public class FunctionParameter implements Serializable {
+	private static final long serialVersionUID = -4696050948395485266L;
+
+	public static final String OUTPUT_PARAMETER_NAME = "result"; //$NON-NLS-1$
+	
+    private String name;  
+    private String type;
+    private String description;
+    private boolean isVarArg;
+
+    /**
+     * Construct a function parameter with no attributes.
+     */
+    public FunctionParameter() {
+    }
+
+    /**
+     * Construct a function parameter with no description.
+     * @param name Name
+     * @param type Type from standard set of types
+     */
+    public FunctionParameter(String name, String type) {
+        this(name, type, null);
+    }
+    
+    /**
+     * Construct a function parameter with all attributes.  
+     * @param name Name
+     * @param type Type from standard set of types
+     * @param description Description
+     */
+    public FunctionParameter(String name, String type, String description) { 
+        this(name, type, description, false);
+    }
+    
+    public FunctionParameter(String name, String type, String description, boolean vararg) { 
+        setName(name);
+        setType(type);
+        setDescription(description);
+        this.isVarArg = vararg;
+    }
+    
+    /**
+     * Return name of parameter.
+     * @return Name
+     */
+    @XmlAttribute
+    public String getName() {
+        return this.name;
+    }
+    
+    /**
+     * Set name
+     * @param name Name
+     */
+    public void setName(String name) { 
+        this.name = name;
+    }
+    
+    /**
+     * Get description of parameter
+     * @return Description
+     */
+    @XmlAttribute
+    public String getDescription() { 
+        return this.description;
+    }        
+    
+    /**
+     * Set description of parameter
+     * @param description Description
+     */
+    public void setDescription(String description) { 
+        this.description = description;
+    }
+       
+    /**
+     * Get type of parameter
+     * @return Type name
+     * @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
+     */
+    @XmlAttribute
+    public String getType() { 
+        return this.type;
+    }        
+    
+    /**
+     * Set type of parameter
+     * @param type Type of parameter
+     * @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
+     */
+    public void setType(String type) {
+        if(type == null) { 
+            this.type = null;
+        } else {
+            this.type = type.toLowerCase();
+        } 
+    }
+       
+    /**
+     * Return hash code for this parameter.  The hash code is based only 
+     * on the type of the parameter.  Changing the type of the parameter 
+     * after placing this object in a hashed collection will likely cause
+     * the object to be lost.
+     * @return Hash code
+     */   
+    public int hashCode() { 
+        if(this.type == null) { 
+            return 0;
+        }
+        return this.type.hashCode();
+    }
+    
+    /**
+     * Compare with other object for equality.  Equality is based on whether
+     * the type is the same as the other parameter.
+     * @return True if equal to obj
+     */   
+    public boolean equals(Object obj) {
+        if(obj == this) { 
+            return true;
+        } 
+        if(!(obj instanceof FunctionParameter)) {
+        	return false;
+        }
+        FunctionParameter other = (FunctionParameter) obj;
+        if(other.getType() == null) { 
+            return (this.getType() == null);
+        }
+        return other.getType().equals(this.getType()) && this.isVarArg == other.isVarArg;
+    }
+       
+    /**
+     * Return string version for debugging purposes
+     * @return String representation of function parameter
+     */ 
+    public String toString() { 
+        return type + (isVarArg?"... ":" ") + name; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+	public void setVarArg(boolean isVarArg) {
+		this.isVarArg = isVarArg;
+	}
+
+	public boolean isVarArg() {
+		return isVarArg;
+	}
+        
+}

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -276,4 +276,18 @@
 			}
 		}
 	}
+	
+	/**
+	 * Add a function with the given name to the model.  
+	 * @param name
+	 * @return
+	 * @throws TranslatorException 
+	 */
+	public FunctionMethod addFunction(String name) throws TranslatorException {
+		FunctionMethod function = new FunctionMethod();
+		function.setName(name);
+		setUUID(function);
+		this.schema.addFunction(function);
+		return function;
+	}		
 }

Modified: trunk/api/src/main/java/org/teiid/metadata/Schema.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/Schema.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/api/src/main/java/org/teiid/metadata/Schema.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -35,6 +35,7 @@
     
     private Map<String, Table> tables = new LinkedHashMap<String, Table>();
 	private Map<String, Procedure> procedures = new LinkedHashMap<String, Procedure>();
+	private Map<String, FunctionMethod> functions = new LinkedHashMap<String, FunctionMethod>();
 	
 	public void addTable(Table table) {
 		table.setParent(this);
@@ -45,6 +46,10 @@
 		procedure.setParent(this);
 		this.procedures.put(procedure.getName().toLowerCase(), procedure);
 	}
+	
+	public void addFunction(FunctionMethod function) {
+		this.functions.put(function.getName().toLowerCase(), function);
+	}	
 
 	/**
 	 * Get the tables defined in this schema
@@ -62,6 +67,14 @@
 		return procedures;
 	}
 	
+	/**
+	 * Get the functions defined in this schema
+	 * @return
+	 */
+	public Map<String, FunctionMethod> getFunctions() {
+		return functions;
+	}
+	
     public String getPrimaryMetamodelUri() {
         return primaryMetamodelUri;
     }

Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -23,6 +23,7 @@
 package org.teiid.translator;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -41,6 +42,7 @@
 import org.teiid.language.SetQuery;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.MetadataFactory;
 import org.teiid.metadata.RuntimeMetadata;
 
@@ -647,6 +649,10 @@
     	return null;
     }
     
+    public List<FunctionMethod> getPushDownFunctions(){
+    	return Collections.EMPTY_LIST;
+    }
+    
     /**
      * Get the integer value representing the number of values allowed in an IN criteria
      * in the WHERE clause of a query

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -29,6 +29,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.language.Comparison;
 import org.teiid.language.Function;
 import org.teiid.language.LanguageObject;
@@ -37,6 +38,8 @@
 import org.teiid.language.Comparison.Operator;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
 import org.teiid.translator.ExecutionContext;
 import org.teiid.translator.SourceSystemFunctions;
 import org.teiid.translator.Translator;
@@ -51,6 +54,13 @@
 @Translator(name="modeshape", description="A translator for the open source Modeshape JCR Repository")
 public class ModeShapeExecutionFactory extends JDBCExecutionFactory {
 	
+	private static final String JCR = "JCR"; //$NON-NLS-1$
+	private static final String JCR_REFERENCE = "JCR_REFERENCE";//$NON-NLS-1$
+	private static final String JCR_CONTAINS = "JCR_CONTAINS";//$NON-NLS-1$
+	private static final String JCR_ISSAMENODE = "JCR_ISSAMENODE";//$NON-NLS-1$
+	private static final String JCR_ISDESCENDANTNODE = "JCR_ISDESCENDANTNODE";//$NON-NLS-1$
+	private static final String JCR_ISCHILDNODE = "JCR_ISCHILDNODE";//$NON-NLS-1$
+	
 	public ModeShapeExecutionFactory() {
 		setDatabaseVersion("2.0"); //$NON-NLS-1$
 		setUseBindVariables(false);
@@ -63,11 +73,11 @@
 		registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("UpperCase")); //$NON-NLS-1$
 		registerFunctionModifier(SourceSystemFunctions.LCASE,new AliasModifier("LowerCase")); //$NON-NLS-1$
         
-		registerFunctionModifier("JCR_ISCHILDNODE", new IdentifierFunctionModifier()); //$NON-NLS-1$
-		registerFunctionModifier("JCR_ISDESCENDANTNODE", new IdentifierFunctionModifier()); //$NON-NLS-1$
-		registerFunctionModifier("JCR_ISSAMENODE", new IdentifierFunctionModifier()); //$NON-NLS-1$
-		registerFunctionModifier("JCR_REFERENCE", new IdentifierFunctionModifier()); //$NON-NLS-1$
-		registerFunctionModifier("JCR_CONTAINS", new IdentifierFunctionModifier()); //$NON-NLS-1$
+		registerFunctionModifier(JCR_ISCHILDNODE, new IdentifierFunctionModifier()); 
+		registerFunctionModifier(JCR_ISDESCENDANTNODE, new IdentifierFunctionModifier()); 
+		registerFunctionModifier(JCR_ISSAMENODE, new IdentifierFunctionModifier()); 
+		registerFunctionModifier(JCR_REFERENCE, new IdentifierFunctionModifier()); 
+		registerFunctionModifier(JCR_CONTAINS, new IdentifierFunctionModifier());
 		
     	LogManager.logTrace(LogConstants.CTX_CONNECTOR, "ModeShape Translator Started"); //$NON-NLS-1$
      }    
@@ -99,15 +109,45 @@
 		supportedFunctions.add(SourceSystemFunctions.UCASE); 
 		supportedFunctions.add(SourceSystemFunctions.LCASE); 
 		supportedFunctions.add(SourceSystemFunctions.LENGTH);
-		supportedFunctions.add("JCR_ISCHILDNODE"); //$NON-NLS-1$
-		supportedFunctions.add("JCR_ISDESCENDANTNODE"); //$NON-NLS-1$
-		supportedFunctions.add("JCR_ISSAMENODE"); //$NON-NLS-1$
-		supportedFunctions.add("JCR_REFERENCE"); //$NON-NLS-1$
-		supportedFunctions.add("JCR_CONTAINS"); //$NON-NLS-1$
 		return supportedFunctions;
     }
     
+    
     @Override
+    public List<FunctionMethod> getPushDownFunctions(){
+    	List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
+		pushdownFunctions.add(new FunctionMethod(JCR_ISCHILDNODE, JCR_ISCHILDNODE, JCR, 
+            new FunctionParameter[] {
+				new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("path2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+            new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		pushdownFunctions.add(new FunctionMethod(JCR_ISDESCENDANTNODE, JCR_ISDESCENDANTNODE, JCR, 
+                new FunctionParameter[] {
+				new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("path2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+		pushdownFunctions.add(new FunctionMethod(JCR_ISSAMENODE, JCR_ISSAMENODE, JCR, 
+                new FunctionParameter[] {
+					new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("path2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		pushdownFunctions.add(new FunctionMethod(JCR_CONTAINS, JCR_CONTAINS, JCR, 
+                new FunctionParameter[] {
+                    new FunctionParameter("selectorOrProperty", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("searchExpr", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		pushdownFunctions.add(new FunctionMethod(JCR_REFERENCE, JCR_REFERENCE, JCR, 
+                new FunctionParameter[] {
+                    new FunctionParameter("selectorOrProperty", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	return pushdownFunctions;    	
+    }    
+    
+    @Override
     public List<?> translate(LanguageObject obj, ExecutionContext context) {
     	if (obj instanceof Comparison) {
     		Comparison compare = (Comparison)obj;

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -49,6 +49,7 @@
 import org.teiid.language.SetQuery.Operation;
 import org.teiid.language.visitor.CollectorVisitor;
 import org.teiid.metadata.Column;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.translator.ExecutionContext;
 import org.teiid.translator.SourceSystemFunctions;
 import org.teiid.translator.Translator;
@@ -65,25 +66,17 @@
 @Translator(name="oracle", description="A translator for Oracle 9i Database or later")
 public class OracleExecutionFactory extends JDBCExecutionFactory {
 
+	
 	private static final String TIME_FORMAT = "HH24:MI:SS"; //$NON-NLS-1$
 	private static final String DATE_FORMAT = "YYYY-MM-DD"; //$NON-NLS-1$
 	private static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT; //$NON-NLS-1$
 	private static final String TIMESTAMP_FORMAT = DATETIME_FORMAT + ".FF";  //$NON-NLS-1$
 
-	/*
-	 * Spatial Functions
-	 */
-	public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
-	public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
-	public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
-	public static final String WITHIN_DISTANCE = "sdo_within_distance"; //$NON-NLS-1$
-	public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance"; //$NON-NLS-1$
-
     public final static String HINT_PREFIX = "/*+"; //$NON-NLS-1$
     public final static String DUAL = "DUAL"; //$NON-NLS-1$
     public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
     public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
-	
+    
     public void start() throws TranslatorException {
         super.start();
         
@@ -120,10 +113,10 @@
 		});
         
         //spatial functions
-        registerFunctionModifier(RELATE, new OracleSpatialFunctionModifier());
-        registerFunctionModifier(NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
-        registerFunctionModifier(FILTER, new OracleSpatialFunctionModifier());
-        registerFunctionModifier(WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
+        registerFunctionModifier(OracleSpatialFunctions.RELATE, new OracleSpatialFunctionModifier());
+        registerFunctionModifier(OracleSpatialFunctions.NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
+        registerFunctionModifier(OracleSpatialFunctions.FILTER, new OracleSpatialFunctionModifier());
+        registerFunctionModifier(OracleSpatialFunctions.WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
         
         //add in type conversion
         ConvertModifier convertModifier = new ConvertModifier();
@@ -335,7 +328,7 @@
 	        // If so, the ORDERED hint is added, if not, it isn't
 	        Collection<Function> col = CollectorVisitor.collectObjects(Function.class, command);
 	        for (Function func : col) {
-	            if (func.getName().equalsIgnoreCase(RELATE)) {
+	            if (func.getName().equalsIgnoreCase(OracleSpatialFunctions.RELATE)) {
 	                return comment + "/*+ ORDERED */ "; //$NON-NLS-1$
 	            }
 	        }
@@ -465,15 +458,15 @@
         supportedFunctions.add("NVL");      //$NON-NLS-1$ 
         supportedFunctions.add("COALESCE"); //$NON-NLS-1$
         
-        supportedFunctions.add(OracleExecutionFactory.RELATE);
-        supportedFunctions.add(OracleExecutionFactory.NEAREST_NEIGHBOR);
-        supportedFunctions.add(OracleExecutionFactory.FILTER);
-        supportedFunctions.add(OracleExecutionFactory.NEAREST_NEIGHBOR_DISTANCE);
-        supportedFunctions.add(OracleExecutionFactory.WITHIN_DISTANCE);
         return supportedFunctions;
     }
     
     @Override
+    public List<FunctionMethod> getPushDownFunctions(){
+    	return OracleSpatialFunctions.getOracleSpatialFunctions();
+    }
+    
+    @Override
     public String translateLiteralTimestamp(Timestamp timestampValue) {
     	if (timestampValue.getNanos() == 0) {
     		String val = formatDateValue(timestampValue);

Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java	                        (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.oracle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+
+public class OracleSpatialFunctions {
+	
+	/*
+	 * Spatial Functions
+	 */
+	public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
+	public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
+	public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
+	public static final String WITHIN_DISTANCE = "sdo_within_distance"; //$NON-NLS-1$
+	public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance"; //$NON-NLS-1$
+	private static final String ORACLE_SDO = "Oracle-SDO"; //$NON-NLS-1$
+	
+
+    public static List<FunctionMethod> getOracleSpatialFunctions(){
+    	    	
+    	List<FunctionMethod> spatialFuncs = new ArrayList<FunctionMethod>();
+    	
+    	spatialFuncs.add(new FunctionMethod(RELATE, RELATE, ORACLE_SDO,   
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+    	spatialFuncs.add(new FunctionMethod(RELATE, RELATE, ORACLE_SDO, 
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	spatialFuncs.add(new FunctionMethod(RELATE, RELATE, ORACLE_SDO,  
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+    	spatialFuncs.add(new FunctionMethod(RELATE, RELATE, ORACLE_SDO, 
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	spatialFuncs.add(new FunctionMethod(NEAREST_NEIGHBOR, NEAREST_NEIGHBOR, ORACLE_SDO,   
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	spatialFuncs.add(new FunctionMethod(NEAREST_NEIGHBOR, NEAREST_NEIGHBOR, ORACLE_SDO,  
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    	
+
+    	spatialFuncs.add(new FunctionMethod(NEAREST_NEIGHBOR, NEAREST_NEIGHBOR, ORACLE_SDO,  
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    	
+    	
+    	spatialFuncs.add(new FunctionMethod(NEAREST_NEIGHBOR_DISTANCE, NEAREST_NEIGHBOR_DISTANCE, ORACLE_SDO,  
+                new FunctionParameter[] {
+                    new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$  
+    	    	
+    	spatialFuncs.add(new FunctionMethod(WITHIN_DISTANCE, WITHIN_DISTANCE, ORACLE_SDO, 
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	spatialFuncs.add(new FunctionMethod(WITHIN_DISTANCE, WITHIN_DISTANCE, ORACLE_SDO,   
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    	
+    	
+    	spatialFuncs.add(new FunctionMethod(WITHIN_DISTANCE, WITHIN_DISTANCE, ORACLE_SDO,  
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	spatialFuncs.add(new FunctionMethod(FILTER, FILTER, ORACLE_SDO,   
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+    	
+    	spatialFuncs.add(new FunctionMethod(FILTER, FILTER, ORACLE_SDO,  
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    
+    	
+    	spatialFuncs.add(new FunctionMethod(FILTER, FILTER, ORACLE_SDO,   
+                new FunctionParameter[] {
+                    new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$      	
+    	
+    	return spatialFuncs;
+    }
+}


Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-jdbc/src/main/resources/JCRFunctions.xmi	2010-12-03 18:46:01 UTC (rev 2754)
@@ -12,18 +12,18 @@
   </diagram:DiagramContainer>
   <mmcore:AnnotationContainer xmi:uuid="mmuuid:c3c82dbf-1339-4354-b23d-7135aa430b21"/>
   <mmfunction:ScalarFunction xmi:uuid="mmuuid:ecf2b4a4-40fe-4cab-b84a-93a26c0560c7" name="JCR_ISCHILDNODE" category="JCR" pushDown="REQUIRED">
-    <inputParameters xmi:uuid="mmuuid:23fd3fce-de13-4b11-957d-a44c2ac6da43" name="path" type="string"/>
-    <inputParameters xmi:uuid="mmuuid:68bafab4-98f7-472d-81cb-38e6bf2aa096" name="path" type="string"/>
+    <inputParameters xmi:uuid="mmuuid:23fd3fce-de13-4b11-957d-a44c2ac6da43" name="path1" type="string"/>
+    <inputParameters xmi:uuid="mmuuid:68bafab4-98f7-472d-81cb-38e6bf2aa096" name="path2" type="string"/>
     <returnParameter xmi:uuid="mmuuid:151394ed-8654-4e9a-a081-f3bf02b71b2d" type="boolean"/>
   </mmfunction:ScalarFunction>
   <mmfunction:ScalarFunction xmi:uuid="mmuuid:6387763f-0397-4abc-a2ca-46c9c0f793bd" name="JCR_ISDESCENDANTNODE" category="JCR" pushDown="REQUIRED">
-    <inputParameters xmi:uuid="mmuuid:c3a1f10b-58a5-4c5b-a94f-bac009b31284" name="path" type="string"/>
-    <inputParameters xmi:uuid="mmuuid:403500a9-f48b-4603-8d92-2011944baa9d" name="path" type="string"/>
+    <inputParameters xmi:uuid="mmuuid:c3a1f10b-58a5-4c5b-a94f-bac009b31284" name="path1" type="string"/>
+    <inputParameters xmi:uuid="mmuuid:403500a9-f48b-4603-8d92-2011944baa9d" name="path2" type="string"/>
     <returnParameter xmi:uuid="mmuuid:ae90df19-106a-481d-b905-68a9c2493316" type="boolean"/>
   </mmfunction:ScalarFunction>
   <mmfunction:ScalarFunction xmi:uuid="mmuuid:4ecc9ba6-a383-4196-a261-1860cc3ee88c" name="JCR_ISSAMENODE" category="JCR" pushDown="REQUIRED">
-    <inputParameters xmi:uuid="mmuuid:94a8a68c-4744-4cdb-9ad8-23417e5aff56" name="path" type="string"/>
-    <inputParameters xmi:uuid="mmuuid:004473ae-2199-43d0-b4bd-fd996fa18b7b" name="path" type="string"/>
+    <inputParameters xmi:uuid="mmuuid:94a8a68c-4744-4cdb-9ad8-23417e5aff56" name="path1" type="string"/>
+    <inputParameters xmi:uuid="mmuuid:004473ae-2199-43d0-b4bd-fd996fa18b7b" name="path2" type="string"/>
     <returnParameter xmi:uuid="mmuuid:8ab20d78-fd6a-400a-9e03-70be996b4cc6" type="boolean"/>
   </mmfunction:ScalarFunction>
   <mmfunction:ScalarFunction xmi:uuid="mmuuid:a84444b6-79b4-45bc-97bf-745503dabc03" name="JCR_CONTAINS" category="JCR" pushDown="REQUIRED">

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -36,8 +36,8 @@
 import org.teiid.cdk.unittest.FakeTranslationFactory;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.language.Command;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.query.function.metadata.FunctionMetadataReader;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.translator.TranslatorException;
 import org.teiid.translator.ExecutionContext;
 

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -722,7 +722,7 @@
         RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
         
         CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
-        return new TransformationMetadata(null, store, null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+        return new TransformationMetadata(null, store, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
     }
 
 	public void helpTestVisitor(String vdb, String input, String expectedOutput) throws TranslatorException {

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -160,7 +160,7 @@
         obj.setNativeType("uniqueidentifier"); //$NON-NLS-1$
         
         CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
-        QueryMetadataInterface metadata = new TransformationMetadata(null, store, null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+        QueryMetadataInterface metadata = new TransformationMetadata(null, store, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
         
         TranslationUtility tu = new TranslationUtility(metadata);
         Command command = tu.parseCommand("select max(x) from bar"); //$NON-NLS-1$

Modified: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -304,7 +304,7 @@
         }
         
         // Create the facade from the store
-        return new TransformationMetadata(null, new CompositeMetadataStore(metadataStore), null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+        return new TransformationMetadata(null, new CompositeMetadataStore(metadataStore), null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
     }    
 }
 

Added: trunk/connectors/translator-portfolioview/.classpath
===================================================================
--- trunk/connectors/translator-portfolioview/.classpath	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/.classpath	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>


Property changes on: trunk/connectors/translator-portfolioview/.classpath
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/.project
===================================================================
--- trunk/connectors/translator-portfolioview/.project	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/.project	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>translator-portfolioview</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>


Property changes on: trunk/connectors/translator-portfolioview/.project
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/connectors/translator-portfolioview/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/.settings/org.eclipse.jdt.core.prefs	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,6 @@
+#Tue Nov 16 14:11:58 EST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6


Property changes on: trunk/connectors/translator-portfolioview/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- trunk/connectors/translator-portfolioview/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/.settings/org.maven.ide.eclipse.prefs	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,9 @@
+#Tue Nov 16 14:11:30 EST 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1


Property changes on: trunk/connectors/translator-portfolioview/.settings/org.maven.ide.eclipse.prefs
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/pom.xml
===================================================================
--- trunk/connectors/translator-portfolioview/pom.xml	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/pom.xml	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>connectors</artifactId>
+        <groupId>org.jboss.teiid</groupId>
+        <version>7.2.0.CR1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>translator-portfolioview</artifactId>
+    <groupId>org.jboss.teiid.connectors</groupId>
+    <name>Portfolio View Generator Translator</name>
+    <description>This translator injects portfolio views into Teiid VDB</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.jboss.teiid</groupId>
+            <artifactId>teiid-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.teiid</groupId>
+            <artifactId>teiid-common-core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.resource</groupId>
+            <artifactId>connector-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <outputDirectory>target/classes</outputDirectory>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.xml</include>
+                    <include>**/*.properties</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>false</filtering>
+                <excludes>
+                    <exclude>**/*.xml</exclude>
+                    <exclude>**/*.properties</exclude>
+                </excludes>
+            </resource>
+        </resources>
+    </build>
+
+</project>


Property changes on: trunk/connectors/translator-portfolioview/pom.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/dap/PortfolioViewExecutionFactory.java
===================================================================
--- trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/dap/PortfolioViewExecutionFactory.java	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/dap/PortfolioViewExecutionFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.citi.translator.dap;
+
+import java.sql.Connection;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import javax.resource.cci.ConnectionFactory;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Call;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.Table.Type;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TranslatorProperty;
+
+ at Translator(name="portfolioview", description="A translator for creating a portfolio view")
+public class PortfolioViewExecutionFactory extends ExecutionFactory<ConnectionFactory, Connection> {
+	
+	private String portfolioName;
+
+	@TranslatorProperty(display="portfolio name", description="Portfolio View name")
+	public String getPortfolioName() {
+		return this.portfolioName;
+	}
+
+	public void setPortfolioName(String portfolio) {
+		this.portfolioName = portfolio;
+	}
+	
+    @Override
+    public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection connection)
+    		throws TranslatorException {
+    	throw new TranslatorException("This is view model, no executions allowed"); //$NON-NLS-1$
+    }
+    
+	@Override
+    public final List getSupportedFunctions() {
+        return Collections.EMPTY_LIST;
+    }
+	
+	@Override
+	public void getMetadata(MetadataFactory metadataFactory,	Connection conn) throws TranslatorException {
+		Table t = createView(metadataFactory, "pg_attribute"); //$NON-NLS-1$ 
+
+		metadataFactory.addColumn("oid", DataTypeManager.DefaultDataTypes.INTEGER, t); //$NON-NLS-1$ 
+		
+		metadataFactory.addPrimaryKey("pk_pg_attr", Arrays.asList("oid"), t); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		String transformation = "select * from foo"; //$NON-NLS-1$
+		t.setSelectTransformation(transformation);
+	}
+	
+	
+	private Table createView(MetadataFactory metadataFactory, String name) throws TranslatorException {
+		Table t = metadataFactory.addTable(name);
+		t.setSupportsUpdate(false);
+		t.setVirtual(true);
+		t.setTableType(Type.Table);
+		return t;
+	}
+}


Property changes on: trunk/connectors/translator-portfolioview/src/main/java/com/citi/translator/dap/PortfolioViewExecutionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-portfolioview/src/main/resources/META-INF/jboss-beans.xml	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/src/main/resources/META-INF/jboss-beans.xml	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   
+   <bean name="translator-citi-dap" class="org.teiid.templates.TranslatorDeploymentTemplate">
+      <property name="info"><inject bean="translator-citi-dap"/></property>
+      <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
+   </bean>
+    
+   <bean name="translator-citi-dap" class="org.teiid.templates.TranslatorTemplateInfo">
+      <constructor factoryMethod="createTemplateInfo">
+         <factory bean="TranslatorDeploymentTemplateInfoFactory"/>
+         <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+         <parameter class="java.lang.Class">com.citi.translator.dap.DAPExecutionFactory</parameter>
+         <parameter class="java.lang.String">translator-citi-dap</parameter>
+         <parameter class="java.lang.String">citi-dap</parameter>         
+      </constructor>
+   </bean> 
+   
+</deployment>


Property changes on: trunk/connectors/translator-portfolioview/src/main/resources/META-INF/jboss-beans.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/target/classes/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-portfolioview/target/classes/META-INF/jboss-beans.xml	                        (rev 0)
+++ trunk/connectors/translator-portfolioview/target/classes/META-INF/jboss-beans.xml	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   
+   <bean name="translator-citi-dap" class="org.teiid.templates.TranslatorDeploymentTemplate">
+      <property name="info"><inject bean="translator-citi-dap"/></property>
+      <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
+   </bean>
+    
+   <bean name="translator-citi-dap" class="org.teiid.templates.TranslatorTemplateInfo">
+      <constructor factoryMethod="createTemplateInfo">
+         <factory bean="TranslatorDeploymentTemplateInfoFactory"/>
+         <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+         <parameter class="java.lang.Class">com.citi.translator.dap.DAPExecutionFactory</parameter>
+         <parameter class="java.lang.String">translator-citi-dap</parameter>
+         <parameter class="java.lang.String">citi-dap</parameter>         
+      </constructor>
+   </bean> 
+   
+</deployment>


Property changes on: trunk/connectors/translator-portfolioview/target/classes/META-INF/jboss-beans.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/connectors/translator-portfolioview/target/classes/com/citi/translator/dap/PortfolioViewExecutionFactory.class
===================================================================
(Binary files differ)


Property changes on: trunk/connectors/translator-portfolioview/target/classes/com/citi/translator/dap/PortfolioViewExecutionFactory.class
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -23,15 +23,19 @@
 package org.teiid.translator.salesforce;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.resource.cci.ConnectionFactory;
 
+import org.teiid.core.types.DataTypeManager;
 import org.teiid.language.Call;
 import org.teiid.language.Command;
 import org.teiid.language.QueryExpression;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
 import org.teiid.metadata.MetadataFactory;
 import org.teiid.metadata.RuntimeMetadata;
 import org.teiid.translator.ExecutionContext;
@@ -51,6 +55,9 @@
 @Translator(name="salesforce", description="A translator for Salesforce")
 public class SalesForceExecutionFactory extends ExecutionFactory<ConnectionFactory, SalesforceConnection> {
 
+	private static final String SALESFORCE = "salesforce"; //$NON-NLS-1$
+	private static final String EXCLUDES = "excludes";//$NON-NLS-1$
+	private static final String INCLUDES = "includes";//$NON-NLS-1$
 	private String connectorStateClass;
 	private boolean auditModelFields = false;	
 	
@@ -123,11 +130,25 @@
 
     @Override
     public List getSupportedFunctions() {
-        List<String> supportedFunctions = new ArrayList<String>();
-        supportedFunctions.add("includes"); //$NON-NLS-1$
-        supportedFunctions.add("excludes"); //$NON-NLS-1$
-        return supportedFunctions;
+        return Collections.EMPTY_LIST;
     }
+    
+    @Override
+    public List<FunctionMethod> getPushDownFunctions(){
+    	List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
+		pushdownFunctions.add(new FunctionMethod(INCLUDES, INCLUDES, SALESFORCE, 
+            new FunctionParameter[] {
+                new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("param", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+            new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		pushdownFunctions.add(new FunctionMethod(EXCLUDES, EXCLUDES, SALESFORCE, 
+                new FunctionParameter[] {
+                    new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+                    new FunctionParameter("param", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    		
+    	return pushdownFunctions;    	
+    }
 
     @Override
     public boolean supportsCompareCriteriaEquals() {

Modified: trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -96,7 +96,7 @@
             Column obj = contactCols.get(i);
             obj.setNameInSource(contactNameInSource[i]);
         }
-        return new TransformationMetadata(null, new CompositeMetadataStore(store), null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+        return new TransformationMetadata(null, new CompositeMetadataStore(store), null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
     }    
 
 	private static TranslationUtility translationUtility = new TranslationUtility(exampleSalesforce());

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -25,6 +25,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
 import org.teiid.query.optimizer.capabilities.SourceCapabilities;
 import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
@@ -106,6 +107,12 @@
                 tgtCaps.setFunctionSupport(func.toLowerCase(), true);
             }
         }
+        List<FunctionMethod> pushDowns = srcCaps.getPushDownFunctions();
+        if(pushDowns != null && pushDowns.size() > 0) {
+            for(FunctionMethod func:pushDowns) {
+                tgtCaps.setFunctionSupport(func.getName().toLowerCase(), true);
+            }
+        }
         
         tgtCaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(srcCaps.getMaxInCriteriaSize()));
         tgtCaps.setSourceProperty(Capability.CONNECTOR_ID, connectorID);

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -27,6 +27,7 @@
 package org.teiid.dqp.internal.datamgr;
 
 import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
@@ -45,6 +46,7 @@
 import org.teiid.logging.MessageLevel;
 import org.teiid.logging.CommandLogMessage.Event;
 import org.teiid.metadata.Datatype;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.MetadataFactory;
 import org.teiid.metadata.MetadataStore;
 import org.teiid.query.QueryPlugin;
@@ -68,6 +70,7 @@
 
 	private String translatorName;
 	private String connectionName;
+	private String modelName;
 	
     // known requests
     private ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem> requestStates = new ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem>();
@@ -129,6 +132,10 @@
 		return factory.getMetadataStore();
 	}    
     
+    public List<FunctionMethod> getPushDownFunctions(){
+    	return getExecutionFactory().getPushDownFunctions();
+    }
+    
     public SourceCapabilities getCapabilities() throws TeiidComponentException {
     	if (cachedCapabilities != null) {
     		return cachedCapabilities;
@@ -275,4 +282,12 @@
     public String getConnectionName() {
     	return this.connectionName;
     }
+    
+    public void setModelName(String modelName) {
+    	this.modelName = modelName;
+    }
+    
+    public String getModelName() {
+    	return this.modelName;
+    }
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -29,6 +29,7 @@
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.core.id.IDGenerator;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.QueryOptimizer;
@@ -82,7 +83,7 @@
 	        
 	        AbstractValidationVisitor visitor = new ValidationVisitor();
 	        Request.validateWithVisitor(visitor, metadata, newCommand);
-	        int determinismLevel = copy.resetDeterminismLevel();
+	        Determinism determinismLevel = copy.resetDeterminismLevel();
 	        newCommand = QueryRewriter.rewrite(newCommand, metadata, copy);
 	        AnalysisRecord record = new AnalysisRecord(false, false);
 	        ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, finder, record, copy);

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -57,10 +57,10 @@
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.logging.MessageLevel;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.eval.SecurityFunctionEvaluator;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TempCapabilitiesFinder;
 import org.teiid.query.metadata.TempMetadataAdapter;
@@ -383,7 +383,7 @@
         Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, true);
         for (GroupSymbol groupSymbol : groups) {
 			if (groupSymbol.isTempTable()) {
-				this.context.setDeterminismLevel(FunctionMethod.SESSION_DETERMINISTIC);
+				this.context.setDeterminismLevel(Determinism.SESSION_DETERMINISTIC);
 				break;
 			}
 		}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -56,9 +56,9 @@
 import org.teiid.logging.LogManager;
 import org.teiid.logging.MessageLevel;
 import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.parser.ParseInfo;
 import org.teiid.query.parser.QueryParser;
 import org.teiid.query.processor.BatchCollector;
@@ -385,12 +385,12 @@
 					doneProducingBatches();
 				}
 				if (doneProducingBatches && cid != null) {
-			    	int determinismLevel = processor.getContext().getDeterminismLevel();
+			    	Determinism determinismLevel = processor.getContext().getDeterminismLevel();
 	            	CachedResults cr = new CachedResults();
 	            	cr.setCommand(originalCommand);
 	                cr.setAnalysisRecord(analysisRecord);
 	                cr.setResults(resultsBuffer);
-	                if (determinismLevel > FunctionMethod.SESSION_DETERMINISTIC) {
+	                if (determinismLevel.isRestrictiveThan(Determinism.SESSION_DETERMINISTIC)) {
 	    				LogManager.logInfo(LogConstants.CTX_DQP, QueryPlugin.Util.getString("RequestWorkItem.cache_nondeterministic", originalCommand)); //$NON-NLS-1$
 	    			}
 	                dqpCore.getRsCache().put(cid, determinismLevel, cr, originalCommand.getCacheHint() != null?originalCommand.getCacheHint().getTtl():null);

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -41,7 +41,7 @@
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.parser.ParseInfo;
 import org.teiid.vdb.runtime.VDBKey;
 
@@ -142,8 +142,8 @@
 		return localCache.size() + distributedCache.size();
 	}
 	
-	public void put(CacheID id, int determinismLevel, T t, Long ttl){
-		if (determinismLevel >= FunctionMethod.SESSION_DETERMINISTIC) {
+	public void put(CacheID id, Determinism determinismLevel, T t, Long ttl){
+		if (determinismLevel.isRestrictiveThanOrEqual(Determinism.SESSION_DETERMINISTIC)) {
 			id.setSessionId(id.originalSessionId);
 			LogManager.logTrace(LogConstants.CTX_DQP, "Adding to session/local cache", id); //$NON-NLS-1$
 			this.localCache.put(id, t, ttl);
@@ -154,7 +154,7 @@
 			
 			id.setSessionId(null);
 			
-			if (determinismLevel == FunctionMethod.USER_DETERMINISTIC) {
+			if (determinismLevel == Determinism.USER_DETERMINISTIC) {
 				id.setUserName(id.originalUserName);
 			}
 			else {

Modified: trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -63,10 +63,10 @@
 import org.teiid.core.types.XMLType.Type;
 import org.teiid.core.types.basic.StringToSQLXMLTransform;
 import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.function.FunctionDescriptor;
 import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.function.source.XMLSystemFunctions;
 import org.teiid.query.processor.ProcessorDataManager;
 import org.teiid.query.sql.LanguageObject;
@@ -963,7 +963,7 @@
 	    }            
 	    
 	    // Check for function we can't evaluate
-	    if(fd.getPushdown() == FunctionMethod.MUST_PUSHDOWN) {
+	    if(fd.getPushdown() == PushDown.MUST_PUSHDOWN) {
 	        throw new TeiidComponentException(QueryPlugin.Util.getString("ExpressionEvaluator.Must_push", fd.getName())); //$NON-NLS-1$
 	    }
 	

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -34,8 +34,9 @@
 import org.teiid.core.util.Assertion;
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.core.util.PropertiesUtils;
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.util.CommandContext;
 
 
@@ -50,13 +51,13 @@
 	private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
 	
 	private String name;
-    private int pushdown;
+    private PushDown pushdown = PushDown.CAN_PUSHDOWN;
 	private Class[] types;
 	private Class returnType;	
 	private int hash;
     private boolean requiresContext;
     private boolean nullDependent;
-    private int deterministic;
+    private Determinism deterministic = Determinism.DETERMINISTIC;
     
     // This is transient as it would be useless to invoke this method in 
     // a different VM.  This function descriptor can be used to look up 
@@ -74,7 +75,7 @@
      * @param invocationMethod Reflection method used to invoke the function
      * @param requiresContext during execution requires command context to be pushed into method as first argument
      */
-	FunctionDescriptor(String name, int pushdown, Class[] types, Class returnType, Method invocationMethod, boolean requiresContext, boolean nullDependent, int deterministic) {
+	FunctionDescriptor(String name, PushDown pushdown, Class[] types, Class returnType, Method invocationMethod, boolean requiresContext, boolean nullDependent, Determinism deterministic) {
 		Assertion.isNotNull(name);
 		Assertion.isNotNull(types);
 		Assertion.isNotNull(returnType);
@@ -99,11 +100,11 @@
 		return this.name;				
 	}
     
-    public int getPushdown() {
+    public PushDown getPushdown() {
         return this.pushdown;
     }
     
-    void setPushdown(int pushdown) {
+    void setPushdown(PushDown pushdown) {
         this.pushdown = pushdown;
     }
 	
@@ -192,11 +193,11 @@
         return nullDependent;
     }
     
-    public int getDeterministic() {
+    public Determinism getDeterministic() {
         return deterministic;
     }
 
-    void setDeterministic(int deterministic) {
+    void setDeterministic(Determinism deterministic) {
         this.deterministic = deterministic;
     }
     
@@ -238,7 +239,7 @@
         	throw new FunctionExecutionException("ERR.015.001.0002", QueryPlugin.Util.getString("ERR.015.001.0002", getName())); //$NON-NLS-1$ //$NON-NLS-2$
         }
         
-        if (getDeterministic() >= FunctionMethod.USER_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
+        if (getDeterministic().isRestrictiveThanOrEqual(Determinism.USER_DETERMINISTIC) && values.length > 0 && values[0] instanceof CommandContext) {
         	CommandContext cc = (CommandContext)values[0];
         	cc.setDeterminismLevel(getDeterministic());
         }

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -30,8 +30,8 @@
 import org.teiid.core.util.Assertion;
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.language.SQLConstants.Reserved;
-import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
 
 
 /**
@@ -41,8 +41,9 @@
  * function name and the names of the arguments.
  */
 public class FunctionForm implements Serializable, Comparable {
-
-    private String name;
+	private static final long serialVersionUID = 2411783099304320334L;
+	
+	private String name;
     private String description;
     private String category;
     private List inputParamNames;

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -32,8 +32,8 @@
 import org.teiid.api.exception.query.InvalidFunctionException;
 import org.teiid.api.exception.query.QueryResolverException;
 import org.teiid.core.types.DataTypeManager;
-import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
 import org.teiid.query.sql.symbol.Expression;
 import org.teiid.query.sql.symbol.Function;
 
@@ -93,13 +93,13 @@
     private FunctionTree systemFunctions;
 
     // Function tree for user-defined functions
-    private FunctionTree userFunctions;
+    private FunctionTree[] userFunctions;
 
 	/**
 	 * Construct the function library.  This should be called only once by the
 	 * FunctionLibraryManager.
 	 */
-	public FunctionLibrary(FunctionTree systemFuncs, FunctionTree userFuncs) {
+	public FunctionLibrary(FunctionTree systemFuncs, FunctionTree... userFuncs) {
         systemFunctions = systemFuncs;
        	userFunctions = userFuncs;
 	}
@@ -111,8 +111,12 @@
     public List getFunctionCategories() {
         // Remove category duplicates
         HashSet categories = new HashSet();
-        categories.addAll( systemFunctions.getCategories() );
-        categories.addAll( userFunctions.getCategories() );
+        categories.addAll( systemFunctions.getCategories() );
+        if (this.userFunctions != null) {
+	        for (FunctionTree tree: this.userFunctions) {
+	        	categories.addAll(tree.getCategories());
+	        }
+        }
 
         // Sort alphabetically
         ArrayList categoryList = new ArrayList(categories);
@@ -127,8 +131,12 @@
      */
     public List getFunctionForms(String category) {
         List forms = new ArrayList();
-        forms.addAll(systemFunctions.getFunctionForms(category));
-        forms.addAll(userFunctions.getFunctionForms(category));
+        forms.addAll(systemFunctions.getFunctionForms(category));
+        if (this.userFunctions != null) {
+	        for (FunctionTree tree: this.userFunctions) {
+	        	forms.addAll(tree.getFunctionForms(category));
+	        }
+        }
 
         // Sort alphabetically
         Collections.sort(forms);
@@ -143,8 +151,13 @@
      */
     public FunctionForm findFunctionForm(String name, int numArgs) {
         FunctionForm form = systemFunctions.findFunctionForm(name, numArgs);
-        if(form == null) {
-            form = userFunctions.findFunctionForm(name, numArgs);
+        if(form == null && this.userFunctions != null) {
+        	for (FunctionTree tree: this.userFunctions) {
+        		form = tree.findFunctionForm(name, numArgs);
+        		if (form != null) {
+        			break;
+        		}
+        	}
         }
         return form;
     }
@@ -162,8 +175,13 @@
         FunctionDescriptor descriptor = systemFunctions.getFunction(name, types);
 
         // If that fails, check the user defined functions
-        if(descriptor == null) {
-            descriptor = userFunctions.getFunction(name, types);
+        if(descriptor == null && this.userFunctions != null) {
+        	for (FunctionTree tree: this.userFunctions) {
+        		descriptor = tree.getFunction(name, types);
+        		if (descriptor != null) {
+        			break;
+        		}
+        	}
         }
 
         return descriptor;
@@ -195,8 +213,12 @@
 
         //First find existing functions with same name and same number of parameters
         final Collection<FunctionMethod> functionMethods = new LinkedList<FunctionMethod>();
-        functionMethods.addAll( this.systemFunctions.findFunctionMethods(name , types.length) );
-        functionMethods.addAll( this.userFunctions.findFunctionMethods(name , types.length) );
+        functionMethods.addAll( this.systemFunctions.findFunctionMethods(name, types.length) );
+        if (this.userFunctions != null) {
+	        for (FunctionTree tree: this.userFunctions) {
+	        	functionMethods.addAll( tree.findFunctionMethods(name, types.length) );
+	        }
+        }
         
         //Score each match, reject any where types can not be converted implicitly       
         //Score of current method (lower score means better match with less converts

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -24,7 +24,7 @@
 
 import java.util.Collection;
 
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod;
 
 
 /**

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -41,10 +41,12 @@
 import org.teiid.core.util.ReflectionHelper;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.function.metadata.FunctionCategoryConstants;
-import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
 import org.teiid.query.util.CommandContext;
 
 
@@ -152,7 +154,7 @@
     	}
     	categoryKey = categoryKey.toUpperCase();
         String nameKey = method.getName().toUpperCase();
-
+        
         // Look up function map (create if necessary)
         Set<String> functions = categories.get(categoryKey);
         if (functions == null) {
@@ -160,16 +162,28 @@
             categories.put(categoryKey, functions);
         }
 
-        // Look up function in function map
-        functions.add(nameKey);
-
-        // Add method to list by function name
-        List<FunctionMethod> knownMethods = functionsByName.get(nameKey);
-        if(knownMethods == null) {
-            knownMethods = new ArrayList<FunctionMethod>();
-            functionsByName.put(nameKey, knownMethods);
-        }
-        knownMethods.add(method);
+        int index = -1;
+        while (true){
+	        // Look up function in function map
+	        functions.add(nameKey);
+	
+	        // Add method to list by function name
+	        List<FunctionMethod> knownMethods = functionsByName.get(nameKey);
+	        if(knownMethods == null) {
+	            knownMethods = new ArrayList<FunctionMethod>();
+	            functionsByName.put(nameKey, knownMethods);
+	        }
+	        knownMethods.add(method);
+	        
+	        // if the function is "." delimited, then add all possible forms
+	        index = nameKey.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR, index+1);
+	        if (index != -1) {
+	        	nameKey = nameKey.substring(index+1);
+	        }
+	        else {
+	        	break;
+	        }
+        } 
         allFunctions.add(method);
     }
 
@@ -273,7 +287,7 @@
         Method invocationMethod = null;
         boolean requiresContext = false;
         // Defect 20007 - Ignore the invocation method if pushdown is not required.
-        if (method.getPushdown() == FunctionMethod.CAN_PUSHDOWN || method.getPushdown() == FunctionMethod.CANNOT_PUSHDOWN) {
+        if (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN) {
             try {
                 Class<?> methodClass = source.getInvocationClass(method.getInvocationClass());
                 ReflectionHelper helper = new ReflectionHelper(methodClass);
@@ -315,28 +329,38 @@
             inputTypes.add(0, CommandContext.class);
         }
 
-        FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, method.isNullDependent(), method.getDeterministic());
+        FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, method.isNullOnNull(), method.getDeterminism());
         // Store this path in the function tree
-        Map node = treeRoot;
-        Object[] path = buildPath(methodName, types);
-        for(int pathIndex = 0; pathIndex < path.length; pathIndex++) {
-            Object pathPart = path[pathIndex];
-            Map children = (Map) node.get(pathPart);
-            if(children == null) {
-                children = new HashMap();
-                node.put(pathPart, children);
-            }
-            if (method.isVarArgs() && pathIndex == path.length - 1) {
-        		node.put(DESCRIPTOR_KEY, descriptor);
-            }
-            node = children;
+        
+        int index = -1;
+        while(true) {
+        	Map node = treeRoot;
+	        Object[] path = buildPath(methodName, types);
+	        for(int pathIndex = 0; pathIndex < path.length; pathIndex++) {
+	            Object pathPart = path[pathIndex];
+	            Map children = (Map) node.get(pathPart);
+	            if(children == null) {
+	                children = new HashMap();
+	                node.put(pathPart, children);
+	            }
+	            if (method.isVarArgs() && pathIndex == path.length - 1) {
+	        		node.put(DESCRIPTOR_KEY, descriptor);
+	            }
+	            node = children;
+	        }
+	
+	        if (method.isVarArgs()) {
+	        	node.put(types[types.length - 1], node);
+	        }
+	        // Store the leaf descriptor in the tree
+	        node.put(DESCRIPTOR_KEY, descriptor);
+	        
+	        index = methodName.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR, index+1);
+	        if (index == -1) {
+	        	break;
+	        }
+	        methodName = methodName.substring(index+1);
         }
-
-        if (method.isVarArgs()) {
-        	node.put(types[types.length - 1], node);
-        }
-        // Store the leaf descriptor in the tree
-        node.put(DESCRIPTOR_KEY, descriptor);
     }
     
     /**

Modified: trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -24,7 +24,7 @@
 
 import java.util.Collection;
 
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod;
 
 
 

Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -11,6 +11,8 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
+import org.teiid.metadata.FunctionMethod;
+
 @XmlType
 @XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
 public class FunctionMetadataReader {

Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -27,6 +27,9 @@
 
 import org.teiid.api.exception.query.FunctionMetadataException;
 import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.report.ActivityReport;
 
@@ -209,8 +212,8 @@
      * @param invocationMethod Invocation method to validate
      * @throws FunctionMetadataException Thrown if invocation method is not valid in some way
      */
-    public static final void validateInvocationMethod(String invocationClass, String invocationMethod, int pushdown) throws FunctionMetadataException {
-    	if (pushdown == FunctionMethod.CAN_PUSHDOWN || pushdown == FunctionMethod.CANNOT_PUSHDOWN) {
+    public static final void validateInvocationMethod(String invocationClass, String invocationMethod, PushDown pushdown) throws FunctionMetadataException {
+    	if (pushdown == PushDown.CAN_PUSHDOWN || pushdown == PushDown.CANNOT_PUSHDOWN) {
             validateIsNotNull(invocationClass, "Invocation class"); //$NON-NLS-1$
             validateIsNotNull(invocationMethod, "Invocation method"); //$NON-NLS-1$
             validateJavaIdentifier(invocationClass, "Invocation class", true); //$NON-NLS-1$

Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,94 +22,17 @@
 
 package org.teiid.query.function.metadata;
 
-import java.io.Serializable;
-import java.util.Arrays;
+import org.teiid.metadata.FunctionParameter;
 
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
 
-import org.teiid.core.util.HashCodeUtil;
-
-
 /**
- * <p>This class represents information about a particular function signature.  
- * Function signatures are unique with respect to their name, # of arguments, 
- * and type of arguments. Return type and argument names are not uniqueness
- * factors.  This class makes no attempt to validate the data put into it, 
- * particularly with respect to null values.  The 
- * {@link FunctionMetadataValidator} can be used to validate this object.</p>
- *
- * Attributes:
- * <UL>
- * <LI>name - Name of the function</LI>
- * <LI>description - Description of the function</LI>
- * <LI>category - Function category containing this function</LI>
- * <LI>pushdown - Determine whether this function can, cannot, or must be pushed down to a source</LI>
- * <LI>invocationClass - Class containing method implementing this function</LI>
- * <LI>invocationMethod - Method implementing this function</LI>
- * <LI>inputParameters - 0 or more input parameters</LI>
- * <LI>outputParameter - 1 output parameter</LI>
- * </UL>
- *
- * @see FunctionParameter
  * @see FunctionMetadataValidator
  * @see FunctionCategoryConstants
  */
-public class FunctionMethod implements Serializable {
-	private static final long serialVersionUID = -8039086494296455152L;
+public class FunctionMethod extends org.teiid.metadata.FunctionMethod {
+	private static final long serialVersionUID = -2380536393719646754L;
 
-	private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
-	private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
-	private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
-
-    public static final int CAN_PUSHDOWN = 0;
-    public static final int CANNOT_PUSHDOWN = 1;
-    public static final int MUST_PUSHDOWN = 2;
-    public static final int SYNTHETIC = 3;
-    
-    /*
-     * always -> normal deterministic functions
-     * vdb -> lookup (however lookup values can be flushed at any time), current_database
-     * session -> env, user
-     * command -> command payload
-     * never -> rand, etc.
-     * 
-     * Anything at a session level and above is treated as deterministic.
-     * This is not quite correct for lookup or env.  Only in extremely rare
-     * circumstances would that be a problem.
-     * 
-     * For now the commandPayload function is treated as a special case, like lookup, in
-     * that it is considered deterministic, but will be delayed in its evaluation until
-     * processing time.
-     */
-    public static final int DETERMINISTIC = 0;
-    public static final int VDB_DETERMINISTIC = 1;
-    public static final int USER_DETERMINISTIC = 2;
-    public static final int SESSION_DETERMINISTIC = 3;
-    public static final int COMMAND_DETERMINISTIC = 4;
-    public static final int NONDETERMINISTIC = 5;
-    
-
-    private String name;
-    private String description;
-    private String category;
-    private int pushdown = CAN_PUSHDOWN;
-    private String invocationClass;
-    private String invocationMethod;
-    private boolean nullDependent;
-    
-    private int deterministic = DETERMINISTIC;
-        
-    private FunctionParameter[] inputParameters;
-    private FunctionParameter outputParameter;
-    
-    /**
-     * Construct a new empty function method.
-     */
-    public FunctionMethod() {
-    }
-
-    /**
+	/**
      * Construct a function method with default pushdown and null dependent attributes.
      * @param name Function name
      * @param description Function description
@@ -122,8 +45,7 @@
     public FunctionMethod(String name, String description, String category, 
         String invocationClass, String invocationMethod, 
         FunctionParameter[] inputParams, FunctionParameter outputParam) {
-        
-        this(name, description, category, invocationClass, invocationMethod, inputParams, outputParam, DETERMINISTIC);
+        this(name, description, category, invocationClass, invocationMethod, inputParams, outputParam, Determinism.DETERMINISTIC);
     }
     
     /**
@@ -138,9 +60,8 @@
      */
     public FunctionMethod(String name, String description, String category, 
         String invocationClass, String invocationMethod, 
-        FunctionParameter[] inputParams, FunctionParameter outputParam, int deterministic) {
-        
-        this(name, description, category, CAN_PUSHDOWN, invocationClass, invocationMethod, inputParams, outputParam, false, deterministic);
+        FunctionParameter[] inputParams, FunctionParameter outputParam, Determinism deterministic) {
+        super(name, description, category, PushDown.CAN_PUSHDOWN, invocationClass, invocationMethod, inputParams, outputParam, false, deterministic);
     }
 
     /**
@@ -154,365 +75,25 @@
      * @param outputParam Output parameter (return parameter)
      */
     public FunctionMethod(String name, String description, String category, 
-        int pushdown, String invocationClass, String invocationMethod, 
+        PushDown pushdown, String invocationClass, String invocationMethod, 
         FunctionParameter[] inputParams, FunctionParameter outputParam) {
-        
-        this(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, true, NONDETERMINISTIC);
+        super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, true,Determinism.NONDETERMINISTIC);
     }
     
-    /**
-     * Construct a function method with all parameters.
-     * @param name Function name
-     * @param description Function description
-     * @param category Function category
-     * @param invocationClass Invocation class
-     * @param invocationMethod Invocation method
-     * @param inputParams Input parameters
-     * @param outputParam Output parameter (return parameter)
-     */
+    public FunctionMethod(String name, String description, String category, FunctionParameter[] inputParams, FunctionParameter outputParam) {
+    	super(name, description, category, PushDown.MUST_PUSHDOWN, null, null, inputParams, outputParam, false, Determinism.DETERMINISTIC);
+    } 
+    
     public FunctionMethod(String name,
-                          String description,
-                          String category,
-                          int pushdown,
-                          String invocationClass,
-                          String invocationMethod,
-                          FunctionParameter[] inputParams,
-                          FunctionParameter outputParam,
-                          boolean nullDependent,
-                          int deterministic) {
-        
-        setName(name);
-        setDescription(description);
-        setCategory(category);
-        setPushdown(pushdown);
-        setInvocationClass(invocationClass);
-        setInvocationMethod(invocationMethod);
-        setInputParameters(inputParams);
-        setOutputParameter(outputParam); 
-        setNullDependent(nullDependent);
-        setDeterministic(deterministic);
+            String description,
+            String category,
+            PushDown pushdown,
+            String invocationClass,
+            String invocationMethod,
+            FunctionParameter[] inputParams,
+            FunctionParameter outputParam,
+            boolean nullDependent,
+            Determinism deterministic) {
+    	super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, nullDependent, deterministic);
     }
-    
-    /**
-     * Return name of method
-     * @return Name
-     */
-    @XmlAttribute
-    public String getName() {
-        return this.name;
-    }
-    
-    /**
-     * Set name of method
-     * @param name Name
-     */
-    public void setName(String name) { 
-        this.name = name;
-    }
-    
-    /**
-     * Get description of method
-     * @return Description
-     */
-    @XmlAttribute
-    public String getDescription() { 
-        return this.description;
-    }        
-    
-    /**
-     * Set description of method
-     * @param description Description
-     */
-    public void setDescription(String description) { 
-        this.description = description;
-    }
-
-    /**
-     * Get category of method
-     * @return Category
-     * @see FunctionCategoryConstants
-     */
-    @XmlAttribute
-    public String getCategory() { 
-        return this.category;
-    }        
-    
-    /**
-     * Set category of method
-     * @param category Category
-     * @see FunctionCategoryConstants
-     */
-    public void setCategory(String category) { 
-        this.category = category;
-    }
-    
-    /**
-     * Get pushdown property of method
-     * @return One of the FunctionMethod constants for pushdown
-     */
-    public int getPushdown() {
-        return pushdown;
-    }
-
-    /**
-     * Set pushdown property of method
-     * @param pushdown One of the FunctionMethod constants for pushdown
-     */
-    public void setPushdown(int pushdown) {
-        this.pushdown = pushdown;
-    }
-    
-    @XmlAttribute
-    public void setPushDown(String pushdown) {
-    	if (pushdown != null) {
-			if (pushdown.equals(REQUIRED)) {
-				this.pushdown = FunctionMethod.MUST_PUSHDOWN;
-			} else if (pushdown.equals(ALLOWED)) {
-				this.pushdown = FunctionMethod.CAN_PUSHDOWN;
-			} else if (pushdown.equals(NOT_ALLOWED)) {
-				this.pushdown = FunctionMethod.CANNOT_PUSHDOWN;
-			}
-		} else {
-			this.pushdown = FunctionMethod.CAN_PUSHDOWN;
-		}
-    }
-    
-    /**
-     * Get invocation class name
-     * @return Invocation class name
-     */
-    @XmlAttribute
-    public String getInvocationClass() { 
-        return this.invocationClass;
-    }        
-    
-    /**
-     * Set invocation class name
-     * @param invocationClass Invocation class name
-     */
-    public void setInvocationClass(String invocationClass) { 
-        this.invocationClass = invocationClass;
-    }
-    
-    /**
-     * Get invocation method name
-     * @return Invocation method name
-     */
-    @XmlAttribute
-    public String getInvocationMethod() { 
-        return this.invocationMethod;
-    }        
-    
-    /**
-     * Set invocation method name
-     * @param invocationMethod Invocation method name
-     */
-    public void setInvocationMethod(String invocationMethod) { 
-        this.invocationMethod = invocationMethod;
-    }
-    
-    /**
-     * Get a count of the input parameters.
-     * @return Number of input parameters
-     */
-    public int getInputParameterCount() {
-        if(this.inputParameters == null) { 
-            return 0;
-        }
-        return this.inputParameters.length;
-    }
-    
-    /**
-     * Get input parameters
-     * @return Array of input parameters, may be null if 0 parameters
-     */
-    @XmlElement
-    public FunctionParameter[] getInputParameters() { 
-        return this.inputParameters;
-    }
-    
-    /**
-     * Set input parameters.
-     * @param params Input parameters
-     */
-    public void setInputParameters(FunctionParameter[] params) { 
-        this.inputParameters = params;
-    }
-    
-    /**
-     * Get ouput parameter.
-     * @return Output parameter or return argument
-     */
-    @XmlElement(name="returnParameter")
-    public FunctionParameter getOutputParameter() { 
-        return this.outputParameter;
-    }
-    
-    /**
-     * Set ouput parameter.
-     * @param param Output Parameter
-     */
-    public void setOutputParameter(FunctionParameter param) {
-    	if (param != null) {
-    		param.setName(FunctionParameter.OUTPUT_PARAMETER_NAME);
-    	}
-        this.outputParameter = param;
-    }
-    
-    /**
-     * Get hash code for this object.  The hash code is based on the name 
-     * and input parameters.  <B>WARNING: Changing the name or input parameters
-     * will change the hash code.</B>  If this occurs after the object has been
-     * placed in a HashSet or HashMap, the object will be lost!!!!  In that 
-     * case, the object must be added to the hashed collection again.
-     * @return Hash code, based on name and input parameters
-     */
-    public int hashCode() { 
-        int hash = HashCodeUtil.hashCode(0, name);
-        if(inputParameters != null) { 
-            hash = HashCodeUtil.hashCode(hash, Arrays.hashCode(inputParameters));
-        }             
-        return hash;
-    }
-    
-    /**
-     * Compare other object for equality.  This object is equal to another 
-     * FunctionMethod if 1) Name of function matches (case-insensitive), 
-     * 2) number of input parameters matches and 3) types of input parameters
-     * match.
-     * @return True if object equals this object according to conditions
-     */
-    public boolean equals(Object obj) {
-        if(obj == this) { 
-            return true;
-        } 
-        if(obj instanceof FunctionMethod) { 
-            FunctionMethod other = (FunctionMethod) obj;
-
-            // Compare # of parameters - do this first as it is much faster than name compare
-            if(getInputParameterCount() != other.getInputParameterCount()) {
-                return false;
-            }
-
-            // Compare function names - case insensitive
-            if(other.getName() == null || this.getName() == null) { 
-                return false;
-            }
-            if(! other.getName().equalsIgnoreCase(this.getName()) ) {
-                return false;
-            }
-            
-            // Compare types of parameters
-            FunctionParameter[] thisInputs = this.getInputParameters();
-            if(thisInputs != null && thisInputs.length > 0) { 
-                // If thisInputs is not null and >0 and other parameter
-                // count matched this parameter count, otherInputs MUST be 
-                // non null to have more than one parameter - so we don't 
-                // need to check it here.
-                FunctionParameter[] otherInputs = other.getInputParameters();
-                
-                for(int i=0; i<thisInputs.length; i++) { 
-                    boolean paramMatch = compareWithNull(thisInputs[i], otherInputs[i]);
-                    if(! paramMatch) { 
-                        return false;
-                    }    
-                }   
-            }    
-            
-            // Found no discrepancies, must be equal
-            return true;            
-        } 
-        return false;
-    }    
-    
-    /**
-     * Compare two objects that may or may not be null and consider null==null
-     * as true.
-     * @param o1 Object 1
-     * @param o2 Object 2
-     * @return True if o1 and o2 are null or if they both aren't and they are equal
-     */
-    private boolean compareWithNull(Object o1, Object o2) {
-        if(o1 == null) { 
-            if(o2 == null) { 
-                return true;
-            }
-            return false;
-        }
-        if(o2 == null) { 
-            return false;
-        }
-        return o1.equals(o2);
-    }
-    
-    /**
-     * Return string version for debugging purposes
-     * @return String representation of function method
-     */ 
-    public String toString() { 
-        StringBuffer str = new StringBuffer();
-        if(name != null) { 
-            str.append(name);
-        } else {
-            str.append("<unknown>"); //$NON-NLS-1$
-        } 
-        
-        // Print parameters
-        str.append("("); //$NON-NLS-1$
-        if(inputParameters != null) { 
-            for(int i=0; i<inputParameters.length; i++) {
-                if(inputParameters[i] != null) { 
-                    str.append(inputParameters[i].toString());                   
-                } else {
-                    str.append("<unknown>"); //$NON-NLS-1$
-                }
-                
-                if(i < (inputParameters.length-1)) { 
-                    str.append(", "); //$NON-NLS-1$
-                }
-            }    
-        }                                
-        str.append(") : "); //$NON-NLS-1$
-        
-        // Print return type
-        if(outputParameter != null) { 
-            str.append(outputParameter.toString());
-        } else {
-            str.append("<unknown>"); //$NON-NLS-1$
-        }
-        
-        return str.toString();
-    }
-
-    /**
-     * Returns true if the function can produce a non-null output from a null parameter
-     */
-    public boolean isNullDependent() {
-        return this.nullDependent;
-    }
-    
-    public void setNullDependent(boolean nullSafe) {
-        this.nullDependent = nullSafe;
-    }
-
-    public int getDeterministic() {
-        return this.deterministic;
-    }
-    
-    @XmlAttribute(name="deterministic")
-    public void setDeterministicBoolean(boolean deterministic) {
-    	this.deterministic = deterministic ? FunctionMethod.DETERMINISTIC : FunctionMethod.NONDETERMINISTIC;
-    }
-    
-    public void setDeterministic(int deterministic) {
-        this.deterministic = deterministic;
-    }
-    
-    public boolean isVarArgs() {
-    	if (this.inputParameters != null && this.inputParameters.length > 0) {
-    		return inputParameters[inputParameters.length - 1].isVarArg();
-    	}
-    	return false;
-    }
-     
 }

Deleted: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -1,183 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.query.function.metadata;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlAttribute;
-
-/**
- * A function parameter defines the name and description of an input or output
- * parameter for a function.  The name should not be null, but that is not 
- * verified by this class.  Validation of this object can be done with the 
- * {@link FunctionMetadataValidator}.  The type string used in the function
- * parameter should be one of the standard type names defined in 
- * {@link org.teiid.core.types.DataTypeManager.DefaultDataTypes}.
- */
-public class FunctionParameter implements Serializable {
-	public static final String OUTPUT_PARAMETER_NAME = "result"; //$NON-NLS-1$
-	
-    private String name;  
-    private String type;
-    private String description;
-    private boolean isVarArg;
-
-    /**
-     * Construct a function parameter with no attributes.
-     */
-    public FunctionParameter() {
-    }
-
-    /**
-     * Construct a function parameter with no description.
-     * @param name Name
-     * @param type Type from standard set of types
-     */
-    public FunctionParameter(String name, String type) {
-        this(name, type, null);
-    }
-    
-    /**
-     * Construct a function parameter with all attributes.  
-     * @param name Name
-     * @param type Type from standard set of types
-     * @param description Description
-     */
-    public FunctionParameter(String name, String type, String description) { 
-        this(name, type, description, false);
-    }
-    
-    public FunctionParameter(String name, String type, String description, boolean vararg) { 
-        setName(name);
-        setType(type);
-        setDescription(description);
-        this.isVarArg = vararg;
-    }
-    
-    /**
-     * Return name of parameter.
-     * @return Name
-     */
-    @XmlAttribute
-    public String getName() {
-        return this.name;
-    }
-    
-    /**
-     * Set name
-     * @param name Name
-     */
-    public void setName(String name) { 
-        this.name = name;
-    }
-    
-    /**
-     * Get description of parameter
-     * @return Description
-     */
-    @XmlAttribute
-    public String getDescription() { 
-        return this.description;
-    }        
-    
-    /**
-     * Set description of parameter
-     * @param description Description
-     */
-    public void setDescription(String description) { 
-        this.description = description;
-    }
-       
-    /**
-     * Get type of parameter
-     * @return Type name
-     * @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
-     */
-    @XmlAttribute
-    public String getType() { 
-        return this.type;
-    }        
-    
-    /**
-     * Set type of parameter
-     * @param type Type of parameter
-     * @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
-     */
-    public void setType(String type) {
-        if(type == null) { 
-            this.type = null;
-        } else {
-            this.type = type.toLowerCase();
-        } 
-    }
-       
-    /**
-     * Return hash code for this parameter.  The hash code is based only 
-     * on the type of the parameter.  Changing the type of the parameter 
-     * after placing this object in a hashed collection will likely cause
-     * the object to be lost.
-     * @return Hash code
-     */   
-    public int hashCode() { 
-        if(this.type == null) { 
-            return 0;
-        }
-        return this.type.hashCode();
-    }
-    
-    /**
-     * Compare with other object for equality.  Equality is based on whether
-     * the type is the same as the other parameter.
-     * @return True if equal to obj
-     */   
-    public boolean equals(Object obj) {
-        if(obj == this) { 
-            return true;
-        } 
-        if(!(obj instanceof FunctionParameter)) {
-        	return false;
-        }
-        FunctionParameter other = (FunctionParameter) obj;
-        if(other.getType() == null) { 
-            return (this.getType() == null);
-        }
-        return other.getType().equals(this.getType()) && this.isVarArg == other.isVarArg;
-    }
-       
-    /**
-     * Return string version for debugging purposes
-     * @return String representation of function parameter
-     */ 
-    public String toString() { 
-        return type + (isVarArg?"... ":" ") + name; //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-	public void setVarArg(boolean isVarArg) {
-		this.isVarArg = isVarArg;
-	}
-
-	public boolean isVarArg() {
-		return isVarArg;
-	}
-        
-}

Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,6 +22,7 @@
 
 package org.teiid.query.function.metadata;
 
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.query.report.ReportItem;
 
 /**

Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -28,13 +28,15 @@
 import java.util.List;
 
 import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.function.FunctionLibrary;
 import org.teiid.query.function.FunctionMetadataSource;
 import org.teiid.query.function.FunctionMethods;
 import org.teiid.query.function.metadata.FunctionCategoryConstants;
 import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
 import org.teiid.translator.SourceSystemFunctions;
 
 
@@ -50,7 +52,7 @@
     private static final String SECURITY_FUNCTION_CLASS = SecuritySystemFunctions.class.getName(); 
     
     /** Cached list of system function metadata, created in constructor */
-    private List<FunctionMethod> functions = new ArrayList<FunctionMethod>();
+    private List<org.teiid.metadata.FunctionMethod> functions = new ArrayList<org.teiid.metadata.FunctionMethod>();
     
     /**
      * Construct a source of system metadata.
@@ -192,16 +194,16 @@
     }
 
     private void addSecurityFunctions() {
-        functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, FunctionMethod.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, PushDown.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                                         new FunctionParameter[] { 
                                             new FunctionParameter("roleType", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                                             new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$ 
-                                        new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, FunctionMethod.USER_DETERMINISTIC ) );       //$NON-NLS-1$ //$NON-NLS-2$
+                                        new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, Determinism.USER_DETERMINISTIC ) );       //$NON-NLS-1$ //$NON-NLS-2$
         
-        functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, FunctionMethod.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, PushDown.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                 new FunctionParameter[] { 
                     new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$ 
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, FunctionMethod.USER_DETERMINISTIC ) );       //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, Determinism.USER_DETERMINISTIC ) );       //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     private void addFormatNumberFunctions() {
@@ -261,13 +263,13 @@
         // With Seed
         FunctionMethod rand = new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ 
                                           new FunctionParameter[] {new FunctionParameter("seed", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rand_arg")) }, //$NON-NLS-1$ //$NON-NLS-2$
-                                          new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), FunctionMethod.NONDETERMINISTIC );                 //$NON-NLS-1$ //$NON-NLS-2$
-        rand.setNullDependent(true);
+                                          new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), Determinism.NONDETERMINISTIC );                 //$NON-NLS-1$ //$NON-NLS-2$
+        rand.setNullOnNull(true);
         functions.add(rand);
         // Without Seed
         functions.add( new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ 
                                           new FunctionParameter[] {}, 
-                                          new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), FunctionMethod.NONDETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$                
+                                          new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), Determinism.NONDETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$                
     }
 
 	private void addDoubleFunction(String name, String description) {
@@ -375,7 +377,7 @@
         functions.add(
             new FunctionMethod(name, description, DATETIME, FUNCTION_CLASS, methodName,
                 new FunctionParameter[] {},
-                new FunctionParameter("result", returnType, description), FunctionMethod.COMMAND_DETERMINISTIC ) );                 //$NON-NLS-1$
+                new FunctionParameter("result", returnType, description), Determinism.COMMAND_DETERMINISTIC ) );                 //$NON-NLS-1$
     }
 
     private void addDateFunction(String name, String methodName, String dateDesc, String timestampDesc, String returnType) {
@@ -406,14 +408,14 @@
 
 	private void addTimestampAddFunction() {
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ 
+			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ 
 				new FunctionParameter[] {
 					new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg1")),  //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg2")),  //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$  
+			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$  
 				new FunctionParameter[] {
 					new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg1")),  //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg2")),  //$NON-NLS-1$ //$NON-NLS-2$
@@ -470,10 +472,10 @@
     
     private void addClobFunction(String name, String description, String methodName, String returnType) {
         functions.add(
-            new FunctionMethod(name, description, STRING, FunctionMethod.MUST_PUSHDOWN, FUNCTION_CLASS, methodName,
+            new FunctionMethod(name, description, STRING, PushDown.MUST_PUSHDOWN, FUNCTION_CLASS, methodName,
                 new FunctionParameter[] {
                     new FunctionParameter("clob", DataTypeManager.DefaultDataTypes.CLOB, QueryPlugin.Util.getString("SystemSource.Clobfunc_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
-                new FunctionParameter("result", returnType, description), false, FunctionMethod.DETERMINISTIC ) );                 //$NON-NLS-1$
+                new FunctionParameter("result", returnType, description), false, Determinism.DETERMINISTIC ) );                 //$NON-NLS-1$
     }
 
     private void addConcatFunction() {
@@ -490,11 +492,11 @@
                     new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concatop_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concatop_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
         
-        FunctionMethod concat2 = new FunctionMethod("concat2", QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ //$NON-NLS-2$ 
+        FunctionMethod concat2 = new FunctionMethod("concat2", QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ //$NON-NLS-2$ 
                            new FunctionParameter[] {
                                new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                                new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
-                           new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")), true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+                           new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")), true, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(concat2);                         
     }
 
@@ -537,7 +539,7 @@
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_result")) );                 //$NON-NLS-1$ //$NON-NLS-2$
-        func.setNullDependent(true);
+        func.setNullOnNull(true);
         functions.add(func);
         functions.add(
             new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate2_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ 
@@ -568,7 +570,7 @@
 
 	private void addSpaceFunction() {
 		functions.add(
-			new FunctionMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ 
+			new FunctionMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ 
 				new FunctionParameter[] {
 					new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Space_arg1"))}, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Space_result")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
@@ -740,14 +742,14 @@
         
     private void addDecodeFunction(String functionName, String resultType) {
         functions.add(
-            new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode1_desc"), MISCELLANEOUS, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
+            new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode1_desc"), MISCELLANEOUS, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
                 new FunctionParameter[] { 
                     new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", resultType, QueryPlugin.Util.getString("SystemSource.Decode1_result") ) ) );    //$NON-NLS-1$ //$NON-NLS-2$
                      
         functions.add(
-            new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode2_desc"), MISCELLANEOUS, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
+            new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode2_desc"), MISCELLANEOUS, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
                 new FunctionParameter[] { 
                     new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -759,55 +761,55 @@
     private void addLookupFunctions() {
     	for (String keyValueType : DataTypeManager.getAllDataTypeNames()) {
             functions.add(
-                    new FunctionMethod("lookup", QueryPlugin.Util.getString("SystemSource.Lookup_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "lookup", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    new FunctionMethod("lookup", QueryPlugin.Util.getString("SystemSource.Lookup_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "lookup", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                         new FunctionParameter[] {
                             new FunctionParameter("codetable", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lookup_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                             new FunctionParameter("returnelement", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lookup_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
                             new FunctionParameter("keyelement", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lookup_arg3")), //$NON-NLS-1$ //$NON-NLS-2$
                             new FunctionParameter("keyvalue", keyValueType, QueryPlugin.Util.getString("SystemSource.Lookup_arg4")), //$NON-NLS-1$ //$NON-NLS-2$
                              },
-                        new FunctionParameter("result", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.Lookup_result")), true, FunctionMethod.VDB_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
+                        new FunctionParameter("result", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.Lookup_result")), true, Determinism.VDB_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
     	}
     }
 
     private void addUserFunction() {
         functions.add(
-            new FunctionMethod("user", QueryPlugin.Util.getString("SystemSource.User_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "user", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), false, FunctionMethod.USER_DETERMINISTIC) );                     //$NON-NLS-1$ //$NON-NLS-2$
+            new FunctionMethod("user", QueryPlugin.Util.getString("SystemSource.User_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "user", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), false, Determinism.USER_DETERMINISTIC) );                     //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addCurrentDatabaseFunction() {
         functions.add(
-            new FunctionMethod("current_database", QueryPlugin.Util.getString("SystemSource.current_database_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "current_database", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("current_database_result")), false, FunctionMethod.VDB_DETERMINISTIC) );                     //$NON-NLS-1$ //$NON-NLS-2$
+            new FunctionMethod("current_database", QueryPlugin.Util.getString("SystemSource.current_database_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "current_database", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("current_database_result")), false, Determinism.VDB_DETERMINISTIC) );                     //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
     private void addEnvFunction() {
         functions.add(
-            new FunctionMethod("env", QueryPlugin.Util.getString("SystemSource.Env_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "env", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod("env", QueryPlugin.Util.getString("SystemSource.Env_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "env", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                 new FunctionParameter[] {
                     new FunctionParameter("variablename", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_varname")) //$NON-NLS-1$ //$NON-NLS-2$
                      },
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_result")), false, FunctionMethod.SESSION_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_result")), false, Determinism.SESSION_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addSessionIdFunction() {
         functions.add(
-            new FunctionMethod(FunctionLibrary.SESSION_ID, QueryPlugin.Util.getString("SystemSource.session_id_desc"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "session_id", null, //$NON-NLS-1$ //$NON-NLS-2$ 
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.session_id_result")), false, FunctionMethod.SESSION_DETERMINISTIC) );                     //$NON-NLS-1$ //$NON-NLS-2$
+            new FunctionMethod(FunctionLibrary.SESSION_ID, QueryPlugin.Util.getString("SystemSource.session_id_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "session_id", null, //$NON-NLS-1$ //$NON-NLS-2$ 
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.session_id_result")), false, Determinism.SESSION_DETERMINISTIC) );                     //$NON-NLS-1$ //$NON-NLS-2$
     }    
     
     private void addCommandPayloadFunctions() {
         functions.add(
-            new FunctionMethod("commandpayload", QueryPlugin.Util.getString("SystemSource.CommandPayload_desc0"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod("commandpayload", QueryPlugin.Util.getString("SystemSource.CommandPayload_desc0"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                  new FunctionParameter[] {},
-                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, FunctionMethod.COMMAND_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
+                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, Determinism.COMMAND_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod("commandpayload", QueryPlugin.Util.getString("SystemSource.CommandPayload_desc1"), MISCELLANEOUS, FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod("commandpayload", QueryPlugin.Util.getString("SystemSource.CommandPayload_desc1"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                  new FunctionParameter[] {
                      new FunctionParameter("property", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_property")) //$NON-NLS-1$ //$NON-NLS-2$
                       },
-                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, FunctionMethod.COMMAND_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
+                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, Determinism.COMMAND_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addIfNullFunctions() {
@@ -824,7 +826,7 @@
                     new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_result")) ); //$NON-NLS-1$ //$NON-NLS-2$
-        nvl.setNullDependent(true);
+        nvl.setNullOnNull(true);
         functions.add(nvl); 
     }
 
@@ -835,7 +837,7 @@
 					new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_result")) ); //$NON-NLS-1$ //$NON-NLS-2$
-        nvl.setNullDependent(true);
+        nvl.setNullOnNull(true);
         functions.add(nvl); 
 	}
 			
@@ -847,13 +849,13 @@
 					new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattimestamp_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattimestamp_result_desc")) ) );       //$NON-NLS-1$ //$NON-NLS-2$
 		functions.add(
-				new FunctionMethod(FunctionLibrary.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"),CONVERSION, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
+				new FunctionMethod(FunctionLibrary.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
 					new FunctionParameter[] { 
 						new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Formatdate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 						new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formatdate_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formatdate_result_desc")) ) );       //$NON-NLS-1$ //$NON-NLS-2$
 		functions.add(
-				new FunctionMethod(FunctionLibrary.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"),CONVERSION, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
+				new FunctionMethod(FunctionLibrary.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
 					new FunctionParameter[] { 
 						new FunctionParameter("time", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Formattime_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 						new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattime_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -868,13 +870,13 @@
 					new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_result_desc")) ) );       //$NON-NLS-1$ //$NON-NLS-2$
 		functions.add(
-				new FunctionMethod(FunctionLibrary.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"),CONVERSION, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
+				new FunctionMethod(FunctionLibrary.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
 					new FunctionParameter[] { 
 						new FunctionParameter("time", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetime_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 						new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetime_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Parsetime_result_desc")) ) );       //$NON-NLS-1$ //$NON-NLS-2$
 		functions.add(
-				new FunctionMethod(FunctionLibrary.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"),CONVERSION, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
+				new FunctionMethod(FunctionLibrary.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
 					new FunctionParameter[] { 
 						new FunctionParameter("date", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsedate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 						new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsedate_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -985,11 +987,11 @@
     }
     
     private void addXmlConcat() {
-        functions.add(new FunctionMethod(SourceSystemFunctions.XMLCONCAT, QueryPlugin.Util.getString("SystemSource.xmlconcat_description"), XML, FunctionMethod.CAN_PUSHDOWN, XML_FUNCTION_CLASS, "xmlConcat", //$NON-NLS-1$ //$NON-NLS-2$  
+        functions.add(new FunctionMethod(SourceSystemFunctions.XMLCONCAT, QueryPlugin.Util.getString("SystemSource.xmlconcat_description"), XML, PushDown.CAN_PUSHDOWN, XML_FUNCTION_CLASS, "xmlConcat", //$NON-NLS-1$ //$NON-NLS-2$  
                             new FunctionParameter[] { 
                                 new FunctionParameter("param1", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                                 new FunctionParameter("param2", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_param2"), true)}, //$NON-NLS-1$ //$NON-NLS-2$ 
-                            new FunctionParameter("result", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_result")), true, FunctionMethod.DETERMINISTIC ) );       //$NON-NLS-1$ //$NON-NLS-2$
+                            new FunctionParameter("result", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_result")), true, Determinism.DETERMINISTIC ) );       //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addTimeZoneFunctions() {
@@ -1009,37 +1011,37 @@
     }
     
     private void addUnixTimeFunctions() {
-    	functions.add(new FunctionMethod(FunctionLibrary.FROM_UNIXTIME, QueryPlugin.Util.getString("SystemSource.from_unixtime_description"), DATETIME, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ 
+    	functions.add(new FunctionMethod(FunctionLibrary.FROM_UNIXTIME, QueryPlugin.Util.getString("SystemSource.from_unixtime_description"), DATETIME, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ 
     			new FunctionParameter[] {
     				new FunctionParameter("unix_timestamp", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.from_unixtime_param1")) //$NON-NLS-1$ //$NON-NLS-2$
     			},
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.from_unixtime_result")), false, FunctionMethod.DETERMINISTIC )); //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.from_unixtime_result")), false, Determinism.DETERMINISTIC )); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addTypedNullIfFunction(String type) {
         functions.add(
-            new FunctionMethod(FunctionLibrary.NULLIF, QueryPlugin.Util.getString("SystemSource.nullif_description"), MISCELLANEOUS, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ 
+            new FunctionMethod(FunctionLibrary.NULLIF, QueryPlugin.Util.getString("SystemSource.nullif_description"), MISCELLANEOUS, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ 
                 new FunctionParameter[] { 
                     new FunctionParameter("op1", type, QueryPlugin.Util.getString("SystemSource.nullif_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("op2", type, QueryPlugin.Util.getString("SystemSource.nullif_param1")) }, //$NON-NLS-1$ //$NON-NLS-2$
-                new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.nullif_result")), true, FunctionMethod.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.nullif_result")), true, Determinism.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addTypedCoalesceFunction(String type) {
         functions.add(
-            new FunctionMethod(FunctionLibrary.COALESCE, QueryPlugin.Util.getString("SystemSource.coalesce_description"), MISCELLANEOUS, FunctionMethod.CAN_PUSHDOWN, FUNCTION_CLASS, "coalesce", //$NON-NLS-1$ //$NON-NLS-2$
+            new FunctionMethod(FunctionLibrary.COALESCE, QueryPlugin.Util.getString("SystemSource.coalesce_description"), MISCELLANEOUS, PushDown.CAN_PUSHDOWN, FUNCTION_CLASS, "coalesce", //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter[] { 
                     new FunctionParameter("op1", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("op2", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("op3", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1"), true) }, //$NON-NLS-1$ //$NON-NLS-2$
-                new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.coalesce_result")), true, FunctionMethod.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.coalesce_result")), true, Determinism.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
     }
 		
     /**
      * Get all function signatures for this metadata source.
      * @return Unordered collection of {@link FunctionMethod}s
      */
-    public Collection<FunctionMethod> getFunctionMethods() {
+    public Collection<org.teiid.metadata.FunctionMethod> getFunctionMethods() {
         return this.functions;
 	}
     

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -65,8 +65,6 @@
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.function.FunctionLibrary;
 import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.UDFSource;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.mapping.relational.QueryNode;
 import org.teiid.query.mapping.xml.MappingDocument;
 import org.teiid.query.mapping.xml.MappingLoader;
@@ -144,7 +142,7 @@
      * TransformationMetadata constructor
      * @param context Object containing the info needed to lookup metadta.
      */
-    public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore store, Map<String, Resource> vdbEntries, Collection <FunctionMethod> udfMethods, FunctionTree systemFunctions) {
+    public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore store, Map<String, Resource> vdbEntries, FunctionTree systemFunctions, FunctionTree... udfFunctions) {
     	ArgCheck.isNotNull(store);
     	this.vdbMetaData = vdbMetadata;
         this.store = store;
@@ -153,10 +151,7 @@
         } else {
         	this.vdbEntries = vdbEntries;
         }
-        if (udfMethods == null) {
-        	udfMethods = Collections.emptyList();
-        }
-        this.functionLibrary = new FunctionLibrary(systemFunctions, new FunctionTree(new UDFSource(udfMethods), true));
+        this.functionLibrary = new FunctionLibrary(systemFunctions, udfFunctions);
     }
     
     //==================================================================================

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -34,6 +34,7 @@
 import org.teiid.core.id.IDGenerator;
 import org.teiid.core.id.IntegerIDFactory;
 import org.teiid.dqp.internal.process.PreparedPlan;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TempCapabilitiesFinder;
@@ -111,7 +112,7 @@
 				String fullName = metadata.getFullName(cupc.getVirtualGroup().getMetadataID());
 				PreparedPlan pp = context.getPlan(fullName);
 				if (pp == null) {
-					int determinismLevel = context.resetDeterminismLevel();
+					Determinism determinismLevel = context.resetDeterminismLevel();
 					ProcessorPlan plan = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
 					//note that this is not a full prepared plan.  It is not usable by user queries.
 					pp = new PreparedPlan();

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -27,9 +27,9 @@
 
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.core.TeiidComponentException;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.SupportConstants;
 import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
@@ -228,7 +228,7 @@
             if (EvaluatableVisitor.willBecomeConstant(obj, true)) { 
                 return; 
             }
-            if(obj.getFunctionDescriptor().getPushdown() == FunctionMethod.CANNOT_PUSHDOWN) {
+            if(obj.getFunctionDescriptor().getPushdown() == PushDown.CANNOT_PUSHDOWN) {
             	markInvalid(obj, "Function metadata indicates it cannot be pusheddown."); //$NON-NLS-1$
             	return;
             }

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -35,7 +35,7 @@
 
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.core.TeiidComponentException;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.relational.RelationalPlanner;
 import org.teiid.query.optimizer.relational.plantree.NodeConstants;
@@ -473,7 +473,7 @@
         Iterator functions = FunctionCollectorVisitor.getFunctions(expression, true).iterator();
         while (functions.hasNext()) {
             Function function = (Function)functions.next();
-            if (function.getFunctionDescriptor().getPushdown() == FunctionMethod.CANNOT_PUSHDOWN) {
+            if (function.getFunctionDescriptor().getPushdown() == PushDown.CANNOT_PUSHDOWN) {
                 return true;
             }
         }

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -32,8 +32,8 @@
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.api.exception.query.QueryPlannerException;
 import org.teiid.core.TeiidComponentException;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
 import org.teiid.query.optimizer.relational.OptimizerRule;
@@ -350,7 +350,7 @@
             // TEIID-16: We do not want to merge a non-deterministic scalar function
             Collection<Function> functions = FunctionCollectorVisitor.getFunctions(symbol, true, true);
            	for (Function function : functions) {
-           		if ( function.getFunctionDescriptor().getDeterministic() >= FunctionMethod.NONDETERMINISTIC ) {
+           		if ( function.getFunctionDescriptor().getDeterministic().isRestrictiveThanOrEqual(Determinism.NONDETERMINISTIC )) {
            			return false;
            		}
             }

Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -102,17 +102,6 @@
 		return sb.toString();
 	}
 	
-    String validateFunctionName(String id) throws ParseException {
-    	int length = id.length();
-        for(int i=0; i<length; i++) { 
-            char c = id.charAt(i);
-            if(! (c == '_' || StringUtil.isLetterOrDigit(c))) { 
-                throw new ParseException(QueryPlugin.Util.getString("SQLParser.Invalid_func", id)); //$NON-NLS-1$   
-            }
-        }
-        return id;
-    }
-
     /**
      * Check if this is a valid string literal
      * @param id Possible string literal

Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -27,8 +27,9 @@
 
 import java.util.TreeSet;
 
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.TempMetadataID;
 import org.teiid.query.sql.LanguageObject;
 import org.teiid.query.sql.LanguageVisitor;
@@ -63,16 +64,16 @@
 
 	private TreeSet<EvaluationLevel> levels = new TreeSet<EvaluationLevel>();
 	private EvaluationLevel targetLevel;
-	private int determinismLevel;
+	private Determinism determinismLevel = Determinism.DETERMINISTIC;
 	private boolean hasCorrelatedReferences;
 	    
     public void visit(Function obj) {
         this.setDeterminismLevel(obj.getFunctionDescriptor().getDeterministic());
-        if (obj.getFunctionDescriptor().getPushdown() == FunctionMethod.MUST_PUSHDOWN) {
+        if (obj.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN) {
             evaluationNotPossible(EvaluationLevel.PUSH_DOWN);
         } else if (obj.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)
         		//TODO: if we had the context here we could plan better for non-prepared requests
-        		|| obj.getFunctionDescriptor().getDeterministic() >= FunctionMethod.COMMAND_DETERMINISTIC) {
+        		|| obj.getFunctionDescriptor().getDeterministic().isRestrictiveThanOrEqual(Determinism.COMMAND_DETERMINISTIC)) {
             evaluationNotPossible(EvaluationLevel.PROCESSING);
         }
     }
@@ -84,8 +85,8 @@
     	}
     }
     
-    private void setDeterminismLevel(int value) {
-    	determinismLevel = Math.max(determinismLevel, value);
+    private void setDeterminismLevel(Determinism value) {
+    	determinismLevel =  Determinism.restrictiveOf(determinismLevel, value);
     }
     
     private void evaluationNotPossible(EvaluationLevel newLevel) {
@@ -196,7 +197,7 @@
         EvaluatableVisitor visitor = new EvaluatableVisitor();
         visitor.targetLevel = EvaluationLevel.PROCESSING;
         PreOrderNavigator.doVisit(obj, visitor);
-        if (pushdown && (visitor.hasCorrelatedReferences || visitor.determinismLevel >= FunctionMethod.NONDETERMINISTIC)) {
+        if (pushdown && (visitor.hasCorrelatedReferences || visitor.determinismLevel.isRestrictiveThanOrEqual(Determinism.NONDETERMINISTIC))) {
         	return false;
         }
         return visitor.isEvaluationPossible();

Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -57,10 +57,10 @@
 import org.teiid.language.SQLConstants.Reserved;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.eval.Evaluator;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.mapping.relational.QueryNode;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TempMetadataID;
@@ -277,7 +277,7 @@
 		option.setNoCache(true);
 		option.addNoCacheGroup(fullName);
 		proc.setOption(option);
-		int determinismLevel = context.resetDeterminismLevel();
+		Determinism determinismLevel = context.resetDeterminismLevel();
 		QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(proc.toString(), fullName.toUpperCase(), context);
 		qp.setNonBlocking(true);
 		BatchCollector bc = qp.createBatchCollector();
@@ -505,7 +505,7 @@
 					TupleBuffer tb = bc.collectTuples();
 					cr.setResults(tb);
 					touchTable(context, fullName, true);
-					this.distributedCache.put(cid, FunctionMethod.VDB_DETERMINISTIC, cr, info.getTtl());
+					this.distributedCache.put(cid, Determinism.VDB_DETERMINISTIC, cr, info.getTtl());
 					ts = tb.createIndexedTupleSource();
 				} else {
 					ts = new BatchCollector.BatchProducerTupleSource(qp);

Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -36,9 +36,9 @@
 import org.teiid.dqp.internal.process.PreparedPlan;
 import org.teiid.dqp.internal.process.SessionAwareCache;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.eval.SecurityFunctionEvaluator;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.optimizer.relational.PlanToProcessConverter;
 import org.teiid.query.parser.ParseInfo;
@@ -90,7 +90,7 @@
 	    
 	    private QueryProcessor.ProcessorFactory queryProcessorFactory;
 	        
-	    private int determinismLevel;
+	    private Determinism determinismLevel = Determinism.DETERMINISTIC;
 	    
 	    private Set<String> groups;
 	    
@@ -152,18 +152,18 @@
     	this.globalState = state;
     }
     
-    public int getDeterminismLevel() {
+    public Determinism getDeterminismLevel() {
 		return globalState.determinismLevel;
 	}
     
-    public int resetDeterminismLevel() {
-    	int result = globalState.determinismLevel;
-    	globalState.determinismLevel = 0;
+    public Determinism resetDeterminismLevel() {
+    	Determinism result = globalState.determinismLevel;
+    	globalState.determinismLevel = Determinism.DETERMINISTIC;
     	return result;
     }
     
-    public void setDeterminismLevel(int level) {
-    	globalState.determinismLevel = Math.max(globalState.determinismLevel, level);
+    public void setDeterminismLevel(Determinism level) {
+    	globalState.determinismLevel = Determinism.restrictiveOf(globalState.determinismLevel, level);
     }
     
     /**
@@ -485,16 +485,16 @@
     	PreparedPlan pp = this.globalState.planCache.get(id);
     	if (pp != null) {
     		if (id.getSessionId() != null) {
-    			setDeterminismLevel(FunctionMethod.USER_DETERMINISTIC);
+    			setDeterminismLevel(Determinism.USER_DETERMINISTIC);
     		} else if (id.getUserName() != null) {
-    			setDeterminismLevel(FunctionMethod.SESSION_DETERMINISTIC);
+    			setDeterminismLevel(Determinism.SESSION_DETERMINISTIC);
     		}
         	return pp;
     	}
     	return null;
     }
     
-    public void putPlan(String key, PreparedPlan plan, int determinismLevel) {
+    public void putPlan(String key, PreparedPlan plan, Determinism determinismLevel) {
     	if (this.globalState.planCache == null) {
     		return;
     	}

Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj	2010-12-03 18:46:01 UTC (rev 2754)
@@ -3539,9 +3539,6 @@
 		}
 	|   
 	(	funcName = id()
-		{ 
-			funcName = validateFunctionName(funcName);
-		}
 		<LPAREN>
 		[
 			expression = expression(info)

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -23,16 +23,22 @@
 package org.teiid.dqp.internal.process;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.TestCase;
 
 import org.mockito.Mockito;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
 import org.teiid.dqp.internal.datamgr.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
 import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
 import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.translator.ExecutionFactory;
 
 
 /**
@@ -77,4 +83,20 @@
         assertEquals("Did not get expected capabilities", true, actual.supportsFunction(functionName)); //$NON-NLS-1$
     }
 
+    
+    public void testPushdownFunctionSupport() throws Exception {
+    	ExecutionFactory<Object, Object> ef  = new ExecutionFactory<Object, Object>(){
+    	    public List<FunctionMethod> getPushDownFunctions(){
+    	    	ArrayList<FunctionMethod> list = new ArrayList<FunctionMethod>();
+    	    	list.add(new FunctionMethod("ns.func", "function", "misc",   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    	                new FunctionParameter[] {
+    	                new FunctionParameter("param", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+    	                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "" ) )); //$NON-NLS-1$ //$NON-NLS-2$    	    	
+    	    	return list;
+    	    }    		
+    	};
+    	
+    	BasicSourceCapabilities bsc = CapabilitiesConverter.convertCapabilities(ef, "conn"); //$NON-NLS-1$
+        assertEquals("Did not get expected capabilities", true, bsc.supportsFunction("ns.func")); //$NON-NLS-1$ //$NON-NLS-2$
+    }
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,7 +22,10 @@
 
 package org.teiid.dqp.internal.process;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 
@@ -30,8 +33,8 @@
 import org.junit.Test;
 import org.teiid.api.exception.query.QueryParserException;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.parser.ParseInfo;
 import org.teiid.query.parser.QueryParser;
 import org.teiid.query.processor.relational.ProjectNode;
@@ -62,7 +65,7 @@
     	//No PreparedPlan at the begining
     	assertNull(cache.get(id));
     	//create one
-    	cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, new PreparedPlan(), null);
+    	cache.put(id, Determinism.SESSION_DETERMINISTIC, new PreparedPlan(), null);
     	//should have one now
     	assertNotNull("Unable to get prepared plan from cache", cache.get(id)); //$NON-NLS-1$
     }
@@ -149,7 +152,7 @@
 	    	CacheID id = new CacheID(session, pi, dummy.toString());
 
 	    	PreparedPlan pPlan = new PreparedPlan();
-    		cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, pPlan, null);
+    		cache.put(id, Determinism.SESSION_DETERMINISTIC, pPlan, null);
     		pPlan.setCommand(dummy); 
     		pPlan.setPlan(new RelationalPlan(new ProjectNode(i)));
             AnalysisRecord analysisRecord = new AnalysisRecord(true, false);

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -21,6 +21,11 @@
  */
 package org.teiid.dqp.internal.process;
 
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.times;
+
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.teiid.adminapi.impl.SessionMetadata;
@@ -28,10 +33,8 @@
 import org.teiid.cache.Cache;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.parser.ParseInfo;
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
 
 
 @SuppressWarnings("nls")
@@ -47,7 +50,7 @@
 		Cachable result = Mockito.mock(Cachable.class);
 		
 		id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
-		cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, result, null);
+		cache.put(id, Determinism.SESSION_DETERMINISTIC, result, null);
 		
 		// make sure that in the case of session specific; we do not call prepare
 		// as session is local only call for distributed
@@ -71,7 +74,7 @@
 		Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
 		Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
 				
-		cache.put(id, FunctionMethod.USER_DETERMINISTIC, result, null);
+		cache.put(id, Determinism.USER_DETERMINISTIC, result, null);
 		
 		// make sure that in the case of session specific; we do not call prepare
 		// as session is local only call for distributed
@@ -97,7 +100,7 @@
 		Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
 		Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);		
 		
-		cache.put(id, FunctionMethod.VDB_DETERMINISTIC, result, null);
+		cache.put(id, Determinism.VDB_DETERMINISTIC, result, null);
 		
 		// make sure that in the case of session specific; we do not call prepare
 		// as session is local only call for distributed
@@ -124,7 +127,7 @@
 		Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);		
 		
 		id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
-		cache.put(id, FunctionMethod.VDB_DETERMINISTIC, result, null);
+		cache.put(id, Determinism.VDB_DETERMINISTIC, result, null);
 		
 		Object c = cache.get(id);
 		

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -28,7 +28,8 @@
 
 import org.teiid.core.types.DataTypeManager;
 import org.teiid.core.util.UnitTestUtil;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.Determinism;
+import org.teiid.metadata.FunctionMethod.PushDown;
 
 
 public class TestFunctionDescriptorImpl extends TestCase {
@@ -74,39 +75,39 @@
     }
     
     public void test1() throws Exception {
-        FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN, //$NON-NLS-1$
+        FunctionDescriptor f1 = new FunctionDescriptor("+", PushDown.CAN_PUSHDOWN, //$NON-NLS-1$
             new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
             DataTypeManager.DefaultDataClasses.INTEGER,
-            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2) , false, true, FunctionMethod.DETERMINISTIC);    //$NON-NLS-1$ //$NON-NLS-2$
+            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2) , false, true, Determinism.DETERMINISTIC);    //$NON-NLS-1$ //$NON-NLS-2$
             
         UnitTestUtil.helpTestEquivalence(0, f1, f1);             
     }
 
     public void test2() throws Exception  {
-        FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+        FunctionDescriptor f1 = new FunctionDescriptor("+", PushDown.CAN_PUSHDOWN,//$NON-NLS-1$
             new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
             DataTypeManager.DefaultDataClasses.INTEGER,
-            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
 
-        FunctionDescriptor f2 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+        FunctionDescriptor f2 = new FunctionDescriptor("+", PushDown.CAN_PUSHDOWN,//$NON-NLS-1$
             new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
             DataTypeManager.DefaultDataClasses.INTEGER,
-            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
 
         UnitTestUtil.helpTestEquivalence(0, f1, f2);
     }
     
     public void test3() throws Exception  {
-        FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+        FunctionDescriptor f1 = new FunctionDescriptor("+", PushDown.CAN_PUSHDOWN,//$NON-NLS-1$
             new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
             DataTypeManager.DefaultDataClasses.INTEGER,
-            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, false, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, false, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
 
         
-        FunctionDescriptor f2 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+        FunctionDescriptor f2 = new FunctionDescriptor("+", PushDown.CAN_PUSHDOWN,//$NON-NLS-1$
             new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
             DataTypeManager.DefaultDataClasses.INTEGER,
-            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+            lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
 
         assertNotSame("objects should not be equal", f1, f2); //$NON-NLS-1$
     }

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,7 +22,12 @@
 
 package org.teiid.query.function;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -56,7 +61,7 @@
 import org.teiid.core.util.ObjectConverterUtil;
 import org.teiid.core.util.TimestampWithTimezone;
 import org.teiid.language.SQLConstants.NonReserved;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.unittest.FakeMetadataFactory;
 import org.teiid.query.unittest.TimestampUtil;
 import org.teiid.query.util.CommandContext;
@@ -98,8 +103,8 @@
             public String getName() {
                 return fname;
             }
-            public int getPushdown() {
-                return FunctionMethod.CAN_PUSHDOWN;
+            public PushDown getPushdown() {
+                return PushDown.CAN_PUSHDOWN;
             }
             public Class[] getTypes() { 
                 return ftypes;

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -29,10 +29,13 @@
 import junit.framework.TestCase;
 
 import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.function.metadata.FunctionMetadataReader;
-import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
 
+ at SuppressWarnings("nls")
 public class TestFunctionMetadataReader extends TestCase {
 
 	public void testLoadFunctionMethods() throws Exception {
@@ -46,8 +49,8 @@
 				assertEquals("MyFunctions", m.getCategory());
 				assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
 				assertEquals("getProperty", m.getInvocationMethod());
-				assertEquals(FunctionMethod.CAN_PUSHDOWN, m.getPushdown());
-				assertEquals(FunctionMethod.DETERMINISTIC, m.getDeterministic());
+				assertEquals(PushDown.CAN_PUSHDOWN, m.getPushdown());
+				assertEquals(Determinism.DETERMINISTIC, m.getDeterminism());
 				assertNull(m.getDescription());
 				
 				assertEquals(1, m.getInputParameterCount());
@@ -65,8 +68,8 @@
 				assertEquals("MyFunctions", m.getCategory());
 				assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
 				assertEquals("getPropertyNoArgs", m.getInvocationMethod());
-				assertEquals(FunctionMethod.CANNOT_PUSHDOWN, m.getPushdown());
-				assertEquals(FunctionMethod.DETERMINISTIC, m.getDeterministic());
+				assertEquals(PushDown.CANNOT_PUSHDOWN, m.getPushdown());
+				assertEquals(Determinism.DETERMINISTIC, m.getDeterminism());
 				assertNull(m.getDescription());
 				
 				assertEquals(0, m.getInputParameterCount());
@@ -79,8 +82,8 @@
 				assertEquals("MyFunctions", m.getCategory());
 				assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
 				assertEquals("getPropertyNoArgs", m.getInvocationMethod());
-				assertEquals(FunctionMethod.CAN_PUSHDOWN, m.getPushdown());
-				assertEquals(FunctionMethod.NONDETERMINISTIC, m.getDeterministic());
+				assertEquals(PushDown.CAN_PUSHDOWN, m.getPushdown());
+				assertEquals(Determinism.NONDETERMINISTIC, m.getDeterminism());
 				assertNull(m.getDescription());
 				
 				assertEquals(0, m.getInputParameterCount());

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -33,9 +33,11 @@
 import org.mockito.Mockito;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.function.metadata.FunctionCategoryConstants;
-import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
 import org.teiid.query.function.source.SystemSource;
 import org.teiid.query.unittest.FakeMetadataFactory;
 
@@ -71,9 +73,9 @@
     
     @Test public void testLoadErrors() {
     	FunctionMethod method = new FunctionMethod(
-    			"dummy", null, null, FunctionMethod.CAN_PUSHDOWN, "nonexistentClass", "noMethod",  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+    			"dummy", null, null, PushDown.CAN_PUSHDOWN, "nonexistentClass", "noMethod",  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 	 	    	new FunctionParameter[0], 
-	 	    	new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING)); //$NON-NLS-1$
+	 	    	new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), false, Determinism.DETERMINISTIC); //$NON-NLS-1$
     	
     	//allowed, since we're not validating the class
     	new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method))));
@@ -133,12 +135,15 @@
     }
     
     @Test public void testNullCategory() {
+    	FunctionMethod method = new FunctionMethod(
+    			"dummy", null, null, PushDown.MUST_PUSHDOWN, "nonexistentClass", "noMethod",  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+	 	    	new FunctionParameter[0], 
+	 	    	new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$
+	 	    	false, Determinism.DETERMINISTIC);
+    	
+    	Collection<org.teiid.metadata.FunctionMethod> list = Arrays.asList(method);
     	FunctionMetadataSource fms = Mockito.mock(FunctionMetadataSource.class);
-    	Mockito.stub(fms.getFunctionMethods()).toReturn(Arrays.asList(new FunctionMethod(
-    			"dummy", null, null, FunctionMethod.MUST_PUSHDOWN, "nonexistentClass", "noMethod",  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-	 	    	new FunctionParameter[0], 
-	 	    	new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) //$NON-NLS-1$
-    	)));
+    	Mockito.stub(fms.getFunctionMethods()).toReturn(list);
     	FunctionTree ft = new FunctionTree(fms);
     	assertEquals(1, ft.getFunctionForms(FunctionCategoryConstants.MISCELLANEOUS).size());
     }

Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,13 +22,12 @@
 
 package org.teiid.query.function.metadata;
 
-import org.teiid.api.exception.query.FunctionMetadataException;
-import org.teiid.query.function.metadata.FunctionMetadataValidator;
-import org.teiid.query.function.metadata.FunctionMethod;
-
 import junit.framework.TestCase;
 
+import org.teiid.api.exception.query.FunctionMetadataException;
+import org.teiid.metadata.FunctionMethod.PushDown;
 
+
 public class TestFunctionMetadataValidator extends TestCase {
 
 	// ################################## FRAMEWORK ################################
@@ -55,7 +54,7 @@
 	    }	    
 	}	
 
-	public void helpTestValidateFunction(String className, String methodName, int pushdown) {
+	public void helpTestValidateFunction(String className, String methodName, PushDown pushdown) {
 	    try {
 	        FunctionMetadataValidator.validateInvocationMethod(className, methodName, pushdown);
 	    } catch(FunctionMetadataException e) {
@@ -63,7 +62,7 @@
 	    }	    
 	}
 	
-	public void helpTestValidateFunctionFail(String className, String methodName, int pushdown) { 
+	public void helpTestValidateFunctionFail(String className, String methodName, PushDown pushdown) { 
 	    try {
 	        FunctionMetadataValidator.validateInvocationMethod(className, methodName, pushdown);
 	     	fail("Expected exception but did not get one"); //$NON-NLS-1$
@@ -102,63 +101,63 @@
 	}
 	
 	public void testValidateFunction1() {
-	 	helpTestValidateFunction("a", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunction("a", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunction2() {
-	 	helpTestValidateFunction("a.b", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunction("a.b", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunction3() {
-	 	helpTestValidateFunction("a.b.c", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunction("a.b.c", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunction4() {
-	 	helpTestValidateFunction("a$1", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunction("a$1", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
     public void testValidateFunction5() {
-        helpTestValidateFunction(null, null, FunctionMethod.MUST_PUSHDOWN);    
+        helpTestValidateFunction(null, null, PushDown.MUST_PUSHDOWN);    
     }
 
 	public void testValidateFunctionFail1() {
-	 	helpTestValidateFunctionFail(null, null, FunctionMethod.CAN_PUSHDOWN);   
+	 	helpTestValidateFunctionFail(null, null, PushDown.CAN_PUSHDOWN);   
 	}
 
 	public void testValidateFunctionFail2() {
-	 	helpTestValidateFunctionFail(null, "a", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$
+	 	helpTestValidateFunctionFail(null, "a", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$
 	}
 
 	public void testValidateFunctionFail3() {
-	 	helpTestValidateFunctionFail("a", null, FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$
+	 	helpTestValidateFunctionFail("a", null, PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$
 	}
 
 	public void testValidateFunctionFail4() {
-	 	helpTestValidateFunctionFail("1", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunctionFail("1", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunctionFail5() {
-	 	helpTestValidateFunctionFail("a", "2", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunctionFail("a", "2", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunctionFail6() {
-	 	helpTestValidateFunctionFail("a@(", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunctionFail("a@(", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunctionFail7() {
-	 	helpTestValidateFunctionFail("a.b.", "b", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunctionFail("a.b.", "b", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	public void testValidateFunctionFail8() {
-	 	helpTestValidateFunctionFail("a", "b.c", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+	 	helpTestValidateFunctionFail("a", "b.c", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
     public void testValidateFunctionFail9() {
-        helpTestValidateFunctionFail("a", "b@", FunctionMethod.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestValidateFunctionFail("a", "b@", PushDown.CAN_PUSHDOWN);    //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public void testValidateFunctionFail10() {
-        helpTestValidateFunctionFail(null, null, FunctionMethod.CAN_PUSHDOWN);    
-        helpTestValidateFunctionFail(null, null, FunctionMethod.CANNOT_PUSHDOWN);    
+        helpTestValidateFunctionFail(null, null, PushDown.CAN_PUSHDOWN);    
+        helpTestValidateFunctionFail(null, null, PushDown.CANNOT_PUSHDOWN);    
     }
 }

Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,14 +22,12 @@
 
 package org.teiid.query.function.metadata;
 
-import org.teiid.core.util.UnitTestUtil;
-import org.teiid.query.function.metadata.FunctionCategoryConstants;
-import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
-
 import junit.framework.TestCase;
 
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.FunctionParameter;
 
+
 public class TestFunctionMethod extends TestCase {
 
     public TestFunctionMethod(String name) {

Modified: trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -92,7 +92,7 @@
 		vdb.addModel(buildModel("x1"));
 		vdb.addModel(buildModel("y"));
 		
-		return new TransformationMetadata(vdb, cms, resources, null, FakeMetadataFactory.SFM.getSystemFunctions());
+		return new TransformationMetadata(vdb, cms, resources, FakeMetadataFactory.SFM.getSystemFunctions(), null);
 	}
 	
 	ModelMetaData buildModel(String name) {
@@ -125,7 +125,7 @@
 		model2.setVisible(true);
 		vdb.addModel(model2);		
 
-		TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+		TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
 		Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
 		assertEquals(2, result.size());
 
@@ -133,7 +133,7 @@
 
 		model.setVisible(false);
 
-		tm = new TransformationMetadata(vdb, cms, null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+		tm = new TransformationMetadata(vdb, cms, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
 		result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
 		assertEquals(1, result.size());
 	}

Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -26,25 +26,32 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.function.FunctionMetadataSource;
 import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.query.function.metadata.FunctionParameter;
 
 
 public class FakeFunctionMetadataSource implements FunctionMetadataSource {
 
     public Collection getFunctionMethods() {
         List methods = new ArrayList();
-        methods.add(new FunctionMethod("xyz", "", "misc", FunctionMethod.MUST_PUSHDOWN,  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        methods.add(new FunctionMethod("xyz", "", "misc", PushDown.MUST_PUSHDOWN,  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                                        FakeFunctionMetadataSource.class.getName(), "xyz", //$NON-NLS-1$
                                        new FunctionParameter[0],  
                                        new FunctionParameter("out", "integer"))); //$NON-NLS-1$ //$NON-NLS-2$
         
         FunctionParameter p1 = new FunctionParameter("astring", "string");  //$NON-NLS-1$  //$NON-NLS-2$
         FunctionParameter result = new FunctionParameter("trimstring", "string"); //$NON-NLS-1$  //$NON-NLS-2$
+
         FunctionMethod method = new FunctionMethod("MYRTRIM", "", "", FakeFunctionMetadataSource.class.getName(), "myrtrim", new FunctionParameter[] {p1}, result);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        method.setPushdown(FunctionMethod.CAN_PUSHDOWN);
+        method.setPushdown(PushDown.CAN_PUSHDOWN);
         methods.add(method);
+        
+        FunctionMethod method2 = new FunctionMethod("misc.namespace.func", "", "", null, null, new FunctionParameter[] {p1}, result);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        method2.setPushdown(PushDown.MUST_PUSHDOWN);
+        methods.add(method2);
+
         return methods;
     }
     

Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -6572,10 +6572,17 @@
         helpException(sql, "Parsing error: Invalid alias format: [a.x]"); //$NON-NLS-1$
     }
     
-    @Test public void testBadFunctionName() {
+    @Test public void testNameSpacedFunctionName() {
         String sql = "select a.x()"; //$NON-NLS-1$
         
-        helpException(sql, "Parsing error: Invalid function name: [a.x]"); //$NON-NLS-1$
+        Query query = new Query();
+        Select select = new Select();
+        Function func1 = new Function("a.x", new Expression[] { }); //$NON-NLS-1$
+        ExpressionSymbol exprSymbol = new ExpressionSymbol("expr", func1); //$NON-NLS-1$
+        select.addSymbol(exprSymbol);        
+        query.setSelect(select);
+        
+        helpTest(sql, "SELECT a.x()", query); //$NON-NLS-1$
     }
     
     @Test public void testUnionJoin() {

Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -22,7 +22,8 @@
 
 package org.teiid.query.processor;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -36,7 +37,7 @@
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.dqp.internal.process.CachedResults;
 import org.teiid.dqp.internal.process.SessionAwareCache;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.metadata.TempMetadataAdapter;
 import org.teiid.query.tempdata.TempTableDataManager;
 import org.teiid.query.tempdata.TempTableStore;
@@ -58,7 +59,7 @@
 		CommandContext cc = TestProcessor.createCommandContext();
 		cc.setTempTableStore(tempStore);
 		TestProcessor.doProcess(processorPlan, dataManager, expectedResults, cc);
-		assertTrue(cc.getDeterminismLevel() <= FunctionMethod.SESSION_DETERMINISTIC);
+		assertTrue(Determinism.SESSION_DETERMINISTIC.isRestrictiveThanOrEqual(cc.getDeterminismLevel()));
 	}
 
 	@Before public void setUp() {

Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -56,10 +56,13 @@
 import org.teiid.query.analysis.AnalysisRecord;
 import org.teiid.query.function.FunctionDescriptor;
 import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.UDFSource;
 import org.teiid.query.mapping.relational.QueryNode;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TempMetadataID;
 import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.FakeFunctionMetadataSource;
 import org.teiid.query.parser.QueryParser;
 import org.teiid.query.resolver.util.BindVariableVisitor;
 import org.teiid.query.sql.LanguageObject;
@@ -1581,6 +1584,20 @@
     	}
     }
     
+	@Test public void testNamespacedFunction() throws Exception {     
+		String sql = "SELECT namespace.func('e1')  FROM vm1.g1 "; //$NON-NLS-1$
+
+        FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+		
+		Query command = (Query) helpParse(sql);
+		QueryResolver.resolveCommand(command, metadata);
+		
+		command = (Query) helpParse("SELECT func('e1')  FROM vm1.g1 ");
+		QueryResolver.resolveCommand(command, metadata);  		
+		
+	}    
+    
     // special test for both sides are String
     @Test public void testSetCriteriaCastFromExpression_9657() {
         // parse
@@ -3078,5 +3095,4 @@
 
         helpResolveUpdateProcedure(procedure, userQuery);
 	}
-        
 }
\ No newline at end of file

Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -32,6 +32,8 @@
 import org.teiid.metadata.Column;
 import org.teiid.metadata.ColumnSet;
 import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
 import org.teiid.metadata.KeyRecord;
 import org.teiid.metadata.MetadataStore;
 import org.teiid.metadata.Procedure;
@@ -41,6 +43,8 @@
 import org.teiid.metadata.BaseColumn.NullType;
 import org.teiid.metadata.Column.SearchType;
 import org.teiid.metadata.ProcedureParameter.Type;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.UDFSource;
 import org.teiid.query.mapping.relational.QueryNode;
 import org.teiid.query.metadata.CompositeMetadataStore;
 import org.teiid.query.metadata.QueryMetadataInterface;
@@ -57,8 +61,7 @@
     public static TransformationMetadata exampleBQTCached() {
         return CACHED_BQT;
     }
-    
-    public static TransformationMetadata exampleBQT() {
+    public static MetadataStore exampleBQTStore() {
     	MetadataStore metadataStore = new MetadataStore();
     	
         Schema bqt1 = createPhysicalModel("BQT1", metadataStore); //$NON-NLS-1$
@@ -264,21 +267,32 @@
         Procedure vsp7 = createVirtualProcedure("TEIIDSP7", mmspTest1, Arrays.asList(vsp7p1), vspqn7); //$NON-NLS-1$
         vsp7.setResultSet(vsprs7);
         
-    	return createTransformationMetadata(metadataStore, "bqt"); 
+        // this is for the source added function
+        bqt1.addFunction(new FunctionMethod("reverse", "reverse", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+                new FunctionParameter[] {new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    		
+        
+    	 return metadataStore;
     }
+    
+	public static TransformationMetadata exampleBQT() {
+		return createTransformationMetadata(exampleBQTStore(), "bqt");	
+	}
+    
 
-	public static TransformationMetadata createTransformationMetadata(
-			MetadataStore metadataStore, String vdbName) {
+	public static TransformationMetadata createTransformationMetadata(MetadataStore metadataStore, String vdbName) {
 		CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
     	VDBMetaData vdbMetaData = new VDBMetaData();
     	vdbMetaData.setName(vdbName); //$NON-NLS-1$
     	vdbMetaData.setVersion(1);
+    	List<FunctionTree> udfs = new ArrayList<FunctionTree>();
     	for (Schema schema : metadataStore.getSchemas().values()) {
 			vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
+			udfs.add(new FunctionTree(new UDFSource(schema.getFunctions().values()), true));
 		}
-    	return new TransformationMetadata(vdbMetaData, store, null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+    	return new TransformationMetadata(vdbMetaData, store, null, FakeMetadataFactory.SFM.getSystemFunctions(), udfs.toArray(new FunctionTree[udfs.size()]));
 	}
-    
+	
     /** 
      * Metadata for Materialized Views
      * @return

Modified: trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -29,13 +29,13 @@
 import org.teiid.cdk.CommandBuilder;
 import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
 import org.teiid.language.Command;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.RuntimeMetadata;
 import org.teiid.metadata.index.VDBMetadataFactory;
 import org.teiid.query.function.FunctionLibrary;
 import org.teiid.query.function.FunctionTree;
 import org.teiid.query.function.SystemFunctionManager;
 import org.teiid.query.function.UDFSource;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.BasicQueryMetadataWrapper;
 import org.teiid.query.metadata.QueryMetadataInterface;
 

Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -38,10 +38,12 @@
 import org.teiid.core.util.FileUtils;
 import org.teiid.core.util.LRUCache;
 import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.FunctionTree;
 import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
 import org.teiid.query.function.metadata.FunctionMetadataReader;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.query.metadata.CompositeMetadataStore;
 import org.teiid.query.metadata.TransformationMetadata;
 
@@ -85,7 +87,7 @@
 				methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
 			}
 			SystemFunctionManager sfm = new SystemFunctionManager();
-			vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(getSystem(), imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(), methods, sfm.getSystemFunctions()); 
+			vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(getSystem(), imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(), sfm.getSystemFunctions(), new FunctionTree(new UDFSource(methods), true)); 
 			VDB_CACHE.put(vdbURL, vdbmetadata);
 			return vdbmetadata;
 		} catch (URISyntaxException e) {

Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -21,18 +21,24 @@
  */
 package org.teiid.deployers;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashMap;
+import java.util.List;
 
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.impl.DataPolicyMetadata;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
 import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.UDFSource;
 import org.teiid.query.metadata.CompositeMetadataStore;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TransformationMetadata;
@@ -92,9 +98,11 @@
 	}
 	
 	private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores, UDFMetaData udf, FunctionTree systemFunctions) {
-		Collection <FunctionMethod> methods = null;
-		if (udf != null) {
-			methods = udf.getFunctions();
+		Collection <FunctionTree> udfs = new ArrayList<FunctionTree>();
+		if (udf != null) {			
+			for (Collection<FunctionMethod> methods:udf.getFunctions()) {
+				udfs.add(new FunctionTree(new UDFSource(methods), true));
+			}
 		}
 		
 		CompositeMetadataStore compositeStore = new CompositeMetadataStore(stores.getStores());
@@ -102,7 +110,7 @@
 			compositeStore.addMetadataStore(s);
 		}
 		
-		TransformationMetadata metadata =  new TransformationMetadata(vdb, compositeStore, visibilityMap, methods, systemFunctions);
+		TransformationMetadata metadata =  new TransformationMetadata(vdb, compositeStore, visibilityMap, systemFunctions, udfs.toArray(new FunctionTree[udfs.size()]));
 				
 		return metadata;
 	}	
@@ -148,20 +156,40 @@
 	}
 	
 	private UDFMetaData getUDF() {
-		if (this.children == null || this.children.isEmpty()) {
-			return this.udf;
-		}
-		
 		UDFMetaData mergedUDF = new UDFMetaData();
 		if (this.udf != null) {
-			mergedUDF.addFunctions(this.udf.getFunctions());
+			mergedUDF.addFunctions(this.udf);
 		}
-		for (CompositeVDB child:this.children.values()) {
-			UDFMetaData funcs = child.getUDF();
-			if (funcs != null) {
-				mergedUDF.addFunctions(funcs.getFunctions());
+		if (this.stores != null) {
+			for(MetadataStore store:this.stores.getStores()) {
+				for (Schema schema:store.getSchemas().values()) {
+					Collection<FunctionMethod> funcs = schema.getFunctions().values();
+					for(FunctionMethod func:funcs) {
+						func.setNameInSource(func.getName());
+						func.setName(schema.getName() + AbstractMetadataRecord.NAME_DELIM_CHAR + func.getName());						
+					}					
+					mergedUDF.addFunctions(funcs);
+				}
 			}
-		}		
+		}
+		if (this.cmr != null) {
+			for (ConnectorManager cm:this.cmr.getConnectorManagers().values()) {
+				List<FunctionMethod> funcs = cm.getPushDownFunctions();
+				for(FunctionMethod func:funcs) {
+					func.setNameInSource(cm.getTranslatorName()+ AbstractMetadataRecord.NAME_DELIM_CHAR + func.getName());
+					func.setName(cm.getModelName() + AbstractMetadataRecord.NAME_DELIM_CHAR + func.getName());					
+				}
+				mergedUDF.addFunctions(funcs);
+			}
+		}
+		if (this.children != null) {
+			for (CompositeVDB child:this.children.values()) {
+				UDFMetaData funcs = child.getUDF();
+				if (funcs != null) {
+					mergedUDF.addFunctions(funcs);
+				}
+			}		
+		}
 		return mergedUDF;
 	}
 	

Modified: trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -30,14 +30,14 @@
 
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.virtual.VirtualFile;
+import org.teiid.metadata.FunctionMethod;
 import org.teiid.query.function.metadata.FunctionMetadataReader;
-import org.teiid.query.function.metadata.FunctionMethod;
 import org.teiid.runtime.RuntimePlugin;
 
 
 @ManagementObject
 public class UDFMetaData {
-	private Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
+	private Collection<Collection <FunctionMethod>> methods = new ArrayList<Collection<FunctionMethod>>();
 	
 	private HashMap<String, VirtualFile> files = new HashMap<String, VirtualFile>();
 	
@@ -55,18 +55,22 @@
 		}
 		VirtualFile file =this.files.get(name);
 		if (file != null) {
-			this.methods.addAll(FunctionMetadataReader.loadFunctionMethods(file.openStream()));
+			this.methods.add(FunctionMetadataReader.loadFunctionMethods(file.openStream()));
 		}
 		else {
 			throw new IOException(RuntimePlugin.Util.getString("udf_model_not_found", name)); //$NON-NLS-1$
 		}
 	}
 	
-	public Collection <FunctionMethod> getFunctions(){
+	public Collection<Collection <FunctionMethod>> getFunctions(){
 		return this.methods;
 	}
 	
 	public void addFunctions(Collection <FunctionMethod> funcs){
-		this.methods.addAll(funcs);
+		this.methods.add(funcs);
 	}
+	
+	public void addFunctions(UDFMetaData funcs){
+		this.methods.addAll(funcs.getFunctions());
+	}	
 }

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2010-12-03 17:14:37 UTC (rev 2753)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -193,6 +193,7 @@
 
 				ConnectorManager cm = new ConnectorManager(name, model.getSourceConnectionJndiName(source));
 				cm.setExecutionFactory(ef);
+				cm.setModelName(model.getName());
 				cmr.addConnectorManager(source, cm);
 			}
 		}

Added: trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java	                        (rev 0)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java	2010-12-03 18:46:01 UTC (rev 2754)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.translator.ExecutionFactory;
+
+ at SuppressWarnings("nls")
+public class TestCompositeVDB {
+	
+	public static TransformationMetadata createTransformationMetadata(MetadataStore metadataStore, String vdbName) throws Exception {
+    	VDBMetaData vdbMetaData = new VDBMetaData();
+    	vdbMetaData.setName(vdbName); //$NON-NLS-1$
+    	vdbMetaData.setVersion(1);
+    	for (Schema schema : metadataStore.getSchemas().values()) {
+			vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
+		}
+    	MetadataStoreGroup metaGroup = new MetadataStoreGroup();
+    	metaGroup.addStore(metadataStore);
+    	
+    	ConnectorManagerRepository cmr = new ConnectorManagerRepository();
+    	cmr.addConnectorManager("source", getConnectorManager("bqt1", "FakeTranslator", "FakeConnection", getFuncsOne()));
+    	cmr.addConnectorManager("source2", getConnectorManager("bqt2", "FakeTranslator2", "FakeConnection2", getFuncsTwo()));
+    	
+    	CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metaGroup, null, null, FakeMetadataFactory.SFM.getSystemFunctions(),cmr);
+    	VDBMetaData vdb = cvdb.getVDB();
+    	return vdb.getAttachment(TransformationMetadata.class);
+	}
+	
+	private static ConnectorManager getConnectorManager(String modelName, String translatorName, String connectionName,  List<FunctionMethod> funcs) {
+		final ExecutionFactory<Object, Object> ef = Mockito.mock(ExecutionFactory.class);
+		
+		Mockito.stub(ef.getPushDownFunctions()).toReturn(funcs);
+		
+		ConnectorManager cm = new ConnectorManager(translatorName,connectionName) { 
+			protected ExecutionFactory getExecutionFactory() {
+				return ef;
+			}
+		};
+		cm.setModelName(modelName); 
+		cm.start();
+		return cm;
+	}
+	
+	private static List<FunctionMethod> getFuncsOne() {
+    	List<FunctionMethod> funcs = new ArrayList<FunctionMethod>();
+        funcs.add(new FunctionMethod("echo", "echo", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+                new FunctionParameter[] {new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    		
+        funcs.add(new FunctionMethod("duplicate_func", "duplicate", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+	                new FunctionParameter[] {new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+	                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    		
+    	return funcs;		
+	}
+	
+	private static List<FunctionMethod> getFuncsTwo() {
+    	List<FunctionMethod> funcs = new ArrayList<FunctionMethod>();
+        funcs.add(new FunctionMethod("duplicate_func", "duplicate", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+                new FunctionParameter[] {new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    		
+    	funcs.add(new FunctionMethod("duplicate_func", "duplicate", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+	                new FunctionParameter[] {new FunctionParameter("c1", DataTypeManager.DefaultDataTypes.INTEGER, ""),
+        		    new FunctionParameter("c2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+	                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$    		
+    	return funcs;		
+	}
+	
+	
+	private void helpResolve(String sql) throws Exception {
+		TransformationMetadata metadata = createTransformationMetadata(RealMetadataFactory.exampleBQTStore(), "bqt");
+		Command command = QueryParser.getQueryParser().parseCommand(sql);
+		QueryResolver.resolveCommand(command, metadata);		
+	}
+	
+	@Test
+	public void testSourceMetadataStoreFunction() throws Exception {
+		helpResolve("SELECT bqt1.reverse(BQT1.SmallA.INTKEY) FROM BQT1.SmallA");
+	}
+	
+	@Test
+	public void testTranslatorDefinedFunction() throws Exception {
+		helpResolve("SELECT bqt1.echo(BQT1.SmallA.INTKEY) FROM BQT1.SmallA");
+	}
+	
+	@Test
+	public void testPartialUDFName() throws Exception {
+		helpResolve("SELECT echo(BQT1.SmallA.STRINGKEY) FROM BQT1.SmallA");
+	}
+	
+	@Test
+	public void testFullyQualifiedDuplicate() throws Exception {
+		helpResolve("SELECT bqt1.duplicate_func(BQT1.SmallA.STRINGKEY) FROM BQT1.SmallA");
+	}	
+	
+	@Test
+	public void testNonQualifiedDuplicateWithDifferentSignature() throws Exception {
+		helpResolve("SELECT duplicate_func(BQT1.SmallA.INTKEY, BQT1.SmallA.STRINGKEY) FROM BQT1.SmallA");
+	}
+	
+	@Test
+	public void testNonQualifiedDuplicate() throws Exception {
+		helpResolve("SELECT duplicate_func(BQT1.SmallA.INTKEY) FROM BQT1.SmallA");
+	}		
+	
+}


Property changes on: trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the teiid-commits mailing list