teradataml 20.0.0.2__py3-none-any.whl → 20.0.0.4__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.

Potentially problematic release.


This version of teradataml might be problematic. Click here for more details.

Files changed (126) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/README.md +315 -2
  3. teradataml/__init__.py +4 -0
  4. teradataml/_version.py +1 -1
  5. teradataml/analytics/analytic_function_executor.py +95 -8
  6. teradataml/analytics/byom/__init__.py +1 -1
  7. teradataml/analytics/json_parser/metadata.py +12 -3
  8. teradataml/analytics/json_parser/utils.py +7 -2
  9. teradataml/analytics/sqle/__init__.py +5 -1
  10. teradataml/analytics/table_operator/__init__.py +1 -1
  11. teradataml/analytics/uaf/__init__.py +1 -1
  12. teradataml/analytics/utils.py +4 -0
  13. teradataml/analytics/valib.py +18 -4
  14. teradataml/automl/__init__.py +51 -6
  15. teradataml/automl/data_preparation.py +59 -35
  16. teradataml/automl/data_transformation.py +58 -33
  17. teradataml/automl/feature_engineering.py +27 -12
  18. teradataml/automl/model_training.py +73 -46
  19. teradataml/common/constants.py +88 -29
  20. teradataml/common/garbagecollector.py +2 -1
  21. teradataml/common/messagecodes.py +19 -3
  22. teradataml/common/messages.py +6 -1
  23. teradataml/common/sqlbundle.py +64 -12
  24. teradataml/common/utils.py +246 -47
  25. teradataml/common/warnings.py +11 -0
  26. teradataml/context/context.py +161 -27
  27. teradataml/data/amazon_reviews_25.csv +26 -0
  28. teradataml/data/byom_example.json +11 -0
  29. teradataml/data/dataframe_example.json +18 -2
  30. teradataml/data/docs/byom/docs/DataRobotPredict.py +2 -2
  31. teradataml/data/docs/byom/docs/DataikuPredict.py +40 -1
  32. teradataml/data/docs/byom/docs/H2OPredict.py +2 -2
  33. teradataml/data/docs/byom/docs/ONNXEmbeddings.py +242 -0
  34. teradataml/data/docs/byom/docs/ONNXPredict.py +2 -2
  35. teradataml/data/docs/byom/docs/PMMLPredict.py +2 -2
  36. teradataml/data/docs/sqle/docs_17_20/NaiveBayes.py +1 -1
  37. teradataml/data/docs/sqle/docs_17_20/Shap.py +34 -6
  38. teradataml/data/docs/sqle/docs_17_20/TDNaiveBayesPredict.py +4 -4
  39. teradataml/data/docs/sqle/docs_17_20/TextParser.py +3 -3
  40. teradataml/data/docs/tableoperator/docs_17_20/Image2Matrix.py +118 -0
  41. teradataml/data/docs/uaf/docs_17_20/CopyArt.py +145 -0
  42. teradataml/data/docs/uaf/docs_17_20/DWT2D.py +4 -1
  43. teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +18 -21
  44. teradataml/data/hnsw_alter_data.csv +5 -0
  45. teradataml/data/hnsw_data.csv +10 -0
  46. teradataml/data/jsons/byom/h2opredict.json +1 -1
  47. teradataml/data/jsons/byom/onnxembeddings.json +266 -0
  48. teradataml/data/jsons/sqle/17.20/TD_Shap.json +0 -1
  49. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +1 -1
  50. teradataml/data/jsons/sqle/20.00/TD_HNSW.json +296 -0
  51. teradataml/data/jsons/sqle/20.00/TD_HNSWPredict.json +206 -0
  52. teradataml/data/jsons/sqle/20.00/TD_HNSWSummary.json +32 -0
  53. teradataml/data/jsons/sqle/20.00/TD_KMeans.json +250 -0
  54. teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +266 -0
  55. teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +278 -0
  56. teradataml/data/jsons/storedprocedure/17.20/TD_COPYART.json +71 -0
  57. teradataml/data/jsons/tableoperator/17.20/IMAGE2MATRIX.json +53 -0
  58. teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +10 -19
  59. teradataml/data/jsons/uaf/17.20/TD_SAX.json +3 -1
  60. teradataml/data/jsons/uaf/17.20/TD_WINDOWDFFT.json +15 -5
  61. teradataml/data/medical_readings.csv +101 -0
  62. teradataml/data/patient_profile.csv +101 -0
  63. teradataml/data/scripts/lightgbm/dataset.template +157 -0
  64. teradataml/data/scripts/lightgbm/lightgbm_class_functions.template +247 -0
  65. teradataml/data/scripts/lightgbm/lightgbm_function.template +216 -0
  66. teradataml/data/scripts/lightgbm/lightgbm_sklearn.template +159 -0
  67. teradataml/data/scripts/sklearn/sklearn_fit.py +194 -167
  68. teradataml/data/scripts/sklearn/sklearn_fit_predict.py +136 -115
  69. teradataml/data/scripts/sklearn/sklearn_function.template +14 -19
  70. teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +155 -137
  71. teradataml/data/scripts/sklearn/sklearn_transform.py +129 -42
  72. teradataml/data/target_udt_data.csv +8 -0
  73. teradataml/data/templates/open_source_ml.json +3 -2
  74. teradataml/data/teradataml_example.json +8 -0
  75. teradataml/data/vectordistance_example.json +4 -0
  76. teradataml/dataframe/copy_to.py +8 -3
  77. teradataml/dataframe/data_transfer.py +11 -1
  78. teradataml/dataframe/dataframe.py +1049 -285
  79. teradataml/dataframe/dataframe_utils.py +152 -20
  80. teradataml/dataframe/functions.py +578 -35
  81. teradataml/dataframe/setop.py +11 -6
  82. teradataml/dataframe/sql.py +185 -16
  83. teradataml/dbutils/dbutils.py +1049 -115
  84. teradataml/dbutils/filemgr.py +48 -1
  85. teradataml/hyperparameter_tuner/optimizer.py +12 -1
  86. teradataml/lib/aed_0_1.dll +0 -0
  87. teradataml/opensource/__init__.py +1 -1
  88. teradataml/opensource/_base.py +1466 -0
  89. teradataml/opensource/_class.py +464 -0
  90. teradataml/opensource/{sklearn/constants.py → _constants.py} +21 -14
  91. teradataml/opensource/_lightgbm.py +949 -0
  92. teradataml/opensource/_sklearn.py +1008 -0
  93. teradataml/opensource/{sklearn/_wrapper_utils.py → _wrapper_utils.py} +5 -6
  94. teradataml/options/__init__.py +54 -38
  95. teradataml/options/configure.py +131 -27
  96. teradataml/options/display.py +13 -2
  97. teradataml/plot/axis.py +47 -8
  98. teradataml/plot/figure.py +33 -0
  99. teradataml/plot/plot.py +63 -13
  100. teradataml/scriptmgmt/UserEnv.py +5 -5
  101. teradataml/scriptmgmt/lls_utils.py +130 -40
  102. teradataml/store/__init__.py +12 -0
  103. teradataml/store/feature_store/__init__.py +0 -0
  104. teradataml/store/feature_store/constants.py +291 -0
  105. teradataml/store/feature_store/feature_store.py +2318 -0
  106. teradataml/store/feature_store/models.py +1505 -0
  107. teradataml/table_operators/Apply.py +32 -18
  108. teradataml/table_operators/Script.py +3 -1
  109. teradataml/table_operators/TableOperator.py +3 -1
  110. teradataml/table_operators/query_generator.py +3 -0
  111. teradataml/table_operators/table_operator_query_generator.py +3 -1
  112. teradataml/table_operators/table_operator_util.py +37 -38
  113. teradataml/table_operators/templates/dataframe_register.template +69 -0
  114. teradataml/utils/dtypes.py +51 -2
  115. teradataml/utils/internal_buffer.py +18 -0
  116. teradataml/utils/validators.py +99 -8
  117. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/METADATA +321 -5
  118. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/RECORD +121 -94
  119. teradataml/libaed_0_1.dylib +0 -0
  120. teradataml/libaed_0_1.so +0 -0
  121. teradataml/opensource/sklearn/__init__.py +0 -1
  122. teradataml/opensource/sklearn/_class.py +0 -255
  123. teradataml/opensource/sklearn/_sklearn_wrapper.py +0 -1800
  124. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/WHEEL +0 -0
  125. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/top_level.txt +0 -0
  126. {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/zip-safe +0 -0
@@ -13,6 +13,7 @@ by other classes which can be reused according to the need.
13
13
  Add all the common functions in this class like creating temporary table names, getting
14
14
  the datatypes etc.
15
15
  """
16
+ from inspect import getsource
16
17
  import json
17
18
  import uuid
18
19
  from math import floor
@@ -43,6 +44,7 @@ from teradataml.options.configure import configure
43
44
  from teradataml.options.display import display
44
45
  from teradataml.common.constants import TeradataReservedKeywords, TeradataConstants
45
46
 
47
+ from teradataml.utils.internal_buffer import _InternalBuffer
46
48
  from teradatasqlalchemy.types import _TDType
47
49
  from teradatasqlalchemy.types import (INTEGER, SMALLINT, BIGINT, BYTEINT,
48
50
  DECIMAL, FLOAT, NUMBER)
@@ -309,6 +311,10 @@ class UtilFuncs():
309
311
  tabname = "\"{}\".\"{}\"".format(_get_user(), tabname)
310
312
  return tabname
311
313
 
314
+ if configure.temp_object_type == TeradataConstants.TERADATA_VOLATILE_TABLE:
315
+ from teradataml.context.context import _get_user
316
+ return "\"{}\".\"{}_{}\"".format(_get_user(), "vt", tabname)
317
+
312
318
  if use_default_database and databasename is None:
313
319
  tabname = "\"{}\".\"{}\"".format(tdmlctx._get_context_temp_databasename(
314
320
  table_type=table_type), tabname)
@@ -692,6 +698,7 @@ class UtilFuncs():
692
698
  EXAMPLES:
693
699
  UtilFuncs._create_table('"dbname"."table_name"', "select * from table_name")
694
700
  """
701
+
695
702
  crt_table = SQLBundle._build_create_table_with_data(table_name, query)
696
703
  if volatile:
697
704
  crt_table = SQLBundle._build_create_volatile_table_with_data(table_name, query)
@@ -755,13 +762,14 @@ class UtilFuncs():
755
762
  return vtab_name
756
763
 
757
764
  @staticmethod
758
- def _drop_table(table_name, check_table_exist=True):
765
+ def _drop_table(table_name, check_table_exist=True, purge_clause=None):
759
766
  """
760
767
  Drops a table.
761
768
 
762
769
  PARAMETERS:
763
770
  table_name - The table to drop.
764
771
  check_table_exist - Checks if the table exist before dropping the table.
772
+ purge_clause - Specifies string representing purge clause to be appended to drop table query.
765
773
 
766
774
  RETURNS:
767
775
  True - if the table is dropped.
@@ -774,9 +782,11 @@ class UtilFuncs():
774
782
  UtilFuncs._drop_table('mytab', check_table_exist = False)
775
783
  UtilFuncs._drop_table('mydb.mytab', check_table_exist = False)
776
784
  UtilFuncs._drop_table("mydb"."mytab", check_table_exist = True)
785
+ UtilFuncs._drop_table("my_lake"."my_db"."my_tab", purge_clause='PURGE ALL')
786
+ UtilFuncs._drop_table("my_lake"."my_db"."my_tab", purge_clause='NO PURGE')
777
787
 
778
788
  """
779
- drop_tab = SQLBundle._build_drop_table(table_name)
789
+ drop_tab = SQLBundle._build_drop_table(table_name, purge_clause)
780
790
  if check_table_exist is True:
781
791
  helptable = UtilFuncs._get_help_tablename(table_name)
782
792
  if helptable:
@@ -956,6 +966,22 @@ class UtilFuncs():
956
966
  """
957
967
  return UtilFuncs._execute_query(SQLBundle._build_help_table(table_name))
958
968
 
969
+ @staticmethod
970
+ def _get_help_datalakename(datalake_name):
971
+ """
972
+ Function to get help of the datalake.
973
+
974
+ PARAMETERS:
975
+ datalake_name - The name of the datalake.
976
+
977
+ RETURNS:
978
+ The help information of the datalake specified by datalake_name.
979
+
980
+ EXAMPLES:
981
+ UtilFuncs._get_help_datalakename(mydatalake)
982
+ """
983
+ return UtilFuncs._execute_query(SQLBundle._build_help_datalake(datalake_name))
984
+
959
985
  @staticmethod
960
986
  def _get_select_table(table_name):
961
987
  """
@@ -1249,43 +1275,106 @@ class UtilFuncs():
1249
1275
  return UtilFuncs._teradata_quote_arg(keyword, "\"", False)
1250
1276
 
1251
1277
  return keyword
1278
+
1279
+ def _contains_space(item):
1280
+ """
1281
+ Check if the specified string in item has spaces or tabs in it.
1282
+
1283
+ PARAMETERS:
1284
+ item:
1285
+ Required Argument.
1286
+ Specifies a string to check for spaces or tabs.
1287
+ Types: str
1252
1288
 
1253
- @staticmethod
1254
- def _in_schema(schema_name, table_name):
1289
+ RETURNS:
1290
+ True, if the specified string has spaces or tabs in it, else False.
1291
+
1292
+ RAISES:
1293
+ None.
1294
+
1295
+ EXAMPLES:
1296
+ # Passing column name with spaces returns True.
1297
+ is_space = UtilFuncs._contains_space("col name")
1298
+ print(is_space)
1299
+ # Passing column name without spaces returns False.
1300
+ is_space = UtilFuncs._contains_space("colname")
1301
+ print(is_space)
1302
+ """
1303
+ # Check if the input is a string and look for spaces or tabs
1304
+ if isinstance(item, str):
1305
+ return any(char in {' ', '\t'} for char in item)
1306
+
1307
+ # If the input is a list, check each element
1308
+ if isinstance(item, list):
1309
+ # Check each item in the list
1310
+ return any(UtilFuncs._contains_space(col) for col in item)
1311
+
1312
+ return False
1313
+
1314
+ def _is_ascii(col_lst):
1255
1315
  """
1256
- Function takes a schema name and a table name and creates a database
1257
- object name in the format "schema"."table_name".
1258
- Note:
1259
- teradataml recommends to use this function to access table(s)/view(s),
1260
- from the database other than the default database.
1316
+ Description:
1317
+ Check if the specified string in col_lst has non-ASCII characters in it.
1261
1318
 
1262
1319
  PARAMETERS:
1263
- schema_name:
1264
- Required Argument
1265
- Specifies the schema where the table resides in.
1266
- Types: str
1320
+ col_lst:
1321
+ Required Argument.
1322
+ Specifies a list of strings to check for non-ASCII characters.
1323
+ Types: list
1267
1324
 
1268
- table_name:
1269
- Required Argument
1270
- Specifies the table name or view name in Vantage.
1271
- Types: str
1325
+ RETURNS:
1326
+ True, if the specified string has non-ASCII characters in it, else False.
1272
1327
 
1328
+ RAISES:
1329
+ None.
1330
+
1273
1331
  EXAMPLES:
1274
- from teradataml.dataframe.dataframe import in_schema, DataFrame
1332
+ # Passing column name with non-ASCII characters returns True.
1333
+ >>> is_non_ascii = UtilFuncs._is_ascii(["col name", "がく片の長さ@name"])
1334
+ >>> print(is_non_ascii)
1335
+ >>> True
1336
+ # Passing column name without non-ASCII characters returns False.
1337
+ >>> is_non_ascii = UtilFuncs._is_ascii(["colname", "col_name"])
1338
+ >>> print(is_non_ascii)
1339
+ >>> False
1340
+ """
1341
+ if isinstance(col_lst, str):
1342
+ # Check if the input is a string and look for non-ASCII characters
1343
+ return not col_lst.isascii()
1344
+
1345
+ if isinstance(col_lst, list):
1346
+ for item in col_lst:
1347
+ if isinstance(item, str) and not item.isascii():
1348
+ return True
1349
+ return False
1350
+
1351
+ @staticmethod
1352
+ def __get_dot_separated_names(full_qualified_name):
1353
+ """
1354
+ Takes in fully qualified name of the table/view (db.table), and returns
1355
+ a dot separated name from the same.
1275
1356
 
1276
- # Example 1: The following example creates a DataFrame from the
1277
- # existing Vantage table "dbcinfo" in the non-default
1278
- # database "dbc" using the in_schema() function.
1279
- df = DataFrame(in_schema("dbc", "dbcinfo"))
1357
+ PARAMETERS:
1358
+ full_qualified_name - Name of the table/view
1280
1359
 
1281
- # Example 2: The following example uses from_table() function, existing
1282
- # Vantage table "dbcinfo" and non-default database "dbc" to
1283
- # create a teradataml DataFrame.
1284
- df = DataFrame.from_table(in_schema("dbc","dbcinfo"))
1360
+ EXAMPLES:
1361
+ UtilFuncs._extract_db_name('"db1"."tablename"')
1362
+ UtilFuncs._extract_db_name('"Icebergs"."db1"."tablename"')
1363
+
1364
+ RETURNS:
1365
+ List of dot separated name from the provided name.
1285
1366
 
1286
1367
  """
1287
- return "{0}.{1}".format(UtilFuncs._teradata_quote_arg(schema_name, "\"", False),
1288
- UtilFuncs._teradata_quote_arg(table_name, "\"", False))
1368
+ # If condition to handle the quoted name.
1369
+ if '"' in full_qualified_name:
1370
+ # Extract the double quoted strings.
1371
+ names = re.findall(r'["](.*?)["]', full_qualified_name)
1372
+ # Remove quotes around the string.
1373
+ names = [i.replace('"', '') for i in names]
1374
+ # Handle non-quoted string with dot separated name.
1375
+ else:
1376
+ names = full_qualified_name.split(".")
1377
+ return names
1289
1378
 
1290
1379
  @staticmethod
1291
1380
  def _extract_db_name(full_qualified_name):
@@ -1297,19 +1386,19 @@ class UtilFuncs():
1297
1386
  full_qualified_name - Name of the table/view
1298
1387
 
1299
1388
  EXAMPLES:
1300
- UtilFuncs._extract_db_name("db1"."tablename")
1389
+ UtilFuncs._extract_db_name('"db1"."tablename"')
1390
+ UtilFuncs._extract_db_name('"Icebergs"."db1"."tablename"')
1301
1391
 
1302
1392
  RETURNS:
1303
1393
  Database name from the provided name.
1304
1394
 
1305
1395
  """
1306
- # Extract the double quoted strings.
1307
- names = re.findall(r'["](.*?)["]', full_qualified_name)
1308
- # Remove quotes around the string.
1309
- names = [i.replace('"', '') for i in names]
1396
+ names = UtilFuncs.__get_dot_separated_names(full_qualified_name)
1310
1397
  if names:
1311
1398
  if len(names) == 2:
1312
1399
  return names[0]
1400
+ elif len(names) == 3:
1401
+ return names[1]
1313
1402
  else:
1314
1403
  return None
1315
1404
 
@@ -1323,23 +1412,45 @@ class UtilFuncs():
1323
1412
  full_qualified_name - Name of the table/view
1324
1413
 
1325
1414
  EXAMPLES:
1326
- UtilFuncs._extract_db_name("db1"."tablename")
1415
+ UtilFuncs._extract_table_name('"db1"."tablename"')
1416
+ UtilFuncs._extract_table_name('"Icebergs"."db1"."tablename"')
1327
1417
 
1328
1418
  RETURNS:
1329
1419
  Table/View name from the provided name.
1330
1420
 
1331
1421
  """
1332
- # Extract the double quoted strings.
1333
- names = re.findall(r'["](.*?)["]', full_qualified_name)
1334
- # Remove quotes around the string.
1335
- names = [i.replace('"', '') for i in names]
1422
+ names = UtilFuncs.__get_dot_separated_names(full_qualified_name)
1336
1423
  if names:
1337
1424
  if len(names) == 2:
1338
1425
  return names[1]
1426
+ elif len(names) == 3:
1427
+ return names[2]
1339
1428
  else:
1340
1429
  return names[0]
1341
1430
  return full_qualified_name
1342
1431
 
1432
+ @staticmethod
1433
+ def _extract_datalake_name(full_qualified_name):
1434
+ """
1435
+ Takes in fully qualified name of the table/view (db.table), and returns
1436
+ a datalake name from the same.
1437
+
1438
+ PARAMETERS:
1439
+ full_qualified_name - Name of the table/view
1440
+
1441
+ EXAMPLES:
1442
+ UtilFuncs._extract_datalake_name('"db1"."tablename"')
1443
+ UtilFuncs._extract_datalake_name('"Icebergs"."db1"."tablename"')
1444
+
1445
+ RETURNS:
1446
+ Database name from the provided name.
1447
+
1448
+ """
1449
+ names = UtilFuncs.__get_dot_separated_names(full_qualified_name)
1450
+ if names and len(names) == 3:
1451
+ return names[0]
1452
+ return None
1453
+
1343
1454
  @staticmethod
1344
1455
  def _teradata_quote_arg(args, quote="'", call_from_wrapper=True):
1345
1456
  """
@@ -2358,8 +2469,16 @@ class UtilFuncs():
2358
2469
  >>> self._is_lake()
2359
2470
  """
2360
2471
 
2361
- from teradataml.context.context import _get_database_version
2362
- return int(_get_database_version().split(".")[0]) >= 20
2472
+ tbl_operator = configure.table_operator.lower() \
2473
+ if configure.table_operator else None
2474
+
2475
+ # If the user does not provide a table_operator, check the database version
2476
+ # and determine the system type accordingly.
2477
+ if tbl_operator is None:
2478
+ from teradataml.context.context import _get_database_version
2479
+ return int(_get_database_version().split(".")[0]) >= 20
2480
+
2481
+ return tbl_operator == "apply"
2363
2482
 
2364
2483
  @staticmethod
2365
2484
  def _get_python_execution_path():
@@ -2379,8 +2498,8 @@ class UtilFuncs():
2379
2498
  EXAMPLES:
2380
2499
  >>> self._get_python_execution_path()
2381
2500
  """
2382
- # 'indb_install_location' expects python installation directory path.
2383
- # Hence, postfixing python binary path.
2501
+ # 'indb_install_location' expects python installation directory path.
2502
+ # Hence, postfixing python binary path.
2384
2503
  return "python" if UtilFuncs._is_lake() else \
2385
2504
  '{}/bin/python3'.format(configure.indb_install_location)
2386
2505
 
@@ -2403,7 +2522,7 @@ class UtilFuncs():
2403
2522
  """
2404
2523
  db_name = UtilFuncs._teradata_unquote_arg(UtilFuncs._extract_db_name(tablename), "\"")
2405
2524
  table_view_name = UtilFuncs._teradata_unquote_arg(UtilFuncs._extract_table_name(tablename), "\"")
2406
- query = SQLBundle._build_select_table_kind(db_name, "{0}".format(table_view_name), "'V'")
2525
+ query = SQLBundle._build_select_table_kind(db_name, "'{0}'".format(table_view_name), "'V'")
2407
2526
 
2408
2527
  df = UtilFuncs._execute_query(query)
2409
2528
  if len(df) > 0:
@@ -2471,7 +2590,7 @@ class UtilFuncs():
2471
2590
  except Exception as exc:
2472
2591
  raise exc
2473
2592
 
2474
- def _get_env_name(col):
2593
+ def _get_env_name(col=None):
2475
2594
  """
2476
2595
  DESCRIPTION:
2477
2596
  Internal function to get the env name if passed with ColumnExpression
@@ -2479,9 +2598,10 @@ class UtilFuncs():
2479
2598
 
2480
2599
  PARAMETERS:
2481
2600
  col:
2482
- Required Argument.
2601
+ Optional Argument.
2483
2602
  Specifies teradataml DataFrame ColumnExpression.
2484
2603
  Types: teradataml DataFrame ColumnExpression
2604
+ Default Value: None
2485
2605
 
2486
2606
  RAISES:
2487
2607
  None.
@@ -2493,10 +2613,10 @@ class UtilFuncs():
2493
2613
  >>> self._get_env_name(col)
2494
2614
  """
2495
2615
 
2496
- # If env_name is passed with ColumnExpression fetch the env name,
2616
+ # If ColumnExpression is passed and env_name is passed with it fetch the env name,
2497
2617
  # else check if default "openml_user_env" env is configured or not,
2498
2618
  # else get the default "openml_env" env if exists or create new deafult env.
2499
- if col._env_name is not None:
2619
+ if col and col._env_name is not None:
2500
2620
  from teradataml.scriptmgmt.UserEnv import UserEnv
2501
2621
  env = col._env_name
2502
2622
  env_name = env.env_name if isinstance(col._env_name, UserEnv) else env
@@ -2506,5 +2626,84 @@ class UtilFuncs():
2506
2626
  env_name = UtilFuncs._create_or_get_env("open_source_ml.json").env_name
2507
2627
  return env_name
2508
2628
 
2629
+ def _func_to_string(user_functions):
2630
+ """
2631
+ DESCRIPTION:
2632
+ Internal function to get the user functions in a single string format.
2633
+
2634
+ PARAMETERS:
2635
+ user_functions:
2636
+ Required Argument.
2637
+ List of user functions.
2638
+ Types: list
2639
+
2640
+ RAISES:
2641
+ None.
2642
+
2643
+ RETURNS:
2644
+ string
2645
+
2646
+ EXAMPLES:
2647
+ >>> from teradataml.dataframe.functions import udf
2648
+ >>> @udf(returns=VARCHAR())
2649
+ ... def sum(x, y):
2650
+ ... return x+y
2651
+ >>>
2652
+ >>> def to_upper(s):
2653
+ ... return s.upper()
2654
+ >>> user_functions = [sum(1,2)._udf, to_upper]
2655
+ >>> res = self._func_to_string(user_functions)
2656
+ >>> print(res)
2657
+ def sum(x, y):
2658
+ return x+y
2659
+
2660
+ def to_upper(s):
2661
+ return s.upper()
2662
+
2663
+ >>>
2664
+ """
2665
+ user_function_code = ""
2666
+ for func in user_functions:
2667
+ # Get the source code of the user function.
2668
+ func = getsource(func)
2669
+ # If the function have any extra space in the beginning remove it.
2670
+ func = func.lstrip()
2671
+ # Function can have decorator,e.g. udf as decorator, remove it.
2672
+ if func.startswith("@"):
2673
+ func = func[func.find("\n")+1: ].lstrip()
2674
+ # If multiple functions are passed, separate them with new line.
2675
+ user_function_code += func + '\n'
2676
+ return user_function_code
2677
+
2678
+ @staticmethod
2679
+ def _get_qualified_table_name(schema_name, table_name):
2680
+ """
2681
+ DESCRIPTION:
2682
+ Internal function to get the fully qualified name of table.
2683
+
2684
+ PARAMETERS:
2685
+ schema_name:
2686
+ Required Argument.
2687
+ Specifies the name of the schema.
2688
+ Types: str
2689
+
2690
+ table_name:
2691
+ Required Argument.
2692
+ Specifies the name of the table.
2693
+ Types: str
2694
+
2695
+ RAISES:
2696
+ None.
2697
+
2698
+ RETURNS:
2699
+ string
2700
+
2701
+ EXAMPLES:
2702
+ >>> UtilFuncs._get_qualified_table_name("schema_name", "table_name")
2703
+ '"schema_name"."table_name"'
2704
+ """
2705
+ return '"{}"."{}"'.format(schema_name, table_name)
2706
+
2707
+
2509
2708
  from teradataml.common.aed_utils import AedUtils
2510
2709
  from teradataml.dbutils.filemgr import remove_file
@@ -17,9 +17,20 @@ class VantageRuntimeWarning(RuntimeWarning):
17
17
  """
18
18
  pass
19
19
 
20
+
20
21
  class TeradataMlRuntimeWarning(RuntimeWarning):
21
22
  """
22
23
  The TeradataMlRuntimeWarning is thrown whenever there are Warnings in runtime execution of objects in teradataml.
23
24
  """
24
25
  # For future purpose
25
26
  pass
27
+
28
+
29
+
30
+ class OneTimeUserWarning(UserWarning):
31
+ """
32
+ The OneTimeUserWarning is thrown when the warning should only be displayed once to the user.
33
+ This can be useful for deprecation warnings, configuration issues, or other
34
+ non-critical warnings that do not need to be repeated multiple times.
35
+ """
36
+ pass