def _create_component_schema()

in src/lookoutequipment/schema.py [0:0]


def _create_component_schema(component_name: str, field_names: List):
    """
    Build a schema for a given component and fieds list
    
    Parameters
        component_name (string):
            name of the component to build a schema for
        
        field_names (list of strings):
            name of all the fields included in this component
            
    Returns:
        dict:
            A dictionnary containing the detailed schema for a given component
    """
    # Test if the field names is correct for this component:
    if len(field_names) == 0:
        raise Exception(f'Field names for component {component_name} should not be empty')
    if len(field_names) == 1:
        raise Exception(f'Component {component_name} must have at least one sensor beyond the timestamp')
    
    # The first field is a timestamp:
    col_list  = [{'Name': field_names[0], 'Type': 'DATETIME'}]
    
    # All the others are float values:
    col_list = col_list + [
        {'Name': field_name, 'Type': 'DOUBLE'} 
        for field_name in field_names[1:]
    ]
    
    # Build the schema for this component:
    component_schema = dict()
    component_schema['ComponentName'] = component_name
    component_schema['Columns'] = col_list
            
    return component_schema