Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import logging 

2 

3from sdc_etl_libs.sdc_dataframe.SDCDataframeEnums import SDCDFTypes 

4from sdc_etl_libs.sdc_dataframe.udfs.pandas.CollapseColumnsPandasUDF import \ 

5 CollapseColumnsPandasUDF 

6from sdc_etl_libs.sdc_dataframe.udfs.pandas.ConcatColumnsPandasUDF import \ 

7 ConcatColumnsPandasUDF 

8from sdc_etl_libs.sdc_dataframe.udfs.pandas.MD5HashRowPandasUDF import \ 

9 MD5HashRowPandasUDF 

10from sdc_etl_libs.sdc_dataframe.udfs.pandas.ConvertToDatetimePandasUDF import \ 

11 ConvertToDatetimePandasUDF 

12 

13 

14class UDFFactory: 

15 

16 @staticmethod 

17 def get_udf(df_type_, udf_name_): 

18 """ 

19 Return a UDF according with the UDF name. 

20 :param df_type_: dataframe type 

21 :param udf_name_: Name of the UDF 

22 :return: A PandasUDF 

23 """ 

24 if df_type_ == SDCDFTypes.PANDAS: 

25 if udf_name_ in available_pandas_udfs.keys(): 

26 return available_pandas_udfs[udf_name_] 

27 else: 

28 logging.exception("%s is not a valid transformation option.", udf_name_) 

29 raise Exception(f"{udf_name_} is not a valid function option.") 

30 else: 

31 raise Exception("Unknown dataframe type") 

32 

33 

34available_pandas_udfs = { 

35 'concat_columns': ConcatColumnsPandasUDF, 

36 'collapse_columns': CollapseColumnsPandasUDF, 

37 'hash_row': MD5HashRowPandasUDF, 

38 'convert_to_datetime': ConvertToDatetimePandasUDF 

39}