diff --git a/tube/etl/indexers/aggregation/parser.py b/tube/etl/indexers/aggregation/parser.py index 5b36c67d..70f3d2e0 100644 --- a/tube/etl/indexers/aggregation/parser.py +++ b/tube/etl/indexers/aggregation/parser.py @@ -113,10 +113,11 @@ def add_program_name_to_parent(self): found_program = -1 i = -1 for path in self.mapping["parent_props"]: - p = path.get("path") + p = path["path"] i += 1 if p.startswith("program"): found_program = i + break if found_program == -1: self.mapping["parent_props"].append( {"path": "programs[{PROGRAM_N}:name]".format(PROGRAM_N=PROGRAM_NAME)} diff --git a/tube/etl/indexers/base/translator.py b/tube/etl/indexers/base/translator.py index 4367b3b0..29859a00 100644 --- a/tube/etl/indexers/base/translator.py +++ b/tube/etl/indexers/base/translator.py @@ -72,7 +72,12 @@ def write(self, df): def get_props_from_data_row(self, df, props, to_tuple=False): if df.isEmpty(): return df.mapValues(get_props_empty_values(props)) + # names is dictionary which maps from the name of source fields in datatable to the list of ids + # of properties in dataframe + # example: names = {"gender": [1, 2], project_name: [3]} names = {} + # values is a dictionary which defines the mapping values (if exist) for each field. + # values = {"code": {1: {"male": "M", "female": "F"}, 2: {"male": "Male", "female": "Female}}, "project_name": {}} values = {} for p in props: n = names.get(p.src, [])