def _construct_machine_label_header_sql(machine_labels):
 machine_labels = sorted(machine_labels)
 if_clauses = []
 for label in machine_labels:
  if_clauses.append(('IF(FIND_IN_SET("%s", tko_test_attributes_host_labels.value), "%s", NULL)' % (label, label)))
 return ('CONCAT_WS(",", %s)' % ', '.join(if_clauses))

def _construct_machine_label_header_sql ( machine_labels ) : machine_labels = sorted ( machine_labels ) if_clauses = [ ] for label in machine_labels : if_clauses . append ( ( 'IF(FIND_IN_SET("%s", tko_test_attributes_host_labels.value), "%s", NULL)' % ( label , label ) ) ) return ( 'CONCAT_WS(",", %s)' % ', ' . join ( if_clauses ) )
example result for machine_labels=[index .