import { getParsedReference } from '../../compiler/exploreCompiler';
import { getReferencedDimension, getReferencedDimensionCaseInsensitive, getReferencedMetric, } from '../../compiler/referenceLookup';
const getParsedMetricReference = ({ metric, ref, }) => {
    if (ref === 'TABLE') {
        return undefined;
    }
    return getParsedReference(ref, metric.table);
};
export const getReferencedDimensionForPreAggregation = ({ metric, ref, tables, }) => {
    const parsedReference = getParsedMetricReference({ metric, ref });
    if (!parsedReference) {
        return undefined;
    }
    return getReferencedDimension(parsedReference.refTable, parsedReference.refName, tables);
};
export const getReferencedMetricForPreAggregation = ({ metric, ref, tables, }) => {
    const parsedReference = getParsedMetricReference({ metric, ref });
    if (!parsedReference) {
        return undefined;
    }
    return getReferencedMetric(parsedReference.refTable, parsedReference.refName, tables);
};
export const getReferencedFilterDimensionForPreAggregation = ({ metric, fieldRef, tables, }) => {
    const { refTable, refName } = getParsedReference(fieldRef, metric.table);
    return getReferencedDimensionCaseInsensitive(refTable, refName, tables);
};
//# sourceMappingURL=referenceLookup.js.map