Author: shawkins
Date: 2011-05-25 15:53:24 -0400 (Wed, 25 May 2011)
New Revision: 3196
Removed:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
Modified:
branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
Log:
TEIID-1605 further refinements to the pushdown function concept to allow for multi-part
function names
Modified: branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++ branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -23,8 +23,8 @@
package org.teiid.translator;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import javax.resource.ResourceException;
@@ -43,6 +43,7 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
@@ -108,6 +109,8 @@
private int maxInSize = DEFAULT_MAX_IN_CRITERIA_SIZE;
private int maxDependentInPredicates = DEFAULT_MAX_IN_CRITERIA_SIZE;
+ private LinkedList<FunctionMethod> pushdownFunctionMethods = new
LinkedList<FunctionMethod>();
+
/**
* Initialize the connector with supplied configuration
*/
@@ -651,10 +654,28 @@
return null;
}
+ /**
+ * Get a list of {@link FunctionMethod}s that will be contributed to the SYS schema.
+ * To avoid conflicts with system functions, the function name should contain a
+ * qualifier - typically <translator name>.<function
name>
+ * @see ExecutionFactory#addPushDownFunction(String, String, FunctionParameter,
FunctionParameter...)
+ * @return
+ */
public List<FunctionMethod> getPushDownFunctions(){
- return Collections.emptyList();
+ return pushdownFunctionMethods;
}
+ protected FunctionMethod addPushDownFunction(String qualifier, String name, String
returnType, String...paramTypes) {
+ FunctionParameter[] params = new FunctionParameter[paramTypes.length];
+ for (int i = 0; i < paramTypes.length; i++) {
+ params[i] = new FunctionParameter("param" + (i+1), paramTypes[i]);
//$NON-NLS-1$
+ }
+ FunctionMethod method = new FunctionMethod(qualifier + '.' + name, name,
qualifier, params, new FunctionParameter("result", returnType)); //$NON-NLS-1$
+ method.setNameInSource(name);
+ pushdownFunctionMethods.add(method);
+ return method;
+ }
+
/**
* Get the integer value representing the number of values allowed in an IN criteria
* in the WHERE clause of a query
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -41,6 +41,7 @@
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
+import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.sql.DataSource;
@@ -144,7 +145,7 @@
}
};
- private Map<String, FunctionModifier> functionModifiers = new
HashMap<String, FunctionModifier>();
+ private Map<String, FunctionModifier> functionModifiers = new
TreeMap<String, FunctionModifier>(String.CASE_INSENSITIVE_ORDER);
private boolean useBindVariables = true;
private String databaseTimeZone;
@@ -511,9 +512,18 @@
if (obj instanceof Function) {
Function function = (Function)obj;
if (functionModifiers != null) {
- FunctionModifier modifier =
functionModifiers.get(function.getName().toLowerCase());
- if (modifier != null) {
- parts = modifier.translate(function);
+ String name = function.getName();
+ while (true) {
+ FunctionModifier modifier = functionModifiers.get(name);
+ if (modifier != null) {
+ parts = modifier.translate(function);
+ break;
+ }
+ int index = name.indexOf('.');
+ if (index < 0 || index == name.length() - 1) {
+ break;
+ }
+ name = name.substring(index + 1);
}
}
} else if (obj instanceof Command) {
@@ -553,7 +563,7 @@
}
/**
- * Return a map of function name in lower case to FunctionModifier.
+ * Return a map of function name to FunctionModifier.
* @return Map of function name to FunctionModifier.
*/
public Map<String, FunctionModifier> getFunctionModifiers() {
@@ -566,7 +576,7 @@
* @param modifier
*/
public void registerFunctionModifier(String name, FunctionModifier modifier) {
- this.functionModifiers.put(name.toLowerCase(), modifier);
+ this.functionModifiers.put(name, modifier);
}
/**
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -21,6 +21,8 @@
*/
package org.teiid.translator.jdbc.ingres;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -28,10 +30,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Limit;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -40,7 +39,6 @@
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-
@Translator(name="ingres", description="A translator for Ingres
Databases")
public class IngresExecutionFactory extends JDBCExecutionFactory {
@@ -78,7 +76,45 @@
registerFunctionModifier(SourceSystemFunctions.RAND, new
AliasModifier("random")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UCASE, new
AliasModifier("uppercase")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new
AliasModifier("day")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new
LocateFunctionModifier(getLanguageFactory()));
+
+ addPushDownFunction(INGRES, "bit_add", INTEGER, INTEGER, INTEGER);
//$NON-NLS-1$
+ addPushDownFunction(INGRES, "bit_length", INTEGER, INTEGER);
//$NON-NLS-1$
+ addPushDownFunction(INGRES, "character_length", STRING, INTEGER);
//$NON-NLS-1$
+ addPushDownFunction(INGRES, "charextract", CHAR, STRING, INTEGER);
//$NON-NLS-1$
+
+ // uses ingres date??
+ //supportedFunctions.add("date_trunc");
+ //supportedFunctions.add("dow");
+ //supportedFunctions.add("extract");
+ addPushDownFunction(INGRES, "gmt_timestamp", STRING, INTEGER);
//$NON-NLS-1$
+ addPushDownFunction(INGRES, "hash", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "hex", STRING, STRING); //$NON-NLS-1$
+
+ // do not have byte[] type
+ //supportedFunctions.add("intextract");
+
+ addPushDownFunction(INGRES, "ln", DOUBLE, DOUBLE); //$NON-NLS-1$
+
+ // see lowercase
+ // supportedFunctions.add("lower");
+ // supportedFunctions.add("upper");
+
+ addPushDownFunction(INGRES, "octet_length", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INGRES, "randomf", FLOAT); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "session_user", STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "size", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "squeeze", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "soundex", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "unhex", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "usercode", STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "username", STRING); //$NON-NLS-1$
+ // ignore
+ // supportedFunctions.add("uuid_create");
+ // supportedFunctions.add("uuid_compare");
+ // supportedFunctions.add("uuid_from_char");
+ // supportedFunctions.add("uuid_to_char");
+
}
@Override
@@ -123,122 +159,6 @@
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- List<FunctionMethod> pushdownFunctions = new
ArrayList<FunctionMethod>();
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "bit_add",
"bit_add", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer2",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "bit_length",
"bit_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' +
"character_length", "character_length", INGRES, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' +
"charextract", "charextract", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.CHAR, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // uses ingres date??
- //supportedFunctions.add("date_trunc");
- //supportedFunctions.add("dow");
- //supportedFunctions.add("extract");
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' +
"gmt_timestamp", "gmt_timestamp", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "hash",
"hash", INGRES,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "hex",
"hex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // do not have byte[] type
- //supportedFunctions.add("intextract");
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "ln",
"ln", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float1",
DataTypeManager.DefaultDataTypes.DOUBLE, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.DOUBLE, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // see lowercase
- // supportedFunctions.add("lower");
- // supportedFunctions.add("upper");
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' +
"octet_length", "octet_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "pad",
"pad", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "pad",
"pad", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "randomf",
"randomf", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' +
"session_user", "session_user", INGRES, null,//$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "size",
"size", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "squeeze",
"squeeze", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "soundex",
"soundex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "unhex",
"unhex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "usercode",
"usercode", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "username",
"username", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ignore
- // supportedFunctions.add("uuid_create");
- // supportedFunctions.add("uuid_compare");
- // supportedFunctions.add("uuid_from_char");
- // supportedFunctions.add("uuid_to_char");
-
- return pushdownFunctions;
- }
-
- @Override
public boolean supportsRowLimit() {
return true;
}
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -21,6 +21,8 @@
*/
package org.teiid.translator.jdbc.intersyscache;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -28,10 +30,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Function;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
@@ -111,6 +110,18 @@
return null;
}
});
+
+ addPushDownFunction(INTER_CACHE, "CHARACTER_LENGTH", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "CHAR_LENGTH", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "CHARINDEX", INTEGER, STRING, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "CHARINDEX", INTEGER, STRING, STRING,
INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "INSTR", INTEGER, STRING, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "INSTR", INTEGER, STRING, STRING,
INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "IS_NUMERIC", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "REPLICATE", STRING, STRING, INTEGER);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "REVERSE", STRING, STRING);
//$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "STUFF", STRING, STRING, STRING,
INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "TRIM", STRING, STRING);
//$NON-NLS-1$
}
@Override
@@ -179,80 +190,6 @@
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
-
- List<FunctionMethod> pushdownFunctions = new
ArrayList<FunctionMethod>();
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"CHARACTER_LENGTH", "CHARACTER_LENGTH", INTER_CACHE, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"CHAR_LENGTH", "CHAR_LENGTH", INTER_CACHE, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"CHARINDEX", "CHARINDEX", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"CHARINDEX", "CHARINDEX", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "INSTR",
"INSTR", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "INSTR",
"INSTR", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"IS_NUMERIC", "IS_NUMERIC", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"REPLICATE", "REPLICATE", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' +
"REVERSE", "REVERSE", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "STUFF",
"STUFF", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer2",
DataTypeManager.DefaultDataTypes.INTEGER, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "TRIM",
"TRIM", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- return pushdownFunctions;
- }
-
-
- @Override
public String translateLiteralDate(Date dateValue) {
return "to_date('" + formatDateValue(dateValue) + "',
'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
}
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -22,6 +22,8 @@
package org.teiid.translator.jdbc.modeshape;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -29,7 +31,6 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Comparison;
import org.teiid.language.Function;
import org.teiid.language.LanguageObject;
@@ -38,8 +39,6 @@
import org.teiid.language.Comparison.Operator;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -47,7 +46,6 @@
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-
/**
* Translator class for accessing the ModeShape JCR repository.
*/
@@ -79,6 +77,12 @@
registerFunctionModifier(JCR_REFERENCE, new IdentifierFunctionModifier());
registerFunctionModifier(JCR_CONTAINS, new IdentifierFunctionModifier());
+ addPushDownFunction(JCR, JCR_ISCHILDNODE, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_ISDESCENDANTNODE, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_ISSAMENODE, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_CONTAINS, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_REFERENCE, BOOLEAN, STRING);
+
LogManager.logTrace(LogConstants.CTX_CONNECTOR, "ModeShape Translator
Started"); //$NON-NLS-1$
}
@@ -112,42 +116,7 @@
return supportedFunctions;
}
-
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- List<FunctionMethod> pushdownFunctions = new
ArrayList<FunctionMethod>();
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_ISCHILDNODE,
JCR_ISCHILDNODE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING,
""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("path2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_ISDESCENDANTNODE,
JCR_ISDESCENDANTNODE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING,
""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("path2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_ISSAMENODE,
JCR_ISSAMENODE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING,
""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("path2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_CONTAINS,
JCR_CONTAINS, JCR,
- new FunctionParameter[] {
- new FunctionParameter("selectorOrProperty",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("searchExpr",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_REFERENCE,
JCR_REFERENCE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("selectorOrProperty",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
- return pushdownFunctions;
- }
-
- @Override
public List<?> translate(LanguageObject obj, ExecutionContext context) {
if (obj instanceof Comparison) {
Comparison compare = (Comparison)obj;
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -22,8 +22,10 @@
/*
*/
-package org.teiid.translator.jdbc.oracle;
+package org.teiid.translator.jdbc.oracle;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
@@ -49,7 +51,6 @@
import org.teiid.language.SetQuery.Operation;
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.metadata.Column;
-import org.teiid.metadata.FunctionMethod;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -75,6 +76,15 @@
public final static String DUAL = "DUAL"; //$NON-NLS-1$
public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
+ /*
+ * Spatial Functions
+ */
+ public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
+ public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
+ public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
+ public static final String WITHIN_DISTANCE = "sdo_within_distance";
//$NON-NLS-1$
+ public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance";
//$NON-NLS-1$
+ public static final String ORACLE_SDO = "Oracle-SDO"; //$NON-NLS-1$
public void start() throws TranslatorException {
super.start();
@@ -112,10 +122,10 @@
});
//spatial functions
- registerFunctionModifier(OracleSpatialFunctions.RELATE, new
OracleSpatialFunctionModifier());
- registerFunctionModifier(OracleSpatialFunctions.NEAREST_NEIGHBOR, new
OracleSpatialFunctionModifier());
- registerFunctionModifier(OracleSpatialFunctions.FILTER, new
OracleSpatialFunctionModifier());
- registerFunctionModifier(OracleSpatialFunctions.WITHIN_DISTANCE, new
OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.RELATE, new
OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.NEAREST_NEIGHBOR, new
OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.FILTER, new
OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.WITHIN_DISTANCE, new
OracleSpatialFunctionModifier());
//add in type conversion
ConvertModifier convertModifier = new ConvertModifier();
@@ -171,6 +181,21 @@
convertModifier.addNumericBooleanConversions();
convertModifier.setWideningNumericImplicit(true);
registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, STRING, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, OBJECT, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, STRING, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, OBJECT, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR, STRING, STRING, OBJECT, STRING,
INTEGER);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR, STRING, OBJECT, OBJECT, STRING,
INTEGER);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR, STRING, OBJECT, STRING, STRING,
INTEGER);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR_DISTANCE, INTEGER, INTEGER);
+ addPushDownFunction(ORACLE_SDO, WITHIN_DISTANCE, STRING, OBJECT, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, WITHIN_DISTANCE, STRING, STRING, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, WITHIN_DISTANCE, STRING, OBJECT, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, FILTER, STRING, OBJECT, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, FILTER, STRING, OBJECT, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, FILTER, STRING, STRING, OBJECT, STRING);
}
public void handleInsertSequences(Insert insert) throws TranslatorException {
@@ -327,7 +352,7 @@
// If so, the ORDERED hint is added, if not, it isn't
Collection<Function> col = CollectorVisitor.collectObjects(Function.class,
command);
for (Function func : col) {
- if (func.getName().equalsIgnoreCase(OracleSpatialFunctions.RELATE)) {
+ if (func.getName().equalsIgnoreCase(OracleExecutionFactory.RELATE)) {
return comment + "/*+ ORDERED */ "; //$NON-NLS-1$
}
}
@@ -456,16 +481,15 @@
supportedFunctions.add("IFNULL"); //$NON-NLS-1$
supportedFunctions.add("NVL"); //$NON-NLS-1$
supportedFunctions.add("COALESCE"); //$NON-NLS-1$
-
+ supportedFunctions.add(RELATE);
+ supportedFunctions.add(NEAREST_NEIGHBOR);
+ supportedFunctions.add(NEAREST_NEIGHBOR_DISTANCE);
+ supportedFunctions.add(WITHIN_DISTANCE);
+ supportedFunctions.add(FILTER);
return supportedFunctions;
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- return OracleSpatialFunctions.getOracleSpatialFunctions();
- }
-
- @Override
public String translateLiteralTimestamp(Timestamp timestampValue) {
if (timestampValue.getNanos() == 0) {
String val = formatDateValue(timestampValue);
Deleted:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -1,149 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.translator.jdbc.oracle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
-
-public class OracleSpatialFunctions {
-
- /*
- * Spatial Functions
- */
- public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
- public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
- public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
- public static final String WITHIN_DISTANCE = "sdo_within_distance";
//$NON-NLS-1$
- public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance";
//$NON-NLS-1$
- public static final String ORACLE_SDO = "Oracle-SDO"; //$NON-NLS-1$
-
-
- public static List<FunctionMethod> getOracleSpatialFunctions(){
-
- List<FunctionMethod> spatialFuncs = new ArrayList<FunctionMethod>();
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR,
NEAREST_NEIGHBOR, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("NUMBER",
DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR,
NEAREST_NEIGHBOR, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("NUMBER",
DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR,
NEAREST_NEIGHBOR, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("NUMBER",
DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' +
NEAREST_NEIGHBOR_DISTANCE, NEAREST_NEIGHBOR_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("NUMBER",
DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + WITHIN_DISTANCE,
WITHIN_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + WITHIN_DISTANCE,
WITHIN_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + WITHIN_DISTANCE,
WITHIN_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + FILTER, FILTER,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + FILTER, FILTER,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + FILTER, FILTER,
ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2",
DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- return spatialFuncs;
- }
-}
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -22,6 +22,8 @@
package org.teiid.translator.jdbc.teradata;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -29,14 +31,11 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.ColumnReference;
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
@@ -164,7 +163,23 @@
public List<?> translate(Function function) {
return Arrays.asList(function.getParameters().get(0), " MOD ",
function.getParameters().get(1)); //$NON-NLS-1$
}
- });
+ });
+
+ addPushDownFunction(TERADATA, "COSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "TANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ACOSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ASINH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ATANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "CHAR2HEXINT", STRING, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "INDEX", INTEGER, STRING, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "BYTES", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "OCTET_LENGTH", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHAMP", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBAKAMP", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBUCKET", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHROW", INTEGER, STRING);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "NULLIFZERO", BIG_DECIMAL, BIG_DECIMAL);
//$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ZEROIFNULL", BIG_DECIMAL, BIG_DECIMAL);
//$NON-NLS-1$
}
@Override
@@ -210,106 +225,13 @@
supportedFunctions.add(SourceSystemFunctions.SQRT);
supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
supportedFunctions.add(SourceSystemFunctions.TAN);
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("**"); //$NON-NLS-1$
supportedFunctions.add(SourceSystemFunctions.UCASE);
supportedFunctions.add(SourceSystemFunctions.YEAR);
return supportedFunctions;
}
-
@Override
- public List<FunctionMethod> getPushDownFunctions(){
-
- List<FunctionMethod> pushdownFunctions = new
ArrayList<FunctionMethod>();
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "COSH",
"COSH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float",
DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Cos")}, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "SINH",
"SINH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float",
DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Sin")}, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "TANH",
"TANH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float",
DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Tanh")}, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ACOSH",
"ACOSH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float",
DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcCos")}, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ASINH",
"ASINH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float",
DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcSin")}, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ATANH",
"ATANH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float",
DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcTan")}, //$NON-NLS-1$
//$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"CHAR2HEXINT", "CHAR2HEXINT", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "INDEX",
"INDEX", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "BYTES",
"BYTES", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"OCTET_LENGTH", "OCTET_LENGTH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHAMP",
"HASHAMP", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"HASHBAKAMP", "HASHBAKAMP", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"HASHBUCKET", "HASHBUCKET", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHROW",
"HASHROW", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"NULLIFZERO", "NULLIFZERO", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "") ) ); //$NON-NLS-1$
//$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' +
"ZEROIFNULL", "ZEROIFNULL", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "") ) ); //$NON-NLS-1$
//$NON-NLS-2$
-
- return pushdownFunctions;
- }
-
-
- @Override
public String translateLiteralDate(Date dateValue) {
return "cast('" + formatDateValue(dateValue) + "' AS DATE
FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
}
Modified:
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -36,6 +36,7 @@
import org.mockito.Mockito;
import org.teiid.cdk.api.TranslationUtility;
import org.teiid.cdk.unittest.FakeTranslationFactory;
+import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.language.Command;
import org.teiid.metadata.FunctionMethod;
@@ -72,7 +73,7 @@
public static void loadUDFs(String udf, TranslationUtility util) {
try {
Collection <FunctionMethod> methods =
FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
- util.setUDF(methods);
+ util.addUDF("foo", methods); //$NON-NLS-1$
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
} catch (JAXBException e) {
@@ -83,8 +84,11 @@
public static Command helpTranslate(String vdbFileName, String udf,
List<FunctionMethod> pushdowns, String sql) {
TranslationUtility util = getTranslationUtility(vdbFileName, null);
- Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
+ if (pushdowns != null) {
+ util.addUDF(CoreConstants.SYSTEM_MODEL, pushdowns);
+ }
if (udf != null) {
+ Collection <FunctionMethod> methods = new
ArrayList<FunctionMethod>();
try {
methods.addAll(FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream()));
} catch (JAXBException e) {
@@ -92,11 +96,8 @@
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
}
+ util.addUDF("foo", methods); //$NON-NLS-1$
}
- if (pushdowns != null) {
- methods.addAll(pushdowns);
- }
- util.setUDF(methods);
return util.parseCommand(sql);
}
Modified:
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
---
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -394,7 +394,15 @@
input, output,
TRANSLATOR);
}
+
+ @Test public void test_sdo_within_distance_pushdownfunction() throws Exception {
+ String input = "SELECT INTKEY FROM BQT1.SMALLA WHERE
sdo_within_distance(OBJECTVALUE, 'SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0,
-45.0, NULL), NULL, NULL)', 'DISTANCE=25.0 UNIT=NAUT_MILE') = true";
//$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE
sdo_within_distance(SmallA.ObjectValue, SDO_GEOMETRY(2001, 8307,
MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), 'DISTANCE=25.0
UNIT=NAUT_MILE') = 'true'"; //$NON-NLS-1$
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
+ TRANSLATOR);
+ }
+
/**
* Test a query which uses
* <code>sdo_within_distance(String literal, Object element, String literal)
Modified:
branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
---
branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -22,7 +22,9 @@
package org.teiid.translator.salesforce;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -88,7 +90,9 @@
@Override
public void start() throws TranslatorException {
super.start();
- LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Started"); //$NON-NLS-1$
+ addPushDownFunction(SALESFORCE, INCLUDES, BOOLEAN, STRING, STRING);
+ addPushDownFunction(SALESFORCE, EXCLUDES, BOOLEAN, STRING, STRING);
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Salesforce ExecutionFactory
Started"); //$NON-NLS-1$
}
@@ -124,28 +128,11 @@
}
@Override
- public List getSupportedFunctions() {
- return Collections.EMPTY_LIST;
+ public List<String> getSupportedFunctions() {
+ return Arrays.asList(INCLUDES, EXCLUDES);
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- List<FunctionMethod> pushdownFunctions = new
ArrayList<FunctionMethod>();
- pushdownFunctions.add(new FunctionMethod(SALESFORCE + '.' +INCLUDES, INCLUDES,
SALESFORCE,
- new FunctionParameter[] {
- new FunctionParameter("columnName",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("param",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(SALESFORCE + '.' + EXCLUDES, EXCLUDES,
SALESFORCE,
- new FunctionParameter[] {
- new FunctionParameter("columnName",
DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("param",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
- return pushdownFunctions;
- }
-
- @Override
public boolean supportsCompareCriteriaEquals() {
return true;
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -31,6 +31,7 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
@@ -70,8 +71,8 @@
import org.teiid.language.SubqueryComparison.Quantifier;
import org.teiid.metadata.Procedure;
import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
@@ -506,8 +507,15 @@
String name = function.getName();
if (function.getFunctionDescriptor() != null) {
name = function.getFunctionDescriptor().getName();
+ //check for translator pushdown functions, and use the name in source if
possible
+ if (function.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN
+ &&
function.getFunctionDescriptor().getSchema().equalsIgnoreCase(CoreConstants.SYSTEM_MODEL)
+ && function.getFunctionDescriptor().getMethod().getNameInSource() !=
null) {
+ name = function.getFunctionDescriptor().getMethod().getNameInSource();
+ }
+ } else {
+ name = SingleElementSymbol.getShortName(name);
}
- name = SingleElementSymbol.getShortName(name);
//if there is any ambiguity in the function name it will be up to the translator
logic to check the
//metadata
@@ -557,9 +565,7 @@
Object mid = symbol.getMetadataID();
- if(! (mid instanceof TempMetadataID)) {
- element.setMetadataObject(metadataFactory.getElement(mid));
- }
+ element.setMetadataObject(metadataFactory.getElement(mid));
return element;
}
@@ -717,9 +723,6 @@
}
fullGroup = removeSchemaName(fullGroup);
NamedTable group = new NamedTable(fullGroup, alias, null);
- if (symbol.getMetadataID() instanceof TempMetadataID) {
- return group;
- }
try {
group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
} catch (QueryMetadataException e) {
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -29,10 +29,12 @@
*/
public class BasicSourceCapabilities implements SourceCapabilities, Serializable {
- private Scope scope = Scope.SCOPE_GLOBAL;
- private Map capabilityMap = new HashMap();
- private Map functionMap = new HashMap();
- private Map propertyMap = new HashMap();
+ private static final long serialVersionUID = -1779069588746365579L;
+
+ private Scope scope = Scope.SCOPE_GLOBAL;
+ private Map<Capability, Boolean> capabilityMap = new HashMap<Capability,
Boolean>();
+ private Map<String, Boolean> functionMap = new TreeMap<String,
Boolean>(String.CASE_INSENSITIVE_ORDER);
+ private Map<Capability, Object> propertyMap = new HashMap<Capability,
Object>();
/**
* Construct a basic capabilities object.
@@ -41,12 +43,12 @@
}
public boolean supportsCapability(Capability capability) {
- Boolean supports = (Boolean) capabilityMap.get(capability);
+ Boolean supports = capabilityMap.get(capability);
return (supports == null) ? false : supports.booleanValue();
}
public boolean supportsFunction(String functionName) {
- Boolean supports = (Boolean) functionMap.get(functionName);
+ Boolean supports = functionMap.get(functionName);
return (supports == null) ? false : supports.booleanValue();
}
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -354,8 +354,7 @@
* used if the capability FUNCTION is true.
*
* @param functionName
- * The function that may be supported (see MetaMatrix documentation for
further definition of the functions and
- * their parameters.)
+ * The function that may be supported
* @return True if function is supported.
*/
public boolean supportsFunction(String functionName);
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -209,14 +209,14 @@
}
//capabilities check is only valid for non-schema scoped functions
- //technically the other functions are scoped to SYS, but that's
+ //technically the other functions are scoped to SYS or their function model, but
that's
//not formally part of their metadata yet
Schema schema = function.getFunctionDescriptor().getMethod().getParent();
if (schema == null) {
// Find capabilities
SourceCapabilities caps = getCapabilities(modelID, metadata, capFinder);
- if
(!caps.supportsFunction(function.getFunctionDescriptor().getName().toLowerCase())) {
+ if (!caps.supportsFunction(function.getFunctionDescriptor().getName())) {
return false;
}
} else if (!schema.getFullName().equalsIgnoreCase(metadata.getFullName(modelID)))
{
@@ -225,7 +225,7 @@
//special check to ensure that special conversions are not pushed down (this can
be removed after we support type based function pushdown)
if (FunctionLibrary.isConvert(function)) {
- Class fromType = function.getArg(0).getType();
+ Class<?> fromType = function.getArg(0).getType();
//object or clob to anything cannot be pushed down
if (DataTypeManager.DefaultDataClasses.OBJECT.equals(fromType)
|| DataTypeManager.DefaultDataClasses.CLOB.equals(fromType)
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -22,11 +22,11 @@
package org.teiid.dqp.internal.process;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
-import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
@@ -34,26 +34,18 @@
import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.TranslatorException;
/**
*/
-public class TestConnectorCapabilitiesFinder extends TestCase {
+@SuppressWarnings("nls")
+public class TestConnectorCapabilitiesFinder {
- /**
- * Constructor for TestConnectorCapabilitiesFinder.
- * @param name
- */
- public TestConnectorCapabilitiesFinder(String name) {
- super(name);
- }
-
- public void testFind() throws Exception {
+ @Test public void testFind() throws Exception {
String modelName = "model"; //$NON-NLS-1$
String functionName = "fakeFunction"; //$NON-NLS-1$
@@ -84,19 +76,17 @@
}
- public void testPushdownFunctionSupport() throws Exception {
+ @Test public void testPushdownFunctionSupport() throws Exception {
ExecutionFactory<Object, Object> ef = new ExecutionFactory<Object,
Object>(){
- public List<FunctionMethod> getPushDownFunctions(){
- ArrayList<FunctionMethod> list = new ArrayList<FunctionMethod>();
- list.add(new FunctionMethod("ns.func", "function",
"misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
- new FunctionParameter("param",
DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING, "" ) )); //$NON-NLS-1$ //$NON-NLS-2$
- return list;
- }
+
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ addPushDownFunction("ns", "func",
DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING);
+ }
};
-
+ ef.start();
BasicSourceCapabilities bsc = CapabilitiesConverter.convertCapabilities(ef,
"conn"); //$NON-NLS-1$
- assertEquals("Did not get expected capabilities", true,
bsc.supportsFunction("ns.func")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Did not get expected capabilities",
bsc.supportsFunction("ns.func")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
===================================================================
---
branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2011-05-25
02:55:47 UTC (rev 3195)
+++
branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2011-05-25
19:53:24 UTC (rev 3196)
@@ -24,7 +24,9 @@
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.teiid.cdk.CommandBuilder;
import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
@@ -53,25 +55,36 @@
public class TranslationUtility {
private QueryMetadataInterface metadata;
+ private FunctionLibrary functionLibrary;
/**
* Construct a utility instance with a given vdb file.
* @param vdbFile The .vdb file name representing metadata for the connector
*/
public TranslationUtility(String vdbFile) {
- metadata = VDBMetadataFactory.getVDBMetadata(vdbFile);
+ initWrapper(VDBMetadataFactory.getVDBMetadata(vdbFile));
}
+
+ private void initWrapper(QueryMetadataInterface acutalMetadata) {
+ functionLibrary = acutalMetadata.getFunctionLibrary();
+ metadata = new BasicQueryMetadataWrapper(acutalMetadata) {
+ @Override
+ public FunctionLibrary getFunctionLibrary() {
+ return functionLibrary;
+ }
+ };
+ }
public TranslationUtility(URL url) {
try {
- metadata = VDBMetadataFactory.getVDBMetadata(url, null);
+ initWrapper(VDBMetadataFactory.getVDBMetadata(url, null));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public TranslationUtility(QueryMetadataInterface metadata) {
- this.metadata = metadata;
+ initWrapper(metadata);
}
public Command parseCommand(String sql, boolean generateAliases, boolean
supportsGroupAliases) {
@@ -98,14 +111,13 @@
public RuntimeMetadata createRuntimeMetadata() {
return new RuntimeMetadataImpl(metadata);
}
+
+ private List<FunctionTree> functions = new ArrayList<FunctionTree>();
+
+ public void addUDF(String schema, Collection<FunctionMethod> methods) {
+ this.functions.add(new FunctionTree(schema, new UDFSource(methods)));
+ SystemFunctionManager sfm = new SystemFunctionManager();
+ functionLibrary = new FunctionLibrary(sfm.getSystemFunctions(),
this.functions.toArray(new FunctionTree[this.functions.size()]));
+ }
- public void setUDF(final Collection<FunctionMethod> methods) {
- this.metadata = new BasicQueryMetadataWrapper(this.metadata) {
- @Override
- public FunctionLibrary getFunctionLibrary() {
- SystemFunctionManager sfm = new SystemFunctionManager();
- return new FunctionLibrary(sfm.getSystemFunctions(), new
FunctionTree("foo", new UDFSource(methods))); //$NON-NLS-1$
- }
- };
- }
}