support building tables from queries