Skip to content

Commit

Permalink
TEIID-5198 allowing for additional partial name resolving for procedures
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jan 3, 2018
1 parent 70edb38 commit 7f7dfe5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Expand Up @@ -131,14 +131,13 @@ public Collection<Procedure> getStoredProcedure(String name) throws TeiidCompone
if (index > -1) {
String schemaName = name.substring(0, index);
Schema schema = getSchema(schemaName);
if (schema == null ) {
throw new QueryMetadataException(QueryPlugin.Event.TEIID30352, name+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
Procedure proc = schema.getProcedures().get(name.substring(index + 1));
if (proc != null) {
result.add(proc);
return result;
}
if (schema != null ) {
Procedure proc = schema.getProcedures().get(name.substring(index + 1));
if (proc != null) {
result.add(proc);
return result;
}
}
}
//assume it's a partial name
for (Schema schema : getSchemas().values()) {
Expand Down
Expand Up @@ -1173,4 +1173,13 @@ public static TransformationMetadata createMetadata(String ddl) throws Exception
TestValidator.helpValidate("begin declare string var; var = exec proc(); select var; end", new String[] {"SELECT var;"}, tm);
}

@Test public void testDotInName() throws Exception {
String ddl = "CREATE FOREIGN PROCEDURE \"my.proc\" (param STRING) RETURNS TABLE (a INTEGER, b STRING);"; //$NON-NLS-1$
TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "y");
StoredProcedure sp = (StoredProcedure) TestResolver.helpResolve("exec \"my.proc\"()", tm);
assertEquals(2, sp.getProjectedSymbols().size());
assertEquals("y.my.proc.b", sp.getProjectedSymbols().get(1).toString());
TestValidator.helpValidate("begin exec proc(); end", new String[] {}, tm);
}

}

0 comments on commit 7f7dfe5

Please sign in to comment.