teiid SVN: r2678 - in branches/7.1.x/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc/oracle and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-25 12:31:58 -0400 (Mon, 25 Oct 2010)
New Revision: 2678
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
Log:
TEIID-1320 update to the oracle timestamp to string logic
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-10-22 21:42:45 UTC (rev 2677)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-10-25 16:31:58 UTC (rev 2678)
@@ -150,11 +150,9 @@
//if column and type is date, just use date format
Expression ex = function.getParameters().get(0);
String format = TIMESTAMP_FORMAT;
- if (ex instanceof ColumnReference) {
- if ("date".equals(((ColumnReference)ex).getMetadataObject().getNativeType())) { //$NON-NLS-1$
- format = DATETIME_FORMAT;
- }
- } else if (!(ex instanceof Function) && !(ex instanceof Literal)) {
+ if (ex instanceof ColumnReference && "date".equalsIgnoreCase(((ColumnReference)ex).getMetadataObject().getNativeType())) { //$NON-NLS-1$
+ format = DATETIME_FORMAT;
+ } else if (!(ex instanceof Literal) && !(ex instanceof Function)) {
//this isn't needed in every case, but it's simpler than inspecting the expression more
ex = ConvertModifier.createConvertFunction(getLanguageFactory(), function.getParameters().get(0), TypeFacility.RUNTIME_NAMES.TIMESTAMP);
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-22 21:42:45 UTC (rev 2677)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-10-25 16:31:58 UTC (rev 2678)
@@ -34,6 +34,7 @@
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
+import org.teiid.metadata.Column;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.SQLConversionVisitor;
@@ -41,6 +42,7 @@
/**
*/
+@SuppressWarnings("nls")
public class TestOracleConvertModifier {
private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
@@ -500,6 +502,13 @@
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 10000000);
helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts '2003-11-01 12:05:02.01'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ @Test public void testTimestampToString1() throws Exception {
+ Column column = new Column();
+ column.setNativeType("DATE");
+ column.setNameInSource("dt");
+ helpTest(LANG_FACTORY.createColumnReference("dt", LANG_FACTORY.createNamedTable("x", null, null), column, Timestamp.class), "string", "to_char(x.dt, 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
@Test public void testTimestampToDate() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 10000000);
14 years, 2 months
teiid SVN: r2677 - in branches/7.1.x/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc/postgresql and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-22 17:42:45 -0400 (Fri, 22 Oct 2010)
New Revision: 2677
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
Log:
TEIID-1319 updating the format string for timestamp to string
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-10-22 21:40:32 UTC (rev 2676)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-10-22 21:42:45 UTC (rev 2677)
@@ -140,7 +140,7 @@
});
convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD HH24:MI:SS.UF")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD HH24:MI:SS.US")); //$NON-NLS-1$ //$NON-NLS-2$
convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-10-22 21:40:32 UTC (rev 2676)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-10-22 21:42:45 UTC (rev 2677)
@@ -158,7 +158,7 @@
}
@Test public void testConversion13() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT to_char(cast(PARTS.PART_WEIGHT AS timestamp), 'YYYY-MM-DD HH24:MI:SS.UF') FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT to_char(cast(PARTS.PART_WEIGHT AS timestamp), 'YYYY-MM-DD HH24:MI:SS.US') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
14 years, 2 months
teiid SVN: r2676 - in branches/7.1.x/engine/src: test/java/org/teiid/query/optimizer and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-22 17:40:32 -0400 (Fri, 22 Oct 2010)
New Revision: 2676
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java
branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
Log:
TEIID-1317 ensuring that limit expressions get evaluated prior to pushdown
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-10-22 16:24:31 UTC (rev 2675)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-10-22 21:40:32 UTC (rev 2676)
@@ -39,6 +39,7 @@
import org.teiid.query.optimizer.relational.RuleStack;
import org.teiid.query.optimizer.relational.plantree.NodeConstants;
import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.processor.ProcessorPlan;
@@ -378,24 +379,20 @@
private void processLimit(PlanNode node,
QueryCommand query, QueryMetadataInterface metadata) {
+
Expression limit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
- if (limit != null) {
- if (query.getLimit() != null) {
- Expression oldlimit = query.getLimit().getRowLimit();
- query.getLimit().setRowLimit(RulePushLimit.getMinValue(limit, oldlimit));
- } else {
- query.setLimit(new Limit(null, limit));
- }
- }
Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
- if (offset != null) {
- if (query.getLimit() != null) {
- Expression oldoffset = query.getLimit().getOffset();
- query.getLimit().setOffset(RulePushLimit.getSum(offset, oldoffset, metadata.getFunctionLibrary()));
- } else {
- query.setLimit(new Limit(offset, null));
- }
+
+ PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
+ Expression childLimit = null;
+ Expression childOffset = null;
+ if (query.getLimit() != null) {
+ childLimit = query.getLimit().getRowLimit();
+ childOffset = query.getLimit().getOffset();
}
+ RulePushLimit.combineLimits(limitNode, metadata, limit, offset, childLimit, childOffset);
+
+ query.setLimit(new Limit((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT)));
}
/**
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java 2010-10-22 16:24:31 UTC (rev 2675)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java 2010-10-22 21:40:32 UTC (rev 2676)
@@ -26,11 +26,16 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
@@ -47,7 +52,9 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.util.CommandContext;
+import org.teiid.translator.SourceSystemFunctions;
/**
@@ -116,18 +123,19 @@
return false;
}
- switch (child.getType()) {
+ Expression parentLimit = (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
+ Expression parentOffset = (Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
+ switch (child.getType()) {
case NodeConstants.Types.TUPLE_LIMIT:
{
+
//combine the limits
- Expression minLimit = getMinValue((Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT), (Expression)child.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT));
- Expression offSet = getSum((Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), (Expression)child.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT), metadata.getFunctionLibrary());
+ Expression childLimit = (Expression)child.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
+ Expression childOffset = (Expression)child.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
+
+ combineLimits(limitNode, metadata, parentLimit, parentOffset, childLimit, childOffset);
NodeEditor.removeChildNode(limitNode, child);
-
- limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, minLimit);
- limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, offSet);
-
limitNodes.remove(child);
return canPushLimit(rootNode, limitNode, limitNodes, metadata, capFinder);
@@ -141,9 +149,7 @@
List<PlanNode> grandChildren = new LinkedList<PlanNode>(child.getChildren());
for (PlanNode grandChild : grandChildren) {
PlanNode newLimit = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
- Expression limit = (Expression)limitNode.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
- Expression offset = (Expression)limitNode.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
- newLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset, metadata.getFunctionLibrary()));
+ newLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, op(SourceSystemFunctions.ADD_OP, parentLimit, parentOffset, metadata.getFunctionLibrary()));
grandChild.addAsParent(newLimit);
limitNodes.add(newLimit);
}
@@ -171,6 +177,28 @@
}
}
}
+
+ static void combineLimits(PlanNode limitNode,
+ QueryMetadataInterface metadata, Expression parentLimit,
+ Expression parentOffset, Expression childLimit,
+ Expression childOffset) {
+ Expression minLimit = null;
+ Expression offSet = null;
+
+ if (childLimit == null) {
+ minLimit = parentLimit;
+ offSet = op(SourceSystemFunctions.ADD_OP, childOffset, parentOffset, metadata.getFunctionLibrary());
+ } else {
+ minLimit = getMinValue(parentLimit, op(SourceSystemFunctions.SUBTRACT_OP, childLimit, parentOffset, metadata.getFunctionLibrary()));
+ offSet = childOffset;
+ if (offSet == null) {
+ offSet = parentOffset;
+ }
+ }
+
+ limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, minLimit);
+ limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, offSet);
+ }
static PlanNode raiseAccessOverLimit(PlanNode rootNode,
PlanNode accessNode,
@@ -206,7 +234,7 @@
// since we're pushing underneath the offset, we want enough rows to satisfy both the limit and the row offset
- pushedLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, getSum(limit, offset, metadata.getFunctionLibrary()));
+ pushedLimit.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, op(SourceSystemFunctions.ADD_OP, limit, offset, metadata.getFunctionLibrary()));
if (accessNode.getChildCount() == 0) {
accessNode.addFirstChild(pushedLimit);
@@ -221,11 +249,7 @@
return RuleRaiseAccess.performRaise(rootNode, accessNode, parentNode);
}
- /**
- * @param limitNode
- * @param child
- */
- static Expression getSum(Expression expr1, Expression expr2, FunctionLibrary functionLibrary) {
+ static Expression op(String op, Expression expr1, Expression expr2, FunctionLibrary functionLibrary) {
if (expr1 == null) {
return expr2;
}
@@ -233,15 +257,29 @@
return expr1;
}
- Function newExpr = new Function("+", new Expression[] {expr1, expr2}); //$NON-NLS-1$
- newExpr.setFunctionDescriptor(functionLibrary.findFunction("+", new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER})); //$NON-NLS-1$
+ Function newExpr = new Function(op, new Expression[] {expr1, expr2});
+ newExpr.setFunctionDescriptor(functionLibrary.findFunction(op, new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER}));
newExpr.setType(newExpr.getFunctionDescriptor().getReturnType());
+ return evaluateIfPossible(newExpr);
+ }
+
+ private static Expression evaluateIfPossible(Expression newExpr) {
+ if (EvaluatableVisitor.isFullyEvaluatable(newExpr, true)) {
+ try {
+ return new Constant(Evaluator.evaluate(newExpr), newExpr.getType());
+ } catch (TeiidException e) {
+ throw new TeiidRuntimeException(e, "Unexpected Exception"); //$NON-NLS-1$
+ }
+ }
return newExpr;
- }
+ }
/**
* @param limitNode
* @param child
+ * @throws TeiidComponentException
+ * @throws BlockedException
+ * @throws ExpressionEvaluationException
*/
static Expression getMinValue(Expression expr1, Expression expr2) {
if (expr1 == null) {
@@ -254,7 +292,8 @@
Criteria crit = new CompareCriteria(expr1, CompareCriteria.LT, expr2);
SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new Object[] {crit}), Arrays.asList(new Object[] {expr1}));
sce.setElseExpression(expr2);
- return sce;
+ sce.setType(expr1.getType());
+ return evaluateIfPossible(sce);
}
/**
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2010-10-22 16:24:31 UTC (rev 2675)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2010-10-22 21:40:32 UTC (rev 2676)
@@ -268,7 +268,7 @@
String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 150" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -535,7 +535,7 @@
String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 50, 100";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT PM1.g2.e1 AS c_0, PM1.g2.e2 AS c_1, PM1.g2.e3 AS c_2, PM1.g2.e4 AS c_3 FROM PM1.g2 LIMIT (100 + 50)", "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$ //$NON-NLS-2$
+ "SELECT PM1.g2.e1 AS c_0, PM1.g2.e2 AS c_1, PM1.g2.e3 AS c_2, PM1.g2.e4 AS c_3 FROM PM1.g2 LIMIT 150", "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT 150" //$NON-NLS-1$ //$NON-NLS-2$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -603,7 +603,7 @@
String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT CASE WHEN (75 + (20 + 10)) < (100 + 10) THEN (75 + (20 + 10)) ELSE (100 + 10) END" //$NON-NLS-1$
+ "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT 105" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -636,9 +636,9 @@
// pm1 model supports order by
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
+ String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 40, 75";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (20 + 10), CASE WHEN 75 < 100 THEN 75 ELSE 100 END" //$NON-NLS-1$
+ "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT 10, 60" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-10-22 16:24:31 UTC (rev 2675)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-10-22 21:40:32 UTC (rev 2676)
@@ -68,7 +68,6 @@
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -7338,7 +7337,7 @@
FakeDataManager dataManager = new FakeDataManager();
sampleData2(dataManager);
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 6"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
helpProcess(plan, dataManager, expected);
}
14 years, 2 months
teiid SVN: r2675 - in branches/7.1.x/engine/src/main/java/org/teiid/query: processor/relational and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-22 12:24:31 -0400 (Fri, 22 Oct 2010)
New Revision: 2675
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/eval/Evaluator.java
branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
branches/7.1.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
Log:
ensuring that xquery evaluation closes all sources it creates.
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-10-22 14:45:09 UTC (rev 2674)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-10-22 16:24:31 UTC (rev 2675)
@@ -41,7 +41,6 @@
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import net.sf.saxon.om.SequenceIterator;
import net.sf.saxon.trans.XPathException;
import org.teiid.api.exception.query.ExpressionEvaluationException;
@@ -110,6 +109,7 @@
import org.teiid.query.sql.util.ValueIteratorSource;
import org.teiid.query.util.CommandContext;
import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
+import org.teiid.query.xquery.saxon.SaxonXQueryExpression.Result;
import org.teiid.translator.WSConnection.Util;
public class Evaluator {
@@ -761,13 +761,18 @@
if (xmlQuery.getEmptyOnEmpty() != null) {
emptyOnEmpty = xmlQuery.getEmptyOnEmpty();
}
+ Result result = null;
try {
- SequenceIterator iter = evaluateXQuery(xmlQuery.getXQueryExpression(), xmlQuery.getPassing(), tuple);
- return xmlQuery.getXQueryExpression().createXMLType(iter, this.context.getBufferManager(), emptyOnEmpty);
+ result = evaluateXQuery(xmlQuery.getXQueryExpression(), xmlQuery.getPassing(), tuple);
+ return xmlQuery.getXQueryExpression().createXMLType(result.iter, this.context.getBufferManager(), emptyOnEmpty);
} catch (TeiidProcessingException e) {
throw new FunctionExecutionException(e, QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage())); //$NON-NLS-1$
} catch (XPathException e) {
throw new FunctionExecutionException(e, QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (result != null) {
+ result.close();
+ }
}
}
@@ -837,7 +842,7 @@
}
}
- public SequenceIterator evaluateXQuery(SaxonXQueryExpression xquery, List<DerivedColumn> cols, List<?> tuple)
+ public Result evaluateXQuery(SaxonXQueryExpression xquery, List<DerivedColumn> cols, List<?> tuple)
throws BlockedException, TeiidComponentException, TeiidProcessingException {
HashMap<String, Object> parameters = new HashMap<String, Object>();
Object contextItem = null;
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2010-10-22 14:45:09 UTC (rev 2674)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2010-10-22 16:24:31 UTC (rev 2675)
@@ -50,6 +50,7 @@
import org.teiid.query.function.FunctionDescriptor;
import org.teiid.query.sql.lang.XMLTable;
import org.teiid.query.sql.lang.XMLTable.XMLColumn;
+import org.teiid.query.xquery.saxon.SaxonXQueryExpression.Result;
/**
* Handles xml table processing.
@@ -69,7 +70,7 @@
private XMLTable table;
private List<XMLColumn> projectedColumns;
- private SequenceIterator result;
+ private Result result;
private int rowCount = 0;
private Item item;
@@ -130,7 +131,7 @@
TeiidComponentException, TeiidProcessingException {
if (item == null) {
try {
- item = result.next();
+ item = result.iter.next();
} catch (XPathException e) {
throw new TeiidProcessingException(e, QueryPlugin.Util.getString("XMLTableNode.error", e.getMessage())); //$NON-NLS-1$
}
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2010-10-22 14:45:09 UTC (rev 2674)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2010-10-22 16:24:31 UTC (rev 2675)
@@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -88,10 +89,27 @@
import org.teiid.query.sql.symbol.DerivedColumn;
import org.teiid.query.sql.symbol.XMLNamespaces;
import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
+import org.teiid.translator.WSConnection.Util;
@SuppressWarnings("serial")
public class SaxonXQueryExpression {
+ public static class Result {
+ public SequenceIterator iter;
+ public List<Source> sources = new LinkedList<Source>();
+
+ public void close() {
+ for (Source source : sources) {
+ Util.closeSource(source);
+ }
+ if (iter != null) {
+ iter.close();
+ }
+ sources.clear();
+ iter = null;
+ }
+ }
+
private static final Expression DUMMY_EXPRESSION = new Expression() {
@Override
public ItemType getItemType(TypeHierarchy th) {
@@ -133,7 +151,7 @@
private net.sf.saxon.query.XQueryExpression xQuery;
private Configuration config = new Configuration();
private PathMapRoot contextRoot;
-
+
public SaxonXQueryExpression(String xQueryString, XMLNamespaces namespaces, List<DerivedColumn> passing, List<XMLTable.XMLColumn> columns)
throws QueryResolverException {
config.setErrorListener(ERROR_LISTENER);
@@ -354,47 +372,55 @@
xmlColumn.setPathExpression(exp);
}
}
-
- public SequenceIterator evaluateXQuery(Object context, Map<String, Object> parameterValues) throws TeiidProcessingException {
+
+ public Result evaluateXQuery(Object context, Map<String, Object> parameterValues) throws TeiidProcessingException {
DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
-
+
+ Result result = new Result();
try {
- for (Map.Entry<String, Object> entry : parameterValues.entrySet()) {
- Object value = entry.getValue();
- if(value instanceof SQLXML) {
- value = XMLSystemFunctions.convertToSource(value);
- } else if (value instanceof java.util.Date) {
- java.util.Date d = (java.util.Date)value;
- value = XMLSystemFunctions.convertToAtomicValue(value);
+ try {
+ for (Map.Entry<String, Object> entry : parameterValues.entrySet()) {
+ Object value = entry.getValue();
+ if(value instanceof SQLXML) {
+ value = XMLSystemFunctions.convertToSource(value);
+ result.sources.add((Source)value);
+ } else if (value instanceof java.util.Date) {
+ value = XMLSystemFunctions.convertToAtomicValue(value);
+ }
+ dynamicContext.setParameter(entry.getKey(), value);
+ }
+ } catch (TransformerException e) {
+ throw new TeiidProcessingException(e);
+ }
+ if (context != null) {
+ Source source = XMLSystemFunctions.convertToSource(context);
+ result.sources.add(source);
+ if (contextRoot != null) {
+ //create our own filter as this logic is not provided in the free saxon
+ ProxyReceiver filter = new PathMapFilter(contextRoot);
+ AugmentedSource sourceInput = AugmentedSource.makeAugmentedSource(source);
+ sourceInput.addFilter(filter);
+ source = sourceInput;
}
- dynamicContext.setParameter(entry.getKey(), value);
+ DocumentInfo doc;
+ try {
+ doc = config.buildDocument(source);
+ } catch (XPathException e) {
+ throw new TeiidProcessingException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_context")); //$NON-NLS-1$
+ }
+ dynamicContext.setContextItem(doc);
}
- } catch (TransformerException e) {
- throw new TeiidProcessingException(e);
+ try {
+ result.iter = xQuery.iterator(dynamicContext);
+ return result;
+ } catch (TransformerException e) {
+ throw new TeiidProcessingException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_xquery")); //$NON-NLS-1$
+ }
+ } finally {
+ if (result.iter == null) {
+ result.close();
+ }
}
-
- if (context != null) {
- Source source = XMLSystemFunctions.convertToSource(context);
- if (contextRoot != null) {
- //create our own filter as this logic is not provided in the free saxon
- ProxyReceiver filter = new PathMapFilter(contextRoot);
- AugmentedSource sourceInput = AugmentedSource.makeAugmentedSource(source);
- sourceInput.addFilter(filter);
- source = sourceInput;
- }
- DocumentInfo doc;
- try {
- doc = config.buildDocument(source);
- } catch (XPathException e) {
- throw new TeiidProcessingException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_context")); //$NON-NLS-1$
- }
- dynamicContext.setContextItem(doc);
- }
- try {
- return xQuery.iterator(dynamicContext);
- } catch (TransformerException e) {
- throw new TeiidProcessingException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_xquery")); //$NON-NLS-1$
- }
}
public XMLType createXMLType(final SequenceIterator iter, BufferManager bufferManager, boolean emptyOnEmpty) throws XPathException, TeiidComponentException, TeiidProcessingException {
14 years, 2 months
teiid SVN: r2674 - in branches/7.1.x: engine/src/main/java/org/teiid/query/metadata and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-22 10:45:09 -0400 (Fri, 22 Oct 2010)
New Revision: 2674
Modified:
branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
Log:
TEIID-1315 fix for parent relative paths for getting schemas. also minor corrections to release notes and an i18n message
Modified: branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-10-21 21:05:20 UTC (rev 2673)
+++ branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-10-22 14:45:09 UTC (rev 2674)
@@ -53,7 +53,7 @@
<li>Model visibility no longer restricts access to tables and procedures. Setting visible to false will only hide entries from system tables. Data roles should be used to restrict data access.
<li>Admin API "getWorkManagerStats" methods renamed to "getWorkerPoolStats". Also, "setRuntimeProperty" and "getProcesses" methods were removed.
<li>By default the "ENV" system function is now turned off. To enable it, edit the teiid-jboss-beans.xml configuration file.
- <li>The use of VARIABLES.ROWCOUNT is now reserved. Use a different
+ <li>The use of VARIABLES.ROWCOUNT is now reserved.
<li>Direct assignments in virtual procedures using stored procedures (e.g. var = EXEC foo()) are only valid if the procedure has a return parameter and no result set.
</ul>
<h4>from 7.0</h4>
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-10-21 21:05:20 UTC (rev 2673)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-10-22 14:45:09 UTC (rev 2674)
@@ -783,10 +783,22 @@
path = path.replace(File.separatorChar, '/');
}
for (String string : schemaPaths) {
- SQLXMLImpl schema = getVDBResourceAsSQLXML(string);
-
+ String parentPath = path;
+ boolean relative = false;
+ while (string.startsWith("../")) { //$NON-NLS-1$
+ relative = true;
+ string = string.substring(3);
+ parentPath = new File(parentPath).getParent();
+ }
+ SQLXMLImpl schema = null;
+ if (!relative) {
+ schema = getVDBResourceAsSQLXML(string);
+ }
if (schema == null) {
- schema = getVDBResourceAsSQLXML(path + '/' + string);
+ if (!parentPath.endsWith("/")) { //$NON-NLS-1$
+ parentPath += "/"; //$NON-NLS-1$
+ }
+ schema = getVDBResourceAsSQLXML(parentPath + string);
}
if (schema == null) {
Modified: branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-21 21:05:20 UTC (rev 2673)
+++ branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-22 14:45:09 UTC (rev 2674)
@@ -871,4 +871,4 @@
RequestWorkItem.cache_nondeterministic=Caching command '{0}'' at a session level, but less deterministic functions were evaluated.
not_found_cache=Results not found in cache
failed_to_unwrap_connection=Failed to unwrap the source connection.
-connection_factory_not_found=Failed to the Connection Factory with JNDI name {0}. Please check the name for spelling or deploy the Connection Factory with specified name.
\ No newline at end of file
+connection_factory_not_found=Failed to find the Connection Factory with JNDI name {0}. Please check the name or deploy the Connection Factory with specified name.
\ No newline at end of file
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java 2010-10-21 21:05:20 UTC (rev 2673)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java 2010-10-22 14:45:09 UTC (rev 2674)
@@ -31,7 +31,9 @@
import java.util.Map;
import java.util.Properties;
+import org.jboss.virtual.VirtualFile;
import org.junit.Test;
+import org.mockito.Mockito;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
@@ -42,6 +44,7 @@
import org.teiid.metadata.Table;
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.translator.TranslatorException;
@@ -71,6 +74,14 @@
MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
mf1.addProcedure("y"); //$NON-NLS-1$
+
+ Table table = mf1.addTable("doc");
+ table.setSchemaPaths(Arrays.asList("../../x.xsd"));
+ table.setResourcePath("/a/b/doc.xmi");
+
+ HashMap<String, Resource> resources = new HashMap<String, Resource>();
+ resources.put("/x.xsd", new Resource(Mockito.mock(VirtualFile.class), true));
+
CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
VDBMetaData vdb = new VDBMetaData();
@@ -79,8 +90,9 @@
vdb.addModel(buildModel("x"));
vdb.addModel(buildModel("x1"));
+ vdb.addModel(buildModel("y"));
- return new TransformationMetadata(vdb, cms, null, null, FakeMetadataFactory.SFM.getSystemFunctions());
+ return new TransformationMetadata(vdb, cms, resources, null, FakeMetadataFactory.SFM.getSystemFunctions());
}
ModelMetaData buildModel(String name) {
@@ -131,4 +143,9 @@
tm.getElementID("x.FoO.coL");
}
+ @Test public void testRelativeSchemas() throws Exception {
+ TransformationMetadata tm = exampleTransformationMetadata();
+ assertEquals(1, tm.getXMLSchemas(tm.getGroupID("x1.doc")).size());
+ }
+
}
14 years, 2 months
teiid SVN: r2673 - in branches/7.1.x: engine/src/test/java/org/teiid/query/processor and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-21 17:05:20 -0400 (Thu, 21 Oct 2010)
New Revision: 2673
Added:
branches/7.1.x/engine/src/test/resources/encoding.xml
Modified:
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
Log:
TEIID-1316 fix for picking up the encoding correctly from the document
Modified: branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
===================================================================
--- branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-10-21 18:49:17 UTC (rev 2672)
+++ branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-10-21 21:05:20 UTC (rev 2673)
@@ -89,14 +89,17 @@
if (cs != null) {
return cs;
}
+ String enc = null;
try {
- String enc = XMLType.getEncoding(this.getBinaryStream());
- if (enc != null) {
- setEncoding(enc);
- }
+ enc = XMLType.getEncoding(this.getBinaryStream());
} catch (SQLException e) {
}
- return Streamable.CHARSET;
+ if (enc != null) {
+ setEncoding(enc);
+ } else {
+ super.setCharset(Streamable.CHARSET);
+ }
+ return super.getCharset();
}
@SuppressWarnings("unchecked")
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-10-21 18:49:17 UTC (rev 2672)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-10-21 21:05:20 UTC (rev 2673)
@@ -25,6 +25,8 @@
import static org.teiid.query.processor.TestProcessor.*;
import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.List;
@@ -349,6 +351,16 @@
processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(blobFromFile("udf.xmi")));
}
+ @Test public void testXmlParseBlobWithEncoding() throws Exception {
+ String sql = "select xmlparse(document cast(? as blob)) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(ObjectConverterUtil.convertToString(new InputStreamReader(new FileInputStream(UnitTestUtil.getTestDataFile("encoding.xml")), Charset.forName("ISO-8859-1")))),
+ };
+
+ processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(blobFromFile("encoding.xml")));
+ }
+
@Test public void testXmlTableTypes() throws Exception {
String sql = "select * from xmltable('/a' passing xmlparse(document '<a>2000-01-01T01:01:00.2-06:00</a>') columns x timestamp path 'xs:dateTime(./text())', y timestamp path '.') as x"; //$NON-NLS-1$
Timestamp ts = TimestampUtil.createTimestamp(100, 0, 1, 1, 1, 0, 200000000);
Added: branches/7.1.x/engine/src/test/resources/encoding.xml
===================================================================
--- branches/7.1.x/engine/src/test/resources/encoding.xml (rev 0)
+++ branches/7.1.x/engine/src/test/resources/encoding.xml 2010-10-21 21:05:20 UTC (rev 2673)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<name>���</name>
Property changes on: branches/7.1.x/engine/src/test/resources/encoding.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 2 months
teiid SVN: r2672 - branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-21 14:49:17 -0400 (Thu, 21 Oct 2010)
New Revision: 2672
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
Log:
TEIID-1314 fix to address bigdecimal truncation with jConnect 6
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-10-21 18:43:02 UTC (rev 2671)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-10-21 18:49:17 UTC (rev 2672)
@@ -817,6 +817,11 @@
stmt.setTimestamp(i,(java.sql.Timestamp)param, getDatabaseCalendar());
return;
}
+ //not all drivers handle the setObject call with BigDecimal correctly (namely jConnect 6.05)
+ if (TypeFacility.RUNTIME_TYPES.BIG_DECIMAL.equals(paramType)) {
+ stmt.setBigDecimal(i, (BigDecimal)param);
+ return;
+ }
//convert these the following to jdbc safe values
if (TypeFacility.RUNTIME_TYPES.BIG_INTEGER.equals(paramType)) {
param = new BigDecimal((BigInteger)param);
@@ -824,7 +829,8 @@
param = new Double(((Float)param).doubleValue());
} else if (TypeFacility.RUNTIME_TYPES.CHAR.equals(paramType)) {
param = ((Character)param).toString();
- }
+ }
+
stmt.setObject(i, param, type);
}
14 years, 2 months
teiid SVN: r2671 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-10-21 14:43:02 -0400 (Thu, 21 Oct 2010)
New Revision: 2671
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1313: avoid the duplicate row the batch boundaries with nested table join
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java 2010-10-21 18:18:56 UTC (rev 2670)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java 2010-10-21 18:43:02 UTC (rev 2671)
@@ -126,12 +126,14 @@
List<?> outputTuple = outputTuple(this.leftSource.getCurrentTuple(), this.rightSource.getCurrentTuple());
- if (this.joinNode.matchesCriteria(outputTuple)) {
- joinNode.addBatchRow(outputTuple);
- outerMatched = true;
- }
+ boolean matches = this.joinNode.matchesCriteria(outputTuple);
rightSource.saveNext();
+
+ if (matches) {
+ outerMatched = true;
+ joinNode.addBatchRow(outputTuple);
+ }
}
if (!outerMatched && this.joinNode.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-10-21 18:18:56 UTC (rev 2670)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-10-21 18:43:02 UTC (rev 2671)
@@ -198,7 +198,19 @@
process(sql, expected);
}
- public static void process(String sql, List[] expectedResults) throws Exception {
+ @Test public void testTextTableMultiBatch() throws Exception {
+ String sql = "select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string) x";
+
+ List[] expected = new List[] {
+ Arrays.asList("c"),
+ Arrays.asList("1"),
+ Arrays.asList("true"),
+ };
+
+ process(sql, expected);
+ }
+
+ public static void process(String sql, List[] expectedResults) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
14 years, 2 months
teiid SVN: r2670 - in branches/7.1.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-10-21 14:18:56 -0400 (Thu, 21 Oct 2010)
New Revision: 2670
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1313: avoid the duplicate row the batch boundaries with nested table join
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java 2010-10-21 15:33:12 UTC (rev 2669)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/processor/relational/NestedTableJoinStrategy.java 2010-10-21 18:18:56 UTC (rev 2670)
@@ -126,12 +126,14 @@
List<?> outputTuple = outputTuple(this.leftSource.getCurrentTuple(), this.rightSource.getCurrentTuple());
- if (this.joinNode.matchesCriteria(outputTuple)) {
- joinNode.addBatchRow(outputTuple);
- outerMatched = true;
- }
+ boolean matches = this.joinNode.matchesCriteria(outputTuple);
rightSource.saveNext();
+
+ if (matches) {
+ outerMatched = true;
+ joinNode.addBatchRow(outputTuple);
+ }
}
if (!outerMatched && this.joinNode.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-10-21 15:33:12 UTC (rev 2669)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-10-21 18:18:56 UTC (rev 2670)
@@ -198,7 +198,19 @@
process(sql, expected);
}
- public static void process(String sql, List[] expectedResults) throws Exception {
+ @Test public void testTextTableMultiBatch() throws Exception {
+ String sql = "select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string) x";
+
+ List[] expected = new List[] {
+ Arrays.asList("c"),
+ Arrays.asList("1"),
+ Arrays.asList("true"),
+ };
+
+ process(sql, expected);
+ }
+
+ public static void process(String sql, List[] expectedResults) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
14 years, 2 months
teiid SVN: r2669 - in branches/7.1.x/engine/src: test/java/org/teiid/query/resolver and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-10-21 11:33:12 -0400 (Thu, 21 Oct 2010)
New Revision: 2669
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
Log:
TEIID-1312 fix for procedure defaults in string form
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-10-21 15:08:08 UTC (rev 2668)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-10-21 15:33:12 UTC (rev 2669)
@@ -908,36 +908,36 @@
append(SPACE);
append(obj.getProcedureName());
append("("); //$NON-NLS-1$
- List params = obj.getInputParameters();
- if (params != null) {
- Iterator iter = params.iterator();
- while (iter.hasNext()) {
- SPParameter param = (SPParameter)iter.next();
+ boolean first = true;
+ for (SPParameter param : obj.getInputParameters()) {
+ if (param.isUsingDefault()) {
+ continue;
+ }
+ if (first) {
+ first = false;
+ } else {
+ append(", "); //$NON-NLS-1$
+ }
+ if (obj.displayNamedParameters()) {
+ append(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
+ append(" => "); //$NON-NLS-1$
+ }
- if (obj.displayNamedParameters()) {
- append(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
- append(" => "); //$NON-NLS-1$
- }
-
- if (param.getExpression() == null) {
- if (param.getName() != null) {
- outputDisplayName(obj.getParamFullName(param));
- } else {
- append("?"); //$NON-NLS-1$
- }
+ if (param.getExpression() == null) {
+ if (param.getName() != null) {
+ outputDisplayName(obj.getParamFullName(param));
} else {
- boolean addParens = !obj.displayNamedParameters() && param.getExpression() instanceof CompareCriteria;
- if (addParens) {
- append(Tokens.LPAREN);
- }
- visitNode(param.getExpression());
- if (addParens) {
- append(Tokens.RPAREN);
- }
+ append("?"); //$NON-NLS-1$
}
- if (iter.hasNext()) {
- append(", "); //$NON-NLS-1$
+ } else {
+ boolean addParens = !obj.displayNamedParameters() && param.getExpression() instanceof CompareCriteria;
+ if (addParens) {
+ append(Tokens.LPAREN);
}
+ visitNode(param.getExpression());
+ if (addParens) {
+ append(Tokens.RPAREN);
+ }
}
}
append(")"); //$NON-NLS-1$
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-10-21 15:08:08 UTC (rev 2668)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-10-21 15:33:12 UTC (rev 2669)
@@ -350,7 +350,7 @@
* @param expectedParameterExpressions
* @since 4.3
*/
- private void helpResolveExec(String sql, Object[] expectedParameterExpressions) {
+ private StoredProcedure helpResolveExec(String sql, Object[] expectedParameterExpressions) {
StoredProcedure proc = (StoredProcedure)helpResolve(sql);
@@ -375,6 +375,8 @@
assertEquals(expectedParameterExpressions[i], param.getExpression());
}
}
+
+ return proc;
}
@@ -1093,7 +1095,8 @@
/** test omitting a required parameter that has a default value */
@Test public void testExecNamedParamsOmitRequiredParamWithDefaultValue() {
Object[] expectedParameterExpressions = new Object[] {new Constant("xyz"), new Constant(new Integer(666)), new Constant("YYZ")};//$NON-NLS-1$ //$NON-NLS-2$
- helpResolveExec("EXEC pm1.sq3b(\"in\" = 'xyz', in2 = 666)", expectedParameterExpressions);//$NON-NLS-1$
+ StoredProcedure sp = helpResolveExec("EXEC pm1.sq3b(\"in\" = 'xyz', in2 = 666)", expectedParameterExpressions);//$NON-NLS-1$
+ assertEquals("EXEC pm1.sq3b(\"in\" => 'xyz', in2 => 666)", sp.toString());
}
@Test public void testExecNamedParamsOptionalParamWithDefaults() {
14 years, 2 months