teradataml 20.0.0.0__py3-none-any.whl → 20.0.0.1__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.
- teradataml/LICENSE-3RD-PARTY.pdf +0 -0
- teradataml/LICENSE.pdf +0 -0
- teradataml/README.md +71 -0
- teradataml/_version.py +2 -2
- teradataml/analytics/analytic_function_executor.py +51 -24
- teradataml/analytics/json_parser/utils.py +11 -17
- teradataml/automl/__init__.py +103 -48
- teradataml/automl/data_preparation.py +55 -37
- teradataml/automl/data_transformation.py +131 -69
- teradataml/automl/feature_engineering.py +117 -185
- teradataml/automl/feature_exploration.py +9 -2
- teradataml/automl/model_evaluation.py +13 -25
- teradataml/automl/model_training.py +214 -75
- teradataml/catalog/model_cataloging_utils.py +1 -1
- teradataml/clients/auth_client.py +133 -0
- teradataml/common/aed_utils.py +3 -2
- teradataml/common/constants.py +11 -6
- teradataml/common/garbagecollector.py +5 -0
- teradataml/common/messagecodes.py +3 -1
- teradataml/common/messages.py +2 -1
- teradataml/common/utils.py +6 -0
- teradataml/context/context.py +49 -29
- teradataml/data/advertising.csv +201 -0
- teradataml/data/bank_marketing.csv +11163 -0
- teradataml/data/bike_sharing.csv +732 -0
- teradataml/data/boston2cols.csv +721 -0
- teradataml/data/breast_cancer.csv +570 -0
- teradataml/data/customer_segmentation_test.csv +2628 -0
- teradataml/data/customer_segmentation_train.csv +8069 -0
- teradataml/data/docs/sqle/docs_17_10/OneHotEncodingFit.py +3 -1
- teradataml/data/docs/sqle/docs_17_10/OneHotEncodingTransform.py +6 -0
- teradataml/data/docs/sqle/docs_17_10/OutlierFilterTransform.py +5 -1
- teradataml/data/docs/sqle/docs_17_20/ANOVA.py +61 -1
- teradataml/data/docs/sqle/docs_17_20/ColumnTransformer.py +2 -0
- teradataml/data/docs/sqle/docs_17_20/FTest.py +105 -26
- teradataml/data/docs/sqle/docs_17_20/GLM.py +162 -1
- teradataml/data/docs/sqle/docs_17_20/GetFutileColumns.py +5 -3
- teradataml/data/docs/sqle/docs_17_20/KMeans.py +48 -1
- teradataml/data/docs/sqle/docs_17_20/NonLinearCombineFit.py +3 -2
- teradataml/data/docs/sqle/docs_17_20/OneHotEncodingFit.py +5 -0
- teradataml/data/docs/sqle/docs_17_20/OneHotEncodingTransform.py +6 -0
- teradataml/data/docs/sqle/docs_17_20/ROC.py +3 -2
- teradataml/data/docs/sqle/docs_17_20/SVMPredict.py +13 -2
- teradataml/data/docs/sqle/docs_17_20/ScaleFit.py +119 -1
- teradataml/data/docs/sqle/docs_17_20/ScaleTransform.py +93 -1
- teradataml/data/docs/sqle/docs_17_20/TDGLMPredict.py +163 -1
- teradataml/data/docs/sqle/docs_17_20/XGBoost.py +12 -4
- teradataml/data/docs/sqle/docs_17_20/XGBoostPredict.py +7 -1
- teradataml/data/docs/sqle/docs_17_20/ZTest.py +72 -7
- teradataml/data/glm_example.json +28 -1
- teradataml/data/housing_train_segment.csv +201 -0
- teradataml/data/insect2Cols.csv +61 -0
- teradataml/data/jsons/sqle/17.20/TD_ANOVA.json +99 -27
- teradataml/data/jsons/sqle/17.20/TD_FTest.json +166 -83
- teradataml/data/jsons/sqle/17.20/TD_GLM.json +90 -14
- teradataml/data/jsons/sqle/17.20/TD_GLMPREDICT.json +48 -5
- teradataml/data/jsons/sqle/17.20/TD_GetFutileColumns.json +5 -3
- teradataml/data/jsons/sqle/17.20/TD_KMeans.json +31 -11
- teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineFit.json +3 -2
- teradataml/data/jsons/sqle/17.20/TD_ROC.json +2 -1
- teradataml/data/jsons/sqle/17.20/TD_SVM.json +16 -16
- teradataml/data/jsons/sqle/17.20/TD_SVMPredict.json +19 -1
- teradataml/data/jsons/sqle/17.20/TD_ScaleFit.json +168 -15
- teradataml/data/jsons/sqle/17.20/TD_ScaleTransform.json +50 -1
- teradataml/data/jsons/sqle/17.20/TD_XGBoost.json +25 -7
- teradataml/data/jsons/sqle/17.20/TD_XGBoostPredict.json +17 -4
- teradataml/data/jsons/sqle/17.20/TD_ZTest.json +157 -80
- teradataml/data/kmeans_example.json +5 -0
- teradataml/data/kmeans_table.csv +10 -0
- teradataml/data/onehot_encoder_train.csv +4 -0
- teradataml/data/openml_example.json +29 -0
- teradataml/data/scale_attributes.csv +3 -0
- teradataml/data/scale_example.json +52 -1
- teradataml/data/scale_input_part_sparse.csv +31 -0
- teradataml/data/scale_input_partitioned.csv +16 -0
- teradataml/data/scale_input_sparse.csv +11 -0
- teradataml/data/scale_parameters.csv +3 -0
- teradataml/data/scripts/deploy_script.py +20 -1
- teradataml/data/scripts/sklearn/sklearn_fit.py +23 -27
- teradataml/data/scripts/sklearn/sklearn_fit_predict.py +20 -28
- teradataml/data/scripts/sklearn/sklearn_function.template +13 -18
- teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +23 -33
- teradataml/data/scripts/sklearn/sklearn_neighbors.py +18 -27
- teradataml/data/scripts/sklearn/sklearn_score.py +20 -29
- teradataml/data/scripts/sklearn/sklearn_transform.py +30 -38
- teradataml/data/teradataml_example.json +77 -0
- teradataml/data/ztest_example.json +16 -0
- teradataml/dataframe/copy_to.py +8 -3
- teradataml/dataframe/data_transfer.py +120 -61
- teradataml/dataframe/dataframe.py +102 -17
- teradataml/dataframe/dataframe_utils.py +47 -9
- teradataml/dataframe/fastload.py +272 -89
- teradataml/dataframe/sql.py +84 -0
- teradataml/dbutils/dbutils.py +2 -2
- teradataml/lib/aed_0_1.dll +0 -0
- teradataml/opensource/sklearn/_sklearn_wrapper.py +102 -55
- teradataml/options/__init__.py +13 -4
- teradataml/options/configure.py +27 -6
- teradataml/scriptmgmt/UserEnv.py +19 -16
- teradataml/scriptmgmt/lls_utils.py +117 -14
- teradataml/table_operators/Script.py +2 -3
- teradataml/table_operators/TableOperator.py +58 -10
- teradataml/utils/validators.py +40 -2
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.1.dist-info}/METADATA +78 -6
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.1.dist-info}/RECORD +108 -90
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.1.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.1.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.1.dist-info}/zip-safe +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unpublished work.
|
|
3
|
+
Copyright (c) 2024 by Teradata Corporation. All rights reserved.
|
|
4
|
+
TERADATA CORPORATION CONFIDENTIAL AND TRADE SECRET
|
|
5
|
+
Primary Owner: gouri.patwardhan@teradata.com
|
|
6
|
+
Secondary Owner: Pradeep.Garre@teradata.com
|
|
7
|
+
This file implements workflow for generating JWT token.
|
|
8
|
+
"""
|
|
9
|
+
import base64
|
|
10
|
+
import jwt
|
|
11
|
+
import time
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import pathlib
|
|
14
|
+
from teradataml import configure
|
|
15
|
+
|
|
16
|
+
class _AuthWorkflow:
|
|
17
|
+
"""
|
|
18
|
+
Get the JWT token for requested user.
|
|
19
|
+
"""
|
|
20
|
+
def __init__(self, state):
|
|
21
|
+
"""
|
|
22
|
+
DESCRIPTION:
|
|
23
|
+
Constructor to initiate Authentication work flow.
|
|
24
|
+
|
|
25
|
+
PARAMETERS:
|
|
26
|
+
state:
|
|
27
|
+
Required Argument.
|
|
28
|
+
Specifies the dictionary containing following:
|
|
29
|
+
1. "base_url" which is extracted from "ues_url".
|
|
30
|
+
2. "org_id" which is also extracted from "ues_url".
|
|
31
|
+
3. "pat_token" which is obtained from VantageCloud Lake Console, and it is specific to the user.
|
|
32
|
+
4. "pem_file" which is obtained from VantageCloud Lake Console, and it is specific to the user.
|
|
33
|
+
5. "username" which is the DB user.
|
|
34
|
+
5. "expiration_time" which is the expiration time for the token and has a default value of
|
|
35
|
+
31536000 seconds.
|
|
36
|
+
Types: dict
|
|
37
|
+
|
|
38
|
+
RETURNS:
|
|
39
|
+
Instance of _AuthWorkflow.
|
|
40
|
+
|
|
41
|
+
RAISES:
|
|
42
|
+
None
|
|
43
|
+
|
|
44
|
+
EXAMPLES :
|
|
45
|
+
>>> _AuthWorkflow(state)
|
|
46
|
+
"""
|
|
47
|
+
self.state = state
|
|
48
|
+
|
|
49
|
+
def _get_epoch_time(self):
|
|
50
|
+
"""
|
|
51
|
+
DESCRIPTION:
|
|
52
|
+
Generate expiry epoch time.
|
|
53
|
+
|
|
54
|
+
RETURNS:
|
|
55
|
+
float
|
|
56
|
+
"""
|
|
57
|
+
current_epoch_time = int(time.time())
|
|
58
|
+
expiry_epoch_time = current_epoch_time + self.state.get('expiration_time')
|
|
59
|
+
return current_epoch_time, expiry_epoch_time
|
|
60
|
+
|
|
61
|
+
def _generate_header(self):
|
|
62
|
+
"""
|
|
63
|
+
DESCRIPTION:
|
|
64
|
+
Generate JWT header.
|
|
65
|
+
|
|
66
|
+
RETURNS:
|
|
67
|
+
dict
|
|
68
|
+
"""
|
|
69
|
+
# Extract the pem file name without extension.
|
|
70
|
+
kid = pathlib.Path(self.state.get('pem_file')).stem
|
|
71
|
+
header = {
|
|
72
|
+
"alg": "RS256",
|
|
73
|
+
"kid": kid,
|
|
74
|
+
"typ": "JWT"
|
|
75
|
+
}
|
|
76
|
+
return header
|
|
77
|
+
|
|
78
|
+
def _generate_payload(self):
|
|
79
|
+
"""
|
|
80
|
+
DESCRIPTION:
|
|
81
|
+
Generate JWT payload.
|
|
82
|
+
|
|
83
|
+
RETURNS:
|
|
84
|
+
A dictionary with the JWT payload.
|
|
85
|
+
"""
|
|
86
|
+
iat, exp= self._get_epoch_time()
|
|
87
|
+
payload = {
|
|
88
|
+
"aud": [
|
|
89
|
+
"td:service:authentication"
|
|
90
|
+
],
|
|
91
|
+
"iat": iat,
|
|
92
|
+
"exp": exp,
|
|
93
|
+
"iss": "teradataml",
|
|
94
|
+
"multi-use": True,
|
|
95
|
+
"org_id": self.state['org_id'],
|
|
96
|
+
"pat": self.state['pat_token'],
|
|
97
|
+
"sub": self.state['username']
|
|
98
|
+
}
|
|
99
|
+
return payload
|
|
100
|
+
|
|
101
|
+
def _sign_jwt(self, payload, header):
|
|
102
|
+
"""
|
|
103
|
+
DESCRIPTION:
|
|
104
|
+
Encode JWT using private key.
|
|
105
|
+
|
|
106
|
+
PARAMETERS:
|
|
107
|
+
payload:
|
|
108
|
+
Required Argument.
|
|
109
|
+
Specifies the payload required for encoding the JWT token.
|
|
110
|
+
Types: dict
|
|
111
|
+
header:
|
|
112
|
+
Required Argument.
|
|
113
|
+
Specified the header required for encoding the JWT token.
|
|
114
|
+
Types: dict
|
|
115
|
+
|
|
116
|
+
RETURNS:
|
|
117
|
+
str
|
|
118
|
+
"""
|
|
119
|
+
with open(self.state['pem_file'], "r") as f:
|
|
120
|
+
private_key = f.read()
|
|
121
|
+
return jwt.encode(payload=payload, key=private_key, algorithm=header["alg"], headers=header)
|
|
122
|
+
|
|
123
|
+
def _proxy_jwt(self):
|
|
124
|
+
"""
|
|
125
|
+
DESCRIPTION:
|
|
126
|
+
Generate JWT token and add the value in dictionary.
|
|
127
|
+
|
|
128
|
+
RETURNS:
|
|
129
|
+
str
|
|
130
|
+
"""
|
|
131
|
+
jwt = self._sign_jwt(self._generate_payload(), self._generate_header())
|
|
132
|
+
self.state['jwt'] = jwt
|
|
133
|
+
return(jwt)
|
teradataml/common/aed_utils.py
CHANGED
|
@@ -1287,8 +1287,9 @@ class AedUtils:
|
|
|
1287
1287
|
arg_name = ["group by"]
|
|
1288
1288
|
# If option is passed, add prefix of the option to the groupby_expr,
|
|
1289
1289
|
# else, add prefix as empty string.
|
|
1290
|
-
|
|
1291
|
-
|
|
1290
|
+
if isinstance(groupby_expr, str):
|
|
1291
|
+
arg_value = ["{} | {}".format(option, groupby_expr)] if option \
|
|
1292
|
+
else ["{}| {}".format("", groupby_expr)]
|
|
1292
1293
|
temp_table_name = UtilFuncs._generate_temp_table_name(prefix="groupby_", use_default_database=True, quote=False)
|
|
1293
1294
|
output_table = [UtilFuncs._extract_table_name(temp_table_name)]
|
|
1294
1295
|
output_schema = [UtilFuncs._extract_db_name(temp_table_name)]
|
teradataml/common/constants.py
CHANGED
|
@@ -65,6 +65,7 @@ class TeradataConstants(Enum):
|
|
|
65
65
|
CONTAINER = 5
|
|
66
66
|
TERADATA_TEXT_FILE = 6
|
|
67
67
|
TERADATA_APPLY = 7
|
|
68
|
+
TERADATA_VOLATILE_TABLE = 8
|
|
68
69
|
TABLE_COLUMN_LIMIT = 2048
|
|
69
70
|
TERADATA_JOINS = ["inner", "left", "right", "full", "cross"]
|
|
70
71
|
TERADATA_JOIN_OPERATORS = ['>=', '<=', '<>', '!=', '>', '<', '=']
|
|
@@ -463,18 +464,18 @@ class TableOperatorConstants(Enum):
|
|
|
463
464
|
ON (select 1) PARTITION BY ANY
|
|
464
465
|
SCRIPT_COMMAND('{}/bin/pip3 --version')
|
|
465
466
|
returns('package VARCHAR(256)'))
|
|
466
|
-
"""
|
|
467
|
+
"""
|
|
467
468
|
|
|
468
469
|
# Script Query to get Python packages and corresponding versions.
|
|
469
470
|
# Location of In-DB packages is indicated by configure.indb_install_location.
|
|
470
471
|
partial_version_query = "SELECT distinct * FROM SCRIPT( ON (select 1) " \
|
|
471
|
-
"PARTITION BY ANY SCRIPT_COMMAND('{}/bin/pip3 freeze | "
|
|
472
|
-
|
|
473
|
-
PACKAGE_VERSION_QUERY = partial_version_query + "{
|
|
472
|
+
"PARTITION BY ANY SCRIPT_COMMAND('{0}/bin/pip3 freeze | "
|
|
473
|
+
|
|
474
|
+
PACKAGE_VERSION_QUERY = partial_version_query + "{1}awk -F ''=='' " \
|
|
474
475
|
"''{{print $1, $2}}''') " \
|
|
475
476
|
"delimiter(' ') " \
|
|
476
|
-
"returns('package VARCHAR({
|
|
477
|
-
"version VARCHAR({
|
|
477
|
+
"returns('package VARCHAR({2}), " \
|
|
478
|
+
"version VARCHAR({2})'))"
|
|
478
479
|
|
|
479
480
|
class ValibConstants(Enum):
|
|
480
481
|
# A dictionary that maps teradataml name of the exposed VALIB function name
|
|
@@ -1404,6 +1405,10 @@ class DriverEscapeFunctions(Enum):
|
|
|
1404
1405
|
WRITE_TO_CSV = "{{fn teradata_write_csv({0})}}"
|
|
1405
1406
|
FIELD_QUOTE = "{{fn teradata_field_quote({0})}}"
|
|
1406
1407
|
FIELD_SEP = "{{fn teradata_field_sep({0})}}"
|
|
1408
|
+
ERR_TBL_1 = "{{fn teradata_error_table_1_suffix({0})}}"
|
|
1409
|
+
ERR_TBL_2 = "{{fn teradata_error_table_2_suffix({0})}}"
|
|
1410
|
+
ERR_STAGING_DB = "{{fn teradata_error_table_database({0})}}"
|
|
1411
|
+
ERR_TBL_MNG_FLAG = "{{fn teradata_manage_error_tables_{0}}}"
|
|
1407
1412
|
|
|
1408
1413
|
|
|
1409
1414
|
class HTTPRequest(Enum):
|
|
@@ -64,8 +64,13 @@ class GarbageCollector():
|
|
|
64
64
|
EXAMPLES:
|
|
65
65
|
GarbageCollector._get_temp_dir_name()
|
|
66
66
|
"""
|
|
67
|
+
# Default location for .teradataml is user's home directory if configure.local_storage is not set.
|
|
67
68
|
tempdir = expanduser("~")
|
|
68
69
|
tempdir = os.path.join(tempdir, GarbageCollector.__garbagecollector_folder_name)
|
|
70
|
+
|
|
71
|
+
# set the .teradataml location to the location specified by the user.
|
|
72
|
+
if configure.local_storage:
|
|
73
|
+
tempdir = os.path.join(configure.local_storage, GarbageCollector.__garbagecollector_folder_name)
|
|
69
74
|
return tempdir
|
|
70
75
|
|
|
71
76
|
@staticmethod
|
|
@@ -180,6 +180,7 @@ class ErrorInfoCodes(Enum):
|
|
|
180
180
|
INVALID_LIST_LENGTH = 'TDML_2314'
|
|
181
181
|
|
|
182
182
|
IMPORT_PYTHON_PACKAGE = 'TDML_2414'
|
|
183
|
+
PATH_NOT_FOUND = 'TDML_2415'
|
|
183
184
|
|
|
184
185
|
# Script local run Error codes
|
|
185
186
|
SCRIPT_LOCAL_RUN_ERROR = 'TDML_2410'
|
|
@@ -419,4 +420,5 @@ class MessageCodes(Enum):
|
|
|
419
420
|
" feature columns."
|
|
420
421
|
PARTITION_VALUES_NOT_MATCHING = "Values in training and test data partition columns should be same."
|
|
421
422
|
PARTITION_IN_BOTH_FIT_AND_PREDICT = "Use \"partition_columns\" only if model is fitted with partition_column(s)."
|
|
422
|
-
INVALID_PARTITIONING_COLS = "Provided partition_column(s) '{}' is/are not present in parent of '{}' DataFrame(s)."
|
|
423
|
+
INVALID_PARTITIONING_COLS = "Provided partition_column(s) '{}' is/are not present in parent of '{}' DataFrame(s)."
|
|
424
|
+
PATH_NOT_FOUND = "Specified local path '{}' not found. Please check the path."
|
teradataml/common/messages.py
CHANGED
|
@@ -188,7 +188,8 @@ class Messages():
|
|
|
188
188
|
[ErrorInfoCodes.PARTITIONING_COLS_IN_FEATURE_COLS, MessageCodes.PARTITIONING_COLS_IN_FEATURE_COLS],
|
|
189
189
|
[ErrorInfoCodes.PARTITION_VALUES_NOT_MATCHING, MessageCodes.PARTITION_VALUES_NOT_MATCHING],
|
|
190
190
|
[ErrorInfoCodes.PARTITION_IN_BOTH_FIT_AND_PREDICT, MessageCodes.PARTITION_IN_BOTH_FIT_AND_PREDICT],
|
|
191
|
-
[ErrorInfoCodes.INVALID_PARTITIONING_COLS, MessageCodes.INVALID_PARTITIONING_COLS]
|
|
191
|
+
[ErrorInfoCodes.INVALID_PARTITIONING_COLS, MessageCodes.INVALID_PARTITIONING_COLS],
|
|
192
|
+
[ErrorInfoCodes.PATH_NOT_FOUND, MessageCodes.PATH_NOT_FOUND]
|
|
192
193
|
]
|
|
193
194
|
|
|
194
195
|
@staticmethod
|
teradataml/common/utils.py
CHANGED
|
@@ -300,6 +300,12 @@ class UtilFuncs():
|
|
|
300
300
|
tabname = "{}_{}".format(tabname, prefix)
|
|
301
301
|
|
|
302
302
|
tabname = "{}_{}".format(tabname, random_string)
|
|
303
|
+
|
|
304
|
+
# ELE-6710 - Use database user associated with the current context for volatile tables.
|
|
305
|
+
if table_type == TeradataConstants.TERADATA_VOLATILE_TABLE:
|
|
306
|
+
from teradataml.context.context import _get_user
|
|
307
|
+
tabname = "\"{}\".\"{}\"".format(_get_user(), tabname)
|
|
308
|
+
return tabname
|
|
303
309
|
|
|
304
310
|
if use_default_database and databasename is None:
|
|
305
311
|
tabname = "\"{}\".\"{}\"".format(tdmlctx._get_context_temp_databasename(
|
teradataml/context/context.py
CHANGED
|
@@ -69,20 +69,24 @@ def _get_current_databasename():
|
|
|
69
69
|
EXAMPLES:
|
|
70
70
|
_get_current_databasename()
|
|
71
71
|
"""
|
|
72
|
-
if
|
|
73
|
-
|
|
74
|
-
try:
|
|
75
|
-
sqlbundle = SQLBundle()
|
|
76
|
-
select_user_query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_DATABASE)
|
|
77
|
-
result = execute_sql(select_user_query)
|
|
78
|
-
return result.fetchall()[0][0]
|
|
79
|
-
except TeradataMlException:
|
|
80
|
-
raise
|
|
81
|
-
except Exception as err:
|
|
82
|
-
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_EXEC_SQL_FAILED, select_user_query),
|
|
83
|
-
MessageCodes.TDMLDF_EXEC_SQL_FAILED) from err
|
|
72
|
+
if configure._current_database_name:
|
|
73
|
+
return configure._current_database_name
|
|
84
74
|
else:
|
|
85
|
-
|
|
75
|
+
if get_connection() is not None:
|
|
76
|
+
select_user_query = ""
|
|
77
|
+
try:
|
|
78
|
+
sqlbundle = SQLBundle()
|
|
79
|
+
select_user_query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_DATABASE)
|
|
80
|
+
result = execute_sql(select_user_query)
|
|
81
|
+
configure._current_database_name = result.fetchall()[0][0]
|
|
82
|
+
return configure._current_database_name
|
|
83
|
+
except TeradataMlException:
|
|
84
|
+
raise
|
|
85
|
+
except Exception as err:
|
|
86
|
+
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_EXEC_SQL_FAILED, select_user_query),
|
|
87
|
+
MessageCodes.TDMLDF_EXEC_SQL_FAILED) from err
|
|
88
|
+
else:
|
|
89
|
+
return None
|
|
86
90
|
|
|
87
91
|
|
|
88
92
|
def _get_database_username():
|
|
@@ -101,20 +105,24 @@ def _get_database_username():
|
|
|
101
105
|
EXAMPLES:
|
|
102
106
|
_get_database_username()
|
|
103
107
|
"""
|
|
104
|
-
if
|
|
105
|
-
|
|
106
|
-
try:
|
|
107
|
-
sqlbundle = SQLBundle()
|
|
108
|
-
select_query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_USER)
|
|
109
|
-
result = execute_sql(select_query)
|
|
110
|
-
return result.fetchall()[0][0]
|
|
111
|
-
except TeradataMlException:
|
|
112
|
-
raise
|
|
113
|
-
except Exception as err:
|
|
114
|
-
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_EXEC_SQL_FAILED, select_query),
|
|
115
|
-
MessageCodes.TDMLDF_EXEC_SQL_FAILED) from err
|
|
108
|
+
if configure._database_username:
|
|
109
|
+
return configure._database_username
|
|
116
110
|
else:
|
|
117
|
-
|
|
111
|
+
if get_connection() is not None:
|
|
112
|
+
select_query = ""
|
|
113
|
+
try:
|
|
114
|
+
sqlbundle = SQLBundle()
|
|
115
|
+
select_query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_USER)
|
|
116
|
+
result = execute_sql(select_query)
|
|
117
|
+
configure._database_username = result.fetchall()[0][0]
|
|
118
|
+
return configure._database_username
|
|
119
|
+
except TeradataMlException:
|
|
120
|
+
raise
|
|
121
|
+
except Exception as err:
|
|
122
|
+
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_EXEC_SQL_FAILED, select_query),
|
|
123
|
+
MessageCodes.TDMLDF_EXEC_SQL_FAILED) from err
|
|
124
|
+
else:
|
|
125
|
+
return None
|
|
118
126
|
|
|
119
127
|
|
|
120
128
|
def __cleanup_garbage_collection():
|
|
@@ -500,7 +508,11 @@ def create_context(host = None, username = None, password = None, tdsqlengine =
|
|
|
500
508
|
__initalise_dag()
|
|
501
509
|
|
|
502
510
|
# Set database version.
|
|
503
|
-
|
|
511
|
+
_get_database_version()
|
|
512
|
+
# Set current database name.
|
|
513
|
+
_get_current_databasename()
|
|
514
|
+
# Set database user name.
|
|
515
|
+
_get_database_username()
|
|
504
516
|
|
|
505
517
|
# Process Analytic functions.
|
|
506
518
|
from teradataml.analytics import _process_analytic_functions
|
|
@@ -666,7 +678,7 @@ def remove_context():
|
|
|
666
678
|
global python_packages_installed
|
|
667
679
|
global td_user
|
|
668
680
|
|
|
669
|
-
#
|
|
681
|
+
# Initiate the garbage collection
|
|
670
682
|
__cleanup_garbage_collection()
|
|
671
683
|
|
|
672
684
|
if user_specified_connection is not True:
|
|
@@ -683,6 +695,9 @@ def remove_context():
|
|
|
683
695
|
td_sqlalchemy_engine = None
|
|
684
696
|
python_packages_installed = False
|
|
685
697
|
td_user = None
|
|
698
|
+
configure._current_database_name = None
|
|
699
|
+
configure._database_username = None
|
|
700
|
+
configure.database_version = None
|
|
686
701
|
|
|
687
702
|
# Closing Dag
|
|
688
703
|
__close_dag()
|
|
@@ -717,6 +732,9 @@ def _get_context_temp_databasename(table_type=TeradataConstants.TERADATA_VIEW):
|
|
|
717
732
|
if table_type == TeradataConstants.TERADATA_VIEW and \
|
|
718
733
|
configure.temp_view_database is not None:
|
|
719
734
|
return configure.temp_view_database
|
|
735
|
+
# ELE-6710 - Use database user associated with the current context for volatile tables.
|
|
736
|
+
if table_type == TeradataConstants.TERADATA_VOLATILE_TABLE:
|
|
737
|
+
return _get_user()
|
|
720
738
|
return temporary_database_name
|
|
721
739
|
|
|
722
740
|
|
|
@@ -877,7 +895,9 @@ def _get_database_version():
|
|
|
877
895
|
# RELEASE 17.05a.00.147
|
|
878
896
|
|
|
879
897
|
try:
|
|
880
|
-
|
|
898
|
+
if configure.database_version is None:
|
|
899
|
+
configure.database_version = execute_sql(Query.VANTAGE_VERSION.value).fetchall()[0][0]
|
|
900
|
+
return configure.database_version
|
|
881
901
|
except:
|
|
882
902
|
return None
|
|
883
903
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
TV,Radio,Newspaper,Sales
|
|
2
|
+
230.1,37.8,69.2,22.1
|
|
3
|
+
44.5,39.3,45.1,10.4
|
|
4
|
+
17.2,45.9,69.3,12
|
|
5
|
+
151.5,41.3,58.5,16.5
|
|
6
|
+
180.8,10.8,58.4,17.9
|
|
7
|
+
8.7,48.9,75,7.2
|
|
8
|
+
57.5,32.8,23.5,11.8
|
|
9
|
+
120.2,19.6,11.6,13.2
|
|
10
|
+
8.6,2.1,1,4.8
|
|
11
|
+
199.8,2.6,21.2,15.6
|
|
12
|
+
66.1,5.8,24.2,12.6
|
|
13
|
+
214.7,24,4,17.4
|
|
14
|
+
23.8,35.1,65.9,9.2
|
|
15
|
+
97.5,7.6,7.2,13.7
|
|
16
|
+
204.1,32.9,46,19
|
|
17
|
+
195.4,47.7,52.9,22.4
|
|
18
|
+
67.8,36.6,114,12.5
|
|
19
|
+
281.4,39.6,55.8,24.4
|
|
20
|
+
69.2,20.5,18.3,11.3
|
|
21
|
+
147.3,23.9,19.1,14.6
|
|
22
|
+
218.4,27.7,53.4,18
|
|
23
|
+
237.4,5.1,23.5,17.5
|
|
24
|
+
13.2,15.9,49.6,5.6
|
|
25
|
+
228.3,16.9,26.2,20.5
|
|
26
|
+
62.3,12.6,18.3,9.7
|
|
27
|
+
262.9,3.5,19.5,17
|
|
28
|
+
142.9,29.3,12.6,15
|
|
29
|
+
240.1,16.7,22.9,20.9
|
|
30
|
+
248.8,27.1,22.9,18.9
|
|
31
|
+
70.6,16,40.8,10.5
|
|
32
|
+
292.9,28.3,43.2,21.4
|
|
33
|
+
112.9,17.4,38.6,11.9
|
|
34
|
+
97.2,1.5,30,13.2
|
|
35
|
+
265.6,20,0.3,17.4
|
|
36
|
+
95.7,1.4,7.4,11.9
|
|
37
|
+
290.7,4.1,8.5,17.8
|
|
38
|
+
266.9,43.8,5,25.4
|
|
39
|
+
74.7,49.4,45.7,14.7
|
|
40
|
+
43.1,26.7,35.1,10.1
|
|
41
|
+
228,37.7,32,21.5
|
|
42
|
+
202.5,22.3,31.6,16.6
|
|
43
|
+
177,33.4,38.7,17.1
|
|
44
|
+
293.6,27.7,1.8,20.7
|
|
45
|
+
206.9,8.4,26.4,17.9
|
|
46
|
+
25.1,25.7,43.3,8.5
|
|
47
|
+
175.1,22.5,31.5,16.1
|
|
48
|
+
89.7,9.9,35.7,10.6
|
|
49
|
+
239.9,41.5,18.5,23.2
|
|
50
|
+
227.2,15.8,49.9,19.8
|
|
51
|
+
66.9,11.7,36.8,9.7
|
|
52
|
+
199.8,3.1,34.6,16.4
|
|
53
|
+
100.4,9.6,3.6,10.7
|
|
54
|
+
216.4,41.7,39.6,22.6
|
|
55
|
+
182.6,46.2,58.7,21.2
|
|
56
|
+
262.7,28.8,15.9,20.2
|
|
57
|
+
198.9,49.4,60,23.7
|
|
58
|
+
7.3,28.1,41.4,5.5
|
|
59
|
+
136.2,19.2,16.6,13.2
|
|
60
|
+
210.8,49.6,37.7,23.8
|
|
61
|
+
210.7,29.5,9.3,18.4
|
|
62
|
+
53.5,2,21.4,8.1
|
|
63
|
+
261.3,42.7,54.7,24.2
|
|
64
|
+
239.3,15.5,27.3,20.7
|
|
65
|
+
102.7,29.6,8.4,14
|
|
66
|
+
131.1,42.8,28.9,16
|
|
67
|
+
69,9.3,0.9,11.3
|
|
68
|
+
31.5,24.6,2.2,11
|
|
69
|
+
139.3,14.5,10.2,13.4
|
|
70
|
+
237.4,27.5,11,18.9
|
|
71
|
+
216.8,43.9,27.2,22.3
|
|
72
|
+
199.1,30.6,38.7,18.3
|
|
73
|
+
109.8,14.3,31.7,12.4
|
|
74
|
+
26.8,33,19.3,8.8
|
|
75
|
+
129.4,5.7,31.3,11
|
|
76
|
+
213.4,24.6,13.1,17
|
|
77
|
+
16.9,43.7,89.4,8.7
|
|
78
|
+
27.5,1.6,20.7,6.9
|
|
79
|
+
120.5,28.5,14.2,14.2
|
|
80
|
+
5.4,29.9,9.4,5.3
|
|
81
|
+
116,7.7,23.1,11
|
|
82
|
+
76.4,26.7,22.3,11.8
|
|
83
|
+
239.8,4.1,36.9,17.3
|
|
84
|
+
75.3,20.3,32.5,11.3
|
|
85
|
+
68.4,44.5,35.6,13.6
|
|
86
|
+
213.5,43,33.8,21.7
|
|
87
|
+
193.2,18.4,65.7,20.2
|
|
88
|
+
76.3,27.5,16,12
|
|
89
|
+
110.7,40.6,63.2,16
|
|
90
|
+
88.3,25.5,73.4,12.9
|
|
91
|
+
109.8,47.8,51.4,16.7
|
|
92
|
+
134.3,4.9,9.3,14
|
|
93
|
+
28.6,1.5,33,7.3
|
|
94
|
+
217.7,33.5,59,19.4
|
|
95
|
+
250.9,36.5,72.3,22.2
|
|
96
|
+
107.4,14,10.9,11.5
|
|
97
|
+
163.3,31.6,52.9,16.9
|
|
98
|
+
197.6,3.5,5.9,16.7
|
|
99
|
+
184.9,21,22,20.5
|
|
100
|
+
289.7,42.3,51.2,25.4
|
|
101
|
+
135.2,41.7,45.9,17.2
|
|
102
|
+
222.4,4.3,49.8,16.7
|
|
103
|
+
296.4,36.3,100.9,23.8
|
|
104
|
+
280.2,10.1,21.4,19.8
|
|
105
|
+
187.9,17.2,17.9,19.7
|
|
106
|
+
238.2,34.3,5.3,20.7
|
|
107
|
+
137.9,46.4,59,15
|
|
108
|
+
25,11,29.7,7.2
|
|
109
|
+
90.4,0.3,23.2,12
|
|
110
|
+
13.1,0.4,25.6,5.3
|
|
111
|
+
255.4,26.9,5.5,19.8
|
|
112
|
+
225.8,8.2,56.5,18.4
|
|
113
|
+
241.7,38,23.2,21.8
|
|
114
|
+
175.7,15.4,2.4,17.1
|
|
115
|
+
209.6,20.6,10.7,20.9
|
|
116
|
+
78.2,46.8,34.5,14.6
|
|
117
|
+
75.1,35,52.7,12.6
|
|
118
|
+
139.2,14.3,25.6,12.2
|
|
119
|
+
76.4,0.8,14.8,9.4
|
|
120
|
+
125.7,36.9,79.2,15.9
|
|
121
|
+
19.4,16,22.3,6.6
|
|
122
|
+
141.3,26.8,46.2,15.5
|
|
123
|
+
18.8,21.7,50.4,7
|
|
124
|
+
224,2.4,15.6,16.6
|
|
125
|
+
123.1,34.6,12.4,15.2
|
|
126
|
+
229.5,32.3,74.2,19.7
|
|
127
|
+
87.2,11.8,25.9,10.6
|
|
128
|
+
7.8,38.9,50.6,6.6
|
|
129
|
+
80.2,0,9.2,11.9
|
|
130
|
+
220.3,49,3.2,24.7
|
|
131
|
+
59.6,12,43.1,9.7
|
|
132
|
+
0.7,39.6,8.7,1.6
|
|
133
|
+
265.2,2.9,43,17.7
|
|
134
|
+
8.4,27.2,2.1,5.7
|
|
135
|
+
219.8,33.5,45.1,19.6
|
|
136
|
+
36.9,38.6,65.6,10.8
|
|
137
|
+
48.3,47,8.5,11.6
|
|
138
|
+
25.6,39,9.3,9.5
|
|
139
|
+
273.7,28.9,59.7,20.8
|
|
140
|
+
43,25.9,20.5,9.6
|
|
141
|
+
184.9,43.9,1.7,20.7
|
|
142
|
+
73.4,17,12.9,10.9
|
|
143
|
+
193.7,35.4,75.6,19.2
|
|
144
|
+
220.5,33.2,37.9,20.1
|
|
145
|
+
104.6,5.7,34.4,10.4
|
|
146
|
+
96.2,14.8,38.9,12.3
|
|
147
|
+
140.3,1.9,9,10.3
|
|
148
|
+
240.1,7.3,8.7,18.2
|
|
149
|
+
243.2,49,44.3,25.4
|
|
150
|
+
38,40.3,11.9,10.9
|
|
151
|
+
44.7,25.8,20.6,10.1
|
|
152
|
+
280.7,13.9,37,16.1
|
|
153
|
+
121,8.4,48.7,11.6
|
|
154
|
+
197.6,23.3,14.2,16.6
|
|
155
|
+
171.3,39.7,37.7,16
|
|
156
|
+
187.8,21.1,9.5,20.6
|
|
157
|
+
4.1,11.6,5.7,3.2
|
|
158
|
+
93.9,43.5,50.5,15.3
|
|
159
|
+
149.8,1.3,24.3,10.1
|
|
160
|
+
11.7,36.9,45.2,7.3
|
|
161
|
+
131.7,18.4,34.6,12.9
|
|
162
|
+
172.5,18.1,30.7,16.4
|
|
163
|
+
85.7,35.8,49.3,13.3
|
|
164
|
+
188.4,18.1,25.6,19.9
|
|
165
|
+
163.5,36.8,7.4,18
|
|
166
|
+
117.2,14.7,5.4,11.9
|
|
167
|
+
234.5,3.4,84.8,16.9
|
|
168
|
+
17.9,37.6,21.6,8
|
|
169
|
+
206.8,5.2,19.4,17.2
|
|
170
|
+
215.4,23.6,57.6,17.1
|
|
171
|
+
284.3,10.6,6.4,20
|
|
172
|
+
50,11.6,18.4,8.4
|
|
173
|
+
164.5,20.9,47.4,17.5
|
|
174
|
+
19.6,20.1,17,7.6
|
|
175
|
+
168.4,7.1,12.8,16.7
|
|
176
|
+
222.4,3.4,13.1,16.5
|
|
177
|
+
276.9,48.9,41.8,27
|
|
178
|
+
248.4,30.2,20.3,20.2
|
|
179
|
+
170.2,7.8,35.2,16.7
|
|
180
|
+
276.7,2.3,23.7,16.8
|
|
181
|
+
165.6,10,17.6,17.6
|
|
182
|
+
156.6,2.6,8.3,15.5
|
|
183
|
+
218.5,5.4,27.4,17.2
|
|
184
|
+
56.2,5.7,29.7,8.7
|
|
185
|
+
287.6,43,71.8,26.2
|
|
186
|
+
253.8,21.3,30,17.6
|
|
187
|
+
205,45.1,19.6,22.6
|
|
188
|
+
139.5,2.1,26.6,10.3
|
|
189
|
+
191.1,28.7,18.2,17.3
|
|
190
|
+
286,13.9,3.7,20.9
|
|
191
|
+
18.7,12.1,23.4,6.7
|
|
192
|
+
39.5,41.1,5.8,10.8
|
|
193
|
+
75.5,10.8,6,11.9
|
|
194
|
+
17.2,4.1,31.6,5.9
|
|
195
|
+
166.8,42,3.6,19.6
|
|
196
|
+
149.7,35.6,6,17.3
|
|
197
|
+
38.2,3.7,13.8,7.6
|
|
198
|
+
94.2,4.9,8.1,14
|
|
199
|
+
177,9.3,6.4,14.8
|
|
200
|
+
283.6,42,66.2,25.5
|
|
201
|
+
232.1,8.6,8.7,18.4
|