Author: shawkins
Date: 2011-12-02 06:42:20 -0500 (Fri, 02 Dec 2011)
New Revision: 3716
Modified:
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/api/src/main/java/org/teiid/translator/TypeFacility.java
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java
Log:
TEIID-1859 TEIID-3 adding new capabilities to control convert pushdown and restrict
comparisons
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-12-01 21:54:57
UTC (rev 3715)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-12-02 11:42:20
UTC (rev 3716)
@@ -666,6 +666,7 @@
/**
* Get list of all supported function names. Arithmetic functions have names like
* "+".
+ * @see SourceSystemFunctions
* @since 3.1 SP3
*/
public List<String> getSupportedFunctions() {
@@ -917,5 +918,28 @@
public boolean supportsLikeRegex() {
return false;
}
+
+ /**
+ * Used for fine grained control of convert/cast pushdown. If {@link
#getSupportedFunctions()} contains
+ * {@link SourceSystemFunctions#CONVERT}, then all of the default Teiid pushdown
conversions are supported.
+ * So typically this method will be implemented when {@link #getSupportedFunctions()}
does not contain
+ * {@link SourceSystemFunctions#CONVERT}. The engine will does not care about an
unnecessary conversion
+ * where fromType == toType.
+ * @param fromType @see RUNTIME_CODES
+ * @param toType @see RUNTIME_CODES
+ * @return true if the given conversion is supported.
+ * @since 8.0
+ */
+ public boolean supportsConvert(int fromType, int toType) {
+ return false;
+ }
+
+ /**
+ * @return true if only Literal comparisons (equality, ordered, like, etc.) are
supported for non-join conditions.
+ * @since 8.0
+ */
+ public boolean supportsOnlyLiteralComparison() {
+ return false;
+ }
}
Modified: trunk/api/src/main/java/org/teiid/translator/TypeFacility.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/TypeFacility.java 2011-12-01 21:54:57 UTC
(rev 3715)
+++ trunk/api/src/main/java/org/teiid/translator/TypeFacility.java 2011-12-02 11:42:20 UTC
(rev 3716)
@@ -41,6 +41,28 @@
/**
*/
public class TypeFacility {
+
+ public static final class RUNTIME_CODES {
+ public static final int STRING = DataTypeManager.DefaultTypeCodes.STRING;
+ public static final int CHAR = DataTypeManager.DefaultTypeCodes.CHAR;
+ public static final int BOOLEAN = DataTypeManager.DefaultTypeCodes.BOOLEAN;
+ public static final int BYTE = DataTypeManager.DefaultTypeCodes.BYTE;
+ public static final int SHORT = DataTypeManager.DefaultTypeCodes.SHORT;
+ public static final int INTEGER = DataTypeManager.DefaultTypeCodes.INTEGER;
+ public static final int LONG = DataTypeManager.DefaultTypeCodes.LONG;
+ public static final int BIG_INTEGER = DataTypeManager.DefaultTypeCodes.BIGINTEGER;
+ public static final int FLOAT = DataTypeManager.DefaultTypeCodes.FLOAT;
+ public static final int DOUBLE = DataTypeManager.DefaultTypeCodes.DOUBLE;
+ public static final int BIG_DECIMAL = DataTypeManager.DefaultTypeCodes.BIGDECIMAL;
+ public static final int DATE = DataTypeManager.DefaultTypeCodes.DATE;
+ public static final int TIME = DataTypeManager.DefaultTypeCodes.TIME;
+ public static final int TIMESTAMP = DataTypeManager.DefaultTypeCodes.TIMESTAMP;
+ public static final int OBJECT = DataTypeManager.DefaultTypeCodes.OBJECT;
+ public static final int BLOB = DataTypeManager.DefaultTypeCodes.BLOB;
+ public static final int CLOB = DataTypeManager.DefaultTypeCodes.CLOB;
+ public static final int XML = DataTypeManager.DefaultTypeCodes.XML;
+ public static final int NULL = DataTypeManager.DefaultTypeCodes.NULL;
+ }
public interface RUNTIME_TYPES {
public static final Class<String> STRING =
DataTypeManager.DefaultDataClasses.STRING;
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-12-01 21:54:57 UTC (rev
3715)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-12-02 11:42:20 UTC (rev
3716)
@@ -27,6 +27,8 @@
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
<LI><B>CallableStatement Named Parameters</B> - you can now use
CallableStatement named parameter get/set methods.
+ <LI><B>New Translator capabilities</B> - translators may indicate
which convert functions they support and restrict non-join comparisons
+ to only literals.
</UL>
<h2><a name="Compatibility">Compatibility
Issues</a></h2>
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-12-01
21:54:57 UTC (rev 3715)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -234,6 +234,8 @@
public static final int NULL = 18;
}
+ public static int MAX_TYPE_CODE = DefaultTypeCodes.NULL;
+
private static final Map<Class<?>, Integer> typeMap = new
LinkedHashMap<Class<?>, Integer>(64);
private static final List<Class<?>> typeList;
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -222,7 +222,6 @@
assertEquals("hello", DataTypeManager.transformValue(new Foo(),
DataTypeManager.DefaultDataClasses.STRING)); //$NON-NLS-1$
}
- @SuppressWarnings("unchecked")
@Test public void testObjectArrayToObject() throws Exception {
Object[] value = {1,2};
assertArrayEquals(value, (Object[])DataTypeManager.transformValue(value,
value.getClass(), DataTypeManager.DefaultDataClasses.OBJECT));
Modified:
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
---
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -172,5 +172,10 @@
public boolean supportsIsNullCriteria() {
return true;
}
-
+
+ @Override
+ public boolean supportsOnlyLiteralComparison() {
+ return true;
+ }
+
}
Modified:
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-12-02
11:42:20 UTC (rev 3716)
@@ -1061,6 +1061,30 @@
</row>
<row>
<entry>
+ <para>OnlyLiteralComparison</para>
+ </entry>
+ <entry>
+ <para></para>
+ </entry>
+ <entry>
+ <para>Translator if only Literal comparisons (equality, ordered,
like, etc.) are supported for non-join conditions.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Convert(int fromType, int toType)</para>
+ </entry>
+ <entry>
+ <para></para>
+ </entry>
+ <entry>
+ <para>Used for fine grained control of convert/cast pushdown. If
<code>ExecutionFactory.getSupportedFunctions()</code> contains
<code>SourceSystemFunctions.CONVERT</code>, then all of the default Teiid
pushdown conversions are supported.
+ So typically this method will be implemented when
<code>ExecutionFactory.getSupportedFunctions()</code> contains
<code>SourceSystemFunctions.CONVERT</code>. See
<code>TypeFacility.RUNTIME_CODES</code> for the possible type codes.
+ The engine will does not care about an unnecessary conversion where fromType ==
toType.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>OrderBy</para>
</entry>
<entry>
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.FunctionMethod;
@@ -109,7 +110,17 @@
tgtCaps.setCapabilitySupport(Capability.CRITERIA_SIMILAR,
srcCaps.supportsSimilarTo());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_REGEX,
srcCaps.supportsLikeRegex());
setSupports(connectorID, tgtCaps, Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES,
srcCaps.supportsWindowDistinctAggregates(), Capability.ELEMENTARY_OLAP,
Capability.QUERY_AGGREGATES_DISTINCT);
+ tgtCaps.setCapabilitySupport(Capability.CRITERIA_ONLY_LITERAL_COMPARE,
srcCaps.supportsOnlyLiteralComparison());
+ //TODO: as more types are added it may make more sense to just delegate calls to
the executionfactory
+ for (int i = 0; i <= DataTypeManager.MAX_TYPE_CODE; i++) {
+ for (int j = 0; j <= DataTypeManager.MAX_TYPE_CODE; j++) {
+ if (i != j) {
+ tgtCaps.setSupportsConvert(i, j, srcCaps.supportsConvert(i, j));
+ }
+ }
+ }
+
List<String> functions = srcCaps.getSupportedFunctions();
if(functions != null && functions.size() > 0) {
Iterator<String> iter = functions.iterator();
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -23,8 +23,14 @@
package org.teiid.query.optimizer.capabilities;
import java.io.Serializable;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.DataTypeManager.DefaultTypeCodes;
+import org.teiid.translator.SourceSystemFunctions;
+
/**
*/
public class BasicSourceCapabilities implements SourceCapabilities, Serializable {
@@ -35,6 +41,7 @@
private Map<Capability, Boolean> capabilityMap = new HashMap<Capability,
Boolean>();
private Map<String, Boolean> functionMap = new TreeMap<String,
Boolean>(String.CASE_INSENSITIVE_ORDER);
private Map<Capability, Object> propertyMap = new HashMap<Capability,
Object>();
+ private boolean[][] converts = new boolean[DataTypeManager.MAX_TYPE_CODE +
1][DataTypeManager.MAX_TYPE_CODE + 1];
/**
* Construct a basic capabilities object.
@@ -61,7 +68,17 @@
}
}
- public void setFunctionSupport(String function, boolean supports) {
+ public void setFunctionSupport(String function, boolean supports) {
+ if (SourceSystemFunctions.CONVERT.equalsIgnoreCase(function)) {
+ for (int i = 0; i < converts.length; i++) {
+ if (i == DefaultTypeCodes.OBJECT || i == DefaultTypeCodes.CLOB || i ==
DefaultTypeCodes.XML) {
+ continue;
+ }
+ for (int j = 0; j < converts.length; j++) {
+ converts[i][j] = j != DefaultTypeCodes.CLOB && j !=
DefaultTypeCodes.XML;
+ }
+ }
+ }
functionMap.put(function, Boolean.valueOf(supports));
}
@@ -95,4 +112,13 @@
return this.propertyMap.get(propertyName);
}
+ @Override
+ public boolean supportsConvert(int sourceType, int targetType) {
+ return converts[sourceType][targetType];
+ }
+
+ public void setSupportsConvert(int sourceType, int targetType, boolean value) {
+ this.converts[sourceType][targetType] = value;
+ }
+
}
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -157,6 +157,8 @@
* @since 4.0
*/
CRITERIA_QUANTIFIED_ALL,
+
+ CRITERIA_ONLY_LITERAL_COMPARE,
/**
* Support indicates connector accepts ORDER BY clause
*
@@ -227,7 +229,7 @@
*
* @since 3.1 SP2
*/
- QUERY_AGGREGATES_DISTINCT("AggregatesDistinct"),
+ QUERY_AGGREGATES_DISTINCT("AggregatesDistinct"), //$NON-NLS-1$
/**
* Support indicates connector can accept scalar subqueries in the SELECT, WHERE,
and HAVING clauses
*
@@ -389,4 +391,12 @@
* @since 4.4
*/
public Object getSourceProperty(Capability propertyName);
+
+ /**
+ *
+ * @param sourceType
+ * @param targetType
+ * @return
+ */
+ public boolean supportsConvert(int sourceType, int targetType);
}
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -42,7 +42,6 @@
import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
@@ -224,15 +223,23 @@
if (metadata.isVirtualModel(modelID)){
return false;
}
+
+ SourceCapabilities caps = getCapabilities(modelID, metadata, capFinder);
+ if (FunctionLibrary.isConvert(function)) {
+ Class<?> fromType = function.getArg(0).getType();
+ Class<?> targetType = function.getType();
+ if (fromType == targetType) {
+ return true; //this should be removed in rewrite
+ }
+ return caps.supportsConvert(DataTypeManager.getTypeCode(fromType),
DataTypeManager.getTypeCode(targetType));
+ }
//capabilities check is only valid for non-schema scoped functions
//technically the other functions are scoped to SYS or their function model, but
that's
//not formally part of their metadata yet
Schema schema = function.getFunctionDescriptor().getMethod().getParent();
if (schema == null) {
// Find capabilities
- SourceCapabilities caps = getCapabilities(modelID, metadata, capFinder);
-
if (!caps.supportsFunction(function.getFunctionDescriptor().getName())) {
return false;
}
@@ -240,22 +247,6 @@
return false; //not the right schema
}
- //special check to ensure that special conversions are not pushed down (this can
be removed after we support type based function pushdown)
- if (FunctionLibrary.isConvert(function)) {
- Class<?> fromType = function.getArg(0).getType();
- //object or clob to anything cannot be pushed down
- if (DataTypeManager.DefaultDataClasses.OBJECT.equals(fromType)
- || DataTypeManager.DefaultDataClasses.CLOB.equals(fromType)
- || DataTypeManager.DefaultDataClasses.XML.equals(fromType))
{
- return false;
- }
- String targetType = (String)((Constant)function.getArg(1)).getValue();
- if (DataTypeManager.DefaultDataTypes.CLOB.equalsIgnoreCase(targetType)
- ||
DataTypeManager.DefaultDataTypes.XML.equalsIgnoreCase(targetType)) {
- return false;
- }
- }
-
return true;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -23,6 +23,7 @@
package org.teiid.query.optimizer.relational.rules;
import java.util.Arrays;
+import java.util.Collection;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.TeiidComponentException;
@@ -41,39 +42,9 @@
import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.lang.AbstractCompareCriteria;
-import org.teiid.query.sql.lang.AbstractSetCriteria;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.DependentSetCriteria;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
-import org.teiid.query.sql.lang.OrderByItem;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.QueryCommand;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.lang.SubqueryCompareCriteria;
-import org.teiid.query.sql.lang.SubqueryContainer;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.navigator.PostOrderNavigator;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.CaseExpression;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.QueryString;
-import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.TextLine;
-import org.teiid.query.sql.symbol.WindowFunction;
-import org.teiid.query.sql.symbol.XMLAttributes;
-import org.teiid.query.sql.symbol.XMLElement;
-import org.teiid.query.sql.symbol.XMLForest;
-import org.teiid.query.sql.symbol.XMLNamespaces;
-import org.teiid.query.sql.symbol.XMLParse;
-import org.teiid.query.sql.symbol.XMLQuery;
-import org.teiid.query.sql.symbol.XMLSerialize;
+import org.teiid.query.sql.symbol.*;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
@@ -95,6 +66,7 @@
// Output state
private TeiidComponentException exception;
private boolean valid = true;
+ private boolean isJoin;
/**
* @param iterator
@@ -215,7 +187,20 @@
public void visit(CompareCriteria obj) {
checkCompareCriteria(obj);
+ checkLiteralComparison(obj, Arrays.asList(obj.getRightExpression()));
}
+
+ private void checkLiteralComparison(LanguageObject obj, Collection<? extends
LanguageObject> toCheck) {
+ if (isJoin || !this.caps.supportsCapability(Capability.CRITERIA_ONLY_LITERAL_COMPARE))
{
+ return;
+ }
+ for (LanguageObject languageObject : toCheck) {
+ if (!EvaluatableVisitor.willBecomeConstant(languageObject, true)) {
+ markInvalid(obj, "Non-literal comparison not supported by source.");
//$NON-NLS-1$
+ return;
+ }
+ }
+ }
public void checkCompareCriteria(AbstractCompareCriteria obj) {
boolean negated = false;
@@ -341,6 +326,8 @@
} catch(TeiidComponentException e) {
handleException(e);
}
+
+ checkLiteralComparison(obj, Arrays.asList(obj.getRightExpression()));
}
public void visit(NotCriteria obj) {
@@ -371,6 +358,7 @@
} catch(TeiidComponentException e) {
handleException(e);
}
+ checkLiteralComparison(crit, crit.getValues());
}
/**
@@ -640,6 +628,10 @@
}
public static boolean canPushLanguageObject(LanguageObject obj, Object modelID,
QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord
analysisRecord) throws QueryMetadataException, TeiidComponentException {
+ return canPushLanguageObject(obj, modelID, metadata, capFinder, analysisRecord,
false);
+ }
+
+ public static boolean canPushLanguageObject(LanguageObject obj, Object modelID,
QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord
analysisRecord, boolean isJoin) throws QueryMetadataException, TeiidComponentException {
if(obj == null) {
return true;
}
@@ -657,6 +649,7 @@
}
CriteriaCapabilityValidatorVisitor visitor = new
CriteriaCapabilityValidatorVisitor(modelID, metadata, capFinder, caps);
+ visitor.isJoin = isJoin;
PostOrderNavigator.doVisit(obj, visitor);
if(visitor.getException() != null) {
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -685,7 +685,7 @@
static boolean isSupportedJoinCriteria(SupportedJoinCriteria sjc, Criteria crit,
Object accessModelID,
QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord
record)
throws QueryMetadataException, TeiidComponentException {
- if(!CriteriaCapabilityValidatorVisitor.canPushLanguageObject(crit, accessModelID,
metadata, capFinder, record) ) {
+ if(!CriteriaCapabilityValidatorVisitor.canPushLanguageObject(crit, accessModelID,
metadata, capFinder, record, true) ) {
return false;
}
if (sjc == SupportedJoinCriteria.ANY) {
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -26,13 +26,14 @@
import java.util.Collection;
import java.util.List;
+import junit.framework.TestCase;
+
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.optimizer.QueryOptimizer;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -47,16 +48,15 @@
import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorReport;
-import junit.framework.TestCase;
-
/**
* @since 4.2
*/
@@ -73,7 +73,7 @@
Command command = QueryParser.getQueryParser().parseCommand(sql[i]);
QueryResolver.resolveCommand(command, md);
ValidatorReport repo = Validator.validate(command, md);
- Collection failures = new ArrayList();
+ Collection<LanguageObject> failures = new
ArrayList<LanguageObject>();
repo.collectInvalidObjects(failures);
if (failures.size() > 0){
fail("Exception during validation (" + repo); //$NON-NLS-1$
@@ -222,6 +222,10 @@
public boolean supportsFunction(String functionName) {return false;}
// since 4.4
public Object getSourceProperty(Capability propertyName) {return null;}
+ @Override
+ public boolean supportsConvert(int sourceType, int targetType) {
+ return false;
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-12-01
21:54:57 UTC (rev 3715)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -39,6 +39,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.DataTypeManager.DefaultTypeCodes;
import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.Schema;
import org.teiid.metadata.Table;
@@ -117,7 +118,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.CRITERIA_BETWEEN, true);
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
caps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
@@ -6534,6 +6535,60 @@
});
}
+ @Test public void testNonJoinComparison() throws Exception {
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_ONLY_LITERAL_COMPARE, true);
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT intkey from bqt1.smalla
where intkey = intnum", //$NON-NLS-1$
+ RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT bqt1.smalla.intkey,
bqt1.smalla.intnum FROM bqt1.smalla"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testConvertSignature() throws Exception {
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setSupportsConvert(DefaultTypeCodes.INTEGER, DefaultTypeCodes.STRING, true);
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1 from pm1.g1 where e1
= e2 and e1 = e3", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new
DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e3 FROM pm1.g1
WHERE pm1.g1.e1 = pm1.g1.e2"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
public static final boolean DEBUG = false;
}
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java 2011-12-01
21:54:57 UTC (rev 3715)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java 2011-12-02
11:42:20 UTC (rev 3716)
@@ -25,7 +25,6 @@
*/
package org.teiid.query.optimizer.capabilities;
-import org.teiid.query.optimizer.capabilities.SourceCapabilities;
public class AllCapabilities implements SourceCapabilities {
public boolean supportsCapability(Capability capability) {
@@ -47,5 +46,10 @@
public Scope getScope() {
return Scope.SCOPE_GLOBAL;
}
+
+ @Override
+ public boolean supportsConvert(int sourceType, int targetType) {
+ return true;
+ }
}
\ No newline at end of file