Author: shawkins
Date: 2010-06-04 21:22:19 -0400 (Fri, 04 Jun 2010)
New Revision: 2182
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1108 fix for npe in costing with a table function
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-06-04
21:51:29 UTC (rev 2181)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-06-05
01:22:19 UTC (rev 2182)
@@ -834,8 +834,11 @@
PlanNode sourceNode = FrameUtil.findOriginatingNode(current, new
HashSet<GroupSymbol>(Arrays.asList(elementSymbol.getGroupSymbol())));
if (sourceNode != null) {
SymbolMap symbolMap =
(SymbolMap)sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
- Expression expr = symbolMap.getMappedExpression(elementSymbol);
- ndv = getNDV(ElementCollectorVisitor.getElements(expr, true),
sourceNode.getFirstChild(), cardinality, metadata);
+ //symbolMap will be null for table functions
+ if (symbolMap != null) {
+ Expression expr = symbolMap.getMappedExpression(elementSymbol);
+ ndv = getNDV(ElementCollectorVisitor.getElements(expr, true),
sourceNode.getFirstChild(), cardinality, metadata);
+ }
}
}
if (ndv == UNKNOWN_VALUE) {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-06-04
21:51:29 UTC (rev 2181)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-06-05
01:22:19 UTC (rev 2182)
@@ -166,6 +166,16 @@
process(sql, expected);
}
+ @Test public void testTextTableCriteria() throws Exception {
+ String sql = "select x.* from texttable('a' || ',' ||
'1' COLUMNS x string, y integer) x where x.y = 1"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", 1),
+ };
+
+ process(sql, expected);
+ }
+
public static void process(String sql, List[] expectedResults) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
Show replies by date