teiid SVN: r2987 - in trunk/engine/src: main/java/org/teiid/query/sql/lang and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-09 17:28:50 -0500 (Wed, 09 Mar 2011)
New Revision: 2987
Modified:
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
Log:
TEIID-1497 adding rewrite logic for quantified some
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-03-09 20:30:47 UTC (rev 2986)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-03-09 22:28:50 UTC (rev 2987)
@@ -1141,8 +1141,8 @@
}
} else if (criteria instanceof SubquerySetCriteria) {
SubquerySetCriteria sub = (SubquerySetCriteria)criteria;
- if (isNull(sub.getExpression())) {
- return UNKNOWN_CRITERIA;
+ if (rewriteLeftExpression(sub)) {
+ return UNKNOWN_CRITERIA;
}
rewriteSubqueryContainer(sub, true);
if (!RelationalNodeUtil.shouldExecute(sub.getCommand(), false, true)) {
@@ -1187,7 +1187,10 @@
private Criteria rewriteDependentSetCriteria(DependentSetCriteria dsc)
throws TeiidComponentException, TeiidProcessingException{
if (!processing) {
- return rewriteCriteria(dsc);
+ if (rewriteLeftExpression(dsc)) {
+ return UNKNOWN_CRITERIA;
+ }
+ return dsc;
}
SetCriteria setCrit = new SetCriteria();
setCrit.setExpression(dsc.getExpression());
@@ -1570,6 +1573,28 @@
* quantifier is replaced with the canonical and equivalent 'SOME'
*/
private Criteria rewriteCriteria(SubqueryCompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
+
+ if (criteria.getCommand().getProcessorPlan() == null && criteria.getPredicateQuantifier() != SubqueryCompareCriteria.ALL) {
+ if (criteria.getOperator() == CompareCriteria.EQ || criteria.getOperator() == CompareCriteria.NE) {
+ SubquerySetCriteria result = new SubquerySetCriteria(criteria.getLeftExpression(), criteria.getCommand());
+ result.setNegated(criteria.getOperator() == CompareCriteria.NE);
+ return rewriteCriteria(result);
+ }
+ CompareCriteria cc = new CompareCriteria();
+ cc.setLeftExpression(criteria.getLeftExpression());
+ Query q = createInlineViewQuery(new GroupSymbol("X"), criteria.getCommand(), metadata, criteria.getCommand().getProjectedSymbols()); //$NON-NLS-1$
+ SingleElementSymbol ses = q.getProjectedSymbols().get(0);
+ Expression expr = SymbolMap.getExpression(ses);
+ q.getSelect().clearSymbols();
+ AggregateSymbol.Type type = Type.MAX;
+ if (criteria.getOperator() == CompareCriteria.GT || criteria.getOperator() == CompareCriteria.GE) {
+ type = Type.MIN;
+ }
+ q.getSelect().addSymbol(new AggregateSymbol(ses.getName(), type.name(), false, expr));
+ cc.setRightExpression(new ScalarSubquery(q));
+ cc.setOperator(criteria.getOperator());
+ return rewriteCriteria(cc);
+ }
Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
@@ -2132,14 +2157,14 @@
return FALSE_CRITERIA;
}
- private Criteria rewriteCriteria(AbstractSetCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
+ private boolean rewriteLeftExpression(AbstractSetCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
criteria.setExpression(rewriteExpressionDirect(criteria.getExpression()));
if (isNull(criteria.getExpression())) {
- return UNKNOWN_CRITERIA;
+ return true;
}
- return criteria;
+ return false;
}
private Criteria rewriteCriteria(SetCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
@@ -2149,7 +2174,7 @@
criteria.setExpression(rewriteExpressionDirect(criteria.getExpression()));
- if (isNull(criteria.getExpression())) {
+ if (rewriteLeftExpression(criteria)) {
return UNKNOWN_CRITERIA;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java 2011-03-09 20:30:47 UTC (rev 2986)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java 2011-03-09 22:28:50 UTC (rev 2987)
@@ -213,5 +213,15 @@
public Expression getRightExpression() {
return new ScalarSubquery(getCommand());
}
+
+ @Override
+ public void negate() {
+ super.negate();
+ if (this.predicateQuantifier == ALL) {
+ this.predicateQuantifier = SOME;
+ } else {
+ this.predicateQuantifier = ALL;
+ }
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-09 20:30:47 UTC (rev 2986)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-09 22:28:50 UTC (rev 2987)
@@ -1292,7 +1292,7 @@
}
@Test public void testCompareSubquery1() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 < any (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 < ALL (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
1, // Access
@@ -1312,27 +1312,6 @@
});
}
- @Test public void testCompareSubquery2() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 <= some (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
@Test public void testCompareSubquery3() {
ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 >= all (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
@@ -2972,14 +2951,14 @@
}
/** Case 1456, defect 10492*/
- @Test public void testAliasingDefect3(){
+ @Test public void testAliasingDefect3() throws Exception {
// Create query
- String sql = "SELECT X.e1 FROM pm1.g2, vm1.g1 X WHERE X.e2 = ANY (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1) AND X.e1 = pm1.g2.e1";//$NON-NLS-1$
+ String sql = "SELECT X.e1 FROM pm1.g2, vm1.g1 X WHERE X.e2 = ALL (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1) AND X.e1 = pm1.g2.e1";//$NON-NLS-1$
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
@@ -2993,7 +2972,7 @@
ProcessorPlan plan = helpPlan(sql, metadata,
null, capFinder,
- new String[] { "SELECT g_1.e1 FROM pm1.g2 AS g_0, pm1.g1 AS g_1 WHERE (g_1.e1 = g_0.e1) AND (g_1.e2 = SOME (SELECT MAX(g_2.e2) FROM pm1.g1 AS g_2 WHERE g_2.e1 = g_1.e1))" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ new String[] { "SELECT g_1.e1 FROM pm1.g2 AS g_0, pm1.g1 AS g_1 WHERE (g_1.e1 = g_0.e1) AND (g_1.e2 = ALL (SELECT MAX(g_2.e2) FROM pm1.g1 AS g_2 WHERE g_2.e1 = g_1.e1))" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-03-09 20:30:47 UTC (rev 2986)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-03-09 22:28:50 UTC (rev 2987)
@@ -871,4 +871,10 @@
@Test public void testInvalidGeneratedSemijoinQuery1() throws Exception {
TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 = (Select max(e2) from pm2.g2 where e1 = pm3.g1.e1)", "SELECT e1 FROM pm3.g1, (SELECT MAX(e2) AS MAX, e1 FROM pm2.g2 GROUP BY e1) AS X__1 WHERE (pm3.g1.e1 = X__1.e1) AND (pm3.g1.e2 = X__1.MAX)", FakeMetadataFactory.example4());
}
+
+ @Test public void testCompareSubquery2() throws Exception {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 <= some (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 <= (SELECT MAX(X.e1) FROM (SELECT e1 FROM pm2.g1) AS X)" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-03-09 20:30:47 UTC (rev 2986)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-03-09 22:28:50 UTC (rev 2987)
@@ -824,12 +824,12 @@
@Test public void testCompareSubqueryANY() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE '3' = ANY (SELECT e1 FROM pm1.g2)", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g1 WHERE '3' = SOME (SELECT e1 FROM pm1.g2)"); //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g1 WHERE '3' IN (SELECT e1 FROM pm1.g2)"); //$NON-NLS-1$
}
@Test public void testCompareSubquery() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE '3' = SOME (SELECT e1 FROM pm1.g2)", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g1 WHERE '3' = SOME (SELECT e1 FROM pm1.g2)"); //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g1 WHERE '3' IN (SELECT e1 FROM pm1.g2)"); //$NON-NLS-1$
}
@Test public void testCompareSubqueryUnknown() {
@@ -2428,13 +2428,17 @@
@Test public void testRewritePredicateOptimizationOr() throws Exception {
helpTestRewriteCriteria("pm1.g1.e2 in (5, 6) or pm1.g1.e2 = 2", "pm1.g1.e2 IN (2, 5, 6)");
}
+
+ @Test public void testRewriteCritSubqueryNegate() {
+ helpTestRewriteCriteria("not(pm1.g1.e1 > SOME (select 'a' from pm1.g2))", "pm1.g1.e1 <= ALL (SELECT 'a' FROM pm1.g2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
@Test public void testRewriteCritSubqueryFalse() {
helpTestRewriteCriteria("exists(select 1 from pm1.g1 where 1=0)", "1 = 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testRewriteCritSubqueryFalse1() {
- helpTestRewriteCriteria("not(pm1.g1.e1 < SOME (select 'a' from pm1.g1 where 1=0))", "1 = 0"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("not(pm1.g1.e1 > SOME (select 'a' from pm1.g1 where 1=0))", "pm1.g1.e1 IS NOT NULL"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testRewriteCritSubqueryFalse2() {
13 years, 10 months
teiid SVN: r2986 - trunk/engine/src/test/java/org/teiid/dqp/internal/process.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-09 15:30:47 -0500 (Wed, 09 Mar 2011)
New Revision: 2986
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
changing the test value to ensure timing issues will not make it fail
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-03-09 19:04:10 UTC (rev 2985)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-03-09 20:30:47 UTC (rev 2986)
@@ -241,7 +241,7 @@
Thread.sleep(100);
}
assertEquals(ThreadState.IDLE, item.getThreadState());
- assertTrue(item.resultsBuffer.getManagedRowCount() < 44);
+ assertTrue(item.resultsBuffer.getManagedRowCount() <= 46);
//pull the rest of the results
for (int j = 0; j < 48; j++) {
item = core.getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(reqMsg.getExecutionId()));
13 years, 10 months
teiid SVN: r2985 - in trunk/engine/src: main/java/org/teiid/query/sql/lang and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-09 14:04:10 -0500 (Wed, 09 Mar 2011)
New Revision: 2985
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
Log:
TEIID-1503 fix for regression with additional checks to prevent unnecessary planning
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2011-03-09 16:11:50 UTC (rev 2984)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2011-03-09 19:04:10 UTC (rev 2985)
@@ -59,7 +59,6 @@
import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.GroupBy;
import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.NotCriteria;
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.Query;
@@ -119,6 +118,7 @@
public boolean not;
public List<Criteria> nonEquiJoinCriteria = new LinkedList<Criteria>();
public Criteria additionalCritieria;
+ public Class<?> type;
}
private IDGenerator idGenerator;
@@ -264,7 +264,7 @@
//if it's currently unknown, removing criteria won't make it any better
return current;
}
-
+
Collection<GroupSymbol> leftGroups = FrameUtil.findJoinSourceNode(current).getGroups();
if (!planQuery(leftGroups, false, plannedResult)) {
@@ -279,6 +279,8 @@
}
try {
+ //clone the symbols as they may change during planning
+ List<SingleElementSymbol> projectedSymbols = LanguageObject.Util.deepClone(plannedResult.query.getProjectedSymbols(), SingleElementSymbol.class);
//NOTE: we could tap into the relationalplanner at a lower level to get this in a plan node form,
//the major benefit would be to reuse the dependent join planning logic if possible.
RelationalPlan subPlan = (RelationalPlan)QueryOptimizer.optimizePlan(plannedResult.query, metadata, idGenerator, capFinder, analysisRecord, context);
@@ -286,6 +288,7 @@
if (planCardinality.floatValue() == NewCalculateCostUtil.UNKNOWN_VALUE
|| planCardinality.floatValue() > 10000000
+ || (sourceCost == NewCalculateCostUtil.UNKNOWN_VALUE && planCardinality.floatValue() > 1000)
|| (sourceCost != NewCalculateCostUtil.UNKNOWN_VALUE && sourceCost * originalCardinality.floatValue() < planCardinality.floatValue() / (100 * Math.log(Math.max(4, sourceCost))))) {
//bail-out if both are unknown or the new plan is too large
return current;
@@ -312,7 +315,7 @@
PlanNode node = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
node.setProperty(NodeConstants.Info.PROCESSOR_PLAN, subPlan);
- node.setProperty(NodeConstants.Info.OUTPUT_COLS, plannedResult.query.getProjectedSymbols());
+ node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectedSymbols);
node.setProperty(NodeConstants.Info.EST_CARDINALITY, planCardinality);
root.addAsParent(semiJoin);
semiJoin.addLastChild(node);
@@ -328,20 +331,18 @@
public PlannedResult findSubquery(Criteria crit) throws TeiidComponentException, QueryMetadataException {
PlannedResult result = new PlannedResult();
- if (crit instanceof NotCriteria) {
- result.not = true;
- crit = ((NotCriteria)crit).getCriteria();
- }
if (crit instanceof SubquerySetCriteria) {
//convert to the quantified form
SubquerySetCriteria ssc = (SubquerySetCriteria)crit;
result.not ^= ssc.isNegated();
+ result.type = crit.getClass();
crit = new SubqueryCompareCriteria(ssc.getExpression(), ssc.getCommand(), SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
} else if (crit instanceof CompareCriteria) {
//convert to the quantified form
CompareCriteria cc = (CompareCriteria)crit;
if (cc.getRightExpression() instanceof ScalarSubquery) {
ScalarSubquery ss = (ScalarSubquery)cc.getRightExpression();
+ result.type = ss.getClass();
if (ss.getCommand() instanceof Query) {
Query query = (Query)ss.getCommand();
if (query.getGroupBy() == null && query.hasAggregates()) {
@@ -375,7 +376,9 @@
if (result.not && !isNonNull(query, rightExpr)) {
return result;
}
-
+ if (result.type == null) {
+ result.type = scc.getClass();
+ }
result.query = query;
result.additionalCritieria = (Criteria)new CompareCriteria(scc.getLeftExpression(), scc.getOperator(), rightExpr).clone();
}
@@ -384,6 +387,7 @@
if (!(exists.getCommand() instanceof Query)) {
return result;
}
+ result.type = crit.getClass();
//the correlations can only be in where (if no group by or aggregates) or having
result.query = (Query)exists.getCommand();
}
@@ -431,6 +435,12 @@
return false;
}
+ if ((plannedResult.type == ExistsCriteria.class || plannedResult.type == ScalarSubquery.class) && plannedResult.query.getCorrelatedReferences() == null) {
+ //we can't really improve on this case
+ //TODO: do this check earlier
+ return false;
+ }
+
plannedResult.query = (Query)plannedResult.query.clone();
plannedResult.query.setLimit(null);
@@ -500,12 +510,12 @@
}
for (SingleElementSymbol ses : requiredExpressions) {
if (projectedSymbols.add(ses)) {
- plannedResult.query.getSelect().addSymbol(ses);
+ plannedResult.query.getSelect().addSymbol((SingleElementSymbol) ses.clone());
}
}
for (SingleElementSymbol ses : (List<SingleElementSymbol>)plannedResult.rightExpressions) {
if (projectedSymbols.add(ses)) {
- plannedResult.query.getSelect().addSymbol(ses);
+ plannedResult.query.getSelect().addSymbol((SingleElementSymbol)ses.clone());
}
}
return true;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2011-03-09 16:11:50 UTC (rev 2984)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2011-03-09 19:04:10 UTC (rev 2985)
@@ -348,7 +348,7 @@
}
if(getLimit() != null) {
- copy.setLimit( (Limit) getLimit().clone());
+ copy.setLimit( getLimit().clone());
}
copy.setWith(LanguageObject.Util.deepClone(this.getWith(), WithQueryCommand.class));
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-03-09 16:11:50 UTC (rev 2984)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-03-09 19:04:10 UTC (rev 2985)
@@ -836,6 +836,27 @@
});
}
+ @Test public void testNonSemiJoin() throws Exception {
+ ProcessorPlan plan = helpPlan("Select x from xmltable('/a/b' passing convert('<a/>', xml) columns x integer path '@x') as t where x = (select count(e2) FROM pm1.g2)", FakeMetadataFactory.example4(), //$NON-NLS-1$
+ new String[] {}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
/**
* Test to ensure that we don't create an invalid semijoin query when attempting to convert the subquery to a semijoin
*/
13 years, 10 months
teiid SVN: r2984 - in trunk/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc/intersystemscache and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-09 11:11:50 -0500 (Wed, 09 Mar 2011)
New Revision: 2984
Added:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheTranslation.java
Removed:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
Log:
TEIID-1060 additional changes to intersystems cache support
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-03-09 15:16:40 UTC (rev 2983)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-03-09 16:11:50 UTC (rev 2984)
@@ -29,15 +29,16 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.language.Expression;
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;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.EscapeSyntaxModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
@@ -50,50 +51,66 @@
@Override
public void start() throws TranslatorException {
super.start();
+ convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
+ convert.addTypeMapping("integer", FunctionModifier.INTEGER); //$NON-NLS-1$
convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
- convert.addTypeMapping("character", FunctionModifier.CHAR); //$NON-NLS-1$
convert.addTypeMapping("decimal(38,19)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
convert.addTypeMapping("decimal(19,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
- convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("character", FunctionModifier.CHAR); //$NON-NLS-1$
convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+ convert.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+ convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
convert.addNumericBooleanConversions();
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("nvl")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new ModifiedFunction(SourceSystemFunctions.CONCAT));
- registerFunctionModifier(SourceSystemFunctions.ACOS, new ModifiedFunction(SourceSystemFunctions.ACOS));
- registerFunctionModifier(SourceSystemFunctions.ASIN, new ModifiedFunction(SourceSystemFunctions.ASIN));
- registerFunctionModifier(SourceSystemFunctions.ATAN, new ModifiedFunction(SourceSystemFunctions.ATAN));
- registerFunctionModifier(SourceSystemFunctions.COS, new ModifiedFunction(SourceSystemFunctions.COS));
- registerFunctionModifier(SourceSystemFunctions.COT, new ModifiedFunction(SourceSystemFunctions.COT));
- registerFunctionModifier(SourceSystemFunctions.CURDATE, new ModifiedFunction(SourceSystemFunctions.CURDATE));
- registerFunctionModifier(SourceSystemFunctions.CURTIME, new ModifiedFunction(SourceSystemFunctions.CURTIME));
- registerFunctionModifier(SourceSystemFunctions.DAYNAME, new ModifiedFunction(SourceSystemFunctions.DAYNAME));
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ModifiedFunction(SourceSystemFunctions.DAYOFMONTH));
- registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ModifiedFunction(SourceSystemFunctions.DAYOFWEEK));
- registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ModifiedFunction(SourceSystemFunctions.DAYOFYEAR));
- registerFunctionModifier(SourceSystemFunctions.EXP, new ModifiedFunction(SourceSystemFunctions.EXP));
- registerFunctionModifier(SourceSystemFunctions.HOUR, new ModifiedFunction(SourceSystemFunctions.HOUR));
- registerFunctionModifier(SourceSystemFunctions.LOG,new ModifiedFunction(SourceSystemFunctions.LOG));
- registerFunctionModifier(SourceSystemFunctions.LOG10, new ModifiedFunction(SourceSystemFunctions.LOG10));
- registerFunctionModifier(SourceSystemFunctions.LEFT, new ModifiedFunction(SourceSystemFunctions.LEFT));
- registerFunctionModifier(SourceSystemFunctions.MINUTE, new ModifiedFunction(SourceSystemFunctions.MINUTE));
- registerFunctionModifier(SourceSystemFunctions.MONTH, new ModifiedFunction(SourceSystemFunctions.MONTH));
- registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new ModifiedFunction(SourceSystemFunctions.MONTHNAME));
- registerFunctionModifier(SourceSystemFunctions.MOD, new ModifiedFunction(SourceSystemFunctions.MOD));
- registerFunctionModifier(SourceSystemFunctions.NOW, new ModifiedFunction(SourceSystemFunctions.NOW));
- registerFunctionModifier(SourceSystemFunctions.PI, new ModifiedFunction(SourceSystemFunctions.PI));
- registerFunctionModifier(SourceSystemFunctions.QUARTER, new ModifiedFunction(SourceSystemFunctions.QUARTER));
- registerFunctionModifier(SourceSystemFunctions.RIGHT, new ModifiedFunction(SourceSystemFunctions.RIGHT));
- registerFunctionModifier(SourceSystemFunctions.SIN, new ModifiedFunction(SourceSystemFunctions.SIN));
- registerFunctionModifier(SourceSystemFunctions.SECOND, new ModifiedFunction(SourceSystemFunctions.SECOND));
- registerFunctionModifier(SourceSystemFunctions.SQRT,new ModifiedFunction(SourceSystemFunctions.SQRT));
- registerFunctionModifier(SourceSystemFunctions.TAN,new ModifiedFunction(SourceSystemFunctions.TAN));
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new ModifiedFunction(SourceSystemFunctions.TIMESTAMPADD));
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new ModifiedFunction(SourceSystemFunctions.TIMESTAMPDIFF));
- registerFunctionModifier(SourceSystemFunctions.TRUNCATE,new ModifiedFunction(SourceSystemFunctions.TRUNCATE));
- registerFunctionModifier(SourceSystemFunctions.WEEK,new ModifiedFunction(SourceSystemFunctions.WEEK));
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.ACOS, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.ASIN, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.ATAN, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.COS, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.COT, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.EXP, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.LOG,new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.LOG10, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.MOD, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.NOW, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.PI, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.SIN, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.SQRT,new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TAN, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TRUNCATE, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DIVIDE_OP, new FunctionModifier() {
+
+ @Override
+ public List<?> translate(Function function) {
+ if (function.getType() == TypeFacility.RUNTIME_TYPES.INTEGER || function.getType() == TypeFacility.RUNTIME_TYPES.LONG) {
+ Function result = convert.createConvertFunction(getLanguageFactory(), function, TypeFacility.getDataTypeName(function.getType()));
+ function.setType(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
+ return Arrays.asList(result);
+ }
+ return null;
+ }
+ });
}
@Override
@@ -227,28 +244,4 @@
return true;
}
- static class ModifiedFunction extends FunctionModifier{
- String name;
- ModifiedFunction(String name){
- this.name = name;
- }
-
- @Override
- public List<?> translate(Function function) {
- StringBuilder sb = new StringBuilder();
- sb.append("{fn ").append(this.name).append('(');//$NON-NLS-1$
- List<Expression> params = function.getParameters();
- if (params != null && !params.isEmpty()) {
- for (int i = 0; i < params.size(); i++) {
- sb.append(params.get(0));
- if (i < (params.size()-1)) {
- sb.append(',');
- }
- }
- }
- sb.append(")}");//$NON-NLS-1$
-
- return Arrays.asList(sb);
- }
- }
}
Deleted: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java 2011-03-09 15:16:40 UTC (rev 2983)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java 2011-03-09 16:11:50 UTC (rev 2984)
@@ -1,138 +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.intersystemscache;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Timestamp;
-import java.util.Arrays;
-
-import org.junit.Test;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.LanguageFactory;
-import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.intersyscache.InterSystemsCacheExecutionFactory;
-/**
- */
-public class TestInterSystemsCacheConvertModifier {
-
- private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
-
- public String helpGetString(Expression expr) throws Exception {
- InterSystemsCacheExecutionFactory trans = new InterSystemsCacheExecutionFactory();
- trans.start();
- SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
- sqlVisitor.append(expr);
-
- return sqlVisitor.toString();
- }
-
- public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
- Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
- Arrays.asList(
- srcExpression,
- LANG_FACTORY.createLiteral(tgtType, String.class)),
- TypeFacility.getDataTypeClass(tgtType));
-
- assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$
- expectedExpression, helpGetString(func));
- }
-
- // Source = STRING
- @Test public void testStringToChar() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "cast('5' AS character)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Source = Boolean
-
- @Test public void testBooleanToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "cast(1 AS decimal(38,19))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = BYTE
-
- @Test public void testByteToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testByteToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testBigIntegerToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testBigIntegerDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "biginteger", "cast(1 AS decimal(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Source = FLOAT
-
- @Test public void testFloatToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "cast(1.2 AS bigint)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = DOUBLE
-
- @Test public void testDoubleToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "cast(1.2 AS smallint)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = BIGDECIMAL
-
- @Test public void testBigDecimalToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "cast(1.0 AS tinyint)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Source = DATE
-
- @Test public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "to_date('2003-11-01', 'yyyy-mm-dd')"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = TIME
-
- @Test public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "cast(to_date('23:59:59', 'hh:mi:ss') AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- // Source = TIMESTAMP
-
- @Test public void testTimestampToString() throws Exception {
- Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "cast(to_timestamp('2003-11-01 12:05:02.0', 'yyyy-mm-dd hh:mi:ss.fffffffff') AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = LONG
- @Test public void testLongToBigInt() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(5, Long.class), "long", "cast(5 AS bigint)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheTranslation.java (from rev 2981, trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheTranslation.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheTranslation.java 2011-03-09 16:11:50 UTC (rev 2984)
@@ -0,0 +1,157 @@
+/*
+ * 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.intersystemscache;
+
+import static org.junit.Assert.*;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Timestamp;
+import java.util.Arrays;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+import org.teiid.translator.jdbc.intersyscache.InterSystemsCacheExecutionFactory;
+/**
+ */
+public class TestInterSystemsCacheTranslation {
+
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ private static InterSystemsCacheExecutionFactory TRANSLATOR;
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new InterSystemsCacheExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+ }
+
+ public String helpGetString(Expression expr) throws Exception {
+ SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
+ Arrays.asList(
+ srcExpression,
+ LANG_FACTORY.createLiteral(tgtType, String.class)),
+ TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$
+ expectedExpression, helpGetString(func));
+ }
+
+ // Source = STRING
+ @Test public void testStringToChar() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "cast('5' AS character)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = Boolean
+
+ @Test public void testBooleanToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "cast(1 AS decimal(38,19))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = BYTE
+
+ @Test public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testByteToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testBigIntegerToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testBigIntegerDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "biginteger", "cast(1 AS decimal(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = FLOAT
+
+ @Test public void testFloatToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "cast(1.2 AS bigint)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = DOUBLE
+
+ @Test public void testDoubleToShort() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "cast(1.2 AS smallint)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = BIGDECIMAL
+
+ @Test public void testBigDecimalToByte() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "cast(1.0 AS tinyint)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = DATE
+
+ @Test public void testDateToTimestamp() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast(to_date('2003-11-01', 'yyyy-mm-dd') AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = TIME
+
+ @Test public void testTimeToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "cast(to_date('23:59:59', 'hh:mi:ss') AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ // Source = TIMESTAMP
+
+ @Test public void testTimestampToString() throws Exception {
+ Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "cast(to_timestamp('2003-11-01 12:05:02.0', 'yyyy-mm-dd hh:mi:ss.fffffffff') AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = LONG
+ @Test public void testLongToBigInt() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(5, Long.class), "long", "cast(5 AS bigint)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring1() throws Exception {
+ String input = "SELECT intnum/intkey FROM BQT1.SMALLA"; //$NON-NLS-1$
+ String output = "SELECT cast((SmallA.IntNum / SmallA.IntKey) AS integer) FROM SmallA"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input, output,
+ TRANSLATOR);
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheTranslation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years, 10 months
teiid SVN: r2983 - trunk/engine/src/test/java/org/teiid/query/optimizer.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-09 10:16:40 -0500 (Wed, 09 Mar 2011)
New Revision: 2983
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
Log:
TEIID-1503 adding a more direct rewrite test
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-09 14:21:54 UTC (rev 2982)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-09 15:16:40 UTC (rev 2983)
@@ -84,7 +84,6 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.unittest.FakeMetadataStore;
-import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorReport;
@@ -6755,17 +6754,6 @@
null, null, false); //$NON-NLS-1$
}
- /**
- * Test to ensure that we don't create an invalid semijoin query when attempting to convert the subquery to a semijoin
- */
- @Test public void testInvalidGeneratedSemijoinQuery() throws Exception {
- String sql = "SELECT intkey FROM BQT1.SmallA AS A WHERE convert(shortvalue, integer) = (SELECT MAX(convert(shortvalue, integer)) FROM (select * from BQT1.SmallA) AS B WHERE b.intnum = a.intnum) ORDER BY intkey";
- BasicSourceCapabilities bsc = getTypicalCapabilities();
- bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.shortvalue, g_0.intnum, g_0.intkey FROM BQT1.SmallA AS g_0"}, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
- }
-
public static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-03-09 14:21:54 UTC (rev 2982)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-03-09 15:16:40 UTC (rev 2983)
@@ -29,12 +29,14 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.rewriter.TestQueryRewriter;
import org.teiid.query.unittest.FakeMetadataFacade;
import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.SourceSystemFunctions;
@SuppressWarnings("nls")
@@ -833,5 +835,19 @@
0 // UnionAll
});
}
-
+
+ /**
+ * Test to ensure that we don't create an invalid semijoin query when attempting to convert the subquery to a semijoin
+ */
+ @Test public void testInvalidGeneratedSemijoinQuery() throws Exception {
+ String sql = "SELECT intkey FROM BQT1.SmallA AS A WHERE convert(shortvalue, integer) = (SELECT MAX(convert(shortvalue, integer)) FROM (select * from BQT1.SmallA) AS B WHERE b.intnum = a.intnum) ORDER BY intkey";
+ BasicSourceCapabilities bsc = getTypicalCapabilities();
+ bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.shortvalue, g_0.intnum, g_0.intkey FROM BQT1.SmallA AS g_0"}, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
+ }
+
+ @Test public void testInvalidGeneratedSemijoinQuery1() throws Exception {
+ TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 = (Select max(e2) from pm2.g2 where e1 = pm3.g1.e1)", "SELECT e1 FROM pm3.g1, (SELECT MAX(e2) AS MAX, e1 FROM pm2.g2 GROUP BY e1) AS X__1 WHERE (pm3.g1.e1 = X__1.e1) AND (pm3.g1.e2 = X__1.MAX)", FakeMetadataFactory.example4());
+ }
}
13 years, 10 months
teiid SVN: r2982 - in trunk/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-09 09:21:54 -0500 (Wed, 09 Mar 2011)
New Revision: 2982
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
Log:
TEIID-1503 fix for bad semijoin query
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2011-03-08 23:03:13 UTC (rev 2981)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2011-03-09 14:21:54 UTC (rev 2982)
@@ -260,6 +260,7 @@
RelationalPlan originalPlan = (RelationalPlan)plannedResult.query.getProcessorPlan();
Number originalCardinality = originalPlan.getRootNode().getEstimateNodeCardinality();
if (originalCardinality.floatValue() == NewCalculateCostUtil.UNKNOWN_VALUE) {
+ //TODO: this check isn't really accurate - exists and scalarsubqueries will always have cardinality 2/1
//if it's currently unknown, removing criteria won't make it any better
return current;
}
@@ -271,7 +272,7 @@
}
//add an order by, which hopefully will get pushed down
- plannedResult.query.setOrderBy(new OrderBy(plannedResult.rightExpressions));
+ plannedResult.query.setOrderBy(new OrderBy(plannedResult.rightExpressions).clone());
for (OrderByItem item : plannedResult.query.getOrderBy().getOrderByItems()) {
int index = plannedResult.query.getProjectedSymbols().indexOf(item.getSymbol());
item.setExpressionPosition(index);
@@ -481,7 +482,14 @@
}
if (addGroupBy) {
- plannedResult.query.setGroupBy(new GroupBy(plannedResult.rightExpressions));
+ LinkedHashSet<SingleElementSymbol> groupingSymbols = new LinkedHashSet<SingleElementSymbol>();
+ ArrayList<SingleElementSymbol> aggs = new ArrayList<SingleElementSymbol>();
+ for (Expression expr : (List<Expression>)plannedResult.rightExpressions) {
+ AggregateSymbolCollectorVisitor.getAggregates(expr, aggs, groupingSymbols);
+ }
+ if (!groupingSymbols.isEmpty()) {
+ plannedResult.query.setGroupBy((GroupBy) new GroupBy(new ArrayList<SingleElementSymbol>(groupingSymbols)).clone());
+ }
}
HashSet<SingleElementSymbol> projectedSymbols = new HashSet<SingleElementSymbol>();
for (SingleElementSymbol ses : plannedResult.query.getProjectedSymbols()) {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-08 23:03:13 UTC (rev 2981)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-03-09 14:21:54 UTC (rev 2982)
@@ -84,6 +84,7 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorReport;
@@ -6753,6 +6754,17 @@
helpPlan("update pm1.g1 set e1 = 1 where exists (select 1 from pm1.g2)", FakeMetadataFactory.example1Cached(), null, //$NON-NLS-1$
null, null, false); //$NON-NLS-1$
}
+
+ /**
+ * Test to ensure that we don't create an invalid semijoin query when attempting to convert the subquery to a semijoin
+ */
+ @Test public void testInvalidGeneratedSemijoinQuery() throws Exception {
+ String sql = "SELECT intkey FROM BQT1.SmallA AS A WHERE convert(shortvalue, integer) = (SELECT MAX(convert(shortvalue, integer)) FROM (select * from BQT1.SmallA) AS B WHERE b.intnum = a.intnum) ORDER BY intkey";
+ BasicSourceCapabilities bsc = getTypicalCapabilities();
+ bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.shortvalue, g_0.intnum, g_0.intkey FROM BQT1.SmallA AS g_0"}, new DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
+ }
public static final boolean DEBUG = false;
13 years, 10 months
teiid SVN: r2981 - trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-03-08 18:03:13 -0500 (Tue, 08 Mar 2011)
New Revision: 2981
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
Log:
TEIID-1060: adding Translator for intersystems cache database
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-03-08 21:37:53 UTC (rev 2980)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-03-08 23:03:13 UTC (rev 2981)
@@ -106,6 +106,7 @@
supportedFunctions.add(SourceSystemFunctions.CEILING);
supportedFunctions.add(SourceSystemFunctions.CHAR);
supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
supportedFunctions.add(SourceSystemFunctions.FLOOR);
supportedFunctions.add(SourceSystemFunctions.IFNULL);
supportedFunctions.add(SourceSystemFunctions.LCASE);
13 years, 10 months
teiid SVN: r2980 - in trunk: build/kits/jboss-container/teiid-examples/jca and 6 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-03-08 16:37:53 -0500 (Tue, 08 Mar 2011)
New Revision: 2980
Added:
trunk/build/kits/jboss-container/teiid-examples/jca/intersystems-cache-ds.xml
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-1060: adding Translator for intersystems cache database
Added: trunk/build/kits/jboss-container/teiid-examples/jca/intersystems-cache-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/intersystems-cache-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/intersystems-cache-ds.xml 2011-03-08 21:37:53 UTC (rev 2980)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<datasources>
+ <!-- unfortunately I did not see a XA data source for intersys cache -->
+ <!-- copy the cacheDB.jar to the lib directory -->
+ <local-tx-datasource>
+ <jndi-name>cacheDS</jndi-name>
+ <connection-url>jdbc:Cache://localhost:1972/{database}</connection-url>
+ <driver-class>com.intersys.jdbc.CacheDriver</driver-class>
+ <user-name>user</user-name>
+ <password>pass</password>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ </local-tx-datasource>
+</datasources>
Property changes on: trunk/build/kits/jboss-container/teiid-examples/jca/intersystems-cache-ds.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-03-08 20:47:01 UTC (rev 2979)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-03-08 21:37:53 UTC (rev 2980)
@@ -37,6 +37,7 @@
</UL>
<LI><B>ARRAYTABLE</B> - the ARRAYTABLE table function was added to simplify array value extraction into a tabular format.
<LI><B>Ingres</B> - Ingres database translator is now available to use as supported source under Teiid.
+ <LI><B>InterSystems Cache</B> - InterSystems Cache database translator is now available to use as supported source under Teiid.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-03-08 21:37:53 UTC (rev 2980)
@@ -0,0 +1,253 @@
+/*
+ * 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.intersyscache;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Expression;
+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;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+@Translator(name="intersystems-cache", description="A translator for Intersystems Cache Database")
+public class InterSystemsCacheExecutionFactory extends JDBCExecutionFactory {
+
+ private static final String INTER_CACHE = "intersystems-cache"; //$NON-NLS-1$
+ protected ConvertModifier convert = new ConvertModifier();
+
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+ convert.addTypeMapping("character", FunctionModifier.CHAR); //$NON-NLS-1$
+ convert.addTypeMapping("decimal(38,19)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convert.addTypeMapping("decimal(19,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
+ convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addNumericBooleanConversions();
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("nvl")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new ModifiedFunction(SourceSystemFunctions.CONCAT));
+ registerFunctionModifier(SourceSystemFunctions.ACOS, new ModifiedFunction(SourceSystemFunctions.ACOS));
+ registerFunctionModifier(SourceSystemFunctions.ASIN, new ModifiedFunction(SourceSystemFunctions.ASIN));
+ registerFunctionModifier(SourceSystemFunctions.ATAN, new ModifiedFunction(SourceSystemFunctions.ATAN));
+ registerFunctionModifier(SourceSystemFunctions.COS, new ModifiedFunction(SourceSystemFunctions.COS));
+ registerFunctionModifier(SourceSystemFunctions.COT, new ModifiedFunction(SourceSystemFunctions.COT));
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new ModifiedFunction(SourceSystemFunctions.CURDATE));
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new ModifiedFunction(SourceSystemFunctions.CURTIME));
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new ModifiedFunction(SourceSystemFunctions.DAYNAME));
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ModifiedFunction(SourceSystemFunctions.DAYOFMONTH));
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ModifiedFunction(SourceSystemFunctions.DAYOFWEEK));
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ModifiedFunction(SourceSystemFunctions.DAYOFYEAR));
+ registerFunctionModifier(SourceSystemFunctions.EXP, new ModifiedFunction(SourceSystemFunctions.EXP));
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ModifiedFunction(SourceSystemFunctions.HOUR));
+ registerFunctionModifier(SourceSystemFunctions.LOG,new ModifiedFunction(SourceSystemFunctions.LOG));
+ registerFunctionModifier(SourceSystemFunctions.LOG10, new ModifiedFunction(SourceSystemFunctions.LOG10));
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new ModifiedFunction(SourceSystemFunctions.LEFT));
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ModifiedFunction(SourceSystemFunctions.MINUTE));
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ModifiedFunction(SourceSystemFunctions.MONTH));
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new ModifiedFunction(SourceSystemFunctions.MONTHNAME));
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModifiedFunction(SourceSystemFunctions.MOD));
+ registerFunctionModifier(SourceSystemFunctions.NOW, new ModifiedFunction(SourceSystemFunctions.NOW));
+ registerFunctionModifier(SourceSystemFunctions.PI, new ModifiedFunction(SourceSystemFunctions.PI));
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new ModifiedFunction(SourceSystemFunctions.QUARTER));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new ModifiedFunction(SourceSystemFunctions.RIGHT));
+ registerFunctionModifier(SourceSystemFunctions.SIN, new ModifiedFunction(SourceSystemFunctions.SIN));
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ModifiedFunction(SourceSystemFunctions.SECOND));
+ registerFunctionModifier(SourceSystemFunctions.SQRT,new ModifiedFunction(SourceSystemFunctions.SQRT));
+ registerFunctionModifier(SourceSystemFunctions.TAN,new ModifiedFunction(SourceSystemFunctions.TAN));
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new ModifiedFunction(SourceSystemFunctions.TIMESTAMPADD));
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new ModifiedFunction(SourceSystemFunctions.TIMESTAMPDIFF));
+ registerFunctionModifier(SourceSystemFunctions.TRUNCATE,new ModifiedFunction(SourceSystemFunctions.TRUNCATE));
+ registerFunctionModifier(SourceSystemFunctions.WEEK,new ModifiedFunction(SourceSystemFunctions.WEEK));
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ASCII);
+ supportedFunctions.add(SourceSystemFunctions.CEILING);
+ supportedFunctions.add(SourceSystemFunctions.CHAR);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.FLOOR);
+ supportedFunctions.add(SourceSystemFunctions.IFNULL);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.LPAD);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.NULLIF);
+ supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.REPEAT);
+ supportedFunctions.add(SourceSystemFunctions.REPLACE);
+ supportedFunctions.add(SourceSystemFunctions.ROUND);
+ supportedFunctions.add(SourceSystemFunctions.RPAD);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SIGN);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.XMLCONCAT);
+
+ return supportedFunctions;
+ }
+
+ @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$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "to_date('" + formatDateValue(timeValue) + "', 'hh:mi:ss')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "to_timestamp('" + formatDateValue(timestampValue) + "', 'yyyy-mm-dd hh:mi:ss.fffffffff')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.LAST;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ static class ModifiedFunction extends FunctionModifier{
+ String name;
+ ModifiedFunction(String name){
+ this.name = name;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{fn ").append(this.name).append('(');//$NON-NLS-1$
+ List<Expression> params = function.getParameters();
+ if (params != null && !params.isEmpty()) {
+ for (int i = 0; i < params.size(); i++) {
+ sb.append(params.get(0));
+ if (i < (params.size()-1)) {
+ sb.append(',');
+ }
+ }
+ }
+ sb.append(")}");//$NON-NLS-1$
+
+ return Arrays.asList(sb);
+ }
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml 2011-03-08 20:47:01 UTC (rev 2979)
+++ trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml 2011-03-08 21:37:53 UTC (rev 2980)
@@ -304,4 +304,20 @@
<parameter class="java.lang.String">Ingres</parameter>
</constructor>
</bean>
+
+ <!-- InterSystems Cache -->
+ <bean name="translator-intersystems-cache-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-intersystems-cache" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-intersystems-cache" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.jdbc.intersyscache.InterSystemsCacheExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-intersystems-cache</parameter>
+ <parameter class="java.lang.String">InterSystems Cache</parameter>
+ </constructor>
+ </bean>
</deployment>
\ No newline at end of file
Added: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java 2011-03-08 21:37:53 UTC (rev 2980)
@@ -0,0 +1,138 @@
+/*
+ * 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.intersystemscache;
+
+import static org.junit.Assert.*;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Timestamp;
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.intersyscache.InterSystemsCacheExecutionFactory;
+/**
+ */
+public class TestInterSystemsCacheConvertModifier {
+
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ public String helpGetString(Expression expr) throws Exception {
+ InterSystemsCacheExecutionFactory trans = new InterSystemsCacheExecutionFactory();
+ trans.start();
+ SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
+ Arrays.asList(
+ srcExpression,
+ LANG_FACTORY.createLiteral(tgtType, String.class)),
+ TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$
+ expectedExpression, helpGetString(func));
+ }
+
+ // Source = STRING
+ @Test public void testStringToChar() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "cast('5' AS character)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = Boolean
+
+ @Test public void testBooleanToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "cast(1 AS decimal(38,19))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = BYTE
+
+ @Test public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testByteToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testBigIntegerToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testBigIntegerDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "biginteger", "cast(1 AS decimal(19,0))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = FLOAT
+
+ @Test public void testFloatToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "cast(1.2 AS bigint)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = DOUBLE
+
+ @Test public void testDoubleToShort() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "cast(1.2 AS smallint)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = BIGDECIMAL
+
+ @Test public void testBigDecimalToByte() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "cast(1.0 AS tinyint)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = DATE
+
+ @Test public void testDateToTimestamp() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "to_date('2003-11-01', 'yyyy-mm-dd')"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = TIME
+
+ @Test public void testTimeToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "cast(to_date('23:59:59', 'hh:mi:ss') AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ // Source = TIMESTAMP
+
+ @Test public void testTimestampToString() throws Exception {
+ Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "cast(to_timestamp('2003-11-01 12:05:02.0', 'yyyy-mm-dd hh:mi:ss.fffffffff') AS varchar(4000))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = LONG
+ @Test public void testLongToBigInt() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(5, Long.class), "long", "cast(5 AS bigint)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/intersystemscache/TestInterSystemsCacheConvertModifier.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-03-08 20:47:01 UTC (rev 2979)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-03-08 21:37:53 UTC (rev 2980)
@@ -247,6 +247,11 @@
</listitem>
<listitem>
<para>
+ <emphasis>intersystems-cache</emphasis> - for use with Intersystems Cache Object database (only relational aspect of it)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<emphasis>informix</emphasis> - for use with any version.
</para>
</listitem>
13 years, 10 months
teiid SVN: r2979 - trunk/documentation/admin-guide/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-03-08 15:47:01 -0500 (Tue, 08 Mar 2011)
New Revision: 2979
Modified:
trunk/documentation/admin-guide/src/main/docbook/en-US/content/performance.xml
Log:
TEIID-1502 update to the performance doc to explain the thread settings and more on the max reserve columns
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/performance.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/performance.xml 2011-03-08 20:39:59 UTC (rev 2978)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/performance.xml 2011-03-08 20:47:01 UTC (rev 2979)
@@ -35,6 +35,15 @@
If you are processing large (100s of MBs) of highly unique datasets
through Teiid, you should consider <link linkend="system_properties">disabling value caching</link> since it
will not significantly reduce memory consumption.
+ <note>
+ <para>The formula (average bytes per value)*(processor batch size)*(maxReserveBatchColumns) approximates the amount of
+ reserve memory used by the BufferManager. The defaults with an assumed value (8 bytes in 32 bit mode) for bytes per column
+ works out to be: 8 bytes * 512 * 16384 = 64MB. Memory consumption can be significantly more or less
+ depending upon actual column values and whether value caching is enabled. The 8 bytes per column includes row/batch list overhead and
+ represents the Java type memory foot print (e.g. java.lang.Integer not a raw 4 byte integer).
+ The nominal target of 64MB per 1 gigabyte of may be too low based upon the particulars of your usage. Raising the maxReserveBatchColumns
+ value too high though may result in out of memory errors.</para>
+ </note>
</para>
<para>
Each intermediate result buffer, temporary LOB, and temporary table
@@ -78,11 +87,15 @@
JDBC, ODBC, and Admin access.
Typical installations will not need to
adjust the default thread and buffer
- size settings. At this time, ODBC
+ size settings.
+ All JDBC socket operations are non-blocking, so setting the number of maxThreads
+ higher than the maximum effective parallelism of the machine will not result in greater performance. The default value 0 for JDBC socket threads will
+ set the max to the number of available processors.
+ At this time, ODBC
queries are executed synchronously from the socket thread.
Simultaneous long-running queries may exhaust the available threads.
Consider increasing the default max threads (15) for ODBC if you
- expect a higher concurrent load of long-running queries.</para>
+ expect a higher concurrent load of long-running ODBC client queries.</para>
</section>
<section>
<title>LOBs</title>
13 years, 10 months