teiid SVN: r833 - trunk/common-internal/src/test/java/com/metamatrix/common/config/xml.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-23 14:36:01 -0400 (Thu, 23 Apr 2009)
New Revision: 833
Modified:
trunk/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
Log:
Teiid - 528 - testcase to verify obtaining properties from dependent object tyes
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-23 18:34:17 UTC (rev 832)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-23 18:36:01 UTC (rev 833)
@@ -406,6 +406,8 @@
fail("Didnt find 6 deployed services for VM " + vm.getName());
}
+
+ boolean foundprops = false;
boolean isenabled = false;
for (Iterator<DeployedComponent> it=depsvcs.iterator(); it.hasNext();) {
DeployedComponent dc = it.next();
@@ -417,11 +419,24 @@
}
}
+
+ Properties props = configModel.getConfiguration().getAllPropertiesForComponent(dc.getDeployedComponentDefnID());
+
+ if (dc.getServiceComponentDefnID().getName().equalsIgnoreCase("runtimemetadataservice")) {
+ String propvalue = props.getProperty("ExceptionOnMaxRows") ;
+ if (propvalue != null && propvalue.equals("true") ) {
+ foundprops = true;
+ }
+ }
}
if (! isenabled) {
fail("Did not find the QueryService deployed service that wase enabled");
}
+ if (! foundprops) {
+ fail("Did not find the dependent property from deployed runtimemetadataservice");
+ }
+
String fileToExport = UnitTestUtil.getTestScratchPath() + ("/exported_config.xml");
cma.writeConfigurationModel(fileToExport, configModel, "TestCase");
15 years, 8 months
teiid SVN: r832 - trunk/common-internal/src/main/java/com/metamatrix/common/config/model.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-23 14:34:17 -0400 (Thu, 23 Apr 2009)
New Revision: 832
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
Log:
Teiid - 528 - changed so that when the configuration model is loaded, that the configuration object is loaded with its defaults and its overrides.
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-23 18:28:52 UTC (rev 831)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-23 18:34:17 UTC (rev 832)
@@ -521,6 +521,7 @@
Properties allprops = this.getDefaultPropertyValues(this.configuration.getComponentTypeID());
allprops.putAll(this.configuration.getProperties());
+ allprops.putAll(System.getProperties());
this.configuration.setProperties(allprops);
15 years, 8 months
teiid SVN: r831 - trunk/common-internal/src/main/java/com/metamatrix/common/config/model.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-23 14:28:52 -0400 (Thu, 23 Apr 2009)
New Revision: 831
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
Log:
Teiid - 528 - changed so that when the configuration model is loaded, that the configuration object is loaded with its defaults and its overrides.
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-23 18:25:52 UTC (rev 830)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-23 18:28:52 UTC (rev 831)
@@ -366,22 +366,7 @@
return result;
}
-// public ConfigurationModelContainer copyAs(ConfigurationID configID) throws ConfigurationException {
-// BasicConfigurationObjectEditor ceditor = new BasicConfigurationObjectEditor(false);
-//
-//
-// Configuration newConfig = ceditor.createConfiguration(configuration, configID.getFullName());
-// ConfigurationModelContainerImpl newConfigModel = new ConfigurationModelContainerImpl(newConfig);
-//
-// newConfigModel.setComponentTypes(this.compTypes);
-//// newConfigModel.setProductTypes(this.prodTypes.values());
-//
-// newConfigModel.setResources(this.resources);
-//
-// return newConfigModel;
-// }
-
public void setComponentTypes(Map newCompTypes) {
this.compTypes = Collections.synchronizedMap(new HashMap(newCompTypes.size()));
@@ -391,16 +376,7 @@
}
}
-// public void setProductTypes(Collection newProdTypes) {
-// this.prodTypes = Collections.synchronizedMap(new HashMap(newProdTypes.size()));
-//
-// Iterator it = newProdTypes.iterator();
-// while (it.hasNext()) {
-// addProductType((ProductType)it.next());
-// }
-// }
-
public void setResources(Map theResources) {
this.resources = Collections.synchronizedMap(new HashMap(theResources.size()));
this.resources.putAll(theResources);
@@ -431,13 +407,6 @@
}
-// public void addProductType(ProductType type) {
-// prodTypes.put(type.getFullName(), type);
-// }
-
-
-
-
public void addResource(SharedResource rd) {
resources.put(rd.getID().getFullName(), rd);
}
@@ -483,16 +452,6 @@
configuration.addHost(host);
-// } else if (obj instanceof ProductServiceConfig) {
-// ProductServiceConfig psc = (ProductServiceConfig) obj;
-//
-//
-// if (configuration == null) {
-// throw new ConfigurationException(ErrorMessageKeys.CONFIG_0001, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_0001));
-// }
-//
-// ConfigurationObjectEditorHelper.addConfigurationComponentDefn(configuration, psc);
-
} else if (obj instanceof SharedResource) {
SharedResource rd = (SharedResource) obj;
@@ -547,7 +506,7 @@
}
// first time thru update the configuration first
// and load the component types
-// Collection hold = new ArrayList(objects.size());
+
Iterator configIt = objects.iterator();
while (configIt.hasNext()) {
Object obj = configIt.next();
@@ -559,27 +518,12 @@
}
}
+
+ Properties allprops = this.getDefaultPropertyValues(this.configuration.getComponentTypeID());
+ allprops.putAll(this.configuration.getProperties());
+
+ this.configuration.setProperties(allprops);
-// else if (obj instanceof ComponentType) {
-// addComponentType((ComponentType) obj);
-// } else {
-// hold.add(obj);
-// }
-//
-//
-// }
-//
-// // second time thru update all other objects
-// Iterator iterator = hold.iterator();
-// while (iterator.hasNext()) {
-//
-// Object obj = iterator.next();
-//
-// addObject(obj);
-//
-// }
-//
-
}
public void remove(BaseID objID) throws ConfigurationException {
@@ -595,9 +539,6 @@
} else if (objID instanceof HostID) {
remove((HostID) objID);
-
-// } else if (objID instanceof ProductServiceConfigID) {
-// remove((ProductServiceConfigID) objID);
} else if (objID instanceof SharedResourceID) {
removeSharedResource((SharedResourceID) objID);
@@ -621,12 +562,7 @@
if (compTypes.containsKey(typeID.getFullName())) {
compTypes.remove(typeID.getFullName());
}
-
-// Collection c = getProductTypes();
-// for (final Iterator i = c.iterator(); i.hasNext();) {
-// final BasicProductType type = (BasicProductType)i.next();
-// type.removeServiceTypeID(typeID);
-// } // for
+
}
@@ -637,16 +573,6 @@
}
}
-// private void remove(ComponentTypeID typeID) {
-// removeComponentType(typeID);
-// }
-//
-//
-// private void remove(SharedResourceID rdID) {
-// removeSharedResource(rdID);
-// }
-
-
private void remove(ServiceComponentDefnID defnID) throws ConfigurationException {
if (configuration == null) {
@@ -699,15 +625,13 @@
ConfigurationModelContainerImpl newConfig = new ConfigurationModelContainerImpl(config);
newConfig.setComponentTypes(this.compTypes);
-// newConfig.setProductTypes(this.prodTypes.values());
newConfig.setResources(this.resources);
return newConfig;
}
private Configuration delete( ComponentObjectID targetID, Configuration configuration ) throws ConfigurationException {
- //System.out.println("<!><!><!><!>deleting " + target + ", delete dependencies: " + deleteDependencies);
-
+
BasicConfiguration basicConfig = (BasicConfiguration) configuration;
basicConfig.removeComponentObject( targetID);
15 years, 8 months
teiid SVN: r830 - trunk/common-internal/src/main/java/com/metamatrix/common/config.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-23 14:25:52 -0400 (Thu, 23 Apr 2009)
New Revision: 830
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
Log:
Teiid-464 - to support shared installation, need the ability to override the default property file to load instead of teiid.properties
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-04-23 15:33:20 UTC (rev 829)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-04-23 18:25:52 UTC (rev 830)
@@ -26,7 +26,6 @@
import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
@@ -75,8 +74,9 @@
* </p>
*/
public final class CurrentConfiguration {
-
- public static final String BOOTSTRAP_FILE_NAME = "metamatrix.properties"; //$NON-NLS-1$
+ private static final String BOOTSTRAP_FILE_PROPERTY = "teiid.bootstrap.file"; //$NON-NLS-1$
+
+ public static final String BOOTSTRAP_FILE_NAME = "teiid.properties"; //$NON-NLS-1$
public static final String CONFIGURATION_READER_CLASS_PROPERTY_NAME = "metamatrix.config.reader"; //$NON-NLS-1$
public static final String CLUSTER_NAME = "metamatrix.cluster.name"; //$NON-NLS-1$
public static final String CONFIGURATION_NAME= "configuration.name"; //$NON-NLS-1$
@@ -330,8 +330,10 @@
Properties systemBootStrapProps = getSystemBootStrapProperties();
Properties bootstrapProps = new Properties(systemBootStrapProps);
InputStream bootstrapPropStream = null;
+
+ String bootstrapfile = systemBootStrapProps.getProperty(BOOTSTRAP_FILE_PROPERTY, BOOTSTRAP_FILE_NAME);
try {
- bootstrapPropStream = this.getClass().getClassLoader().getResourceAsStream(BOOTSTRAP_FILE_NAME);
+ bootstrapPropStream = this.getClass().getClassLoader().getResourceAsStream(bootstrapfile);
if (bootstrapPropStream != null) {
bootstrapProps.load(bootstrapPropStream);
}
15 years, 8 months
teiid SVN: r829 - in trunk: connector-api/src/main/java/org/teiid/connector/basic and 12 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-23 11:33:20 -0400 (Thu, 23 Apr 2009)
New Revision: 829
Removed:
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java
trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
Log:
TEIID-203 adding the supportsGroupBy capability and consolidating resolvervisitorutil and resolverutil.
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -395,4 +395,10 @@
*/
boolean supportsBulkInsert();
+ /**
+ * Whether the source supports an explicit GROUP BY clause
+ * @since 6.0
+ */
+ boolean supportsGroupBy();
+
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -430,4 +430,9 @@
public boolean supportsBulkInsert() {
return false;
}
+
+ @Override
+ public boolean supportsGroupBy() {
+ return false;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -59,6 +59,11 @@
public void setMaxInCriteriaSize(int maxInCriteriaSize) {
this.maxInCriteriaSize = maxInCriteriaSize;
}
+
+ @Override
+ public boolean supportsGroupBy() {
+ return true;
+ }
/*
* @see com.metamatrix.data.ConnectorCapabilities#supportsAggregates()
Modified: trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java
===================================================================
--- trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -67,6 +67,11 @@
});
return functions;
}
+
+ @Override
+ public boolean supportsGroupBy() {
+ return true;
+ }
/*
* @see com.metamatrix.data.ConnectorCapabilities#supportsAggregates()
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -57,7 +57,10 @@
}
public void setCapabilitySupport(Capability capability, boolean supports) {
- capabilityMap.put(capability, Boolean.valueOf(supports));
+ if (supports && capability == Capability.QUERY_AGGREGATES) {
+ capabilityMap.put(Capability.QUERY_GROUP_BY, true);
+ }
+ capabilityMap.put(capability, supports);
}
public void setFunctionSupport(String function, boolean supports) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -373,7 +373,11 @@
/**
* @since 6.0.0 indicates support for where all
*/
- REQUIRES_CRITERIA
+ REQUIRES_CRITERIA,
+ /**
+ * @since 6.1.0 indicates support for GROUP BY
+ */
+ QUERY_GROUP_BY
}
public enum Scope {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -139,10 +139,12 @@
if (!caps.supportsCapability(Capability.QUERY_AGGREGATES)) {
return false;
}
-
- boolean supportsFunctionsInGroupBy = caps.supportsCapability(Capability.QUERY_FUNCTIONS_IN_GROUP_BY);
+ if (groupCols != null && !groupCols.isEmpty()) {
+ if (!caps.supportsCapability(Capability.QUERY_GROUP_BY)) {
+ return false;
+ }
+ boolean supportsFunctionsInGroupBy = caps.supportsCapability(Capability.QUERY_FUNCTIONS_IN_GROUP_BY);
- if(groupCols != null) {
// Also verify that if there is a function that we can support pushdown of functions in group by
Iterator colIter = groupCols.iterator();
while(colIter.hasNext()) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -44,7 +44,7 @@
import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
+import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.Command;
@@ -151,7 +151,7 @@
QueryNode queryNode = null;
try {
GroupSymbol gs = new GroupSymbol(groupName);
- ResolverVisitorUtil.resolveGroup(gs, metadata);
+ ResolverUtil.resolveGroup(gs, metadata);
queryNode = metadata.getVirtualPlan(gs.getMetadataID());
} catch (QueryResolverException e) {
throw new QueryPlannerException(e, ErrorMessageKeys.OPTIMIZER_0029, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0029, groupName));
@@ -179,7 +179,7 @@
public static GroupSymbol createResolvedGroup(GroupSymbol group, QueryMetadataInterface metadata)
throws MetaMatrixComponentException {
try {
- ResolverVisitorUtil.resolveGroup(group, metadata);
+ ResolverUtil.resolveGroup(group, metadata);
return group;
} catch (QueryResolverException e) {
throw new MetaMatrixComponentException(e);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -54,7 +54,6 @@
import com.metamatrix.query.processor.relational.RelationalNode;
import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
@@ -382,7 +381,7 @@
throws QueryResolverException,QueryMetadataException,MetaMatrixComponentException {
GroupSymbol oldGroupSymbol = new GroupSymbol(oldGroup);
- ResolverVisitorUtil.resolveGroup(oldGroupSymbol, metadata);
+ ResolverUtil.resolveGroup(oldGroupSymbol, metadata);
HashSet projectedElements = new HashSet(ResolverUtil.resolveElementsInGroup(oldGroupSymbol, metadata));
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -39,7 +39,6 @@
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.ProcedureReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.GroupContext;
@@ -219,7 +218,7 @@
QueryResolverException {
// Resolve group so we can tell whether it is an update procedure
GroupSymbol group = procCommand.getGroup();
- ResolverVisitorUtil.resolveGroup(group, metadata);
+ ResolverUtil.resolveGroup(group, metadata);
}
public static GroupSymbol addScalarGroup(String name, TempMetadataStore metadata, GroupContext externalGroups, List symbols) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -51,8 +51,8 @@
import com.metamatrix.query.resolver.command.UpdateResolver;
import com.metamatrix.query.resolver.command.XMLQueryResolver;
import com.metamatrix.query.resolver.command.XQueryResolver;
+import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.From;
@@ -242,7 +242,7 @@
GroupSymbol symbol = ((UnaryFromClause)clause).getGroup();
- ResolverVisitorUtil.resolveGroup(symbol, metadata);
+ ResolverUtil.resolveGroup(symbol, metadata);
if (symbol.isProcedure()) {
return false;
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -38,7 +38,6 @@
import com.metamatrix.query.resolver.CommandResolver;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.ProcedureReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.DynamicCommand;
@@ -96,7 +95,7 @@
GroupSymbol intoSymbol = dynamicCmd.getIntoGroup();
if (intoSymbol != null) {
if (!intoSymbol.isImplicitTempGroupSymbol()) {
- ResolverVisitorUtil.resolveGroup(intoSymbol, metadata);
+ ResolverUtil.resolveGroup(intoSymbol, metadata);
} else {
List symbols = dynamicCmd.getAsColumns();
ResolverUtil.resolveImplicitTempGroup(metadata, intoSymbol, symbols);
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -56,7 +56,6 @@
import com.metamatrix.query.resolver.util.BindVariableVisitor;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.ExistsCriteria;
@@ -390,7 +389,7 @@
public void visit(GroupSymbol obj) {
try {
- ResolverVisitorUtil.resolveGroup(obj, metadata);
+ ResolverUtil.resolveGroup(obj, metadata);
} catch (QueryResolverException err) {
throw new MetaMatrixRuntimeException(err);
} catch (MetaMatrixComponentException err) {
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -36,7 +36,6 @@
import com.metamatrix.query.resolver.CommandResolver;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Create;
import com.metamatrix.query.sql.lang.Drop;
@@ -79,12 +78,12 @@
//exception at runtime if the user has not dropped the previous table yet
ResolverUtil.addTempTable(metadata, group, create.getColumns());
- ResolverVisitorUtil.resolveGroup(((Create)command).getTable(), metadata);
+ ResolverUtil.resolveGroup(((Create)command).getTable(), metadata);
Set groups = new HashSet();
groups.add(((Create)command).getTable());
ResolverVisitor.resolveLanguageObject(command, groups, metadata);
} else if(command.getType() == Command.TYPE_DROP) {
- ResolverVisitorUtil.resolveGroup(((Drop)command).getTable(), metadata);
+ ResolverUtil.resolveGroup(((Drop)command).getTable(), metadata);
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -51,7 +51,6 @@
import com.metamatrix.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.ProcedureReservedWords;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
@@ -93,7 +92,7 @@
if(!groupName.equalsIgnoreCase(ProcedureReservedWords.INPUT) &&
!groupName.equalsIgnoreCase(ProcedureReservedWords.CHANGING) ) {
// set the groupSymbol on the procedure
- ResolverVisitorUtil.resolveGroup(groupSymbol, metadata);
+ ResolverUtil.resolveGroup(groupSymbol, metadata);
procCommand.setVirtualGroup(groupSymbol);
virtualGroup = groupSymbol;
break;
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -42,7 +42,6 @@
import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.util.ErrorMessageKeys;
@@ -155,7 +154,7 @@
ElementSymbol element = (ElementSymbol) expr;
GroupSymbol groupSymbol = new GroupSymbol(metadata.getGroupName(element.getName()));
- ResolverVisitorUtil.resolveGroup(groupSymbol, metadata);
+ ResolverUtil.resolveGroup(groupSymbol, metadata);
ResolverVisitor.resolveLanguageObject(element, Arrays.asList(groupSymbol), metadata);
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -23,6 +23,7 @@
package com.metamatrix.query.resolver.util;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -34,6 +35,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.types.DataTypeManager.DefaultDataTypes;
@@ -44,6 +46,7 @@
import com.metamatrix.query.function.FunctionLibraryManager;
import com.metamatrix.query.metadata.GroupInfo;
import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
import com.metamatrix.query.metadata.SupportConstants;
import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.metadata.TempMetadataID;
@@ -51,6 +54,7 @@
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.Limit;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.symbol.AbstractCaseExpression;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
@@ -71,7 +75,32 @@
*/
public class ResolverUtil {
- // Can't construct
+ public static class ResolvedLookup {
+ private GroupSymbol group;
+ private ElementSymbol keyElement;
+ private ElementSymbol returnElement;
+
+ void setGroup(GroupSymbol group) {
+ this.group = group;
+ }
+ public GroupSymbol getGroup() {
+ return group;
+ }
+ void setKeyElement(ElementSymbol keyElement) {
+ this.keyElement = keyElement;
+ }
+ public ElementSymbol getKeyElement() {
+ return keyElement;
+ }
+ void setReturnElement(ElementSymbol returnElement) {
+ this.returnElement = returnElement;
+ }
+ public ElementSymbol getReturnElement() {
+ return returnElement;
+ }
+ }
+
+ // Can't construct
private ResolverUtil() {}
/*
@@ -106,11 +135,11 @@
// A type can be implicitly converted to itself, so we put the implicit
// conversions as well as the original type in the working list of
// conversions.
- HashSet commonConversions = new LinkedHashSet();
+ HashSet<String> commonConversions = new LinkedHashSet<String>();
commonConversions.add(typeNames[0]);
commonConversions.addAll(DataTypeManager.getImplicitConversions(typeNames[0]));
for (int i = 1; i < typeNames.length; i++ ) {
- HashSet conversions = new LinkedHashSet(DataTypeManager.getImplicitConversions(typeNames[i]));
+ HashSet<String> conversions = new LinkedHashSet<String>(DataTypeManager.getImplicitConversions(typeNames[i]));
conversions.add(typeNames[i]);
// Equivalent to set intersection
commonConversions.retainAll(conversions);
@@ -126,7 +155,7 @@
commonConversions.remove(DefaultDataTypes.STRING);
commonConversions.remove(DefaultDataTypes.OBJECT);
if (!commonConversions.isEmpty()) {
- return (String)commonConversions.iterator().next();
+ return commonConversions.iterator().next();
}
return null;
}
@@ -570,7 +599,7 @@
if (metadata.getMetadataStore().getTempElementElementIDs(symbol.getCanonicalName())==null) {
addTempGroup(metadata, symbol, symbols, true);
}
- ResolverVisitorUtil.resolveGroup(symbol, metadata);
+ ResolverUtil.resolveGroup(symbol, metadata);
}
}
@@ -748,5 +777,202 @@
}
return false;
}
+
+ /**
+ * Check the type of the (left) expression and the type of the single
+ * projected symbol of the subquery. If they are not the same, try to find
+ * an implicit conversion from the former type to the latter type, and wrap
+ * the left expression in that conversion function; otherwise throw an
+ * Exception.
+ * @param expression the Expression on one side of the predicate criteria
+ * @param crit the SubqueryContainer containing the subquery Command of the other
+ * side of the predicate criteria
+ * @return implicit conversion Function, or null if none is necessary
+ * @throws QueryResolverException if a conversion is necessary but none can
+ * be found
+ */
+ static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit)
+ throws QueryResolverException {
+
+ // Check that type of the expression is same as the type of the
+ // single projected symbol of the subquery
+ Class exprType = expression.getType();
+ if(exprType == null) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0030, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0030, expression));
+ }
+ String exprTypeName = DataTypeManager.getDataTypeName(exprType);
+
+ Collection projectedSymbols = crit.getCommand().getProjectedSymbols();
+ if (projectedSymbols.size() != 1){
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0032, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0032, crit.getCommand()));
+ }
+ Class subqueryType = ((Expression)projectedSymbols.iterator().next()).getType();
+ String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
+ Expression result = null;
+ try {
+ result = convertExpression(expression, exprTypeName, subqueryTypeName);
+ } catch (QueryResolverException qre) {
+ throw new QueryResolverException(qre, ErrorMessageKeys.RESOLVER_0033, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0033, crit));
+ }
+ return result;
+ }
+
+ public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException {
+ Expression[] args = lookup.getArgs();
+ ResolvedLookup result = new ResolvedLookup();
+ // Special code to handle setting return type of the lookup function to match the type of the return element
+ if( args[0] instanceof Constant && args[1] instanceof Constant && args[2] instanceof Constant) {
+ // If code table name in lookup function refers to virtual group, throws exception
+ GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
+ try {
+ groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
+ if (groupSym.getMetadataID() instanceof TempMetadataID) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0065, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0065, ((Constant)args[0]).getValue()));
+ }
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, ((Constant)args[0]).getValue()));
+ }
+ result.setGroup(groupSym);
+
+ List<GroupSymbol> groups = Arrays.asList(groupSym);
+
+ String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
+ ElementSymbol returnElement = new ElementSymbol(returnElementName);
+ try {
+ ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, returnElementName));
+ }
+ result.setReturnElement(returnElement);
+
+ String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
+ ElementSymbol keyElement = new ElementSymbol(keyElementName);
+ try {
+ ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
+ }
+ result.setKeyElement(keyElement);
+ return result;
+ }
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0063, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0063));
+ }
+
+ private static QueryResolverException handleUnresolvedGroup(GroupSymbol symbol, String description) {
+ UnresolvedSymbolDescription usd = new UnresolvedSymbolDescription(symbol.toString(), description);
+ QueryResolverException e = new QueryResolverException(usd.getDescription()+": "+usd.getSymbol()); //$NON-NLS-1$
+ e.setUnresolvedSymbols(Arrays.asList(usd));
+ return e;
+ }
+
+ public static void resolveGroup(GroupSymbol symbol, QueryMetadataInterface metadata)
+ throws MetaMatrixComponentException, QueryResolverException {
+
+ if (symbol.getMetadataID() != null){
+ return;
+ }
+
+ // determine the "metadataID" part of the symbol to look up
+ String potentialID = symbol.getNonCorrelationName();
+
+ String name = symbol.getName();
+ String definition = symbol.getDefinition();
+
+ Object groupID = null;
+ try {
+ // get valid GroupID for possibleID - this may throw exceptions if group is invalid
+ groupID = metadata.getGroupID(potentialID);
+ } catch(QueryMetadataException e) {
+ // didn't find this group ID
+ }
+
+ // If that didn't work, try to strip a vdb name from potentialID
+ String vdbName = null;
+ if(groupID == null) {
+ String newPotentialID = potentialID;
+ int vdbIndex = potentialID.indexOf(ElementSymbol.SEPARATOR);
+ if(vdbIndex >= 0) {
+ String potentialVdbName = potentialID.substring(0, vdbIndex);
+ newPotentialID = potentialID.substring(vdbIndex+1);
+
+ try {
+ groupID = metadata.getGroupID(newPotentialID);
+ vdbName = potentialVdbName;
+ } catch(QueryMetadataException e) {
+ // ignore - just didn't find it
+ }
+ if(groupID != null) {
+ potentialID = newPotentialID;
+ }
+ }
+ }
+
+ // the group could be partially qualified, verify that this group exists
+ // and there is only one group that matches the given partial name
+ if(groupID == null) {
+ Collection groupNames = null;
+ try {
+ groupNames = metadata.getGroupsForPartialName(potentialID);
+ } catch(QueryMetadataException e) {
+ // ignore - just didn't find it
+ }
+
+ if(groupNames != null) {
+ int matches = groupNames.size();
+ if(matches == 1) {
+ potentialID = (String) groupNames.iterator().next();
+ try {
+ // get valid GroupID for possibleID - this may throw exceptions if group is invalid
+ groupID = metadata.getGroupID(potentialID);
+ //set group full name
+ if(symbol.getDefinition() != null){
+ symbol.setDefinition(potentialID);
+ }else{
+ symbol.setName(potentialID);
+ }
+ } catch(QueryMetadataException e) {
+ // didn't find this group ID
+ }
+ } else if(matches > 1) {
+ throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0055));
+ }
+ }
+ }
+
+ if (groupID == null || metadata.isProcedure(groupID)) {
+ //try procedure relational resolving
+ try {
+ StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(potentialID);
+ symbol.setProcedure(true);
+ groupID = storedProcedureInfo.getProcedureID();
+ } catch(QueryMetadataException e) {
+ // just ignore
+ }
+ }
+
+ if(groupID == null) {
+ throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0056));
+ }
+ // set real metadata ID in the symbol
+ symbol.setMetadataID(groupID);
+ if(vdbName != null) {
+ // reset name or definition to strip vdb name
+ if(symbol.getDefinition() == null) {
+ symbol.setName(potentialID);
+ } else {
+ symbol.setDefinition(potentialID);
+ }
+ }
+ try {
+ if (!symbol.isProcedure()) {
+ symbol.setIsTempTable(metadata.isTemporaryTable(groupID));
+ }
+ } catch(QueryMetadataException e) {
+ // should not come here
+ }
+
+ symbol.setOutputDefinition(definition);
+ symbol.setOutputName(name);
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -288,7 +288,7 @@
public void visit(SubqueryCompareCriteria obj) {
try {
- obj.setLeftExpression(ResolverVisitorUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj));
+ obj.setLeftExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj));
} catch(QueryResolverException e) {
handleException(e);
}
@@ -297,7 +297,7 @@
public void visit(SubquerySetCriteria obj) {
try {
- obj.setExpression(ResolverVisitorUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj));
+ obj.setExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj));
} catch(QueryResolverException e) {
handleException(e);
}
@@ -457,7 +457,7 @@
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0037, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0037, new Object[] {DataTypeManager.getDataTypeName(srcTypeClass), dataType}));
}
} else if(fd.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
- ResolverVisitorUtil.ResolvedLookup lookup = ResolverVisitorUtil.resolveLookup(function, metadata);
+ ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(function, metadata);
fd = library.copyFunctionChangeReturnType(fd, lookup.getReturnElement().getType());
} else if(fd.getName().equalsIgnoreCase(FunctionLibrary.XPATHVALUE)) {
// Validate the xpath value is valid
Deleted: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -1,271 +0,0 @@
-/*
- * 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 com.metamatrix.query.resolver.util;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public class ResolverVisitorUtil {
-
- public static class ResolvedLookup {
- private GroupSymbol group;
- private ElementSymbol keyElement;
- private ElementSymbol returnElement;
-
- void setGroup(GroupSymbol group) {
- this.group = group;
- }
- public GroupSymbol getGroup() {
- return group;
- }
- void setKeyElement(ElementSymbol keyElement) {
- this.keyElement = keyElement;
- }
- public ElementSymbol getKeyElement() {
- return keyElement;
- }
- void setReturnElement(ElementSymbol returnElement) {
- this.returnElement = returnElement;
- }
- public ElementSymbol getReturnElement() {
- return returnElement;
- }
- }
-
- /**
- * Check the type of the (left) expression and the type of the single
- * projected symbol of the subquery. If they are not the same, try to find
- * an implicit conversion from the former type to the latter type, and wrap
- * the left expression in that conversion function; otherwise throw an
- * Exception.
- * @param expression the Expression on one side of the predicate criteria
- * @param crit the SubqueryContainer containing the subquery Command of the other
- * side of the predicate criteria
- * @return implicit conversion Function, or null if none is necessary
- * @throws QueryResolverException if a conversion is necessary but none can
- * be found
- */
- static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit)
- throws QueryResolverException {
-
- // Check that type of the expression is same as the type of the
- // single projected symbol of the subquery
- Class exprType = expression.getType();
- if(exprType == null) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0030, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0030, expression));
- }
- String exprTypeName = DataTypeManager.getDataTypeName(exprType);
-
- Collection projectedSymbols = crit.getCommand().getProjectedSymbols();
- if (projectedSymbols.size() != 1){
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0032, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0032, crit.getCommand()));
- }
- Class subqueryType = ((Expression)projectedSymbols.iterator().next()).getType();
- String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
- Expression result = null;
- try {
- result = ResolverUtil.convertExpression(expression, exprTypeName, subqueryTypeName);
- } catch (QueryResolverException qre) {
- throw new QueryResolverException(qre, ErrorMessageKeys.RESOLVER_0033, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0033, crit));
- }
- return result;
- }
-
- public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException {
- Expression[] args = lookup.getArgs();
- ResolvedLookup result = new ResolvedLookup();
- // Special code to handle setting return type of the lookup function to match the type of the return element
- if( args[0] instanceof Constant && args[1] instanceof Constant && args[2] instanceof Constant) {
- // If code table name in lookup function refers to virtual group, throws exception
- GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
- try {
- groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
- if (groupSym.getMetadataID() instanceof TempMetadataID) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0065, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0065, ((Constant)args[0]).getValue()));
- }
- } catch(QueryMetadataException e) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, ((Constant)args[0]).getValue()));
- }
- result.setGroup(groupSym);
-
- List<GroupSymbol> groups = Arrays.asList(groupSym);
-
- String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
- ElementSymbol returnElement = new ElementSymbol(returnElementName);
- try {
- ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
- } catch(QueryMetadataException e) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, returnElementName));
- }
- result.setReturnElement(returnElement);
-
- String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
- ElementSymbol keyElement = new ElementSymbol(keyElementName);
- try {
- ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
- } catch(QueryMetadataException e) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
- }
- result.setKeyElement(keyElement);
- return result;
- }
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0063, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0063));
- }
-
- private static QueryResolverException handleUnresolvedGroup(GroupSymbol symbol, String description) {
- UnresolvedSymbolDescription usd = new UnresolvedSymbolDescription(symbol.toString(), description);
- QueryResolverException e = new QueryResolverException(usd.getDescription()+": "+usd.getSymbol()); //$NON-NLS-1$
- e.setUnresolvedSymbols(Arrays.asList(usd));
- return e;
- }
-
- public static void resolveGroup(GroupSymbol symbol, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryResolverException {
-
- if (symbol.getMetadataID() != null){
- return;
- }
-
- // determine the "metadataID" part of the symbol to look up
- String potentialID = symbol.getNonCorrelationName();
-
- String name = symbol.getName();
- String definition = symbol.getDefinition();
-
- Object groupID = null;
- try {
- // get valid GroupID for possibleID - this may throw exceptions if group is invalid
- groupID = metadata.getGroupID(potentialID);
- } catch(QueryMetadataException e) {
- // didn't find this group ID
- }
-
- // If that didn't work, try to strip a vdb name from potentialID
- String vdbName = null;
- if(groupID == null) {
- String newPotentialID = potentialID;
- int vdbIndex = potentialID.indexOf(ElementSymbol.SEPARATOR);
- if(vdbIndex >= 0) {
- String potentialVdbName = potentialID.substring(0, vdbIndex);
- newPotentialID = potentialID.substring(vdbIndex+1);
-
- try {
- groupID = metadata.getGroupID(newPotentialID);
- vdbName = potentialVdbName;
- } catch(QueryMetadataException e) {
- // ignore - just didn't find it
- }
- if(groupID != null) {
- potentialID = newPotentialID;
- }
- }
- }
-
- // the group could be partially qualified, verify that this group exists
- // and there is only one group that matches the given partial name
- if(groupID == null) {
- Collection groupNames = null;
- try {
- groupNames = metadata.getGroupsForPartialName(potentialID);
- } catch(QueryMetadataException e) {
- // ignore - just didn't find it
- }
-
- if(groupNames != null) {
- int matches = groupNames.size();
- if(matches == 1) {
- potentialID = (String) groupNames.iterator().next();
- try {
- // get valid GroupID for possibleID - this may throw exceptions if group is invalid
- groupID = metadata.getGroupID(potentialID);
- //set group full name
- if(symbol.getDefinition() != null){
- symbol.setDefinition(potentialID);
- }else{
- symbol.setName(potentialID);
- }
- } catch(QueryMetadataException e) {
- // didn't find this group ID
- }
- } else if(matches > 1) {
- throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0055));
- }
- }
- }
-
- if (groupID == null || metadata.isProcedure(groupID)) {
- //try procedure relational resolving
- try {
- StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(potentialID);
- symbol.setProcedure(true);
- groupID = storedProcedureInfo.getProcedureID();
- } catch(QueryMetadataException e) {
- // just ignore
- }
- }
-
- if(groupID == null) {
- throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0056));
- }
- // set real metadata ID in the symbol
- symbol.setMetadataID(groupID);
- if(vdbName != null) {
- // reset name or definition to strip vdb name
- if(symbol.getDefinition() == null) {
- symbol.setName(potentialID);
- } else {
- symbol.setDefinition(potentialID);
- }
- }
- try {
- if (!symbol.isProcedure()) {
- symbol.setIsTempTable(metadata.isTemporaryTable(groupID));
- }
- } catch(QueryMetadataException e) {
- // should not come here
- }
-
- symbol.setOutputDefinition(definition);
- symbol.setOutputName(name);
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -41,8 +41,7 @@
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.SupportConstants;
import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil.ResolvedLookup;
+import com.metamatrix.query.resolver.util.ResolverUtil.ResolvedLookup;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.ProcedureReservedWords;
@@ -282,7 +281,7 @@
public void visit(Function obj) {
if(FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
try {
- ResolvedLookup resolvedLookup = ResolverVisitorUtil.resolveLookup(obj, getMetadata());
+ ResolverUtil.ResolvedLookup resolvedLookup = ResolverUtil.resolveLookup(obj, getMetadata());
if(ValidationVisitor.isNonComparable(resolvedLookup.getKeyElement())) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_lookup_key", resolvedLookup.getKeyElement()), resolvedLookup.getKeyElement()); //$NON-NLS-1$
}
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 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -100,6 +100,7 @@
tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_GROUP_BY, srcCaps.supportsGroupBy());
List functions = srcCaps.getSupportedFunctions();
if(functions != null && functions.size() > 0) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -42,8 +42,7 @@
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil.ResolvedLookup;
+import com.metamatrix.query.resolver.util.ResolverUtil.ResolvedLookup;
import com.metamatrix.query.sql.lang.Delete;
import com.metamatrix.query.sql.lang.Insert;
import com.metamatrix.query.sql.lang.Into;
@@ -115,7 +114,7 @@
if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
try {
List<Symbol> symbols = new LinkedList<Symbol>();
- ResolvedLookup lookup = ResolverVisitorUtil.resolveLookup(obj, this.getMetadata());
+ ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(obj, this.getMetadata());
symbols.add(lookup.getGroup());
symbols.add(lookup.getKeyElement());
symbols.add(lookup.getReturnElement());
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -33,8 +33,8 @@
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil.ResolvedLookup;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.resolver.util.ResolverUtil.ResolvedLookup;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Delete;
import com.metamatrix.query.sql.lang.Insert;
@@ -90,7 +90,7 @@
public void visit(Function obj) {
if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
try {
- ResolvedLookup resolvedLookup = ResolverVisitorUtil.resolveLookup(obj, getMetadata());
+ ResolverUtil.ResolvedLookup resolvedLookup = ResolverUtil.resolveLookup(obj, getMetadata());
validateModelVisibility(getMetadata().getModelID(resolvedLookup.getGroup().getMetadataID()), resolvedLookup.getGroup());
} catch (QueryResolverException e) {
handleException(e, obj);
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java 2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java 2009-04-23 15:33:20 UTC (rev 829)
@@ -431,4 +431,23 @@
});
}
+ public void testNoGroupAggregatePushdown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "select count(*) from bqt1.smalla", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT count(*) from bqt1.smalla"}, //$NON-NLS-1$
+ true);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
}
15 years, 8 months
teiid SVN: r828 - in trunk: engine/src/main/java/com/metamatrix/query/resolver/command and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-22 16:03:21 -0400 (Wed, 22 Apr 2009)
New Revision: 828
Added:
trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
Log:
TEIID-526, TEIID-527 ensuring that the user command is unmodified and eliminating the duplicate node conversion logic
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -49,17 +49,17 @@
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.GroupBy;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.QueryCommand;
+import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.navigator.PostOrderNavigator;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
@@ -206,96 +206,58 @@
}
} else if(type == NodeConstants.Types.PROJECT) {
- List<SingleElementSymbol> elements = (List<SingleElementSymbol>) node.getProperty(NodeConstants.Info.PROJECT_COLS);
-
- for (int i = 0; i < elements.size(); i++) {
- SingleElementSymbol symbol = elements.get(i);
- SingleElementSymbol mappedSymbol = convertSingleElementSymbol(symbol, symbolMap, true);
- elements.set(i, mappedSymbol);
-
- if (newGroup == null) {
- GroupsUsedByElementsVisitor.getGroups(mappedSymbol, groups);
- }
+ List<SingleElementSymbol> projectedSymbols = (List<SingleElementSymbol>)node.getProperty(NodeConstants.Info.PROJECT_COLS);
+ Select select = new Select(projectedSymbols);
+ ExpressionMappingVisitor.mapExpressions(select, symbolMap);
+ node.setProperty(NodeConstants.Info.PROJECT_COLS, select.getSymbols());
+ if (newGroup == null) {
+ GroupsUsedByElementsVisitor.getGroups(select, groups);
}
-
} else if(type == NodeConstants.Types.JOIN) {
// Convert join criteria property
List<Criteria> joinCrits = (List<Criteria>) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
- if(joinCrits != null) {
- for (int i = 0; i < joinCrits.size(); i++) {
- Criteria crit = joinCrits.get(i);
- crit = convertCriteria(crit, symbolMap);
-
- if (newGroup == null) {
- GroupsUsedByElementsVisitor.getGroups(crit, groups);
- }
- joinCrits.set(i, crit);
- }
+ if(joinCrits != null && !joinCrits.isEmpty()) {
+ Criteria crit = new CompoundCriteria(joinCrits);
+ crit = convertCriteria(crit, symbolMap);
+ if (crit instanceof CompoundCriteria) {
+ node.setProperty(NodeConstants.Info.JOIN_CRITERIA, ((CompoundCriteria)crit).getCriteria());
+ } else {
+ joinCrits = new ArrayList<Criteria>();
+ joinCrits.add(crit);
+ node.setProperty(NodeConstants.Info.JOIN_CRITERIA, joinCrits);
+ }
+ if (newGroup == null) {
+ GroupsUsedByElementsVisitor.getGroups(crit, groups);
+ }
}
convertAccessPatterns(symbolMap, node);
} else if(type == NodeConstants.Types.SORT) {
- List<SingleElementSymbol> elements = (List<SingleElementSymbol>) node.getProperty(NodeConstants.Info.SORT_ORDER);
-
- for (int i = 0; i < elements.size(); i++) {
- SingleElementSymbol symbol = elements.get(i);
- SingleElementSymbol mappedSymbol = convertSingleElementSymbol(symbol, symbolMap, true);
- elements.set(i, mappedSymbol);
-
- if (newGroup == null) {
- GroupsUsedByElementsVisitor.getGroups(mappedSymbol, groups);
- }
+ List<SingleElementSymbol> sortCols = (List<SingleElementSymbol>)node.getProperty(NodeConstants.Info.SORT_ORDER);
+ OrderBy orderBy = new OrderBy(sortCols);
+ ExpressionMappingVisitor.mapExpressions(orderBy, symbolMap);
+ node.setProperty(NodeConstants.Info.SORT_ORDER, orderBy.getVariables());
+ if (newGroup == null) {
+ GroupsUsedByElementsVisitor.getGroups(orderBy, groups);
}
-
} else if(type == NodeConstants.Types.GROUP) {
- // Grouping columns
- List groupCols = (List) node.getProperty(NodeConstants.Info.GROUP_COLS);
- if(groupCols != null) {
- List newGroupCols = new ArrayList(groupCols.size());
- Iterator groupIter = groupCols.iterator();
- while(groupIter.hasNext()) {
- SingleElementSymbol groupCol = (SingleElementSymbol) groupIter.next();
- Expression mappedCol = convertSingleElementSymbol(groupCol, symbolMap, false);
- newGroupCols.add( mappedCol );
-
- if (newGroup == null) {
- GroupsUsedByElementsVisitor.getGroups(mappedCol, groups);
- }
- }
- node.setProperty(NodeConstants.Info.GROUP_COLS, newGroupCols);
+ List<SingleElementSymbol> groupCols = (List<SingleElementSymbol>)node.getProperty(NodeConstants.Info.GROUP_COLS);
+ if (groupCols != null) {
+ GroupBy groupBy= new GroupBy(groupCols);
+ ExpressionMappingVisitor.mapExpressions(groupBy, symbolMap);
+ node.setProperty(NodeConstants.Info.GROUP_COLS, groupBy.getSymbols());
+ if (newGroup == null) {
+ GroupsUsedByElementsVisitor.getGroups(groupCols, groups);
+ }
}
} else if (type == NodeConstants.Types.SOURCE || type == NodeConstants.Types.ACCESS) {
convertAccessPatterns(symbolMap, node);
}
}
- static SingleElementSymbol convertSingleElementSymbol(SingleElementSymbol symbol, Map symbolMap, boolean shouldAlias) {
-
- // Preserve old "short name" of alias by aliasing
- String name = symbol.getShortName();
+ private static Expression convertExpression(Expression expression, Map symbolMap) {
- Expression mappedExpression = convertExpression(SymbolMap.getExpression(symbol), symbolMap);
-
- // Convert symbol using symbol map
- SingleElementSymbol mappedSymbol = null;
-
- if(!(mappedExpression instanceof SingleElementSymbol)) {
- mappedSymbol = new ExpressionSymbol(name, mappedExpression);
- } else {
- mappedSymbol = (SingleElementSymbol)mappedExpression;
- }
-
- // Re-alias to maintain name if necessary
- if(shouldAlias && (mappedSymbol instanceof ExpressionSymbol || !mappedSymbol.getShortCanonicalName().equals(name.toUpperCase()))) {
- mappedSymbol = new AliasSymbol(name, mappedSymbol);
- }
-
- return mappedSymbol;
- }
-
- static Expression convertExpression(Expression expression, Map symbolMap) {
-
if (expression == null || expression instanceof Constant) {
return expression;
}
@@ -318,20 +280,16 @@
}
}
- ExpressionMappingVisitor emv = new ExpressionMappingVisitor(symbolMap);
+ ExpressionMappingVisitor.mapExpressions(expression, symbolMap);
- PreOrderNavigator.doVisit(expression, emv);
-
return expression;
}
static Criteria convertCriteria(Criteria criteria, final Map symbolMap)
throws QueryPlannerException {
- ExpressionMappingVisitor emv = new ExpressionMappingVisitor(symbolMap);
+ ExpressionMappingVisitor.mapExpressions(criteria, symbolMap);
- PostOrderNavigator.doVisit(criteria, emv);
-
// Simplify criteria if possible
try {
return QueryRewriter.rewriteCriteria(criteria, null, null, null);
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -49,15 +49,10 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.GroupBy;
import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -68,7 +63,6 @@
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
import com.metamatrix.query.util.CommandContext;
@@ -141,6 +135,7 @@
/**
* Attempt to push the group node below one or more joins, manipulating the parent plan as necessary. This may involve
* modifying symbols in parent nodes (to account for staged aggregates).
+ * @throws QueryPlannerException
*
* @since 4.2
*/
@@ -149,7 +144,7 @@
Set<AggregateSymbol> allAggregates,
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder) throws MetaMatrixComponentException,
- QueryMetadataException {
+ QueryMetadataException, QueryPlannerException {
Map<PlanNode, List<SingleElementSymbol>> aggregateMap = createNodeMapping(groupNode, allAggregates);
Map<PlanNode, List<SingleElementSymbol>> groupingMap = createNodeMapping(groupNode, groupingExpressions);
@@ -220,7 +215,7 @@
private void stageAggregates(PlanNode groupNode,
QueryMetadataInterface metadata,
Set<SingleElementSymbol> stagedGroupingSymbols,
- List<SingleElementSymbol> aggregates) throws MetaMatrixComponentException {
+ List<SingleElementSymbol> aggregates) throws MetaMatrixComponentException, QueryPlannerException {
//remove any aggregates that are computed over a group by column
Set<Expression> expressions = new HashSet<Expression>();
for (SingleElementSymbol expression : stagedGroupingSymbols) {
@@ -414,74 +409,19 @@
return aggMap;
}
- static void mapExpressions(PlanNode node, Map<? extends Expression, ? extends Expression> exprMap) {
- PlanNode current = node;
+ static void mapExpressions(PlanNode node, Map<? extends Expression, ? extends Expression> exprMap)
+ throws QueryPlannerException {
- while (current != null) {
+ while (node != null) {
+ FrameUtil.convertNode(node, null, null, exprMap);
- // Convert expressions from correlated subquery references;
- // currently only for SELECT or PROJECT nodes
- SymbolMap refs = (SymbolMap)node.getProperty(NodeConstants.Info.CORRELATED_REFERENCES);
- if (refs != null){
- for (Map.Entry<ElementSymbol, Expression> ref : refs.asUpdatableMap().entrySet()) {
- Expression expr = ref.getValue();
- Expression mappedExpr = exprMap.get(expr);
- if (mappedExpr != null) {
- ref.setValue(mappedExpr);
- } else {
- ExpressionMappingVisitor.mapExpressions(ref.getValue(), exprMap);
- }
- }
- }
-
- switch (current.getType()) {
- case NodeConstants.Types.SELECT: {
- Criteria crit = (Criteria)current.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- ExpressionMappingVisitor.mapExpressions(crit, exprMap);
- break;
- }
- case NodeConstants.Types.PROJECT: {
- List<SingleElementSymbol> projectedSymbols = (List<SingleElementSymbol>)current.getProperty(NodeConstants.Info.PROJECT_COLS);
- Select select = new Select(projectedSymbols);
- ExpressionMappingVisitor.mapExpressions(select, exprMap);
- current.setProperty(NodeConstants.Info.PROJECT_COLS, select.getSymbols());
- break;
- }
- case NodeConstants.Types.SOURCE: {
- PlanNode projectNode = NodeEditor.findNodePreOrder(current, NodeConstants.Types.PROJECT);
- List<SingleElementSymbol> projectedSymbols = (List<SingleElementSymbol>)projectNode.getProperty(NodeConstants.Info.PROJECT_COLS);
- SymbolMap symbolMap = SymbolMap.createSymbolMap(current.getGroups().iterator().next(), projectedSymbols);
- current.setProperty(NodeConstants.Info.SYMBOL_MAP, symbolMap);
+ switch (node.getType()) {
+ case NodeConstants.Types.SOURCE:
+ case NodeConstants.Types.GROUP:
return;
- }
- case NodeConstants.Types.SORT: {
- List<SingleElementSymbol> sortCols = (List<SingleElementSymbol>)current.getProperty(NodeConstants.Info.SORT_ORDER);
- OrderBy orderBy = new OrderBy(sortCols);
- ExpressionMappingVisitor.mapExpressions(orderBy, exprMap);
- current.setProperty(NodeConstants.Info.PROJECT_COLS, orderBy.getVariables());
- break;
- }
- case NodeConstants.Types.JOIN: {
- List joinCriteria = (List)current.getProperty(NodeConstants.Info.JOIN_CRITERIA);
- if (joinCriteria != null) {
- CompoundCriteria crit = new CompoundCriteria(joinCriteria);
- ExpressionMappingVisitor.mapExpressions(crit, exprMap);
- current.setProperty(NodeConstants.Info.JOIN_CRITERIA, crit.getCriteria());
- }
- break;
- }
- case NodeConstants.Types.GROUP: {
- List<SingleElementSymbol> groupCols = (List<SingleElementSymbol>)current.getProperty(NodeConstants.Info.GROUP_COLS);
- if (groupCols != null) {
- GroupBy groupBy= new GroupBy(groupCols);
- ExpressionMappingVisitor.mapExpressions(groupBy, exprMap);
- current.setProperty(NodeConstants.Info.GROUP_COLS, groupBy.getSymbols());
- }
- return;
- }
}
- current = current.getParent();
+ node = node.getParent();
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -53,11 +53,9 @@
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.util.ErrorMessageKeys;
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -104,7 +104,7 @@
replacmentSymbol = new ExpressionSymbol(ses.getName(), replacement);
}
- if (alias && createAliases() && !replacmentSymbol.getShortName().equals(ses.getShortName())) {
+ if (alias && createAliases() && !replacmentSymbol.getShortCanonicalName().equals(ses.getShortCanonicalName())) {
replacmentSymbol = new AliasSymbol(ses.getShortName(), replacmentSymbol);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -73,7 +73,6 @@
*/
public class MetaDataProcessor {
-
// Resources
private MetadataService metadataService;
private DQPCore requestManager;
@@ -118,10 +117,18 @@
if(multiModels != null && multiModels.size() > 0) {
this.metadata = new MultiSourceMetadataWrapper(this.metadata, multiModels);
}
+
+ RequestWorkItem workItem = null;
+ try {
+ workItem = requestManager.getRequestWorkItem(requestID);
+ } catch (MetaMatrixProcessingException e) {
+ if (preparedSql == null) {
+ throw e;
+ }
+ }
TempTableStore tempTableStore = null;
if(tempTableStoresHolder != null) {
- RequestWorkItem workItem = requestManager.safeGetWorkItem(requestID);
if (workItem != null) {
tempTableStore = tempTableStoresHolder.getTempTableStore(workContext.getConnectionID());
}
@@ -130,9 +137,8 @@
metadata = new TempMetadataAdapter(this.metadata, tempTableStore.getMetadataStore());
}
- if(preparedSql == null) {
- RequestWorkItem workItem = requestManager.getRequestWorkItem(requestID);
- return getMetadataForCommand(workItem.getOriginalCommand());
+ if(workItem != null) {
+ return getMetadataForCommand(workItem.getOriginalCommand());
}
return obtainMetadataForPreparedSql(preparedSql, workContext, allowDoubleQuotedVariable);
}
@@ -147,9 +153,7 @@
if (((Query)originalCommand).getIsXML()) {
columnMetadata = new Map[1];
columnMetadata[0] = createXMLColumnMetadata((Query)originalCommand);
- } else if (((Query)originalCommand).getInto() != null) {
- columnMetadata = null;
- } else {
+ } else if (((Query)originalCommand).getInto() == null) {
columnMetadata = createProjectedSymbolMetadata(originalCommand);
}
} else {
@@ -164,7 +168,6 @@
case Command.TYPE_DELETE:
case Command.TYPE_CREATE:
case Command.TYPE_DROP:
- columnMetadata = null;
break;
case Command.TYPE_XQUERY:
columnMetadata = new Map[1];
@@ -216,8 +219,7 @@
if(plan != null) {
command = plan.getCommand();
} else {
- QueryParser parser = QueryParser.getQueryParser();
- command = parser.parseCommand(sql, info);
+ command = QueryParser.getQueryParser().parseCommand(sql, info);
QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, this.metadata, AnalysisRecord.createNonRecordingRecord());
}
return getMetadataForCommand(command);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -84,9 +84,6 @@
handleCallableStatement(command);
super.resolveCommand(command);
-
- //save the command in it's present form so that it can be validated later
- prepPlan.setCommand((Command) command.clone());
}
/**
@@ -150,26 +147,24 @@
}
ProcessorPlan cachedPlan = prepPlan.getPlan();
- Command command = prepPlan.getCommand();
if (cachedPlan == null) {
prepPlan.setRewritenCommand(super.generatePlan());
-
if (!this.addedLimit) { //TODO: this is a little problematic
+ prepPlan.setCommand(this.userCommand);
// Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
prepPlan.setPlan((ProcessorPlan)processPlan.clone());
prepPlan.setAnalysisRecord(analysisRecord);
this.prepPlanCache.putPreparedPlan(id, this.context.isSessionFunctionEvaluated(), prepPlan);
}
- command = prepPlan.getCommand();
} else {
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
processPlan = (ProcessorPlan)cachedPlan.clone();
//already in cache. obtain the values from cache
analysisRecord = prepPlan.getAnalysisRecord();
- this.userCommand = command;
- createCommandContext(command);
+ this.userCommand = prepPlan.getCommand();
+ createCommandContext();
}
if (requestMsg.isPreparedBatchUpdate()) {
@@ -178,7 +173,7 @@
List<Reference> params = prepPlan.getReferences();
List<?> values = requestMsg.getParameterValues();
- resolveAndValidateParameters(command, params, values);
+ resolveAndValidateParameters(this.userCommand, params, values);
}
return prepPlan.getRewritenCommand();
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -235,22 +236,22 @@
}
}
- protected void createCommandContext(Command command) throws QueryValidatorException {
+ protected void createCommandContext() throws QueryValidatorException {
boolean returnsResultSet = false;
this.returnsUpdateCount = true;
- if(command instanceof Query) {
- Query query = (Query)command;
+ if(userCommand instanceof Query) {
+ Query query = (Query)userCommand;
returnsResultSet = query.getInto() == null;
returnsUpdateCount = !returnsResultSet;
- } else if (command instanceof SetQuery) {
+ } else if (userCommand instanceof SetQuery) {
returnsResultSet = true;
returnsUpdateCount = false;
- } else if (command instanceof XQuery) {
+ } else if (userCommand instanceof XQuery) {
returnsResultSet = true;
returnsUpdateCount = false;
- } else if (command instanceof StoredProcedure) {
+ } else if (userCommand instanceof StoredProcedure) {
returnsUpdateCount = false;
- StoredProcedure proc = (StoredProcedure)command;
+ StoredProcedure proc = (StoredProcedure)userCommand;
returnsResultSet = proc.returnsResultSet();
}
if (this.requestMsg.getRequireResultSet() != null && this.requestMsg.getRequireResultSet() != returnsResultSet) {
@@ -276,8 +277,8 @@
workContext.getVdbName(),
workContext.getVdbVersion(),
props,
- useProcDebug(command),
- collectNodeStatistics(command));
+ useProcDebug(userCommand),
+ collectNodeStatistics(userCommand));
this.context.setProcessorBatchSize(bufferManager.getProcessorBatchSize());
this.context.setConnectorBatchSize(bufferManager.getConnectorBatchSize());
this.context.setStreamingBatchSize(chunkSize);
@@ -308,7 +309,14 @@
if (this.tempTableStore != null) {
QueryResolver.setChildMetadata(command, tempTableStore.getMetadataStore().getData(), null);
}
+ //ensure that the user command is distinct from the processing command
+ //rewrite and planning may alter options, symbols, etc.
+
+ //TODO clone after the resolve - but that doesn't currently work for exec resolving
+ this.userCommand = (Command)command.clone();
+ QueryResolver.resolveCommand(this.userCommand, Collections.emptyMap(), false, metadata, analysisRecord);
+
QueryResolver.resolveCommand(command, metadata, analysisRecord);
}
@@ -369,7 +377,7 @@
}
}
- protected void createProcessor() throws MetaMatrixComponentException {
+ protected void createProcessor(Command processingCommand) throws MetaMatrixComponentException {
TransactionContext tc = null;
@@ -388,7 +396,7 @@
if(ExecutionProperties.AUTO_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
startAutoWrapTxn = true;
- } else if ( userCommand.updatingModelCount(metadata) > 1) {
+ } else if ( processingCommand.updatingModelCount(metadata) > 1) {
if (ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
String msg = DQPPlugin.Util.getString("Request.txn_needed_wrong_mode", requestId); //$NON-NLS-1$
throw new MetaMatrixComponentException(msg);
@@ -467,14 +475,12 @@
resolveCommand(command);
- createCommandContext(command);
+ createCommandContext();
validateQuery(command, true);
validateQueryValues(command);
- this.userCommand = command;
-
command = QueryRewriter.rewrite(command, null, metadata, context);
/*
@@ -590,13 +596,13 @@
initMetadata();
- generatePlan();
+ Command processingCommand = generatePlan();
validateEntitlement(userCommand);
setSchemasForXMLPlan(userCommand, metadata);
- createProcessor();
+ createProcessor(processingCommand);
}
public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException {
@@ -641,16 +647,7 @@
if (authSvc.checkingEntitlements()) {
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(
this.workContext.getConnectionID(), authSvc);
- if (command.getType() == Command.TYPE_XQUERY) {
- // validate its first level children
- Iterator iter = command.getSubCommands().iterator();
- while (iter.hasNext()) {
- validateWithVisitor(visitor, this.metadata,
- (Command) iter.next(), true);
- }
- } else {
- validateWithVisitor(visitor, this.metadata, command, true);
- }
+ validateWithVisitor(visitor, this.metadata, command, true);
} else if (workContext.getUserName().equals(
AuthorizationService.DEFAULT_WSDL_USERNAME)) {
if (command.getType() == Command.TYPE_STORED_PROCEDURE &&
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -684,7 +684,7 @@
dqpWorkContext.getUserName(),
dqpWorkContext.getVdbName(),
dqpWorkContext.getVdbVersion(),
- (originalCommand != null ? originalCommand.toString() : null ),
+ requestMsg.getCommandString(),
-1);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -359,7 +359,7 @@
Constant expectedConst = new Constant(new Double(10.0));
assertEquals("Did not get expected constant value for SqrtLeft in root node of plan: ", //$NON-NLS-1$
expectedConst,
- ((ExpressionSymbol) ((AliasSymbol) elem.get(8)).getSymbol()).getExpression() // should be a AliasSymbol containing an expression
+ ((ExpressionSymbol)elem.get(8)).getExpression() // should be a AliasSymbol containing an expression
);
}
@@ -427,7 +427,7 @@
Constant expectedConst = new Constant(new Double(10.0));
assertEquals("Did not get expected constant value for SqrtLeft in root node of plan: ", //$NON-NLS-1$
expectedConst,
- ((ExpressionSymbol) ((AliasSymbol) elem.get(8)).getSymbol()).getExpression() // should be a AliasSymbol containing an expression
+ ((ExpressionSymbol) elem.get(8)).getExpression() // should be a AliasSymbol containing an expression
);
assertEquals("Did not get expected constant value for SqrtTop in root node of plan: ", //$NON-NLS-1$
expectedConst,
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -23,6 +23,7 @@
package com.metamatrix.query.sql.visitor;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,6 +32,7 @@
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.CompareCriteria;
+import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetCriteria;
import com.metamatrix.query.sql.symbol.CaseExpression;
import com.metamatrix.query.sql.symbol.Constant;
@@ -163,4 +165,22 @@
helpTest(TestSearchedCaseExpression.example(3), map, mapped);
}
+ /**
+ * We do not need to create an alias if the canonical short names match
+ */
+ public void testSelectAlias() {
+ ElementSymbol x = new ElementSymbol("y.x"); //$NON-NLS-1$
+ ElementSymbol y = new ElementSymbol("z.X"); //$NON-NLS-1$
+
+ HashMap map = new HashMap();
+ map.put(x, y);
+
+ LanguageObject toMap = new Select(Arrays.asList(x));
+
+ ExpressionMappingVisitor.mapExpressions(toMap, map);
+
+ assertEquals("Did not get expected mapped expression", "SELECT z.X", toMap.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -152,7 +152,7 @@
// Initialize components
ApplicationEnvironment env = new ApplicationEnvironment();
env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, null, prepPlanCache, env, null);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env, null);
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-04-22 18:58:59 UTC (rev 827)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -50,6 +50,7 @@
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.TestProcessor;
+import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -218,9 +219,9 @@
workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(conn), "foo")); //$NON-NLS-1$
PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
@Override
- protected void createProcessor()
+ protected void createProcessor(Command processingCommand)
throws MetaMatrixComponentException {
- //don't bother
+
}
};
FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata, "example1", "1", "pm1", "1", "BINDING"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
Added: trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java (rev 0)
+++ trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -0,0 +1,74 @@
+/*
+ * 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 com.metamatrix.jdbc;
+
+import java.util.Map;
+
+import org.teiid.dqp.internal.process.MetaDataProcessor;
+
+import junit.framework.TestCase;
+
+
+/**
+ */
+public class TestResultsMetadataWithProvider extends TestCase {
+
+ /**
+ * Constructor for TestResultsMetadataWithProvider.
+ * @param name
+ */
+ public TestResultsMetadataWithProvider(String name) {
+ super(name);
+ }
+
+ public StaticMetadataProvider exampleProvider() throws Exception {
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ Map col1 = processor.getDefaultColumn("vdb", "1", "table", "col1", String.class); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Map col2 = processor.getDefaultColumn("vdb", "1", "table", "col2", Integer.class); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ Map[] columnMetadata = new Map[] {
+ col1, col2
+ };
+
+ StaticMetadataProvider provider = StaticMetadataProvider.createWithData(columnMetadata, 0);
+ return provider;
+ }
+
+ public void test1() throws Exception {
+ ResultsMetadataWithProvider rmd = new ResultsMetadataWithProvider(exampleProvider());
+
+ assertEquals(false, rmd.isAutoIncrement(1));
+ assertEquals(false, rmd.isCaseSensitive(1));
+ assertEquals(false, rmd.isCurrency(1));
+ assertEquals(true, rmd.isDefinitelyWritable(1));
+ assertEquals(false, rmd.isReadOnly(1));
+ assertEquals(true, rmd.isSearchable(1));
+ assertEquals(true, rmd.isSigned(1));
+ assertEquals(true, rmd.isWritable(1));
+ assertEquals(null, rmd.getCatalogName(1));
+ assertEquals("vdb", rmd.getSchemaName(1)); //$NON-NLS-1$
+ assertEquals("table", rmd.getTableName(1)); //$NON-NLS-1$
+ assertEquals("col1", rmd.getColumnName(1)); //$NON-NLS-1$
+ assertEquals("string", rmd.getColumnTypeName(1)); //$NON-NLS-1$
+ }
+}
Property changes on: trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java (rev 0)
+++ trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java 2009-04-22 20:03:21 UTC (rev 828)
@@ -0,0 +1,108 @@
+/*
+ * 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 com.metamatrix.jdbc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.teiid.dqp.internal.process.MetaDataProcessor;
+
+import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
+
+/**
+ */
+public class TestStaticMetadataProvider extends TestCase {
+
+ /**
+ * Constructor for TestStaticMetadataProvider.
+ * @param name
+ */
+ public TestStaticMetadataProvider(String name) {
+ super(name);
+ }
+
+ private StaticMetadataProvider example1() throws Exception {
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ Map[] columnMetadata = new Map[] {
+ processor.getDefaultColumn("vdb", "1", "table", "c1", String.class), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ processor.getDefaultColumn("vdb", "1", "table", "c2", Integer.class) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ };
+
+ return StaticMetadataProvider.createWithData(columnMetadata, 0);
+ }
+
+ public void testMetadata() throws Exception {
+ StaticMetadataProvider provider = example1();
+ assertEquals(2, provider.getColumnCount());
+
+ for(int i=0; i<provider.getColumnCount(); i++) {
+ assertNotNull(provider.getValue(i, ResultsMetadataConstants.VIRTUAL_DATABASE_NAME));
+ assertNotNull(provider.getValue(i, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION));
+ assertNotNull(provider.getValue(i, ResultsMetadataConstants.GROUP_NAME));
+ assertNotNull(provider.getValue(i, ResultsMetadataConstants.ELEMENT_NAME));
+
+ }
+ }
+
+ public void testGetStringValue() throws Exception {
+ Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
+ String value = "vdb"; //$NON-NLS-1$
+
+ Map columnMetadata = new HashMap();
+ columnMetadata.put(property, value);
+
+ StaticMetadataProvider md = StaticMetadataProvider.createWithData(new Map[] {columnMetadata}, 0);
+
+ String actualValue = md.getStringValue(0, property);
+ assertEquals(value, actualValue);
+ }
+
+ public void testGetIntValue() throws Exception {
+ Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
+ Integer value = new Integer(10); //$NON-NLS-1$
+
+ Map columnMetadata = new HashMap();
+ columnMetadata.put(property, value);
+
+ StaticMetadataProvider md = StaticMetadataProvider.createWithData(new Map[] {columnMetadata}, 0);
+
+ int actualValue = md.getIntValue(0, property);
+ assertEquals(10, actualValue);
+ }
+
+ public void testGetBooleanValue() throws Exception {
+ Integer property = ResultsMetadataConstants.VIRTUAL_DATABASE_NAME;
+ Boolean value = Boolean.TRUE; //$NON-NLS-1$
+
+ Map columnMetadata = new HashMap();
+ columnMetadata.put(property, value);
+
+ StaticMetadataProvider md = StaticMetadataProvider.createWithData(new Map[] {columnMetadata}, 0);
+
+ boolean actualValue = md.getBooleanValue(0, property);
+ assertEquals(true, actualValue);
+ }
+
+}
Property changes on: trunk/test-integration/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 8 months
teiid SVN: r827 - trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-22 14:58:59 -0400 (Wed, 22 Apr 2009)
New Revision: 827
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
Log:
TEIID-472:When Embedded finds a connector type that is not defined in it's own configuration.xml, it is wrong fully removing all the property definitions set by the VDB loader from the connector type that is loaded from file"configurationInfo.def". The correct behaviour should be, look in its configuration if not found, look for its parent and combine its parent and self defined properties to make the correct set of the property definitions.
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-04-22 18:36:11 UTC (rev 826)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-04-22 18:58:59 UTC (rev 827)
@@ -53,6 +53,7 @@
import com.metamatrix.common.config.model.BasicComponentType;
import com.metamatrix.common.config.model.BasicConnectorBinding;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.object.PropertyDefinition;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.util.crypto.CryptoException;
@@ -1108,7 +1109,20 @@
private ComponentType addFullPropertyDefns(ConnectorBindingType type) {
BasicComponentType baseType = (BasicComponentType)type;
- baseType.setComponentTypeDefinitions(this.configurationModel.getAllComponentTypeDefinitions((ComponentTypeID)baseType.getID()));
+ Collection c = this.configurationModel.getAllComponentTypeDefinitions((ComponentTypeID)baseType.getID());
+
+ // if the type is found in the configuration.xml, then add its prop-definitions; else look for parent
+ if (c == null || c.isEmpty()) {
+ // this means user has added a new connector type
+ c = this.configurationModel.getAllComponentTypeDefinitions(type.getSuperComponentTypeID());
+ }
+
+ if (c != null && !c.isEmpty()) {
+ Set<PropertyDefinition> defns = new HashSet<PropertyDefinition>();
+ defns.addAll(c);
+ defns.addAll(type.getComponentTypeDefinitions());
+ baseType.setComponentTypeDefinitions(defns);
+ }
return baseType;
}
15 years, 8 months
teiid SVN: r826 - branches/6.0.x/embedded/src/main/java/com/metamatrix/dqp/embedded/services.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-22 14:36:11 -0400 (Wed, 22 Apr 2009)
New Revision: 826
Modified:
branches/6.0.x/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
Log:
TEIID-472: When Embedded finds a connector type that is not defined in it's own configuration.xml, it is wrong fully removing all the property definitions set by the VDB loader from the connector type that is loaded from file"configurationInfo.def". The correct behaviour should be, look in its configuration if not found, look for its parent and combine its parent and seld defined properties to make the correct set of the property definitions.
Modified: branches/6.0.x/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- branches/6.0.x/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-04-22 18:21:28 UTC (rev 825)
+++ branches/6.0.x/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-04-22 18:36:11 UTC (rev 826)
@@ -53,6 +53,7 @@
import com.metamatrix.common.config.model.BasicComponentType;
import com.metamatrix.common.config.model.BasicConnectorBinding;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.object.PropertyDefinition;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.util.crypto.CryptoException;
@@ -1108,7 +1109,20 @@
private ComponentType addFullPropertyDefns(ConnectorBindingType type) {
BasicComponentType baseType = (BasicComponentType)type;
- baseType.setComponentTypeDefinitions(this.configurationModel.getAllComponentTypeDefinitions((ComponentTypeID)baseType.getID()));
+ Collection c = this.configurationModel.getAllComponentTypeDefinitions((ComponentTypeID)baseType.getID());
+
+ // if the type is found in the configuration.xml, then add its prop-definitions; else look for parent
+ if (c == null || c.isEmpty()) {
+ // this means user has added a new connector type
+ c = this.configurationModel.getAllComponentTypeDefinitions(type.getSuperComponentTypeID());
+ }
+
+ if (c != null && !c.isEmpty()) {
+ Set<PropertyDefinition> defns = new HashSet<PropertyDefinition>();
+ defns.addAll(c);
+ defns.addAll(type.getComponentTypeDefinitions());
+ baseType.setComponentTypeDefinitions(defns);
+ }
return baseType;
}
15 years, 8 months
teiid SVN: r825 - in branches/6.0.x/connectors/connector-jdbc/src: test/java/org/teiid/connector/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-22 14:21:28 -0400 (Wed, 22 Apr 2009)
New Revision: 825
Modified:
branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
branches/6.0.x/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java
Log:
TEIID-505: pulling changes from trunk for consistency for the branch
Modified: branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
===================================================================
--- branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-04-22 17:54:23 UTC (rev 824)
+++ branches/6.0.x/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2009-04-22 18:21:28 UTC (rev 825)
@@ -254,13 +254,13 @@
}
final String url = connectionProps.getProperty(JDBCPropertyNames.URL);
- if (url == null || url.trim().length() == 0) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_database_name_3")); //$NON-NLS-1$
- }
if (temp instanceof Driver) {
final Driver driver = (Driver)temp;
// check URL if there is one
+ if (url == null || url.trim().length() == 0) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_database_name_3")); //$NON-NLS-1$
+ }
validateURL(driver, url);
this.ds = (DataSource)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {DataSource.class}, new InvocationHandler() {
@Override
@@ -289,7 +289,6 @@
}
});
} else {
- parseURL(url, connectionProps);
if (temp instanceof DataSource) {
this.ds = (DataSource)temp;
PropertiesUtils.setBeanProperties(this.ds, connectionProps, null);
@@ -325,57 +324,6 @@
}
}
- /**
- * Parse URL for DataSource connection properties and add to connectionProps.
- * @param url
- * @param connectionProps
- * @throws ConnectorException
- */
- static void parseURL(final String url, final Properties connectionProps) throws ConnectorException {
- // Will be: [jdbc:mmx:dbType://aHost:aPort], [DatabaseName=aDataBase], [CollectionID=aCollectionID], ...
- final String[] urlParts = url.split(";"); //$NON-NLS-1$
-
- // Will be: [jdbc:mmx:dbType:], [aHost:aPort]
- final String[] protoHost = urlParts[0].split("//"); //$NON-NLS-1$
-
- // Will be: [aHost], [aPort]
- final String[] hostPort = protoHost[1].split(":"); //$NON-NLS-1$
- connectionProps.setProperty(XAJDBCPropertyNames.SERVER_NAME, hostPort[0]);
- connectionProps.setProperty(XAJDBCPropertyNames.PORT_NUMBER, hostPort[1]);
-
- // For "databaseName", "SID", and all optional props
- // (<propName1>=<propValue1>;<propName2>=<propValue2>;...)
- for ( int i = 1; i < urlParts.length; i++ ) {
- final String nameVal = urlParts[i];
- // Will be: [propName], [propVal]
- final String[] aProp = nameVal.split("="); //$NON-NLS-1$
- if ( aProp.length > 1) {
- // Set optional prop names lower case so that we can find
- // set method names for them when we introspect the DataSource
- connectionProps.setProperty(aProp[0].toLowerCase(), aProp[1]);
- }
- }
-
- String serverName = connectionProps.getProperty(XAJDBCPropertyNames.SERVER_NAME);
- String serverPort = connectionProps.getProperty(XAJDBCPropertyNames.PORT_NUMBER);
- if ( serverName == null || serverName.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.SERVER_NAME));
- }
- if ( serverPort == null || serverPort.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.PORT_NUMBER));
- }
-
- // Unique resource name for this connector
- final StringBuffer dataSourceResourceName = new StringBuffer(connectionProps.getProperty(XAJDBCPropertyNames.DATASOURCE_NAME, "XADS")); //$NON-NLS-1$
- dataSourceResourceName.append('_');
- dataSourceResourceName.append(serverName);
- dataSourceResourceName.append('_');
- dataSourceResourceName.append(connectionProps.getProperty(ConnectorPropertyNames.CONNECTOR_ID));
- connectionProps.setProperty( XAJDBCPropertyNames.DATASOURCE_NAME, dataSourceResourceName.toString());
- }
-
public int getDefaultTransactionIsolationLevel() {
return this.transIsoLevel;
}
Modified: branches/6.0.x/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java
===================================================================
--- branches/6.0.x/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java 2009-04-22 17:54:23 UTC (rev 824)
+++ branches/6.0.x/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCConnector.java 2009-04-22 18:21:28 UTC (rev 825)
@@ -60,18 +60,4 @@
public void test3() throws Exception {
helpTestMaxIn(1, 1);
}
-
- @Test
- public void testParseUrl() throws ConnectorException {
- String urlWithEmptyProp = "jdbc:mmx:db2://aHost:aPort;DatabaseName=DB2_DataBase;CollectionID=aCollectionID;PackageName=aPackageName;BogusProp=aBogusProp;UnEmptyProp=;"; //$NON-NLS-1$
- Properties props = new Properties();
- JDBCConnector.parseURL(urlWithEmptyProp, props);
-
- assertEquals("aPort", props.getProperty(XAJDBCPropertyNames.PORT_NUMBER)); //$NON-NLS-1$
- assertEquals("aHost", props.getProperty(XAJDBCPropertyNames.SERVER_NAME)); //$NON-NLS-1$
- assertEquals("XADS_aHost_null", props.getProperty(XAJDBCPropertyNames.DATASOURCE_NAME)); //$NON-NLS-1$
- assertEquals("aBogusProp", props.getProperty("bogusprop")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNull(props.getProperty("unemptyprop")); //$NON-NLS-1$
- }
-
}
15 years, 8 months
teiid SVN: r824 - trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-22 13:54:23 -0400 (Wed, 22 Apr 2009)
New Revision: 824
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
Log:
TEIID-444 Per Ramesh, this change fixes the issue with obtaining the ContextCache from the buffersevice, instead of from the proxy.
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-04-22 08:13:51 UTC (rev 823)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-04-22 17:54:23 UTC (rev 824)
@@ -117,7 +117,7 @@
private MetadataService metadataService;
private TrackingService tracker;
private TransactionService transactionService;
- private DQPContextCache contextCache;
+ private BufferService bufferService;
private volatile Boolean started;
@@ -140,6 +140,7 @@
return classloader;
}
+
public SourceCapabilities getCapabilities(RequestID requestID, Serializable executionPayload, DQPWorkContext message) throws ConnectorException {
Connection conn = null;
// Defect 17536 - Set the thread-context classloader to the non-delegating classloader when calling
@@ -162,7 +163,7 @@
requestID.toString(),
"capabilities-request", "0"); //$NON-NLS-1$ //$NON-NLS-2$
- context.setContextCache(this.contextCache);
+ context.setContextCache(getContextCache());
conn = connector.getConnection(context);
caps = conn.getCapabilities();
@@ -325,11 +326,7 @@
this.exceptionOnMaxRows = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.EXCEPTION_ON_MAX_ROWS, false);
this.synchWorkers = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.SYNCH_WORKERS, true);
- BufferService bufferService = (BufferService)env.findService(DQPServiceNames.BUFFER_SERVICE);
- if (bufferService != null) {
- this.contextCache = bufferService.getContextCache();
- }
-
+ this.bufferService = (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE);
// Initialize and start the connector
initStartConnector(connectorEnv);
//check result set cache
@@ -626,7 +623,11 @@
}
DQPContextCache getContextCache() {
- return this.contextCache;
+ if (bufferService != null) {
+ return bufferService.getContextCache();
+ }
+
+ return null;
}
/**
15 years, 8 months