[teiid-commits] teiid SVN: r1218 - in trunk/connectors/connector-jdbc/src: test/java/org/teiid/connector/jdbc/postgresql and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Aug 6 16:11:11 EDT 2009


Author: shawkins
Date: 2009-08-06 16:11:11 -0400 (Thu, 06 Aug 2009)
New Revision: 1218

Added:
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
Modified:
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
   trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
Log:
TEIID-758 adding support for locate to postgresql.

Added: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java	                        (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java	2009-08-06 20:11:11 UTC (rev 1218)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.jdbc.postgresql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.jdbc.translator.BasicFunctionModifier;
+import org.teiid.connector.language.IExpression;
+import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageFactory;
+
+public class LocateFunctionModifier extends BasicFunctionModifier {
+	
+	private ILanguageFactory factory; 
+	
+	public LocateFunctionModifier(ILanguageFactory factory) {
+		this.factory = factory;
+	}
+
+	@Override
+	public List<?> translate(IFunction function) {
+		List<Object> parts = new ArrayList<Object>();
+		List<IExpression> params = function.getParameters();
+		parts.add("position("); //$NON-NLS-1$
+		parts.add(params.get(0));		
+		parts.add(" in "); //$NON-NLS-1$
+		if (params.size() == 3) {
+			parts.add(factory.createFunction("substr", params.subList(1, 3), TypeFacility.RUNTIME_TYPES.STRING)); //$NON-NLS-1$
+		} else {
+			parts.add(params.get(1));
+		}
+		parts.add(")"); //$NON-NLS-1$
+		return parts;
+	}
+	
+}


Property changes on: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/LocateFunctionModifier.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java	2009-08-06 16:47:07 UTC (rev 1217)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLCapabilities.java	2009-08-06 20:11:11 UTC (rev 1218)
@@ -89,8 +89,7 @@
         supportedFunctions.add("LCASE"); //$NON-NLS-1$
         supportedFunctions.add("LEFT"); //$NON-NLS-1$
         supportedFunctions.add("LENGTH"); //$NON-NLS-1$
-        // Doesn't support both forms exposed by MM
-//        supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+        supportedFunctions.add("LOCATE"); //$NON-NLS-1$
         supportedFunctions.add("LOWER"); //$NON-NLS-1$
         supportedFunctions.add("LPAD"); //$NON-NLS-1$
         supportedFunctions.add("LTRIM"); //$NON-NLS-1$

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java	2009-08-06 16:47:07 UTC (rev 1217)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java	2009-08-06 20:11:11 UTC (rev 1218)
@@ -93,7 +93,9 @@
         registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
         
         registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$ 
-        registerFunctionModifier(SourceSystemFunctions.CONVERT, new PostgreSQLConvertModifier(getLanguageFactory()));        
+        registerFunctionModifier(SourceSystemFunctions.CONVERT, new PostgreSQLConvertModifier(getLanguageFactory())); 
+        
+        registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
     }    
     
     @Override

Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java	2009-08-06 16:47:07 UTC (rev 1217)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java	2009-08-06 20:11:11 UTC (rev 1218)
@@ -22,40 +22,24 @@
 
 package org.teiid.connector.jdbc.postgresql;
 
-import java.util.Map;
 import java.util.Properties;
 
+import org.junit.BeforeClass;
+import org.junit.Test;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.jdbc.MetadataFactory;
-import org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator;
-import org.teiid.connector.jdbc.translator.TranslatedCommand;
-import org.teiid.connector.language.ICommand;
 
-import junit.framework.TestCase;
-
 import com.metamatrix.cdk.api.EnvironmentUtility;
 
-/**
- */
-public class TestPostgreSQLTranslator extends TestCase {
+public class TestPostgreSQLTranslator {
 
-    private static Map MODIFIERS;
     private static PostgreSQLTranslator TRANSLATOR; 
-
-    static {
-        try {
-            TRANSLATOR = new PostgreSQLTranslator();        
-            TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
-            MODIFIERS = TRANSLATOR.getFunctionModifiers();
-        } catch(ConnectorException e) {
-            e.printStackTrace();    
-        }
-    }
-
-    public TestPostgreSQLTranslator(String name) {
-        super(name);
-    }
-
+
+    @BeforeClass public static void setupOnce() throws Exception {
+        TRANSLATOR = new PostgreSQLTranslator();        
+        TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
+    }
+    
     public String getTestVDB() {
         return MetadataFactory.PARTS_VDB;
     }
@@ -64,401 +48,359 @@
         return MetadataFactory.BQT_VDB;
     }
         
-    public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput) throws ConnectorException {
-        // Convert from sql to objects
-        ICommand obj = MetadataFactory.helpTranslate(vdb, input);
-        
-        TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), TRANSLATOR);
-        tc.translateCommand(obj);
-        
-        
-        // Check stuff
-        assertEquals("Did not get correct sql", expectedOutput, tc.getSql());             //$NON-NLS-1$
+    public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
+        MetadataFactory.helpTestVisitor(vdb, input, expectedOutput, TRANSLATOR);
     }
 
