code: def to_date(
      date_str: Union[str, Expression[str]],
      format: Union[str, Expression[str]] = None,
  ) -> Expression:
      """
      Converts the date string with the given format (by default 'yyyy-MM-dd') to a date.
  
      :param date_str: The date string
      :param format: The format of the string
      :return: The date value with DATE type.
      """
      if format is None:
          return _unary_op("toDate", date_str)
      else:
          return _binary_op("toDate", date_str, format)
  
imports: from typing import Union
  from pyflink import add_version_doc
  from pyflink.java_gateway import get_gateway
  from pyflink.table.expression import Expression, _get_java_expression, TimePointUnit, JsonOnNull
  from pyflink.table.types import _to_java_data_type, DataType
  from pyflink.table.udf import UserDefinedFunctionWrapper
  from pyflink.util.java_utils import to_jarray, load_java_class
label_desc: Use image node_id 21 for calling a global function with example usage: to_date(date_str, format) and returns: _unary_op, _binary_op