A query library may be either internal or external. An internal library would be primarily used in hthor queries for testing and debugging before deploying to Roxie. Although you can use internal query libraries in Roxie queries, the advantages come from using the external version.
An external query library is created by the BUILD action, which compiles the query library into its own workunit. The name of the library is the job name associated with the workunit. Therefore, the #WORKUNIT would normally be used to give the workunit a meaningful job name, as in this example:
#WORKUNIT('name','Ppass.FilterDsLib'); BUILD(FilterDsLib1);
This code builds the library for the INTERFACE parameter version of the code above:
#WORKUNIT('name','Ipass.FilterDsLib'); BUILD(FilterDsLib2);
The system maintains a catalog of the latest versions of each query library that is updated whenever a library is built. Hthor uses this to resolve query libraries when running a query (as will Thor, when it eventually supports query libraries). Roxie uses the query aliasing mechanism in the same way.