[teiid-commits] teiid SVN: r4437 - in trunk/engine/src: main/java/org/teiid/query/resolver/util and 2 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Sep 13 14:55:46 EDT 2012
Author: shawkins
Date: 2012-09-13 14:55:45 -0400 (Thu, 13 Sep 2012)
New Revision: 4437
Modified:
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
Log:
TEIID-2206 updating the ambiguous column message
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-13 18:13:25 UTC (rev 4436)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-13 18:55:45 UTC (rev 4437)
@@ -532,5 +532,8 @@
TEIID31114,
TEIID31115,
TEIID31116,
+ TEIID31117,
+ TEIID31118,
+ TEIID31119,
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2012-09-13 18:13:25 UTC (rev 4436)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2012-09-13 18:55:45 UTC (rev 4437)
@@ -60,16 +60,6 @@
public static final String TEIID_PASS_THROUGH_TYPE = "teiid:pass-through-type"; //$NON-NLS-1$
private static final String SYS_PREFIX = CoreConstants.SYSTEM_MODEL + '.';
- private static class ElementMatch {
- ElementSymbol element;
- GroupSymbol group;
-
- public ElementMatch(ElementSymbol element, GroupSymbol group) {
- this.element = element;
- this.group = group;
- }
- }
-
private static ThreadLocal<Boolean> determinePartialName = new ThreadLocal<Boolean>() {
protected Boolean initialValue() {
return false;
@@ -87,6 +77,8 @@
private QueryResolverException resolverException;
private Map<Function, QueryResolverException> unresolvedFunctions;
private boolean findShortName;
+ private List<ElementSymbol> matches = new ArrayList<ElementSymbol>(2);
+ private List<GroupSymbol> groupMatches = new ArrayList<GroupSymbol>(2);
/**
* Constructor for ResolveElementsVisitor.
@@ -189,16 +181,17 @@
}
}
- LinkedList<ElementMatch> matches = new LinkedList<ElementMatch>();
+ matches.clear();
+ groupMatches.clear();
while (root != null) {
Collection<GroupSymbol> matchedGroups = ResolverUtil.findMatchingGroups(groupContext, root.getGroups(), metadata);
if (matchedGroups != null && !matchedGroups.isEmpty()) {
groupMatched = true;
- resolveAgainstGroups(shortCanonicalName, matchedGroups, matches);
+ resolveAgainstGroups(shortCanonicalName, matchedGroups);
if (matches.size() > 1) {
- throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.getString("ERR.015.008.0053", elementSymbol)); //$NON-NLS-1$
+ throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31117, elementSymbol, groupMatches));
}
if (matches.size() == 1) {
@@ -212,15 +205,13 @@
if (matches.isEmpty()) {
if (groupMatched) {
- throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.getString("ERR.015.008.0054", elementSymbol)); //$NON-NLS-1$
+ throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31118, elementSymbol));
}
- throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.getString("ERR.015.008.0051", elementSymbol)); //$NON-NLS-1$
+ throw handleUnresolvedElement(elementSymbol, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31119, elementSymbol));
}
- ElementMatch match = matches.getFirst();
-
//copy the match information
- ElementSymbol resolvedSymbol = match.element;
- GroupSymbol resolvedGroup = match.group;
+ ElementSymbol resolvedSymbol = matches.get(0);
+ GroupSymbol resolvedGroup = groupMatches.get(0);
String oldName = elementSymbol.getOutputName();
if (expectedGroupContext != null && !ResolverUtil.nameMatchesGroup(expectedGroupContext, resolvedGroup.getName())) {
return false;
@@ -235,14 +226,15 @@
}
private void resolveAgainstGroups(String elementShortName,
- Collection<GroupSymbol> matchedGroups, LinkedList<ElementMatch> matches) throws QueryMetadataException,
+ Collection<GroupSymbol> matchedGroups) throws QueryMetadataException,
TeiidComponentException {
for (GroupSymbol group : matchedGroups) {
GroupInfo groupInfo = ResolverUtil.getGroupInfo(group, metadata);
ElementSymbol result = groupInfo.getSymbol(elementShortName);
if (result != null) {
- matches.add(new ElementMatch(result, group));
+ matches.add(result);
+ groupMatches.add(group);
}
}
}
@@ -762,7 +754,7 @@
throws QueryResolverException {
// Check that each of the values are the same type as expression
- Class exprType = scrit.getExpression().getType();
+ Class<?> exprType = scrit.getExpression().getType();
if(exprType == null) {
throw new QueryResolverException(QueryPlugin.Event.TEIID30075, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30075, scrit.getExpression()));
}
@@ -854,8 +846,8 @@
// 2. Attempt to set the target types of all contained expressions,
// and collect their type names for the next step
- ArrayList whenTypeNames = new ArrayList(whenCount + 1);
- ArrayList thenTypeNames = new ArrayList(whenCount + 1);
+ ArrayList<String> whenTypeNames = new ArrayList<String>(whenCount + 1);
+ ArrayList<String> thenTypeNames = new ArrayList<String>(whenCount + 1);
setDesiredType(expr, whenType, obj);
// Add the expression's type to the WHEN types
whenTypeNames.add(DataTypeManager.getDataTypeName(expr.getType()));
@@ -887,17 +879,17 @@
// Invariants: all the expressions' types are non-null
// 3. Perform implicit type conversions
- String whenTypeName = ResolverUtil.getCommonType((String[])whenTypeNames.toArray(new String[whenTypeNames.size()]));
+ String whenTypeName = ResolverUtil.getCommonType(whenTypeNames.toArray(new String[whenTypeNames.size()]));
if (whenTypeName == null) {
throw new QueryResolverException(QueryPlugin.Event.TEIID30079, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30079, "WHEN", obj));//$NON-NLS-1$
}
- String thenTypeName = ResolverUtil.getCommonType((String[])thenTypeNames.toArray(new String[thenTypeNames.size()]));
+ String thenTypeName = ResolverUtil.getCommonType(thenTypeNames.toArray(new String[thenTypeNames.size()]));
if (thenTypeName == null) {
throw new QueryResolverException(QueryPlugin.Event.TEIID30079, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30079, "THEN/ELSE", obj));//$NON-NLS-1$
}
obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), whenTypeName, metadata));
- ArrayList whens = new ArrayList(whenCount);
- ArrayList thens = new ArrayList(whenCount);
+ ArrayList<Expression> whens = new ArrayList<Expression>(whenCount);
+ ArrayList<Expression> thens = new ArrayList<Expression>(whenCount);
for (int i = 0; i < whenCount; i++) {
whens.add(ResolverUtil.convertExpression(obj.getWhenExpression(i), whenTypeName, metadata));
thens.add(ResolverUtil.convertExpression(obj.getThenExpression(i), thenTypeName, metadata));
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-09-13 18:13:25 UTC (rev 4436)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-09-13 18:55:45 UTC (rev 4437)
@@ -104,9 +104,9 @@
ERR.015.008.0046=The symbol {0} may only be used once in the FROM clause.
ERR.015.008.0047=The symbol {0} refers to a group not defined in the FROM clause.
ERR.015.008.0049=Bindings must be specified
-ERR.015.008.0051=Symbol {0} is specified with an unknown group context
-ERR.015.008.0053=Element "{0}" is ambiguous, it exists in two or more groups.
-ERR.015.008.0054=Element "{0}" is not defined by any relevant group.
+TEIID31119=Symbol {0} is specified with an unknown group context
+TEIID31117=Element "{0}" is ambiguous and should be qualified, at a single scope it exists in {1}
+TEIID31118=Element "{0}" is not defined by any relevant group.
ERR.015.008.0055=Group specified is ambiguous, resubmit the query by fully qualifying the group name
TEIID30358=Procedure ''{0}'' is ambiguous, use the fully qualified name instead
ERR.015.008.0056=Group does not exist
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2012-09-13 18:13:25 UTC (rev 4436)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2012-09-13 18:55:45 UTC (rev 4437)
@@ -443,7 +443,7 @@
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
helpFailUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.UPDATE, "Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
+ Table.TriggerEvent.UPDATE, "TEIID31119 Symbol pm1.g1.e2 is specified with an unknown group context"); //$NON-NLS-1$
}
// physical elements used on criteria of the if statement
@@ -522,7 +522,7 @@
String userCommand = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
- helpFailUpdateProcedure(procedure, userCommand, Table.TriggerEvent.UPDATE, "Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
+ helpFailUpdateProcedure(procedure, userCommand, Table.TriggerEvent.UPDATE, "TEIID31118 Element \"badElement\" is not defined by any relevant group."); //$NON-NLS-1$
}
// addresses Cases 4624. Before change to UpdateProcedureResolver,
@@ -747,7 +747,7 @@
String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
helpFailUpdateProcedure(procedure, userQuery,
- Table.TriggerEvent.UPDATE, "TEIID30126 Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
+ Table.TriggerEvent.UPDATE, "TEIID30126 Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'var1': TEIID31118 Element \"var1\" is not defined by any relevant group.]"); //$NON-NLS-1$
}
// variables cannot be used among insert elements
@@ -762,7 +762,7 @@
String userQuery = "UPDATE vm1.g3 SET x='x' where e3= 1"; //$NON-NLS-1$
helpFailUpdateProcedure(procedure, userQuery,
- Table.TriggerEvent.UPDATE, "TEIID30126 Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUTS.x': Symbol INPUTS.x is specified with an unknown group context]"); //$NON-NLS-1$
+ Table.TriggerEvent.UPDATE, "TEIID30126 Column variables do not reference columns on group \"pm1.g1\": [Unable to resolve 'INPUTS.x': TEIID31119 Symbol INPUTS.x is specified with an unknown group context]"); //$NON-NLS-1$
}
//should resolve first to the table's column
@@ -788,7 +788,7 @@
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
helpFailUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.UPDATE, "Element \"e1\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
+ Table.TriggerEvent.UPDATE, "TEIID31117 Element \"e1\" is ambiguous and should be qualified, at a single scope it exists in [CHANGING, \"NEW\", \"OLD\"]"); //$NON-NLS-1$
}
@Test public void testLoopRedefinition() {
@@ -820,7 +820,7 @@
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
helpFailUpdateProcedure(proc.toString(), userUpdateStr,
- Table.TriggerEvent.UPDATE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+ Table.TriggerEvent.UPDATE, "TEIID31119 Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
}
@Test public void testTempGroupElementShouldNotBeResolable1() {
@@ -833,7 +833,7 @@
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
helpFailUpdateProcedure(proc.toString(), userUpdateStr,
- Table.TriggerEvent.UPDATE, "Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
+ Table.TriggerEvent.UPDATE, "TEIID31119 Symbol #temp.a is specified with an unknown group context"); //$NON-NLS-1$
}
@Test public void testProcedureCreate() throws Exception {
@@ -927,7 +927,7 @@
String userUpdateStr = "delete from vm1.g1 where e1='x'"; //$NON-NLS-1$
helpFailUpdateProcedure(procedure, userUpdateStr,
- Table.TriggerEvent.DELETE, "Symbol \"NEW\".e1 is specified with an unknown group context"); //$NON-NLS-1$
+ Table.TriggerEvent.DELETE, "TEIID31119 Symbol \"NEW\".e1 is specified with an unknown group context"); //$NON-NLS-1$
}
@Test public void testInvalidVirtualProcedure3() throws Exception {
@@ -998,7 +998,7 @@
}
@Test public void testInvalidVirtualProcedure2() throws Exception {
- helpResolveException("EXEC pm1.vsp12()", RealMetadataFactory.example1Cached(), "Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpResolveException("EXEC pm1.vsp12()", RealMetadataFactory.example1Cached(), "TEIID31119 Symbol mycursor.e2 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testLoopRedefinition2() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2012-09-13 18:13:25 UTC (rev 4436)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2012-09-13 18:55:45 UTC (rev 4437)
@@ -940,7 +940,7 @@
fail("Expected exception on invalid variable pm1.sq2.in"); //$NON-NLS-1$
} catch(QueryResolverException e) {
- assertEquals("Symbol pm1.sq2.\"in\" is specified with an unknown group context", e.getMessage()); //$NON-NLS-1$
+ assertEquals("TEIID31119 Symbol pm1.sq2.\"in\" is specified with an unknown group context", e.getMessage()); //$NON-NLS-1$
}
}
@@ -1702,7 +1702,7 @@
*/
@Test public void testNestedCorrelatedSubqueries4(){
String sql = "select X.e2 from pm4.g2 Y, pm4.g2 X where X.e2 = all (select e2 from pm4.g1 where e5 = e1)"; //$NON-NLS-1$
- helpResolveException(sql, metadata, "Element \"e5\" is ambiguous, it exists in two or more groups."); //$NON-NLS-1$
+ helpResolveException(sql, metadata, "TEIID31117 Element \"e5\" is ambiguous and should be qualified, at a single scope it exists in [pm4.g2 AS Y, pm4.g2 AS X]"); //$NON-NLS-1$
}
@Test public void testSubqueryCorrelatedInCriteriaVirtualLayer(){
@@ -2226,7 +2226,7 @@
procedure = procedure + "DECLARE string VARIABLES.X = 1;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- helpResolveException(procedure, "Element \"VARIABLES.X\" is not defined by any relevant group."); //$NON-NLS-1$
+ helpResolveException(procedure, "TEIID31118 Element \"VARIABLES.X\" is not defined by any relevant group."); //$NON-NLS-1$
}
/**
@@ -2266,7 +2266,7 @@
@Test public void testCreateUnknownPk() {
String sql = "CREATE LOCAL TEMPORARY TABLE foo (column1 string, primary key (column2))"; //$NON-NLS-1$
- helpResolveException(sql, "Element \"column2\" is not defined by any relevant group."); //$NON-NLS-1$
+ helpResolveException(sql, "TEIID31118 Element \"column2\" is not defined by any relevant group."); //$NON-NLS-1$
}
@Test public void testCreateAlreadyExists() {
@@ -2318,7 +2318,7 @@
QueryResolver.resolveCriteria(criteria, metadata);
fail("Exception expected"); //$NON-NLS-1$
} catch(QueryResolverException e) {
- assertEquals("Symbol e1 is specified with an unknown group context", e.getMessage()); //$NON-NLS-1$
+ assertEquals("TEIID31119 Symbol e1 is specified with an unknown group context", e.getMessage()); //$NON-NLS-1$
}
}
@@ -2351,7 +2351,7 @@
+"SELECT ROWS_UPDATED; " //$NON-NLS-1$
+"end "; //$NON-NLS-1$
- helpResolveException(sql, metadata, "Element \"ROWS_UPDATED\" is not defined by any relevant group."); //$NON-NLS-1$
+ helpResolveException(sql, metadata, "TEIID31118 Element \"ROWS_UPDATED\" is not defined by any relevant group."); //$NON-NLS-1$
}
@Test public void testXMLQueryWithVariable() {
@@ -2575,11 +2575,11 @@
}
@Test public void testResolveOldProcRelational() {
- helpResolveException("SELECT * FROM pm1.g1, (exec pm1.sq2(pm1.g1.e1)) as a", "Symbol pm1.g1.e1 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpResolveException("SELECT * FROM pm1.g1, (exec pm1.sq2(pm1.g1.e1)) as a", "TEIID31119 Symbol pm1.g1.e1 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testResolverOrderOfPrecedence() {
- helpResolveException("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 CROSS JOIN (pm1.g2 LEFT OUTER JOIN pm2.g1 on pm1.g1.e1 = pm2.g1.e1)", "Symbol pm1.g1.e1 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpResolveException("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 CROSS JOIN (pm1.g2 LEFT OUTER JOIN pm2.g1 on pm1.g1.e1 = pm2.g1.e1)", "TEIID31119 Symbol pm1.g1.e1 is specified with an unknown group context"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
More information about the teiid-commits
mailing list