}
public void addTapToConnection( LingualConnection connection, String schemaName, Tap tap, String tableAlias )
{
MapSchema rootSchema = (MapSchema) connection.getRootSchema();
TapSchema subSchema = (TapSchema) rootSchema.getSubSchema( schemaName );
SchemaDef schemaDef = schemaCatalog.getSchemaDef( schemaName );
if( tableAlias != null && schemaDef.getTable( tableAlias ) != null )
{
TapTable table = (TapTable) subSchema.getTable( tableAlias, Object.class );
if( table.getName().equals( tableAlias ) )
LOG.debug( "table exists: {}, discarding", tableAlias );
else
LOG.debug( "replacing alias: {}, for: {} ", tableAlias, table.getName() );
}
String currentTableName = createTableDefFor( schemaName, null, tap.getIdentifier(), tap.getSinkFields(), null, null );
TableDef tableDef = schemaDef.getTable( currentTableName );
TapTable tapTable = subSchema.addTapTableFor( tableDef ); // add table named after flow
LOG.debug( "adding table:{}", tableDef.getName() );
if( tableAlias != null && !tapTable.getName().equals( tableAlias ) )
{
LOG.debug( "adding alias: {}, for table: {}", tableAlias, tapTable.getName() );
subSchema.addTable( tableAlias, tapTable ); // add names after given tableName (LAST)
}
}