src/util.js
/**
 * replaces tablename with union of tables from one dataset or multiple datasets
 * i.e:
 * if query inputted is SELECT req_url FROM ^myrequest
 * output will become SELECT req_url FROM (SELECT * FROM helix_logging_myService.requests*)
 *
 * @param {string} query a query loaded from loadQuery with placeholders
 * @param {object} replacers an function mapping from placeholders to replacer methods
 */
replaces tablename with union of tables from one dataset or multiple datasets
i.e:
if query inputted is SELECT req_url FROM ^myrequest
output will become SELECT req_url FROM (SELECT * FROM helix_logging_myService.requests*)

@param {string} query a query loaded from loadQuery with placeholders
@param {object} replacers an function mapping from placeholders to replacer methods
replaces tablename with union of tables from one dataset or multiple datasets i . e : if query inputted is SELECT req_url FROM ^myrequest output will become SELECT req_url FROM ( SELECT * FROM helix_logging_myService . requests * ) @param { string } query a query loaded from loadQuery with placeholders @param { object } replacers an function mapping from placeholders to replacer methods
async function replaceTableNames(query, replacers) {
  const replacements = await (query.match(/\^[a-z]+/g) ? query.match(/\^[a-z]+/g) : [])
    .map((placeholder) => placeholder.substr(1))
    .reduce(async (pvp, placeholder) => {
      const pv = await pvp;
      if (pv[placeholder]) {
        return pv;
      }
      pv[placeholder] = await replacers[placeholder]();
      return pv;
    }, {});
  return Object.keys(replacements).reduce((q, placeholder) => q.replace(new RegExp(`\\^${placeholder}`, 'g'), replacements[placeholder]), query);
}
async function replaceTableNames ( query , replacers ) { const replacements = await ( query . match ( / \^[a-z]+ / g ) ? query . match ( / \^[a-z]+ / g ) : [ ] ) . map ( ( placeholder ) => placeholder . substr ( 1 ) ) . reduce ( async ( pvp , placeholder ) => { const pv = await pvp ; if ( pv [ placeholder ] ) { return pv ; } pv [ placeholder ] = await replacers [ placeholder ] ( ) ; return pv ; } , { } ) ; return Object . keys ( replacements ) . reduce ( ( q , placeholder ) => q . replace ( new RegExp ( ` \\ ${ placeholder } ` , 'g' ) , replacements [ placeholder ] ) , query ) ; }
replaces tablename with union of tables from one dataset or multiple datasets
 i.e:
 if query inputted is SELECT req_url FROM ^myrequest
 output will become SELECT req_url FROM (SELECT * FROM helix_logging_myService.requests*)
replaces tablename with union of tables from one dataset or multiple datasets i . e : if query inputted is SELECT req_url FROM ^myrequest output will become SELECT req_url FROM ( SELECT * FROM helix_logging_myService . requests * )