def value_to_bigquery_field(
    name: str, value: Any, default_type: Optional[str] = None
) -> Optional[schema.SchemaField]:
    """Infers the BigQuery schema field type from a single value.

    Args:
        name:
            The name of the field.
        value:
            The value to infer the type from. If None, the default type is used
            if available.
        default_type:
            The default field type.  Defaults to None.

    Returns:
        The schema field, or None if a type cannot be inferred.
    """

    # Set the SchemaField datatype to the given default_type if the value
    # being assessed is None.
    if value is None:
        return schema.SchemaField(name, default_type)

    # Map from Python types to BigQuery types. This isn't super exhaustive
    # because we rely more on pyarrow, which can check more than one value to
    # determine the type.
    type_mapping = {
        str: "STRING",
    }

    # geopandas and shapely are optional dependencies, so only check if those
    # are installed.
    if _BaseGeometry is not None:
        type_mapping[_BaseGeometry] = "GEOGRAPHY"

    for type_, bq_type in type_mapping.items():
        if isinstance(value, type_):
            return schema.SchemaField(name, bq_type)

    # For timezone-naive datetimes, the later pyarrow conversion to try and
    # learn the type add a timezone to such datetimes, causing them to be
    # recognized as TIMESTAMP type. We thus additionally check the actual data
    # to see if we need to overrule that and choose DATETIME instead.
    #
    # See: https://github.com/googleapis/python-bigquery/issues/985
    # and https://github.com/googleapis/python-bigquery/pull/1061
    # and https://github.com/googleapis/python-bigquery-pandas/issues/450
    if isinstance(value, datetime.datetime):
        if value.tzinfo is not None:
            return schema.SchemaField(name, "TIMESTAMP")
        else:
            return schema.SchemaField(name, "DATETIME")

    return None
Infers the BigQuery schema field type from a single value.

    Args:
        name:
            The name of the field.
        value:
            The value to infer the type from. If None, the default type is used
            if available.
        default_type:
            The default field type.  Defaults to None.

    Returns:
        The schema field, or None if a type cannot be inferred.
    
pandas_gbq/schema/pandas_to_bigquery.py