in utils/lookout_equipment_utils.py [0:0]
def _create_component_schema(component_name: str, field_names: List):
"""
Build a schema for a given component and fieds list
PARAMS
======
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
=======
component_schema: dict
A dictionnary containing the detailed schema for a given component
"""
# Initialize the dictionary with the component name:
component_schema = dict()
component_schema['ComponentName'] = component_name
# Loops through all the fields:
col_list = []
is_first_field = True
component_schema['Columns'] = col_list
for field_name in field_names:
# The first field is considered to be the timestamp:
if is_first_field:
ts_col = dict()
ts_col['Name'] = field_name
ts_col['Type'] = 'DATETIME'
col_list.append(ts_col)
is_first_field = False
# All the other fields are supposed to be float values:
else:
attr_col = dict()
attr_col['Name'] = field_name
attr_col['Type'] = 'DOUBLE'
col_list.append(attr_col)
return component_schema