Author: shawkins
Date: 2011-07-30 08:31:35 -0400 (Sat, 30 Jul 2011)
New Revision: 3350
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
Log:
TEIID-1690 fix for npe in xquery processing
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2011-07-28
21:06:28 UTC (rev 3349)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2011-07-30
12:31:35 UTC (rev 3350)
@@ -242,8 +242,11 @@
public SaxonXQueryExpression clone() {
SaxonXQueryExpression clone = new SaxonXQueryExpression();
clone.xQuery = xQuery;
+ clone.xQueryString = xQueryString;
clone.config = config;
clone.contextRoot = contextRoot;
+ clone.namespaceMap = namespaceMap;
+ clone.streamingPathFilter = streamingPathFilter;
return clone;
}
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-07-28
21:06:28 UTC (rev 3349)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-07-30
12:31:35 UTC (rev 3350)
@@ -38,10 +38,16 @@
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.core.types.BlobImpl;
import org.teiid.core.types.BlobType;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.InputStreamFactory;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
@@ -187,6 +193,32 @@
process(sql, expected);
}
+ @Test public void testXmlTableInView() throws Exception {
+ String sql = "select * from g1"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ Arrays.asList(null, "first"),
+ Arrays.asList("attr", "second"),
+ };
+
+ MetadataStore metadataStore = new MetadataStore();
+ // Create models
+ Schema vm1 = RealMetadataFactory.createVirtualModel("vm1", metadataStore);
//$NON-NLS-1$
+
+ QueryNode vm1g1n1 = new QueryNode("select * from xmltable('/a/b'
passing convert('<a><b>first</b><b
x=\"attr\">second</b></a>', xml) columns x string path
'@x', val string path '/.') as x"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vm1g1 = RealMetadataFactory.createVirtualGroup("g1", vm1, vm1g1n1);
//$NON-NLS-1$
+
+ RealMetadataFactory.createElements(vm1g1,
+ new String[] { "x", "val" },
//$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING });
+ // Create the facade from the store
+ TransformationMetadata metadata =
RealMetadataFactory.createTransformationMetadata(metadataStore, "example");
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new
DefaultCapabilitiesFinder(), createCommandContext());
+
+ helpProcess(plan, createCommandContext(), dataManager, expected);
+ }
+
@Test public void testXmlTableDefaultAndParent() throws Exception {
String sql = "select * from xmltable('/a/b' passing
convert('<a y=\"rev\"><b>first</b><b
x=\"1\">second</b></a>', xml) columns x integer default -1
path '@x' , val string path '../@y') as x"; //$NON-NLS-1$
Show replies by date