teradataml 20.0.0.1__py3-none-any.whl → 20.0.0.3__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 +306 -0
- teradataml/__init__.py +10 -3
- teradataml/_version.py +1 -1
- teradataml/analytics/__init__.py +3 -2
- teradataml/analytics/analytic_function_executor.py +299 -16
- teradataml/analytics/analytic_query_generator.py +92 -0
- teradataml/analytics/byom/__init__.py +3 -2
- teradataml/analytics/json_parser/metadata.py +13 -3
- teradataml/analytics/json_parser/utils.py +13 -6
- teradataml/analytics/meta_class.py +40 -1
- teradataml/analytics/sqle/DecisionTreePredict.py +1 -1
- teradataml/analytics/sqle/__init__.py +11 -2
- teradataml/analytics/table_operator/__init__.py +4 -3
- teradataml/analytics/uaf/__init__.py +21 -2
- teradataml/analytics/utils.py +66 -1
- teradataml/analytics/valib.py +1 -1
- teradataml/automl/__init__.py +1502 -323
- teradataml/automl/custom_json_utils.py +139 -61
- teradataml/automl/data_preparation.py +247 -307
- teradataml/automl/data_transformation.py +32 -12
- teradataml/automl/feature_engineering.py +325 -86
- teradataml/automl/model_evaluation.py +44 -35
- teradataml/automl/model_training.py +122 -153
- teradataml/catalog/byom.py +8 -8
- teradataml/clients/pkce_client.py +1 -1
- teradataml/common/__init__.py +2 -1
- teradataml/common/constants.py +72 -0
- teradataml/common/deprecations.py +13 -7
- teradataml/common/garbagecollector.py +152 -120
- teradataml/common/messagecodes.py +11 -2
- teradataml/common/messages.py +4 -1
- teradataml/common/sqlbundle.py +26 -4
- teradataml/common/utils.py +225 -14
- teradataml/common/wrapper_utils.py +1 -1
- teradataml/context/context.py +82 -2
- teradataml/data/SQL_Fundamentals.pdf +0 -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/dataframe_example.json +27 -1
- teradataml/data/docs/sqle/docs_17_20/CFilter.py +132 -0
- teradataml/data/docs/sqle/docs_17_20/NaiveBayes.py +162 -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/Shap.py +203 -0
- 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/TextParser.py +3 -3
- teradataml/data/docs/sqle/docs_17_20/Unpivoting.py +216 -0
- teradataml/data/docs/tableoperator/docs_17_20/Image2Matrix.py +118 -0
- 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/CopyArt.py +145 -0
- 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/DickeyFuller.py +18 -21
- 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/grocery_transaction.csv +19 -0
- teradataml/data/idwt2d_dataTable.csv +5 -0
- teradataml/data/idwt_dataTable.csv +8 -0
- teradataml/data/idwt_filterTable.csv +3 -0
- teradataml/data/interval_data.csv +5 -0
- teradataml/data/jsons/paired_functions.json +14 -0
- teradataml/data/jsons/sqle/17.20/TD_CFilter.json +118 -0
- 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_OneClassSVM.json +9 -9
- teradataml/data/jsons/sqle/17.20/TD_Pivoting.json +280 -0
- 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_TextParser.json +1 -1
- teradataml/data/jsons/sqle/17.20/TD_Unpivoting.json +235 -0
- teradataml/data/jsons/sqle/20.00/TD_KMeans.json +250 -0
- teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +266 -0
- teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +278 -0
- teradataml/data/jsons/storedprocedure/17.20/TD_COPYART.json +71 -0
- teradataml/data/jsons/storedprocedure/17.20/TD_FILTERFACTORY1D.json +150 -0
- teradataml/data/jsons/tableoperator/17.20/IMAGE2MATRIX.json +53 -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_DICKEY_FULLER.json +10 -19
- 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 +210 -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 +410 -0
- teradataml/data/load_example_data.py +8 -2
- teradataml/data/medical_readings.csv +101 -0
- teradataml/data/naivebayestextclassifier_example.json +1 -1
- teradataml/data/naivebayestextclassifierpredict_example.json +11 -0
- teradataml/data/patient_profile.csv +101 -0
- teradataml/data/peppers.png +0 -0
- teradataml/data/real_values.csv +14 -0
- teradataml/data/sax_example.json +8 -0
- teradataml/data/scripts/deploy_script.py +1 -1
- teradataml/data/scripts/lightgbm/dataset.template +157 -0
- teradataml/data/scripts/lightgbm/lightgbm_class_functions.template +247 -0
- teradataml/data/scripts/lightgbm/lightgbm_function.template +216 -0
- teradataml/data/scripts/lightgbm/lightgbm_sklearn.template +159 -0
- teradataml/data/scripts/sklearn/sklearn_fit.py +194 -160
- teradataml/data/scripts/sklearn/sklearn_fit_predict.py +136 -115
- teradataml/data/scripts/sklearn/sklearn_function.template +34 -16
- teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +155 -137
- teradataml/data/scripts/sklearn/sklearn_neighbors.py +1 -1
- teradataml/data/scripts/sklearn/sklearn_score.py +12 -3
- teradataml/data/scripts/sklearn/sklearn_transform.py +162 -24
- teradataml/data/star_pivot.csv +8 -0
- teradataml/data/target_udt_data.csv +8 -0
- teradataml/data/templates/open_source_ml.json +3 -1
- teradataml/data/teradataml_example.json +20 -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/vectordistance_example.json +4 -0
- teradataml/data/windowdfft.csv +16 -0
- teradataml/dataframe/copy_to.py +1 -1
- teradataml/dataframe/data_transfer.py +5 -3
- teradataml/dataframe/dataframe.py +1002 -201
- teradataml/dataframe/fastload.py +3 -3
- teradataml/dataframe/functions.py +867 -0
- teradataml/dataframe/row.py +160 -0
- teradataml/dataframe/setop.py +2 -2
- teradataml/dataframe/sql.py +840 -33
- teradataml/dataframe/window.py +1 -1
- teradataml/dbutils/dbutils.py +878 -34
- teradataml/dbutils/filemgr.py +48 -1
- 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/__init__.py +1 -1
- teradataml/opensource/{sklearn/_class.py → _class.py} +102 -17
- teradataml/opensource/_lightgbm.py +950 -0
- teradataml/opensource/{sklearn/_wrapper_utils.py → _wrapper_utils.py} +1 -2
- teradataml/opensource/{sklearn/constants.py → constants.py} +13 -10
- teradataml/opensource/sklearn/__init__.py +0 -1
- teradataml/opensource/sklearn/_sklearn_wrapper.py +1019 -574
- teradataml/options/__init__.py +9 -23
- teradataml/options/configure.py +42 -4
- teradataml/options/display.py +2 -2
- teradataml/plot/axis.py +4 -4
- teradataml/scriptmgmt/UserEnv.py +13 -9
- teradataml/scriptmgmt/lls_utils.py +77 -23
- teradataml/store/__init__.py +13 -0
- teradataml/store/feature_store/__init__.py +0 -0
- teradataml/store/feature_store/constants.py +291 -0
- teradataml/store/feature_store/feature_store.py +2223 -0
- teradataml/store/feature_store/models.py +1505 -0
- teradataml/store/vector_store/__init__.py +1586 -0
- teradataml/table_operators/Script.py +2 -2
- teradataml/table_operators/TableOperator.py +106 -20
- teradataml/table_operators/query_generator.py +3 -0
- teradataml/table_operators/table_operator_query_generator.py +3 -1
- teradataml/table_operators/table_operator_util.py +102 -56
- teradataml/table_operators/templates/dataframe_register.template +69 -0
- 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/dtypes.py +4 -2
- teradataml/utils/validators.py +34 -2
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.3.dist-info}/METADATA +311 -3
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.3.dist-info}/RECORD +240 -157
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.3.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.3.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.3.dist-info}/zip-safe +0 -0
teradataml/common/constants.py
CHANGED
|
@@ -18,6 +18,14 @@ from teradataml.options.configure import configure
|
|
|
18
18
|
from teradatasqlalchemy.types import (INTEGER, SMALLINT, BIGINT, BYTEINT, DECIMAL, FLOAT, NUMBER, VARCHAR)
|
|
19
19
|
from teradatasqlalchemy.types import (DATE, TIME, TIMESTAMP)
|
|
20
20
|
from teradatasqlalchemy.types import (BYTE, VARBYTE, BLOB)
|
|
21
|
+
from teradatasqlalchemy import (CHAR, CLOB)
|
|
22
|
+
from teradatasqlalchemy import (PERIOD_DATE, PERIOD_TIME, PERIOD_TIMESTAMP)
|
|
23
|
+
from teradatasqlalchemy import (INTERVAL_YEAR, INTERVAL_YEAR_TO_MONTH, INTERVAL_MONTH,
|
|
24
|
+
INTERVAL_DAY,INTERVAL_DAY_TO_HOUR, INTERVAL_DAY_TO_MINUTE,
|
|
25
|
+
INTERVAL_DAY_TO_SECOND, INTERVAL_HOUR,
|
|
26
|
+
INTERVAL_HOUR_TO_MINUTE, INTERVAL_HOUR_TO_SECOND,
|
|
27
|
+
INTERVAL_MINUTE, INTERVAL_MINUTE_TO_SECOND,
|
|
28
|
+
INTERVAL_SECOND)
|
|
21
29
|
from teradatasqlalchemy import (GEOMETRY, MBR, MBB)
|
|
22
30
|
|
|
23
31
|
|
|
@@ -53,6 +61,7 @@ class SQLConstants(Enum):
|
|
|
53
61
|
SQL_DELETE_ALL_ROWS = 29
|
|
54
62
|
SQL_DELETE_SPECIFIC_ROW = 30
|
|
55
63
|
SQL_EXEC_STORED_PROCEDURE = 31
|
|
64
|
+
SQL_SELECT_COLUMNNAMES_WITH_WHERE = 32
|
|
56
65
|
CONSTRAINT = ["check_constraint", "primary_key_constraint",
|
|
57
66
|
"foreign_key_constraint", "unique_key_constraint"]
|
|
58
67
|
|
|
@@ -123,6 +132,14 @@ class TeradataTypes(Enum):
|
|
|
123
132
|
TD_DATE_TYPES = [DATE, sqlalchemy.sql.sqltypes.Date]
|
|
124
133
|
TD_DATE_CODES = ["DA"]
|
|
125
134
|
TD_NULL_TYPE = "NULLTYPE"
|
|
135
|
+
TD_ALL_TYPES = (BYTEINT, SMALLINT, INTEGER, BIGINT, DECIMAL, FLOAT, NUMBER,
|
|
136
|
+
TIMESTAMP, DATE, TIME, CHAR, VARCHAR, CLOB, BYTE, VARBYTE,
|
|
137
|
+
BLOB, PERIOD_DATE, PERIOD_TIME, PERIOD_TIMESTAMP,
|
|
138
|
+
INTERVAL_YEAR, INTERVAL_YEAR_TO_MONTH, INTERVAL_MONTH,
|
|
139
|
+
INTERVAL_DAY, INTERVAL_DAY_TO_HOUR, INTERVAL_DAY_TO_MINUTE,
|
|
140
|
+
INTERVAL_DAY_TO_SECOND, INTERVAL_HOUR,
|
|
141
|
+
INTERVAL_HOUR_TO_MINUTE, INTERVAL_HOUR_TO_SECOND,
|
|
142
|
+
INTERVAL_MINUTE, INTERVAL_MINUTE_TO_SECOND, INTERVAL_SECOND)
|
|
126
143
|
|
|
127
144
|
|
|
128
145
|
class TeradataTableKindConstants(Enum):
|
|
@@ -425,6 +442,10 @@ class TableOperatorConstants(Enum):
|
|
|
425
442
|
MAP_TEMPLATE = "dataframe_map.template"
|
|
426
443
|
# Template of the intermediate script that will be generated.
|
|
427
444
|
APPLY_TEMPLATE = "dataframe_apply.template"
|
|
445
|
+
# Template of the intermediate script that will be generated for UDF.
|
|
446
|
+
UDF_TEMPLATE = "dataframe_udf.template"
|
|
447
|
+
# Template of the intermediate script that will be generated for register.
|
|
448
|
+
REGISTER_TEMPLATE = "dataframe_register.template"
|
|
428
449
|
# In-DB execution mode.
|
|
429
450
|
INDB_EXEC = "IN-DB"
|
|
430
451
|
# Local execution mode.
|
|
@@ -439,6 +460,10 @@ class TableOperatorConstants(Enum):
|
|
|
439
460
|
MAP_PARTITION_OP = "map_partition"
|
|
440
461
|
# apply operation.
|
|
441
462
|
APPLY_OP = "apply"
|
|
463
|
+
# udf operation.
|
|
464
|
+
UDF_OP = "udf"
|
|
465
|
+
# register operation.
|
|
466
|
+
REGISTER_OP = "register"
|
|
442
467
|
# Template of the script_executor that will be used to generate the temporary script_executor file.
|
|
443
468
|
SCRIPT_TEMPLATE = "script_executor.template"
|
|
444
469
|
# Log Type.
|
|
@@ -476,6 +501,9 @@ class TableOperatorConstants(Enum):
|
|
|
476
501
|
"delimiter(' ') " \
|
|
477
502
|
"returns('package VARCHAR({2}), " \
|
|
478
503
|
"version VARCHAR({2})'))"
|
|
504
|
+
|
|
505
|
+
SCRIPT_LIST_FILES_QUERY = "SELECT DISTINCT * FROM SCRIPT (SCRIPT_COMMAND " \
|
|
506
|
+
"('ls ./{}') RETURNS ('Files VARCHAR({})'))"
|
|
479
507
|
|
|
480
508
|
class ValibConstants(Enum):
|
|
481
509
|
# A dictionary that maps teradataml name of the exposed VALIB function name
|
|
@@ -1369,6 +1397,7 @@ class TeradataAnalyticFunctionTypes(Enum):
|
|
|
1369
1397
|
UAF = "UAF"
|
|
1370
1398
|
TABLEOPERATOR = "TABLE_OPERATOR"
|
|
1371
1399
|
BYOM = "BYOM"
|
|
1400
|
+
STORED_PROCEDURE = "STORED_PROCEDURE"
|
|
1372
1401
|
|
|
1373
1402
|
|
|
1374
1403
|
class TeradataAnalyticFunctionInfo(Enum):
|
|
@@ -1379,6 +1408,8 @@ class TeradataAnalyticFunctionInfo(Enum):
|
|
|
1379
1408
|
TABLE_OPERATOR = {"func_type": "tableoperator", "lowest_version": "17.00 ",
|
|
1380
1409
|
"display_function_type_name" :"TABLE OPERATOR"}
|
|
1381
1410
|
BYOM = {"func_type": "byom", "lowest_version": None, "display_function_type_name": "BYOM"}
|
|
1411
|
+
STORED_PROCEDURE = {"func_type": "storedprocedure", "lowest_version": "17.20", "display_function_type_name": "UAF",
|
|
1412
|
+
"metadata_class" : "_AnlyFuncMetadataUAF"}
|
|
1382
1413
|
|
|
1383
1414
|
class TeradataUAFSpecificArgs(Enum):
|
|
1384
1415
|
INPUT_MODE = "input_mode"
|
|
@@ -1436,3 +1467,44 @@ class CloudProvider(Enum):
|
|
|
1436
1467
|
# and '2018-03-28', using the latest one.
|
|
1437
1468
|
X_MS_VERSION = "2019-12-12"
|
|
1438
1469
|
X_MS_BLOB_TYPE = "BlockBlob"
|
|
1470
|
+
|
|
1471
|
+
class SessionParamsSQL:
|
|
1472
|
+
# Holds the SQL Statements for Session params.
|
|
1473
|
+
TIMEZONE = "SET TIME ZONE {}"
|
|
1474
|
+
ACCOUNT = "SET SESSION ACCOUNT = '{}' FOR {}"
|
|
1475
|
+
CALENDAR = "SET SESSION CALENDAR = {}"
|
|
1476
|
+
CHARACTER_SET_UNICODE = "SET SESSION CHARACTER SET UNICODE PASS THROUGH {}"
|
|
1477
|
+
COLLATION = "SET SESSION COLLATION {}"
|
|
1478
|
+
CONSTRAINT = "SET SESSION CONSTRAINT = {}"
|
|
1479
|
+
DATABASE = "SET SESSION DATABASE {}"
|
|
1480
|
+
DATEFORM = "SET SESSION DATEFORM = {}"
|
|
1481
|
+
DEBUG_FUNCTION = "SET SESSION DEBUG FUNCTION {} {}"
|
|
1482
|
+
DOT_NOTATION = "SET SESSION DOT NOTATION {} ON ERROR"
|
|
1483
|
+
ISOLATED_LOADING = "SET SESSION FOR {} ISOLATED LOADING"
|
|
1484
|
+
FUNCTION_TRACE = "SET SESSION FUNCTION TRACE USING {} FOR TABLE {}"
|
|
1485
|
+
JSON_IGNORE_ERRORS = "SET SESSION JSON IGNORE ERRORS {}"
|
|
1486
|
+
SEARCHUIFDBPATH = "SET SESSION SEARCHUIFDBPATH = {}"
|
|
1487
|
+
TRANSACTION_ISOLATION_LEVEL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL {}"
|
|
1488
|
+
QUERY_BAND = "SET QUERY_BAND = {} FOR {}"
|
|
1489
|
+
UDFSEARCHPATH = "SET SESSION UDFSEARCHPATH = {} FOR FUNCTION = {}"
|
|
1490
|
+
|
|
1491
|
+
class SessionParamsPythonNames:
|
|
1492
|
+
# Holds the SQL Statements for Session params.
|
|
1493
|
+
TIMEZONE = "Session Time Zone"
|
|
1494
|
+
ACCOUNT = "Account Name"
|
|
1495
|
+
CALENDAR = "Calendar"
|
|
1496
|
+
COLLATION = "Collation"
|
|
1497
|
+
DATABASE = "Current DataBase"
|
|
1498
|
+
DATEFORM = 'Current DateForm'
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
class Action(Enum):
|
|
1502
|
+
# Holds variable names for the type of grant to be provided.
|
|
1503
|
+
GRANT = "GRANT"
|
|
1504
|
+
REVOKE = "REVOKE"
|
|
1505
|
+
|
|
1506
|
+
class Permission(Enum):
|
|
1507
|
+
# Holds variable names for the type of permission to be provided.
|
|
1508
|
+
READ = "READ"
|
|
1509
|
+
WRITE = "WRITE"
|
|
1510
|
+
|
|
@@ -87,13 +87,19 @@ def argument_deprecation(tdml_version, deprecated_arguments, behaviour=False, al
|
|
|
87
87
|
|
|
88
88
|
def decorator(func):
|
|
89
89
|
def wrapper(*args, **kwargs):
|
|
90
|
-
|
|
91
|
-
if
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
# Check if deprecated arguments is a list, if not convert it to a list
|
|
91
|
+
deprecated_args_list = deprecated_arguments if isinstance(deprecated_arguments, list) \
|
|
92
|
+
else [deprecated_arguments]
|
|
93
|
+
# Check list of deprecated arguments are used in the function call
|
|
94
|
+
deprecated_arguments_used = [arg for arg in deprecated_args_list if arg in kwargs]
|
|
95
|
+
if deprecated_arguments_used:
|
|
96
|
+
msg = "\nThe argument(s) \"{}\" will be deprecated in {}."
|
|
97
|
+
if behaviour:
|
|
98
|
+
msg = "\nBehaviour of the argument(s) \"{}\" will change in {}."
|
|
99
|
+
msg = msg.format(deprecated_arguments_used, tdml_version)
|
|
100
|
+
if alternatives is not None:
|
|
101
|
+
msg += "\nUse argument(s) \"{}\" instead.".format(alternatives)
|
|
102
|
+
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
|
|
97
103
|
return func(*args, **kwargs)
|
|
98
104
|
|
|
99
105
|
return wraps(func)(wrapper)
|
|
@@ -22,6 +22,7 @@ from teradataml.common.messages import Messages
|
|
|
22
22
|
from teradataml.common.messagecodes import MessageCodes
|
|
23
23
|
from teradataml.common.constants import TeradataConstants
|
|
24
24
|
from teradataml.options.configure import configure
|
|
25
|
+
from teradataml.utils.internal_buffer import _InternalBuffer
|
|
25
26
|
from teradatasql import OperationalError
|
|
26
27
|
import psutil
|
|
27
28
|
import getpass
|
|
@@ -36,15 +37,22 @@ class GarbageCollector():
|
|
|
36
37
|
garbage collection, so that they can be dropped when connection is disconnected/lost.
|
|
37
38
|
Writes to a output file where the database name & table/view/script names are persisted.
|
|
38
39
|
"""
|
|
39
|
-
|
|
40
|
+
# Adding old garbage collector file name to support backward compatibility.
|
|
41
|
+
__old_garbage_persistent_file_name = getpass.getuser() + "_garbagecollect.info"
|
|
40
42
|
__garbagecollector_folder_name = '.teradataml'
|
|
41
43
|
__contentseperator = ","
|
|
44
|
+
__filenameseperator = "_"
|
|
42
45
|
__version = "ver1.0"
|
|
43
46
|
__gc_tables = []
|
|
44
47
|
__gc_views = []
|
|
45
48
|
__gc_scripts = []
|
|
46
49
|
__gc_container = []
|
|
47
50
|
__gc_apply = []
|
|
51
|
+
# Function to get the garbage collector file name specific to host and process.
|
|
52
|
+
_get_gc_file_name = lambda: "{}_{}_{}_garbagecollect.info".format(
|
|
53
|
+
getpass.getuser(),
|
|
54
|
+
tdmlctx.context._get_host_ip(),
|
|
55
|
+
str(os.getpid()))
|
|
48
56
|
|
|
49
57
|
@staticmethod
|
|
50
58
|
def _get_temp_dir_name():
|
|
@@ -93,7 +101,7 @@ class GarbageCollector():
|
|
|
93
101
|
"""
|
|
94
102
|
tempdir = GarbageCollector._get_temp_dir_name()
|
|
95
103
|
os.makedirs(tempdir, exist_ok=True)
|
|
96
|
-
tempfile = os.path.join(os.path.sep, tempdir, GarbageCollector.
|
|
104
|
+
tempfile = os.path.join(os.path.sep, tempdir, GarbageCollector._get_gc_file_name())
|
|
97
105
|
return tempfile
|
|
98
106
|
|
|
99
107
|
@staticmethod
|
|
@@ -205,29 +213,31 @@ class GarbageCollector():
|
|
|
205
213
|
EXAMPLES:
|
|
206
214
|
GarbageCollector._add_to_garbagecollector(object_name = "temp"."temp_table1")
|
|
207
215
|
"""
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
216
|
+
# Use global lock while writing to the garbage collector file.
|
|
217
|
+
with _InternalBuffer.get("global_lock"):
|
|
218
|
+
if object_name and object_type:
|
|
219
|
+
try:
|
|
220
|
+
tempfilename = GarbageCollector.__make_temp_file_name()
|
|
221
|
+
writecontent = str(GarbageCollector.__version) + "," + str(os.getpid())
|
|
222
|
+
writecontent += "," + str(object_type.value)
|
|
223
|
+
writecontent += "," + object_name + "\n"
|
|
224
|
+
with open(tempfilename, 'a+') as fgc:
|
|
225
|
+
fgc.write(writecontent)
|
|
226
|
+
if configure._validate_gc:
|
|
227
|
+
GarbageCollector.__validate_gc_add_object(object_name, object_type)
|
|
228
|
+
except TeradataMlException:
|
|
229
|
+
raise
|
|
230
|
+
except Exception as err:
|
|
231
|
+
logger.error(Messages.get_message(MessageCodes.TDMLDF_CREATE_GARBAGE_COLLECTOR) + str(err))
|
|
232
|
+
raise TeradataMlException(Messages.get_message(MessageCodes.TDMLDF_CREATE_GARBAGE_COLLECTOR),
|
|
233
|
+
MessageCodes.TDMLDF_CREATE_GARBAGE_COLLECTOR) from err
|
|
234
|
+
finally:
|
|
235
|
+
if fgc is not None:
|
|
236
|
+
fgc.close()
|
|
227
237
|
return True
|
|
228
238
|
|
|
229
239
|
@staticmethod
|
|
230
|
-
def __deleterow(content_row):
|
|
240
|
+
def __deleterow(content_row, file_name):
|
|
231
241
|
"""
|
|
232
242
|
DESCRIPTION:
|
|
233
243
|
Deletes an entry from persisted file.
|
|
@@ -237,6 +247,11 @@ class GarbageCollector():
|
|
|
237
247
|
Required Argument.
|
|
238
248
|
Specifies the text of row to delete from the persisted file.
|
|
239
249
|
Types: str
|
|
250
|
+
|
|
251
|
+
file_name:
|
|
252
|
+
Required Argument.
|
|
253
|
+
Specifies the name of the file to delete the row.
|
|
254
|
+
Types: str
|
|
240
255
|
|
|
241
256
|
RETURNS:
|
|
242
257
|
None.
|
|
@@ -248,10 +263,9 @@ class GarbageCollector():
|
|
|
248
263
|
GarbageCollector._deleterow(content_row = 'ver1.0,72136,3,"alice"."temp_table_gbview1"')
|
|
249
264
|
"""
|
|
250
265
|
try:
|
|
251
|
-
|
|
252
|
-
if not os.path.isfile(tempfilename):
|
|
266
|
+
if not os.path.isfile(file_name):
|
|
253
267
|
return True
|
|
254
|
-
with open(
|
|
268
|
+
with open(file_name, 'r+') as fgc:
|
|
255
269
|
output = fgc.readlines()
|
|
256
270
|
fgc.seek(0)
|
|
257
271
|
for dbtablename in output:
|
|
@@ -491,104 +505,122 @@ class GarbageCollector():
|
|
|
491
505
|
"""
|
|
492
506
|
try:
|
|
493
507
|
td_connection = tdmlctx.context.get_connection()
|
|
494
|
-
|
|
495
|
-
|
|
508
|
+
# Get the temp directory where garbage collector file is persisted.
|
|
509
|
+
tempdir = GarbageCollector._get_temp_dir_name()
|
|
510
|
+
# Garbage collect file that is created by the current host and current process.
|
|
511
|
+
# Also check if file is not of current process and associated process is
|
|
512
|
+
# currently running in the system or not.
|
|
513
|
+
# Walk through the temp directory and filter garbage collector files.
|
|
514
|
+
tempfiles = []
|
|
515
|
+
for root, _, files in os.walk(tempdir):
|
|
516
|
+
for file in files:
|
|
517
|
+
if file.endswith('_garbagecollect.info'):
|
|
518
|
+
try:
|
|
519
|
+
filepath = os.path.join(root, file)
|
|
520
|
+
fileparts = file.split(GarbageCollector.__filenameseperator)
|
|
521
|
+
hostname = fileparts[1]
|
|
522
|
+
filepid = int(fileparts[2])
|
|
523
|
+
# Check for both host ip and hostname in case user passed hostname for creating connection.
|
|
524
|
+
if hostname == tdmlctx.context._get_host_ip() or hostname == tdmlctx.context._get_host():
|
|
525
|
+
if filepid == os.getpid() or not psutil.pid_exists(filepid):
|
|
526
|
+
tempfiles.append(filepath)
|
|
527
|
+
except (IndexError, ValueError):
|
|
528
|
+
# Handle the case where the filename format is not as expected
|
|
529
|
+
# check if old garbage collector file is present.
|
|
530
|
+
if file == GarbageCollector.__old_garbage_persistent_file_name:
|
|
531
|
+
tempfiles.append(filepath)
|
|
532
|
+
|
|
533
|
+
# Process each garbage collector file.
|
|
534
|
+
if len(tempfiles) == 0:
|
|
496
535
|
return True
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
contentpid = int(recordparts[1].strip())
|
|
508
|
-
# Check and garbage collect even currrent running process at exit.
|
|
509
|
-
# Check if contentpid is not of current process as well as any
|
|
510
|
-
# currently running process in the system
|
|
511
|
-
proceed_to_cleanup = False
|
|
512
|
-
if contentpid != int(os.getpid()):
|
|
513
|
-
if not psutil.pid_exists(contentpid):
|
|
514
|
-
proceed_to_cleanup = True
|
|
515
|
-
else:
|
|
516
|
-
proceed_to_cleanup = True
|
|
517
|
-
if proceed_to_cleanup == True:
|
|
518
|
-
object_type = int(recordparts[2].strip())
|
|
519
|
-
database_object = recordparts[3].strip()
|
|
520
|
-
|
|
521
|
-
# Create the TeradataConstant to use with __delete_object_from_gc_list().
|
|
522
|
-
object_type_enum = TeradataConstants(object_type)
|
|
523
|
-
|
|
536
|
+
else:
|
|
537
|
+
for tempfilename in tempfiles:
|
|
538
|
+
if not os.path.isfile(tempfilename):
|
|
539
|
+
return True
|
|
540
|
+
with open(tempfilename, 'r+') as fgc:
|
|
541
|
+
content = fgc.readlines()
|
|
542
|
+
|
|
543
|
+
for contentrecord in content:
|
|
544
|
+
contentrecord = contentrecord.strip()
|
|
545
|
+
if (td_connection is not None) and (len(contentrecord) > 0):
|
|
524
546
|
try:
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
"[Teradata Database] [Error 3807] Object" in str(operr) or \
|
|
568
|
-
"[Teradata Database] [Error 9852] The file" in str(operr):
|
|
569
|
-
GarbageCollector.__deleterow(contentrecord)
|
|
570
|
-
# Delete entry from gc lists of required.
|
|
571
|
-
GarbageCollector.__delete_object_from_gc_list(database_object,
|
|
572
|
-
object_type_enum)
|
|
573
|
-
except (TeradataMlException, RuntimeError) as err:
|
|
574
|
-
if "Failed to execute get_env" in str(err) or \
|
|
575
|
-
"Failed to execute remove_file" in str(err):
|
|
576
|
-
# For removing files in OpenAF environment.
|
|
577
|
-
GarbageCollector.__deleterow(contentrecord)
|
|
578
|
-
# Delete entry from gc lists of required.
|
|
547
|
+
recordparts = contentrecord.split(GarbageCollector.__contentseperator)
|
|
548
|
+
object_type = int(recordparts[2].strip())
|
|
549
|
+
database_object = recordparts[3].strip()
|
|
550
|
+
|
|
551
|
+
# Create the TeradataConstant to use with __delete_object_from_gc_list().
|
|
552
|
+
object_type_enum = TeradataConstants(object_type)
|
|
553
|
+
|
|
554
|
+
try:
|
|
555
|
+
# Drop the table/view/script/container based on database object type retrieved from the collector file.
|
|
556
|
+
# # Drop table.
|
|
557
|
+
if TeradataConstants.TERADATA_TABLE.value == object_type:
|
|
558
|
+
tdmlutil.utils.UtilFuncs._drop_table(database_object,
|
|
559
|
+
check_table_exist=False)
|
|
560
|
+
|
|
561
|
+
# # Drop view.
|
|
562
|
+
elif TeradataConstants.TERADATA_VIEW.value == object_type:
|
|
563
|
+
tdmlutil.utils.UtilFuncs._drop_view(database_object,
|
|
564
|
+
check_view_exist=False)
|
|
565
|
+
|
|
566
|
+
elif object_type in [TeradataConstants.TERADATA_LOCAL_SCRIPT.value,
|
|
567
|
+
TeradataConstants.TERADATA_TEXT_FILE.value]:
|
|
568
|
+
GarbageCollector.__delete_gc_tempdir_local_file(database_object, object_type)
|
|
569
|
+
|
|
570
|
+
# # Drop Apply script.
|
|
571
|
+
elif TeradataConstants.TERADATA_APPLY.value == object_type:
|
|
572
|
+
tdmlutil.utils.UtilFuncs._delete_script(database_object,
|
|
573
|
+
file_type=object_type_enum)
|
|
574
|
+
# Delete the script locally
|
|
575
|
+
GarbageCollector.__delete_gc_tempdir_local_file(database_object, object_type)
|
|
576
|
+
|
|
577
|
+
# # Drop STO script.
|
|
578
|
+
else:
|
|
579
|
+
tdmlutil.utils.UtilFuncs._delete_script(database_object,
|
|
580
|
+
file_type=object_type_enum,
|
|
581
|
+
check_script_exist=False)
|
|
582
|
+
# Delete the script locally
|
|
583
|
+
GarbageCollector.__delete_gc_tempdir_local_file(database_object, object_type)
|
|
584
|
+
|
|
585
|
+
# Remove the entry for a table/view from GC, after it has been dropped.
|
|
586
|
+
GarbageCollector.__deleterow(contentrecord, tempfilename)
|
|
587
|
+
|
|
588
|
+
# Finally, delete the entry from gc lists if required.
|
|
579
589
|
GarbageCollector.__delete_object_from_gc_list(database_object,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
590
|
+
object_type_enum)
|
|
591
|
+
except OperationalError as operr:
|
|
592
|
+
# Remove the entry for a table/view/script even after drop has failed,
|
|
593
|
+
# if that object does not exist.
|
|
594
|
+
# Also added additional check for error when the database containing
|
|
595
|
+
# the object doesn't exist anymore.
|
|
596
|
+
if "[Teradata Database] [Error 3802] Database" in str(operr) or \
|
|
597
|
+
"[Teradata Database] [Error 3807] Object" in str(operr) or \
|
|
598
|
+
"[Teradata Database] [Error 9852] The file" in str(operr):
|
|
599
|
+
GarbageCollector.__deleterow(contentrecord, tempfilename)
|
|
600
|
+
# Delete entry from gc lists of required.
|
|
601
|
+
GarbageCollector.__delete_object_from_gc_list(database_object,
|
|
602
|
+
object_type_enum)
|
|
603
|
+
except (TeradataMlException, RuntimeError) as err:
|
|
604
|
+
if "Failed to execute get_env" in str(err) or \
|
|
605
|
+
"Failed to execute remove_file" in str(err):
|
|
606
|
+
# For removing files in OpenAF environment.
|
|
607
|
+
GarbageCollector.__deleterow(contentrecord, tempfilename)
|
|
608
|
+
# Delete entry from gc lists of required.
|
|
609
|
+
GarbageCollector.__delete_object_from_gc_list(database_object,
|
|
610
|
+
object_type_enum)
|
|
611
|
+
except FileNotFoundError:
|
|
612
|
+
# This will occur only when the item being deleted is a file,
|
|
613
|
+
# and it's local copy is not found.
|
|
614
|
+
GarbageCollector.__deleterow(contentrecord, tempfilename)
|
|
615
|
+
if object_type == TeradataConstants.TERADATA_APPLY:
|
|
616
|
+
GarbageCollector.__gc_apply.remove(database_object)
|
|
617
|
+
elif object_type == TeradataConstants.TERADATA_SCRIPT:
|
|
618
|
+
GarbageCollector.__gc_scripts.remove(database_object)
|
|
619
|
+
except Exception as err:
|
|
620
|
+
pass
|
|
621
|
+
# delete empty file itself after deleting the entry from the file
|
|
622
|
+
if os.path.getsize(tempfilename) == 0:
|
|
623
|
+
GarbageCollector._delete_local_file(tempfilename)
|
|
592
624
|
except Exception as e:
|
|
593
625
|
logger.error(Messages.get_message(MessageCodes.TDMLDF_DELETE_GARBAGE_COLLECTOR) + str(e))
|
|
594
626
|
finally:
|
|
@@ -86,6 +86,7 @@ class ErrorInfoCodes(Enum):
|
|
|
86
86
|
LIST_DB_TABLES_FAILED = 'TDML_2053'
|
|
87
87
|
INVALID_CONTEXT_CONNECTION = 'TDML_2054'
|
|
88
88
|
TDMLDF_REQUIRED_TABLE_ALIAS = "TDML_2055"
|
|
89
|
+
TDMLDF_ALIAS_REQUIRED = TDMLDF_REQUIRED_TABLE_ALIAS
|
|
89
90
|
TDMLDF_COLUMN_ALREADY_EXISTS = "TDML_2056"
|
|
90
91
|
TDMLDF_AGGREGATE_INVALID_COLUMN = 'TDML_2057'
|
|
91
92
|
TDMLDF_AGGREGATE_COMBINED_ERR = 'TDML_2058'
|
|
@@ -219,6 +220,10 @@ class ErrorInfoCodes(Enum):
|
|
|
219
220
|
PARTITION_VALUES_NOT_MATCHING = 'TDML_2538'
|
|
220
221
|
PARTITION_IN_BOTH_FIT_AND_PREDICT = 'TDML_2539'
|
|
221
222
|
INVALID_PARTITIONING_COLS = 'TDML_2540'
|
|
223
|
+
TARGET_COL_NOT_FOUND_FOR_EVALUATE = 'TDML_2541'
|
|
224
|
+
|
|
225
|
+
# OpenAF Error codes starting from 2551 - Reserved till 2560.
|
|
226
|
+
AUTH_TOKEN_REQUIRED = 'TDML_2551'
|
|
222
227
|
|
|
223
228
|
class MessageCodes(Enum):
|
|
224
229
|
"""
|
|
@@ -273,6 +278,7 @@ class MessageCodes(Enum):
|
|
|
273
278
|
"and df.select([['col1', 'col2', 'col3']])."
|
|
274
279
|
TDMLDF_INVALID_TABLE_ALIAS = "{} should not be equal."
|
|
275
280
|
TDMLDF_REQUIRED_TABLE_ALIAS = "All arguments lsuffix, rsuffix, lprefix and rprefix should not be None as TeradataML DataFrames contains common column(s)."
|
|
281
|
+
TDMLDF_ALIAS_REQUIRED = "Use aliased DataFrames for self {}."
|
|
276
282
|
TDMLDF_COLUMN_ALREADY_EXISTS = "Column name with alias '{}' already exists in {} TeradataML DataFrame, change '{}'"
|
|
277
283
|
TDMLDF_INVALID_JOIN_CONDITION = "Invalid 'on' condition(s): '{}', check documentation for valid conditions."
|
|
278
284
|
TDMLDF_UNEQUAL_NUMBER_OF_COLUMNS = "Number of columns in '{}' and '{}' should be equal."
|
|
@@ -418,7 +424,10 @@ class MessageCodes(Enum):
|
|
|
418
424
|
"they should be present in '{}' DataFrame."
|
|
419
425
|
PARTITIONING_COLS_IN_FEATURE_COLS = "Columns in '{}' argument should not be part of"\
|
|
420
426
|
" feature columns."
|
|
421
|
-
PARTITION_VALUES_NOT_MATCHING = "Values in
|
|
427
|
+
PARTITION_VALUES_NOT_MATCHING = "Values in {} and {} data partition columns should be same."
|
|
422
428
|
PARTITION_IN_BOTH_FIT_AND_PREDICT = "Use \"partition_columns\" only if model is fitted with partition_column(s)."
|
|
423
429
|
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."
|
|
430
|
+
PATH_NOT_FOUND = "Specified local path '{}' not found. Please check the path."
|
|
431
|
+
TARGET_COL_NOT_FOUND_FOR_EVALUATE = "Target column '{}' not found in the passed dataFrame. "\
|
|
432
|
+
"evaluate() requires target column to be present in the dataFrame."
|
|
433
|
+
AUTH_TOKEN_REQUIRED = "Authentication token is required to run '{}'. Set the token using set_auth_token()."
|
teradataml/common/messages.py
CHANGED
|
@@ -88,6 +88,7 @@ class Messages():
|
|
|
88
88
|
[ErrorInfoCodes.TDMLDF_INVALID_JOIN_CONDITION, MessageCodes.TDMLDF_INVALID_JOIN_CONDITION],
|
|
89
89
|
[ErrorInfoCodes.TDMLDF_INVALID_TABLE_ALIAS, MessageCodes.TDMLDF_INVALID_TABLE_ALIAS],
|
|
90
90
|
[ErrorInfoCodes.TDMLDF_REQUIRED_TABLE_ALIAS, MessageCodes.TDMLDF_REQUIRED_TABLE_ALIAS],
|
|
91
|
+
[ErrorInfoCodes.TDMLDF_ALIAS_REQUIRED, MessageCodes.TDMLDF_ALIAS_REQUIRED],
|
|
91
92
|
[ErrorInfoCodes.TDMLDF_COLUMN_ALREADY_EXISTS, MessageCodes.TDMLDF_COLUMN_ALREADY_EXISTS],
|
|
92
93
|
[ErrorInfoCodes.INVALID_LENGTH_ARGS, MessageCodes.INVALID_LENGTH_ARGS],
|
|
93
94
|
[ErrorInfoCodes.TDMLDF_AGGREGATE_UNSUPPORTED, MessageCodes.TDMLDF_AGGREGATE_UNSUPPORTED],
|
|
@@ -189,7 +190,9 @@ class Messages():
|
|
|
189
190
|
[ErrorInfoCodes.PARTITION_VALUES_NOT_MATCHING, MessageCodes.PARTITION_VALUES_NOT_MATCHING],
|
|
190
191
|
[ErrorInfoCodes.PARTITION_IN_BOTH_FIT_AND_PREDICT, MessageCodes.PARTITION_IN_BOTH_FIT_AND_PREDICT],
|
|
191
192
|
[ErrorInfoCodes.INVALID_PARTITIONING_COLS, MessageCodes.INVALID_PARTITIONING_COLS],
|
|
192
|
-
[ErrorInfoCodes.PATH_NOT_FOUND, MessageCodes.PATH_NOT_FOUND]
|
|
193
|
+
[ErrorInfoCodes.PATH_NOT_FOUND, MessageCodes.PATH_NOT_FOUND],
|
|
194
|
+
[ErrorInfoCodes.TARGET_COL_NOT_FOUND_FOR_EVALUATE, MessageCodes.TARGET_COL_NOT_FOUND_FOR_EVALUATE],
|
|
195
|
+
[ErrorInfoCodes.AUTH_TOKEN_REQUIRED, MessageCodes.AUTH_TOKEN_REQUIRED],
|
|
193
196
|
]
|
|
194
197
|
|
|
195
198
|
@staticmethod
|
teradataml/common/sqlbundle.py
CHANGED
|
@@ -47,7 +47,7 @@ class SQLBundle:
|
|
|
47
47
|
[SQLConstants.SQL_HELP_COLUMNS, "help column {0}.*"],
|
|
48
48
|
[SQLConstants.SQL_DROP_TABLE, "DROP TABLE {0}"],
|
|
49
49
|
[SQLConstants.SQL_DROP_VIEW, "DROP VIEW {0}"],
|
|
50
|
-
[SQLConstants.SQL_NROWS_FROM_QUERY, "SELECT COUNT(*) FROM {0}"],
|
|
50
|
+
[SQLConstants.SQL_NROWS_FROM_QUERY, "SELECT CAST(COUNT(*) AS BIGINT) FROM {0}"],
|
|
51
51
|
[SQLConstants.SQL_TOP_NROWS_FROM_TABLEORVIEW, "select top {0} * from {1}"],
|
|
52
52
|
[SQLConstants.SQL_INSERT_INTO_TABLE_VALUES, "insert into {0} values({1})"],
|
|
53
53
|
[SQLConstants.SQL_SELECT_COLUMNNAMES_FROM, "sel {0} from ({1}) as {2}"],
|
|
@@ -67,7 +67,8 @@ class SQLBundle:
|
|
|
67
67
|
[SQLConstants.SQL_DELETE_ALL_ROWS, "DELETE FROM {0}"],
|
|
68
68
|
[SQLConstants.SQL_DELETE_SPECIFIC_ROW, "DELETE FROM {0} WHERE {1}"],
|
|
69
69
|
[SQLConstants.SQL_CREATE_TABLE_USING_COLUMNS, "CREATE MULTISET TABLE {0}( {1} )"],
|
|
70
|
-
[SQLConstants.SQL_EXEC_STORED_PROCEDURE, "call {0}"]
|
|
70
|
+
[SQLConstants.SQL_EXEC_STORED_PROCEDURE, "call {0}"],
|
|
71
|
+
[SQLConstants.SQL_SELECT_COLUMNNAMES_WITH_WHERE, "sel {0} from {1} where {2}"],
|
|
71
72
|
|
|
72
73
|
]
|
|
73
74
|
self._add_sql_version()
|
|
@@ -446,11 +447,32 @@ class SQLBundle:
|
|
|
446
447
|
query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_DATABASENAME).format(schema_name)
|
|
447
448
|
if table_name:
|
|
448
449
|
if '%' in table_name:
|
|
449
|
-
|
|
450
|
+
# Check if '%' is present in the between of table name excluding first and last character
|
|
451
|
+
# as '%' can be present at the start or end of table name
|
|
452
|
+
# and replace single quotes with empty string
|
|
453
|
+
# Checking for following cases with % in between table name:
|
|
454
|
+
# eg: table_name = 'ab%c', '%a%bc', '%ab%c%' or 'ab%c%'
|
|
455
|
+
|
|
456
|
+
# table_name[1:-1] - Removing single quotes from table name
|
|
457
|
+
# table_name[1:-1][1:-1] - Removing first and last character from table_name[1:-1]
|
|
458
|
+
if '%' in table_name[1:-1][1:-1]:
|
|
459
|
+
query = "{0}{1}".format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_NAME_LIKE).format(table_name))
|
|
460
|
+
else:
|
|
461
|
+
# Checking for following cases with % at the start or end of table name:
|
|
462
|
+
# eg: table_name = '%abc', 'abc%', '%abc%'
|
|
463
|
+
# Extracting table name without '%' character
|
|
464
|
+
table_name_str = table_name.replace('%', '')
|
|
465
|
+
|
|
466
|
+
# Adding condition to check if table name contains the string using POSITION function
|
|
467
|
+
# POSITION function returns the position index of the substring in the string if found,
|
|
468
|
+
# else returns 0
|
|
469
|
+
query = "{0}{1}{2}".format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_NAME_LIKE).format(table_name), \
|
|
470
|
+
" AND POSITION({0} IN TABLENAME) > 0".format(table_name_str))
|
|
450
471
|
else:
|
|
451
|
-
query = "{0}{1}".format(query, sqlbundle._get_sql_query(SQLConstants.
|
|
472
|
+
query = "{0}{1}".format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_NAME_LIKE).format(table_name))
|
|
452
473
|
if table_kind:
|
|
453
474
|
query = '{0}{1}'.format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_KIND).format(table_kind))
|
|
475
|
+
|
|
454
476
|
return query
|
|
455
477
|
|
|
456
478
|
# TODO :: Following SQLConstants needs to be implemented as and when needed.
|