def METHOD_NAME(expression: exp.Expression, dialect: str) -> MeasureAndDimTables:
    """Finds all the table references in a metric definition.
    Additionally ensure than the first table returned is the 'measure' or numeric value being aggregated.
    """
    tables = {}
    measure_table = None
    def is_measure(node: exp.Expression) -> bool:
        parent = node.parent
        if isinstance(parent, exp.AggFunc) and node.arg_key == "this":
            return True
        if isinstance(parent, (exp.If, exp.Case)) and node.arg_key != "this":
            return is_measure(parent)
        if isinstance(parent, (exp.Binary, exp.Paren, exp.Distinct)):
            return is_measure(parent)
        return False
    for node, _, key in expression.walk():
        if isinstance(node, exp.Column) and node.table:
            table = d.normalize_model_name(node, dialect=dialect)
            tables[table] = True
            if not measure_table and is_measure(node):
                measure_table = table
    if not measure_table:
        raise ConfigError(f"Could not infer a measures table from '{expression}'")
    tables.pop(measure_table)
    return (measure_table, tuple(tables.keys()))