def cast_to_schema_type(field, schema_type):
    """
    generates cast expression to the type specified by the schema

    :param field: field name
    :param schema_type: type of the field as specified in the schema
    :return: string of cast expression
    """
    bq_int_float = {'integer': 'INT64', 'float': 'FLOAT64'}

    if schema_type.lower() not in bq_int_float:
        col = f'SAFE_CAST({field} AS {schema_type.upper()}) AS {field}'
    else:
        col = f'SAFE_CAST({field} AS {bq_int_float[schema_type]}) AS {field}'
    return col