teradataml 20.0.0.0__py3-none-any.whl → 20.0.0.2__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 +183 -0
- teradataml/__init__.py +6 -3
- teradataml/_version.py +2 -2
- teradataml/analytics/__init__.py +3 -2
- teradataml/analytics/analytic_function_executor.py +275 -40
- teradataml/analytics/analytic_query_generator.py +92 -0
- teradataml/analytics/byom/__init__.py +3 -2
- teradataml/analytics/json_parser/metadata.py +1 -0
- teradataml/analytics/json_parser/utils.py +17 -21
- teradataml/analytics/meta_class.py +40 -1
- teradataml/analytics/sqle/DecisionTreePredict.py +1 -1
- teradataml/analytics/sqle/__init__.py +10 -2
- teradataml/analytics/table_operator/__init__.py +3 -2
- teradataml/analytics/uaf/__init__.py +21 -2
- teradataml/analytics/utils.py +62 -1
- teradataml/analytics/valib.py +1 -1
- teradataml/automl/__init__.py +1553 -319
- teradataml/automl/custom_json_utils.py +139 -61
- teradataml/automl/data_preparation.py +276 -319
- teradataml/automl/data_transformation.py +163 -81
- teradataml/automl/feature_engineering.py +402 -239
- teradataml/automl/feature_exploration.py +9 -2
- teradataml/automl/model_evaluation.py +48 -51
- teradataml/automl/model_training.py +291 -189
- teradataml/catalog/byom.py +8 -8
- teradataml/catalog/model_cataloging_utils.py +1 -1
- teradataml/clients/auth_client.py +133 -0
- teradataml/clients/pkce_client.py +1 -1
- teradataml/common/aed_utils.py +3 -2
- teradataml/common/constants.py +48 -6
- teradataml/common/deprecations.py +13 -7
- teradataml/common/garbagecollector.py +156 -120
- teradataml/common/messagecodes.py +6 -1
- teradataml/common/messages.py +3 -1
- teradataml/common/sqlbundle.py +1 -1
- teradataml/common/utils.py +103 -11
- teradataml/common/wrapper_utils.py +1 -1
- teradataml/context/context.py +121 -31
- 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/complaints_test_tokenized.csv +353 -0
- teradataml/data/complaints_tokens_model.csv +348 -0
- teradataml/data/covid_confirm_sd.csv +83 -0
- teradataml/data/customer_segmentation_test.csv +2628 -0
- teradataml/data/customer_segmentation_train.csv +8069 -0
- teradataml/data/dataframe_example.json +10 -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/CFilter.py +132 -0
- 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/NaiveBayes.py +162 -0
- 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/OutlierFilterFit.py +2 -0
- teradataml/data/docs/sqle/docs_17_20/Pivoting.py +279 -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/Shap.py +197 -0
- teradataml/data/docs/sqle/docs_17_20/TDGLMPredict.py +163 -1
- teradataml/data/docs/sqle/docs_17_20/TDNaiveBayesPredict.py +189 -0
- teradataml/data/docs/sqle/docs_17_20/TFIDF.py +142 -0
- teradataml/data/docs/sqle/docs_17_20/Unpivoting.py +216 -0
- 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/docs/uaf/docs_17_20/ACF.py +1 -10
- teradataml/data/docs/uaf/docs_17_20/ArimaEstimate.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/ArimaForecast.py +35 -5
- teradataml/data/docs/uaf/docs_17_20/ArimaValidate.py +3 -1
- teradataml/data/docs/uaf/docs_17_20/ArimaXEstimate.py +293 -0
- teradataml/data/docs/uaf/docs_17_20/AutoArima.py +354 -0
- teradataml/data/docs/uaf/docs_17_20/BreuschGodfrey.py +3 -2
- teradataml/data/docs/uaf/docs_17_20/BreuschPaganGodfrey.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/Convolve.py +13 -10
- teradataml/data/docs/uaf/docs_17_20/Convolve2.py +4 -1
- teradataml/data/docs/uaf/docs_17_20/CumulPeriodogram.py +5 -4
- teradataml/data/docs/uaf/docs_17_20/DFFT2Conv.py +4 -4
- teradataml/data/docs/uaf/docs_17_20/DWT.py +235 -0
- teradataml/data/docs/uaf/docs_17_20/DWT2D.py +214 -0
- teradataml/data/docs/uaf/docs_17_20/DurbinWatson.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/ExtractResults.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/FilterFactory1d.py +160 -0
- teradataml/data/docs/uaf/docs_17_20/GenseriesSinusoids.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/GoldfeldQuandt.py +9 -31
- teradataml/data/docs/uaf/docs_17_20/HoltWintersForecaster.py +4 -2
- teradataml/data/docs/uaf/docs_17_20/IDFFT2.py +1 -8
- teradataml/data/docs/uaf/docs_17_20/IDWT.py +236 -0
- teradataml/data/docs/uaf/docs_17_20/IDWT2D.py +226 -0
- teradataml/data/docs/uaf/docs_17_20/IQR.py +134 -0
- teradataml/data/docs/uaf/docs_17_20/LineSpec.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/LinearRegr.py +2 -2
- teradataml/data/docs/uaf/docs_17_20/MAMean.py +3 -3
- teradataml/data/docs/uaf/docs_17_20/Matrix2Image.py +297 -0
- teradataml/data/docs/uaf/docs_17_20/MatrixMultiply.py +15 -6
- teradataml/data/docs/uaf/docs_17_20/PACF.py +0 -1
- teradataml/data/docs/uaf/docs_17_20/Portman.py +2 -2
- teradataml/data/docs/uaf/docs_17_20/PowerSpec.py +2 -2
- teradataml/data/docs/uaf/docs_17_20/Resample.py +9 -1
- teradataml/data/docs/uaf/docs_17_20/SAX.py +246 -0
- teradataml/data/docs/uaf/docs_17_20/SeasonalNormalize.py +17 -10
- teradataml/data/docs/uaf/docs_17_20/SignifPeriodicities.py +1 -1
- teradataml/data/docs/uaf/docs_17_20/WhitesGeneral.py +3 -1
- teradataml/data/docs/uaf/docs_17_20/WindowDFFT.py +368 -0
- teradataml/data/dwt2d_dataTable.csv +65 -0
- teradataml/data/dwt_dataTable.csv +8 -0
- teradataml/data/dwt_filterTable.csv +3 -0
- teradataml/data/finance_data4.csv +13 -0
- teradataml/data/glm_example.json +28 -1
- teradataml/data/grocery_transaction.csv +19 -0
- teradataml/data/housing_train_segment.csv +201 -0
- teradataml/data/idwt2d_dataTable.csv +5 -0
- teradataml/data/idwt_dataTable.csv +8 -0
- teradataml/data/idwt_filterTable.csv +3 -0
- teradataml/data/insect2Cols.csv +61 -0
- teradataml/data/interval_data.csv +5 -0
- teradataml/data/jsons/paired_functions.json +14 -0
- teradataml/data/jsons/sqle/17.20/TD_ANOVA.json +99 -27
- teradataml/data/jsons/sqle/17.20/TD_CFilter.json +118 -0
- 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_NaiveBayes.json +193 -0
- teradataml/data/jsons/sqle/17.20/TD_NaiveBayesPredict.json +212 -0
- teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineFit.json +3 -2
- teradataml/data/jsons/sqle/17.20/TD_OneClassSVM.json +9 -9
- teradataml/data/jsons/sqle/17.20/TD_Pivoting.json +280 -0
- 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_Shap.json +222 -0
- teradataml/data/jsons/sqle/17.20/TD_TFIDF.json +162 -0
- teradataml/data/jsons/sqle/17.20/TD_Unpivoting.json +235 -0
- 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/jsons/storedprocedure/17.20/TD_FILTERFACTORY1D.json +150 -0
- teradataml/data/jsons/uaf/17.20/TD_ACF.json +1 -18
- teradataml/data/jsons/uaf/17.20/TD_ARIMAESTIMATE.json +3 -16
- teradataml/data/jsons/uaf/17.20/TD_ARIMAFORECAST.json +0 -3
- teradataml/data/jsons/uaf/17.20/TD_ARIMAVALIDATE.json +5 -3
- teradataml/data/jsons/uaf/17.20/TD_ARIMAXESTIMATE.json +362 -0
- teradataml/data/jsons/uaf/17.20/TD_AUTOARIMA.json +469 -0
- teradataml/data/jsons/uaf/17.20/TD_BINARYMATRIXOP.json +0 -3
- teradataml/data/jsons/uaf/17.20/TD_BINARYSERIESOP.json +0 -2
- teradataml/data/jsons/uaf/17.20/TD_BREUSCH_GODFREY.json +2 -1
- teradataml/data/jsons/uaf/17.20/TD_BREUSCH_PAGAN_GODFREY.json +2 -5
- teradataml/data/jsons/uaf/17.20/TD_CONVOLVE.json +3 -6
- teradataml/data/jsons/uaf/17.20/TD_CONVOLVE2.json +1 -3
- teradataml/data/jsons/uaf/17.20/TD_CUMUL_PERIODOGRAM.json +0 -5
- teradataml/data/jsons/uaf/17.20/TD_DFFT.json +1 -4
- teradataml/data/jsons/uaf/17.20/TD_DFFT2.json +2 -7
- teradataml/data/jsons/uaf/17.20/TD_DFFT2CONV.json +1 -2
- teradataml/data/jsons/uaf/17.20/TD_DFFTCONV.json +0 -2
- teradataml/data/jsons/uaf/17.20/TD_DTW.json +3 -6
- teradataml/data/jsons/uaf/17.20/TD_DWT.json +173 -0
- teradataml/data/jsons/uaf/17.20/TD_DWT2D.json +160 -0
- teradataml/data/jsons/uaf/17.20/TD_FITMETRICS.json +1 -1
- teradataml/data/jsons/uaf/17.20/TD_GOLDFELD_QUANDT.json +16 -30
- teradataml/data/jsons/uaf/17.20/{TD_HOLT_WINTERS_FORECAST.json → TD_HOLT_WINTERS_FORECASTER.json} +1 -2
- teradataml/data/jsons/uaf/17.20/TD_IDFFT2.json +1 -15
- teradataml/data/jsons/uaf/17.20/TD_IDWT.json +162 -0
- teradataml/data/jsons/uaf/17.20/TD_IDWT2D.json +149 -0
- teradataml/data/jsons/uaf/17.20/TD_IQR.json +117 -0
- teradataml/data/jsons/uaf/17.20/TD_LINEAR_REGR.json +1 -1
- teradataml/data/jsons/uaf/17.20/TD_LINESPEC.json +1 -1
- teradataml/data/jsons/uaf/17.20/TD_MAMEAN.json +1 -3
- teradataml/data/jsons/uaf/17.20/TD_MATRIX2IMAGE.json +209 -0
- teradataml/data/jsons/uaf/17.20/TD_PACF.json +2 -2
- teradataml/data/jsons/uaf/17.20/TD_POWERSPEC.json +5 -5
- teradataml/data/jsons/uaf/17.20/TD_RESAMPLE.json +48 -28
- teradataml/data/jsons/uaf/17.20/TD_SAX.json +208 -0
- teradataml/data/jsons/uaf/17.20/TD_SEASONALNORMALIZE.json +12 -6
- teradataml/data/jsons/uaf/17.20/TD_SIMPLEEXP.json +0 -1
- teradataml/data/jsons/uaf/17.20/TD_TRACKINGOP.json +8 -8
- teradataml/data/jsons/uaf/17.20/TD_UNDIFF.json +1 -1
- teradataml/data/jsons/uaf/17.20/TD_UNNORMALIZE.json +1 -1
- teradataml/data/jsons/uaf/17.20/TD_WINDOWDFFT.json +400 -0
- teradataml/data/kmeans_example.json +5 -0
- teradataml/data/kmeans_table.csv +10 -0
- teradataml/data/load_example_data.py +8 -2
- teradataml/data/naivebayestextclassifier_example.json +1 -1
- teradataml/data/naivebayestextclassifierpredict_example.json +11 -0
- teradataml/data/onehot_encoder_train.csv +4 -0
- teradataml/data/openml_example.json +29 -0
- teradataml/data/peppers.png +0 -0
- teradataml/data/real_values.csv +14 -0
- teradataml/data/sax_example.json +8 -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 +21 -2
- teradataml/data/scripts/sklearn/sklearn_fit.py +40 -37
- teradataml/data/scripts/sklearn/sklearn_fit_predict.py +22 -30
- teradataml/data/scripts/sklearn/sklearn_function.template +42 -24
- teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +23 -33
- teradataml/data/scripts/sklearn/sklearn_neighbors.py +19 -28
- teradataml/data/scripts/sklearn/sklearn_score.py +32 -32
- teradataml/data/scripts/sklearn/sklearn_transform.py +85 -42
- teradataml/data/star_pivot.csv +8 -0
- teradataml/data/templates/open_source_ml.json +2 -1
- teradataml/data/teradataml_example.json +97 -1
- teradataml/data/timestamp_data.csv +4 -0
- teradataml/data/titanic_dataset_unpivoted.csv +19 -0
- teradataml/data/uaf_example.json +55 -1
- teradataml/data/unpivot_example.json +15 -0
- teradataml/data/url_data.csv +9 -0
- teradataml/data/windowdfft.csv +16 -0
- teradataml/data/ztest_example.json +16 -0
- teradataml/dataframe/copy_to.py +9 -4
- teradataml/dataframe/data_transfer.py +125 -64
- teradataml/dataframe/dataframe.py +575 -57
- teradataml/dataframe/dataframe_utils.py +47 -9
- teradataml/dataframe/fastload.py +273 -90
- teradataml/dataframe/functions.py +339 -0
- teradataml/dataframe/row.py +160 -0
- teradataml/dataframe/setop.py +2 -2
- teradataml/dataframe/sql.py +740 -18
- teradataml/dataframe/window.py +1 -1
- teradataml/dbutils/dbutils.py +324 -18
- teradataml/geospatial/geodataframe.py +1 -1
- teradataml/geospatial/geodataframecolumn.py +1 -1
- teradataml/hyperparameter_tuner/optimizer.py +13 -13
- teradataml/lib/aed_0_1.dll +0 -0
- teradataml/opensource/sklearn/_sklearn_wrapper.py +254 -122
- teradataml/options/__init__.py +16 -5
- teradataml/options/configure.py +39 -6
- teradataml/options/display.py +2 -2
- teradataml/plot/axis.py +4 -4
- teradataml/scriptmgmt/UserEnv.py +26 -19
- teradataml/scriptmgmt/lls_utils.py +120 -16
- teradataml/table_operators/Script.py +4 -5
- teradataml/table_operators/TableOperator.py +160 -26
- teradataml/table_operators/table_operator_util.py +88 -41
- teradataml/table_operators/templates/dataframe_udf.template +63 -0
- teradataml/telemetry_utils/__init__.py +0 -0
- teradataml/telemetry_utils/queryband.py +52 -0
- teradataml/utils/validators.py +41 -3
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.2.dist-info}/METADATA +191 -6
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.2.dist-info}/RECORD +263 -185
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.2.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.2.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.0.dist-info → teradataml-20.0.0.2.dist-info}/zip-safe +0 -0
teradataml/context/context.py
CHANGED
|
@@ -13,9 +13,10 @@ A teradataml context functions provide interface to Teradata Vantage. Provides f
|
|
|
13
13
|
context which can be used by other analytical functions to get the Teradata Vantage connection.
|
|
14
14
|
|
|
15
15
|
"""
|
|
16
|
+
import ipaddress
|
|
16
17
|
from pathlib import Path
|
|
17
18
|
from sqlalchemy import create_engine
|
|
18
|
-
from
|
|
19
|
+
from teradataml.telemetry_utils.queryband import collect_queryband
|
|
19
20
|
from teradataml.common.deprecations import argument_deprecation
|
|
20
21
|
from teradataml.common.exceptions import TeradataMlException
|
|
21
22
|
from teradataml.common.warnings import TeradataMlRuntimeWarning
|
|
@@ -35,6 +36,8 @@ from sqlalchemy.engine.url import URL
|
|
|
35
36
|
import os
|
|
36
37
|
import warnings
|
|
37
38
|
import atexit
|
|
39
|
+
import socket
|
|
40
|
+
import threading
|
|
38
41
|
import urllib.parse
|
|
39
42
|
|
|
40
43
|
# Store a global Teradata Vantage Connection.
|
|
@@ -69,20 +72,24 @@ def _get_current_databasename():
|
|
|
69
72
|
EXAMPLES:
|
|
70
73
|
_get_current_databasename()
|
|
71
74
|
"""
|
|
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
|
|
75
|
+
if configure._current_database_name:
|
|
76
|
+
return configure._current_database_name
|
|
84
77
|
else:
|
|
85
|
-
|
|
78
|
+
if get_connection() is not None:
|
|
79
|
+
select_user_query = ""
|
|
80
|
+
try:
|
|
81
|
+
sqlbundle = SQLBundle()
|
|
82
|
+
select_user_query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_DATABASE)
|
|
83
|
+
result = execute_sql(select_user_query)
|
|
84
|
+
configure._current_database_name = result.fetchall()[0][0]
|
|
85
|
+
return configure._current_database_name
|
|
86
|
+
except TeradataMlException:
|
|
87
|
+
raise
|
|
88
|
+
except Exception as err:
|
|
89
|
+
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_EXEC_SQL_FAILED, select_user_query),
|
|
90
|
+
MessageCodes.TDMLDF_EXEC_SQL_FAILED) from err
|
|
91
|
+
else:
|
|
92
|
+
return None
|
|
86
93
|
|
|
87
94
|
|
|
88
95
|
def _get_database_username():
|
|
@@ -101,20 +108,24 @@ def _get_database_username():
|
|
|
101
108
|
EXAMPLES:
|
|
102
109
|
_get_database_username()
|
|
103
110
|
"""
|
|
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
|
|
111
|
+
if configure._database_username:
|
|
112
|
+
return configure._database_username
|
|
116
113
|
else:
|
|
117
|
-
|
|
114
|
+
if get_connection() is not None:
|
|
115
|
+
select_query = ""
|
|
116
|
+
try:
|
|
117
|
+
sqlbundle = SQLBundle()
|
|
118
|
+
select_query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_USER)
|
|
119
|
+
result = execute_sql(select_query)
|
|
120
|
+
configure._database_username = result.fetchall()[0][0]
|
|
121
|
+
return configure._database_username
|
|
122
|
+
except TeradataMlException:
|
|
123
|
+
raise
|
|
124
|
+
except Exception as err:
|
|
125
|
+
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_EXEC_SQL_FAILED, select_query),
|
|
126
|
+
MessageCodes.TDMLDF_EXEC_SQL_FAILED) from err
|
|
127
|
+
else:
|
|
128
|
+
return None
|
|
118
129
|
|
|
119
130
|
|
|
120
131
|
def __cleanup_garbage_collection():
|
|
@@ -500,11 +511,18 @@ def create_context(host = None, username = None, password = None, tdsqlengine =
|
|
|
500
511
|
__initalise_dag()
|
|
501
512
|
|
|
502
513
|
# Set database version.
|
|
503
|
-
|
|
514
|
+
_get_database_version()
|
|
515
|
+
# Set current database name.
|
|
516
|
+
_get_current_databasename()
|
|
517
|
+
# Set database user name.
|
|
518
|
+
_get_database_username()
|
|
504
519
|
|
|
505
520
|
# Process Analytic functions.
|
|
506
521
|
from teradataml.analytics import _process_analytic_functions
|
|
507
522
|
_process_analytic_functions()
|
|
523
|
+
|
|
524
|
+
# Add global lock to internal buffer
|
|
525
|
+
_InternalBuffer.add(global_lock=threading.Lock())
|
|
508
526
|
|
|
509
527
|
# Return the connection by default
|
|
510
528
|
return td_sqlalchemy_engine
|
|
@@ -608,6 +626,8 @@ def set_context(tdsqlengine, temp_database_name=None):
|
|
|
608
626
|
global user_specified_connection
|
|
609
627
|
global python_packages_installed
|
|
610
628
|
if td_connection is not None:
|
|
629
|
+
# Clearing the internal buffer.
|
|
630
|
+
_InternalBuffer.clean()
|
|
611
631
|
warnings.warn(Messages.get_message(MessageCodes.OVERWRITE_CONTEXT), stacklevel=2)
|
|
612
632
|
remove_context()
|
|
613
633
|
|
|
@@ -637,6 +657,9 @@ def set_context(tdsqlengine, temp_database_name=None):
|
|
|
637
657
|
|
|
638
658
|
# Initialise Dag
|
|
639
659
|
__initalise_dag()
|
|
660
|
+
|
|
661
|
+
# Add global lock to internal buffer
|
|
662
|
+
_InternalBuffer.add(global_lock=threading.Lock())
|
|
640
663
|
|
|
641
664
|
return td_connection
|
|
642
665
|
|
|
@@ -666,9 +689,10 @@ def remove_context():
|
|
|
666
689
|
global python_packages_installed
|
|
667
690
|
global td_user
|
|
668
691
|
|
|
669
|
-
#
|
|
692
|
+
# Initiate the garbage collection
|
|
670
693
|
__cleanup_garbage_collection()
|
|
671
694
|
|
|
695
|
+
# Check if connection is established or not.
|
|
672
696
|
if user_specified_connection is not True:
|
|
673
697
|
try:
|
|
674
698
|
# Close the connection if not user specified connection.
|
|
@@ -683,6 +707,9 @@ def remove_context():
|
|
|
683
707
|
td_sqlalchemy_engine = None
|
|
684
708
|
python_packages_installed = False
|
|
685
709
|
td_user = None
|
|
710
|
+
configure._current_database_name = None
|
|
711
|
+
configure._database_username = None
|
|
712
|
+
configure.database_version = None
|
|
686
713
|
|
|
687
714
|
# Closing Dag
|
|
688
715
|
__close_dag()
|
|
@@ -717,6 +744,9 @@ def _get_context_temp_databasename(table_type=TeradataConstants.TERADATA_VIEW):
|
|
|
717
744
|
if table_type == TeradataConstants.TERADATA_VIEW and \
|
|
718
745
|
configure.temp_view_database is not None:
|
|
719
746
|
return configure.temp_view_database
|
|
747
|
+
# ELE-6710 - Use database user associated with the current context for volatile tables.
|
|
748
|
+
if table_type == TeradataConstants.TERADATA_VOLATILE_TABLE:
|
|
749
|
+
return _get_user()
|
|
720
750
|
return temporary_database_name
|
|
721
751
|
|
|
722
752
|
|
|
@@ -821,7 +851,8 @@ def _get_vantage_version():
|
|
|
821
851
|
EXAMPLES:
|
|
822
852
|
_get_vantage_version()
|
|
823
853
|
"""
|
|
824
|
-
if td_connection.dialect.has_table(td_connection, "versionInfo", schema="pm"
|
|
854
|
+
if td_connection.dialect.has_table(td_connection, "versionInfo", schema="pm",
|
|
855
|
+
table_only=True):
|
|
825
856
|
|
|
826
857
|
# BTEQ -- Enter your SQL request or BTEQ command:
|
|
827
858
|
# select * from pm.versionInfo;
|
|
@@ -877,7 +908,9 @@ def _get_database_version():
|
|
|
877
908
|
# RELEASE 17.05a.00.147
|
|
878
909
|
|
|
879
910
|
try:
|
|
880
|
-
|
|
911
|
+
if configure.database_version is None:
|
|
912
|
+
configure.database_version = execute_sql(Query.VANTAGE_VERSION.value).fetchall()[0][0]
|
|
913
|
+
return configure.database_version
|
|
881
914
|
except:
|
|
882
915
|
return None
|
|
883
916
|
|
|
@@ -960,6 +993,63 @@ def _get_user():
|
|
|
960
993
|
td_user = _get_database_username()
|
|
961
994
|
return td_user
|
|
962
995
|
|
|
996
|
+
def _get_host():
|
|
997
|
+
"""
|
|
998
|
+
DESCRIPTION:
|
|
999
|
+
An internal function to get the host associated with the current context.
|
|
1000
|
+
|
|
1001
|
+
PARAMETERS:
|
|
1002
|
+
None.
|
|
1003
|
+
|
|
1004
|
+
RETURNS:
|
|
1005
|
+
Host associated with the current context.
|
|
1006
|
+
|
|
1007
|
+
RAISES:
|
|
1008
|
+
None.
|
|
1009
|
+
|
|
1010
|
+
EXAMPLES:
|
|
1011
|
+
_get_host()
|
|
1012
|
+
"""
|
|
1013
|
+
global td_sqlalchemy_engine
|
|
1014
|
+
return td_sqlalchemy_engine.url.host
|
|
1015
|
+
|
|
1016
|
+
def _get_host_ip():
|
|
1017
|
+
"""
|
|
1018
|
+
DESCRIPTION:
|
|
1019
|
+
Function to return the host IP address.
|
|
1020
|
+
|
|
1021
|
+
PARAMETERS:
|
|
1022
|
+
None.
|
|
1023
|
+
|
|
1024
|
+
RETURNS:
|
|
1025
|
+
Host IP address.
|
|
1026
|
+
|
|
1027
|
+
RAISES:
|
|
1028
|
+
None.
|
|
1029
|
+
|
|
1030
|
+
EXAMPLES:
|
|
1031
|
+
GarbageCollector._get_host_ip()
|
|
1032
|
+
"""
|
|
1033
|
+
# Return None if connection is not established.
|
|
1034
|
+
if td_connection is None:
|
|
1035
|
+
return None
|
|
1036
|
+
|
|
1037
|
+
host_ip = _get_host()
|
|
1038
|
+
try:
|
|
1039
|
+
# Validate if host_ip is a valid IP address (IPv4 or IPv6)
|
|
1040
|
+
ipaddress.ip_address(host_ip)
|
|
1041
|
+
except ValueError:
|
|
1042
|
+
# If host is not an IP address, get the IP address by DNS name from _InternalBuffer.
|
|
1043
|
+
host_ip = _InternalBuffer.get('dns_host_ip')
|
|
1044
|
+
if host_ip is None:
|
|
1045
|
+
global td_sqlalchemy_engine
|
|
1046
|
+
# Get the list of addresses(compatible for both IPv4 and IPv6)
|
|
1047
|
+
addr_info = socket.getaddrinfo(td_sqlalchemy_engine.url.host, None)
|
|
1048
|
+
# Pick the first address from the list
|
|
1049
|
+
host_ip = addr_info[0][4][0]
|
|
1050
|
+
# Add the DNS host IP to the _InternalBuffer.
|
|
1051
|
+
_InternalBuffer.add(dns_host_ip=host_ip)
|
|
1052
|
+
return host_ip
|
|
963
1053
|
|
|
964
1054
|
class ContextUtilFuncs():
|
|
965
1055
|
@staticmethod
|
|
@@ -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
|