class_docstr: Expression renderer for the BigQuery engine.
class_docstr_tok: ["Expression","renderer","for","the","BigQuery","engine","."]
docstr: Render a percentile expression for BigQuery.
  
  Use the fraction class to determine numerator and denominator for offset and quantile.
  For example - 0.5 or median would be 1/2 - generate two quantiles and pick the 1-indexed value
  from the result list [min, median, max].
docstr_tok: ["Render","a","percentile","expression","for","BigQuery",".","Use","the","fraction","class","to","determine","numerator","and","denominator","for","offset","and","quantile",".","For","example","-","0.5","or","median","would","be","1\/2","-","generate","two","quantiles","and","pick","the","1-indexed","value","from","the","result","list","[","min",",","median",",","max","]","."]
code: def visit_percentile_expr(
      self, node: SqlPercentileExpression
  ) -> SqlExpressionRenderResult:
      """Render a percentile expression for BigQuery.
  
      Use the fraction class to determine numerator and denominator for offset and quantile.
      For example - 0.5 or median would be 1/2 - generate two quantiles and pick the 1-indexed value
      from the result list [min, median, max].
      """
      if (
          node.percentile_args.function_type
          is SqlPercentileFunctionType.APPROXIMATE_CONTINUOUS
      ):
          arg_rendered = self.render_sql_expr(node.order_by_arg)
          params = arg_rendered.bind_parameters
          percentile = node.percentile_args.percentile
  
          fraction = Fraction(percentile).limit_denominator()
  
          return SqlExpressionRenderResult(
              sql=f"APPROX_QUANTILES({arg_rendered.sql}, {fraction.denominator})[OFFSET({fraction.numerator})]",
              bind_parameters=params,
          )
      elif (
          node.percentile_args.function_type
          is SqlPercentileFunctionType.APPROXIMATE_DISCRETE
          or node.percentile_args.function_type
          is SqlPercentileFunctionType.CONTINUOUS
          or node.percentile_args.function_type
          is SqlPercentileFunctionType.DISCRETE
      ):
          raise UnsupportedEngineFeatureError(
              "Only approximate continous percentile aggregations are supported for BigQuery. Set "
              + "use_approximate_percentile and disable use_discrete_percentile in all percentile measures."
          )
      else:
          assert_values_exhausted(node.percentile_args.function_type)
  
imports: from __future__ import annotations
  from fractions import Fraction
  from typing import Collection
  from dbt_semantic_interfaces.enum_extension import assert_values_exhausted
  from dbt_semantic_interfaces.type_enums.date_part import DatePart
  from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
  from typing_extensions import override
  from metricflow.errors.errors import UnsupportedEngineFeatureError
  from metricflow.sql.render.expr_renderer import DefaultSqlExpressionRenderer, SqlExpressionRenderer, SqlExpressionRenderResult
  from metricflow.sql.render.sql_plan_renderer import DefaultSqlQueryPlanRenderer
  from metricflow.sql.sql_bind_parameters import SqlBindParameters
  from metricflow.sql.sql_exprs import SqlCastToTimestampExpression, SqlDateTruncExpression, SqlExtractExpression, SqlGenerateUuidExpression, SqlPercentileExpression, SqlPercentileFunctionType, SqlSubtractTimeIntervalExpression
  from metricflow.sql.sql_plan import SqlSelectColumn
label_desc: Use image node_id 5 for calling the BigQuerySqlExpressionRenderer obj's underlying member method code with example usage: obj.visit_percentile_expr(node) and returns: SqlExpressionRenderResult