def get_table_match_type(p4_table):
    match_types = []
    for _, m_type, _ in p4_table.match_fields:
        match_types.append(match_type_to_str(m_type))

    if len(match_types) == 0:
        match_type = "exact"
    elif "range" in match_types:
        match_type = "range"
    elif "ternary" in match_types:
        match_type = "ternary"
    elif match_types.count("lpm") >= 2:  # pragma: no cover
        LOG_CRITICAL("cannot have 2 different lpm matches in a single table")
    elif "lpm" in match_types:
        match_type = "lpm"
    else:
        # that includes the case when we only have one valid match and
        # nothing else
        match_type = "exact"

    return match_type