Author: shawkins
Date: 2012-04-18 14:03:49 -0400 (Wed, 18 Apr 2012)
New Revision: 4020
Modified:
branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
Log:
TEIID-2005 fixing oracle sequence issue and updating javadocs
Modified: branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-18
18:03:19 UTC (rev 4019)
+++ branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-18
18:03:49 UTC (rev 4020)
@@ -685,7 +685,10 @@
/**
* Get list of all supported function names. Arithmetic functions have names like
* "+".
- * @see SourceSystemFunctions
+ * @see SourceSystemFunctions for a listing of system pushdown functions. Note that
+ * not all system functions are listed as some functions will use a common name
+ * such as CONCAT vs. the || operator, and other functions will be rewritten and
+ * not pushed down, such as SPACE.
* @since 3.1 SP3
*/
public List<String> getSupportedFunctions() {
Modified:
branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
---
branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-04-18
18:03:19 UTC (rev 4019)
+++
branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-04-18
18:03:49 UTC (rev 4020)
@@ -27,6 +27,10 @@
* The names and function forms follow the Open Group CLI functions, with a few
exceptions
* (such as lpad, rpad, bitand, bitor, etc. which are most notably supported by Oracle).
*
+ * Note that not all system functions are listed as some functions will use a common
name
+ * such as CONCAT vs. the || operator, and other functions will be rewritten and
+ * not pushed down, such as SPACE.
+ *
*/
public class SourceSystemFunctions {
Modified:
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
---
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-04-18
18:03:19 UTC (rev 4019)
+++
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-04-18
18:03:49 UTC (rev 4020)
@@ -41,6 +41,7 @@
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -493,6 +494,34 @@
super.visit(obj);
}
+ public void visit(NamedTable table) {
+ stripDualAlias(table);
+ super.visit(table);
+ }
+
+ private void stripDualAlias(NamedTable table) {
+ if (table.getCorrelationName() != null) {
+ String groupName = null;
+ AbstractMetadataRecord groupID = table.getMetadataObject();
+ if(groupID != null) {
+ groupName = getName(groupID);
+ } else {
+ groupName = table.getName();
+ }
+ if (DUAL.equalsIgnoreCase(groupName)) {
+ table.setCorrelationName(null);
+ }
+ }
+ }
+
+ @Override
+ public void visit(ColumnReference obj) {
+ if (obj.getTable() != null) {
+ stripDualAlias(obj.getTable());
+ }
+ super.visit(obj);
+ }
+
};
}
Modified:
branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
---
branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-04-18
18:03:19 UTC (rev 4019)
+++
branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-04-18
18:03:49 UTC (rev 4020)
@@ -655,8 +655,8 @@
* @since 4.3
*/
@Test public void testDUAL() throws Exception {
- String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
- String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
+ String input = "SELECT something FROM DUAL as g0"; //$NON-NLS-1$
+ String output = "SELECT seq.nextval FROM DUAL"; //$NON-NLS-1$
helpTestVisitor(getOracleSpecificMetadata(),
input,
@@ -776,14 +776,15 @@
cols.get(1).setNameInSource("ID:SEQUENCE=MYSEQUENCE.nextVal");
//$NON-NLS-1$
cols.get(2).setNativeType("date"); //$NON-NLS-1$
cols.get(3).setNativeType("CHAR");
- RealMetadataFactory.createElements(dual, new String[] {"something"},
new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+ List<Column> dualCols = RealMetadataFactory.createElements(dual, new
String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING});
//$NON-NLS-1$
+ dualCols.get(0).setNameInSource("seq.nextval");
ProcedureParameter in1 = RealMetadataFactory.createParameter("in1",
SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
ColumnSet<Procedure> rs3 =
RealMetadataFactory.createResultSet("proc.rs1", new String[] { "e1" },
new String[] { DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$
Procedure p = RealMetadataFactory.createStoredProcedure("proc", foo,
Arrays.asList(in1));
p.setResultSet(rs3);
p.setProperty(SQLConversionVisitor.TEIID_NATIVE_QUERY, "select x from y
where z = $1");
-
+
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
return new TransformationMetadata(null, store, null,
RealMetadataFactory.SFM.getSystemFunctions(), null);
}
Show replies by date