-    public void testRewriteConversion1() throws Exception {
+    @Test public void testRewriteConversion1() throws Exception {
         String input = "SELECT char(convert(PART_WEIGHT, integer) + 100) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT chr((cast(PARTS.PART_WEIGHT AS integer) + 100)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
           
-    public void testRewriteConversion2() throws Exception {
+    @Test public void testRewriteConversion2() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, long) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS bigint) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
           
-    public void testRewriteConversion3() throws Exception {
+    @Test public void testRewriteConversion3() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, short) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS smallint) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
           
-    public void testRewriteConversion4() throws Exception {
+    @Test public void testRewriteConversion4() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, float) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS real) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion5() throws Exception {
+    @Test public void testRewriteConversion5() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, double) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS float8) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion6() throws Exception {
+    @Test public void testRewriteConversion6() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, biginteger) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS numeric) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion7() throws Exception {
+    @Test public void testRewriteConversion7() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, bigdecimal) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS decimal) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion8() throws Exception {
+    @Test public void testRewriteConversion8() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, boolean) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(PARTS.PART_WEIGHT AS boolean) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion9() throws Exception {
+    @Test public void testRewriteConversion9() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, date) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion10() throws Exception {
+    @Test public void testRewriteConversion10() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, time) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion11() throws Exception {
+    @Test public void testRewriteConversion11() throws Exception {
         String input = "SELECT convert(PART_WEIGHT, timestamp) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion12() throws Exception {
+    @Test public void testRewriteConversion12() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, time), string) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_char(to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion13() throws Exception {
+    @Test public void testRewriteConversion13() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_char(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'YYYY-MM-DD HH24:MI:SS.US') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion14() throws Exception {
+    @Test public void testRewriteConversion14() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, date), string) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_char(to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD'), 'YYYY-MM-DD') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion15() throws Exception {
+    @Test public void testRewriteConversion15() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, timestamp), date) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') AS date) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion16() throws Exception {
+    @Test public void testRewriteConversion16() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, timestamp), time) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT cast(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF') AS time) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion17() throws Exception {
+    @Test public void testRewriteConversion17() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, time), timestamp) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_timestamp(to_char(to_timestamp(('1970-01-01 ' || PARTS.PART_WEIGHT), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion18() throws Exception {
+    @Test public void testRewriteConversion18() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, date), timestamp) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT to_timestamp(to_char(to_date(PARTS.PART_WEIGHT, 'YYYY-MM-DD'), 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteConversion19() throws Exception {
+    @Test public void testRewriteConversion19() throws Exception {
         String input = "SELECT convert(convert(PART_WEIGHT, boolean), string) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT CASE WHEN cast(PARTS.PART_WEIGHT AS boolean) = TRUE THEN '1' ELSE '0' END FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
     
-    public void testRewriteLog() throws Exception {
+    @Test public void testRewriteLog() throws Exception {
         String input = "SELECT log(convert(PART_WEIGHT, double)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT ln(cast(PARTS.PART_WEIGHT AS float8)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
         input = "SELECT log10(convert(PART_WEIGHT, double)) FROM PARTS"; //$NON-NLS-1$
         output = "SELECT log(cast(PARTS.PART_WEIGHT AS float8)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
     
-    public void testRewriteLeft() throws Exception {
+    @Test public void testRewriteLeft() throws Exception {
         String input = "SELECT left(PART_WEIGHT, 2) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT SUBSTR(PARTS.PART_WEIGHT, 1, 2) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRewriteRight() throws Exception {
+    @Test public void testRewriteRight() throws Exception {
         String input = "SELECT right(PART_WEIGHT, 2) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT SUBSTR(PARTS.PART_WEIGHT, (-1 * 2)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
     
-    public void testDayOfWeek() throws Exception {
+    @Test public void testDayOfWeek() throws Exception {
         String input = "SELECT dayofweek(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT (EXTRACT(DOW FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) + 1) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testDayOfMonth() throws Exception {
+    @Test public void testDayOfMonth() throws Exception {
         String input = "SELECT dayofmonth(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(DAY FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testDayOfYear() throws Exception {
+    @Test public void testDayOfYear() throws Exception {
         String input = "SELECT dayofyear(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(DOY FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testHour() throws Exception {
+    @Test public void testHour() throws Exception {
         String input = "SELECT hour(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(HOUR FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testMinute() throws Exception {
+    @Test public void testMinute() throws Exception {
         String input = "SELECT minute(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(MINUTE FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testMonth() throws Exception {
+    @Test public void testMonth() throws Exception {
         String input = "SELECT month(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(MONTH FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testQuarter() throws Exception {
+    @Test public void testQuarter() throws Exception {
         String input = "SELECT quarter(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(QUARTER FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testSecond() throws Exception {
+    @Test public void testSecond() throws Exception {
         String input = "SELECT second(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(SECOND FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testWeek() throws Exception {
+    @Test public void testWeek() throws Exception {
         String input = "SELECT week(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(WEEK FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testYear() throws Exception {
+    @Test public void testYear() throws Exception {
         String input = "SELECT year(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT EXTRACT(YEAR FROM to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testDayName() throws Exception {
+    @Test public void testDayName() throws Exception {
         String input = "SELECT dayname(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT RTRIM(TO_CHAR(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'Day')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testMonthName() throws Exception {
+    @Test public void testMonthName() throws Exception {
         String input = "SELECT monthname(convert(PART_WEIGHT, timestamp)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT RTRIM(TO_CHAR(to_timestamp(PARTS.PART_WEIGHT, 'YYYY-MM-DD HH24:MI:SS.UF'), 'Month')) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testIfnull() throws Exception {
+    @Test public void testIfnull() throws Exception {
         String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT coalesce(PARTS.PART_WEIGHT, 'otherString') FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testSubstring1() throws Exception {
+    @Test public void testSubstring1() throws Exception {
         String input = "SELECT substring(PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT substr(PARTS.PART_WEIGHT, 1) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testSubstring2() throws Exception {
+    @Test public void testSubstring2() throws Exception {
         String input = "SELECT substring(PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT substr(PARTS.PART_WEIGHT, 1, 5) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testBooleanAggregate() throws Exception {
+    @Test public void testBooleanAggregate() throws Exception {
         String input = "SELECT MIN(convert(PART_WEIGHT, boolean)) FROM PARTS"; //$NON-NLS-1$
         String output = "SELECT bool_and(cast(PARTS.PART_WEIGHT AS boolean)) FROM PARTS";  //$NON-NLS-1$
 
         helpTestVisitor(getTestVDB(),
             input, 
-            MODIFIERS,
             output);
     }
-    public void testRowLimit2() throws Exception {
+    @Test public void testRowLimit2() throws Exception {
         String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
         String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100"; //$NON-NLS-1$
                
         helpTestVisitor(getTestBQTVDB(),
             input, 
-            MODIFIERS,
             output);        
     }
-    public void testRowLimit3() throws Exception {
+    @Test public void testRowLimit3() throws Exception {
         String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
         String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100 OFFSET 50"; //$NON-NLS-1$
                
         helpTestVisitor(getTestBQTVDB(),
             input, 
-            MODIFIERS,
             output);        
     }    
     
-    public void testBitFunctions() throws Exception {
+    @Test public void testBitFunctions() throws Exception {
         String input = "select bitand(intkey, intnum), bitnot(intkey), bitor(intnum, intkey), bitxor(intnum, intkey) from bqt1.smalla"; //$NON-NLS-1$
         String output = "SELECT (SmallA.IntKey & SmallA.IntNum), ~(SmallA.IntKey), (SmallA.IntNum | SmallA.IntKey), (SmallA.IntNum # SmallA.IntKey) FROM SmallA"; //$NON-NLS-1$
                
         helpTestVisitor(getTestBQTVDB(),
             input, 
-            MODIFIERS,
             output);        
     }
+    
+    @Test public void testLocate() throws Exception {
+    	String input = "select locate('a', stringkey), locate('b', stringkey, 2) from bqt1.smalla"; //$NON-NLS-1$
+        String output = "SELECT position('a' in SmallA.StringKey), position('b' in substr(SmallA.StringKey, 2)) FROM SmallA"; //$NON-NLS-1$
+               
+        helpTestVisitor(getTestBQTVDB(),
+            input, 
+            output);
+    }
     
-    
 }



More information about the teiid-commits mailing list