tdfs4ds 0.2.4.25__py3-none-any.whl → 0.2.4.26__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tdfs4ds/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '0.2.4.25'
1
+ __version__ = '0.2.4.26'
2
2
  import logging
3
3
  # Setup the logger
4
4
  logging.basicConfig(
@@ -869,39 +869,6 @@ def Gettdtypes(tddf, features_columns, entity_id):
869
869
  # Increment the feature ID for the next iteration.
870
870
  feature_id += 1
871
871
 
872
- # # Iterate over the data types of the columns in the DataFrame.
873
- # for k, v in types.items():
874
- # # If the column name does not exist in the feature catalog table and is in the list of feature column names...
875
- # if k.upper() not in [n.upper() for n in existing_features] and k.upper() in [n.upper() for n in features_columns]:
876
- # # If the data type of the column is integer...
877
- # if 'int' in str(v.lower()):
878
- # # Add an entry to the result dictionary for the column name with its data type and new feature ID.
879
- # res[k] = {'type': 'BIGINT', 'id': feature_id}
880
- # # If the data type of the column is float...
881
- # elif 'float' in str(v.lower()):
882
- # # Add an entry to the result dictionary for the column name with its data type and new feature ID.
883
- # res[k] = {'type': 'FLOAT', 'id': feature_id}
884
- # # If the data type of the column is varchar with unicode encoding ...
885
- # elif 'unicode' in str(v.lower()):
886
- # res[k] = {'type': 'VARCHAR_UNICODE', 'id': feature_id}
887
- # # Print a message that the data type is not yet managed.
888
- # #if tdfs4ds.DISPLAY_LOGS: print(f'{k} has a type that is not yet managed')
889
- # # If the data type of the column is varchar with unicode encoding ...
890
- # elif 'latin' in str(v.lower()):
891
- # res[k] = {'type': 'VARCHAR_LATIN', 'id': feature_id}
892
- # # Print a message that the data type is not yet managed.
893
- # #if tdfs4ds.DISPLAY_LOGS: print(f'{k} has a type that is not yet managed')
894
- # elif 'decimal' in str(v.lower()):
895
- # res[k] = {'type': 'DECIMAL', 'id': feature_id}
896
- # # Print a message that the data type is not yet managed.
897
- # # if tdfs4ds.DISPLAY_LOGS: print(f'{k} has a type that is not yet managed')
898
- # else:
899
- # res[k] = {'type': 'VARCHAR_LATIN', 'id': feature_id}
900
- # # Print a message that the data type is not yet managed.
901
- # # if tdfs4ds.DISPLAY_LOGS: print(f'{k} has a type that is not yet managed')
902
- # # Increment the feature ID for the next iteration.
903
- # feature_id += 1
904
-
905
872
  # Return the result dictionary.
906
873
  return res
907
874
 
@@ -979,36 +946,50 @@ def tdstone2_Gettdtypes(existing_model, entity_id, display_logs=False):
979
946
  # Return the dictionary containing feature names, types, and IDs.
980
947
  return res
981
948
 
982
- def delete_feature(feature_name, data_domain=None):
949
+ def delete_feature(feature_name, entity_id, data_domain=None):
983
950
  """
984
- Delete the values of a specific feature from the feature table within a given data domain.
951
+ Delete the values of a specific feature for given entities from the feature table
952
+ within a specified data domain.
985
953
 
986
954
  This function constructs and executes two SQL queries against a Teradata database
987
- to remove a feature specified by its name. The first query retrieves the table name
988
- where the feature resides, based on the feature name and data domain. The second query
989
- deletes the feature from the identified table.
955
+ to remove a feature specified by its name and entity identifiers. The first query
956
+ retrieves the table name where the feature resides, based on the feature name,
957
+ entity, and data domain. The second query deletes the feature values from the
958
+ identified table.
990
959
 
991
960
  Parameters:
992
961
  - feature_name (str): The name of the feature to be removed.
993
- - data_domain (str, optional): The data domain where the feature is located. If not specified,
994
- the function uses the default data domain defined in tdfs4ds.DATA_DOMAIN.
995
-
996
- The function checks if the DEBUG_MODE flag in the tdfs4ds module is set to True. If so,
997
- it prints the SQL queries and the resolved table name for debugging purposes.
962
+ - entity_id (str or list of str): Entity identifier(s). If a string is provided,
963
+ it will be converted to a single-element list. The list is always sorted
964
+ alphabetically before use.
965
+ - data_domain (str, optional): The data domain where the feature is located.
966
+ If not specified, the function uses the default data domain defined in
967
+ `tdfs4ds.DATA_DOMAIN`.
968
+
969
+ Behavior:
970
+ - The function checks if the `DEBUG_MODE` flag in the `tdfs4ds` module is set to True.
971
+ If so, it prints the generated SQL queries and the resolved table name for debugging.
972
+ - If the feature table cannot be resolved, the function returns without executing
973
+ a delete query.
998
974
 
999
- The function does not return any value.
975
+ Returns:
976
+ - None
1000
977
 
1001
978
  Note:
1002
979
  - The function assumes the presence of a module `tdfs4ds` with predefined constants
1003
- such as `DATA_DOMAIN`, `SCHEMA`, `FEATURE_CATALOG_NAME`, and a flag `DEBUG_MODE`.
980
+ such as `DATA_DOMAIN`, `SCHEMA`, `FEATURE_CATALOG_NAME_VIEW`, and a flag `DEBUG_MODE`.
1004
981
  - It also assumes a `tdml` module or object with an `execute_sql` method capable of
1005
982
  executing SQL queries against a Teradata database and fetching the results.
1006
983
 
1007
984
  Raises:
1008
- - This function might raise exceptions related to SQL execution or connection issues,
1009
- which are not explicitly handled within the function itself.
985
+ - Exceptions related to SQL execution or connection issues may be raised but are not
986
+ explicitly handled, except for printing the error message.
1010
987
  """
1011
988
 
989
+ if isinstance(entity_id, str):
990
+ entity_id = [entity_id]
991
+ entity_id = sorted(entity_id)
992
+
1012
993
  if data_domain is None:
1013
994
  data_domain = tdfs4ds.DATA_DOMAIN
1014
995
 
@@ -1016,17 +997,19 @@ def delete_feature(feature_name, data_domain=None):
1016
997
  SEL FEATURE_DATABASE||'.'||FEATURE_TABLE AS TABLE_NAME
1017
998
  FROM {tdfs4ds.SCHEMA}.{tdfs4ds.FEATURE_CATALOG_NAME_VIEW}
1018
999
  WHERE FEATURE_NAME = '{feature_name}'
1019
- AND DATA_DOMAIN = '{data_domain}'"""
1000
+ AND DATA_DOMAIN = '{data_domain}'
1001
+ AND ENTITY_NAME = '{','.join([e.upper() for e in entity_id])}'"""
1020
1002
  if tdfs4ds.DEBUG_MODE:
1021
1003
  print(query0)
1022
1004
 
1023
1005
  table_name = tdml.execute_sql(query0).fetchall()
1024
- if len(table_name)>0:
1006
+ if len(table_name) > 0:
1025
1007
  table_name = table_name[0][0]
1026
1008
  else:
1027
1009
  return
1028
1010
  if tdfs4ds.DEBUG_MODE:
1029
1011
  print('table name : ', table_name)
1012
+
1030
1013
  query = f"""
1031
1014
  DELETE {table_name}
1032
1015
  WHERE FEATURE_ID = (
@@ -1044,6 +1027,7 @@ def delete_feature(feature_name, data_domain=None):
1044
1027
 
1045
1028
  return
1046
1029
 
1030
+
1047
1031
  def remove_feature(feature_name, entity_id, data_domain=None):
1048
1032
  """
1049
1033
  Attempts to remove a specific feature from the feature catalog and any associated data,
@@ -1060,7 +1044,9 @@ def remove_feature(feature_name, entity_id, data_domain=None):
1060
1044
 
1061
1045
  Parameters:
1062
1046
  - feature_name (str): The name of the feature to be removed.
1063
- - entity_id (list of str): A list of entity identifiers associated with the feature.
1047
+ - entity_id (str or list of str): Entity identifier(s). If a string is provided,
1048
+ it will be converted to a single-element list. The list is always sorted
1049
+ alphabetically before use.
1064
1050
  - data_domain (str, optional): The data domain where the feature is located. If not provided,
1065
1051
  the function uses the default data domain from the `tdfs4ds.DATA_DOMAIN` setting.
1066
1052
 
@@ -1084,16 +1070,19 @@ def remove_feature(feature_name, entity_id, data_domain=None):
1084
1070
  - SQL execution or connection exceptions might occur but are not explicitly handled by this function.
1085
1071
  """
1086
1072
 
1073
+ if isinstance(entity_id, str):
1074
+ entity_id = [entity_id]
1075
+ entity_id = sorted(entity_id)
1076
+
1087
1077
  if data_domain is None:
1088
1078
  data_domain = tdfs4ds.DATA_DOMAIN
1089
1079
 
1090
1080
  try:
1091
- delete_feature(feature_name, data_domain)
1081
+ delete_feature(feature_name, entity_id, data_domain)
1092
1082
  except Exception as e:
1093
1083
  print(str(e).split('\n')[0])
1094
1084
  return
1095
1085
 
1096
- entity_id.sort()
1097
1086
  query = f"""
1098
1087
  NONSEQUENCED VALIDTIME DELETE {tdfs4ds.SCHEMA}.{tdfs4ds.FEATURE_CATALOG_NAME}
1099
1088
  WHERE FEATURE_NAME = '{feature_name}'
@@ -1102,7 +1091,6 @@ def remove_feature(feature_name, entity_id, data_domain=None):
1102
1091
  """
1103
1092
  if tdfs4ds.DEBUG_MODE:
1104
1093
  print(query)
1094
+
1105
1095
  tdml.execute_sql(query)
1106
1096
  return
1107
-
1108
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tdfs4ds
3
- Version: 0.2.4.25
3
+ Version: 0.2.4.26
4
4
  Summary: A python package to simplify the usage of feature store using Teradata Vantage ...
5
5
  Author: Denis Molin
6
6
  Requires-Python: >=3.6
@@ -2,7 +2,7 @@ tdfs/__init__.py,sha256=7AcO7uB1opRCt7t2JOHworKimfAaDeO3boRW7u9Geo8,23
2
2
  tdfs/datasets.py,sha256=-b2MPEKGki2V1M8iUcoDR9uc2krIK7u1CK-EhChvihs,985
3
3
  tdfs/feature_store.py,sha256=Honu7eOAXxP4Ivz0mRlhuNkfTDzgZl5HB1WlQUwzcZ0,31354
4
4
  tdfs/data/curves.csv,sha256=q0Tm-0yu7VMK4lHvHpgi1LMeRq0lO5gJy2Q17brKbEM,112488
5
- tdfs4ds/__init__.py,sha256=SLBlY2M4Z7IyvMYnd8wRWUeXJeWJhDYLD7FdWXII7lI,64168
5
+ tdfs4ds/__init__.py,sha256=_UnSzqinlnbLOM4wOTxJrT1a_qTn6mRiNHz4jE6bRaI,64168
6
6
  tdfs4ds/datasets.py,sha256=LE4Gn0muwdyrIrCrbkE92cnafUML63z1lj5bFIIVzmc,3524
7
7
  tdfs4ds/feature_engineering.py,sha256=oVnZ2V_XNGE12LKC_fNfkrWSQZLgtYRmaf8Dispi6S4,7081
8
8
  tdfs4ds/feature_store.py,sha256=y-oItPZw6nBkBcGAceaATZbkLPTsvpk0OnpzTxYofDs,68576
@@ -19,7 +19,7 @@ tdfs4ds/feature_store/__init__.py,sha256=a7NPCkpTx40UR5LRErwnskpABG2Vuib7F5wUjaU
19
19
  tdfs4ds/feature_store/entity_management.py,sha256=9ltytv3yCTG84NZXBpb1Tlkf9pOxvrNb0MVidU4pwvE,10157
20
20
  tdfs4ds/feature_store/feature_data_processing.py,sha256=rvpnFrV6Tmg8C6xcSQLT_lrFYqZsdSzFXmS-4suK9qg,42847
21
21
  tdfs4ds/feature_store/feature_query_retrieval.py,sha256=zuHRZhL6-qyLpPS7mWgRy1WingSN5iibkbi53Q7jfAs,33834
22
- tdfs4ds/feature_store/feature_store_management.py,sha256=bVJbGZx1zj8Ph3q_qb939bxXSqsDl6e6SZw_GGzJ0qk,56238
22
+ tdfs4ds/feature_store/feature_store_management.py,sha256=ufIBTdrnHBvGdXggavJoTVoZjOHFtH5ZiYqJr5eIBhg,54713
23
23
  tdfs4ds/process_store/__init__.py,sha256=npHR_xju5ecGmWfYHDyteLwiU3x-cL4HD3sFK_th7xY,229
24
24
  tdfs4ds/process_store/process_followup.py,sha256=PvLcU7meg3ljBlPfuez3qwTVqpHHhVJxYxGqjgiHE8E,7265
25
25
  tdfs4ds/process_store/process_query_administration.py,sha256=DsIt97cBoJ7NcpQzbQt55eUFNgXGdOMm5Hh2aX5v0PY,7762
@@ -32,7 +32,7 @@ tdfs4ds/utils/lineage.py,sha256=gy5M42qy5fvdWmlohAY3WPYoqAyp5VakeEmeT1YjrJQ,3783
32
32
  tdfs4ds/utils/query_management.py,sha256=nAcE8QY1GWAKgOtb-ubSfDVcnYbU7Ge8CruVRLoPtmY,6356
33
33
  tdfs4ds/utils/time_management.py,sha256=1eqGs7rT3SGag0F30R3PzwiC7Aa7DKia2Ud0aSNKcPg,10593
34
34
  tdfs4ds/utils/visualization.py,sha256=5S528KoKzzkrAdCxfy7ecyqKvAXBoibNvHwz_u5ISMs,23167
35
- tdfs4ds-0.2.4.25.dist-info/METADATA,sha256=u4jn-r_y-KkfxsVcBRAQ07OQw7vkSUEwvtNp0BS2WKs,14326
36
- tdfs4ds-0.2.4.25.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
37
- tdfs4ds-0.2.4.25.dist-info/top_level.txt,sha256=wMyVkMvnBn8RRt1xBveGQxOpWFijPMPkMiE7G2mi8zo,8
38
- tdfs4ds-0.2.4.25.dist-info/RECORD,,
35
+ tdfs4ds-0.2.4.26.dist-info/METADATA,sha256=15eq8Z08VdFjD-GXC2cLqGvfb8OQoDRi3oPlmTyiq00,14326
36
+ tdfs4ds-0.2.4.26.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
37
+ tdfs4ds-0.2.4.26.dist-info/top_level.txt,sha256=wMyVkMvnBn8RRt1xBveGQxOpWFijPMPkMiE7G2mi8zo,8
38
+ tdfs4ds-0.2.4.26.dist-info/RECORD,,