def get_fields_with_datatype(
    dataset_ids: list, field_info: dict, data_format: str
) -> dict:
    """
    Returns the column name and its data type by looking up stream and log_fields json file.

    If a mapping column name is not present in log_fields.json it returns
    the column name as `col<idx>` and its data type as `string`

    Example:
    ```
    {
        "cp": "string",
        "bytes" : "bigint",
        "col1": "string"
    }
    ```
    """

    result = {}
    result["version"] = "string"
    # start set as 1 as the 0th field is version
    # if the column name lookup on field_info fails,
    # it sets the column name as col<idx> ex, col5
    # for JSON, column format is string by default
    for itr, colid in enumerate(dataset_ids, start=1):
        result[field_info.get(colid, {"name": "col" + str(itr)})["name"]] = (
            "string"
            if data_format == "JSON"
            else field_info.get(colid, {"dtype": "string"})["dtype"]
        )

    return result