[teiid-commits] teiid SVN: r550 - in trunk: common-core/src/main/java/com/metamatrix/common/types/basic and 8 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Mar 12 12:07:02 EDT 2009


Author: shawkins
Date: 2009-03-12 12:07:02 -0400 (Thu, 12 Mar 2009)
New Revision: 550

Added:
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java
Modified:
   trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToFloatTransform.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToDoubleTransform.java
   trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
   trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMethod.java
   trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionParameter.java
   trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
   trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
   trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
   trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
Log:
TEIID-243 TEIID-413 TEIID-414 adding vararg support, better java method resolution, and fixing isNarrowing for long and integer conversions

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -30,6 +30,7 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -136,10 +137,10 @@
 	}
 
 	/** Base data type names and classes, Type name --> Type class */
-	private static Map<String, Class> dataTypeNames = new HashMap<String, Class>();
+	private static Map<String, Class> dataTypeNames = new LinkedHashMap<String, Class>();
 
 	/** Base data type names and classes, Type class --> Type name */
-	private static Map<Class, String> dataTypeClasses = new HashMap<Class, String>();
+	private static Map<Class, String> dataTypeClasses = new LinkedHashMap<Class, String>();
 
 	private static Set<String> DATA_TYPE_NAMES = Collections
 			.unmodifiableSet(dataTypeNames.keySet());
@@ -516,8 +517,6 @@
 	 * Load default data types.
 	 */
 	static void loadDataTypes() {
-		DataTypeManager.addDataType(DefaultDataTypes.STRING,
-				DefaultDataClasses.STRING);
 		DataTypeManager.addDataType(DefaultDataTypes.BOOLEAN,
 				DefaultDataClasses.BOOLEAN);
 		DataTypeManager.addDataType(DefaultDataTypes.BYTE,
@@ -544,16 +543,18 @@
 				DefaultDataClasses.TIME);
 		DataTypeManager.addDataType(DefaultDataTypes.TIMESTAMP,
 				DefaultDataClasses.TIMESTAMP);
+		DataTypeManager.addDataType(DefaultDataTypes.STRING,
+				DefaultDataClasses.STRING);
+		DataTypeManager.addDataType(DefaultDataTypes.CLOB,
+				DefaultDataClasses.CLOB);
+		DataTypeManager.addDataType(DefaultDataTypes.XML,
+				DefaultDataClasses.XML);
 		DataTypeManager.addDataType(DefaultDataTypes.OBJECT,
 				DefaultDataClasses.OBJECT);
 		DataTypeManager.addDataType(DefaultDataTypes.NULL,
 				DefaultDataClasses.NULL);
 		DataTypeManager.addDataType(DefaultDataTypes.BLOB,
 				DefaultDataClasses.BLOB);
-		DataTypeManager.addDataType(DefaultDataTypes.CLOB,
-				DefaultDataClasses.CLOB);
-		DataTypeManager.addDataType(DefaultDataTypes.XML,
-				DefaultDataClasses.XML);
 	}
 
 	/**

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToFloatTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToFloatTransform.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToFloatTransform.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -58,5 +58,10 @@
 	public Class getTargetType() {
 		return Float.class;
 	}
+	
+	@Override
+	public boolean isNarrowing() {
+		return true;
+	}
 
 }

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToDoubleTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToDoubleTransform.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToDoubleTransform.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -58,5 +58,10 @@
 	public Class getTargetType() {
 		return Double.class;
 	}
+	
+	@Override
+	public boolean isNarrowing() {
+		return true;
+	}
 
 }

Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml	2009-03-12 16:07:02 UTC (rev 550)
@@ -1591,13 +1591,13 @@
           </row>
           <row>
             <entry>
-              <para>COALESCE(x,y)</para>
+              <para>COALESCE(x,y+)</para>
             </entry>
             <entry>
               <para>Returns the first non-null parameter</para>
             </entry>
             <entry>
-              <para>x, y can be any type</para>
+              <para>x and all y's can be any compatible types</para>
             </entry>
           </row>
         </tbody>
@@ -2125,12 +2125,6 @@
             </para>
           </listitem>
           <listitem>
-            <para>All input arguments defined on function must be java.lang.Object.</para>
-          </listitem>
-          <listitem>
-            <para>Returned value must be declared as java.lang.Object.</para>
-          </listitem>
-          <listitem>
             <para>Any exception can be thrown, but Teiid will rethrow the exception as a <classname>FunctionExecutionException</classname>.</para>
           </listitem>          
         </itemizedlist>
@@ -2146,10 +2140,11 @@
      * @param doubleCelsiusTemp 
      * @return Fahrenheit 
      */
-    public static Object celsiusToFahrenheit(Object doubleCelsiusTemp){
-        double celsiusTemp = ((Double)doubleCelsiusTemp).doubleValue();
-        double fahrenheitTemp = (celsiusTemp)*9/5 + 32;
-        return new Double(fahrenheitTemp);
+    public static Double celsiusToFahrenheit(Double doubleCelsiusTemp){
+        if (doubleCelsiusTemp == null) {
+        	return null;
+        }
+        return (doubleCelsiusTemp)*9/5 + 32;
     }
 }]]></programlisting>
         </example>

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -238,8 +238,9 @@
             //Iterate over the parameters adding conversions where required or failing when
             //no implicit conversion is possible
             int i = 0;
-            for(; i < types.length; i++) {
-                final String tmpTypeName = methodTypes[i].getType();
+            for(; i < types.length; i++) {
+            	//treat all varags as the same type
+                final String tmpTypeName = methodTypes[Math.min(i, methodTypes.length - 1)].getType();
                 Class targetType = DataTypeManager.getDataTypeClass(tmpTypeName);
 
                 Class sourceType = types[i];
@@ -322,6 +323,14 @@
 
         if(fd == null) {
             throw new InvalidFunctionException(ErrorMessageKeys.FUNCTION_0001, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0001, fd));
+        }
+        
+        if (!fd.isNullDependent()) {
+        	for (int i = 0; i < values.length; i++) {
+				if (values[i] == null) {
+					return null;
+				}
+			}
         }
 
         // If descriptor is missing invokable method, find this VM's descriptor
@@ -338,10 +347,16 @@
             if (method == null){
                 throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, localDescriptor.getName()));
             }
-        }
-
+        }
+        
         // Invoke the method and return the result
-        try {
+        try {
+        	if (method.isVarArgs()) {
+        		int i = method.getParameterTypes().length;
+        		Object[] newValues = Arrays.copyOf(values, i);
+        		newValues[i - 1] = Arrays.copyOfRange(values, i - 1, values.length);
+        		values = newValues;
+        	}
             Object result = method.invoke(null, values);
             result = DataTypeManager.convertToRuntimeType(result);
             result = DataTypeManager.transformValue(result, fd.getReturnType());

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -50,9 +50,7 @@
 	// ================== Function = plus =====================
 
 	public static Object plus(Object x, Object y) throws FunctionExecutionException {
-		if(x == null || y == null) {
-			return null;
-		} else if(x instanceof Integer) {
+		if(x instanceof Integer) {
 			if(y instanceof Integer) {
 				return new Integer(((Integer)x).intValue() + ((Integer)y).intValue());
 			}
@@ -84,9 +82,7 @@
 	// ================== Function = minus =====================
 
 	public static Object minus(Object x, Object y) throws FunctionExecutionException {
-		if(x == null || y == null) {
-			return null;
-		} else if(x instanceof Integer) {
+		if(x instanceof Integer) {
 			if(y instanceof Integer) {
 				return new Integer(((Integer)x).intValue() - ((Integer)y).intValue());
 			}
@@ -118,9 +114,7 @@
 	// ================== Function = multiply =====================
 
 	public static Object multiply(Object x, Object y) throws FunctionExecutionException {
-		if(x == null || y == null) {
-			return null;
-		} else if(x instanceof Integer) {
+		if(x instanceof Integer) {
 			if(y instanceof Integer) {
 				return new Integer(((Integer)x).intValue() * ((Integer)y).intValue());
 			}
@@ -152,9 +146,7 @@
 	// ================== Function = divide =====================
 
 	public static Object divide(Object x, Object y) throws FunctionExecutionException {
-		if(x == null || y == null) {
-			return null;
-		} else if(x instanceof Integer) {
+		if(x instanceof Integer) {
 			if(y instanceof Integer) {
 				return new Integer(((Integer)x).intValue() / ((Integer)y).intValue());
 			}
@@ -186,9 +178,7 @@
 	// ================== Function = abs =====================
 
 	public static Object abs(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Integer) {
+		if(x instanceof Integer) {
 			return new Integer(Math.abs(((Integer)x).intValue()));
 		} else if(x instanceof Long) {
 			return new Long(Math.abs(((Long)x).longValue()));
@@ -207,64 +197,34 @@
 
 	// ================== Function = ceiling =====================
 
-	public static Object ceiling(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Double) {
-			return new Double(Math.ceil(((Double)x).doubleValue()));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "ceiling", x.getClass().getName())); //$NON-NLS-1$
+	public static Object ceiling(Double x) {
+		return new Double(Math.ceil(x));
 	}
 
 	// ================== Function = exp =====================
 
-	public static Object exp(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Double) {
-			return new Double(Math.exp(((Double)x).doubleValue()));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "exp", x.getClass().getName())); //$NON-NLS-1$
+	public static Object exp(Double x) {
+		return new Double(Math.exp(x));
 	}
 
 	// ================== Function = floor =====================
 
-	public static  Object floor(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Double) {
-			return new Double(Math.floor(((Double)x).doubleValue()));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "floor", x.getClass().getName())); //$NON-NLS-1$
+	public static  Object floor(Double x) {
+		return new Double(Math.floor(x.doubleValue()));
 	}
 
 	// ================== Function = log =====================
 
-	public static  Object log(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Double) {
-			return new Double(Math.log(((Double)x).doubleValue()));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "log", x.getClass().getName())); //$NON-NLS-1$
+	public static  Object log(Double x) {
+		return new Double(Math.log(x));
 	}
 
 	// ================== Function = log10 =====================
 
 	private static final double log10baseE = Math.log(10);
 
-	public static Object log10(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Double) {
-			return new Double( Math.log(((Double)x).doubleValue()) / log10baseE);
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "log10", x.getClass().getName())); //$NON-NLS-1$
+	public static Object log10(Double x) {
+		return new Double( Math.log(x) / log10baseE);
 	}
     
     // ================== Function = rand=====================
@@ -429,20 +389,8 @@
 	// ================== Function = sqrt =====================
 
 
-	public static  Object sqrt(Object x) throws FunctionExecutionException {
-		if(x == null) {
-			return null;
-		} else if(x instanceof Integer) {
-			return new Double( Math.sqrt(((Integer)x).intValue()));
-		} else if(x instanceof Long) {
-			return new Double( Math.sqrt(((Long)x).longValue()));
-		} else if(x instanceof Float) {
-			return new Double( Math.sqrt(((Float)x).floatValue()));
-		} else if(x instanceof Double) {
-			return new Double( Math.sqrt(((Double)x).doubleValue()));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "sqrt", x.getClass().getName())); //$NON-NLS-1$
+	public static  Object sqrt(Number x) {
+		return new Double( Math.sqrt(x.doubleValue()));
 	}
 
 	// ================== Function = currentDate =====================
@@ -477,116 +425,44 @@
 	static final String[] dayNames = new String[] {
 		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
 
-	public static Object dayName(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-            // Day of week is 1-based - convert to 0-based for lookup
-			return dayNames[getField((Date)x, Calendar.DAY_OF_WEEK) - 1];
-		} else if(x instanceof Timestamp) {
-            // Day of week is 1-based - convert to 0-based for lookup
-			return dayNames[getField((Timestamp)x, Calendar.DAY_OF_WEEK) - 1];
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "dayName", x.getClass().getName())); //$NON-NLS-1$
+	public static Object dayName(Date x) {
+		return dayNames[getField(x, Calendar.DAY_OF_WEEK) - 1];
 	}
 
 	// ================== Function = dayofmonth =====================
 
-	public static  Object dayOfMonth(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return Integer.valueOf(getField((Date)x, Calendar.DATE));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.DATE));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "dayOfMonth", x.getClass().getName())); //$NON-NLS-1$
+	public static  Object dayOfMonth(Date x) {
+		return Integer.valueOf(getField(x, Calendar.DATE));
 	}
 
 	// ================== Function = dayofweek =====================
 
-	public static Object dayOfWeek(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return Integer.valueOf(getField((Date)x, Calendar.DAY_OF_WEEK));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.DAY_OF_WEEK));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "dayOfWeek", x.getClass().getName())); //$NON-NLS-1$
+	public static Object dayOfWeek(Date x) {
+		return Integer.valueOf(getField(x, Calendar.DAY_OF_WEEK));
 	}
 
 	// ================== Function = dayofyear =====================
 
-	public static Object dayOfYear(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return Integer.valueOf(getField((Date)x, Calendar.DAY_OF_YEAR));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.DAY_OF_YEAR));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "dayOfYear", x.getClass().getName())); //$NON-NLS-1$
+	public static Object dayOfYear(Date x) {
+		return Integer.valueOf(getField(x, Calendar.DAY_OF_YEAR));
 	}
 
 	// ================== Function = hour =====================
 
-	public static Object hour(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Time) {
-			return Integer.valueOf(getField((Time)x, Calendar.HOUR_OF_DAY));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.HOUR_OF_DAY));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "hour", x.getClass().getName())); //$NON-NLS-1$
+	public static Object hour(Date x) {
+		return Integer.valueOf(getField(x, Calendar.HOUR_OF_DAY));
 	}
 
 	// ================== Function = minute =====================
 
-	public static Object minute(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Time) {
-			return Integer.valueOf(getField((Time)x, Calendar.MINUTE));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.MINUTE));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "minute", x.getClass().getName())); //$NON-NLS-1$
+	public static Object minute(Date x) {
+		return Integer.valueOf(getField(x, Calendar.MINUTE));
 	}
 
 	// ================== Function = month =====================
 
-	public static Object month(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return Integer.valueOf(getField((Date)x, Calendar.MONTH)+1);
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.MONTH)+1);
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "month", x.getClass().getName())); //$NON-NLS-1$
+	public static Object month(Date x) {
+		return Integer.valueOf(getField(x, Calendar.MONTH)+1);
 	}
 
 	// ================== Function = monthname =====================
@@ -595,81 +471,34 @@
 		"January", "February", "March", "April", "May", "June", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
 		"July", "August", "September", "October", "November", "December" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
 
-	public static Object monthName(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return monthNames[getField((Date)x, Calendar.MONTH)];
-		} else if(x instanceof Timestamp) {
-			return monthNames[getField((Timestamp)x, Calendar.MONTH)];
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "monthName", x.getClass().getName())); //$NON-NLS-1$
+	public static Object monthName(Date x) {
+		return monthNames[getField(x, Calendar.MONTH)];
 	}
 
 	// ================== Function = second =====================
 
-	public static Object second(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Time) {
-			return Integer.valueOf(getField((Time)x, Calendar.SECOND));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.SECOND));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "second", x.getClass().getName())); //$NON-NLS-1$
+	public static Object second(Date x) {
+		return Integer.valueOf(getField(x, Calendar.SECOND));
 	}
 
 	// ================== Function = week =====================
 
-	public static Object week(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return Integer.valueOf(getField((Date)x, Calendar.WEEK_OF_YEAR));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.WEEK_OF_YEAR));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "week", x.getClass().getName())); //$NON-NLS-1$
+	public static Object week(Date x) {
+		return Integer.valueOf(getField(x, Calendar.WEEK_OF_YEAR));
 	}
 
 	// ================== Function = year =====================
 
-	public static Object year(Object x)
-		throws FunctionExecutionException {
-
-		if(x == null) {
-			return null;
-		} else if(x instanceof Date) {
-			return Integer.valueOf(getField((Date)x, Calendar.YEAR));
-		} else if(x instanceof Timestamp) {
-			return Integer.valueOf(getField((Timestamp)x, Calendar.YEAR));
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "year", x.getClass().getName())); //$NON-NLS-1$
+	public static Object year(Date x) {
+		return Integer.valueOf(getField(x, Calendar.YEAR));
 	}
 
 	// ================== Function = quarter =====================
 
-	public static Object quarter(Object date)
+	public static Object quarter(Date date)
 		throws FunctionExecutionException {
-		int month = 12;
-
-		if(date == null) {
-			return null;
-		} else if(date instanceof Date) {
-			month = getField((Date)date, Calendar.MONTH);
-		} else if(date instanceof Timestamp) {
-			month = getField((Timestamp)date, Calendar.MONTH);
-		} 
+		int month = getField(date, Calendar.MONTH);
+		
 		if (month > 11) {
 			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0066, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0066,
 					new Object[] {"quarter", date.getClass().getName()})); //$NON-NLS-1$
@@ -679,64 +508,60 @@
 
 	//	================== Function = timestampadd =====================
 
-	public static Object timestampAdd(Object interval, Object count, Object timestamp)
-		throws FunctionExecutionException {
+	public static Object timestampAdd(String intervalType, Integer count, Timestamp timestamp) {
 		Calendar cal = TimestampWithTimezone.getCalendar();
 
-		if (interval == null || count == null || timestamp == null) {
-			return null;
-		} else if (interval instanceof String && count instanceof Integer) {
-            String intervalType = (String) interval;
-			if (timestamp instanceof Timestamp) {
-				int nanos = ((Timestamp) timestamp).getNanos();
-				cal.setTime((Timestamp) timestamp);
+		int nanos = timestamp.getNanos();
+		cal.setTime(timestamp);
 
-				// case of interval = 1, fractional seconds (nanos), don't go to branches of addField()
-				if (intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
-					int countValue = ((Integer) count).intValue();
-					nanos += countValue;
+		// case of interval = 1, fractional seconds (nanos), don't go to branches of addField()
+		if (intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+			int countValue = count.intValue();
+			nanos += countValue;
 
-					// Handle the case of nanos > 999,999,999 and increase the second.
-					// Since the count number is an interger, so the maximum is definite,
-					// and nanos/999,999,999 can at most be added to second
-					if ( nanos > 999999999) {
-						int addSecond = nanos / 999999999;
-						int leftNanos = nanos % 999999999;
-						cal.add(Calendar.SECOND, addSecond);
+			// Handle the case of nanos > 999,999,999 and increase the second.
+			// Since the count number is an interger, so the maximum is definite,
+			// and nanos/999,999,999 can at most be added to second
+			if ( nanos > 999999999) {
+				int addSecond = nanos / 999999999;
+				int leftNanos = nanos % 999999999;
+				cal.add(Calendar.SECOND, addSecond);
 
-						Timestamp ts = new Timestamp(cal.getTime().getTime());
-						ts.setNanos(leftNanos);
-						return ts;
-					} 
-                    // nanos <= 999,999,999
-					Timestamp ts = new Timestamp(cal.getTime().getTime());
-					ts.setNanos(nanos);
-					return ts;
-				}
-                // for interval from 2 to 9
-				addField(intervalType, (Integer)count, cal);
 				Timestamp ts = new Timestamp(cal.getTime().getTime());
-
-				//rectify returned timestamp with original nanos
-				ts.setNanos(nanos);
+				ts.setNanos(leftNanos);
 				return ts;
-			} else if (timestamp instanceof Time) {
-				// Note: if dates are different, for example, days are different, the times
-				// are still different even they may have the same hours, minutes and seconds.
-				cal.setTime((Time) timestamp);
-				addField(intervalType, (Integer)count, cal);
-				return TimestampWithTimezone.createTime(cal.getTime());
-			} else if (timestamp instanceof Date) {
-				cal.setTime((Date) timestamp);
-				addField(intervalType, (Integer)count, cal);
-                return TimestampWithTimezone.createDate(cal.getTime());
-			}
+			} 
+            // nanos <= 999,999,999
+			Timestamp ts = new Timestamp(cal.getTime().getTime());
+			ts.setNanos(nanos);
+			return ts;
 		}
+        // for interval from 2 to 9
+		addField(intervalType, count, cal);
+		Timestamp ts = new Timestamp(cal.getTime().getTime());
 
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0067, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0067,
-			new Object[] {"timestampAdd", interval.getClass().getName(), count.getClass().getName(), timestamp.getClass().getName() })); //$NON-NLS-1$
+		//rectify returned timestamp with original nanos
+		ts.setNanos(nanos);
+		return ts;
 	}
+	
+	public static Object timestampAdd(String intervalType, Integer count, java.sql.Date timestamp) {
+		Calendar cal = TimestampWithTimezone.getCalendar();
+		// Note: if dates are different, for example, days are different, the times
+		// are still different even they may have the same hours, minutes and seconds.
+		cal.setTime(timestamp);
+		addField(intervalType, count, cal);
+		return TimestampWithTimezone.createDate(cal.getTime());
+	}
+	
+	public static Object timestampAdd(String intervalType, Integer count, Time timestamp) {
+		Calendar cal = TimestampWithTimezone.getCalendar();
+		cal.setTime(timestamp);
+		addField(intervalType, count, cal);
+	    return TimestampWithTimezone.createTime(cal.getTime());
+	}
 
+
 	/** Helper method for timestampAdd method
 	 * @param interval Integer
 	 * @param count Integer
@@ -768,6 +593,10 @@
 
 	//	================== Function = timestampdiff =====================
 
+    public static Object timestampDiff(String intervalType, Time timestamp1, Time timestamp2) {
+    	return timestampDiff(intervalType, new Timestamp(timestamp1.getTime()), new Timestamp(timestamp2.getTime()));
+    }
+	
 	/**
      * This method truncates (ignores) figures
      * @param interval
@@ -776,59 +605,36 @@
      * @return
      * @throws FunctionExecutionException
      */
