Skip to content

Commit

Permalink
TEIID-2796 ensuring multi-source works with a vdb import
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Feb 6, 2014
1 parent 2b68c9b commit 1294b13
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Expand Up @@ -261,7 +261,7 @@ public void metadataLoadFinished() {

TransformationMetadata metadata = buildTransformationMetaData(mergedVDB, getVisibilityMap(), mergedStore, getUDF(), systemFunctions, this.additionalStores);
QueryMetadataInterface qmi = metadata;
Map<String, String> multiSourceModels = MultiSourceMetadataWrapper.getMultiSourceModels(vdb);
Map<String, String> multiSourceModels = MultiSourceMetadataWrapper.getMultiSourceModels(mergedVDB);
if(multiSourceModels != null && !multiSourceModels.isEmpty()) {
qmi = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
}
Expand Down
Expand Up @@ -43,6 +43,10 @@ public class HardCodedExecutionFactory extends ExecutionFactory<Object, Object>
Map<String, List<? extends List<?>>> dataMap = new HashMap<String, List<? extends List<?>>>();
Map<String, int[]> updateMap = new HashMap<String, int[]>();

public HardCodedExecutionFactory() {
setSourceRequired(false);
}

@Override
public ResultSetExecution createResultSetExecution(
final QueryExpression command, ExecutionContext executionContext,
Expand Down Expand Up @@ -118,11 +122,6 @@ public int[] getUpdateCounts() throws DataNotAvailableException,
};
}

@Override
public boolean isSourceRequired() {
return false;
}

public void addData(String key, List<? extends List<?>> list) {
this.dataMap.put(key, list);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import org.teiid.adminapi.impl.VDBImportMetadata;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.FakeServer.DeployVDBParameter;
import org.teiid.runtime.HardCodedExecutionFactory;


@SuppressWarnings("nls")
Expand Down Expand Up @@ -115,4 +116,26 @@ public void testMergeWithEmptyVDB() throws Exception {

execute("select * from vw"); //$NON-NLS-1$
}

@Test public void testMergeWithMultiSource() throws Exception {
HardCodedExecutionFactory hc = new HardCodedExecutionFactory();
hc.addData("SELECT tbl.col FROM tbl", Arrays.asList(Arrays.asList("a")));
server.addTranslator("hc", hc);
server.deployVDB(new ByteArrayInputStream(new String("<vdb name=\"ms-base\" version=\"1\">"
+ "<model name=\"myschema\"><source name=\"a\" translator-name=\"hc\"/><source name=\"b\" translator-name=\"hc\"/>"
+ "<metadata type = \"DDL\"><![CDATA[CREATE foreign table tbl (col string);]]></metadata></model>"
+ "</vdb>").getBytes()));
this.internalConnection = server.createConnection("jdbc:teiid:ms-base");

execute("select * from tbl"); //$NON-NLS-1$
assertRowCount(2);

server.deployVDB(new ByteArrayInputStream(new String("<vdb name=\"ms-2\" version=\"1\">"
+ "<import-vdb name=\"ms-base\" version=\"1\"/>"
+ "</vdb>").getBytes()));
this.internalConnection = server.createConnection("jdbc:teiid:ms-2");

execute("select * from tbl"); //$NON-NLS-1$
assertRowCount(2);
}
}

0 comments on commit 1294b13

Please sign in to comment.