def bc_metrics_query(table_name='%(table_name)s'):
    """
    Further preprocess raw dataframe such that the format fits the bandi-
    coot expectations. That means timestamps as string and no NULL values
    for call durations. Only keep national events and add the antenna
    coordinates.

    Inputs
    ------
    table_name : Name of the table the query is supposed to run on,
                 defaulting to '%(table_name)s', i.e. no substitution.

    Output
    ------
    Dataframe ready for processing by bandicoot module.
    """
    query = """
        SELECT
          caller_id,
          interaction,
          direction,
          correspondent_id,
          CAST(CAST(datetime AS TIMESTAMP) as STRING) as datetime,
          IFNULL(CAST(call_duration as STRING), '') as call_duration,
          cd.antenna_id as antenna_id,
          latitude,
          longitude
        FROM %(table_name)s cd
        JOIN table_antennas_locations al
        ON cd.antenna_id = al.antenna_id
        WHERE national = 1
    """
    return query % {'table_name': table_name}
