<commit_before>
import _ from "underscore";
import { mbqlEq } from "../query/util";

import { VALID_OPERATORS, VALID_AGGREGATIONS } from "./tokens";

export { VALID_OPERATORS, VALID_AGGREGATIONS } from "./tokens";

export function formatAggregationName(aggregationOption) {
    return VALID_AGGREGATIONS.get(aggregationOption.short);
}

function formatIdentifier(name) {
    return /^\w+$/.test(name) ?
        name :
        JSON.stringify(name);
}

export function formatMetricName(metric) {<commit_msg>Allow aggregation names as field names (if quoted). Resolves #4049<commit_after>
import _ from "underscore";
import { mbqlEq } from "../query/util";

import { VALID_OPERATORS, VALID_AGGREGATIONS } from "./tokens";

export { VALID_OPERATORS, VALID_AGGREGATIONS } from "./tokens";

const RESERVED_WORDS = new Set(VALID_AGGREGATIONS.values());

export function formatAggregationName(aggregationOption) {
    return VALID_AGGREGATIONS.get(aggregationOption.short);
}

function formatIdentifier(name) {
    return /^\w+$/.test(name) && !RESERVED_WORDS.has(name) ?
        name :
        JSON.stringify(name);
}

export function formatMetricName(metric) {
{'fraction_non_alphanumeric': 0.12218370883882149, 'fraction_numerical': 0.0034662045060658577, 'mean_word_length': 4.8040201005025125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3098545', 'n_tokens_mistral': 378, 'n_tokens_neox': 363, 'n_words': 78}