class_docstr: Resolves inputs to a query (e.g. metrics, group by items into concrete specs.
class_docstr_tok: ["Resolves","inputs","to","a","query","(","e.g",".","metrics",",","group","by","items","into","concrete","specs","."]
code: def _resolve_query(
      self, resolver_input_for_query: ResolverInputForQuery
  ) -> MetricFlowQueryResolution:
      metric_inputs = resolver_input_for_query.metric_inputs
      group_by_item_inputs = (
          resolver_input_for_query.group_by_item_inputs
      )
      order_by_item_inputs = (
          resolver_input_for_query.order_by_item_inputs
      )
      limit_input = resolver_input_for_query.limit_input
      query_level_filter_input = resolver_input_for_query.filter_input
      min_max_only_input = resolver_input_for_query.min_max_only
  
      # Define a resolution path for issues where the input is considered to be the whole query.
      query_resolution_path = MetricFlowQueryResolutionPath.from_path_item(
          QueryGroupByItemResolutionNode(
              parent_nodes=(),
              metrics_in_query=tuple(
                  metric_input.spec_pattern.metric_reference
                  for metric_input in metric_inputs
              ),
              where_filter_intersection=query_level_filter_input.where_filter_intersection,
          )
      )
  
      mappings_to_merge: List[InputToIssueSetMapping] = []
  
      # Resolve metrics.
      resolve_metrics_result = self._resolve_metric_inputs(
          metric_inputs, query_resolution_path=query_resolution_path
      )
      mappings_to_merge.append(
          resolve_metrics_result.input_to_issue_set_mapping
      )
      metric_specs = resolve_metrics_result.metric_specs
  
      # Resolve limit
      resolve_limit_result = self._resolve_limit_input(
          limit_input=limit_input,
          query_resolution_path=query_resolution_path,
      )
      mappings_to_merge.append(
          resolve_limit_result.input_to_issue_set_mapping
      )
  
      # Resolve min max only
      resolve_min_max_only_result = self._resolve_min_max_only_input(
          min_max_only_input=min_max_only_input,
          query_resolution_path=query_resolution_path,
          metric_inputs=metric_inputs,
          group_by_item_inputs=group_by_item_inputs,
          order_by_item_inputs=order_by_item_inputs,
          limit_input=limit_input,
      )
      mappings_to_merge.append(
          resolve_min_max_only_result.input_to_issue_set_mapping
      )
  
      # Early stop before resolving further as with invalid metrics, the errors won't be as useful.
      issue_set_mapping_so_far = InputToIssueSetMapping.merge_iterable(
          mappings_to_merge
      )
      if issue_set_mapping_so_far.has_issues:
          return MetricFlowQueryResolution(
              query_spec=None,
              resolution_dag=None,
              filter_spec_lookup=FilterSpecResolutionLookUp.empty_instance(),
              input_to_issue_set=issue_set_mapping_so_far,
          )
  
      # Resolve group by items.
      resolve_group_by_item_result = (
          self._resolve_group_by_items_result(
              metric_references=tuple(
                  metric_spec.reference for metric_spec in metric_specs
              ),
              group_by_item_inputs=group_by_item_inputs,
              filter_input=query_level_filter_input,
          )
      )
      resolution_dag = resolve_group_by_item_result.resolution_dag
      group_by_item_specs = (
          resolve_group_by_item_result.group_by_item_specs
      )
      mappings_to_merge.append(
          resolve_group_by_item_result.input_to_issue_set_mapping
      )
  
      # Resolve order by.
      resolve_order_by_result = (
          MetricFlowQueryResolver._resolve_order_by(
              resolver_inputs_for_order_by_items=order_by_item_inputs,
              metric_specs=metric_specs,
              group_by_item_specs=group_by_item_specs,
              query_resolution_path=query_resolution_path,
          )
      )
      order_by_specs = resolve_order_by_result.order_by_specs
      if resolve_order_by_result.input_to_issue_set_mapping.has_issues:
          mappings_to_merge.append(
              resolve_order_by_result.input_to_issue_set_mapping
          )
  
      # Resolve all where filters in the DAG and generate mappings if there are issues.
      filter_spec_lookup = self._build_filter_spec_lookup(
          resolution_dag
      )
      for filter_spec_resolution in filter_spec_lookup.spec_resolutions:
          if filter_spec_resolution.issue_set.has_issues:
              mappings_to_merge.append(
                  InputToIssueSetMapping.from_one_item(
                      resolver_input=ResolverInputForWhereFilterIntersection(
                          filter_resolution_path=filter_spec_resolution.filter_location_path,
                          where_filter_intersection=filter_spec_resolution.where_filter_intersection,
                          object_builder_str=filter_spec_resolution.object_builder_str,
                      ),
                      issue_set=filter_spec_resolution.issue_set,
                  )
              )
  
      for (
          non_parseable_resolution
      ) in filter_spec_lookup.non_parsable_resolutions:
          filter_resolver_input = ResolverInputForWhereFilterIntersection(
              filter_resolution_path=non_parseable_resolution.filter_location_path,
              where_filter_intersection=non_parseable_resolution.where_filter_intersection,
              object_builder_str=None,
          )
          mappings_to_merge.append(
              InputToIssueSetMapping.from_one_item(
                  resolver_input=filter_resolver_input,
                  issue_set=non_parseable_resolution.issue_set,
              )
          )
  
      # Return if there are any errors as issues generated by later validations may not make sense otherwise.
      issue_set_mapping_so_far = InputToIssueSetMapping.merge_iterable(
          mappings_to_merge
      )
      if issue_set_mapping_so_far.has_issues:
          return MetricFlowQueryResolution(
              query_spec=None,
              resolution_dag=resolution_dag,
              filter_spec_lookup=filter_spec_lookup,
              input_to_issue_set=issue_set_mapping_so_far,
          )
  
      # No errors.
      linkable_spec_set = LinkableSpecSet.from_specs(
          group_by_item_specs
      )
      logger.info(
          f"Group-by-items were resolved to:\n{mf_pformat(linkable_spec_set.as_tuple)}"
      )
  
      # Run post-resolution validation rules to generate issues that are generated at the query-level.
      query_level_issue_set = (
          self._post_resolution_query_validator.validate_query(
              resolution_dag=resolution_dag,
              resolver_input_for_query=resolver_input_for_query,
          )
      )
  
      if query_level_issue_set.has_issues:
          mappings_to_merge.append(
              InputToIssueSetMapping(
                  (
                      InputToIssueSetMappingItem(
                          resolver_input=resolver_input_for_query,
                          issue_set=query_level_issue_set,
                      ),
                  )
              )
          )
  
      issue_set_mapping = InputToIssueSetMapping.merge_iterable(
          mappings_to_merge
      )
  
      if issue_set_mapping.has_issues:
          return MetricFlowQueryResolution(
              query_spec=None,
              resolution_dag=resolution_dag,
              filter_spec_lookup=filter_spec_lookup,
              input_to_issue_set=issue_set_mapping,
          )
  
      return MetricFlowQueryResolution(
          query_spec=MetricFlowQuerySpec(
              metric_specs=metric_specs,
              dimension_specs=linkable_spec_set.dimension_specs,
              entity_specs=linkable_spec_set.entity_specs,
              time_dimension_specs=linkable_spec_set.time_dimension_specs,
              order_by_specs=tuple(order_by_specs),
              limit=limit_input.limit,
              filter_intersection=query_level_filter_input.where_filter_intersection,
              filter_spec_resolution_lookup=filter_spec_lookup,
              min_max_only=min_max_only_input.min_max_only,
          ),
          resolution_dag=resolution_dag,
          filter_spec_lookup=filter_spec_lookup,
          input_to_issue_set=issue_set_mapping,
      )
  
imports: from __future__ import annotations
  import logging
  from dataclasses import dataclass
  from typing import List, Optional, Sequence, Tuple
  from dbt_semantic_interfaces.references import MetricReference
  from metricflow.dag.dag_to_text import dag_as_text
  from metricflow.mf_logging.pretty_print import mf_pformat
  from metricflow.mf_logging.runtime import log_runtime
  from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
  from metricflow.naming.metric_scheme import MetricNamingScheme
  from metricflow.query.group_by_item.filter_spec_resolution.filter_pattern_factory import WhereFilterPatternFactory
  from metricflow.query.group_by_item.filter_spec_resolution.filter_spec_lookup import FilterSpecResolutionLookUp
  from metricflow.query.group_by_item.filter_spec_resolution.filter_spec_resolver import WhereFilterSpecResolver
  from metricflow.query.group_by_item.group_by_item_resolver import GroupByItemResolution, GroupByItemResolver
  from metricflow.query.group_by_item.resolution_dag.dag import GroupByItemResolutionDag
  from metricflow.query.group_by_item.resolution_dag.dag_builder import GroupByItemResolutionDagBuilder
  from metricflow.query.group_by_item.resolution_dag.resolution_nodes.query_resolution_node import QueryGroupByItemResolutionNode
  from metricflow.query.group_by_item.resolution_path import MetricFlowQueryResolutionPath
  from metricflow.query.issues.issues_base import MetricFlowQueryResolutionIssueSet
  from metricflow.query.issues.parsing.invalid_limit import InvalidLimitIssue
  from metricflow.query.issues.parsing.invalid_metric import InvalidMetricIssue
  from metricflow.query.issues.parsing.invalid_min_max_only import InvalidMinMaxOnlyIssue
  from metricflow.query.issues.parsing.invalid_order import InvalidOrderByItemIssue
  from metricflow.query.query_resolution import InputToIssueSetMapping, InputToIssueSetMappingItem, MetricFlowQueryResolution
  from metricflow.query.resolver_inputs.query_resolver_inputs import ResolverInputForGroupByItem, ResolverInputForLimit, ResolverInputForMetric, ResolverInputForMinMaxOnly, ResolverInputForOrderByItem, ResolverInputForQuery, ResolverInputForQueryLevelWhereFilterIntersection, ResolverInputForWhereFilterIntersection
  from metricflow.query.suggestion_generator import QueryItemSuggestionGenerator
  from metricflow.query.validation_rules.query_validator import PostResolutionQueryValidator
  from metricflow.specs.patterns.match_list_pattern import MatchListSpecPattern
  from metricflow.specs.specs import InstanceSpec, LinkableInstanceSpec, LinkableSpecSet, MetricFlowQuerySpec, MetricSpec, OrderBySpec
label_desc: Use image node_id 10 for calling the MetricFlowQueryResolver obj's underlying member method code with example usage: obj._resolve_query(resolver_input_for_query) and returns: MetricFlowQueryResolution, MetricFlowQueryResolution, MetricFlowQueryResolution, MetricFlowQueryResolution