teiid SVN: r1661 - trunk/connector-api/src/main/resources.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-14 13:21:21 -0500 (Mon, 14 Dec 2009)
New Revision: 1661
Modified:
trunk/connector-api/src/main/resources/connector-base.xml
Log:
TEIID-168 removing result set caching from the connectors
Modified: trunk/connector-api/src/main/resources/connector-base.xml
===================================================================
--- trunk/connector-api/src/main/resources/connector-base.xml 2009-12-14 16:45:10 UTC (rev 1660)
+++ trunk/connector-api/src/main/resources/connector-base.xml 2009-12-14 18:21:21 UTC (rev 1661)
@@ -12,13 +12,6 @@
<PropertyDefinition Name="ServiceClassName" DisplayName="Service Class Name" ShortDescription="" DefaultValue="com.metamatrix.server.connector.service.ConnectorService" IsRequired="true" IsModifiable="false" />
<PropertyDefinition Name="MaxResultRows" DisplayName="Maximum Result Rows" ShortDescription="" DefaultValue="10000" IsRequired="true" PropertyType="Integer" IsExpert="true" />
<PropertyDefinition Name="SynchWorkers" DisplayName="Synchronous Workers" ShortDescription="Whether worker threads will be bound to connections. Asynch connectors should set this value to false." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
- <PropertyDefinition Name="ResultSetCacheEnabled" DisplayName="ResultSet Cache Enabled" ShortDescription="" DefaultValue="false" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
- <PropertyDefinition Name="ResultSetCacheMaxSize" DisplayName="ResultSet Cache Maximum Size (megabytes)" ShortDescription="" DefaultValue="20" PropertyType="Integer" IsExpert="true" />
- <PropertyDefinition Name="ResultSetCacheMaxAge" DisplayName="ResultSet Cache Maximum Age (milliseconds)" ShortDescription="" DefaultValue="3600000" PropertyType="Long" IsExpert="true" />
- <PropertyDefinition Name="ResultSetCacheScope" DisplayName="ResultSet Cache Scope" ShortDescription="" DefaultValue="vdb" IsExpert="true">
- <AllowedValue>vdb</AllowedValue>
- <AllowedValue>session</AllowedValue>
- </PropertyDefinition>
<PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Set to true if this is an XA Connector" DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
<PropertyDefinition Name="ConnectionPoolEnabled" DisplayName="Connection Pool Enabled" ShortDescription="Enable the use of connection pooling with this connector." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
<PropertyDefinition Name="UseCredentialMap" DisplayName="Requires Credential Map" ShortDescription="Set to true if this connector requires credentials to be passed via a credential map." DefaultValue="false" IsRequired="true" PropertyType="Boolean" IsExpert="true" IsMasked="false" />
15 years
teiid SVN: r1660 - in branches/JCA: common-internal/src/main/java/com/metamatrix/platform/security/api and 9 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-14 11:45:10 -0500 (Mon, 14 Dec 2009)
New Revision: 1660
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
branches/JCA/engine/src/main/java/org/teiid/cache/
branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
Log:
TEIID-833: adding VDB deployer
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+import java.io.Serializable;
+
+public enum Visibility implements Serializable{
+ PUBLIC,PRIVATE;
+}
\ No newline at end of file
Added: branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
===================================================================
--- branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java (rev 0)
+++ branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,36 @@
+/*
+ * 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.platform.security.api;
+
+import java.util.Collection;
+
+public class AuthorizationPoliciesHolder {
+ private Collection<AuthorizationPolicy> policies;
+
+ public void setAuthorizationPolicies(Collection<AuthorizationPolicy> policies) {
+ this.policies = policies;
+ }
+
+ public Collection<AuthorizationPolicy> getAuthorizationPolicies(){
+ return this.policies;
+ }
+}
Added: branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
===================================================================
(Binary files differ)
Property changes on: branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java (rev 0)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,29 @@
+package com.metamatrix.common.comm;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class ClientServiceRegistryImpl implements ClientServiceRegistry{
+
+ private ConcurrentHashMap<String, Object> localServices = new ConcurrentHashMap<String, Object>();
+ private ConcurrentHashMap<String, String> loggingContext = new ConcurrentHashMap<String, String>();
+
+ public ClientServiceRegistryImpl() {
+ }
+
+ public <T> T getClientService(Class<T> iface) {
+ return (T)this.localServices.get(iface.getName());
+ }
+
+ public Object getClientService(String iface) {
+ return localServices.get(iface);
+ }
+
+ public <T> void registerClientService(Class<T> iface, T instance, String loggingContext) {
+ this.localServices.put(iface.getName(), instance);
+ this.loggingContext.put(iface.getName(), loggingContext);
+ }
+
+ public String getLoggingContextForService(String iface) {
+ return this.loggingContext.get(iface);
+ }
+}
Added: branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.metamatrix.cache.Cache;
+import com.metamatrix.cache.CacheConfiguration;
+import com.metamatrix.cache.CacheFactory;
+import com.metamatrix.cache.CacheListener;
+import com.metamatrix.cache.Cache.Type;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DefaultCacheFactory implements CacheFactory, Serializable {
+ private static final long serialVersionUID = -5541424157695857527L;
+
+ DefaultCache cacheRoot = new DefaultCache("Teiid");
+ private volatile boolean destroyed = false;
+
+ @Override
+ public void destroy() {
+ this.destroyed = true;
+ }
+
+ @Override
+ public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ if (!destroyed) {
+ Cache node = cacheRoot.addChild(type.location());
+ return node;
+ }
+ throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
+ }
+
+ class DefaultCache<K, V> implements Cache<K, V>, Serializable {
+ Map<K, V> map = new HashMap();
+ Map<String, Cache> children = new HashMap();
+ String name;
+
+ public DefaultCache(String name) {
+ this.name = name;
+ }
+ public void addListener(CacheListener listener) {
+ }
+
+ public void clear() {
+ map.clear();
+ }
+
+ public V get(K key) {
+ return map.get(key);
+ }
+
+ public Set<K> keySet() {
+ return map.keySet();
+ }
+
+ public V put(K key, V value) {
+ return map.put(key, value);
+ }
+
+ public V remove(K key) {
+ return map.remove(key);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public Collection<V> values() {
+ return map.values();
+ }
+
+ @Override
+ public void removeListener() {
+ }
+
+ @Override
+ public Cache addChild(String name) {
+ if (children.get(name) != null) {
+ return children.get(name);
+ }
+
+ Cache c = new DefaultCache(name);
+ children.put(name, c);
+ return c;
+ }
+
+ @Override
+ public Cache getChild(String name) {
+ return children.get(name);
+ }
+
+ @Override
+ public List<Cache> getChildren() {
+ return new ArrayList<Cache>(children.values());
+ }
+
+ @Override
+ public boolean removeChild(String name) {
+ Object obj = children.remove(name);
+ return obj != null;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
+
+}
Added: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class ConnectorManagerRepository implements Serializable{
+ private static final long serialVersionUID = -1611063218178314458L;
+
+ private Map<String, ConnectorManager> repo = new ConcurrentHashMap<String, ConnectorManager>();
+
+ public void addConnectorManager(String connectorName, ConnectorManager mgr) {
+ this.repo.put(connectorName, mgr);
+ }
+
+ public ConnectorManager getConnectorManager(String connectorName) {
+ return this.repo.get(connectorName);
+ }
+
+ public ConnectorManager removeConnectorManager(String connectorName) {
+ return this.repo.remove(connectorName);
+ }
+}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.jboss.deployers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+
+public class ConnectorBindingDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
+ protected Logger log = Logger.getLogger(getClass());
+ private ManagedObjectFactory mof;
+
+ private ConnectorManagerRepository connectorManagerRepository;
+
+ public ConnectorBindingDeployer() {
+ super(ManagedConnectionFactoryDeploymentGroup.class);
+ setRelativeOrder(3000);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ ConnectorManagerGroup cmGroup = new ConnectorManagerGroup();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorDefinition = data.getConnectionDefinition();
+ if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
+ String connectorName = data.getJndiName();
+
+ ConnectorManager cm = null;
+ try {
+ cm = createConnectorManger("java:"+connectorName);
+ cm.start();
+ cmGroup.addConnectorManager(cm);
+ } catch (ApplicationLifecycleException e) {
+ throw new DeploymentException(e);
+ }
+
+ // Add the references to the mgr as loaded.
+ this.connectorManagerRepository.addConnectorManager("java:"+connectorName, cm);
+
+ log.info("Teiid Connector Started = " + connectorName); //$NON-NLS-1$
+ }
+ }
+
+ if (!cmGroup.getConnectorManagers().isEmpty()) {
+ unit.addAttachment(ConnectorManagerGroup.class, cmGroup);
+ }
+ }
+
+
+ ConnectorManager createConnectorManger(String deployedConnectorName) {
+ ConnectorManager mgr = new ConnectorManager(deployedConnectorName);
+ return mgr;
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.connectorManagerRepository = repo;
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
+ super.undeploy(unit, group);
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorDefinition = data.getConnectionDefinition();
+ if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
+ String connectorName = data.getJndiName();
+ ConnectorManager cm = this.connectorManagerRepository.removeConnectorManager("java:"+connectorName);
+ if (cm != null) {
+ cm.stop();
+ }
+ log.info("Teiid Connector Stopped = " + connectorName); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
+ throws DeploymentException {
+ //TODO: Need to link CM--> CB as management objects. rareddy
+ // ConnectorManagerGroup cmGroup = unit.removeAttachment(ConnectorManagerGroup.class);
+ // if (cmGroup != null) {
+ // for (ConnectorManager mgr:cmGroup.getConnectorManagers()) {
+ // ManagedObject mo = this.mof.initManagedObject(mgr, ConnectorManager.class, mgr.getName(), mgr.getName());
+ // if (mo == null) {
+ // throw new DeploymentException("could not create managed object");
+ // }
+ // managedObjects.put(mo.getName(), mo);
+ // }
+ // }
+ }
+
+
+ public void setManagedObjectFactory(ManagedObjectFactory mof) {
+ this.mof = mof;
+ }
+}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jboss.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+
+public class ConnectorManagerGroup {
+ private List<ConnectorManager> mgrs = new ArrayList<ConnectorManager>();
+
+ public void addConnectorManager(ConnectorManager cm) {
+ this.mgrs.add(cm);
+ }
+
+ public List<ConnectorManager> getConnectorManagers(){
+ return this.mgrs;
+ }
+}
Added: branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
===================================================================
--- branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java (rev 0)
+++ branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.virtual.VirtualFile;
+
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+public class VirtualRandomAccessFile {
+ File indexFile;
+ String mode;
+
+ public VirtualRandomAccessFile(VirtualFile file, String mode) throws IOException{
+ this.indexFile = File.createTempFile(file.getName(), null);
+ ObjectConverterUtil.write(file.openStream(), indexFile);
+ this.mode = mode;
+ }
+
+ public SafeRandomAccessFile getSafeRandomAccessFile() throws IOException {
+ return new SafeRandomAccessFile(indexFile, mode);
+ }
+
+ public void close() {
+ indexFile.delete();
+ }
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.deployers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.vfs.spi.deployer.MultipleVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Overriding the base MultipleVFSParsingDeployer so that the parse method is supplied with VFSDeploymentUnit.
+ * @param <T>
+ */
+public abstract class BaseMultipleVFSParsingDeployer<T> extends MultipleVFSParsingDeployer<T> {
+
+ public BaseMultipleVFSParsingDeployer(Class<T> output,Map<String, Class<?>> mappings, String suffix, Class<?> suffixClass) {
+ super(output, mappings, suffix, suffixClass);
+ }
+
+ public BaseMultipleVFSParsingDeployer(Class<T> output,Map<String, Class<?>> mappings) {
+ super(output, mappings);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected T mergeFiles(VFSDeploymentUnit unit, T root,List<VirtualFile> files, Set<String> missingFiles) throws Exception {
+ Map<Class<?>, List<Object>> metadata = new HashMap<Class<?>, List<Object>>();
+ for (VirtualFile file : files) {
+ Class<?> clazz = matchFileToClass(unit, file);
+ List<Object> instances = metadata.get(clazz);
+ if (instances == null) {
+ instances = new ArrayList<Object>();
+ metadata.put(clazz, instances);
+ }
+ Object instance = parse(unit, clazz, file, root);
+ instances.add(instance);
+ }
+ return mergeMetaData(unit, root, metadata, missingFiles);
+ }
+
+ @Override
+ protected <U> U parse(Class<U> expectedType, VirtualFile file, Object root) throws Exception{
+ throw new UnsupportedOperationException("This will be never invoked");
+ }
+ protected abstract <U> U parse(VFSDeploymentUnit unit, Class<U> expectedType, VirtualFile file, Object root) throws Exception;
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.Visibility;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+import com.metamatrix.core.vdb.ModelType;
+
+public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
+
+ public DynamicVDBDeployer() {
+ super(VDBMetaData.class);
+ setSuffix("-vdb.xml");
+ }
+
+ @Override
+ protected VDBMetaData parse(VFSDeploymentUnit unit, VirtualFile file, VDBMetaData root) throws Exception {
+ VDBMetaData def = DefParser.load(file.openStream());
+
+ // Set the additional model properties which are traditionally on the VDB based Models.
+ for(ModelMetaData model:def.getModels()) {
+ model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+ model.setVisibility(Visibility.PUBLIC);
+ model.setSupportsMultiSourceBindings(false);
+ }
+
+ def.setUrl(unit.getRoot().toURL());
+ log.debug("VDB "+unit.getRoot().getName()+" has been parsed.");
+ return def;
+ }
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2009-12-14 16:45:10 UTC (rev 1660)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.deployers;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.plugins.context.zip.ZipEntryContext;
+import org.teiid.adminapi.Visibility;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.metadata.index.IndexConstants;
+import org.teiid.metadata.index.IndexMetadataFactory;
+
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class SystemVDBDeployer {
+ private VDBRepository vdbRepository;
+
+
+ public void start() {
+ ModelMetaData model = new ModelMetaData();
+ model.setName(CoreConstants.SYSTEM_MODEL);
+ model.setVisibility(Visibility.PUBLIC);
+
+ VDBMetaData deployment = new VDBMetaData();
+ deployment.setName(CoreConstants.SYSTEM_VDB);
+
+ deployment.addModel(model);
+
+ try {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB);
+ if (url == null) {
+ throw new MetaMatrixRuntimeException("System.vdb not found in classpath");
+ }
+ SystemVDBContext systemVDB = new SystemVDBContext(url);
+ VirtualFile vdb = new VirtualFile(systemVDB.getRoot());
+ List<VirtualFile> children = vdb.getChildrenRecursively(new VirtualFileFilter() {
+ @Override
+ public boolean accepts(VirtualFile file) {
+ return file.getName().endsWith(IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT);
+ }
+ });
+
+ IndexMetadataFactory imf = new IndexMetadataFactory();
+ for (VirtualFile f: children) {
+ imf.addIndexFile(f);
+ }
+ this.vdbRepository.addMetadataStore(deployment, imf.getMetadataStore());
+ } catch (URISyntaxException e) {
+ throw new MetaMatrixRuntimeException(e, "Failed to deploy "+CoreConstants.SYSTEM_VDB);
+ } catch (IOException e) {
+ throw new MetaMatrixRuntimeException(e, "Failed to deploy "+CoreConstants.SYSTEM_VDB);
+ }
+ }
+
+ public void stop() {
+ this.vdbRepository.removeVDB(CoreConstants.SYSTEM_VDB, 1);
+ }
+
+ public void setVDBRepository(VDBRepository repo) {
+ this.vdbRepository = repo;
+ }
+
+ private static class SystemVDBContext extends ZipEntryContext{
+ private static final long serialVersionUID = -6504988258841073415L;
+
+ protected SystemVDBContext(URL url) throws IOException, URISyntaxException {
+ super(url,true);
+ }
+ }
+}
15 years
teiid SVN: r1656 - in trunk/engine/src: main/java/com/metamatrix/query/optimizer/relational/rules and 9 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-11 18:05:15 -0500 (Fri, 11 Dec 2009)
New Revision: 1656
Added:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
Log:
TEIID-900 changing to more uniformly propagate the no cache hint and to make the table specific no cache apply only to one level
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -445,7 +445,7 @@
if(command instanceof Insert){
Insert insert = (Insert)command;
if (insert.getQueryExpression() != null) {
- PlanNode plan = createQueryPlan(insert.getQueryExpression());
+ PlanNode plan = generatePlan(insert.getQueryExpression());
attachLast(sourceNode, plan);
mergeTempMetadata(insert.getQueryExpression(), insert);
projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
@@ -694,16 +694,14 @@
MetaMatrixComponentException, QueryResolverException,
QueryValidatorException, QueryMetadataException {
if (nestedCommand instanceof QueryCommand) {
+ //remove unnecessary order by
QueryCommand queryCommand = (QueryCommand)nestedCommand;
if (queryCommand.getLimit() == null) {
queryCommand.setOrderBy(null);
}
}
node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
- // Create symbol map from virtual group to child plan
- List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
- node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group, projectCols));
-
+
if (merge && nestedCommand instanceof Query && QueryResolver.isXMLQuery((Query)nestedCommand, metadata)) {
merge = false;
}
@@ -712,6 +710,8 @@
mergeTempMetadata(nestedCommand, parentCommand);
PlanNode childRoot = generatePlan(nestedCommand);
node.addFirstChild(childRoot);
+ List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
+ node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group, projectCols, metadata));
} else {
QueryMetadataInterface actualMetadata = metadata;
if (actualMetadata instanceof TempMetadataAdapter) {
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-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -208,7 +208,20 @@
//update the parent plan with the staged aggregates and the new projected symbols
List<SingleElementSymbol> projectedViewSymbols = (List<SingleElementSymbol>)NodeEditor.findNodePreOrder(child, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- SymbolMap newParentMap = SymbolMap.createSymbolMap(child.getGroups().iterator().next(), projectedViewSymbols);
+ List<ElementSymbol> updatedVirturalElement = new ArrayList<ElementSymbol>(virtualElements);
+
+ //hack to introduce aggregate symbols to the parent view TODO: this should change the metadata properly.
+ GroupSymbol virtualGroup = child.getGroups().iterator().next();
+ for (int i = updatedVirturalElement.size(); i < projectedViewSymbols.size(); i++) {
+ SingleElementSymbol symbol = projectedViewSymbols.get(i);
+ String name = symbol.getShortName();
+ String virtualElementName = virtualGroup.getCanonicalName() + ElementSymbol.SEPARATOR + name;
+ ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
+ virtualElement.setGroupSymbol(virtualGroup);
+ virtualElement.setType(symbol.getType());
+ updatedVirturalElement.add(virtualElement);
+ }
+ SymbolMap newParentMap = SymbolMap.createSymbolMap(updatedVirturalElement, projectedViewSymbols);
child.setProperty(NodeConstants.Info.SYMBOL_MAP, newParentMap);
Map<AggregateSymbol, ElementSymbol> projectedMap = new HashMap<AggregateSymbol, ElementSymbol>();
Iterator<AggregateSymbol> aggIter = aggregates.iterator();
@@ -303,7 +316,7 @@
List<SingleElementSymbol> projectedViewSymbols = QueryRewriter.deepClone(projectedSymbols, SingleElementSymbol.class);
- SymbolMap viewMapping = SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource, NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols);
+ SymbolMap viewMapping = SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource, NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols, metadata);
for (AggregateSymbol agg : aggregates) {
agg = (AggregateSymbol)agg.clone();
ExpressionMappingVisitor.mapExpressions(agg, viewMapping.asMap());
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -415,7 +414,7 @@
Criteria crit = (Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- Collection elements = getElementsIncriteria(crit);
+ Collection<ElementSymbol> elements = getElementsIncriteria(crit);
boolean removeAps = satisfyAccessPatterns(aps, elements);
if (removeAps) {
@@ -426,8 +425,8 @@
Collections.sort(aps);
}
- static Collection getElementsIncriteria(Criteria crit) {
- Collection elements = new HashSet();
+ static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) {
+ Collection<ElementSymbol> elements = new HashSet<ElementSymbol>();
boolean first = true;
if(crit instanceof CompoundCriteria) {
CompoundCriteria compCrit = (CompoundCriteria) crit;
@@ -450,7 +449,7 @@
* @param elements
* @return
*/
- static boolean satisfyAccessPatterns(List<AccessPattern> aps, Collection elements) {
+ static boolean satisfyAccessPatterns(List<AccessPattern> aps, Collection<ElementSymbol> elements) {
for (AccessPattern ap : aps) {
ap.getUnsatisfied().removeAll(elements);
if (ap.getUnsatisfied().isEmpty()) {
@@ -484,39 +483,28 @@
satisfyAccessPatterns(critNode, sourceNode);
SymbolMap symbolMap = (SymbolMap) sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
-
+ SymbolMap childMap = symbolMap;
+
// Move criteria to first child of union - names are the same, so no symbol mapping
- LinkedList unionChildren = new LinkedList();
+ LinkedList<PlanNode> unionChildren = new LinkedList<PlanNode>();
collectUnionChildren(setOp, unionChildren);
int movedCount = 0;
- Iterator childIter = unionChildren.iterator();
- PlanNode firstChild = (PlanNode) childIter.next();
- GroupSymbol sourceGroup = sourceNode.getGroups().iterator().next();
-
- PlanNode firstBranchNode = NodeEditor.findNodePreOrder(firstChild, NodeConstants.Types.PROJECT);
-
- if(createConvertedSelectNode(critNode, virtualGroup, firstBranchNode, symbolMap)) {
- movedCount++;
- }
- // Find project cols on first branch
- List firstProjectCols = (List) firstBranchNode.getProperty(NodeConstants.Info.PROJECT_COLS);
-
- // For each of the remaining children of the union, push separately
- while(childIter.hasNext()) {
- PlanNode childNode = (PlanNode) childIter.next();
-
+ for (PlanNode planNode : unionChildren) {
// Find first project node
- PlanNode projectNode = NodeEditor.findNodePreOrder(childNode, NodeConstants.Types.PROJECT);
+ PlanNode projectNode = NodeEditor.findNodePreOrder(planNode, NodeConstants.Types.PROJECT);
- // Create symbol map
- symbolMap = SymbolMap.createSymbolMap(sourceGroup, firstProjectCols, (List) projectNode.getProperty(NodeConstants.Info.PROJECT_COLS));
+ if (childMap == null) {
+ childMap = SymbolMap.createSymbolMap(symbolMap.getKeys(), (List) projectNode.getProperty(NodeConstants.Info.PROJECT_COLS));
+ }
// Move the node
- if(createConvertedSelectNode(critNode, virtualGroup, projectNode, symbolMap)) {
+ if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap)) {
movedCount++;
}
+
+ childMap = null; //create a new symbol map for the other children
}
//TODO - the logic here could be made more intelligent about EXCEPT and INTERSECT.
@@ -588,7 +576,7 @@
return false;
}
- Collection scalarSubqueries = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(converted);
+ Collection<SubqueryContainer> scalarSubqueries = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(converted);
if (!scalarSubqueries.isEmpty()){
return false;
}
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-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -113,7 +113,7 @@
// then in the query transformation, this info is used in evaluating/validating
// has criteria/translate criteria clauses
Command transformCmd = getQueryTransformCmd(virtualGroup, metadata);
- Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, (List<SingleElementSymbol>)transformCmd.getProjectedSymbols()).asMap();
+ Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, (List<SingleElementSymbol>)transformCmd.getProjectedSymbols(), metadata).asMap();
procCommand.setSymbolMap(symbolMap);
}
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-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -551,18 +551,6 @@
return groupInfo;
}
- public static List resolveElements(GroupSymbol group, QueryMetadataInterface metadata, List elementIDs) throws MetaMatrixComponentException, QueryMetadataException {
- GroupInfo groupInfo = getGroupInfo(group, metadata);
- List result = new ArrayList(elementIDs.size());
- for (Iterator iterator = elementIDs.iterator(); iterator.hasNext();) {
- Object id = iterator.next();
- ElementSymbol symbol = groupInfo.getSymbol(id);
- assert symbol != null;
- result.add(symbol);
- }
- return result;
- }
-
/**
* When access patterns are flattened, they are an approximation the user
* may need to enter as criteria.
@@ -590,11 +578,18 @@
}
while (j.hasNext()) {
List elements = metadata.getElementIDsInAccessPattern(j.next());
- elements = resolveElements(group, metadata, elements);
+ GroupInfo groupInfo = getGroupInfo(group, metadata);
+ List result = new ArrayList(elements.size());
+ for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+ Object id = iterator.next();
+ ElementSymbol symbol = groupInfo.getSymbol(id);
+ assert symbol != null;
+ result.add(symbol);
+ }
if (flatten) {
- accessPatterns.addAll(elements);
+ accessPatterns.addAll(result);
} else {
- accessPatterns.add(new AccessPattern(elements));
+ accessPatterns.add(new AccessPattern(result));
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -26,11 +26,14 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.core.util.Assertion;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -100,27 +103,10 @@
}
public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends SingleElementSymbol> projectCols) {
- return createSymbolMap(virtualGroup, projectCols, projectCols);
+ List<? extends SingleElementSymbol> projectCols, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ return createSymbolMap(ResolverUtil.resolveElementsInGroup(virtualGroup, metadata), projectCols);
}
- public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends SingleElementSymbol> projectCols,
- List<? extends SingleElementSymbol> mappedCols) {
- String virtualGroupName = virtualGroup.getName();
- List<ElementSymbol> virtualElements = new LinkedList<ElementSymbol>();
- for (SingleElementSymbol symbol : projectCols) {
- String name = symbol.getShortName();
- String virtualElementName = virtualGroupName + ElementSymbol.SEPARATOR + name;
- ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
- virtualElement.setGroupSymbol(virtualGroup);
- virtualElement.setType(symbol.getType());
- virtualElements.add(virtualElement);
- }
-
- return createSymbolMap(virtualElements, mappedCols);
- }
-
public static final SymbolMap createSymbolMap(List<ElementSymbol> virtualElements,
List<? extends Expression> mappedCols) {
Assertion.assertTrue(virtualElements.size() == mappedCols.size());
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -48,9 +48,9 @@
super();
// Load some default VDBs
- addVdb(null, null, FakeMetadataFactory.exampleBQT());
- addVdb("bqt", "1", FakeMetadataFactory.exampleBQT()); //$NON-NLS-1$ //$NON-NLS-2$
- addVdb("example1", "1", FakeMetadataFactory.example1()); //$NON-NLS-1$ //$NON-NLS-2$
+ addVdb(null, null, FakeMetadataFactory.exampleBQTCached());
+ addVdb("bqt", "1", FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$ //$NON-NLS-2$
+ addVdb("example1", "1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
}
private String getKey(String vdbName, String vdbVersion) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -22,7 +22,7 @@
package com.metamatrix.query.optimizer;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -31,69 +31,69 @@
import com.metamatrix.query.validator.TestValidator;
-public class TestAccessPatterns extends TestCase {
+public class TestAccessPatterns {
/**
* The virtual access patterns should get satisfied
*/
- public void testVirtualAccessPatternPassing() {
+ @Test public void testVirtualAccessPatternPassing() {
String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1 and e1='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT test.\"group\".e0, test.\"group\".e2 FROM test.\"group\" WHERE (test.\"group\".e0 = 1) AND (test.\"group\".e1 = '2')"}); //$NON-NLS-1$
}
- public void testVirtualAccessPatternPassing1() {
+ @Test public void testVirtualAccessPatternPassing1() {
String sql = "delete from vm1.g37 where e1 = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
}
- public void testVirtualAccessPatternFailing() {
+ @Test public void testVirtualAccessPatternFailing() {
String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testVirtualAccessPatternFailing1() {
+ @Test public void testVirtualAccessPatternFailing1() {
String sql = "delete from vm1.g37"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern1() throws Exception {
+ @Test public void testAccessPattern1() throws Exception {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql,
TestValidator.exampleMetadata4(),
new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
}
- public void testAccessPattern2() {
+ @Test public void testAccessPattern2() {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern3() {
+ @Test public void testAccessPattern3() {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e2='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern4() throws Exception {
+ @Test public void testAccessPattern4() throws Exception {
String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
}
- public void testAccessPattern5() {
+ @Test public void testAccessPattern5() {
String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern6() {
+ @Test public void testAccessPattern6() {
String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT e1, e0, e2 FROM test.\"group\""}); //$NON-NLS-1$
}
- public void testAccessPattern7() {
+ @Test public void testAccessPattern7() {
String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern8() {
+ @Test public void testAccessPattern8() {
String sql = "SELECT e0, e2 FROM vTest.vGroup"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
}
@@ -102,7 +102,7 @@
* Tests two access nodes, each with access patterns, but one already
* satisfied by user criteria - the other should be made dependent
*/
- public void testNodesBothHaveAccessPatterns1() throws Exception {
+ @Test public void testNodesBothHaveAccessPatterns1() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g2 where pm4.g2.e5 = 'abc' and pm4.g1.e1 = pm4.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
@@ -113,7 +113,7 @@
* satisfied by user criteria - the other should be made dependent
* (same query written slightly different).
*/
- public void testNodesBothHaveAccessPatterns1a() throws Exception {
+ @Test public void testNodesBothHaveAccessPatterns1a() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g2, pm4.g1 where pm4.g2.e1 = pm4.g1.e1 and pm4.g2.e5 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
@@ -123,7 +123,7 @@
* Self join - tests that both access nodes are satisfied by the select
* criteria (therefore merge join should be used)
*/
- public void testSelfJoinAccessPatterns() throws Exception {
+ @Test public void testSelfJoinAccessPatterns() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g1 as g1A where pm4.g1.e1 = 'abc' and g1A.e1 = 'abc' and pm4.g1.e2 = g1A.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g1A.e2 FROM pm4.g1 AS g1A WHERE g1A.e1 = 'abc'", "SELECT pm4.g1.e2, pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
@@ -145,41 +145,41 @@
});
}
- public void testAccessPatternsFails() {
+ @Test public void testAccessPatternsFails() {
TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2, pm4.g2 as g2A where pm4.g2.e2 = 123 and pm4.g2.e1 = g2A.e5", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPatternsFails2() {
+ @Test public void testAccessPatternsFails2() {
TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPatternFails() {
+ @Test public void testUnionWithAccessPatternFails() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1 where pm4.g1.e2 = 1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPatternFails2() {
+ @Test public void testUnionWithAccessPatternFails2() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPattern() {
+ @Test public void testUnionWithAccessPattern() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testUnionWithAccessPattern2() {
+ @Test public void testUnionWithAccessPattern2() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc' and pm4.g1.e2 = 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE (pm4.g1.e1 = 'abc') AND (pm4.g1.e2 = 1)" }); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testAccessPatternPartialMatch() throws Exception {
+ @Test public void testAccessPatternPartialMatch() throws Exception {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 and pm4.g2.e2 = 123", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
new String[] { "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE (g_0.e2 = 123) AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
@@ -190,7 +190,7 @@
* completely different query plan which can't satisfy the access pattern.
* @see #testAccessPatternPartialMatch
*/
- public void testAccessPatternFails3() {
+ @Test public void testAccessPatternFails3() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 or pm4.g2.e2 = 123", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null,
@@ -201,7 +201,7 @@
* Access patterns on models that support joins requires that the access patterns are satisfied prior to
* RulePlanJoins
*/
- public void testAccessPatternsGroupsInSameModelFails() {
+ @Test public void testAccessPatternsGroupsInSameModelFails() {
TestOptimizer.helpPlan("select pm5.g1.e1 from pm5.g1, pm5.g2 where pm5.g1.e1 = pm5.g2.e1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
@@ -211,7 +211,7 @@
// ACCESS PATTERNS
// ==================================================================================
- public void testPushingCriteriaThroughFrameAccessPattern0() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern0() {
TestOptimizer.helpPlan("select * from vm1.g9 where vm1.g9.e1='abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
@@ -220,17 +220,17 @@
/**
* pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
*/
- public void testPushingCriteriaThroughFrameAccessPattern1() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern1() {
TestOptimizer.helpPlan("select * from vm1.g1, vm1.g10 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g10.e1", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
null, TestOptimizer.SHOULD_FAIL );
}
- public void testPushingCriteriaThroughFrameAccessPattern2() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern2() {
TestOptimizer.helpPlan("select e1 from vm1.g11 where vm1.g11.e1='abc' and vm1.g11.e2=123", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm4.g2.e1 FROM pm4.g2 WHERE (pm4.g2.e1 = 'abc') AND (pm4.g2.e2 = 123)" }); //$NON-NLS-1$
}
- public void testPushingCriteriaThroughFrameAccessPattern3() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern3() {
TestOptimizer.helpPlan("select * from vm1.g1, vm1.g9 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g9.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {"SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
@@ -240,7 +240,7 @@
/**
* pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
*/
- public void testPushingCriteriaThroughFrameAccessPattern4() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern4() {
TestOptimizer.helpPlan("select * from vm1.g10 where vm1.g10.e1='abc'", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
null, TestOptimizer.SHOULD_FAIL );
}
@@ -248,7 +248,7 @@
/**
* TODO: in this case we should perform a criteria optimization to create set criteria
*/
- public void testCase6425() {
+ @Test public void testCase6425() {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e1 = '2'"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -258,7 +258,7 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- public void testCase6425_2() {
+ @Test public void testCase6425_2() {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR (e1 = '2' AND e2 = 3)"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -268,7 +268,7 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- public void testCase6425_4() throws Exception {
+ @Test public void testCase6425_4() throws Exception {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e2 = '2'"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -279,7 +279,7 @@
/*
* Criteria was preventing rule choose dependent from creating the appropriate dependent join
*/
- public void testMultiAccessPatternWithCriteria() throws Exception {
+ @Test public void testMultiAccessPatternWithCriteria() throws Exception {
String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' "; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -23,7 +23,6 @@
package com.metamatrix.query.optimizer;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -41,7 +40,6 @@
import com.metamatrix.query.processor.relational.RelationalNode;
import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
import com.metamatrix.query.unittest.FakeMetadataFacade;
@@ -137,13 +135,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestOptimizer.helpGetCommand("select pm1.g1.e1 from pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), Collections.EMPTY_LIST); //$NON-NLS-1$
-
- Option option = new Option();
- option.addDependentGroup("pm2.g1"); //$NON-NLS-1$
- command.setOption(option);
-
- ProcessorPlan plan = TestOptimizer.helpPlanCommand(command, FakeMetadataFactory.example1Cached(), capFinder,
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1 option makedep pm2.g1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
checkDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
@@ -173,11 +165,9 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestOptimizer.helpGetCommand("select pm1.g1.e1, pm2.g1.e1 from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), Collections.EMPTY_LIST); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1, pm2.g1.e1 from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- ProcessorPlan plan = TestOptimizer.helpPlanCommand(command, FakeMetadataFactory.example1Cached(), capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
checkNotDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -22,44 +22,72 @@
package com.metamatrix.query.optimizer;
+import static com.metamatrix.query.optimizer.TestOptimizer.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
+import org.junit.Test;
+import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
-public class TestInlineView extends TestCase {
+public class TestInlineView {
+
+ public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
- public void testANSIJoinInlineView() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ caps.setFunctionSupport("case", true); //$NON-NLS-1$
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ return metadata;
+ }
+
+ @Test public void testANSIJoinInlineView() throws Exception {
runTest(createANSIJoinInlineView());
}
- public void testInlineView() throws Exception {
+ @Test public void testInlineView() throws Exception {
runTest(createInlineView());
}
- public void testInlineViewWithDistinctAndOrderBy() throws Exception {
+ @Test public void testInlineViewWithDistinctAndOrderBy() throws Exception {
runTest(createInlineViewWithDistinctAndOrderBy());
}
- public void testInlineViewOfVirtual() throws Exception{
+ @Test public void testInlineViewOfVirtual() throws Exception{
runTest(createInlineViewOfVirtual());
}
- public void testInlineViewWithOuterOrderAndGroup() throws Exception {
+ @Test public void testInlineViewWithOuterOrderAndGroup() throws Exception {
runTest(createInlineViewWithOuterOrderAndGroup());
}
- public void testInlineViewsInUnions() throws Exception {
+ @Test public void testInlineViewsInUnions() throws Exception {
runTest(crateInlineViewsInUnions());
}
- public void testUnionInInlineView() throws Exception{
+ @Test public void testUnionInInlineView() throws Exception{
runTest(createUnionInInlineView());
}
@@ -83,8 +111,6 @@
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineView() throws Exception {
String userQuery = "select bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa from (select count(bqt1.smalla.intkey) as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, bqt1.smallb " + //$NON-NLS-1$
@@ -106,8 +132,6 @@
return new InlineViewCase("testInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineViewWithDistinctAndOrderBy() throws Exception {
String userQuery = "select Q1.a from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2"; //$NON-NLS-1$
@@ -130,7 +154,6 @@
}
-
public static InlineViewCase createInlineViewOfVirtual() throws Exception{
String userQuery = "select q1.A from (select count(intkey) as a, intkey, stringkey from vqt.smalla group by intkey, stringkey) q1 inner join vqt.smallb as q2 on q1.intkey = q2.a12345 where q1.a = 2"; //$NON-NLS-1$
String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.StringKey HAVING COUNT(g_0.IntKey) = 2) AS v_0, BQT1.SmallA AS g_1 WHERE v_0.c_0 = Concat(g_1.StringKey, g_1.StringNum)"; //$NON-NLS-1$
@@ -147,8 +170,6 @@
return new InlineViewCase("testInlineViewOfVirtual", userQuery, optimizedQuery, //$NON-NLS-1$
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineViewWithOuterOrderAndGroup() throws Exception {
String userQuery = "select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b"; //$NON-NLS-1$
@@ -170,8 +191,6 @@
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase crateInlineViewsInUnions() throws Exception {
String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)"; //$NON-NLS-1$
String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0"; //$NON-NLS-1$
@@ -196,8 +215,6 @@
}
-
-
public static InlineViewCase createUnionInInlineView() throws Exception{
String userQuery = "select t1.intkey from (select case when q1.a=1 then 2 else 1 end as a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)) as q3, bqt1.smallb as t1 where q3.a = t1.intkey order by t1.intkey"; //$NON-NLS-1$
@@ -228,7 +245,7 @@
protected void runTest(InlineViewCase testCase) throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = TestOptimizer.createInlineViewMetadata(capFinder);
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -236,4 +253,60 @@
TestOptimizer.checkSubPlanCount(plan, 0);
}
+
+ @Test public void testAliasCreationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkSubPlanCount(plan, 0);
+ }
+
+ @Test public void testAliasPreservationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkSubPlanCount(plan, 0);
+ }
+
+ /**
+ * Order by's will be added to the atomic queries
+ */
+ @Test public void testCrossSourceInlineView() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ checkSubPlanCount(plan, 0);
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -28,7 +28,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -182,13 +181,13 @@
throw new MetaMatrixRuntimeException(err);
}
- return helpPlanCommand(command, md, capFinder, expectedAtomic, shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
}
public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) throws QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
Command command = helpGetCommand(sql, md, bindings);
- return helpPlanCommand(command, md, capFinder, expectedAtomic, mode);
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, mode);
}
@@ -218,13 +217,13 @@
return command;
}
- public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) {
+ public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, String[] expectedAtomic, ComparisonMode mode) {
if (capFinder == null){
capFinder = getGenericFinder();
}
// Collect atomic queries
- ProcessorPlan plan = getPlan(command, md, capFinder, mode != ComparisonMode.FAILED_PLANNING);
+ ProcessorPlan plan = getPlan(command, md, capFinder, analysisRecord, mode != ComparisonMode.FAILED_PLANNING);
if (mode == ComparisonMode.CORRECTED_COMMAND_STRING) {
checkAtomicQueries(expectedAtomic, plan, md, capFinder);
@@ -237,14 +236,14 @@
public static void checkAtomicQueries(String[] expectedAtomic,
ProcessorPlan plan) {
- Set actualQueries = getAtomicQueries(plan);
+ Set<String> actualQueries = getAtomicQueries(plan);
if (actualQueries.size() != 1 || expectedAtomic.length != 1) {
// Compare atomic queries
HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(expectedAtomic));
assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
} else {
- assertEquals("Did not get expected atomic query: ", expectedAtomic[0], (String)actualQueries.iterator().next()); //$NON-NLS-1$
+ assertEquals("Did not get expected atomic query: ", expectedAtomic[0], actualQueries.iterator().next()); //$NON-NLS-1$
}
}
@@ -274,10 +273,12 @@
assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
}
- public static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) {
+ static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, boolean shouldSucceed) {
// plan
ProcessorPlan plan = null;
- AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
+ if (analysisRecord == null) {
+ analysisRecord = new AnalysisRecord(false, false, DEBUG);
+ }
if (shouldSucceed) {
try {
//do planning
@@ -318,27 +319,22 @@
return plan;
}
- public static Set getAtomicQueries(ProcessorPlan plan) {
- Iterator atomicQueries = getAtomicCommands(plan).iterator();
+ public static Set<String> getAtomicQueries(ProcessorPlan plan) {
+ Set<Command> atomicQueries = new HashSet<Command>();
+ if(plan instanceof RelationalPlan) {
+ getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
+ }
- Set stringQueries = new HashSet();
+ Set<String> stringQueries = new HashSet<String>();
- while (atomicQueries.hasNext()) {
- stringQueries.add(atomicQueries.next().toString());
+ for (Command command : atomicQueries) {
+ stringQueries.add(command.toString());
}
return stringQueries;
}
- public static Set getAtomicCommands(ProcessorPlan plan) {
- Set atomicQueries = new HashSet();
- if(plan instanceof RelationalPlan) {
- getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
- }
- return atomicQueries;
- }
-
- private static void getAtomicCommands(RelationalNode node, Set atomicQueries) {
+ private static void getAtomicCommands(RelationalNode node, Set<Command> atomicQueries) {
if(node instanceof AccessNode) {
AccessNode accessNode = (AccessNode) node;
atomicQueries.add( accessNode.getCommand());
@@ -397,7 +393,7 @@
* @param relationalNode
* @return int[]
*/
- public static void collectCounts(RelationalNode relationalNode, int[] counts, Class<?>[] types) {
+ static void collectCounts(RelationalNode relationalNode, int[] counts, Class<?>[] types) {
Class<?> nodeType = relationalNode.getClass();
if(nodeType.equals(JoinNode.class)) {
JoinStrategy strategy = ((JoinNode)relationalNode).getJoinStrategy();
@@ -608,7 +604,7 @@
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
List vm1g4e = FakeMetadataFactory.createElements(vm1g4,
- new String[] { "e1", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
List vm1g5e = FakeMetadataFactory.createElements(vm1g5,
new String[] { "e1" }, //$NON-NLS-1$
@@ -4262,8 +4258,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
@@ -4282,8 +4277,7 @@
caps.setCapabilitySupport(Capability.QUERY_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE e1 WHEN 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
@@ -4318,8 +4312,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
@@ -4338,8 +4331,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
@@ -4840,7 +4832,7 @@
ProcessorPlan subplan = (ProcessorPlan) subplans.iterator().next();
// Collect atomic queries
- Set actualQueries = getAtomicQueries(subplan);
+ Set<String> actualQueries = getAtomicQueries(subplan);
// Compare atomic queries
HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(new String[] { "SELECT bqt1.smalla.datevalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smalla.intkey) AND (bqt1.smalla.stringkey = bqt1.smalla.stringkey)"})); //$NON-NLS-1$
@@ -5770,7 +5762,7 @@
ProcessorPlan plan = helpPlan(
"select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in (select e2 from vm1.g1)", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT g_1.e1, g_3.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_1.e1 = g_3.e1) AND (g_1.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -5851,72 +5843,7 @@
ComparisonMode.EXACT_COMMAND_STRING );
}
-
- public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- caps.setFunctionSupport("case", true); //$NON-NLS-1$
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- return metadata;
- }
- /**
- * Order by's will be added to the atomic queries
- */
- @Test public void testCrossSourceInlineView() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- checkSubPlanCount(plan, 0);
- }
-
- @Test public void testAliasPreservationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
- }
-
//since this does not support convert, it should not be collapsed
@Test public void testBadCollapseUnion() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -5950,7 +5877,7 @@
}
@Test public void testCase3966() {
- ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )", FakeMetadataFactory.example1(), //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {} );
checkNodeTypes(plan, new int[] {
@@ -6655,19 +6582,7 @@
checkNodeTypes(plan, FULL_PUSHDOWN);
}
-
- @Test public void testAliasCreationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
- ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
- }
-
@Test public void testCase6364() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
@@ -6821,6 +6736,6 @@
TestOptimizer.SHOULD_SUCCEED);
}
- private static final boolean DEBUG = false;
+ public static final boolean DEBUG = false;
}
Added: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -0,0 +1,141 @@
+/*
+ * 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.optimizer.relational;
+
+import static com.metamatrix.query.optimizer.TestOptimizer.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestMaterialization {
+
+ @Test public void testMaterializedTransformation() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
+ @Test public void testMaterializedTransformationLoading() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testMaterializedTransformationNoCache() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ //related to defect 14423
+ @Test public void testMaterializedTransformationNoCache2() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", ((QueryAnnotation)annotations.iterator().next()).getCategory(), QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheInTransformation() throws Exception {
+ String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testTableNoCacheDoesntCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -22,10 +22,13 @@
package com.metamatrix.query.optimizer.relational.rules;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Collection;
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.teiid.dqp.internal.process.TestPreparedStatement;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -51,31 +54,14 @@
/**
* Tests {@link RuleChooseAccessPattern}
*/
-public class TestRuleAccessPatternValidation extends TestCase {
+public class TestRuleAccessPatternValidation {
- private static final FakeMetadataFacade METADATA = FakeMetadataFactory.example1();
+ private static final FakeMetadataFacade METADATA = FakeMetadataFactory.example1Cached();
- private PlanHints planHints;
-
private static final boolean DEBUG = false;
- private static CapabilitiesFinder FINDER = new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());;
+ private static CapabilitiesFinder FINDER = new DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());
- // ################################## FRAMEWORK ################################
-
- /**
- * Constructor for TestRuleChooseAccessPattern.
- */
- public TestRuleAccessPatternValidation(String name) {
- super(name);
- }
-
- public void setUp() {
- this.planHints = new PlanHints();
- }
-
- // ################################## TEST HELPERS ################################
-
/**
* @param command the query to be turned into a test query plan
* @param expectedChosenPredicates expected criteria predicates that should
@@ -112,7 +98,7 @@
p.initialize(query, null, METADATA, FINDER, null, null);
PlanNode planNode = p.generatePlan(query);
- final RuleStack rules = RelationalPlanner.buildRules(planHints);
+ final RuleStack rules = RelationalPlanner.buildRules(new PlanHints());
PlanNode testPlan = helpExecuteRules(rules, planNode, METADATA, DEBUG);
@@ -149,7 +135,7 @@
* This test demonstrates that APs are ignored for inserts
* CASE 3966
*/
- public void testInsertWithAccessPattern_Case3966() throws Exception {
+ @Test public void testInsertWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "insert into pm4.g1 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )" ); //$NON-NLS-1$
}
@@ -157,7 +143,7 @@
* This test demonstrates that a satisfied AP does not fail.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "delete from pm4.g1 where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
@@ -165,7 +151,7 @@
* This test demonstrates that unsatisfied AP fails.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966_2() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966_2() throws Exception {
try {
this.helpTestAccessPatternValidation( "delete from pm4.g1" ); //$NON-NLS-1$
fail("Expected QueryPlannerException, but did not get one"); //$NON-NLS-1$
@@ -177,7 +163,7 @@
}
}
- public void testUpdateWithAccessPattern_Case3966() throws Exception {
+ @Test public void testUpdateWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "update pm4.g1 set e1 = 'test1' where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
@@ -185,7 +171,7 @@
* This test demonstrates that unsatisfied AP fails.
* Found testing fix for 3966.
*/
- public void testUpdateWithAccessPattern_Case3966_2() throws Exception {
+ @Test public void testUpdateWithAccessPattern_Case3966_2() throws Exception {
try {
this.helpTestAccessPatternValidation( "update pm4.g1 set e1 = 'test'" ); //$NON-NLS-1$
fail("Expected QueryPlannerException, but did not get one"); //$NON-NLS-1$
@@ -201,7 +187,7 @@
* This test demonstrates that APs are ignored for inserts through a virtual layer
* CASE 3966
*/
- public void testInsertWithAccessPattern_Case3966_VL() throws Exception {
+ @Test public void testInsertWithAccessPattern_Case3966_VL() throws Exception {
this.helpTestAccessPatternValidation( "insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )" ); //$NON-NLS-1$
}
@@ -210,7 +196,7 @@
* through a virtual layer does not fail.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966_VL() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966_VL() throws Exception {
this.helpTestAccessPatternValidation( "delete from vm1.g37 where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -71,7 +71,7 @@
/* Make Neither Side Dependent */
private static final int NEITHER_SIDE = 3;
- private FakeMetadataFacade metadata;
+ private FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
// ################################## FRAMEWORK ################################
@@ -79,15 +79,6 @@
super(name);
}
- public void setUp() {
- // set up resolver metadata
- metadata = FakeMetadataFactory.example1();
- }
-
- public void tearDown() {
- metadata = null;
- }
-
// ################################## TEST HELPERS ################################
public PlanNode createAccessNode(Collection groupSymbols) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -26,8 +26,6 @@
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
@@ -41,7 +39,7 @@
public class TestRulePlaceAccess extends TestCase {
- private static final QueryMetadataInterface METADATA = FakeMetadataFactory.example1();
+ private static final QueryMetadataInterface METADATA = FakeMetadataFactory.example1Cached();
// ################################## FRAMEWORK ################################
@@ -58,7 +56,7 @@
* Object element ids) for a physical group will be found and added
* as a property of an ACCESS node.
*/
- public void testAddAccessPatterns2(){
+ public void testAddAccessPatterns2() throws Exception {
Query query = new Query();
From from = new From();
@@ -70,31 +68,17 @@
select.addSymbol(new AllSymbol());
query.setSelect(select);
- try {
- group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
- } catch (QueryMetadataException e) {
- fail(e.getMessage());
- } catch (MetaMatrixComponentException e) {
- fail(e.getMessage());
- }
+ group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
PlanNode n1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
n1.setProperty(NodeConstants.Info.ATOMIC_REQUEST, query);
n1.addGroup(group);
- try {
- RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
- } catch (QueryMetadataException e) {
- fail(e.getMessage());
- } catch (MetaMatrixComponentException e) {
- fail(e.getMessage());
- }
+ RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
Collection accessPatterns = (Collection)n1.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
assertNotNull(accessPatterns);
assertTrue("Expected two access patterns, got " + accessPatterns.size(), accessPatterns.size() == 2); //$NON-NLS-1$
-// assertTrue(accessPatterns.contains(FakeMetadata.ELEMENT_IDS_1));
-// assertTrue(accessPatterns.contains(FakeMetadata.ELEMENT_IDS_2));
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -32,6 +32,9 @@
import org.junit.Test;
import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.relational.RelationalPlanner;
@@ -46,7 +49,6 @@
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.util.CommandContext;
@@ -65,7 +67,7 @@
}
@Test public void testPushAcrossFrameWithAccessNode() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ QueryMetadataInterface metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore());
Command command = TestOptimizer.helpGetCommand("select * from (select * from pm1.g1 union select * from pm1.g2) x where e1 = 1", metadata, null); //$NON-NLS-1$
Command subCommand = TestOptimizer.helpGetCommand("select * from pm1.g1 union select * from pm1.g2", metadata, null); //$NON-NLS-1$
RelationalPlanner p = new RelationalPlanner();
@@ -74,7 +76,7 @@
PlanNode child = p.generatePlan(subCommand);
PlanNode sourceNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.SOURCE);
sourceNode.addFirstChild(child);
- sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS)));
+ sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS), metadata));
//add a dummy access node
PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
accessNode.addGroups(child.getFirstChild().getGroups());
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -642,7 +642,7 @@
// Slightly modify metadata to set max set size to just a few rows - this
// will allow us to test the dependent overflow case
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -711,8 +711,6 @@
capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Slightly modify metadata to set max set size to just a few rows - this
- // will allow us to test the dependent overflow case
FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
Command command = TestProcessor.helpParse(sql);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -100,7 +100,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -259,7 +259,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -340,7 +340,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -481,9 +481,8 @@
} );
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -505,9 +504,8 @@
new List[] {
Arrays.asList(new Object[] { new Integer(1) }),
} );
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -1990,7 +1988,7 @@
sampleData1(dataManager);
// Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1());
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
// Run query
helpProcess(plan, dataManager, expected);
@@ -3915,7 +3913,7 @@
sampleData1(dataManager);
// Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1());
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
// Run query
helpProcess(plan, dataManager, expected);
@@ -6515,7 +6513,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-11 22:59:31 UTC (rev 1655)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-11 23:05:15 UTC (rev 1656)
@@ -237,7 +237,7 @@
QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g1 = createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
- QueryNode vm2g1n1 = new QueryNode("vm2.g1", "SELECT * FROM pm1.g1, pm1.g2 where pm1.g1.e2 = pm1.g2.e2"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm2g1n1 = new QueryNode("vm2.g1", "SELECT pm1.g1.* FROM pm1.g1, pm1.g2 where pm1.g1.e2 = pm1.g2.e2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm2g1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm2.g1", vm2, vm2g1n1); //$NON-NLS-1$
QueryNode vm1g1n1_defect10711 = new QueryNode("vm1.g1a", "SELECT * FROM vm1.g1 as X"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -405,8 +405,8 @@
new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
List vm1g11e = createElements(vm1g11,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ new String[] { "e1", "e2", "e3", "e4", "e5", "e6"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
List vm1g12e = createElements(vm1g12,
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
@@ -480,8 +480,8 @@
new String[] { "ve1", "ve2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
List vm1g37e = createElements(vm1g37,
- new String[] { "e1", "e2", "e3", "e4", "e5" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.DOUBLE });
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
List vm1g38e = createElements(vm1g38,
new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
@@ -1008,7 +1008,7 @@
FakeMetadataObject vgvp6e4 = FakeMetadataFactory.createElement("vm1.vgvp6.ve4", vgvp6, DataTypeManager.DefaultDataTypes.INTEGER, 3); //$NON-NLS-1$
//virtual group with two elements. One selectable, one not.
- QueryNode vm1g35n1 = new QueryNode("vm1.g35", "SELECT e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g35n1 = new QueryNode("vm1.g35", "SELECT e1, e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g35 = createVirtualGroup("vm1.g35", vm1, vm1g35n1); //$NON-NLS-1$
FakeMetadataObject vm1g35e1 = FakeMetadataFactory.createElement("vm1.g35.e1", vm1g35, DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
vm1g35e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
@@ -2007,7 +2007,7 @@
QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM vm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g1 = createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
- QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g2 = createUpdatableVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
// Create virtual elements
@@ -2016,9 +2016,9 @@
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE },
new Object[] { "xyz", Integer.getInteger("123"), Boolean.valueOf("true"), Double.valueOf("123.456")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
List vm1g2e = createElementsWithDefaults(vm1g2,
- new String[] { "e1", "e2", "e3" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN },
- new Object[] { "abc", Integer.getInteger("456"), Boolean.valueOf("false")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE },
+ new Object[] { "abc", Integer.getInteger("456"), Boolean.valueOf("false"), null}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vm1g1.putProperty(procedureType, procedure1);
vm1g2.putProperty(procedureType, procedure2);
@@ -3302,12 +3302,22 @@
new String[] { "e1" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
+ FakeMetadataObject physGroup1 = createPhysicalGroup("MatTable.MatTable1", physModel); //$NON-NLS-1$
+ List physElements1 = createElements(physGroup,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
+ FakeMetadataObject physGroupStage1 = createPhysicalGroup("MatTable.MatStage1", physModel); //$NON-NLS-1$
+ List physStageElements1 = createElements(physGroupStage,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
FakeMetadataObject physGroup_virtSrc = createPhysicalGroup("MatSrc.MatSrc", physModel_virtSrc); //$NON-NLS-1$
List physElements_virtSrc = createElements(physGroup_virtSrc,
new String[] { "X" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
- QueryNode virtTrans = new QueryNode("MatView.MatView", "SELECT x FROM MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode virtTrans = new QueryNode("MatView.MatView", "SELECT x as e1 FROM MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject virtGroup = createVirtualGroup("MatView.MatView", virtModel, virtTrans); //$NON-NLS-1$
List virtElements = createElements(virtGroup,
new String[] { "e1" }, //$NON-NLS-1$
@@ -3323,6 +3333,15 @@
new String[] { "e1" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
+ QueryNode virtTrans1 = new QueryNode("MatView.MatView1", "SELECT e1 FROM MatView.MatView where e1 = 1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject virtGroup1 = createVirtualGroup("MatView.MatView1", virtModel, virtTrans1); //$NON-NLS-1$
+ List virtElements1 = createElements(virtGroup1,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
+ virtGroup1.putProperty(FakeMetadataObject.Props.MAT_GROUP, physGroup1);
+ virtGroup1.putProperty(FakeMetadataObject.Props.MAT_STAGE, physGroupStage1);
+
FakeMetadataStore store = new FakeMetadataStore();
store.addObject(virtModel);
store.addObject(physModel);
@@ -3331,13 +3350,18 @@
store.addObjects(physElements);
store.addObject(physGroupStage);
store.addObjects(physStageElements);
+ store.addObject(physGroup1);
+ store.addObjects(physElements1);
+ store.addObject(physGroupStage1);
+ store.addObjects(physStageElements1);
store.addObject(physGroup_virtSrc);
store.addObjects(physElements_virtSrc);
store.addObject(virtGroup);
store.addObjects(virtElements);
store.addObject(vGroup);
store.addObjects(vElements);
-
+ store.addObject(virtGroup1);
+ store.addObjects(virtElements1);
return new FakeMetadataFacade(store);
}
15 years
teiid SVN: r1655 - in trunk/engine/src: test/java/com/metamatrix/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-11 17:59:31 -0500 (Fri, 11 Dec 2009)
New Revision: 1655
Modified:
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
Log:
TEIID-904 fix for procedure relational failing even though there are no parameters
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-12-11 22:49:47 UTC (rev 1654)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2009-12-11 22:59:31 UTC (rev 1655)
@@ -378,14 +378,15 @@
id = metadata.getMetadataStore().getTempGroupID(queryName);
id.setOriginalMetadataID(storedProcedureCommand.getProcedureID());
- List accessPatternIds = new LinkedList();
-
- for (Iterator i = accessPatternElementNames.iterator(); i.hasNext();) {
- String name = (String)i.next();
- accessPatternIds.add(metadata.getMetadataStore().getTempElementID(name));
+ if (!accessPatternElementNames.isEmpty()) {
+ List<TempMetadataID> accessPatternIds = new LinkedList<TempMetadataID>();
+
+ for (String name : accessPatternElementNames) {
+ accessPatternIds.add(metadata.getMetadataStore().getTempElementID(name));
+ }
+
+ id.setAccessPatterns(Arrays.asList(new TempMetadataID("procedure access pattern", accessPatternIds))); //$NON-NLS-1$
}
-
- id.setAccessPatterns(Arrays.asList(new TempMetadataID("procedure access pattern", accessPatternIds))); //$NON-NLS-1$
}
group.setMetadataID(id);
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2009-12-11 22:49:47 UTC (rev 1654)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2009-12-11 22:59:31 UTC (rev 1655)
@@ -738,4 +738,20 @@
}
+ @Test public void testProcRelationalWithNoInputs() {
+ String sql = "select e1 from pm1.vsp2 order by e1 desc limit 1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList("c") //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
}
15 years
teiid SVN: r1654 - in trunk/engine/src: test/java/com/metamatrix/query/sql/proc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-11 17:49:47 -0500 (Fri, 11 Dec 2009)
New Revision: 1654
Modified:
trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java
trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java
Log:
TEIID-905 fix for block clone
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java 2009-12-11 22:46:42 UTC (rev 1653)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java 2009-12-11 22:49:47 UTC (rev 1654)
@@ -22,26 +22,28 @@
package com.metamatrix.query.sql.proc;
-import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
import com.metamatrix.core.util.EquivalenceUtil;
+import com.metamatrix.query.sql.LanguageObject;
+import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
/**
* <p> This class represents a group of <code>Statement</code> objects. The
* statements are stored on this object in the order in which they are added.</p>
*/
-public class Block implements LanguageObject {
+public class Block implements LanguageObject {
// list of statements on this block
- private List statements;
+ private List<Statement> statements;
/**
* Constructor for Block.
*/
public Block() {
- statements = new ArrayList();
+ statements = new ArrayList<Statement>();
}
/**
@@ -57,7 +59,7 @@
* Get all the statements contained on this block.
* @return A list of <code>Statement</code>s contained in this block
*/
- public List getStatements() {
+ public List<Statement> getStatements() {
return statements;
}
@@ -65,7 +67,7 @@
* Set the statements contained on this block.
* @param statements A list of <code>Statement</code>s contained in this block
*/
- public void setStatements(List statements) {
+ public void setStatements(List<Statement> statements) {
this.statements = statements;
}
@@ -91,11 +93,8 @@
*/
public Object clone() {
Block copy = new Block();
- if(!statements.isEmpty()) {
- Iterator stmtIter = statements.iterator();
- while(stmtIter.hasNext()) {
- copy.addStatement((Statement) stmtIter.next());
- }
+ for (Statement statement : statements) {
+ copy.addStatement((Statement)statement.clone());
}
return copy;
}
@@ -129,18 +128,7 @@
* @return Hash code
*/
public int hashCode() {
- // For speed, this hash code relies only on the hash codes of its select
- // and criteria clauses, not on the from, order by, or option clauses
- int myHash = 0;
-
- myHash = HashCodeUtil.hashCode(myHash, this.getStatements());
- if(!this.getStatements().isEmpty()) {
- Iterator stmtIter = this.getStatements().iterator();
- while(stmtIter.hasNext()) {
- myHash = HashCodeUtil.hashCode(myHash, stmtIter.next());
- }
- }
- return myHash;
+ return statements.hashCode();
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java 2009-12-11 22:46:42 UTC (rev 1653)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java 2009-12-11 22:49:47 UTC (rev 1654)
@@ -60,13 +60,13 @@
public void testGetStatements1() {
Block b1 = sample1();
- List stmts = b1.getStatements();
+ List<Statement> stmts = b1.getStatements();
assertTrue("Incorrect number of statements in the Block", (stmts.size() == 4)); //$NON-NLS-1$
}
public void testGetStatements2() {
Block b1 = sample1();
- Statement stmt = (Statement) b1.getStatements().get(1);
+ Statement stmt = b1.getStatements().get(1);
assertTrue("Incorrect statement in the Block", stmt.equals(TestCommandStatement.sample1())); //$NON-NLS-1$
}
@@ -79,7 +79,7 @@
public void testaddStatement2() {
Block b1 = (Block) sample2().clone();
b1.addStatement(TestCommandStatement.sample2());
- Statement stmt = (Statement) b1.getStatements().get(4);
+ Statement stmt = b1.getStatements().get(4);
assertTrue("Incorrect statement in the Block", stmt.equals(TestCommandStatement.sample2())); //$NON-NLS-1$
}
@@ -102,5 +102,12 @@
int equals = -1;
UnitTestUtil.helpTestEquivalence(equals, b1, b2);
}
+
+ public void testClone() {
+ Block b1 = sample1();
+ Block b2 = (Block)b1.clone();
+ UnitTestUtil.helpTestEquivalence(0, b1, b2);
+ assertNotSame(b1.getStatements().get(0), b2.getStatements().get(0));
+ }
}
15 years
teiid SVN: r1653 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/query.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-11 17:46:42 -0500 (Fri, 11 Dec 2009)
New Revision: 1653
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
Log:
Teiid 781 - changes to support running from hudson
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-12-11 22:46:22 UTC (rev 1652)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-12-11 22:46:42 UTC (rev 1653)
@@ -55,6 +55,8 @@
protected int queryTimeout = -1;
protected ConnectionStrategy connStrategy;
+
+ private Throwable applicationException=null;
public AbstractQueryTransactionTest() {
super();
@@ -156,6 +158,7 @@
@Override
public void setup() throws QueryTestFailedException {
+ this.applicationException = null;
this.setConnection(connStrategy.getConnection());
setupDataStore();
@@ -272,6 +275,30 @@
@Override
public XAConnection getXAConnection() {
return null;
+
}
+ @Override
+ public void setApplicationException(Throwable t) {
+ this.applicationException = t;
+
+ }
+
+ @Override
+ public boolean exceptionOccurred() {
+ return (super.exceptionOccurred() ? super.exceptionOccurred() : this.applicationException != null);
+
+ }
+
+ @Override
+ public Throwable getApplicationException() {
+ // TODO Auto-generated method stub
+ return this.applicationException;
+ }
+
+
+
+
+
+
}
15 years
teiid SVN: r1652 - in trunk/test-integration/db/src/main/java/org/teiid/test: client/ctc and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-11 17:46:22 -0500 (Fri, 11 Dec 2009)
New Revision: 1652
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
Log:
Teiid 781 - changes to support running from hudson
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -103,89 +103,10 @@
}
-// private void testScenarios() throws Exception {
-//
-//
-//// String teiid_home = deployProperties.getProperty("teiid.home");
-//// File f = new File(teiid_home);
-//// if (f.exists() && f.isDirectory()) {
-//// FileUtils.removeDirectoryAndChildren(f);
-//// }
-//
-// this.overrides = getSubstitutedProperties(ConfigPropertyLoader.getInstance().getProperties());
-//
-// ConfigPropertyLoader.getInstance().setProperties(this.overrides);
-//
-// String scenaios_dir = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_DIR);
-// if (scenaios_dir == null) {
-// throw new TransactionRuntimeException("scenariodir property was not defined");
-// }
-//
-// File files[] = FileUtils.findAllFilesInDirectoryHavingExtension(scenaios_dir,
-// ".properties");
-// if (files == null || files.length == 0)
-// throw new QueryTestFailedException((new StringBuilder()).append(
-// "No scenario files found in directory ").append(scenaios_dir)
-// .toString());
-//
-//
-// // List<String> queryFiles = new ArrayList<String>(files.length);
-// for (int i = 0; i < files.length; i++) {
-// // overrides need to be reset because all overrides are cleared out after each query set
-// ConfigPropertyLoader.getInstance().setProperties(overrides);
-//
-// runTest(files[i]);
-// }
-//
-//
-// }
-// private void runScenariox() throws Exception {
-// String scenario_file = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_FILE);
-// if (scenario_file == null) {
-// throw new TransactionRuntimeException(TestProperties.PROP_SCENARIO_FILE + " property was not defined");
-// }
-//
-// Properties sc_props = PropertiesUtils.load(scenario_file);
-// Properties sc_updates = getSubstitutedProperties(sc_props);
-// if (!sc_updates.isEmpty()) {
-// sc_props.putAll(sc_props);
-// }
-//
-// String scenario_name = FileUtils.getBaseFileNameWithoutExtension(scenario_file);
-//
-// TestLogger.log("Starting scenario " + scenario_name);
-//
-// this.overrides = getSubstitutedProperties(ConfigPropertyLoader.getInstance().getProperties());
-//
-//
-// // update the URL with the vdb that is to be used
-// String url = ConfigPropertyLoader.getInstance().getProperty(DriverConnection.DS_URL);
-// String vdb_name = ConfigPropertyLoader.getInstance().getProperty(DataSourceConnection.DS_DATABASENAME);
-//
-// Assert.assertNotNull(DataSourceConnection.DS_DATABASENAME + " property not set, need it for the vdb name", vdb_name);
-// url = StringUtil.replace(url, "${vdb}", vdb_name);
-//
-// this.overrides.setProperty(DriverConnection.DS_URL, url);
-//
-// ConfigPropertyLoader.getInstance().setProperties(this.overrides);
-//
-// QueryScenario set = new CTCQueryScenario(scenario_name, ConfigPropertyLoader.getInstance().getProperties());
-//
-// TransactionContainer tc = getTransactionContainter();
-//
-// runTestCase(set, tc);
-//
-// TestLogger.log("Completed scenario " + scenario_name);
-//
-//
-// }
-
-
private void runScenario() throws Exception {
-
String scenario_file = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_FILE);
if (scenario_file == null) {
throw new TransactionRuntimeException(TestProperties.PROP_SCENARIO_FILE + " property was not defined");
@@ -273,8 +194,8 @@
userTxn.init(querySetID, queryidentifier, sqlObject);
// run test
-
tc.runTransaction(userTxn);
+
testResults.add(userTxn.getTestResult());
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -56,8 +56,6 @@
private TestResult rs = null;
private boolean errorExpected = false;
-
- private Throwable resultException = null;
private String sql = null;
@@ -81,7 +79,6 @@
rs = null;
errorExpected = false;
- resultException = null;
}
@@ -125,7 +122,7 @@
TestLogger.logDebug("expected error: " + this.errorExpected);
try {
- System.out.println("QueryID: " + this.querySetID + ":"
+ System.out.println(this.querySet.getQueryScenarioIdentifier() + ":" + this.querySetID + ":"
+ this.queryIdentifier);
// need to set this so the underlying query execution handles an
// error properly.
@@ -134,9 +131,8 @@
execute(sql);
} catch (Throwable t) {
+ this.setApplicationException(t);
- resultException = t;
-
} finally {
// Capture resp time
endTS = System.currentTimeMillis();
@@ -156,19 +152,26 @@
// this.internalResultSet;
ResultsGenerator genResults = this.querySet.getResultsGenerator();
+
+ Throwable resultException = null;
resultException = (this.getLastException() != null ? this
- .getLastException() : resultException);
+ .getLastException() : this.getApplicationException());
+
+
if (resultException != null) {
- if (this.exceptionExpected()) {
- testStatus = TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION;
- } else {
- testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
- }
+ if (this.exceptionExpected()) {
+ testStatus = TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION;
+ } else {
+ testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
+ }
}
+
+
+
if (this.querySet.getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
if (testStatus != TestResult.RESULT_STATE.TEST_EXCEPTION) {
@@ -272,4 +275,7 @@
}
+
+
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -162,7 +162,7 @@
if (!expectedResults.isException()) {
// The actual exception was expected, but the expected results was not
- throw new QueryTestFailedException(eMsg + "TThe actual exception was expected, but the Expected results wasn't an exception. Actual exception: '" //$NON-NLS-1$
+ throw new QueryTestFailedException(eMsg + "The actual result was an exception, but the Expected results wasn't an exception. Actual exception: '" //$NON-NLS-1$
+ actualException.getMessage() + "'"); //$NON-NLS-1$
}
// We got an exception that we expected - convert actual exception to ResultsHolder
@@ -198,7 +198,11 @@
compareExceptions(actualResults, expectedResults, eMsg);
+ } else if (expectedResults.isException()) {
+ throw new QueryTestFailedException(eMsg + "The Expected result was an exception, but the Actual results wasn't an exception. Expected exception: '" //$NON-NLS-1$
+ + expectedResults.getExceptionMsg() + "'"); //$NON-NLS-1$
+
} else {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -64,7 +64,6 @@
protected void runTest(TransactionQueryTestCase test) {
debug("Start runTest: " + test.getTestName());
- try {
debug(" before(test)");
@@ -74,10 +73,32 @@
test.before();
debug(" test.testcase");
+
+ try {
+
// run the test
test.testCase();
+
+ } catch (Throwable e) {
+ if (!test.exceptionExpected()) {
+ e.printStackTrace();
+ debug("Error: " + e.getMessage());
+ test.setApplicationException(e);
+
+ }
+ }
+
+ if (test.exceptionExpected() && !test.exceptionOccurred()) {
+ TransactionRuntimeException t = new TransactionRuntimeException(
+ "Expected exception, but one did not occur for test: "
+ + this.getClass().getName() + "."
+ + test.getTestName());
+ test.setApplicationException(t);
+ }
+
+
debug(" test.after");
test.after();
@@ -87,25 +108,9 @@
debug("End runTest: " + test.getTestName());
- } catch (TransactionRuntimeException tre) {
- throw tre;
- } catch (Throwable e) {
- if (!test.exceptionExpected()) {
- e.printStackTrace();
- debug("Error: " + e.getMessage());
- throw new TransactionRuntimeException(e.getMessage());
- }
- }
- if (test.exceptionExpected() && !test.exceptionOccurred()) {
- throw new TransactionRuntimeException(
- "Expected exception, but one did not occur for test: "
- + this.getClass().getName() + "."
- + test.getTestName());
- }
-
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java 2009-12-11 20:52:34 UTC (rev 1651)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java 2009-12-11 22:46:22 UTC (rev 1652)
@@ -135,15 +135,6 @@
void setConnection(Connection conn);
/**
- * Called to set the properties used to initialize prior to execution.
- *
- * @param props
- *
- * @since
- */
-// void setExecutionProperties(Properties props);
-
- /**
* Override <code>before</code> if there is behavior that needs to be
* performed prior to {@link #testCase()} being called.
*
@@ -203,5 +194,9 @@
boolean exceptionExpected();
boolean exceptionOccurred();
+
+ void setApplicationException(Throwable t);
+
+ Throwable getApplicationException();
}
15 years
teiid SVN: r1651 - trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2009-12-11 15:52:34 -0500 (Fri, 11 Dec 2009)
New Revision: 1651
Modified:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
Log:
TEIID-896
INSERT failing with SF connector on types other than a string
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-12-11 20:52:34 UTC (rev 1651)
@@ -64,7 +64,7 @@
String val;
if(value instanceof ILiteral) {
ILiteral literalValue = (ILiteral)value;
- val = this.stripQutes((String)literalValue.getValue());
+ val = this.stripQutes(literalValue.getValue().toString());
} else {
val = value.toString();
}
15 years
teiid SVN: r1650 - in trunk/connectors/connector-salesforce/src: main/java/com/metamatrix/connector/salesforce/connection and 4 other directories.
by teiid-commits@lists.jboss.org
Author: jdoyle
Date: 2009-12-11 14:59:37 -0500 (Fri, 11 Dec 2009)
New Revision: 1650
Added:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java
Removed:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java
Modified:
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java
trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
Log:
TEIID-180
Consider using Salesforce retrieve() rather than generic query() call for queries with IN criteria
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Constants.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -45,5 +45,7 @@
public static final String RESTRICTED_MULTISELECT_PICKLIST_TYPE = "restrictedmultiselectpicklist"; //$NON-NLS-1$
public static final String SUPPORTS_QUERY = "Supports Query";
+
+ public static final String SUPPORTS_RETRIEVE = "Supports Retrieve";
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -40,12 +40,15 @@
import com.metamatrix.connector.salesforce.Messages;
import com.metamatrix.connector.salesforce.connection.impl.ConnectionImpl;
import com.metamatrix.connector.salesforce.execution.DataPayload;
+import com.metamatrix.connector.salesforce.execution.DeleteExecutionImpl;
import com.metamatrix.connector.salesforce.execution.DeletedResult;
+import com.metamatrix.connector.salesforce.execution.InsertExecutionImpl;
import com.metamatrix.connector.salesforce.execution.ProcedureExecutionParentImpl;
import com.metamatrix.connector.salesforce.execution.QueryExecutionImpl;
-import com.metamatrix.connector.salesforce.execution.UpdateExecutionParent;
+import com.metamatrix.connector.salesforce.execution.UpdateExecutionImpl;
import com.metamatrix.connector.salesforce.execution.UpdatedResult;
import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
public class SalesforceConnection extends BasicConnection {
@@ -99,7 +102,15 @@
public UpdateExecution createUpdateExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new UpdateExecutionParent(command, this, metadata, executionContext, connectorEnv);
+ UpdateExecution result = null;
+ if(command instanceof org.teiid.connector.language.IDelete) {
+ result = new DeleteExecutionImpl(command, this, metadata, executionContext, connectorEnv);
+ } else if (command instanceof org.teiid.connector.language.IInsert) {
+ result = new InsertExecutionImpl(command, this, metadata, executionContext, connectorEnv);
+ } else if (command instanceof org.teiid.connector.language.IUpdate) {
+ result = new UpdateExecutionImpl(command, this, metadata, executionContext, connectorEnv);
+ }
+ return result;
}
@@ -158,4 +169,11 @@
Calendar endCalendar) throws ConnectorException {
return connection.getDeleted(objectName, startCalendar, endCalendar);
}
+
+ public QueryResult retrieve(String fieldList, String sObjectType, String[] ids) throws ConnectorException {
+ SObject[] objects = connection.retrieve(fieldList, sObjectType, ids);
+ QueryResult result = new QueryResult(true, "teiid_created_result",
+ objects, objects.length);
+ return result;
+ }
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -330,4 +330,14 @@
throw new ConnectorException(e, e.getMessage());
}
}
+
+ public SObject[] retrieve(String fieldList, String sObjectType, String[] ids) throws ConnectorException {
+ try {
+ return binding.retrieve(fieldList, sObjectType, ids);
+ } catch (ApiFault e) {
+ throw new ConnectorException(e.getMessage());
+ } catch (RemoteException e) {
+ throw new ConnectorException(e, e.getMessage());
+ }
+ }
}
Copied: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java (from rev 1625, trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java)
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java (rev 0)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/AbstractUpdateExecution.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -0,0 +1,122 @@
+/*
+ * 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.connector.salesforce.execution;
+
+import java.util.ArrayList;
+
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.DataNotAvailableException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.UpdateExecution;
+import org.teiid.connector.basic.BasicExecution;
+import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.ICompareCriteria;
+import org.teiid.connector.language.ICriteria;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+
+import com.metamatrix.connector.salesforce.Util;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
+import com.metamatrix.connector.salesforce.execution.visitors.IQueryProvidingVisitor;
+import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
+
+/**
+ *
+ * Parent class to the Update, Delete, and Insert execution classes.
+ * Provisions the correct impl and contains some common code to
+ * get IDs of Salesforce objects.
+ *
+ */
+public abstract class AbstractUpdateExecution extends BasicExecution implements UpdateExecution {
+
+ protected SalesforceConnection connection;
+ protected RuntimeMetadata metadata;
+ protected ExecutionContext context;
+ protected ConnectorEnvironment connectorEnv;
+ protected ICommand command;
+ protected int result;
+
+ public AbstractUpdateExecution(ICommand command, SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ this.connection = salesforceConnection;
+ this.metadata = metadata;
+ this.context = context;
+ this.connectorEnv = connectorEnv;
+ this.command = command;
+ }
+
+ @Override
+ public void cancel() throws ConnectorException {
+ }
+
+ @Override
+ public void close() throws ConnectorException {
+ }
+
+ @Override
+ public int[] getUpdateCounts() throws DataNotAvailableException,
+ ConnectorException {
+ return new int[] {result};
+ }
+
+ public RuntimeMetadata getMetadata() {
+ return metadata;
+ }
+
+ public ConnectorEnvironment getConnectorEnv() {
+ return connectorEnv;
+ }
+
+ public SalesforceConnection getConnection() {
+ return connection;
+ }
+
+ String[] getIDs(ICriteria criteria, IQueryProvidingVisitor visitor) throws ConnectorException {
+ String[] Ids = null;
+ if (visitor.hasOnlyIDCriteria()) {
+ try {
+ String Id = ((ICompareCriteria)criteria).getRightExpression().toString();
+ Id = Util.stripQutes(Id);
+ Ids = new String[] { Id };
+ } catch (ClassCastException cce) {
+ throw new RuntimeException(
+ "Error: The delete criteria is not a CompareCriteria");
+ }
+
+ } else if (visitor.hasCriteria()) {
+ String query = visitor.getQuery();
+ QueryResult results = getConnection().query(query, context.getBatchSize(), Boolean.FALSE);
+ if (null != results && results.getSize() > 0) {
+ ArrayList<String> idList = new ArrayList<String>(results
+ .getRecords().length);
+ for (int i = 0; i < results.getRecords().length; i++) {
+ SObject sObject = results.getRecords(i);
+ idList.add(sObject.getId());
+ }
+ Ids = idList.toArray(new String[0]);
+ }
+ }
+ return Ids;
+ }
+}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -21,22 +21,33 @@
*/
package com.metamatrix.connector.salesforce.execution;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IDelete;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.execution.visitors.DeleteVisitor;
-public class DeleteExecutionImpl {
+public class DeleteExecutionImpl extends AbstractUpdateExecution {
- public int execute(IDelete delete, UpdateExecutionParent parent) throws ConnectorException {
-
- int result = 0;
- DeleteVisitor dVisitor = new DeleteVisitor(parent.getMetadata());
- dVisitor.visitNode(delete);
- String[] Ids = parent.getIDs(delete.getCriteria(), dVisitor);
+
+ public DeleteExecutionImpl(ICommand command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ super(command, salesforceConnection, metadata, context, connectorEnv);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ DeleteVisitor dVisitor = new DeleteVisitor(getMetadata());
+ dVisitor.visitNode(command);
+ String[] Ids = getIDs(((IDelete)command).getCriteria(), dVisitor);
if(null != Ids && Ids.length > 0) {
- result = parent.getConnection().delete(Ids);
+ result = getConnection().delete(Ids);
}
- return result;
}
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -22,21 +22,32 @@
package com.metamatrix.connector.salesforce.execution;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IInsert;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.execution.visitors.InsertVisitor;
-public class InsertExecutionImpl {
+public class InsertExecutionImpl extends AbstractUpdateExecution {
- public int execute(IInsert insert,
- UpdateExecutionParent salesforceUpdateExecution) throws ConnectorException {
-
- InsertVisitor visitor = new InsertVisitor(salesforceUpdateExecution.getMetadata());
- visitor.visit(insert);
+ public InsertExecutionImpl(ICommand command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ super(command, salesforceConnection, metadata, context, connectorEnv);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ InsertVisitor visitor = new InsertVisitor(getMetadata());
+ visitor.visit((IInsert)command);
DataPayload data = new DataPayload();
data.setType(visitor.getTableName());
data.setMessageElements(visitor.getMessageElements());
- return salesforceUpdateExecution.getConnection().create(data);
+ result = getConnection().create(data);
}
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -118,18 +118,28 @@
connectorEnv.getLogger().logInfo(
getLogPreamble() + "Incoming Query: " + query.toString());
IFrom from = ((IQuery)query).getFrom();
+ String finalQuery;
if(from.getItems().get(0) instanceof IJoin) {
visitor = new JoinQueryVisitor(metadata);
+ visitor.visitNode(query);
+ finalQuery = visitor.getQuery().trim();
+ connectorEnv.getLogger().logInfo(
+ getLogPreamble() + "Executing Query: " + finalQuery);
+
+ results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
} else {
visitor = new SelectVisitor(metadata);
+ visitor.visitNode(query);
+ if(visitor.canRetrieve()) {
+ results = connection.retrieve(visitor.getRetrieveFieldList(),
+ visitor.getTableName(), visitor.getIdInCriteria());
+ } else {
+ finalQuery = visitor.getQuery().trim();
+ connectorEnv.getLogger().logInfo(
+ getLogPreamble() + "Executing Query: " + finalQuery);
+ results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
+ }
}
- visitor.visitNode(query);
- String finalQuery;
- finalQuery = visitor.getQuery().trim();
- connectorEnv.getLogger().logInfo(
- getLogPreamble() + "Executing Query: " + finalQuery);
-
- results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
}
@SuppressWarnings("unchecked")
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -27,29 +27,39 @@
import javax.xml.namespace.QName;
import org.apache.axis.message.MessageElement;
+import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.ILiteral;
import org.teiid.connector.language.ISetClause;
import org.teiid.connector.language.IUpdate;
import org.teiid.connector.metadata.runtime.Element;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.salesforce.Util;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.execution.visitors.UpdateVisitor;
-public class UpdateExecutionImpl {
+public class UpdateExecutionImpl extends AbstractUpdateExecution {
- public int execute(IUpdate update, UpdateExecutionParent parent)
- throws ConnectorException {
- int result = 0;
- UpdateVisitor visitor = new UpdateVisitor(parent
- .getMetadata());
- visitor.visit(update);
- String[] Ids = parent.getIDs(update.getCriteria(), visitor);
+ public UpdateExecutionImpl(ICommand command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context,
+ ConnectorEnvironment connectorEnv) {
+ super(command, salesforceConnection, metadata, context, connectorEnv);
+ }
+ @Override
+ public void execute() throws ConnectorException {
+ UpdateVisitor visitor = new UpdateVisitor(getMetadata());
+ visitor.visit((IUpdate)command);
+ String[] Ids = getIDs(((IUpdate)command).getCriteria(), visitor);
+
if (null != Ids && Ids.length > 0) {
List<MessageElement> elements = new ArrayList<MessageElement>();
- for (ISetClause clause : update.getChanges().getClauses()) {
+ for (ISetClause clause : ((IUpdate)command).getChanges().getClauses()) {
IElement element = clause.getSymbol();
Element column = element.getMetadataObject();
String val = ((ILiteral) clause.getValue())
@@ -69,9 +79,7 @@
updateDataList.add(data);
}
- result = parent.getConnection().update(updateDataList);
+ result = getConnection().update(updateDataList);
}
- return result;
}
-
}
Deleted: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -1,139 +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.connector.salesforce.execution;
-
-import java.util.ArrayList;
-
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.DataNotAvailableException;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.UpdateExecution;
-import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.ICommand;
-import org.teiid.connector.language.ICompareCriteria;
-import org.teiid.connector.language.ICriteria;
-import org.teiid.connector.language.IDelete;
-import org.teiid.connector.language.IInsert;
-import org.teiid.connector.language.IUpdate;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-
-import com.metamatrix.connector.salesforce.Util;
-import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
-import com.metamatrix.connector.salesforce.execution.visitors.IQueryProvidingVisitor;
-import com.sforce.soap.partner.QueryResult;
-import com.sforce.soap.partner.sobject.SObject;
-
-/**
- *
- * Parent class to the Update, Delete, and Insert execution classes.
- * Provisions the correct impl and contains some common code to
- * get IDs of Salesforce objects.
- *
- */
-public class UpdateExecutionParent extends BasicExecution implements UpdateExecution {
-
- private SalesforceConnection connection;
- private RuntimeMetadata metadata;
- private ExecutionContext context;
- private ConnectorEnvironment connectorEnv;
- private ICommand command;
- private int result;
-
- public UpdateExecutionParent(ICommand command, SalesforceConnection salesforceConnection,
- RuntimeMetadata metadata, ExecutionContext context,
- ConnectorEnvironment connectorEnv) {
- this.connection = salesforceConnection;
- this.metadata = metadata;
- this.context = context;
- this.connectorEnv = connectorEnv;
- this.command = command;
- }
-
- @Override
- public void cancel() throws ConnectorException {
- }
-
- @Override
- public void close() throws ConnectorException {
- }
-
- @Override
- public void execute() throws ConnectorException {
- if(command instanceof org.teiid.connector.language.IDelete) {
- DeleteExecutionImpl ex = new DeleteExecutionImpl();
- result = ex.execute(((IDelete)command), this);
- } else if (command instanceof org.teiid.connector.language.IInsert) {
- InsertExecutionImpl ex = new InsertExecutionImpl();
- result = ex.execute(((IInsert)command), this);
- } else if (command instanceof org.teiid.connector.language.IUpdate) {
- UpdateExecutionImpl ex = new UpdateExecutionImpl();
- result = ex.execute(((IUpdate)command), this);
- }
- }
-
- @Override
- public int[] getUpdateCounts() throws DataNotAvailableException,
- ConnectorException {
- return new int[] {result};
- }
-
- public RuntimeMetadata getMetadata() {
- return metadata;
- }
-
- public ConnectorEnvironment getConnectorEnv() {
- return connectorEnv;
- }
-
- public SalesforceConnection getConnection() {
- return connection;
- }
-
- String[] getIDs(ICriteria criteria, IQueryProvidingVisitor visitor) throws ConnectorException {
- String[] Ids = null;
- if (visitor.hasOnlyIDCriteria()) {
- try {
- String Id = ((ICompareCriteria)criteria).getRightExpression().toString();
- Id = Util.stripQutes(Id);
- Ids = new String[] { Id };
- } catch (ClassCastException cce) {
- throw new RuntimeException(
- "Error: The delete criteria is not a CompareCriteria");
- }
-
- } else if (visitor.hasCriteria()) {
- String query = visitor.getQuery();
- QueryResult results = getConnection().query(query, context.getBatchSize(), Boolean.FALSE);
- if (null != results && results.getSize() > 0) {
- ArrayList<String> idList = new ArrayList<String>(results
- .getRecords().length);
- for (int i = 0; i < results.getRecords().length; i++) {
- SObject sObject = results.getRecords(i);
- idList.add(sObject.getId());
- }
- Ids = idList.toArray(new String[0]);
- }
- }
- return Ids;
- }
-}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -76,6 +76,10 @@
protected Group table;
boolean onlyIDCriteria;
protected Boolean queryAll = Boolean.FALSE;
+
+ // support for invoking a retrieve when possible.
+ protected IInCriteria idInCriteria = null;
+
public CriteriaVisitor( RuntimeMetadata metadata ) {
this.metadata = metadata;
@@ -322,9 +326,12 @@
private void appendCriteria( IInCriteria criteria ) throws ConnectorException {
StringBuffer queryString = new StringBuffer();
+ IExpression leftExp = criteria.getLeftExpression();
+ if(isIdColumn(leftExp)) {
+ idInCriteria = criteria;
+ }
+ queryString.append(getValue(leftExp));
queryString.append(' ');
- queryString.append(getValue(criteria.getLeftExpression()));
- queryString.append(' ');
if (criteria.isNegated()) {
queryString.append("NOT ");
}
@@ -354,7 +361,7 @@
return result;
}
- private String getValue( IExpression expr ) throws ConnectorException {
+ protected String getValue( IExpression expr ) throws ConnectorException {
String result;
if (expr instanceof IElement) {
IElement element = (IElement)expr;
@@ -378,7 +385,7 @@
}
List<Element> columnIds = table.getChildren();
for (Element element : columnIds) {
- String name = table.getName() + '.' + element.getName();
+ String name = table.getName() + '.' + element.getNameInSource();
columnElementsByName.put(name, element);
// influences queryAll behavior
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -51,6 +51,7 @@
private int idIndex = -1; // index of the ID select symbol.
protected List<ISelectSymbol> selectSymbols;
protected StringBuffer limitClause = new StringBuffer();
+ private Boolean supportsRetrieve;
public SelectVisitor(RuntimeMetadata metadata) {
super(metadata);
@@ -112,6 +113,7 @@
if(fromItem instanceof IGroup) {
table = ((IGroup)fromItem).getMetadataObject();
String supportsQuery = (String)table.getProperties().get(Constants.SUPPORTS_QUERY);
+ supportsRetrieve = Boolean.valueOf((String)table.getProperties().get(Constants.SUPPORTS_RETRIEVE));
if (!Boolean.valueOf(supportsQuery)) {
throw new ConnectorException(table.getNameInSource() + " "
+ Messages.getString("CriteriaVisitor.query.not.supported"));
@@ -198,4 +200,37 @@
return queryAll;
}
+
+ public String getRetrieveFieldList() throws ConnectorException {
+ assertRetrieveValidated();
+ StringBuffer result = new StringBuffer();
+ addSelectSymbols(table.getNameInSource(), result);
+ return result.toString();
+ }
+
+
+ public String[] getIdInCriteria() throws ConnectorException {
+ assertRetrieveValidated();
+ List<IExpression> expressions = this.idInCriteria.getRightExpressions();
+ String[] result = new String[expressions.size()];
+ for(int i = 0; i < expressions.size(); i++) {
+ result[i] = getValue(expressions.get(i));
+ }
+ return result;
+ }
+
+ private void assertRetrieveValidated() throws AssertionError {
+ if(!hasOnlyIDCriteria()) {
+ throw new AssertionError("Must call hasOnlyIdInCriteria() before this method");
+ }
+ }
+
+ public boolean hasOnlyIdInCriteria() {
+ return hasOnlyIDCriteria() && idInCriteria != null;
+ }
+
+ public boolean canRetrieve() {
+ return supportsRetrieve && hasOnlyIDCriteria();
+ }
+
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -21,8 +21,6 @@
*/
package com.metamatrix.connector.salesforce.execution.visitors;
-import java.util.Iterator;
-
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.IUpdate;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2009-12-11 18:32:04 UTC (rev 1649)
+++ trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2009-12-11 19:59:37 UTC (rev 1650)
@@ -132,23 +132,37 @@
visitor.visit(command);
assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (NOT (Account.AccountName LIKE '%foo')) OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
}
+
- // I can't really write this test until I see what teiid is going to pass the connectro based upon the user query.
- // SELECT Account.Name AS c_0, Contact.Name AS c_1 FROM Contact LEFT OUTER JOIN Account ON Account.Id = Contact.AccountId
+ @Test public void testIN() throws Exception {
+ IQuery command = (IQuery)translationUtility.parseCommand("select * from Account where Industry IN (1,2,3)"); //$NON-NLS-1$
+ SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
+ visitor.visit(command);
+ assertFalse(visitor.hasOnlyIDCriteria());
+ assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE Industry IN('1','2','3')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
+
+ }
+
+ @Test public void testOnlyIDsIN() throws Exception {
+ // this can resolve to a better performing retrieve call
+ IQuery command = (IQuery)translationUtility.parseCommand("select * from Account where ID IN (1,2,3)"); //$NON-NLS-1$
+ SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
+ visitor.visit(command);
+ assertTrue(visitor.hasOnlyIdInCriteria());
+ assertEquals("Account", visitor.getTableName());
+ assertEquals("Account.id, Account.AccountName, Account.Stuff, Account.Industry", visitor.getRetrieveFieldList());
+ assertEquals(new String[]{"1", "2", "3"}, visitor.getIdInCriteria());
+ }
+
@Test public void testJoin() throws Exception {
IQuery command = (IQuery)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Contact LEFT OUTER JOIN Account ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
-
SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.AccountName, Contact.ContactName FROM Contact", visitor.getQuery().toString().trim()); //$NON-NLS-1$
- // SELECT Contact.Id, Contact.Name, Account.Name FROM Contact WHERE Account.Industry != 'media'
- // Looks like using q names will work, but we need to distinguish between the parent and child table somehow cannot send
- // SELECT Contact.Id, Contact.Name, Account.Name FROM Contact, Account WHERE Account.Industry != 'media'
}
@Test public void testJoin2() throws Exception {
IQuery command = (IQuery)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Account LEFT OUTER JOIN Contact ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
-
SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.AccountName, (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
15 years
teiid SVN: r1649 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-11 13:32:04 -0500 (Fri, 11 Dec 2009)
New Revision: 1649
Modified:
trunk/test-integration/db/src/main/resources/qe-test.properties
Log:
Teiid 781 - documenting the qe config props file
Modified: trunk/test-integration/db/src/main/resources/qe-test.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/qe-test.properties 2009-12-11 16:09:22 UTC (rev 1648)
+++ trunk/test-integration/db/src/main/resources/qe-test.properties 2009-12-11 18:32:04 UTC (rev 1649)
@@ -1,25 +1,41 @@
-# NOTES:
-# - ${queryset.dir} property is expected to come from the scenario file, indicating which queryset of files to use (because each scenario could be different)
+# The qe-test.properties is used by the bulk client testing .
+# This file provides properties to the process in 2 ways:
+# 1. It acts as a template when property substitution is involved. Meaning the property value will be derived
+# at execution time.
+# 2. The other properties will be static.
-# Need to setup the following system properties that will be picked up and substituted
-# - query.artifacts.dir - indicating where all query sets can be found
-# - vdb.artifacts.dir - indicates where all the vdb can be found
+##--- The following properties are expected to come from the scenario file
+# - ${queryset.dir} indicate which queryset of files to use (because each scenario could be different, bqt, sp, etc)
+# - ${test.queries.dir} indicates which directory in the ${queryset.dir} to find the queries to run.
+# - ${expected.results.dir} indicates which directory in the ${queryset.dir} to find the expected results. This may be different when
+# multiple scenarios use the same queries but have different expected results
+
+##--- The following properties are expected to be passed in as system properties
+# - ${queryset.artifacts.dir} indicates where all query sets can be found
+# - ${vdb.artifacts.dir} indicates where the vdbs can be found
+
+
+# the location where a specific query set can be found
queryfiles.loc=${queryset.artifacts.dir}/${queryset.dir}/${test.queries.dir}
+# the location where the specific expected result files can be found
results.loc=${queryset.artifacts.dir}/${queryset.dir}/${expected.results.dir}
#
-# 3 - where to find the vdb's, which is used to define the vdb.definition setting in the deploy.properties
+# where to find the vdb's, which is used to define the vdb.definition setting in the deploy.properties
vdb.loc=${vdb.artifacts.dir}
# turn off the configuration of the datastores (data refresh) and connector bindings (seting the datastore connection info)
disable_datastore=true
-
+# the location where newly generated expected results will be created (resultmode = generate)
generatedir=target/bulk-query-tests/${queryset.dir}/generate
+# the comparison reports for each query set
outputdir=target/bulk-query-tests/${queryset.dir}/output
+
+# write the summary files out to this location to make it easier to assimilate the files
summarydir=target/bulk-query-tests
@@ -28,7 +44,10 @@
transaction-type=offwrap
#transaction-type=local
-
+# resultmode options:
+# - compare : compare actual results to expected results
+# - generate : create new expected results
+# - none : run the queries, only report when errors occur
resultmode=compare
15 years