[teiid-commits] teiid SVN: r4224 - in trunk/engine/src: main/java/org/teiid/query/processor/relational and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Sun Jul 8 08:06:57 EDT 2012


Author: shawkins
Date: 2012-07-08 08:06:55 -0400 (Sun, 08 Jul 2012)
New Revision: 4224

Added:
   trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceNode.java
Modified:
   trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
   trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
Log:
TEIID-2094 fix for projection issue

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java	2012-07-05 20:35:48 UTC (rev 4223)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java	2012-07-08 12:06:55 UTC (rev 4224)
@@ -449,18 +449,6 @@
 				break;
 
 			case NodeConstants.Types.SOURCE:
-			    SymbolMap symbolMap = (SymbolMap) node.getProperty(NodeConstants.Info.SYMBOL_MAP);
-				if(symbolMap != null) {
-					PlanNode child = node.getLastChild();
-
-                    if (node.getParent().getType() != NodeConstants.Types.PROJECT || node.getParent().getProperty(NodeConstants.Info.INTO_GROUP) == null) {
-                    	if (child.getType() == NodeConstants.Types.PROJECT) {
-                    		//update the project cols based upon the original output
-                    		child.setProperty(NodeConstants.Info.PROJECT_COLS, child.getProperty(NodeConstants.Info.OUTPUT_COLS));
-                    	}
-                        child.setProperty(NodeConstants.Info.OUTPUT_COLS, node.getProperty(NodeConstants.Info.OUTPUT_COLS));
-                    }
-				}
 				Object source = node.getProperty(NodeConstants.Info.TABLE_FUNCTION);
 				if (source instanceof XMLTable) {
 					XMLTable xt = (XMLTable)source;
@@ -497,6 +485,24 @@
 					processNode = atn;
 					break;
 				}
+			    SymbolMap symbolMap = (SymbolMap) node.getProperty(NodeConstants.Info.SYMBOL_MAP);
+				if(symbolMap != null) {
+					PlanNode child = node.getLastChild();
+
+                    if (node.getParent().getType() == NodeConstants.Types.PROJECT 
+                    		&& node.getParent().getProperty(NodeConstants.Info.INTO_GROUP) != null) {
+                    	return null;
+                    }
+                	if (child.getType() == NodeConstants.Types.PROJECT) {
+                		//update the project cols based upon the original output
+                		child.setProperty(NodeConstants.Info.PROJECT_COLS, child.getProperty(NodeConstants.Info.OUTPUT_COLS));
+                        child.setProperty(NodeConstants.Info.OUTPUT_COLS, node.getProperty(NodeConstants.Info.OUTPUT_COLS));
+                        return null;
+                	}
+                	//TODO: vet the other node types for how they project, specifically select/join/windowfunctionproject nodes cannot have their elements modified
+                    processNode = new SourceNode(getID());
+                    break;
+				}
 				return null;
     		case NodeConstants.Types.SET_OP:
                 Operation setOp = (Operation) node.getProperty(NodeConstants.Info.SET_OPERATION);

Added: trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceNode.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceNode.java	2012-07-08 12:06:55 UTC (rev 4224)
@@ -0,0 +1,50 @@
+/*
+ * 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.query.processor.relational;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
+public class SourceNode extends RelationalNode {
+	protected SourceNode() {
+	}
+	
+	public SourceNode(int id) {
+		super(id);
+	}
+	
+	@Override
+	protected TupleBatch nextBatchDirect() throws BlockedException,
+			TeiidComponentException, TeiidProcessingException {
+		return getChildren()[0].nextBatch();
+	}
+
+	@Override
+	public Object clone() {
+		SourceNode clone = new SourceNode();
+		clone.copy(this, clone);
+		return clone;
+	}
+}
\ No newline at end of file


Property changes on: trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceNode.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java	2012-07-05 20:35:48 UTC (rev 4223)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java	2012-07-08 12:06:55 UTC (rev 4224)
@@ -97,7 +97,47 @@
        // Run query
        TestProcessor.helpProcess(plan, dataManager, expected);
    }
+    
+    @Test public void testDependentView() { 
+        String sql = "SELECT v.e1 FROM (select distinct e1 from pm1.g1) as v, pm2.g1 WHERE v.e1=pm2.g1.e1 order by v.e1 option makedep v"; //$NON-NLS-1$
+        
+        List[] expected = new List[] { 
+            Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+            Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+            Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+            Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+            Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+        };    
+        
+        FakeDataManager dataManager = new FakeDataManager();
+        TestProcessor.sampleData1(dataManager);
+        
+        ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
 
+        TestProcessor.helpProcess(plan, dataManager, expected);
+    }
+    
+    /**
+     * specific test for TEIID-2094
+     */
+    @Test public void testDependentView1() { 
+        String sql = "SELECT v.e1 FROM (select distinct e1 from pm1.g1) as v, pm2.g1 WHERE v.e1=pm2.g1.e1 order by v.e1 option makedep v"; //$NON-NLS-1$
+        
+        List[] expected = new List[] { 
+            Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+        };    
+        
+        HardcodedDataManager dataManager = new HardcodedDataManager(RealMetadataFactory.example1Cached());
+        dataManager.addData("SELECT g_0.e1 AS c_0 FROM g1 AS g_0 ORDER BY c_0", new List<?>[] {Arrays.asList("a")});
+        dataManager.addData("SELECT v_0.c_0 FROM (SELECT DISTINCT g_0.e1 AS c_0 FROM g1 AS g_0) AS v_0 WHERE v_0.c_0 = 'a'", new List<?>[] {Arrays.asList("a")});
+        
+        BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+        caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+        ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps));
+
+        TestProcessor.helpProcess(plan, dataManager, expected);
+    }
+
     /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
     @Test public void testMultiCritDepJoin2() { 
        // Create query 



More information about the teiid-commits mailing list