-    public static Object timestampDiff(Object interval, Object timestamp1, Object timestamp2) 
-        throws FunctionExecutionException {
+    public static Object timestampDiff(String intervalType, Timestamp ts1Obj, Timestamp ts2Obj)  {
+        long ts1 = ts1Obj.getTime() / 1000 * 1000000000 + ts1Obj.getNanos();
+        long ts2 = ts2Obj.getTime() / 1000 * 1000000000 + ts2Obj.getNanos();
+        
+        long tsDiff = ts2 - ts1;
 
-		if (interval == null || timestamp1 == null || timestamp2 == null) {
-			return null;
-        } else if (interval instanceof String) {
-            String intervalType = (String) interval;
-            // Incoming can be time or timestamp  - convert to timestamp
-            if(timestamp1 instanceof Time) {
-            	Time t1 = (Time)timestamp1;
-            	timestamp1 = new Timestamp(t1.getTime());
-            }
-            if(timestamp2 instanceof Time) {
-            	Time t2 = (Time)timestamp2;
-            	timestamp2 = new Timestamp(t2.getTime());
-            }
-            // In nanos
-            Timestamp ts1Obj = (Timestamp)timestamp1;
-            Timestamp ts2Obj = (Timestamp)timestamp2;
-            
-            long ts1 = ts1Obj.getTime() / 1000 * 1000000000 + ts1Obj.getNanos();
-            long ts2 = ts2Obj.getTime() / 1000 * 1000000000 + ts2Obj.getNanos();
-            
-            long tsDiff = ts2 - ts1;
-    
-            long count = 0;
-            if(interval.equals(ReservedWords.SQL_TSI_FRAC_SECOND)) {
-                count = tsDiff;
-            } else { 
-            	tsDiff = tsDiff / 1000000; //convert to milliseconds
-	            if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_SECOND)) {
-	                count = tsDiff / 1000;
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MINUTE)) {
-	                count = (tsDiff / 1000) / 60;
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_HOUR)) {
-	                count = (tsDiff / 1000) / (60*60);
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_DAY)) {
-	                count = (tsDiff / 1000) / (60*60*24);
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_WEEK)) {
-	                count = (tsDiff / 1000) / (60*60*24*7);
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MONTH)) {
-	                count = (tsDiff / 1000) / (60*60*24*30);
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_QUARTER)) {
-	                count = (tsDiff / 1000) / (60*60*24*91);
-	            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_YEAR)) {
-	                count = (tsDiff / 1000) / (60*60*24*365);
-	            }    
-            }
-            return new Long(count);
+        long count = 0;
+        if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_FRAC_SECOND)) {
+            count = tsDiff;
+        } else { 
+        	tsDiff = tsDiff / 1000000; //convert to milliseconds
+            if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_SECOND)) {
+                count = tsDiff / 1000;
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MINUTE)) {
+                count = (tsDiff / 1000) / 60;
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_HOUR)) {
+                count = (tsDiff / 1000) / (60*60);
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_DAY)) {
+                count = (tsDiff / 1000) / (60*60*24);
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_WEEK)) {
+                count = (tsDiff / 1000) / (60*60*24*7);
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_MONTH)) {
+                count = (tsDiff / 1000) / (60*60*24*30);
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_QUARTER)) {
+                count = (tsDiff / 1000) / (60*60*24*91);
+            } else if(intervalType.equalsIgnoreCase(ReservedWords.SQL_TSI_YEAR)) {
+                count = (tsDiff / 1000) / (60*60*24*365);
+            }    
         }
-        
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0067, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0067,
-                  new Object[] {"timestampDiff", interval.getClass().getName(),timestamp1.getClass().getName(),timestamp2.getClass().getName() })); //$NON-NLS-1$        
+        return new Long(count);
 	}
 
     //  ================== Function = timestampcreate =====================
@@ -841,19 +647,14 @@
      * @return
      * @throws FunctionExecutionException
      */
-    public static Object timestampCreate(Object date, Object time) {
-
-        if (date == null || time == null) {
-            return null;
-        }
-
+    public static Object timestampCreate(java.sql.Date date, Time time) {
         Calendar tsCal = TimestampWithTimezone.getCalendar();
-        tsCal.setTime((java.sql.Time)time);
+        tsCal.setTime(time);
         int hour = tsCal.get(Calendar.HOUR_OF_DAY);
         int minute = tsCal.get(Calendar.MINUTE);
         int second = tsCal.get(Calendar.SECOND);
         
-        tsCal.setTime((java.sql.Date)date);
+        tsCal.setTime(date);
         
         tsCal.set(Calendar.HOUR_OF_DAY, hour);
         tsCal.set(Calendar.MINUTE, minute);
@@ -864,51 +665,19 @@
 
 	// ================== Function = length =====================
 
-	public static Object length(Object str)
-		throws FunctionExecutionException {
-
-		if(str == null) {
-			return null;
-		} else if(str instanceof String) {
-			return new Integer(((String)str).length());
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "length", str.getClass().getName())); //$NON-NLS-1$
+	public static Object length(String str) {
+		return new Integer(str.length());
 	}
 
 	// ================== Function = concat =====================
 
-	public static Object concat(Object str1, Object str2)
-		throws FunctionExecutionException {
-
-		if(str1 == null || str2 == null) {
-			return null;
-		} else if(str1 instanceof String && str2 instanceof String) {
-			return (String) str1 + (String) str2;
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"concat", str1.getClass().getName(), str2.getClass().getName()})); //$NON-NLS-1$
+	public static Object concat(String str1, String str2) {
+		return str1 + str2;
 	}
 
 	// ================== Function = substring =====================
 
-	public static Object substring(Object str, Object start, Object length)
-		throws FunctionExecutionException {
-
-		if(str == null || start == null || length == null) {
-			return null;
-		} 
-		if(str instanceof String && start instanceof Integer && length instanceof Integer) {
-			String string = (String) str;
-			int startVal = ((Integer)start).intValue();
-			int lengthVal = ((Integer)length).intValue();
-            return substring(string, startVal, lengthVal);
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0013, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0013, new Object[]{"substring", str.getClass().getName(), start.getClass().getName(), length.getClass().getName()} )); //$NON-NLS-1$
-	}
-
-	private static Object substring(String string, int startVal, int lengthVal) {
+	public static Object substring(String string, Integer startVal, Integer lengthVal) {
 		if (startVal < 0) {
         	startVal = string.length() + startVal;
         } else if (startVal > 0){
@@ -928,280 +697,178 @@
 		return string.substring(startVal, endVal);
 	}
 
-    public static Object substring(Object str, Object start)
-        throws FunctionExecutionException {
-
-        if(str == null || start == null) {
-            return null;
-        } else if(str instanceof String && start instanceof Integer) {
-            String string = (String) str;
-            int startVal = ((Integer)start).intValue();
-            return substring(string, startVal, string.length());
-        }
-
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"substring",  str.getClass().getName(), start.getClass().getName()})); //$NON-NLS-1$
+    public static Object substring(String string, Integer start) {
+        int startVal = start.intValue();
+        return substring(string, startVal, string.length());
     }
 
 	// ================== Function = left =====================
 
-	public static Object left(Object str, Object count)
+	public static Object left(String string, Integer count)
 		throws FunctionExecutionException {
-
-		if(str == null || count == null) {
-			return null;
-		} else if(str instanceof String && count instanceof Integer) {
-
-			String string = (String) str;
-			int countValue = ((Integer)count).intValue();
-            if(countValue < 0) {
-                throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
-            } else if(string.length() < countValue) {
-                return string;
-			} else {
-    			return string.substring(0, countValue);
-            }
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"left", str.getClass().getName(), count.getClass().getName()})); //$NON-NLS-1$
+		int countValue = count.intValue();
+        if(countValue < 0) {
+            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
+        } 
+        if(string.length() < countValue) {
+            return string;
+        }
+        return string.substring(0, countValue);
 	}
 
 	// ================== Function = right =====================
 
-	public static Object right(Object str, Object count)
+	public static Object right(String string, Integer count) 
 		throws FunctionExecutionException {
-
-		if(str == null || count == null) {
-			return null;
-		} else if(str instanceof String && count instanceof Integer) {
-
-			String string = (String) str;
-			int countValue = ((Integer)count).intValue();
-            if(countValue < 0) {
-                throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
-            } else if(string.length() < countValue) {
-                return string;
-			} else {
-    			return string.substring(string.length() - countValue);
-            }
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"right", str.getClass().getName(), count.getClass().getName()})); //$NON-NLS-1$
+		int countValue = count.intValue();
+        if(countValue < 0) {
+            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
+        } else if(string.length() < countValue) {
+            return string;
+		} else {
+			return string.substring(string.length() - countValue);
+        }
 	}
 
 	// ================== Function = lowercase =====================
 
-	public static Object lowerCase(Object str)
-		throws FunctionExecutionException {
-
-		if(str == null) {
-			return null;
-		} else if(str instanceof String) {
-			return ((String)str).toLowerCase();
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "lowerCase", str.getClass().getName())); //$NON-NLS-1$
+	public static Object lowerCase(String str) {
+		return str.toLowerCase();
 	}
 
 	// ================== Function = uppercase =====================
 
-	public static Object upperCase(Object str)
-		throws FunctionExecutionException {
-
-		if(str == null) {
-			return null;
-		} else if(str instanceof String) {
-			return ((String)str).toUpperCase();
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "upperCase", str.getClass().getName())); //$NON-NLS-1$
+	public static Object upperCase(String str) {
+		return str.toUpperCase();
 	}
 
 	// ================== Function = locate =====================
 
-	public static Object locate(Object sub, Object str)
-		throws FunctionExecutionException {
-
-		if(str == null || sub == null) {
-			return null;
-		} else if(sub instanceof String && str instanceof String) {
-    		return new Integer(((String)str).indexOf((String)sub) + 1);
-		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"locate", sub.getClass().getName(), str.getClass().getName()})); //$NON-NLS-1$
+	public static Object locate(String sub, String str) {
+		return locate(sub, str, 1);
 	}
 
-	public static Object locate(Object sub, Object str, Object start)
-		throws FunctionExecutionException {
-
+	/**
+	 * TODO: The treatment of negative start indexes is inconsistent here.
+	 * We're treating the null value like Derby, but not throwing an
+	 * exception if the value is less than 1 (less than 0 in DB2).
+	 */
+	public static Object locate(String sub, String str, Integer start) {
 		if(str == null || sub == null) {
 			return null;
-		} else if(sub instanceof String && str instanceof String) {
-			if(start == null) {
-				return new Integer(((String)str).indexOf((String)sub) + 1);
-			} else if(start instanceof Integer) {
-				return new Integer(((String)str).indexOf((String)sub, ((Integer)start).intValue() - 1) + 1);
-			}
+		} 
+		if (start == null) {
+			start = 1;
 		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0013, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0013, new Object[]{"locate",  sub.getClass().getName() ,str.getClass().getName(), start.getClass().getName()})); //$NON-NLS-1$
+		return new Integer(str.indexOf(sub, start.intValue() - 1) + 1);
 	}
 
 	// ================== Function = lefttrim =====================
 
 	private static final char SPACE = ' ';
 
-	public static Object leftTrim(Object str)
-		throws FunctionExecutionException {
-
-		if(str == null) {
-			return null;
-		} else if(str instanceof String) {
-			String string = (String) str;
-			for(int i=0; i<string.length(); i++) {
-				if(string.charAt(i) != SPACE) {
-					// end of trim, return what's left
-					return string.substring(i);
-				}
+	public static Object leftTrim(String string) {
+		for(int i=0; i<string.length(); i++) {
+			if(string.charAt(i) != SPACE) {
+				// end of trim, return what's left
+				return string.substring(i);
 			}
-
-			// All spaces, so trim it all
-			return ""; //$NON-NLS-1$
 		}
 
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "leftTrim", str.getClass().getName())); //$NON-NLS-1$
+		// All spaces, so trim it all
+		return ""; //$NON-NLS-1$
 	}
 
 	// ================== Function = righttrim =====================
 
-	public static Object rightTrim(Object str)
-		throws FunctionExecutionException {
-
-		if(str == null) {
-			return null;
-		} else if(str instanceof String) {
-			String string = (String) str;
-
-			for(int i=string.length()-1; i>=0; i--) {
-				if(string.charAt(i) != SPACE) {
-					// end of trim, return what's left
-					return string.substring(0, i+1);
-				}
+	public static Object rightTrim(String string) {
+		for(int i=string.length()-1; i>=0; i--) {
+			if(string.charAt(i) != SPACE) {
+				// end of trim, return what's left
+				return string.substring(0, i+1);
 			}
-
-			// All spaces, so trim it all
-			return ""; //$NON-NLS-1$
 		}
 
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "rightTrim", str.getClass().getName())); //$NON-NLS-1$
+		// All spaces, so trim it all
+		return ""; //$NON-NLS-1$
 	}
 
 	// ================== Function = replace =====================
 
-	public static Object replace(Object str, Object sub, Object replace)
-		throws FunctionExecutionException {
+	public static Object replace(String string, String subString, String replaceString) {
+		// Check some simple cases that require no work
+		if(subString.length() > string.length() || string.length() == 0 || subString.length() == 0) {
+			return string;
+		}
 
-		if(str == null || sub == null || replace == null) {
-			return null;
-		} else if(str instanceof String && sub instanceof String && replace instanceof String) {
-			String string = (String) str;
-			String subString = (String) sub;
-			String replaceString = (String) replace;
+		StringBuffer result = new StringBuffer();
+		int index = 0;
 
-			// Check some simple cases that require no work
-			if(subString.length() > string.length() || string.length() == 0 || subString.length() == 0) {
-				return string;
-			}
+		while(true) {
+			int newIndex = string.indexOf(subString, index);
+			if(newIndex < 0) {
+				// No more replacement sections, grab from old index to end of string
+				result.append( string.substring(index) );
 
-			StringBuffer result = new StringBuffer();
-			int index = 0;
+				// Break out of loop
+				break;
 
-			while(true) {
-				int newIndex = string.indexOf(subString, index);
-				if(newIndex < 0) {
-					// No more replacement sections, grab from old index to end of string
-					result.append( string.substring(index) );
+			}
+			// Matched the substring at newIndex
 
-					// Break out of loop
-					break;
+			// First append section from old index to new
+			result.append( string.substring( index, newIndex) );
 
-				}
-				// Matched the substring at newIndex
+			// Then append replacement section for sub
+			result.append( replaceString );
 
-				// First append section from old index to new
-				result.append( string.substring( index, newIndex) );
-
-				// Then append replacement section for sub
-				result.append( replaceString );
-
-				// Then move the index counter forward
-				index = newIndex + subString.length();
-			}
-
-			return result.toString();
+			// Then move the index counter forward
+			index = newIndex + subString.length();
 		}
 
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0013, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0013, new Object[]{"replace",  str.getClass().getName(), sub.getClass().getName(), replace.getClass().getName()})); //$NON-NLS-1$
+		return result.toString();
 	}
 
 	// ================== Function = insert =====================
 
-	public static Object insert(Object str1, Object start, Object length, Object str2)
+	public static Object insert(String string1, Integer start, Integer length, String str2)
 		throws FunctionExecutionException {
+		int startValue = start.intValue();
+		int len = length.intValue();
 
-		if(str1 == null || start == null || length == null || str2 == null) {
-			return null;
-		} else if(str1 instanceof String && str2 instanceof String
-			&& start instanceof Integer && length instanceof Integer) {
+		// Check some invalid cases
+		if(startValue < 1 || (startValue-1) > string1.length()) {
+			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0061, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0061, start, string1));
+		} else if (len < 0) {
+			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0062, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0062, len));
+		} else if (string1.length() == 0 && (startValue > 1 || len >0) ) {
+			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0063, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0063));
+		}
 
-			String string1 = (String) str1;
-			int startValue = ((Integer) start).intValue();
-			int len = ((Integer) length).intValue();
+		StringBuffer result = new StringBuffer();
+		result.append(string1.substring(0, startValue-1));
+		int endValue = startValue + len - 1;
 
-			// Check some invalid cases
-			if(startValue < 1 || (startValue-1) > ((String)str1).length()) {
-				throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0061, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0061, start, str1));
-			} else if (len < 0) {
-				throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0062, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0062, len));
-			} else if (((String) str1).length() == 0 && (startValue > 1 || len >0) ) {
-				throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0063, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0063));
-			}
-
-			StringBuffer result = new StringBuffer();
-			result.append(string1.substring(0, startValue-1));
-			int endValue = startValue + len - 1;
-
-			// str2.length() = 0 is a valid case
-			if (endValue > ((String)str1).length()) {
-				result.append((String) str2);
-			} else {
-				result.append((String) str2);
-				result.append(string1.substring( endValue ));
-			}
-
-			return result.toString();
+		// str2.length() = 0 is a valid case
+		if (endValue > string1.length()) {
+			result.append(str2);
+		} else {
+			result.append(str2);
+			result.append(string1.substring( endValue ));
 		}
 
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0064, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0064,
-			new Object[] {"insert", str1.getClass().getName(), start.getClass().getName(), length.getClass().getName() , str2.getClass().getName()})); //$NON-NLS-1$
+		return result.toString();
 	}
 
 	// ================== Function = repeat =====================
-	public static Object repeat(Object str, Object count)
-		throws FunctionExecutionException {
-		if (str == null || count == null) {
-			return null;
-		} else if (str instanceof String && count instanceof Integer) {
-			int repeatCount = ((Integer) count).intValue();
-			StringBuffer result = new StringBuffer();
+	public static Object repeat(String str, Integer count) {
+		int repeatCount = count.intValue();
+		StringBuffer result = new StringBuffer();
 
-			for (int i = 0; i < repeatCount && result.length() <= DataTypeManager.MAX_STRING_LENGTH; i++) {
-				result.append((String)str);
-			}
-			return result.toString();
+		for (int i = 0; i < repeatCount && result.length() <= DataTypeManager.MAX_STRING_LENGTH; i++) {
+			result.append(str);
 		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0065, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0065,
-			new Object[] {"repeat", str.getClass().getName(), count.getClass().getName()})); //$NON-NLS-1$
+		return result.toString();
 	}
 
     // ================== Function = ascii =====================
@@ -1209,10 +876,6 @@
     public static Object ascii(Object ch)
         throws FunctionExecutionException {
 
-        if(ch == null) {
-            return null;
-        }
-
         char c = 0;
         if(ch instanceof Character) {
             c = ((Character) ch).charValue();
@@ -1232,65 +895,43 @@
 
     // ================== Function = chr =====================
 
-    public static Object chr(Object intValue) {
-
-        if(intValue == null) {
-            return null;
-        }
-
-        Integer theInt = (Integer) intValue;
-
-        return new Character((char) theInt.intValue());
+    public static Object chr(int intValue) {
+        return new Character((char) intValue);
     }
 
     // ================== Function = initCap =====================
 
-    public static Object initCap(Object str)
-        throws FunctionExecutionException {
+    public static Object initCap(String s) {
+        StringBuffer cap = new StringBuffer();
 
-        if(str == null) {
-            return null;
-        } else if(str instanceof String) {
-            String s = (String) str;
-            StringBuffer cap = new StringBuffer();
+        boolean checkCap = true;
+        for(int i=0; i<s.length(); i++) {
+            char c = s.charAt(i);
 
-            boolean checkCap = true;
-            for(int i=0; i<s.length(); i++) {
-                char c = s.charAt(i);
-
-                // Decide whether to upper case
-                if(checkCap) {
-                    cap.append(Character.toUpperCase(c));
-                } else {
-                    cap.append(Character.toLowerCase(c));
-                }
-
-                // Reset flag for next character
-                checkCap = Character.isWhitespace(c);
+            // Decide whether to upper case
+            if(checkCap) {
+                cap.append(Character.toUpperCase(c));
+            } else {
+                cap.append(Character.toLowerCase(c));
             }
-            return cap.toString();
-        }
 
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "initCap", str.getClass().getName())); //$NON-NLS-1$
+            // Reset flag for next character
+            checkCap = Character.isWhitespace(c);
+        }
+        return cap.toString();
     }
 
     // ================== Function = lpad =====================
 
-    public static Object lpad(Object inputString, Object padLength, Object padStr)
+    public static Object lpad(String inputString, Integer padLength, String padStr)
         throws FunctionExecutionException {
 
     	return pad(inputString, padLength, padStr, true);
     }
 
-    public static Object pad(Object inputString, Object padLength, Object padStr, boolean left)
+    public static Object pad(String str, Integer padLength, String padStr, boolean left)
     throws FunctionExecutionException {
-
-	    if(inputString == null || padLength == null || padStr == null) {
-	        return null;
-	    }
-	
-	    String str = (String) inputString;
-	    int length = ((Integer)padLength).intValue();
+	    int length = padLength.intValue();
 	    if(length < 1) {
 	        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0025, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0025));
 	    }
@@ -1301,17 +942,16 @@
 	    	length = DataTypeManager.MAX_STRING_LENGTH;
 	    }
 	    // Get pad character
-	    String pad = (String) padStr;
-	    if(pad.length() == 0) {
+	    if(padStr.length() == 0) {
 	        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0027, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0027));
 	    }
 	    // Pad string
 	    StringBuffer outStr = new StringBuffer(str);
 	    while(outStr.length() < length) {
 	    	if (left) {
-	    		outStr.insert(0, pad);
+	    		outStr.insert(0, padStr);
 	    	} else {
-	    		outStr.append(pad);
+	    		outStr.append(padStr);
 	    	}
 	    }
 	    if (left) {
@@ -1323,7 +963,7 @@
     
     public static final String SPACE_CHAR = " "; //$NON-NLS-1$
 
-    public static Object lpad(Object inputString, Object padLength)
+    public static Object lpad(String inputString, Integer padLength)
         throws FunctionExecutionException {
 
         return lpad(inputString, padLength, SPACE_CHAR);
@@ -1331,13 +971,13 @@
 
     // ================== Function = rpad =====================
 
-    public static Object rpad(Object inputString, Object padLength, Object padStr)
+    public static Object rpad(String inputString, Integer padLength, String padStr)
         throws FunctionExecutionException {
 
     	return pad(inputString, padLength, padStr, false);
     }
 
-    public static Object rpad(Object inputString, Object padLength)
+    public static Object rpad(String inputString, Integer padLength)
         throws FunctionExecutionException {
 
         return rpad(inputString, padLength, SPACE_CHAR);
@@ -1345,23 +985,14 @@
 
     // ================== Function = translate =====================
 
-    public static Object translate(Object inputString, Object srcChars, Object destChars)
+    public static Object translate(String str, String in, String out)
         throws FunctionExecutionException {
-
-        if(inputString == null || srcChars == null || destChars == null) {
-            return null;
-        }
-
-        String str = (String) inputString;
-        String in = (String) srcChars;
-        String out = (String) destChars;
-
         if(in.length() != out.length()) {
             throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0031, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0031));
         }
 
         if(in.length() == 0 || str.length() == 0) {
-            return inputString;
+            return str;
         }
 
         StringBuffer translated = new StringBuffer(str.length());
@@ -1386,22 +1017,13 @@
 	// ================== Function = convert =====================
 
 	@SuppressWarnings("unchecked")
-	public static Object convert(Object src, Object type)
+	public static Object convert(Object src, String type)
 		throws FunctionExecutionException {
-
-		if(src == null) {
-			return null;
-		} else if(type instanceof String) {
-			String typeStr = (String) type;
-
-			try {
-				return DataTypeManager.transformValue(src, DataTypeManager.getDataTypeClass(typeStr));
-			} catch(TransformationException e) {
-				throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0033, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0033, new Object[]{src, DataTypeManager.getDataTypeName(src.getClass()), typeStr}));
-			}
+		try {
+			return DataTypeManager.transformValue(src, DataTypeManager.getDataTypeClass(type));
+		} catch(TransformationException e) {
+			throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0033, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0033, new Object[]{src, DataTypeManager.getDataTypeName(src.getClass()), type}));
 		}
-
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0034, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0034, type));
 	}
 
     // ================== Function = context and rowlimit =====================
