def _concat_ids(spark, dataset, columnNames):
    """Concatenates structureId and chainId fields into a single key if chainId
    field is present

    Parameters
    ----------
    spark : :obj:`SparkSession <pyspark.sql.SparkSession>`
    dataset : Dataframe
    columnNames : list
    """
    if 'chainId' in dataset.columns:
        dataset.createOrReplaceTempView('table')
        sql = (
            "SELECT CONCAT(structureId,'.',chainId) as structureChainId," +
            'structureId,chainId,%s' % ','.join(columnNames) + ' from table')
        dataset = spark.sql(sql)
    return dataset
