class_docstr: Expression renderer for the Databricks engine.
class_docstr_tok: ["Expression","renderer","for","the","Databricks","engine","."]
docstr: Render a percentile expression for Databricks.
docstr_tok: ["Render","a","percentile","expression","for","Databricks","."]
code: def visit_percentile_expr(
      self, node: SqlPercentileExpression
  ) -> SqlExpressionRenderResult:
      """Render a percentile expression for Databricks."""
      arg_rendered = self.render_sql_expr(node.order_by_arg)
      params = arg_rendered.bind_parameters
      percentile = node.percentile_args.percentile
  
      if (
          node.percentile_args.function_type
          is SqlPercentileFunctionType.CONTINUOUS
      ):
          function_str = "PERCENTILE_CONT"
      elif (
          node.percentile_args.function_type
          is SqlPercentileFunctionType.DISCRETE
      ):
          # discrete percentile only supported on databricks 11.0 >=. Disable for now.
          raise UnsupportedEngineFeatureError(
              "Discrete percentile aggregate not supported for Databricks.  Use "
              + "continuous or approximate discrete percentile in all percentile measures."
          )
      elif (
          node.percentile_args.function_type
          is SqlPercentileFunctionType.APPROXIMATE_CONTINUOUS
      ):
          raise UnsupportedEngineFeatureError(
              "Approximate continuous percentile aggregate not supported for Databricks. Use "
              + "continuous or approximate discrete percentile in all percentile measures."
          )
      elif (
          node.percentile_args.function_type
          is SqlPercentileFunctionType.APPROXIMATE_DISCRETE
      ):
          return SqlExpressionRenderResult(
              sql=f"APPROX_PERCENTILE({arg_rendered.sql}, {percentile})",
              bind_parameters=params,
          )
      else:
          assert_values_exhausted(node.percentile_args.function_type)
  
      return SqlExpressionRenderResult(
          sql=f"{function_str}({percentile}) WITHIN GROUP (ORDER BY ({arg_rendered.sql}))",
          bind_parameters=params,
      )
  
file_path: metricflow/metricflow/sql/render/databricks.py
imports: from __future__ import annotations
  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 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_exprs import SqlPercentileExpression, SqlPercentileFunctionType
label_desc: Use image node_id 3 for calling the DatabricksSqlExpressionRenderer obj's underlying member method code with example usage: obj.visit_percentile_expr(node) and returns: SqlExpressionRenderResult, SqlExpressionRenderResult