@@ -1462,24 +1084,31 @@
 
         throw new UnsupportedOperationException("This method should never be called."); //$NON-NLS-1$
     }
-
+	
     // ================== Function = nvl =====================
-
-    public static Object ifnull(Object value, Object valueIfNull) {
-
-        if(value == null) {
-            return valueIfNull;
-        }
-        return value;
+    
+    public static Object ifnull(Object value, Object ifNullValue) {
+    	return coalesce(value, ifNullValue);
     }
+    
+    public static Object coalesce(Object value, Object value1, Object... other) {
+    	if (value != null) {
+    		return value;
+    	}
+    	if (value1 != null) {
+    		return value1;
+    	}
+        for (Object object : other) {
+			if (object != null) {
+				return object;
+			}
+		}
+        return null;
+    }
 
 	// ================== Format date/time/timestamp TO String ==================
 	public static Object formatDate(Object date, Object format)
 		throws FunctionExecutionException {
-		if (date == null || format == null) {
-			return null;
-		}
-
 		try {
             SimpleDateFormat sdf = new SimpleDateFormat((String)format);
             return sdf.format((Date)date);
@@ -1491,10 +1120,6 @@
 
 	public static Object formatTime(Object time, Object format)
 		throws FunctionExecutionException {
-		if (time == null || format == null) {
-			return null;
-		}
-
 		try {
             SimpleDateFormat sdf = new SimpleDateFormat((String)format);
             return sdf.format((Time)time);
@@ -1506,10 +1131,6 @@
 
 	public static Object formatTimestamp(Object timestamp, Object format)
 		throws FunctionExecutionException {
-		if (timestamp == null || format == null) {
-			return null;
-		}
-
 		try {
             SimpleDateFormat sdf = new SimpleDateFormat((String)format);
             return sdf.format((Timestamp) timestamp);
@@ -1520,17 +1141,11 @@
 	}
 
 	//	================== Parse String TO date/time/timestamp  ==================
-	public static Object parseDate(Object date, Object format)
+	public static Object parseDate(String date, String format)
 		throws FunctionExecutionException {
-		java.util.Date parsedDate = null;
-
-		if (date == null || format == null) {
-			return null;
-		}
-
 		try {
-			DateFormat df= new SimpleDateFormat((String) format);
-			parsedDate = df.parse((String) date);
+			DateFormat df= new SimpleDateFormat(format);
+			Date parsedDate = df.parse(date);
             return TimestampWithTimezone.createDate(parsedDate);
 		} catch (java.text.ParseException pe) {
 			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
@@ -1538,17 +1153,12 @@
 		}
 	}
 
-	public static Object parseTime(Object time, Object format)
+	public static Object parseTime(String time, String format)
 		throws FunctionExecutionException {
-		java.util.Date date = null;
 
-		if (time == null || format == null) {
-			return null;
-		}
-
 		try {
-			DateFormat df= new SimpleDateFormat((String) format);
-			date = df.parse((String) time);
+			DateFormat df= new SimpleDateFormat(format);
+			Date date = df.parse(time);
             return TimestampWithTimezone.createTime(date);
 		} catch (java.text.ParseException pe) {
 			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
@@ -1556,17 +1166,12 @@
 		}
 	}
 
-	public static Object parseTimestamp(Object timestamp, Object format)
+	public static Object parseTimestamp(String timestamp, String format)
 		throws FunctionExecutionException {
-		java.util.Date date = null;
 
-		if (timestamp == null || format == null) {
-			return null;
-		}
-
 		try {
-			DateFormat df= new SimpleDateFormat((String) format);
-			date = df.parse((String) timestamp);
+			DateFormat df= new SimpleDateFormat(format);
+			Date date = df.parse(timestamp);
             return new Timestamp(date.getTime());
 		} catch (java.text.ParseException pe) {
 			throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
@@ -1679,82 +1284,38 @@
 	}
 
 	// ================== Function - ACOS =====================
-	public static Object acos(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.acos(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "acos", number.getClass().getName())); //$NON-NLS-1$
+	public static Object acos(Double number) {
+		return new Double(Math.acos(number.doubleValue()));
 	}
 
 	// ================== Function - ASIN =====================
-	public static Object asin(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.asin(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "asin", number.getClass().getName())); //$NON-NLS-1$
+	public static Object asin(Double number) {
+		return new Double(Math.asin(number.doubleValue()));
 	}
 
-
 	// ================== Function - ATAN =====================
-	public static Object atan(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.atan(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "atan", number.getClass().getName())); //$NON-NLS-1$
+	public static Object atan(Double number) {
+		return new Double(Math.atan(number.doubleValue()));
 	}
 
 	// ================== Function - ATAN2 =====================
-	public static Object atan2(Object number1, Object number2) throws FunctionExecutionException {
-		if(number1 == null || number2 == null){
-			return null;
-		}
-		if(number1 instanceof Double && number2 instanceof Double ){
-			return new Double(Math.atan2(((Double)number1).doubleValue(), ((Double)number2).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, "atan2", number1.getClass().getName(), number2.getClass().getName())); //$NON-NLS-1$
+	public static Object atan2(Double number1, Double number2) {
+		return new Double(Math.atan2(number1.doubleValue(), number2.doubleValue()));
 	}
 
 	// ================== Function - COS =====================
-	public static Object cos(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.cos(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "cos", number.getClass().getName())); //$NON-NLS-1$
+	public static Object cos(Double number) {
+		return new Double(Math.cos(number.doubleValue()));
 	}
 
 	// ================== Function - COT =====================
-	public static Object cot(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(1/Math.tan(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "cot", number.getClass().getName())); //$NON-NLS-1$
+	public static Object cot(Double number) {
+		return new Double(1/Math.tan(number.doubleValue()));
 	}
 
-
 	// ================== Function - DEGREES =====================
-	public static Object degrees(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.toDegrees(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "degrees", number.getClass().getName())); //$NON-NLS-1$
+	public static Object degrees(Double number) {
+		return new Double(Math.toDegrees(number.doubleValue()));
 	}
 
 	// ================== Function - PI =====================
@@ -1763,89 +1324,38 @@
 	}
 
 	// ================== Function - RADIANS =====================
-	public static Object radians(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.toRadians(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "redians", number.getClass().getName())); //$NON-NLS-1$
+	public static Object radians(Double number) {
+		return new Double(Math.toRadians(number.doubleValue()));
 	}
 
 	// ================== Function - SIN =====================
-	public static Object sin(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.sin(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "sin", number.getClass().getName())); //$NON-NLS-1$
+	public static Object sin(Double number) {
+		return new Double(Math.sin(number.doubleValue()));
 	}
 
 	// ================== Function - TAN =====================
-	public static Object tan(Object number) throws FunctionExecutionException {
-		if(number == null){
-			return null;
-		}
-		if(number instanceof Double){
-			return new Double(Math.tan(((Double)number).doubleValue()));
-		}
-		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "tan", number.getClass().getName())); //$NON-NLS-1$
+	public static Object tan(Double number) {
+		return new Double(Math.tan(number.doubleValue()));
 	}
 
     // ================== Function - BITAND =====================
-	public static Object bitand(Object x, Object y) throws FunctionExecutionException {
-        if (x == null || y == null) {
-            return null;
-        }
-        if (!(x instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitand", x.getClass().getName())); //$NON-NLS-1$
-        }
-        if (!(y instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitand", y.getClass().getName())); //$NON-NLS-1$
-        }
-        return new Integer(((Integer)x).intValue() & ((Integer)y).intValue());
+	public static Object bitand(int x, int y) {
+        return x & y;
 	}
 
     // ================== Function - BITOR =====================
-    public static Object bitor(Object x, Object y) throws FunctionExecutionException {
-        if (x == null || y == null) {
-            return null;
-        }
-        if (!(x instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitor", x.getClass().getName())); //$NON-NLS-1$
-        }
-        if (!(y instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitor", y.getClass().getName())); //$NON-NLS-1$
-        }
-        return new Integer(((Integer)x).intValue() | ((Integer)y).intValue());
+    public static Object bitor(int x, int y) {
+        return x | y;
     }
 
     // ================== Function - BITXOR =====================
-    public static Object bitxor(Object x, Object y) throws FunctionExecutionException {
-        if (x == null || y == null) {
-            return null;
-        }
-        if (!(x instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitxor", x.getClass().getName())); //$NON-NLS-1$
-        }
-        if (!(y instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitxor", y.getClass().getName())); //$NON-NLS-1$
-        }
-        return new Integer(((Integer)x).intValue() ^ ((Integer)y).intValue());
+    public static Object bitxor(int x, int y) {
+        return x ^ y;
     }
 
     // ================== Function - BITNOT =====================
-    public static Object bitnot(Object x) throws FunctionExecutionException {
-        if (x == null) {
-            return null;
-        }
-        if (!(x instanceof Integer)) {
-            throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "bitxor", x.getClass().getName())); //$NON-NLS-1$
-        }
-        return new Integer(((Integer)x).intValue() ^ 0xFFFFFFFF);
+    public static int bitnot(int x) {
+        return x ^ 0xFFFFFFFF;
     }
 
     // ================= Function - USER ========================
@@ -1863,57 +1373,42 @@
         return payload.toString();
     }
 
-    public static Object commandPayload(CommandContext context, Object param) 
+    public static Object commandPayload(CommandContext context, String param) 
         throws ExpressionEvaluationException, FunctionExecutionException{
         Serializable payload = context.getCommandPayload();
-        if(payload == null || param == null) {
+        if(payload == null) {
             return null;
         }
         
-        if (param instanceof String) {
-            // 1-arg form - assume payload is a Properties object
-            if(payload instanceof Properties) {
-                String property = (String)param;                
-                return ((Properties)payload).getProperty(property);
-            }            
-            // Payload was bad
-            throw new ExpressionEvaluationException(QueryPlugin.Util.getString("ExpressionEvaluator.Expected_props_for_payload_function", "commandPayload", payload.getClass().getName())); //$NON-NLS-1$ //$NON-NLS-2$
-        }
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0071, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0070, "commandPayload", param.getClass().getName())); //$NON-NLS-1$
+        // 1-arg form - assume payload is a Properties object
+        if(payload instanceof Properties) {
+            return ((Properties)payload).getProperty(param);
+        }            
+        // Payload was bad
+        throw new ExpressionEvaluationException(QueryPlugin.Util.getString("ExpressionEvaluator.Expected_props_for_payload_function", "commandPayload", payload.getClass().getName())); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     // ================= Function - ENV ========================
-    public static Object env(CommandContext context, Object param) throws FunctionExecutionException {
-        if (param == null) {
-            return null;
-        }      
-        if (param instanceof String) {
-            // All context property keys must be lowercase - we lowercase the incoming key here to match regardless of case
-            String propertyName = ((String)param);
-            String propertyNameNocase = propertyName.toLowerCase();
-            Properties envProps = context.getEnvironmentProperties();
-            if(envProps != null && envProps.containsKey(propertyNameNocase)) {
-                return envProps.getProperty(propertyNameNocase);
-            }
-            String value = System.getProperty(propertyName);
-            if (value == null) {
-                value = System.getProperty(propertyNameNocase);
-            }
-            return value;            
+    public static Object env(CommandContext context, String propertyName) {
+        // All context property keys must be lowercase - we lowercase the incoming key here to match regardless of case
+        String propertyNameNocase = propertyName.toLowerCase();
+        Properties envProps = context.getEnvironmentProperties();
+        if(envProps != null && envProps.containsKey(propertyNameNocase)) {
+            return envProps.getProperty(propertyNameNocase);
         }
-        throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0070, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0070, "env", param.getClass().getName())); //$NON-NLS-1$
+        String value = System.getProperty(propertyName);
+        if (value == null) {
+            value = System.getProperty(propertyNameNocase);
+        }
+        return value;            
     }
     
     // ================= Function - MODIFYTIMEZONE ========================
     
-    public static Object modifyTimeZone(Object value, Object originalTimezoneString, Object targetTimezoneString) {
-        if (value == null || originalTimezoneString == null || targetTimezoneString == null) {
-            return null;
-        }
+    public static Object modifyTimeZone(Timestamp value, String originalTimezoneString, String targetTimezoneString) {
+        TimeZone originalTimeZone = TimeZone.getTimeZone(originalTimezoneString);
+        TimeZone dbmsTimeZone = TimeZone.getTimeZone(targetTimezoneString);
 
-        TimeZone originalTimeZone = TimeZone.getTimeZone((String)originalTimezoneString);
-        TimeZone dbmsTimeZone = TimeZone.getTimeZone((String)targetTimezoneString);
-
         // Check that the dbms time zone is really different than the local time zone
         if (originalTimeZone.equals(dbmsTimeZone)) {
             return value;
@@ -1921,24 +1416,15 @@
 
         Calendar cal = Calendar.getInstance(dbmsTimeZone);
         
-        Timestamp in = (Timestamp)value;
-        
-        return TimestampWithTimezone.createTimestamp(in, originalTimeZone, cal);
+        return TimestampWithTimezone.createTimestamp(value, originalTimeZone, cal);
     }
 
-    public static Object modifyTimeZone(CommandContext context, Object value, Object targetTimezoneString) {
-        if (value == null || targetTimezoneString == null) {
-            return null;
-        }
+    public static Object modifyTimeZone(CommandContext context, Timestamp value, String targetTimezoneString) {
+        TimeZone dbmsTimeZone = TimeZone.getTimeZone(targetTimezoneString);
 
-        TimeZone dbmsTimeZone = TimeZone.getTimeZone((String)targetTimezoneString);
-
         Calendar cal = Calendar.getInstance(dbmsTimeZone);
         
-        Timestamp in = (Timestamp)value;
-        
-        return TimestampWithTimezone.createTimestamp(in, context.getServerTimeZone(), cal);
+        return TimestampWithTimezone.createTimestamp(value, context.getServerTimeZone(), cal);
     } 
     
 }
-

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -22,14 +22,15 @@
 
 package com.metamatrix.query.function;
 
+import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -38,10 +39,12 @@
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.util.Assertion;
+import com.metamatrix.core.util.ReflectionHelper;
 import com.metamatrix.query.QueryPlugin;
 import com.metamatrix.query.function.metadata.FunctionCategoryConstants;
 import com.metamatrix.query.function.metadata.FunctionMethod;
 import com.metamatrix.query.function.metadata.FunctionParameter;
+import com.metamatrix.query.util.CommandContext;
 import com.metamatrix.query.util.ErrorMessageKeys;
 import com.metamatrix.query.util.LogConstants;
 
@@ -247,21 +250,11 @@
      * @return Corresponding form or null if not found
      */
     FunctionForm findFunctionForm(String name, int args) {
-        List methods = (List) functionsByName.get(name.toUpperCase());
-        if(methods == null || methods.size() == 0) {
-            return null;
-        }
-
-        Iterator iter = methods.iterator();
-        while(iter.hasNext()) {
-            FunctionMethod method = (FunctionMethod) iter.next();
-            if(method.getInputParameterCount() == args) {
-                return new FunctionForm(method);
-            }
-        }
-
-        // Didn't find it
-        return null;
+    	List<FunctionMethod> results = findFunctionMethods(name, args);
+    	if (results.size() > 0) {
+    		return new FunctionForm(results.get(0));
+    	}
+    	return null;
     }
     
     /**
@@ -270,18 +263,16 @@
      * @param args Number of arguments
      * @return Corresponding form or null if not found
      */
-    Collection findFunctionMethods(String name, int args) {
-        final Collection allMatches = new ArrayList();
-        List methods = (List) functionsByName.get(name.toUpperCase());
+    List<FunctionMethod> findFunctionMethods(String name, int args) {
+        final List<FunctionMethod> allMatches = new ArrayList<FunctionMethod>();
+        List<FunctionMethod> methods = (List<FunctionMethod>) functionsByName.get(name.toUpperCase());
         if(methods == null || methods.size() == 0) {
             return allMatches;
         }
 
-        Iterator iter = methods.iterator();
-        while(iter.hasNext()) {
-            FunctionMethod method = (FunctionMethod) iter.next();
-            if(method.getInputParameterCount() == args) {
-                allMatches.add(method);
+        for (FunctionMethod functionMethod : methods) {
+            if(functionMethod.getInputParameterCount() == args || functionMethod.isVarArgs() && args >= functionMethod.getInputParameterCount() - 1) {
+                allMatches.add(functionMethod);
             }
         }
 
@@ -301,17 +292,21 @@
 
         // Get input types for path
         FunctionParameter[] inputParams = method.getInputParameters();
-        Class[] inputTypes = null;
-        if(inputParams == null) {
-            inputTypes = new Class[0];
-        } else {
-            inputTypes = new Class[inputParams.length];
+        List<Class> inputTypes = new LinkedList<Class>();
+        if(inputParams != null) {
             for(int i=0; i<inputParams.length; i++) {
                 String typeName = inputParams[i].getType();
-                inputTypes[i] = DataTypeManager.getDataTypeClass(typeName);
+                inputTypes.add(DataTypeManager.getDataTypeClass(typeName));
             }
         }
+        Class[] types = inputTypes.toArray(new Class[inputTypes.size()]);
 
+        if (method.isVarArgs()) {
+        	inputTypes.set(inputTypes.size() - 1, Array.newInstance(inputTypes.get(inputTypes.size() - 1), 0).getClass());
+        }
+
+        inputTypes.add(0, CommandContext.class);
+
         // Get return type
         FunctionParameter outputParam = method.getOutputParameter();
         Class outputType = null;
@@ -319,100 +314,57 @@
             outputType = DataTypeManager.getDataTypeClass(outputParam.getType());
         }
 
-        // Build path
-        Object[] path = buildPath(methodName, inputTypes);
-
-        // Create function descriptor
-        FunctionDescriptor descriptor = createFunctionDescriptor(source, method, inputTypes, outputType);
-
-        // Store this path in the function tree
-        Map node = treeRoot;
-        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);
-            }
-            node = children;
-        }
-
-        // Store the leaf descriptor in the tree
-        node.put(DESCRIPTOR_KEY, descriptor);
-    }
-
-    /** 
-     * @param method
-     * @param inputTypes
-     * @param outputType
-     * @return
-     */
-    private FunctionDescriptor createFunctionDescriptor(FunctionMetadataSource source, FunctionMethod method, Class[] inputTypes, Class outputType) {
         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) {
-            // Defect 20007 - Ignore the invocation method if pushdown is required.
-            Class[] methodSignature = null;
             try {
+                Class methodClass = source.getInvocationClass(method.getInvocationClass());
+                ReflectionHelper helper = new ReflectionHelper(methodClass);
                 try {
-                    methodSignature = methodSignatureWithContext(inputTypes.length);
-                    invocationMethod = lookupMethod(source, method.getInvocationClass(), method.getInvocationMethod(), methodSignature);
-                    requiresContext = true;
-                }catch(NoSuchMethodException e) {
-                    methodSignature = methodSignature(inputTypes.length);
-                    invocationMethod = lookupMethod(source, method.getInvocationClass(), method.getInvocationMethod(), methodSignature);    
-                }                
+                	invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
+                	requiresContext = true;
+                } catch (NoSuchMethodException e) {
+		            inputTypes = inputTypes.subList(1, inputTypes.size());
+                	invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
+                }
             } catch (ClassNotFoundException e) {
               // Failed to load class, so can't load method - this will fail at invocation time.
               // We don't fail here because this situation can occur in the modeler, which does
               // not have the function jar files.  The modeler never invokes, so this isn't a
               // problem.
             } catch (Exception e) {                
-                throw new MetaMatrixRuntimeException(e, ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, Arrays.asList(methodSignature)}));
+                throw new MetaMatrixRuntimeException(e, ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, inputTypes}));
             } 
+            if(invocationMethod != null && !FunctionTree.isValidMethod(invocationMethod)) {
+            	throw new MetaMatrixRuntimeException(ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, inputTypes}));
+            }
         }
-        return new FunctionDescriptor(method.getName(), method.getPushdown(), inputTypes, outputType, invocationMethod, requiresContext, method.isNullDependent(), method.getDeterministic());
-    }
 
-    /**
-     * Find the invocation method for a function.
-     * @param source The function metadata source, which knows how to obtain the invocation class
-     * @param invocationClass The class to invoke for this function
-     * @param invocationMethod The method to invoke for this function
-     * @param numArgs Number of arguments in method
-     */
-    private Method lookupMethod(FunctionMetadataSource source, String invocationClass, String invocationMethod, Class[] methodSignature) 
-        throws NoSuchMethodException, ClassNotFoundException {
+        FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, method.isNullDependent(), method.getDeterministic());
+        // 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;
+        }
 
-		Class methodClass = source.getInvocationClass(invocationClass);
-        Method method = methodClass.getMethod(invocationMethod, methodSignature);
-
-        // Validate method
-        if(! FunctionTree.isValidMethod(method)) {
-            return null;
+        if (method.isVarArgs()) {
+        	node.put(types[types.length - 1], node);
         }
-        return method;
+        // Store the leaf descriptor in the tree
+        node.put(DESCRIPTOR_KEY, descriptor);
     }
     
-    private Class[] methodSignatureWithContext(int numArgs) {
-        // Build parameter signature
-        Class[] objectSignature = new Class[numArgs+1];
-        objectSignature[0] = com.metamatrix.query.util.CommandContext.class;
-        for(int i=1; i<numArgs+1; i++) {
-            objectSignature[i] = java.lang.Object.class;
-        }
-        return objectSignature;
-    }    
-    
-    private Class[] methodSignature(int numArgs) {
-        // Build parameter signature
-        Class[] objectSignature = new Class[numArgs];       
-        for(int i=0; i<numArgs; i++) {
-            objectSignature[i] = java.lang.Object.class;
-        }
-        return objectSignature;
-    }     
-    
 	/**
 	 * Validate a method looked up by reflection.  The method should have a non-void return type
 	 * and be a public static method.
@@ -454,12 +406,9 @@
         // Walk path in tree
         Map node = treeRoot;
         for(int i=0; i<path.length; i++) {
-            if(node.containsKey(path[i])) {
-                // Walk path
-                node = (Map) node.get(path[i]);
-            } else {
-                // No known path for this part - no match
-                return null;
+        	node = (Map)node.get(path[i]);
+        	if (node == null) {
+        		return null;
             }
         }
 

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMethod.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMethod.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -473,5 +473,12 @@
     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;
+    }
      
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionParameter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionParameter.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionParameter.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -38,6 +38,7 @@
     private String name;  
     private String type;
     private String description;
+    private boolean isVarArg;
 
     /**
      * Construct a function parameter with no attributes.
@@ -51,8 +52,7 @@
      * @param type Type from standard set of types
      */
     public FunctionParameter(String name, String type) {
-        setName(name);
-        setType(type);
+        this(name, type, null);
     }
     
     /**
@@ -62,10 +62,15 @@
      * @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.
@@ -143,17 +148,15 @@
     public boolean equals(Object obj) {
         if(obj == this) { 
             return true;
-        } else if(obj == null) { 
-            return false;
-        } else if(obj instanceof FunctionParameter) { 
-            FunctionParameter other = (FunctionParameter) obj;
-            if(other.getType() == null) { 
-                return (this.getType() == null);
-            }
-            return other.getType().equals(this.getType());
-        } else {
-            return false;
-        }    
+        } 
+        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;
     }
        
     /**
@@ -161,7 +164,15 @@
      * @return String representation of function parameter
      */ 
     public String toString() { 
-        return type + " " + name; //$NON-NLS-1$
+        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/com/metamatrix/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -58,10 +58,10 @@
      */
     public SystemSource() {
 		// +, -, *, /
-        addArithmeticFunction(SourceSystemFunctions.ADD_OP, QueryPlugin.Util.getString("SystemSource.Add_desc"), "plus", QueryPlugin.Util.getString("SystemSource.Add_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addArithmeticFunction(SourceSystemFunctions.SUBTRACT_OP, QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus", QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addArithmeticFunction(SourceSystemFunctions.MULTIPLY_OP, QueryPlugin.Util.getString("SystemSource.Multiply_desc"), "multiply", QueryPlugin.Util.getString("SystemSource.Multiply_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addArithmeticFunction(SourceSystemFunctions.DIVIDE_OP, QueryPlugin.Util.getString("SystemSource.Divide_desc"), "divide", QueryPlugin.Util.getString("SystemSource.Divide_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        addArithmeticFunction(SourceSystemFunctions.ADD_OP, QueryPlugin.Util.getString("SystemSource.Add_desc"), "plus", QueryPlugin.Util.getString("SystemSource.Add_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addArithmeticFunction(SourceSystemFunctions.SUBTRACT_OP, QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus", QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addArithmeticFunction(SourceSystemFunctions.MULTIPLY_OP, QueryPlugin.Util.getString("SystemSource.Multiply_desc"), "multiply", QueryPlugin.Util.getString("SystemSource.Multiply_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addArithmeticFunction(SourceSystemFunctions.DIVIDE_OP, QueryPlugin.Util.getString("SystemSource.Divide_desc"), "divide", QueryPlugin.Util.getString("SystemSource.Divide_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         
         // numeric
         addAbsFunction();
@@ -71,45 +71,45 @@
         addRoundFunction();
         addSignFunction();
         addSqrtFunction();        
-		addDoubleFunction(SourceSystemFunctions.ACOS, QueryPlugin.Util.getString("SystemSource.Acos_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.ASIN, QueryPlugin.Util.getString("SystemSource.Asin_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.ATAN, QueryPlugin.Util.getString("SystemSource.Atan_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addAtan2Function(SourceSystemFunctions.ATAN2, QueryPlugin.Util.getString("SystemSource.Atan2_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.COS, QueryPlugin.Util.getString("SystemSource.Cos_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.COT, QueryPlugin.Util.getString("SystemSource.Cot_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.DEGREES, QueryPlugin.Util.getString("SystemSource.Degrees_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addPiFunction(SourceSystemFunctions.PI, QueryPlugin.Util.getString("SystemSource.Pi_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.RADIANS, QueryPlugin.Util.getString("SystemSource.Radians_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.SIN, QueryPlugin.Util.getString("SystemSource.Sin_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-		addDoubleFunction(SourceSystemFunctions.TAN, QueryPlugin.Util.getString("SystemSource.Tan_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-        addDoubleFunction(SourceSystemFunctions.LOG, QueryPlugin.Util.getString("SystemSource.Log_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-        addDoubleFunction(SourceSystemFunctions.LOG10, QueryPlugin.Util.getString("SystemSource.Log10_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-        addDoubleFunction(SourceSystemFunctions.CEILING, QueryPlugin.Util.getString("SystemSource.Ceiling_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-        addDoubleFunction(SourceSystemFunctions.EXP, QueryPlugin.Util.getString("SystemSource.Exp_desc")); //$NON-NLS-1$ //$NON-NLS-2$
-        addDoubleFunction(SourceSystemFunctions.FLOOR, QueryPlugin.Util.getString("SystemSource.Floor_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+		addDoubleFunction(SourceSystemFunctions.ACOS, QueryPlugin.Util.getString("SystemSource.Acos_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.ASIN, QueryPlugin.Util.getString("SystemSource.Asin_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.ATAN, QueryPlugin.Util.getString("SystemSource.Atan_desc")); //$NON-NLS-1$ 
+		addAtan2Function(SourceSystemFunctions.ATAN2, QueryPlugin.Util.getString("SystemSource.Atan2_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.COS, QueryPlugin.Util.getString("SystemSource.Cos_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.COT, QueryPlugin.Util.getString("SystemSource.Cot_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.DEGREES, QueryPlugin.Util.getString("SystemSource.Degrees_desc")); //$NON-NLS-1$ 
+		addPiFunction(SourceSystemFunctions.PI, QueryPlugin.Util.getString("SystemSource.Pi_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.RADIANS, QueryPlugin.Util.getString("SystemSource.Radians_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.SIN, QueryPlugin.Util.getString("SystemSource.Sin_desc")); //$NON-NLS-1$ 
+		addDoubleFunction(SourceSystemFunctions.TAN, QueryPlugin.Util.getString("SystemSource.Tan_desc")); //$NON-NLS-1$ 
+        addDoubleFunction(SourceSystemFunctions.LOG, QueryPlugin.Util.getString("SystemSource.Log_desc")); //$NON-NLS-1$ 
+        addDoubleFunction(SourceSystemFunctions.LOG10, QueryPlugin.Util.getString("SystemSource.Log10_desc")); //$NON-NLS-1$ 
+        addDoubleFunction(SourceSystemFunctions.CEILING, QueryPlugin.Util.getString("SystemSource.Ceiling_desc")); //$NON-NLS-1$ 
+        addDoubleFunction(SourceSystemFunctions.EXP, QueryPlugin.Util.getString("SystemSource.Exp_desc")); //$NON-NLS-1$ 
+        addDoubleFunction(SourceSystemFunctions.FLOOR, QueryPlugin.Util.getString("SystemSource.Floor_desc")); //$NON-NLS-1$ 
         
         // bit
-        addBitFunction(SourceSystemFunctions.BITAND, QueryPlugin.Util.getString("SystemSource.Bitand_desc"), "bitand", 2, QueryPlugin.Util.getString("SystemSource.Bitand_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addBitFunction(SourceSystemFunctions.BITOR, QueryPlugin.Util.getString("SystemSource.Bitor_desc"), "bitor", 2, QueryPlugin.Util.getString("SystemSource.Bitor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addBitFunction(SourceSystemFunctions.BITXOR, QueryPlugin.Util.getString("SystemSource.Bitxor_desc"), "bitxor", 2, QueryPlugin.Util.getString("SystemSource.Bitxor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addBitFunction(SourceSystemFunctions.BITNOT, QueryPlugin.Util.getString("SystemSource.Bitnot_desc"), "bitnot", 1, QueryPlugin.Util.getString("SystemSource.Bitnot_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        addBitFunction(SourceSystemFunctions.BITAND, QueryPlugin.Util.getString("SystemSource.Bitand_desc"), "bitand", 2, QueryPlugin.Util.getString("SystemSource.Bitand_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addBitFunction(SourceSystemFunctions.BITOR, QueryPlugin.Util.getString("SystemSource.Bitor_desc"), "bitor", 2, QueryPlugin.Util.getString("SystemSource.Bitor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addBitFunction(SourceSystemFunctions.BITXOR, QueryPlugin.Util.getString("SystemSource.Bitxor_desc"), "bitxor", 2, QueryPlugin.Util.getString("SystemSource.Bitxor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addBitFunction(SourceSystemFunctions.BITNOT, QueryPlugin.Util.getString("SystemSource.Bitnot_desc"), "bitnot", 1, QueryPlugin.Util.getString("SystemSource.Bitnot_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 
         // date
-        addConstantDateFunction(SourceSystemFunctions.CURDATE, QueryPlugin.Util.getString("SystemSource.Curdate_desc"), "currentDate", DataTypeManager.DefaultDataTypes.DATE); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addConstantDateFunction(SourceSystemFunctions.CURTIME, QueryPlugin.Util.getString("SystemSource.Curtime_desc"), "currentTime", DataTypeManager.DefaultDataTypes.TIME); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addConstantDateFunction(SourceSystemFunctions.NOW, QueryPlugin.Util.getString("SystemSource.Now_desc"), "currentTimestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addDateFunction(SourceSystemFunctions.DAYNAME, "dayName", QueryPlugin.Util.getString("SystemSource.Dayname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.DAYOFMONTH, "dayOfMonth", QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.DAYOFWEEK, "dayOfWeek", QueryPlugin.Util.getString("SystemSource.Dayofweek_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofweek_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.DAYOFYEAR, "dayOfYear", QueryPlugin.Util.getString("SystemSource.Dayofyear_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofyear_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.MONTH, "month", QueryPlugin.Util.getString("SystemSource.Month_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Month_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.MONTHNAME, "monthName", QueryPlugin.Util.getString("SystemSource.Monthname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Monthname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.WEEK, "week", QueryPlugin.Util.getString("SystemSource.Week_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Week_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addDateFunction(SourceSystemFunctions.YEAR, "year", QueryPlugin.Util.getString("SystemSource.Year_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Year_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addTimeFunction(SourceSystemFunctions.HOUR, "hour", QueryPlugin.Util.getString("SystemSource.Hour_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Hour_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addTimeFunction(SourceSystemFunctions.MINUTE, "minute", QueryPlugin.Util.getString("SystemSource.Minute_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Minute_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addTimeFunction(SourceSystemFunctions.SECOND, "second", QueryPlugin.Util.getString("SystemSource.Second_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Second_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		addQuarterFunction(SourceSystemFunctions.QUARTER, "quarter", QueryPlugin.Util.getString("SystemSource.Quarter_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Quarter_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        addConstantDateFunction(SourceSystemFunctions.CURDATE, QueryPlugin.Util.getString("SystemSource.Curdate_desc"), "currentDate", DataTypeManager.DefaultDataTypes.DATE); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addConstantDateFunction(SourceSystemFunctions.CURTIME, QueryPlugin.Util.getString("SystemSource.Curtime_desc"), "currentTime", DataTypeManager.DefaultDataTypes.TIME); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addConstantDateFunction(SourceSystemFunctions.NOW, QueryPlugin.Util.getString("SystemSource.Now_desc"), "currentTimestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addDateFunction(SourceSystemFunctions.DAYNAME, "dayName", QueryPlugin.Util.getString("SystemSource.Dayname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.DAYOFMONTH, "dayOfMonth", QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.DAYOFWEEK, "dayOfWeek", QueryPlugin.Util.getString("SystemSource.Dayofweek_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofweek_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.DAYOFYEAR, "dayOfYear", QueryPlugin.Util.getString("SystemSource.Dayofyear_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofyear_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.MONTH, "month", QueryPlugin.Util.getString("SystemSource.Month_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Month_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.MONTHNAME, "monthName", QueryPlugin.Util.getString("SystemSource.Monthname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Monthname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.WEEK, "week", QueryPlugin.Util.getString("SystemSource.Week_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Week_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addDateFunction(SourceSystemFunctions.YEAR, "year", QueryPlugin.Util.getString("SystemSource.Year_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Year_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addTimeFunction(SourceSystemFunctions.HOUR, "hour", QueryPlugin.Util.getString("SystemSource.Hour_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Hour_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addTimeFunction(SourceSystemFunctions.MINUTE, "minute", QueryPlugin.Util.getString("SystemSource.Minute_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Minute_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addTimeFunction(SourceSystemFunctions.SECOND, "second", QueryPlugin.Util.getString("SystemSource.Second_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Second_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+		addQuarterFunction(SourceSystemFunctions.QUARTER, "quarter", QueryPlugin.Util.getString("SystemSource.Quarter_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Quarter_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 		addTimestampAddFunction();
         addTimestampDiffFunction();
         addTimeZoneFunctions();
@@ -117,13 +117,13 @@
         addUnixTimeFunctions();
 		                  
         // string
-        addStringFunction(SourceSystemFunctions.LENGTH, QueryPlugin.Util.getString("SystemSource.Length_result"), "length", DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addStringFunction(SourceSystemFunctions.UCASE, QueryPlugin.Util.getString("SystemSource.Ucase_result"), "upperCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addStringFunction(SourceSystemFunctions.LCASE, QueryPlugin.Util.getString("SystemSource.Lcase_result"), "lowerCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        addStringFunction(SourceSystemFunctions.LENGTH, QueryPlugin.Util.getString("SystemSource.Length_result"), "length", DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addStringFunction(SourceSystemFunctions.UCASE, QueryPlugin.Util.getString("SystemSource.Ucase_result"), "upperCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addStringFunction(SourceSystemFunctions.LCASE, QueryPlugin.Util.getString("SystemSource.Lcase_result"), "lowerCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ 
 		addStringFunction("lower", QueryPlugin.Util.getString("SystemSource.Lower_result"), "lowerCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 		addStringFunction("upper", QueryPlugin.Util.getString("SystemSource.Upper_result"), "upperCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addStringFunction(SourceSystemFunctions.LTRIM, QueryPlugin.Util.getString("SystemSource.Left_result"), "leftTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addStringFunction(SourceSystemFunctions.RTRIM, QueryPlugin.Util.getString("SystemSource.Right_result"), "rightTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        addStringFunction(SourceSystemFunctions.LTRIM, QueryPlugin.Util.getString("SystemSource.Left_result"), "leftTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addStringFunction(SourceSystemFunctions.RTRIM, QueryPlugin.Util.getString("SystemSource.Right_result"), "rightTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ 
         addConcatFunction();    
         addSubstringFunction(); 
         addLeftRightFunctions();
@@ -140,8 +140,8 @@
 		addInsertFunction();
 		
         // clob
-        addClobFunction(SourceSystemFunctions.UCASE, QueryPlugin.Util.getString("SystemSource.UcaseClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        addClobFunction(SourceSystemFunctions.LCASE, QueryPlugin.Util.getString("SystemSource.LcaseClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        addClobFunction(SourceSystemFunctions.UCASE, QueryPlugin.Util.getString("SystemSource.UcaseClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ 
+        addClobFunction(SourceSystemFunctions.LCASE, QueryPlugin.Util.getString("SystemSource.LcaseClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ 
         addClobFunction("lower", QueryPlugin.Util.getString("SystemSource.LowerClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         addClobFunction("upper", QueryPlugin.Util.getString("SystemSource.UpperClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         
@@ -160,16 +160,16 @@
 		addIfNullFunctions();
         
 		// format 
-		addFormatTimeFunction(SourceSystemFunctions.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"), "formatTime", QueryPlugin.Util.getString("SystemSource.Formattime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		addFormatDateFunction(SourceSystemFunctions.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"), "formatDate", QueryPlugin.Util.getString("SystemSource.Formatdate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		addFormatTimestampFunction(SourceSystemFunctions.FORMATTIMESTAMP, QueryPlugin.Util.getString("SystemSource.Formattimestamp_desc"), "formatTimestamp", QueryPlugin.Util.getString("SystemSource.Formattimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		addFormatTimeFunction(SourceSystemFunctions.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"), "formatTime", QueryPlugin.Util.getString("SystemSource.Formattime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+		addFormatDateFunction(SourceSystemFunctions.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"), "formatDate", QueryPlugin.Util.getString("SystemSource.Formatdate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+		addFormatTimestampFunction(SourceSystemFunctions.FORMATTIMESTAMP, QueryPlugin.Util.getString("SystemSource.Formattimestamp_desc"), "formatTimestamp", QueryPlugin.Util.getString("SystemSource.Formattimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 
 		addFormatNumberFunctions();
 		
 		// parse
-		addParseTimeFunction(SourceSystemFunctions.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"), "parseTime", QueryPlugin.Util.getString("SystemSource.Parsetime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		addParseDateFunction(SourceSystemFunctions.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"), "parseDate", QueryPlugin.Util.getString("SystemSource.Parsedate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-		addParseTimestampFunction(SourceSystemFunctions.PARSETIMESTAMP, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_desc"), "parseTimestamp", QueryPlugin.Util.getString("SystemSource.Parsetimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		addParseTimeFunction(SourceSystemFunctions.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"), "parseTime", QueryPlugin.Util.getString("SystemSource.Parsetime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+		addParseDateFunction(SourceSystemFunctions.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"), "parseDate", QueryPlugin.Util.getString("SystemSource.Parsedate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+		addParseTimestampFunction(SourceSystemFunctions.PARSETIMESTAMP, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_desc"), "parseTimestamp", QueryPlugin.Util.getString("SystemSource.Parsetimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 		
 		addParseNumberFunctions();
         
@@ -195,21 +195,21 @@
     }
 
     private void addFormatNumberFunctions() {
-		addFormatNumberFunction(SourceSystemFunctions.FORMATINTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_desc"), "formatInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addFormatNumberFunction(SourceSystemFunctions.FORMATLONG, QueryPlugin.Util.getString("SystemSource.Formatlong_desc"), "formatLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Formatlong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addFormatNumberFunction(SourceSystemFunctions.FORMATDOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_desc"), "formatDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addFormatNumberFunction(SourceSystemFunctions.FORMATFLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_desc"), "formatFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addFormatNumberFunction(SourceSystemFunctions.FORMATBIGINTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_desc"), "formatBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addFormatNumberFunction(SourceSystemFunctions.FORMATBIGDECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_desc"), "formatBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+		addFormatNumberFunction(SourceSystemFunctions.FORMATINTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_desc"), "formatInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addFormatNumberFunction(SourceSystemFunctions.FORMATLONG, QueryPlugin.Util.getString("SystemSource.Formatlong_desc"), "formatLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Formatlong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addFormatNumberFunction(SourceSystemFunctions.FORMATDOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_desc"), "formatDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addFormatNumberFunction(SourceSystemFunctions.FORMATFLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_desc"), "formatFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addFormatNumberFunction(SourceSystemFunctions.FORMATBIGINTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_desc"), "formatBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addFormatNumberFunction(SourceSystemFunctions.FORMATBIGDECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_desc"), "formatBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
 	}
 	
 	private void addParseNumberFunctions() {
-		addParseNumberFunction(SourceSystemFunctions.PARSEINTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_desc"), "parseInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addParseNumberFunction(SourceSystemFunctions.PARSELONG, QueryPlugin.Util.getString("SystemSource.Parselong_desc"), "parseLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Parselong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addParseNumberFunction(SourceSystemFunctions.PARSEDOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_desc"), "parseDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addParseNumberFunction(SourceSystemFunctions.PARSEFLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_desc"), "parseFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addParseNumberFunction(SourceSystemFunctions.PARSEBIGINTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_desc"), "parseBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-		addParseNumberFunction(SourceSystemFunctions.PARSEBIGDECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_desc"), "parseBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_result_desc"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+		addParseNumberFunction(SourceSystemFunctions.PARSEINTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_desc"), "parseInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addParseNumberFunction(SourceSystemFunctions.PARSELONG, QueryPlugin.Util.getString("SystemSource.Parselong_desc"), "parseLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Parselong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addParseNumberFunction(SourceSystemFunctions.PARSEDOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_desc"), "parseDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addParseNumberFunction(SourceSystemFunctions.PARSEFLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_desc"), "parseFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addParseNumberFunction(SourceSystemFunctions.PARSEBIGINTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_desc"), "parseBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
+		addParseNumberFunction(SourceSystemFunctions.PARSEBIGDECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_desc"), "parseBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_result_desc"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
 	}
 	
     private void addArithmeticFunction(String functionName, String description, String methodName, String resultsDescription) {
@@ -241,7 +241,7 @@
 
     private void addTypedAbsFunction(String type) {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.ABS, QueryPlugin.Util.getString("SystemSource.Abs_desc"), NUMERIC, FUNCTION_CLASS, "abs", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.ABS, QueryPlugin.Util.getString("SystemSource.Abs_desc"), NUMERIC, FUNCTION_CLASS, "abs", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] { 
                     new FunctionParameter("number", type, QueryPlugin.Util.getString("SystemSource.Abs_arg")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.Abs_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
@@ -249,13 +249,13 @@
     
     private void addRandFunction() {
         // With Seed
-        FunctionMethod rand = new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        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);
         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$ //$NON-NLS-3$
+        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$                
     }
@@ -285,11 +285,11 @@
 	}
 			
     private void addModFunction() {
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.LONG); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.FLOAT); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.DOUBLE); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.BIG_INTEGER); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.LONG); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
+        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.FLOAT); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
+        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.DOUBLE); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
+        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.BIG_INTEGER); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
     }
     
     private void addPowerFunction() {
@@ -299,7 +299,7 @@
 
     private void addTypedPowerFunction(String baseType, String powerType) { 
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.POWER, QueryPlugin.Util.getString("SystemSource.Power_desc"), NUMERIC, FUNCTION_CLASS, "power", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.POWER, QueryPlugin.Util.getString("SystemSource.Power_desc"), NUMERIC, FUNCTION_CLASS, "power", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] { 
                     new FunctionParameter("base", baseType, QueryPlugin.Util.getString("SystemSource.Power_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("power", powerType, QueryPlugin.Util.getString("SystemSource.Power_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -315,7 +315,7 @@
 
     private void addTypedRoundFunction(String roundType) { 
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.ROUND, QueryPlugin.Util.getString("SystemSource.Round_desc"), NUMERIC, FUNCTION_CLASS, "round", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.ROUND, QueryPlugin.Util.getString("SystemSource.Round_desc"), NUMERIC, FUNCTION_CLASS, "round", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] { 
                     new FunctionParameter("number", roundType, QueryPlugin.Util.getString("SystemSource.Round_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("places", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Round_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -333,22 +333,20 @@
     
     private void addTypedSignFunction(String type) {        
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.SIGN, QueryPlugin.Util.getString("SystemSource.Sign_desc"), NUMERIC, FUNCTION_CLASS, "sign", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.SIGN, QueryPlugin.Util.getString("SystemSource.Sign_desc"), NUMERIC, FUNCTION_CLASS, "sign", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] { 
                     new FunctionParameter("number", type, QueryPlugin.Util.getString("SystemSource.Sign_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Sign_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
     } 
     
     private void addSqrtFunction() {
-        addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.INTEGER);
         addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.LONG);
-        addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.FLOAT);
         addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.DOUBLE);
     }
     
     private void addTypedSqrtFunction(String type) {        
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.SQRT, QueryPlugin.Util.getString("SystemSource.Sqrt_desc"), NUMERIC, FUNCTION_CLASS, "sqrt", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.SQRT, QueryPlugin.Util.getString("SystemSource.Sqrt_desc"), NUMERIC, FUNCTION_CLASS, "sqrt", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] { 
                     new FunctionParameter("number", type, QueryPlugin.Util.getString("SystemSource.Sqrt_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Sqrt_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
@@ -393,21 +391,21 @@
 
 	private void addTimestampAddFunction() {
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ 
 				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, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ 
 				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$
 					new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ 
 				new FunctionParameter[] {
 					new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_arg1")),  //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_arg2")),  //$NON-NLS-1$ //$NON-NLS-2$
@@ -417,14 +415,14 @@
 
     private void addTimestampDiffFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.TIMESTAMPDIFF, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.TIMESTAMPDIFF, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_arg1")),  //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("time1", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("time2", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_result_desc")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.TIMESTAMPDIFF, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.TIMESTAMPDIFF, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_arg1")),  //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("timestamp1", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -434,7 +432,7 @@
     
     private void addTimestampCreateFunction() {
         functions.add(
-              new FunctionMethod(SourceSystemFunctions.TIMESTAMPCREATE, QueryPlugin.Util.getString("SystemSource.TimestampCreate_desc"), DATETIME, FUNCTION_CLASS, "timestampCreate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+              new FunctionMethod(SourceSystemFunctions.TIMESTAMPCREATE, QueryPlugin.Util.getString("SystemSource.TimestampCreate_desc"), DATETIME, FUNCTION_CLASS, "timestampCreate", //$NON-NLS-1$ //$NON-NLS-2$ 
                   new FunctionParameter[] {
                       new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.TimestampCreate_arg1")),  //$NON-NLS-1$ //$NON-NLS-2$
                       new FunctionParameter("time", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.TimestampCreate_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
@@ -472,7 +470,7 @@
 
     private void addConcatFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.CONCAT, QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, FUNCTION_CLASS, "concat", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.CONCAT, QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, FUNCTION_CLASS, "concat", //$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$
@@ -494,14 +492,14 @@
 
     private void addSubstringFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.SUBSTRING, QueryPlugin.Util.getString("SystemSource.Substring_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.SUBSTRING, QueryPlugin.Util.getString("SystemSource.Substring_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Substring_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Substring_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Substring_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Substring_result")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.SUBSTRING, QueryPlugin.Util.getString("SystemSource.Susbstring2_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.SUBSTRING, QueryPlugin.Util.getString("SystemSource.Susbstring2_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Substring2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Substring2_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -510,13 +508,13 @@
 
     private void addLeftRightFunctions() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.LEFT, QueryPlugin.Util.getString("SystemSource.Left_desc"), STRING, FUNCTION_CLASS, "left", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.LEFT, QueryPlugin.Util.getString("SystemSource.Left_desc"), STRING, FUNCTION_CLASS, "left", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Left_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Left_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Left2_result")) ) );                 //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.RIGHT, QueryPlugin.Util.getString("SystemSource.Right_desc"), STRING, FUNCTION_CLASS, "right", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.RIGHT, QueryPlugin.Util.getString("SystemSource.Right_desc"), STRING, FUNCTION_CLASS, "right", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Right_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Right_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -524,15 +522,17 @@
     }
            
     private void addLocateFunction() {
-        functions.add(
-            new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        FunctionMethod func =
+            new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     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$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_result")) );                 //$NON-NLS-1$ //$NON-NLS-2$
+        func.setNullDependent(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$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate2_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate2_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -541,7 +541,7 @@
 
     private void addReplaceFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.REPLACE, QueryPlugin.Util.getString("SystemSource.Replace_desc"), STRING, FUNCTION_CLASS, "replace", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.REPLACE, QueryPlugin.Util.getString("SystemSource.Replace_desc"), STRING, FUNCTION_CLASS, "replace", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Replace_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Replace_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -551,7 +551,7 @@
 
 	private void addRepeatFunction() {
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.REPEAT, QueryPlugin.Util.getString("SystemSource.Repeat_desc"), STRING, FUNCTION_CLASS, "repeat", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(SourceSystemFunctions.REPEAT, QueryPlugin.Util.getString("SystemSource.Repeat_desc"), STRING, FUNCTION_CLASS, "repeat", //$NON-NLS-1$ //$NON-NLS-2$ 
 				new FunctionParameter[] {
 					new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Repeat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Repeat_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
@@ -560,7 +560,7 @@
 
 	private void addSpaceFunction() {
 		functions.add(
-			new FunctionMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, FunctionMethod.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$
@@ -568,7 +568,7 @@
 
 	private void addInsertFunction() {
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.INSERT, QueryPlugin.Util.getString("SystemSource.Insert_desc"), STRING, FUNCTION_CLASS, "insert", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(SourceSystemFunctions.INSERT, QueryPlugin.Util.getString("SystemSource.Insert_desc"), STRING, FUNCTION_CLASS, "insert", //$NON-NLS-1$ //$NON-NLS-2$ 
 				new FunctionParameter[] {
 					new FunctionParameter("str1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Insert_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("start", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Insert_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -579,12 +579,12 @@
 		
     private void addAsciiFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Ascii_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Ascii_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii2_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii2_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("char", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Ascii2_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Ascii2_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -592,7 +592,7 @@
 
 	private void addCharFunction() {
 		functions.add(
-			new FunctionMethod(SourceSystemFunctions.CHAR, QueryPlugin.Util.getString("SystemSource.Char_desc"), STRING, FUNCTION_CLASS, "chr", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new FunctionMethod(SourceSystemFunctions.CHAR, QueryPlugin.Util.getString("SystemSource.Char_desc"), STRING, FUNCTION_CLASS, "chr", //$NON-NLS-1$ //$NON-NLS-2$ 
 				new FunctionParameter[] {
 					new FunctionParameter("code", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Char_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Char_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -605,7 +605,7 @@
 	
     private void addInitCapFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.INITCAP, QueryPlugin.Util.getString("SystemSource.Initcap_desc"), STRING, FUNCTION_CLASS, "initCap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.INITCAP, QueryPlugin.Util.getString("SystemSource.Initcap_desc"), STRING, FUNCTION_CLASS, "initCap", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Initcap_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Initcap_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -613,13 +613,13 @@
 
     private void addLpadFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.LPAD, QueryPlugin.Util.getString("SystemSource.Lpad_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.LPAD, QueryPlugin.Util.getString("SystemSource.Lpad_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Lpad_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.LPAD, QueryPlugin.Util.getString("SystemSource.Lpad3_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.LPAD, QueryPlugin.Util.getString("SystemSource.Lpad3_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad3_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Lpad3_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -629,13 +629,13 @@
 
     private void addRpadFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.RPAD, QueryPlugin.Util.getString("SystemSource.Rpad1_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.RPAD, QueryPlugin.Util.getString("SystemSource.Rpad1_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad1_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rpad1_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
                 new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad1_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.RPAD, QueryPlugin.Util.getString("SystemSource.Rpad3_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.RPAD, QueryPlugin.Util.getString("SystemSource.Rpad3_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad3_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rpad3_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -645,7 +645,7 @@
 
     private void addTranslateFunction() {
         functions.add(
-            new FunctionMethod(SourceSystemFunctions.TRANSLATE, QueryPlugin.Util.getString("SystemSource.Translate_desc"), STRING, FUNCTION_CLASS, "translate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new FunctionMethod(SourceSystemFunctions.TRANSLATE, QueryPlugin.Util.getString("SystemSource.Translate_desc"), STRING, FUNCTION_CLASS, "translate", //$NON-NLS-1$ //$NON-NLS-2$ 
                 new FunctionParameter[] {
                     new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Translate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
                     new FunctionParameter("source", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Translate_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -655,7 +655,7 @@
     
     private void addConversionFunctions() {
     	for (String type : DataTypeManager.getAllDataTypeNames()) {
-            addTypedConversionFunction(SourceSystemFunctions.CONVERT, type); //$NON-NLS-1$
+            addTypedConversionFunction(SourceSystemFunctions.CONVERT, type); 
             addTypedConversionFunction("cast", type); //$NON-NLS-1$
     	}
     }
@@ -898,13 +898,13 @@
      * @since 4.2
      */
     private void addXpathFunction() {
-        functions.add(new FunctionMethod(SourceSystemFunctions.XPATHVALUE, QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        functions.add(new FunctionMethod(SourceSystemFunctions.XPATHVALUE, QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ 
                             new FunctionParameter[] { 
                                 new FunctionParameter("document", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                                 new FunctionParameter("xpath", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$ 
                             new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_result")) ) );       //$NON-NLS-1$ //$NON-NLS-2$
 
-        functions.add(new FunctionMethod(SourceSystemFunctions.XPATHVALUE, QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        functions.add(new FunctionMethod(SourceSystemFunctions.XPATHVALUE, QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ 
                                          new FunctionParameter[] { 
                                              new FunctionParameter("document", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xpath_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                                              new FunctionParameter("xpath", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$ 
@@ -913,14 +913,14 @@
     }
     
     private void addTimeZoneFunctions() {
-        functions.add(new FunctionMethod(SourceSystemFunctions.MODIFYTIMEZONE, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        functions.add(new FunctionMethod(SourceSystemFunctions.MODIFYTIMEZONE, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ 
                             new FunctionParameter[] { 
                                 new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                                 new FunctionParameter("startTimeZone", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param2")), //$NON-NLS-1$ //$NON-NLS-2$
                                 new FunctionParameter("endTimeZone", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param3"))}, //$NON-NLS-1$ //$NON-NLS-2$ 
                             new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_result")) ) );       //$NON-NLS-1$ //$NON-NLS-2$
 
-        functions.add(new FunctionMethod(SourceSystemFunctions.MODIFYTIMEZONE, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        functions.add(new FunctionMethod(SourceSystemFunctions.MODIFYTIMEZONE, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ 
                                          new FunctionParameter[] { 
                                              new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param1")), //$NON-NLS-1$ //$NON-NLS-2$
                                              new FunctionParameter("endTimeZone", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param3"))}, //$NON-NLS-1$ //$NON-NLS-2$ 
@@ -945,13 +945,13 @@
                 new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.nullif_result")), true, FunctionMethod.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    //TODO: add support for varargs
     private void addTypedCoalesceFunction(String type) {
         functions.add(
-            new FunctionMethod(FunctionLibrary.COALESCE, QueryPlugin.Util.getString("SystemSource.coalesce_description"), MISCELLANEOUS, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ 
+            new FunctionMethod(FunctionLibrary.COALESCE, QueryPlugin.Util.getString("SystemSource.coalesce_description"), MISCELLANEOUS, FunctionMethod.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("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$
     }
 		

Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -165,12 +165,12 @@
     private static final Map<String, String> ALIASED_FUNCTIONS = new HashMap<String, String>();
     
     static {
-    	ALIASED_FUNCTIONS.put("lower", SourceSystemFunctions.LCASE);
-    	ALIASED_FUNCTIONS.put("upper", SourceSystemFunctions.UCASE);
-    	ALIASED_FUNCTIONS.put("cast", SourceSystemFunctions.CONVERT);
-    	ALIASED_FUNCTIONS.put("nvl", SourceSystemFunctions.IFNULL);
-    	ALIASED_FUNCTIONS.put("||", SourceSystemFunctions.CONCAT);
-    	ALIASED_FUNCTIONS.put("chr", SourceSystemFunctions.CHAR);
+    	ALIASED_FUNCTIONS.put("lower", SourceSystemFunctions.LCASE); //$NON-NLS-1$
+    	ALIASED_FUNCTIONS.put("upper", SourceSystemFunctions.UCASE); //$NON-NLS-1$
+    	ALIASED_FUNCTIONS.put("cast", SourceSystemFunctions.CONVERT); //$NON-NLS-1$
+    	ALIASED_FUNCTIONS.put("nvl", SourceSystemFunctions.IFNULL); //$NON-NLS-1$
+    	ALIASED_FUNCTIONS.put("||", SourceSystemFunctions.CONCAT); //$NON-NLS-1$
+    	ALIASED_FUNCTIONS.put("chr", SourceSystemFunctions.CHAR); //$NON-NLS-1$
     }
 
 	private QueryRewriter() { }
@@ -2016,7 +2016,7 @@
 		if (function.getName().equalsIgnoreCase(FunctionLibrary.SPACE)) {
 			//change the function into timestampadd
 			Function result = new Function(SourceSystemFunctions.REPEAT,
-					new Expression[] {new Constant(" "), function.getArg(0)});
+					new Expression[] {new Constant(" "), function.getArg(0)}); //$NON-NLS-1$
 			//resolve the function
 			FunctionDescriptor descriptor = 
 	        	FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.REPEAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER});
@@ -2049,7 +2049,6 @@
 			return rewriteExpression(caseExpr, procCommand, context, metadata);
 		}
 		
-		//TODO: add proper support for COALESCE
 		if (function.getName().equalsIgnoreCase(FunctionLibrary.COALESCE)) {
 			Expression[] args = function.getArgs();
 			if (args.length == 2) {
@@ -2062,22 +2061,6 @@
 				result.setType(function.getType());
 				return rewriteFunction(result, procCommand, context, metadata);
 			}
-			
-			//rewrite coalesce(a, b) => case when (a is not null) then a when (b is not null) b else null
-			List<Criteria> when = new ArrayList<Criteria>(args.length);
-			List<Expression> then = new ArrayList<Expression>(args.length);
-			for (int i = 0; i < args.length; i++) {
-				IsNullCriteria inc = new IsNullCriteria(args[i]);
-				inc.setNegated(true);
-				when.add(inc);
-				then.add(args[i]);
-			}
-			
-			Constant nullConstant = new Constant(null, function.getType());
-			SearchedCaseExpression caseExpr = new SearchedCaseExpression(when, then);
-			caseExpr.setElseExpression(nullConstant);
-			caseExpr.setType(function.getType());
-			return rewriteExpression(caseExpr, procCommand, context, metadata);
 		}
 		
 		//rewrite concat2 - CONCAT2(a, b) ==> CASE WHEN (a is NULL AND b is NULL) THEN NULL ELSE CONCAT( NVL(a, ''), NVL(b, '') )

Modified: trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties	2009-03-12 16:07:02 UTC (rev 550)
@@ -784,8 +784,7 @@
 SystemSource.nullif_param2=Second parameter
 SystemSource.nullif_result=null if the parameters are equivalent else param1
 SystemSource.coalesce_description=Returns the first non-null parameter
-SystemSource.coalesce_param1=First parameter
-SystemSource.coalesce_param2=Second parameter
+SystemSource.coalesce_param1=parameter
 SystemSource.coalesce_result=The first non-null parameter
 TempMetadataAdapter.Element_____{0}_____not_found._1=Element ''{0}'' not found.
 TempMetadataAdapter.Group_____{0}_____not_found._1=Group ''{0}'' not found.

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -48,12 +48,12 @@
 
     // ################################## TEST HELPERS ################################
 
-    private void helpConcat(Object s1, Object s2, Object expected) throws FunctionExecutionException {
+    private void helpConcat(String s1, String s2, Object expected) throws FunctionExecutionException {
         Object actual = FunctionMethods.concat(s1, s2);
         assertEquals("concat(" + s1 + ", " + s2 + ") failed.", expected, actual);	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public static void helpTrim(Object str, boolean left, Object expected) throws FunctionExecutionException {
+    public static void helpTrim(String str, boolean left, Object expected) {
         Object actual = null;
         if (left) {
             actual = FunctionMethods.leftTrim(str);
@@ -64,27 +64,27 @@
         }
     }
 
-    public static void helpLeft(Object str, int count, Object expected) throws FunctionExecutionException {
+    public static void helpLeft(String str, int count, Object expected) throws FunctionExecutionException {
         Object actual = FunctionMethods.left(str, new Integer(count));
         assertEquals("left(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public static void helpRight(Object str, int count, Object expected) throws FunctionExecutionException {
+    public static void helpRight(String str, int count, Object expected) throws FunctionExecutionException {
         Object actual = FunctionMethods.right(str, new Integer(count));
         assertEquals("right(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public static void helpReplace(Object str, Object sub, Object replace, Object expected) throws FunctionExecutionException {
+    public static void helpReplace(String str, String sub, String replace, Object expected) {
         Object actual = FunctionMethods.replace(str, sub, replace);
         assertEquals("replace(" + str + "," + sub + "," + replace + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public static void helpSubstring(Object str, Object start, Object length, Object expected) throws FunctionExecutionException {
+    public static void helpSubstring(String str, Integer start, Integer length, Object expected) throws FunctionExecutionException {
         Object actual = FunctionMethods.substring(str, start, length);
         assertEquals("substring(" + str + "," + start + "," + length + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public static void helpSubstring(Object str, Object start, Object expected) throws FunctionExecutionException {
+    public static void helpSubstring(String str, Integer start, Object expected) throws FunctionExecutionException {
         Object actual = FunctionMethods.substring(str, start);
         assertEquals("substring(" + str + "," + start + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
@@ -102,7 +102,7 @@
         } 
     }
 
-    public static void helpTestInitCap(String input, String expected) throws FunctionExecutionException {
+    public static void helpTestInitCap(String input, String expected) {
         String actual = (String) FunctionMethods.initCap(input);
         assertEquals("Didn't get expected result from initCap", expected, actual); //$NON-NLS-1$
     }
@@ -138,8 +138,8 @@
         assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
     }
 
-    public static void helpTestLocate(String locateString, String input, int start, int expectedLocation) throws FunctionExecutionException {
-        Integer location = (Integer) FunctionMethods.locate(locateString, input, new Integer(start));
+    public static void helpTestLocate(String locateString, String input, Integer start, int expectedLocation) {
+        Integer location = (Integer) FunctionMethods.locate(locateString, input, start);
         int actualLocation = location.intValue();
         assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
     }
@@ -175,13 +175,19 @@
                      expected, actual.toString()); 
     }
 
-    public static void helpTestTimestampAdd(String intervalType, int intervalCount, Object datetime, String expected) throws FunctionExecutionException {
-        Object actual = FunctionMethods.timestampAdd(intervalType, new Integer(intervalCount), datetime);
-        assertEquals("timestampadd(" + intervalType + ", " + intervalCount + ", " + datetime + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-                     expected, new Constant(actual).toString()); 
-    }
+    public static void helpTestTimestampDiff(String intervalType, Timestamp timeStamp1, Timestamp timeStamp2, Long expected) throws FunctionExecutionException {
+        Object actual = FunctionMethods.timestampDiff(intervalType, timeStamp1, timeStamp2);
+        assertEquals("timestampDiff(" + intervalType + ", " + timeStamp1 + ", " + timeStamp2 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+                     expected, actual); 
 
-    public static void helpTestTimestampDiff(String intervalType, Object timeStamp1, Object timeStamp2, Long expected) throws FunctionExecutionException {
+        // test reverse - should be 
+        Long expected2 = new Long(0 - expected.longValue());
+        Object actual2 = FunctionMethods.timestampDiff(intervalType, timeStamp2, timeStamp1);
+        assertEquals("timestampDiff(" + intervalType + ", " + timeStamp2 + ", " + timeStamp1 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+                     expected2, actual2); 
+    }
+    
+    public static void helpTestTimestampDiff(String intervalType, Time timeStamp1, Time timeStamp2, Long expected) throws FunctionExecutionException {
         Object actual = FunctionMethods.timestampDiff(intervalType, timeStamp1, timeStamp2);
         assertEquals("timestampDiff(" + intervalType + ", " + timeStamp1 + ", " + timeStamp2 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                      expected, actual); 
@@ -207,32 +213,12 @@
         helpConcat("x", "y", "xy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testConcat2() throws FunctionExecutionException {
-        helpConcat(null, "x", null); //$NON-NLS-1$
-    }
-
-    public void testConcat3() throws FunctionExecutionException {
-        helpConcat("x", null, null); //$NON-NLS-1$
-    }
-
-    public void testConcat4() throws FunctionExecutionException {
-        helpConcat(null, null, null);
-    }
-
     public void testConcat5() throws FunctionExecutionException {
         helpConcat("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     // ------------------------------ TRIM ------------------------------
 
-    public void testTrim1() throws FunctionExecutionException {
-        helpTrim(null, true, null);
-    }
-
-    public void testTrim2() throws FunctionExecutionException {
-        helpTrim(null, false, null);
-    }
-
     public void testTrim3() throws FunctionExecutionException {
         helpTrim("", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -283,10 +269,6 @@
         helpLeft("abcd", 3, "abc"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLeft3() throws FunctionExecutionException {
-        helpLeft(null, 2, null);
-    }
-
     public void testLeft4() throws FunctionExecutionException {
         helpLeft("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -313,10 +295,6 @@
         helpRight("abcd", 3, "bcd"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testRight3() throws FunctionExecutionException {
-        helpRight(null, 2, null);
-    }
-
     public void testRight4() throws FunctionExecutionException {
         helpRight("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -351,10 +329,6 @@
         helpSubstring("abc", new Integer(3), new Integer(0), ""); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testSubstring5() throws FunctionExecutionException {
-        helpSubstring(null, new Integer(3), new Integer(3), null);
-    }
-
     public void testSubstring6() throws FunctionExecutionException {
         helpSubstring("abc", new Integer(3), "c"); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -529,11 +503,6 @@
         assertEquals("Didn't get expected code", 32, code.intValue()); //$NON-NLS-1$
     }
 
-    public void testAscii3() throws FunctionExecutionException {
-        Integer code = (Integer) FunctionMethods.ascii(null);
-        assertEquals("Didn't get expected code", null, code); //$NON-NLS-1$
-    }
-
     public void testAscii4() {
         try {
             FunctionMethods.ascii(""); //$NON-NLS-1$
@@ -552,11 +521,6 @@
         assertEquals("Didn't get expected character", ' ', chr.charValue()); //$NON-NLS-1$
     }
 
-    public void testChr2() {
-        Character chr = (Character) FunctionMethods.chr(null);
-        assertEquals("Didn't get expected character", null, chr); //$NON-NLS-1$
-    }
-
     public void testNvl1() {
         String ret = (String) FunctionMethods.ifnull("x", "y"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals("Didn't get expected value", "x", ret); //$NON-NLS-1$ //$NON-NLS-2$
@@ -572,11 +536,7 @@
         assertEquals("Didn't get expected value", null, ret); //$NON-NLS-1$
     }
 
-    public void testInitCap1() throws FunctionExecutionException {
-        helpTestInitCap(null, null);
-    }
-
-    public void testInitCap2() throws FunctionExecutionException {
+    public void testInitCap2() throws Exception {
         helpTestInitCap("abc", "Abc"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
@@ -596,10 +556,6 @@
         helpTestLpad("x", 4, "   x");     //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLpad2() throws FunctionExecutionException {
-        helpTestLpad(null, 4, null);
-    }
-
     public void testLpad3() throws FunctionExecutionException {
         helpTestLpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -609,25 +565,21 @@
     }
 
     public void testLpad5() throws FunctionExecutionException {
-        helpTestLpad("", 4, "x", "xxxx");     //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestLpad("", 4, "x", "xxxx");     //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testLpad6() throws FunctionExecutionException {
-        helpTestLpad("10", 6, "0", "000010"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestLpad("10", 6, "0", "000010"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
     public void testLpad7() throws FunctionExecutionException {
-    	helpTestLpad("x", 4, "yq", "qyqx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+    	helpTestLpad("x", 4, "yq", "qyqx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
     }
 
     public void testRpad1() throws FunctionExecutionException {
         helpTestRpad("x", 4, "x   "); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testRpad2() throws FunctionExecutionException {
-        helpTestRpad(null, 4, null);
-    }
-
     public void testRpad3() throws FunctionExecutionException {
         helpTestRpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
     }
@@ -637,11 +589,11 @@
     }
 
     public void testRpad5() throws FunctionExecutionException {
-        helpTestRpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestRpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testRpad6() throws FunctionExecutionException {
-        helpTestRpad("10", 6, "0", "100000"); //$NON-NLS-1$ //$NON-NLS-2$
+        helpTestRpad("10", 6, "0", "100000"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     public void testTranslate1() throws FunctionExecutionException {
@@ -680,82 +632,48 @@
         helpTestLocate("y", "xx", 0); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testLocate5() throws FunctionExecutionException {
+    public void testLocate5() throws Exception {
         helpTestLocate("b", "abab", 3, 4); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testLocate6() throws FunctionExecutionException {
+    public void testLocate6() throws Exception {
         helpTestLocate("z", "abab", 0, 0); //$NON-NLS-1$ //$NON-NLS-2$
     }
+    
+    public void testLocate7() throws Exception {
+        helpTestLocate("z", "abab", null, 0); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+    
+    public void testLocate8() throws Exception {
+        helpTestLocate("z", "abab", -1, 0); //$NON-NLS-1$ //$NON-NLS-2$
+    }
 
-    public void testBitand() throws FunctionExecutionException {
+    public void testBitand() throws Exception {
         // Both values are integers
         Integer result = (Integer) FunctionMethods.bitand(new Integer(0xFFF), new Integer(0x0F0));
         assertNotNull("Result should not be null", result); //$NON-NLS-1$
         assertEquals("result should be 0x0F0", 0x0F0, result.intValue()); //$NON-NLS-1$
-        // first value is not an integer, but second is
-        try {
-            FunctionMethods.bitand(new String("0xFFF"), new Integer(0x0F0)); //$NON-NLS-1$
-            fail("bitand function should expect integer as first param"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
-        // first value is an integer, but second is not
-        try {
-            FunctionMethods.bitand(new Integer(0xFFF), new Long(0x0F0L));
-            fail("bitand function should expect integer as second param"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
     }
 
-    public void testBitor() throws FunctionExecutionException {
+    public void testBitor() throws Exception {
         // Both values are integers
         Integer result = (Integer) FunctionMethods.bitor(new Integer(0xFFF), new Integer(0x0F0));
         assertNotNull("Result should not be null", result); //$NON-NLS-1$
         assertEquals("result should be 0xFFF", 0xFFF, result.intValue()); //$NON-NLS-1$
-        // first value is not an integer, but second is
-        try {
-            FunctionMethods.bitor(new String("0xFFF"), new Integer(0x0F0)); //$NON-NLS-1$
-            fail("bitor function should expect integer as first param"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
-        // first value is an integer, but second is not
-        try {
-            FunctionMethods.bitor(new Integer(0xFFF), new Long(0x0F0L));
-            fail("bitor function should expect integer as second param"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
     }
 
-    public void testBitxor() throws FunctionExecutionException {
+    public void testBitxor() throws Exception {
         // Both values are integers
         Integer result = (Integer) FunctionMethods.bitxor(new Integer(0xFFF), new Integer(0x0F0));
         assertNotNull("Result should not be null", result); //$NON-NLS-1$
         assertEquals("result should be 0xF0F", 0xF0F, result.intValue()); //$NON-NLS-1$
-        // first value is not an integer, but second is
-        try {
-            FunctionMethods.bitxor(new String("0xFFF"), new Integer(0x0F0)); //$NON-NLS-1$
-            fail("bitxor function should expect integer as first param"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
-        // first value is an integer, but second is not
-        try {
-            FunctionMethods.bitxor(new Integer(0xFFF), new Long(0x0F0L));
-            fail("bitxor function should expect integer as second param"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
     }
 
-    public void testBitnot() throws FunctionExecutionException {
+    public void testBitnot() {
         // Both values are integers
         Integer result = (Integer) FunctionMethods.bitnot(new Integer(0xF0F));
         assertNotNull("Result should not be null", result); //$NON-NLS-1$
         assertEquals("result should be 0xFFFFF0F0", 0xFFFFF0F0, result.intValue()); //$NON-NLS-1$
-        // first value is not an integer, but second is
-        try {
-            FunctionMethods.bitnot(new String("0xFFF")); //$NON-NLS-1$
-            fail("bitnot function should expect an integer"); //$NON-NLS-1$
-        } catch (FunctionExecutionException e) {
-        }
     }
 
     public void testRoundInteger1() throws FunctionExecutionException {
@@ -950,17 +868,16 @@
         helpTestTimestampCreate(TimestampUtil.createDate(103, 11, 1), TimestampUtil.createTime(23, 59, 59), "2003-12-01 23:59:59.0"); //$NON-NLS-1$
     }
 
-    public void testTimestampAdd1() throws FunctionExecutionException {
-        helpTestTimestampAdd(ReservedWords.SQL_TSI_DAY, 3, TimestampUtil.createDate(103, 11, 1), "{d'2003-12-04'}"); //$NON-NLS-1$
+    public void testTimestampAdd1() throws Exception {
+        assertEquals(TimestampUtil.createDate(103, 11, 4), FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_DAY, 3, TimestampUtil.createDate(103, 11, 1))); 
     }
 
-    public void testTimestampAdd2() throws FunctionExecutionException {
-        helpTestTimestampAdd(ReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0),
-                             "{ts'2003-12-01 18:20:30.0'}"); //$NON-NLS-1$
+    public void testTimestampAdd2() throws Exception {
+    	assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
     }
 
-    public void testTimestampAdd3() throws FunctionExecutionException {
-        helpTestTimestampAdd(ReservedWords.SQL_TSI_MINUTE, 90, TimestampUtil.createTime(10, 20, 30), "{t'11:50:30'}"); //$NON-NLS-1$
+    public void testTimestampAdd3() throws Exception {
+    	assertEquals(TimestampUtil.createTime(11, 50, 30), FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_MINUTE, 90, TimestampUtil.createTime(10, 20, 30)));
     }
 
     public void testTimestampDiffTimeStamp_FracSec_1() throws FunctionExecutionException {
@@ -1170,10 +1087,6 @@
      * against the system default timezone (not the startTz shown below).  The fianl date value is also being read
      * against the default timezone and not the endTz shown. 
      */
-    public void testModifyTimeZoneNull() throws Exception {
-        helpTestModifyTimeZone(null, "GMT+00:00", "GMT-01:00", null); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
     public void testModifyTimeZoneGMT() throws Exception {
         helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "GMT+00:00", "GMT-01:00", "2004-10-03 16:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -32,7 +32,11 @@
 import java.util.Properties;
 import java.util.TimeZone;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.connector.api.SourceSystemFunctions;
 
 import com.metamatrix.api.exception.query.FunctionExecutionException;
 import com.metamatrix.api.exception.query.InvalidFunctionException;
@@ -43,7 +47,7 @@
 import com.metamatrix.query.unittest.TimestampUtil;
 import com.metamatrix.query.util.CommandContext;
 
-public class TestFunctionLibrary extends TestCase {
+public class TestFunctionLibrary {
 
 	// These are just used as shorthand convenience to make unit tests more readable below
 	private static final Class T_STRING = DataTypeManager.DefaultDataClasses.STRING;
@@ -60,17 +64,11 @@
 	
 	private FunctionLibrary library = FunctionLibraryManager.getFunctionLibrary();
 
-    // ################################## FRAMEWORK ################################
-	
-	public TestFunctionLibrary(String name) { 
-		super(name);
-	}	
-	
-	public void setUp() { 
+	@Before public void setUp() { 
 		TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00")); //$NON-NLS-1$ 
 	}
 	
-	public void tearDown() { 
+	@After public void tearDown() { 
 		TimestampWithTimezone.resetCalendar(null);
 	}
 	
@@ -260,90 +258,90 @@
     }    
 	// ################################## ACTUAL TESTS ################################
 	
-	public void testFindFunction1() { 
+	@Test public void testFindFunction1() { 
 		helpFindFunction("convert", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
             helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }) );
 	}
 	
-	public void testFindFunction2() { 
+	@Test public void testFindFunction2() { 
 		helpFindFunction("cast", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
             helpCreateDescriptor(FunctionLibrary.CAST, new Class[] { T_INTEGER, T_STRING }) );
 	}
 	
-    public void testFindFunction3() {
+    @Test public void testFindFunction3() {
         helpFindFunction("curdate", new Class[0], //$NON-NLS-1$
         	helpCreateDescriptor("curdate", new Class[0])); //$NON-NLS-1$
     }
    
-    public void testFindFunction4() {
+    @Test public void testFindFunction4() {
         helpFindFunctionFail("curdate", new Class[] { T_INTEGER }); //$NON-NLS-1$
     }
     
-    public void testFindFunction5() {
+    @Test public void testFindFunction5() {
         helpFindFunction("+", new Class[] { T_INTEGER, T_INTEGER }, //$NON-NLS-1$
         	helpCreateDescriptor("+", new Class[] { T_INTEGER, T_INTEGER }) ); //$NON-NLS-1$
     }
     
-    public void testFindFunction6() {
+    @Test public void testFindFunction6() {
         helpFindFunctionFail("+", new Class[] {T_INTEGER, T_FLOAT}); //$NON-NLS-1$
     }
     
-    public void testFindFunction7() {
+    @Test public void testFindFunction7() {
         helpFindFunctionFail("+", new Class[] {T_INTEGER, T_FLOAT, T_INTEGER}); //$NON-NLS-1$
     }
     
-    public void testFindFunction8() {
+    @Test public void testFindFunction8() {
         helpFindFunctionFail("+", new Class[] {T_INTEGER}); //$NON-NLS-1$
     }
     
-    public void testFindFunction9() {        
+    @Test public void testFindFunction9() {        
 		helpFindFunctionFail("+", new Class[] {T_INTEGER, T_NULL });     //$NON-NLS-1$
     }
 
-    public void testFindFunction10() {
+    @Test public void testFindFunction10() {
         helpFindFunction("substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
             helpCreateDescriptor("substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }) ); //$NON-NLS-1$
     }
 
-    public void testFindFunction11() {
+    @Test public void testFindFunction11() {
         helpFindFunction("substring", new Class[] { T_STRING, T_INTEGER }, //$NON-NLS-1$
             helpCreateDescriptor("substring", new Class[] { T_STRING, T_INTEGER }) ); //$NON-NLS-1$
     }
 
-    public void testFindFunction12() {
+    @Test public void testFindFunction12() {
         helpFindFunction("context", new Class[] { T_STRING, T_INTEGER }, //$NON-NLS-1$
             helpCreateDescriptor("context", new Class[] { T_STRING, T_INTEGER }) ); //$NON-NLS-1$
     }
 
-    public void testFindFunction12a() {
+    @Test public void testFindFunction12a() {
         helpFindFunction("rowlimit", new Class[] { T_STRING }, //$NON-NLS-1$
             helpCreateDescriptor("rowlimit", new Class[] { T_STRING }) ); //$NON-NLS-1$
     }
 
-    public void testFindFunction12b() {
+    @Test public void testFindFunction12b() {
         helpFindFunction("rowlimitexception", new Class[] { T_STRING }, //$NON-NLS-1$
             helpCreateDescriptor("rowlimitexception", new Class[] { T_STRING }) ); //$NON-NLS-1$
     }
     
-	public void testFind0ArgConversion1() { 	
+	@Test public void testFind0ArgConversion1() { 	
 		helpFindConversions(
 			"curdate", new Class[] {}, //$NON-NLS-1$
 			new FunctionDescriptor[0] );
 	}
 
-	public void testFind0ArgConversion2() { 	
+	@Test public void testFind0ArgConversion2() { 	
 		helpFindConversions(
 			"curdate", new Class[] { T_INTEGER }, //$NON-NLS-1$
 			null );
 	}
 
-	public void testFind1ArgConversion1() { 	
+	@Test public void testFind1ArgConversion1() { 	
 		helpFindConversions(
 			"length", new Class[] { T_STRING }, //$NON-NLS-1$
 			new FunctionDescriptor[1] );
 	}
 
-	public void testFind1ArgConversion2() { 	
+	@Test public void testFind1ArgConversion2() { 	
 		helpFindConversions(
 			"length", new Class[] { T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -351,7 +349,7 @@
 			} );
 	}
 
-	public void testFind1ArgConversion3() { 	
+	@Test public void testFind1ArgConversion3() { 	
 		helpFindConversions(
 			"length", new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -359,13 +357,13 @@
 			} );
 	}
 
-	public void testFind2ArgConversion1() { 	
+	@Test public void testFind2ArgConversion1() { 	
 		helpFindConversions(
 			"+", new Class[] { T_INTEGER, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[2] );
 	}
 
-	public void testFind2ArgConversion2() { 	
+	@Test public void testFind2ArgConversion2() { 	
 		helpFindConversions(
 			"+", new Class[] { T_INTEGER, T_FLOAT }, //$NON-NLS-1$
 			new FunctionDescriptor[] { 
@@ -373,7 +371,7 @@
 				null } );
 	}
 
-	public void testFind2ArgConversion3() { 	
+	@Test public void testFind2ArgConversion3() { 	
 		helpFindConversions(
 			"+", new Class[] { T_FLOAT, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[] { 
@@ -381,13 +379,13 @@
                 helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }) } );
 	}
 
-	public void testFind2ArgConversion4() { 	
+	@Test public void testFind2ArgConversion4() { 	
 		helpFindConversions(
 			"+", new Class[] { T_STRING, T_FLOAT }, //$NON-NLS-1$
 			null );
 	}
 
-	public void testFind2ArgConversion5() { 	
+	@Test public void testFind2ArgConversion5() { 	
 		helpFindConversions(
 			"+", new Class[] { T_NULL, T_NULL }, //$NON-NLS-1$
 			new FunctionDescriptor[] { 
@@ -395,7 +393,7 @@
                 helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) } );
 	}
 
-	public void testFind2ArgConversion6() { 	
+	@Test public void testFind2ArgConversion6() { 	
 		helpFindConversions(
 			"+", new Class[] { T_NULL, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[] { 
@@ -403,7 +401,7 @@
 				null } );
 	}
 
-	public void testFind2ArgConversion7() { 	
+	@Test public void testFind2ArgConversion7() { 	
 		helpFindConversions(
 			"+", new Class[] { T_INTEGER, T_NULL }, //$NON-NLS-1$
 			new FunctionDescriptor[] { 
@@ -411,13 +409,13 @@
 			    helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) } );
 	}
 
-	public void testFind3ArgConversion1() { 	
+	@Test public void testFind3ArgConversion1() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[3] );
 	}
 
-	public void testFind3ArgConversion2() { 	
+	@Test public void testFind3ArgConversion2() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_INTEGER, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -427,7 +425,7 @@
 			} );
 	}
 
-	public void testFind3ArgConversion3() { 	
+	@Test public void testFind3ArgConversion3() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_INTEGER, T_INTEGER, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -437,13 +435,13 @@
 			} );
 	}
 
-	public void testFind3ArgConversion4() { 	
+	@Test public void testFind3ArgConversion4() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_STRING, T_INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP }, //$NON-NLS-1$
 			null );
 	}
 
-	public void testFind3ArgConversion5() { 	
+	@Test public void testFind3ArgConversion5() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_STRING, DataTypeManager.DefaultDataClasses.SHORT, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -453,7 +451,7 @@
 			} );
 	}
 
-	public void testFind3ArgConversion6() { 	
+	@Test public void testFind3ArgConversion6() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_INTEGER, DataTypeManager.DefaultDataClasses.SHORT, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -463,7 +461,7 @@
 			} );
 	}
 
-	public void testFind3ArgConversion7() { 	
+	@Test public void testFind3ArgConversion7() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_NULL, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -473,7 +471,7 @@
 			);
 	}
 
-	public void testFind3ArgConversion8() { 	
+	@Test public void testFind3ArgConversion8() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_NULL, T_NULL, T_INTEGER }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -483,7 +481,7 @@
 			);
 	}
 
-	public void testFind3ArgConversion9() { 	
+	@Test public void testFind3ArgConversion9() { 	
 		helpFindConversions(
 			"substring", new Class[] { T_NULL, T_NULL, T_NULL }, //$NON-NLS-1$
 			new FunctionDescriptor[] {
@@ -494,7 +492,7 @@
 	}
 
     // Walk through all functions by metadata 
-    public void testEnumerateForms() {
+    @Test public void testEnumerateForms() {
         FunctionLibrary lib = FunctionLibraryManager.getFunctionLibrary();
         
         Collection categories = lib.getFunctionCategories();
@@ -515,623 +513,623 @@
         }        
     }
 
-	public void testFindForm1() { 
+	@Test public void testFindForm1() { 
 		helpFindForm("convert", 2); //$NON-NLS-1$
 	}
  
-	public void testFindForm2() { 
+	@Test public void testFindForm2() { 
 		helpFindForm("locate", 2); //$NON-NLS-1$
 	}
     
-	public void testFindForm3() { 
+	@Test public void testFindForm3() { 
 		helpFindForm("locate", 3); //$NON-NLS-1$
 	}
 
-    public void testFindForm4() { 
+    @Test public void testFindForm4() { 
         helpFindForm("substring", 2); //$NON-NLS-1$
     }
     
-    public void testFindForm5() { 
+    @Test public void testFindForm5() { 
         helpFindForm("substring", 3); //$NON-NLS-1$
     }
  
-	public void testFindForm6() { 
+	@Test public void testFindForm6() { 
 		helpFindForm("now", 0); //$NON-NLS-1$
 	}
     
-    public void testInvokePlus1() { 
+    @Test public void testInvokePlus1() { 
     	helpInvokeMethod("+", new Object[] { new Integer(3), new Integer(2) }, new Integer(5)); //$NON-NLS-1$
     }
 
-    public void testInvokePlus2() {
+    @Test public void testInvokePlus2() {
         helpInvokeMethod("+", new Object[] { new Long(3), new Long(2) }, new Long(5)); //$NON-NLS-1$
     }
 
-    public void testInvokePlus3() {
+    @Test public void testInvokePlus3() {
         helpInvokeMethod("+", new Object[] { new Float(3), new Float(2) }, new Float(5)); //$NON-NLS-1$
     }
 
-    public void testInvokePlus4() {
+    @Test public void testInvokePlus4() {
         helpInvokeMethod("+", new Object[] { new Double(3), new Double(2) }, new Double(5)); //$NON-NLS-1$
     }
 
-    public void testInvokePlus5() {
+    @Test public void testInvokePlus5() {
         helpInvokeMethod("+", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokePlus6() {
+    @Test public void testInvokePlus6() {
         helpInvokeMethod("+", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeMinus1() {
+    @Test public void testInvokeMinus1() {
         helpInvokeMethod("-", new Object[] { new Integer(3), new Integer(2) }, new Integer(1)); //$NON-NLS-1$
     }
 
-    public void testInvokeMinus2() {
+    @Test public void testInvokeMinus2() {
         helpInvokeMethod("-", new Object[] { new Long(3), new Long(2) }, new Long(1)); //$NON-NLS-1$
     }
 
-    public void testInvokeMinus3() {
+    @Test public void testInvokeMinus3() {
         helpInvokeMethod("-", new Object[] { new Float(3), new Float(2) }, new Float(1)); //$NON-NLS-1$
     }
 
-    public void testInvokeMinus4() {
+    @Test public void testInvokeMinus4() {
         helpInvokeMethod("-", new Object[] { new Double(3), new Double(2) }, new Double(1)); //$NON-NLS-1$
     }
 
-    public void testInvokeMinus5() {
+    @Test public void testInvokeMinus5() {
         helpInvokeMethod("-", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeMinus6() {
+    @Test public void testInvokeMinus6() {
         helpInvokeMethod("-", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeMultiply1() {
+    @Test public void testInvokeMultiply1() {
         helpInvokeMethod("*", new Object[] { new Integer(3), new Integer(2) }, new Integer(6)); //$NON-NLS-1$
     }
 
-    public void testInvokeMultiply2() {
+    @Test public void testInvokeMultiply2() {
         helpInvokeMethod("*", new Object[] { new Long(3), new Long(2) }, new Long(6)); //$NON-NLS-1$
     }
 
-    public void testInvokeMultiply3() {
+    @Test public void testInvokeMultiply3() {
         helpInvokeMethod("*", new Object[] { new Float(3), new Float(2) }, new Float(6)); //$NON-NLS-1$
     }
 
-    public void testInvokeMultiply4() {
+    @Test public void testInvokeMultiply4() {
         helpInvokeMethod("*", new Object[] { new Double(3), new Double(2) }, new Double(6)); //$NON-NLS-1$
     }
 
-    public void testInvokeMultiply5() {
+    @Test public void testInvokeMultiply5() {
         helpInvokeMethod("*", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("6")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeMultiply6() {
+    @Test public void testInvokeMultiply6() {
         helpInvokeMethod("*", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("6")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeDivide1() {
+    @Test public void testInvokeDivide1() {
         helpInvokeMethod("/", new Object[] { new Integer(3), new Integer(2) }, new Integer(1)); //$NON-NLS-1$
     }
 
-    public void testInvokeDivide2() {
+    @Test public void testInvokeDivide2() {
         helpInvokeMethod("/", new Object[] { new Long(3), new Long(2) }, new Long(1)); //$NON-NLS-1$
     }
 
-    public void testInvokeDivide3() {
+    @Test public void testInvokeDivide3() {
         helpInvokeMethod("/", new Object[] { new Float(3), new Float(2) }, new Float(1.5)); //$NON-NLS-1$
     }
 
-    public void testInvokeDivide4() {
+    @Test public void testInvokeDivide4() {
         helpInvokeMethod("/", new Object[] { new Double(3), new Double(2) }, new Double(1.5)); //$NON-NLS-1$
     }
 
-    public void testInvokeDivide5() {
+    @Test public void testInvokeDivide5() {
         helpInvokeMethod("/", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
     // one digit precision
-    public void testInvokeDivide6() {
+    @Test public void testInvokeDivide6() {
         helpInvokeMethod("/", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("2"));   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeAbs1() {
+    @Test public void testInvokeAbs1() {
         helpInvokeMethod("abs", new Object[] { new Integer(-3) }, new Integer(3)); //$NON-NLS-1$
     }
 
-    public void testInvokeAbs2() {
+    @Test public void testInvokeAbs2() {
         helpInvokeMethod("abs", new Object[] { new Long(-3) }, new Long(3)); //$NON-NLS-1$
     }
 
-    public void testInvokeAbs3() {
+    @Test public void testInvokeAbs3() {
         helpInvokeMethod("abs", new Object[] { new Float(-3) }, new Float(3)); //$NON-NLS-1$
     }
 
-    public void testInvokeAbs4() {
+    @Test public void testInvokeAbs4() {
         helpInvokeMethod("abs", new Object[] { new Double(-3) }, new Double(3)); //$NON-NLS-1$
     }
 
-    public void testInvokeAbs5() {
+    @Test public void testInvokeAbs5() {
         helpInvokeMethod("abs", new Object[] { new BigInteger("-3") }, new BigInteger("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testInvokeAbs6() {
+    @Test public void testInvokeAbs6() {
         helpInvokeMethod("abs", new Object[] { new BigDecimal("-3") }, new BigDecimal("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-	public void testInvokeAcos() {
+	@Test public void testInvokeAcos() {
 		helpInvokeMethod("acos", new Object[] { new Double(0.05) }, new Double(1.5207754699891267)); //$NON-NLS-1$
 	}
 
-	public void testInvokeAsin() {
+	@Test public void testInvokeAsin() {
 		helpInvokeMethod("asin", new Object[] { new Double(0.05) }, new Double(0.050020856805770016)); //$NON-NLS-1$
 	}
 
-	public void testInvokeAtan() {
+	@Test public void testInvokeAtan() {
 		helpInvokeMethod("atan", new Object[] { new Double(0.05) }, new Double(0.049958395721942765)); //$NON-NLS-1$
 	}
 
-	public void testInvokeAtan2() {
+	@Test public void testInvokeAtan2() {
 		helpInvokeMethod("atan2", new Object[] { new Double(0.05), new Double(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
 	}
 
-	public void testInvokeCos() {
+	@Test public void testInvokeCos() {
 		helpInvokeMethod("cos", new Object[] { new Double(1.57) }, new Double(7.963267107332633E-4)); //$NON-NLS-1$
 	}
 
-	public void testInvokeCot() {
+	@Test public void testInvokeCot() {
 		helpInvokeMethod("cot", new Object[] { new Double(1.57) }, new Double(7.963269632231926E-4)); //$NON-NLS-1$
 	}
 
-	public void testInvokeDegrees() {
+	@Test public void testInvokeDegrees() {
 		helpInvokeMethod("degrees", new Object[] { new Double(1.57) }, new Double(89.95437383553926)); //$NON-NLS-1$
 	}
 
-	public void testInvokePI() {
+	@Test public void testInvokePI() {
 		helpInvokeMethod("pi", new Object[] { }, new Double(3.141592653589793)); //$NON-NLS-1$
 	}
 
-	public void testInvokeRadians() {
+	@Test public void testInvokeRadians() {
 		helpInvokeMethod("radians", new Object[] { new Double(89.95437383553926) }, new Double(1.57)); //$NON-NLS-1$
 	}
 	
-	public void testInvokeSin() {
+	@Test public void testInvokeSin() {
 		helpInvokeMethod("sin", new Object[] { new Double(1.57) }, new Double(0.9999996829318346)); //$NON-NLS-1$
 	}
 	
-	public void testInvokeTan() {
+	@Test public void testInvokeTan() {
 		helpInvokeMethod("tan", new Object[] { new Double(0.785) }, new Double(0.9992039901050427)); //$NON-NLS-1$
 	}
 							
-    public void testInvokeAscii() {
+    @Test public void testInvokeAscii() {
         helpInvokeMethod("ascii", new Object[] { " " }, new Integer(32)); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testInvokeChr() {
+    @Test public void testInvokeChr() {
         helpInvokeMethod("chr", new Object[] { new Integer(32) }, new Character(' ')); //$NON-NLS-1$
     }
     
-    public void testInvokeNvl() {
+    @Test public void testInvokeNvl() {
         helpInvokeMethod("nvl", new Object[] { new Integer(5), new Integer(10) }, new Integer(5) ); //$NON-NLS-1$
     }
 
-    public void testInvokeConcatOperator() {
+    @Test public void testInvokeConcatOperator() {
         helpInvokeMethod("||", new Object[] { "a", "b" }, "ab" );         //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
-    public void testInvokeInitcap() {
+    @Test public void testInvokeInitcap() {
         helpInvokeMethod("initcap", new Object[] { "my test\ndata" }, "My Test\nData" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testInvokeLpad1() {
+    @Test public void testInvokeLpad1() {
         helpInvokeMethod("lpad", new Object[] { "x", new Integer(3) }, "  x" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testInvokeLpad2() {
-        helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), "y" }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testInvokeLpad2() {
+        helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), "y" }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
     
-    public void testInvokeRpad1() {
+    @Test public void testInvokeRpad1() {
         helpInvokeMethod("rpad", new Object[] { "x", new Integer(3) }, "x  " ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
-    public void testInvokeRpad2() {
-        helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), "y" }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    @Test public void testInvokeRpad2() {
+        helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), "y" }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
     }
 
-    public void testInvokeTranslate() {
+    @Test public void testInvokeTranslate() {
         helpInvokeMethod("translate", new Object[] { "ababcd", "ad", "da" }, "dbdbca" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
     }
     
-	public void testFindFunction13() { 
+	@Test public void testFindFunction13() { 
 		helpFindFunction("formatTime", new Class[] { T_TIME, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatTime", new Class[] { T_TIME, T_STRING }) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFunction14() { 
+	@Test public void testFindFunction14() { 
 		helpFindFunction("formatDate", new Class[] { T_DATE, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatDate", new Class[] { T_DATE, T_STRING }) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFunction15() { 
+	@Test public void testFindFunction15() { 
 		helpFindFunction("formatTimestamp", new Class[] { T_TIMESTAMP, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatTimestamp", new Class[] { T_TIMESTAMP, T_STRING }) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFunction16() { 
+	@Test public void testFindFunction16() { 
 		helpFindFunction("parseTime", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseTime", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFunction17() { 
+	@Test public void testFindFunction17() { 
 		helpFindFunction("parseDate", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseDate", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFunction18() { 
+	@Test public void testFindFunction18() { 
 		helpFindFunction("parseTimestamp", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 				helpCreateDescriptor("parseTimestamp", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
 	}
 	
-    public void testFindFunction19() {
+    @Test public void testFindFunction19() {
         helpFindFunction("env", new Class[] {T_STRING}, //$NON-NLS-1$
                          helpCreateDescriptor("env", new Class[] {T_STRING})); //$NON-NLS-1$
     }
 
-	public void testInvokeFormatTime1() {
+	@Test public void testInvokeFormatTime1() {
 		helpInvokeMethod("formatTime", new Object[] {TimestampUtil.createTime(3,5,12), new String("h:mm a") }, "3:05 AM");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatTime2() {
+	@Test public void testInvokeFormatTime2() {
 		helpInvokeMethod("formatTime", new Object[] {TimestampUtil.createTime(13, 5,12), new String("K:mm a, z") }, "1:05 PM, GMT-06:00");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatTime3() {
+	@Test public void testInvokeFormatTime3() {
 		helpInvokeMethod("formatTime", new Object[] {TimestampUtil.createTime(13, 5,12), new String("HH:mm:ss z") }, "13:05:12 GMT-06:00");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatTime4() {
+	@Test public void testInvokeFormatTime4() {
 		TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("America/Chicago")); //$NON-NLS-1$
 		helpInvokeMethod("formatTime", new Object[] {TimestampUtil.createTime(13, 5,12), new String("hh a, zzzz") }, "01 PM, Central Standard Time");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatTimeFail() {
+	@Test public void testInvokeFormatTimeFail() {
 		helpInvokeMethodFail("formatTime", new Object[] {TimestampUtil.createTime(13, 5,12), new String("hh i, www") },  //$NON-NLS-1$ //$NON-NLS-2$
 			new FunctionExecutionException("")); //$NON-NLS-1$
 	}
 		
-	public void testInvokeFormatDate1() {
+	@Test public void testInvokeFormatDate1() {
 		helpInvokeMethod("formatDate", new Object[] {TimestampUtil.createDate(103, 2, 5), new String("yyyy.MM.dd G") }, "2003.03.05 AD");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatDate2() {
+	@Test public void testInvokeFormatDate2() {
 		helpInvokeMethod("formatDate", new Object[] {TimestampUtil.createDate(103, 2, 5), new String("EEE, MMM d, '' yy") }, "Wed, Mar 5, ' 03");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatDate3() {
+	@Test public void testInvokeFormatDate3() {
 		helpInvokeMethod("formatDate", new Object[] {new Date(12345678), new String("yyyy.MMMMM.dd GGG hh:mm aaa") }, "1969.December.31 AD 09:25 PM");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatDateFail() {
+	@Test public void testInvokeFormatDateFail() {
 		helpInvokeMethodFail("formatTime", new Object[] {TimestampUtil.createTime(103, 2, 5), new String("yyyy.i.www") },  //$NON-NLS-1$ //$NON-NLS-2$
 			new FunctionExecutionException("")); //$NON-NLS-1$
 	}
 	
-	public void testInvokeFormatTimestamp1() {
+	@Test public void testInvokeFormatTimestamp1() {
 		helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("mm/dd/yy h:mm a") }, "04/05/03 3:04 AM");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatTimestamp2() {
+	@Test public void testInvokeFormatTimestamp2() {
 		helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("yyyy-mm-dd k:mm a z") }, "2003-04-05 3:04 AM GMT-06:00");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatTimestamp3() {
+	@Test public void testInvokeFormatTimestamp3() {
 			helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("yyyy-mm-dd hh:mm:ss.SSSS") }, "2003-04-05 03:04:12.0000");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 		
-	public void testInvokeFormatTimestampFail() {
+	@Test public void testInvokeFormatTimestampFail() {
 		helpInvokeMethodFail("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("mm/dd/nn h:mm a") },  //$NON-NLS-1$ //$NON-NLS-2$
 			new FunctionExecutionException("")); //$NON-NLS-1$
 	}
 	
-	public void testInvokeParseTime1() {
+	@Test public void testInvokeParseTime1() {
 		helpInvokeMethod("parseTime", new Object[] {new String("3:12 PM"), new String("h:mm a") }, TimestampUtil.createTime(15, 12, 0));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseTime2() {
+	@Test public void testInvokeParseTime2() {
 		helpInvokeMethod("parseTime", new Object[] {new String("03:12:23 CST"), new String("hh:mm:ss z") }, TimestampUtil.createTime(3, 12, 23));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 		
-	public void testInvokeParseDate1() {
+	@Test public void testInvokeParseDate1() {
 		helpInvokeMethod("parseDate", new Object[] {new String("03/05/03"), new String("MM/dd/yy") }, TimestampUtil.createDate(103, 2, 5));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseDate2() {
+	@Test public void testInvokeParseDate2() {
 		helpInvokeMethod("parseDate", new Object[] {new String("05-Mar-03"), new String("dd-MMM-yy") }, TimestampUtil.createDate(103, 2, 5));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
-	public void testInvokeParseTimestamp1() {
+	@Test public void testInvokeParseTimestamp1() {
 		helpInvokeMethod("parseTimestamp", new Object[] {new String("05 Mar 2003 03:12:23 CST"), new String("dd MMM yyyy HH:mm:ss z") }, TimestampUtil.createTimestamp(103, 2, 5, 3, 12, 23, 0));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseTimestamp2() {
+	@Test public void testInvokeParseTimestamp2() {
 		helpInvokeMethod("parseTimestamp", new Object[] {new String("05 Mar 2003 03:12:23.333"), new String("dd MMM yyyy HH:mm:ss.SSS") }, TimestampUtil.createTimestamp(103, 2, 5, 3, 12, 23, 333*1000000));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
-	public void testFindFormatInteger() { 
+	@Test public void testFindFormatInteger() { 
 		helpFindFunction("formatInteger", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatInteger", new Class[] { T_INTEGER, T_STRING}) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFormatFloat() { 
+	@Test public void testFindFormatFloat() { 
 		helpFindFunction("formatFloat", new Class[] { T_FLOAT, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatFloat", new Class[] { T_FLOAT, T_STRING}) ); //$NON-NLS-1$
 	}
 
-	public void testFindFormatDouble() { 
+	@Test public void testFindFormatDouble() { 
 		helpFindFunction("formatDouble", new Class[] { T_DOUBLE, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatDouble", new Class[] { T_DOUBLE, T_STRING}) ); //$NON-NLS-1$
 	}
 		
-	public void testFindFormatLong() { 
+	@Test public void testFindFormatLong() { 
 		helpFindFunction("formatLong", new Class[] { T_LONG, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatLong", new Class[] { T_LONG, T_STRING}) ); //$NON-NLS-1$
 	}
 	
-	public void testFindFormatBigInteger() { 
+	@Test public void testFindFormatBigInteger() { 
 		helpFindFunction("formatBigInteger", new Class[] { T_BIG_INTEGER, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatBigInteger", new Class[] { T_BIG_INTEGER, T_STRING}) ); //$NON-NLS-1$
 	}
 
-	public void testFindFormatBigDecimal() { 
+	@Test public void testFindFormatBigDecimal() { 
 		helpFindFunction("formatBigDecimal", new Class[] { T_BIG_DECIMAL, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("formatBigDecimal", new Class[] { T_BIG_DECIMAL, T_STRING}) ); //$NON-NLS-1$
 	}
 			
-	public void testFindParseInteger() { 
+	@Test public void testFindParseInteger() { 
 		helpFindFunction("parseInteger", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseInteger", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
 	}
 	
-	public void testFindParseLong() { 
+	@Test public void testFindParseLong() { 
 		helpFindFunction("parseLong", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseLong", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
 	}
 
-	public void testFindParseDouble() { 
+	@Test public void testFindParseDouble() { 
 		helpFindFunction("parseDouble", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseDouble", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
 	}	
-	public void testFindParseFloat() { 
+	@Test public void testFindParseFloat() { 
 		helpFindFunction("parseFloat", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseFloat", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
 	}
 	
-	public void testFindParseBigInteger() { 
+	@Test public void testFindParseBigInteger() { 
 		helpFindFunction("parseBigInteger", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseBigInteger", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
 	}
 
-	public void testFindParseBigDecimal() { 
+	@Test public void testFindParseBigDecimal() { 
 		helpFindFunction("parseBigDecimal", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
 			helpCreateDescriptor("parseBigDecimal", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
 	}	
 			
-	public void testInvokeParseInteger() {
+	@Test public void testInvokeParseInteger() {
 		helpInvokeMethod("parseInteger", new Object[] {new String("-1234"), new String("######")}, new Integer(-1234));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseLong() {
+	@Test public void testInvokeParseLong() {
 		helpInvokeMethod("parseLong", new Object[] {new String("123456"), new String("######.##")}, new Long(123456));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseDouble() {
+	@Test public void testInvokeParseDouble() {
 		helpInvokeMethod("parseDouble", new Object[] {new String("123456.78"), new String("#####.#")}, new Double(123456.78));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseFloat() {
+	@Test public void testInvokeParseFloat() {
 		helpInvokeMethod("parseFloat", new Object[] {new String("1234.56"), new String("####.###")}, new Float(1234.56));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeParseBigInteger() {
+	@Test public void testInvokeParseBigInteger() {
 		helpInvokeMethod("parseBigInteger", new Object[] {new String("12345678"), new String("###,###")}, new BigInteger("12345678"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	}
 	
-	public void testInvokeParseBigDecimal() {
+	@Test public void testInvokeParseBigDecimal() {
 		helpInvokeMethod("parseBigDecimal", new Object[] {new String("1234.56"), new String("#####")}, new BigDecimal("1234.56"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	}
 
-	public void testInvokeFormatInteger() {
+	@Test public void testInvokeFormatInteger() {
 		helpInvokeMethod("formatInteger", new Object[] {new Integer(-1234), new String("######")}, "-1234");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatLong() {
+	@Test public void testInvokeFormatLong() {
 		helpInvokeMethod("formatLong", new Object[] {new Long(123456788), new String("##,###,#")}, "1,2,3,4,5,6,7,8,8");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatDouble() {
+	@Test public void testInvokeFormatDouble() {
 		helpInvokeMethod("formatDouble", new Object[] {new Double(1234.67), new String("####.##")}, "1234.67");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatFloat() {
+	@Test public void testInvokeFormatFloat() {
 		helpInvokeMethod("formatFloat", new Object[] {new Float(1234.67), new String("###.###")}, "1234.67");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeFormatBigInteger() {
+	@Test public void testInvokeFormatBigInteger() {
 		helpInvokeMethod("formatBigInteger", new Object[] {new BigInteger("45"), new String("###.###")}, "45");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	}
 	
-	public void testInvokeFormatBigDecimal() {
+	@Test public void testInvokeFormatBigDecimal() {
 		helpInvokeMethod("formatBigDecimal", new Object[] {new BigDecimal("1234.56"), new String("###.###")}, "1234.56");	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	}	
 
-	public void testInvokeQuarter1() {
+	@Test public void testInvokeQuarter1() {
 		//		2003-5-15
 		helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 4, 15)}, new Integer(2));	 //$NON-NLS-1$
 	}
 	
-	public void testInvokeQuarter2() {
+	@Test public void testInvokeQuarter2() {
 		//		2003-5-1
 		helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 3, 31)}, new Integer(2));	 //$NON-NLS-1$
 	}
 	
-	public void testInvokeQuarter3() {
+	@Test public void testInvokeQuarter3() {
 		//		2003-1-31
 		helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 0, 31)}, new Integer(1));	 //$NON-NLS-1$
 	}
 	
-	public void testInvokeQuarter4() {
+	@Test public void testInvokeQuarter4() {
 	//		2003-9-30
 		helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 8, 30)}, new Integer(3));	 //$NON-NLS-1$
 	}
 	
-	public void testInvokeQuarter5() {
+	@Test public void testInvokeQuarter5() {
 	//		2003-12-31
 		helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 11, 31)}, new Integer(4));	 //$NON-NLS-1$
 	}		
 	
-	public void testInvokeQuarter6() {
+	@Test public void testInvokeQuarter6() {
 		//bad date such as 2003-13-45
 		helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 12, 45)}, new Integer(1));	 //$NON-NLS-1$
 	}
 	
-	public void testInvokeIfNull() {
+	@Test public void testInvokeIfNull() {
 		helpInvokeMethod("ifnull", new Object[] {new Integer(5), new Integer(10)}, new Integer(5));	 //$NON-NLS-1$
 	}
 
-	public void testInvokeLower() {
+	@Test public void testInvokeLower() {
 		helpInvokeMethod("lower", new Object[] {new String("LOWER")}, new String("lower"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 	
-	public void testInvokeUpper() {
+	@Test public void testInvokeUpper() {
 		helpInvokeMethod("upper", new Object[] {new String("upper")}, new String("UPPER"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
-	public void testInvokeRepeat() {
+	@Test public void testInvokeRepeat() {
 		helpInvokeMethod("repeat", new Object[] {new String("cat"), new Integer(3)}, new String("catcatcat"));	 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
-	public void testInvokeChar() {
+	@Test public void testInvokeChar() {
 		helpInvokeMethod("char", new Object[] {new Integer(32) }, new Character(' ')); //$NON-NLS-1$
 	}
 
 	/** normal input */
-	public void testInvokeInsert1() {
+	@Test public void testInvokeInsert1() {
 		helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(4),  //$NON-NLS-1$ //$NON-NLS-2$
 			new Integer(2), new String("cat")}, new String("Dowcatown"));	 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/** empty string2 */	
-	public void testInvokeInsert2() {
+	@Test public void testInvokeInsert2() {
 		helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(4),  //$NON-NLS-1$ //$NON-NLS-2$
 			new Integer(2), new String("")}, new String("Dowown"));	 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/** empty string1 with start = 1 and length = 0, so result is just string2 */	
-	public void testInvokeInsert3() {
+	@Test public void testInvokeInsert3() {
 		helpInvokeMethod("insert", new Object[] {new String(""), new Integer(1),  //$NON-NLS-1$ //$NON-NLS-2$
 			new Integer(0), new String("cat")}, new String("cat"));	 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/** should fail, with start > string1.length() */
-	public void testInvokeInsert4() {
+	@Test public void testInvokeInsert4() {
 		helpInvokeMethodFail("insert", new Object[] {new String(""), new Integer(2),  //$NON-NLS-1$ //$NON-NLS-2$
 			new Integer(0), new String("cat")}, new FunctionExecutionException("")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/** should fail, with length > 0 and input string1.length() = 0 */
-	public void testInvokeInsert5() {
+	@Test public void testInvokeInsert5() {
 		helpInvokeMethodFail("insert", new Object[] {new String(""), new Integer(1),  //$NON-NLS-1$ //$NON-NLS-2$
 			new Integer(1), new String("cat")}, new FunctionExecutionException(""));	 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/**  (length + start) > string1.length(), then just append str2 starting at start position */
-	public void testInvokeInsert6() {
+	@Test public void testInvokeInsert6() {
 		helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(7),  //$NON-NLS-1$ //$NON-NLS-2$
 			new Integer(5), new String("cat")}, new String("Downtocat"));	 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	/** date + day --> count=28, inteval=day, result should be 2003-6-12 */
-	public void testInvokeTimestampAddDate1() {
+	@Test public void testInvokeTimestampAddDate1() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_DAY,  //$NON-NLS-1$
 			new Integer(28), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(103, 5, 12));	
 	}	
 
-    public void testInvokeTimestampAddDate_ignore_case() {
+    @Test public void testInvokeTimestampAddDate_ignore_case() {
         helpInvokeMethod("timestampAdd", new Object[] {"sql_TSI_day",  //$NON-NLS-1$ //$NON-NLS-2$
             new Integer(28), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(103, 5, 12));    
     }   
     
 	/** date + day --> count=-28, inteval=day, result should be 2003-4-17 */
-	public void testInvokeTimestampAddDate1a() {
+	@Test public void testInvokeTimestampAddDate1a() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_DAY,  //$NON-NLS-1$
 			new Integer(-28), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(103, 3, 17));	
 	}	
 	
 	/** date + month --> count=18, inteval=month, result should be 2004-11-15 */
-	public void testInvokeTimestampAddDate2() {
+	@Test public void testInvokeTimestampAddDate2() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MONTH,  //$NON-NLS-1$
 			new Integer(18), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(104, 10, 15));	
 	}
 
 	/** date + month --> count=-18, inteval=month, result should be 2001-11-15 */
-	public void testInvokeTimestampAddDate2a() {
+	@Test public void testInvokeTimestampAddDate2a() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MONTH,  //$NON-NLS-1$
 			new Integer(-18), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(101, 10, 15));	
 	}
 	
 	/** date + week --> count=6, inteval=week, result should be 2003-04-03 */
-	public void testInvokeTimestampAddDate3() {
+	@Test public void testInvokeTimestampAddDate3() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_WEEK,  //$NON-NLS-1$
 			new Integer(-6), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(103, 3, 3));	
 	}
 
 	/** date + quarter --> count=3, inteval=quarter, result should be 2004-2-15 */
-	public void testInvokeTimestampAddDate4() {
+	@Test public void testInvokeTimestampAddDate4() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_QUARTER,  //$NON-NLS-1$
 			new Integer(3), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(104, 1, 15));	
 	}
 
 	/** date + year --> count=-1, inteval=year, result should be 2002-5-15 */
-	public void testInvokeTimestampAddDate5() {
+	@Test public void testInvokeTimestampAddDate5() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_YEAR,  //$NON-NLS-1$
 			new Integer(-1), TimestampUtil.createDate(103, 4, 15)}, TimestampUtil.createDate(102, 4, 15));	
 	}
 			
 	/** time + minute --> count=23, inteval=3, result should be 03:32:12 */
-	public void testInvokeTimestampAddTime1() {
+	@Test public void testInvokeTimestampAddTime1() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_MINUTE,  //$NON-NLS-1$
 			new Integer(23), TimestampUtil.createTime(3, 9, 12)}, TimestampUtil.createTime(3, 32, 12));	
 	}
 
 	/** time + hour --> count=21, inteval=4, result should be 00:09:12 and overflow */
-	public void testInvokeTimestampAddTime2() {
+	@Test public void testInvokeTimestampAddTime2() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
 			new Integer(21), TimestampUtil.createTime(3, 9, 12)}, TimestampUtil.createTime(0, 9, 12));	
 	}
 
 	/** time + hour --> count=2, inteval=4, result should be 01:12:12*/
-	public void testInvokeTimestampAddTime3() {
+	@Test public void testInvokeTimestampAddTime3() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
 			new Integer(2), TimestampUtil.createTime(23, 12, 12)}, TimestampUtil.createTime(1, 12, 12));	
 	}
 	
 	/** time + second --> count=23, inteval=2, result should be 03:10:01 */
-	public void testInvokeTimestampAddTime4() {
+	@Test public void testInvokeTimestampAddTime4() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_SECOND,  //$NON-NLS-1$
 			new Integer(49), TimestampUtil.createTime(3, 9, 12)}, TimestampUtil.createTime(3, 10, 1));	
 	}
 
 	/** timestamp + second --> count=23, inteval=2, result should be 2003-05-15 03:09:35.100  */
-	public void testInvokeTimestampAddTimestamp1() {
+	@Test public void testInvokeTimestampAddTimestamp1() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_SECOND,  //$NON-NLS-1$
 			new Integer(23), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)}, 
 			TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 35, 100));	
 	}
 
 	/** timestamp + nanos --> count=1, inteval=1, result should be 2003-05-15 03:09:12.000000101  */
-	public void testInvokeTimestampAddTimestamp2() {
+	@Test public void testInvokeTimestampAddTimestamp2() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
 			new Integer(1), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)}, 
 			TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 101));	
@@ -1140,20 +1138,20 @@
 	/** timestamp + nanos --> count=2100000000, inteval=1, result should be 2003-05-15 03:10:01.100000003
 	 *  with increase in second and minutes, because second already at 59 sec originally
 	 */
-	public void testInvokeTimestampAddTimestamp3() {
+	@Test public void testInvokeTimestampAddTimestamp3() {
 		helpInvokeMethod("timestampAdd", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
 			new Integer(2100000000), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 59, 1)}, 
 			TimestampUtil.createTimestamp(103, 4, 15, 3, 10, 1, 100000003));	
 	}
 			
 	/** time --> interval=hour, time1 = 03:04:45, time2= 05:05:36 return = 2  */
-	public void testInvokeTimestampDiffTime1() {
+	@Test public void testInvokeTimestampDiffTime1() {
 		helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_HOUR,  //$NON-NLS-1$
 			TimestampUtil.createTime(3, 4, 45), TimestampUtil.createTime(5, 5, 36) }, 
 			new Long(2));	
 	}
 	
-    public void testInvokeTimestampDiffTime1_ignorecase() {
+    @Test public void testInvokeTimestampDiffTime1_ignorecase() {
         helpInvokeMethod("timestampDiff", new Object[] {"SQL_tsi_HOUR",  //$NON-NLS-1$ //$NON-NLS-2$
             TimestampUtil.createTime(3, 4, 45), TimestampUtil.createTime(5, 5, 36) }, 
             new Long(2));   
@@ -1163,7 +1161,7 @@
 	 * timestamp --> interval=week, time1 = 2002-06-21 03:09:35.100,
 	 * time2= 2003-05-02 05:19:35.500 return = 45
 	 */
-	public void testInvokeTimestampDiffTimestamp1() {
+	@Test public void testInvokeTimestampDiffTimestamp1() {
 		helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_WEEK,  //$NON-NLS-1$
 			TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100), TimestampUtil.createTimestamp(103, 4, 2, 5, 19, 35, 500) }, 
 			new Long(45));	
@@ -1173,7 +1171,7 @@
      * timestamp --> interval=frac_second, time1 = 2002-06-21 03:09:35.000000001,
      * time2= 2002-06-21 03:09:35.100000000 return = 999999999
      */
-    public void testInvokeTimestampDiffTimestamp2() {
+    @Test public void testInvokeTimestampDiffTimestamp2() {
         helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
             TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 1), TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100000000) }, 
             new Long(99999999));  
@@ -1183,53 +1181,53 @@
      * timestamp --> interval=frac_second, time1 = 2002-06-21 03:09:35.000000002,
      * time2= 2002-06-22 03:09:35.000000001 return = 
      */
-    public void testInvokeTimestampDiffTimestamp3() {
+    @Test public void testInvokeTimestampDiffTimestamp3() {
         helpInvokeMethod("timestampDiff", new Object[] {ReservedWords.SQL_TSI_FRAC_SECOND,  //$NON-NLS-1$
             TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 2), TimestampUtil.createTimestamp(102, 5, 22, 3, 9, 35, 1) }, 
             new Long(86399999999999L));  
     }
 
-    public void testInvokeTimestampCreate1() {
+    @Test public void testInvokeTimestampCreate1() {
         helpInvokeMethod("timestampCreate", new Object[] {TimestampUtil.createDate(103, 4, 15), //$NON-NLS-1$
                                                           TimestampUtil.createTime(23, 59, 59)},
                                                           TimestampUtil.createTimestamp(103, 4, 15, 23, 59, 59, 0));    
     }   
     
-    public void testInvokeBitand() {
+    @Test public void testInvokeBitand() {
         helpInvokeMethod("bitand", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0x0F0)); //$NON-NLS-1$
     }
-    public void testInvokeBitor() {
+    @Test public void testInvokeBitor() {
         helpInvokeMethod("bitor", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0xFFF)); //$NON-NLS-1$
     }
-    public void testInvokeBitxor() {
+    @Test public void testInvokeBitxor() {
         helpInvokeMethod("bitxor", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0xF0F)); //$NON-NLS-1$
     }
-    public void testInvokeBitnot() {
+    @Test public void testInvokeBitnot() {
         helpInvokeMethod("bitnot", new Object[] {new Integer(0xF0F)}, new Integer(0xFFFFF0F0)); //$NON-NLS-1$
     }
     
-    public void testInvokeRound1() {
+    @Test public void testInvokeRound1() {
         helpInvokeMethod("round", new Object[] {new Integer(123), new Integer(-1)}, new Integer(120)); //$NON-NLS-1$
     }
 
-    public void testInvokeRound2() {
+    @Test public void testInvokeRound2() {
         helpInvokeMethod("round", new Object[] {new Float(123.456), new Integer(2)}, new Float(123.46)); //$NON-NLS-1$
     }
 
-    public void testInvokeRound3() {
+    @Test public void testInvokeRound3() {
         helpInvokeMethod("round", new Object[] {new Double(123.456), new Integer(2)}, new Double(123.46)); //$NON-NLS-1$
     }
 
-    public void testInvokeRound4() {
+    @Test public void testInvokeRound4() {
         helpInvokeMethod("round", new Object[] {new BigDecimal("123.456"), new Integer(2)}, new BigDecimal("123.460")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
     /** defect 10941 */
-    public void testInvokeConvertTime() {
+    @Test public void testInvokeConvertTime() {
         helpInvokeMethod("convert", new Object[] {"05:00:00", "time"}, TimestampUtil.createTime(5, 0, 0)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$                    
     }
 
-    public void testInvokeXpath1() {
+    @Test public void testInvokeXpath1() {
         helpInvokeMethod("xpathValue",  //$NON-NLS-1$
                          new Object[] {
                                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>test</c></b></a>", //$NON-NLS-1$
@@ -1237,7 +1235,7 @@
                          "test"); //$NON-NLS-1$ 
     }
     
-    public void testInvokeXpathWithNill() {
+    @Test public void testInvokeXpathWithNill() {
         helpInvokeMethod("xpathValue",  //$NON-NLS-1$
                          new Object[] {
                                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><b xsi:nil=\"true\"/></a>", //$NON-NLS-1$
@@ -1245,7 +1243,7 @@
                          null);
     }
     
-    public void testInvokeXpathWithNill1() {
+    @Test public void testInvokeXpathWithNill1() {
         helpInvokeMethod("xpathValue",  //$NON-NLS-1$
                          new Object[] {
                                        "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b>value</b></a>", //$NON-NLS-1$
@@ -1253,7 +1251,7 @@
                          "value"); //$NON-NLS-1$
     }
     
-    public void testInvokeModifyTimeZone() {
+    @Test public void testInvokeModifyTimeZone() {
         Timestamp ts = Timestamp.valueOf("2004-10-03 23:59:59.123"); //$NON-NLS-1$
         Timestamp out = Timestamp.valueOf("2004-10-03 22:59:59.123"); //$NON-NLS-1$
         helpInvokeMethod("modifyTimeZone", new Object[] {ts, "America/Chicago", "America/New_York" }, out); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -1266,20 +1264,20 @@
         helpInvokeMethod("modifyTimeZone", new Object[] {ts, "America/New_York" }, out); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testInvokeRand() {
+    @Test public void testInvokeRand() {
         helpInvokeMethod("rand", new Object[] {new Integer(100)}, new Double(0.7220096548596434)); //$NON-NLS-1$ 
         helpInvokeMethodFail("rand", new Class[] {Integer.class}, new Object[] {new Double(100)}, new FunctionExecutionException("")); //$NON-NLS-1$ //$NON-NLS-2$
         // this does not actually fail but returns a result
         helpInvokeMethodFail("rand", new Class[] {Integer.class}, new Object[] {null}, new FunctionExecutionException("")); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInvokeUser() throws Exception {
+    @Test public void testInvokeUser() throws Exception {
         CommandContext c = new CommandContext();
         c.setUserName("foodude"); //$NON-NLS-1$
         helpInvokeMethod("user", new Class[] {}, new Object[] {}, c, "foodude"); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testInvokeEnv() throws Exception {
+    @Test public void testInvokeEnv() throws Exception {
         CommandContext c = new CommandContext();
         Properties props = new Properties();
         props.setProperty("env_test", "env_value"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1288,7 +1286,7 @@
         helpInvokeMethod("env", new Class[] {String.class}, new Object[] {null}, c, null); //$NON-NLS-1$ 
     }
     
-    public void testInvokeCommandPayload() throws Exception {
+    @Test public void testInvokeCommandPayload() throws Exception {
         CommandContext c = new CommandContext();        
         c.setCommandPayload("payload_too heavy"); //$NON-NLS-1$
         helpInvokeMethod("commandpayload", new Class[] {}, new Object[] {}, c, "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$ 
@@ -1299,7 +1297,7 @@
         helpInvokeMethod("commandpayload", new Class[] {String.class}, new Object[] {"payload"}, c, "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }    
     
-    public void testNullDependent() {
+    @Test public void testNullDependent() {
         FunctionDescriptor actual = library.findFunction("concat2", new Class[] {String.class, String.class}); //$NON-NLS-1$
         assertTrue(actual.isNullDependent());
         
@@ -1307,95 +1305,102 @@
         assertFalse(actual.isNullDependent());
     }
     
-    public void testInvokeCeiling() {
+    @Test public void testInvokeCeiling() {
         helpInvokeMethod("ceiling", new Object[] { new Double("3.14") }, new Double("4")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testInvokeFloor() {
+    @Test public void testInvokeFloor() {
         helpInvokeMethod("floor", new Object[] { new Double("3.14") }, new Double("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testInvokeExp() {
+    @Test public void testInvokeExp() {
         helpInvokeMethod("exp", new Object[] { new Double("0") }, new Double("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testInvokeLog() {
+    @Test public void testInvokeLog() {
         helpInvokeMethod("log", new Object[] { new Double("1") }, new Double("0")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testInvokeLog10() {
+    @Test public void testInvokeLog10() {
         helpInvokeMethod("log10", new Object[] { new Double("10") }, new Double("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testInvokePower() {
+    @Test public void testInvokePower() {
         helpInvokeMethod("power", new Object[] { new Double("10"), new Double("2") }, new Double("100")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
     
-    public void testInvokeSqrt() {
+    @Test public void testInvokeSqrt() {
         helpInvokeMethod("sqrt", new Object[] { new Double("4")}, new Double("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testInvokeDayName() {
-        TimestampUtil util = new TimestampUtil();
+    @Test public void testInvokeDayName() {
         for (int i = 0; i < FunctionMethods.dayNames.length; i++) {
-            Date time = util.createDate(100, 0, i + 2);
+            Date time = TimestampUtil.createDate(100, 0, i + 2);
             helpInvokeMethod("dayName", new Object[] { time }, FunctionMethods.dayNames[i]); //$NON-NLS-1$ 
         }
     }
     
-    public void testInvokeDayOfMonth() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeDayOfMonth() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("dayOfMonth", new Object[] { time }, new Integer(1)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeDayOfWeek() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeDayOfWeek() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("dayOfWeek", new Object[] { time }, new Integer(7)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeDayOfYear() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 2, 1, 2, 3, 4);
+    @Test public void testInvokeDayOfYear() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 2, 1, 2, 3, 4);
         helpInvokeMethod("dayOfYear", new Object[] { time }, new Integer(2)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeMonth() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeMonth() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("month", new Object[] { time }, new Integer(1)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeMonthName() {
-        TimestampUtil util = new TimestampUtil();
+    @Test public void testInvokeMonthName() {
         for (int i = 0; i < FunctionMethods.monthNames.length; i++) {
-            Date time = util.createDate(100, i, 1);
+            Date time = TimestampUtil.createDate(100, i, 1);
             helpInvokeMethod("monthName", new Object[] { time }, FunctionMethods.monthNames[i]); //$NON-NLS-1$ 
         }
     }
     
-    public void testInvokeMinute() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeMinute() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("minute", new Object[] { time }, new Integer(2)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeSecond() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeSecond() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("second", new Object[] { time }, new Integer(3)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeWeek() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeWeek() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("week", new Object[] { time }, new Integer(1)); //$NON-NLS-1$ 
     }
     
-    public void testInvokeYear() {
-        TimestampUtil util = new TimestampUtil();
-        Timestamp time = util.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+    @Test public void testInvokeYear() {
+        Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
         helpInvokeMethod("year", new Object[] { time }, new Integer(2000)); //$NON-NLS-1$ 
     }
+    
+    @Test public void testInvokeCoalesce() {
+    	helpInvokeMethod(FunctionLibrary.COALESCE, new Object[] { Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(2) }, Integer.valueOf(0));
+    }
+    
+    @Test public void testInvokeCoalesce1() {
+    	helpInvokeMethod(FunctionLibrary.COALESCE, new Object[] { null, null}, null);
+    }
+    
+    @Test public void testInvokeNull() throws Exception {
+        helpInvokeMethod(SourceSystemFunctions.LTRIM, new Class[] {DataTypeManager.DefaultDataClasses.STRING}, new Object[] { null }, null, null);  
+    }
+    
+    @Test public void testInvokeNull1() throws Exception {
+        helpInvokeMethod(SourceSystemFunctions.CONCAT, new Class[] {DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING}, new Object[] { null, String.valueOf(1) }, null, null);  
+    }    
+    
 }

Added: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java	                        (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -0,0 +1,128 @@
+/*
+ * 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.metamatrix.query.resolver;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.Function;
+import com.metamatrix.query.sql.symbol.Reference;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestFunctionResolving {
+
+    @Test public void testResolveBadConvert() throws Exception {
+        Function function = new Function("convert", new Expression[] {new Constant(new Character('a')), new Constant(DataTypeManager.DefaultDataTypes.DATE)}); //$NON-NLS-1$
+        
+        try {
+            ResolverVisitorUtil.resolveFunction(function, FakeMetadataFactory.example1Cached());
+            fail("excpetion expected"); //$NON-NLS-1$
+        } catch (QueryResolverException err) {
+            assertEquals("The conversion from char to date is not allowed.", err.getMessage()); //$NON-NLS-1$
+        } 
+    }
+    
+    @Test public void testResolvesClosestType() throws Exception {
+        ElementSymbol e1 = new ElementSymbol("pm1.g1.e1"); //$NON-NLS-1$
+        e1.setType(DataTypeManager.DefaultDataClasses.BYTE);
+        Function function = new Function("abs", new Expression[] {e1}); //$NON-NLS-1$
+        
+        ResolverVisitorUtil.resolveFunction(function, FakeMetadataFactory.example1Cached());
+        
+        assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, function.getType());
+    }
+    
+    @Test public void testResolveConvertReference() throws Exception {
+        Function function = new Function("convert", new Expression[] {new Reference(0), new Constant(DataTypeManager.DefaultDataTypes.BOOLEAN)}); //$NON-NLS-1$
+        
+        ResolverVisitorUtil.resolveFunction(function, FakeMetadataFactory.example1Cached());
+        
+        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getType());
+        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getArgs()[0].getType());
+    }
+    
+    @Test public void testResolveAmbiguousFunction() throws Exception {
+        Function function = new Function("LCASE", new Expression[] {new Reference(0)}); //$NON-NLS-1$
+        
+        try {
+            ResolverVisitorUtil.resolveFunction(function, FakeMetadataFactory.example1Cached());
+            fail("excpetion expected"); //$NON-NLS-1$
+        } catch (QueryResolverException err) {
+            assertEquals("The function 'LCASE(?)' has more than one possible signature.", err.getMessage()); //$NON-NLS-1$
+        } 
+    }
+    
+    @Test public void testResolveCoalesce() throws Exception {
+    	String sql = "coalesce('', '')"; //$NON-NLS-1$
+    	helpResolveFunction(sql);
+    }
+    
+    @Test public void testResolveCoalesce1() throws Exception {
+    	String sql = "coalesce('', '', '')"; //$NON-NLS-1$
+    	helpResolveFunction(sql);
+    }
+    
+    /**
+     * Should resolve using varags logic
+     */
+    @Test public void testResolveCoalesce1a() throws Exception {
+    	String sql = "coalesce('', '', '', '')"; //$NON-NLS-1$
+    	helpResolveFunction(sql);
+    }
+    
+    /**
+     * Should resolve as 1 is implicitly convertable to string
+     */
+    @Test public void testResolveCoalesce2() throws Exception {
+    	String sql = "coalesce('', 1, '', '')"; //$NON-NLS-1$
+    	helpResolveFunction(sql);
+    }
+    
+    @Test public void testResolveCoalesce3() throws Exception {
+    	String sql = "coalesce('', 1, null, '')"; //$NON-NLS-1$
+    	helpResolveFunction(sql);
+    }
+    
+    @Test public void testResolveCoalesce4() throws Exception {
+    	String sql = "coalesce({d'2009-03-11'}, 1)"; //$NON-NLS-1$
+    	helpResolveFunction(sql);
+    }
+
+	private Function helpResolveFunction(String sql) throws QueryParserException,
+			QueryResolverException, MetaMatrixComponentException {
+		Function func = (Function)QueryParser.getQueryParser().parseExpression(sql);
+    	ResolverVisitorUtil.resolveFunction(func, FakeMetadataFactory.example1Cached());
+    	assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getType());
+    	return func;
+	}
+	
+}


Property changes on: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2009-03-11 23:11:24 UTC (rev 549)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java	2009-03-12 16:07:02 UTC (rev 550)
@@ -4257,48 +4257,7 @@
         
         helpResolveException(sql);
     }
-    
-    public void testResolvesClosestType() throws Exception {
-        ElementSymbol e1 = new ElementSymbol("pm1.g1.e1"); //$NON-NLS-1$
-        e1.setType(DataTypeManager.DefaultDataClasses.BYTE);
-        Function function = new Function("abs", new Expression[] {e1}); //$NON-NLS-1$
-        
-        ResolverVisitorUtil.resolveFunction(function, metadata);
-        
-        assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, function.getType());
-    }
-    
-    public void testResolveConvertReference() throws Exception {
-        Function function = new Function("convert", new Expression[] {new Reference(0), new Constant(DataTypeManager.DefaultDataTypes.BOOLEAN)}); //$NON-NLS-1$
-        
-        ResolverVisitorUtil.resolveFunction(function, metadata);
-        
-        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getType());
-        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getArgs()[0].getType());
-    }
-    
-    public void testResolveAmbiguousFunction() throws Exception {
-        Function function = new Function("LCASE", new Expression[] {new Reference(0)}); //$NON-NLS-1$
-        
-        try {
-            ResolverVisitorUtil.resolveFunction(function, metadata);
-            fail("excpetion expected"); //$NON-NLS-1$
-        } catch (QueryResolverException err) {
-            assertEquals("The function 'LCASE(?)' has more than one possible signature.", err.getMessage()); //$NON-NLS-1$
-        } 
-    }
-    
-    public void testResolvBadConvert() throws Exception {
-        Function function = new Function("convert", new Expression[] {new Constant(new Character('a')), new Constant(DataTypeManager.DefaultDataTypes.DATE)}); //$NON-NLS-1$
-        
-        try {
-            ResolverVisitorUtil.resolveFunction(function, metadata);
-            fail("excpetion expected"); //$NON-NLS-1$
-        } catch (QueryResolverException err) {
-            assertEquals("The conversion from char to date is not allowed.", err.getMessage()); //$NON-NLS-1$
-        } 
-    }
-    
+            
     public void testCreateAfterImplicitTempTable() {
         StringBuffer proc = new StringBuffer("CREATE PROCEDURE") //$NON-NLS-1$
         .append("\nBEGIN") //$NON-NLS-1$




More information about the teiid-commits mailing list