'Merges the ds config from druid_config into one stored in the db.'

@classmethod
def sync_to_db_from_config(cls, druid_config, user, cluster):

    session = db.session()
    datasource = session.query(cls).filter_by(datasource_name=druid_config['name']).first()
    if (not datasource):
        datasource = cls(datasource_name=druid_config['name'], cluster=cluster, owner=user, changed_by_fk=user.id, created_by_fk=user.id)
        session.add(datasource)
    dimensions = druid_config['dimensions']
    for dim in dimensions:
        col_obj = session.query(DruidColumn).filter_by(datasource_name=druid_config['name'], column_name=dim).first()
        if (not col_obj):
            col_obj = DruidColumn(datasource_name=druid_config['name'], column_name=dim, groupby=True, filterable=True, type='STRING', datasource=datasource)
            session.add(col_obj)
    for metric_spec in druid_config['metrics_spec']:
        metric_name = metric_spec['name']
        metric_type = metric_spec['type']
        metric_json = json.dumps(metric_spec)
        if (metric_type == 'count'):
            metric_type = 'longSum'
            metric_json = json.dumps({'type': 'longSum', 'name': metric_name, 'fieldName': metric_name})
        metric_obj = session.query(DruidMetric).filter_by(datasource_name=druid_config['name'], metric_name=metric_name).first()
        if (not metric_obj):
            metric_obj = DruidMetric(metric_name=metric_name, metric_type=metric_type, verbose_name=('%s(%s)' % (metric_type, metric_name)), datasource=datasource, json=metric_json, description=('Imported    from    the    airolap    config    dir    for    %s' % druid_config['name']))
            session.add(metric_obj)
    session.commit()
