Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Define list of string form query results to use in loop operation

Hi, I wanted to do this looping in dataform .sqlx file:

 

 

 

js {
const tables = [
'table1',
'table2',
'table3'
];

const selectAllFromTables = tables.map(t => {
    return `select * from \`${t}\``;
}).join(`
union all
`);
}

${selectAllFromTables}

 

 

 

 But I want the list of strings (const table = ) to come from the results of a query, very similar to run_query in dbt. Is it possible in dataform?

7 9 2,364
9 REPLIES 9