Skip to content

Commit

Permalink
TEIID-5551 using the full subtree regardless of type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Nov 27, 2018
1 parent a39293a commit 01748b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.types.XMLTranslator;
import org.teiid.core.types.XMLType;
Expand Down Expand Up @@ -76,7 +75,6 @@
import net.sf.saxon.om.SequenceIterator;
import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.pattern.AnyNodeTest;
import net.sf.saxon.pattern.NodeKindTest;
import net.sf.saxon.query.QueryResult;
import net.sf.saxon.query.StaticQueryContext;
import net.sf.saxon.query.XQueryExpression;
Expand Down Expand Up @@ -364,7 +362,7 @@ private PathMapRoot projectColumns(PathMapRoot parentRoot, List<XMLTable.XMLColu
}
//special case for handling '.', which the pathmap logic doesn't consider as a root
if (internalExpression instanceof ContextItemExpression) {
addReturnedArcs(xmlColumn, finalNode);
addReturnedArcs(finalNode);
}
if (subContextRoot == null) {
continue;
Expand All @@ -378,7 +376,7 @@ private PathMapRoot projectColumns(PathMapRoot parentRoot, List<XMLTable.XMLColu
HashSet<PathMapNode> subFinalNodes = new HashSet<PathMapNode>();
getReturnableNodes(subContextRoot, subFinalNodes);
for (PathMapNode subNode : subFinalNodes) {
addReturnedArcs(xmlColumn, subNode);
addReturnedArcs(subNode);
}
}
//Workaround to rerun the reduction algorithm - by making a copy of the old version
Expand Down Expand Up @@ -462,14 +460,8 @@ private boolean validateColumnForStreaming(AnalysisRecord record,
return true;
}

private void addReturnedArcs(XMLColumn xmlColumn, PathMapNode subNode) {
if (xmlColumn.getSymbol().getType() == DataTypeManager.DefaultDataClasses.XML) {
subNode.createArc(AxisInfo.DESCENDANT_OR_SELF, AnyNodeTest.getInstance());
} else {
//this may not always be needed, but it doesn't harm anything
subNode.createArc(AxisInfo.CHILD, NodeKindTest.TEXT);
subNode.setAtomized();
}
private void addReturnedArcs(PathMapNode subNode) {
subNode.createArc(AxisInfo.DESCENDANT_OR_SELF, AnyNodeTest.getInstance());
}

private void getReturnableNodes(PathMapNode node, HashSet<PathMapNode> finalNodes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,17 @@ public static BlobType blobFromFile(final String file) {
helpProcess(plan, cc, dataManager, expected);
}

@Test public void testPathSubtree() throws Exception {
String sql = "Select * From XmlTable ('/root' Passing cast('<root><def><test1>10</test1><test1>20</test1></def><abc>22</abc></root>' as xml) \n" +
"Columns b string Path 'def')xx";

List<?>[] expected = new List<?>[] {
Arrays.asList("1020"),
};

process(sql, expected);
}

@Test public void testRootFunction() throws Exception {
String xml = "'<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" type=\"decimal\">\n" +
" <waitSeconds xsi:type=\"decimal\">13</waitSeconds>\n" +
Expand Down

0 comments on commit 01748b9

Please sign in to comment.