If we need to find the SQL query from an entity we can create a new query and copy paste the datasource from entity to the new query and write below job to get the SQL query as a string.
class RunnableClasstest
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
query query;
queryBuildDataSource qbds;
;
query = new Query(queryStr(querytest));
info(query.dataSourceNo(1).toString());
}
}