Author: shawkins
Date: 2011-11-09 05:23:35 -0500 (Wed, 09 Nov 2011)
New Revision: 3621
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
Log:
TEIID-1818 fix for prepared context item type
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2011-11-08
19:02:22 UTC (rev 3620)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2011-11-09
10:23:35 UTC (rev 3621)
@@ -343,6 +343,7 @@
visitNodes(obj.getPassing());
postTableFunctionReference(obj, saved);
try {
+ ResolverUtil.setDesiredType(obj.getPassing(), obj);
obj.compileXqueryExpression();
for (XMLTable.XMLColumn column : obj.getColumns()) {
if (column.getDefaultExpression() == null) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-11-08
19:02:22 UTC (rev 3620)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2011-11-09
10:23:35 UTC (rev 3621)
@@ -74,6 +74,7 @@
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.AliasSymbol;
import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.DerivedColumn;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
@@ -288,6 +289,15 @@
return conversion;
}
+
+ public static void setDesiredType(List<DerivedColumn> passing, LanguageObject
obj) throws QueryResolverException {
+ for (DerivedColumn dc : passing) {
+ if (dc.getAlias() == null) {
+ ResolverUtil.setDesiredType(dc.getExpression(),
DataTypeManager.DefaultDataClasses.XML, obj);
+ break;
+ }
+ }
+ }
/**
* Utility to set the type of an expression if it is a Reference and has a null
type.
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-11-08
19:02:22 UTC (rev 3620)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2011-11-09
10:23:35 UTC (rev 3621)
@@ -402,6 +402,7 @@
@Override
public void visit(XMLQuery obj) {
try {
+ ResolverUtil.setDesiredType(obj.getPassing(), obj);
obj.compileXqueryExpression();
} catch (QueryResolverException e) {
handleException(e);
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-11-08
19:02:22 UTC (rev 3620)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-11-09
10:23:35 UTC (rev 3621)
@@ -94,6 +94,8 @@
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.XMLQuery;
+import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.CommandCollectorVisitor;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
@@ -2986,5 +2988,15 @@
@Test public void testTrim1() {
helpResolve("select trim('x' from e1) from pm1.g1");
}
+
+ @Test public void testXmlTableWithParam() {
+ helpResolve("select * from xmltable('/a' passing ?) as x");
+ }
+
+ @Test public void testXmlQueryWithParam() {
+ Query q = (Query)helpResolve("select xmlquery('/a' passing ?)");
+ XMLQuery ex = (XMLQuery) SymbolMap.getExpression((Expression)
q.getSelect().getSymbols().get(0));
+ assertEquals(DataTypeManager.DefaultDataClasses.XML,
ex.getPassing().get(0).getExpression().getType());
+ }
}
\ No newline at end of file
Show replies by date