teradataml 20.0.0.1__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.pdf +0 -0
- teradataml/README.md +112 -0
- teradataml/__init__.py +6 -3
- teradataml/_version.py +1 -1
- teradataml/analytics/__init__.py +3 -2
- teradataml/analytics/analytic_function_executor.py +224 -16
- 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 +6 -4
- 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 +1502 -323
- teradataml/automl/custom_json_utils.py +139 -61
- teradataml/automl/data_preparation.py +245 -306
- teradataml/automl/data_transformation.py +32 -12
- teradataml/automl/feature_engineering.py +313 -82
- teradataml/automl/model_evaluation.py +44 -35
- teradataml/automl/model_training.py +109 -146
- teradataml/catalog/byom.py +8 -8
- teradataml/clients/pkce_client.py +1 -1
- teradataml/common/constants.py +37 -0
- teradataml/common/deprecations.py +13 -7
- teradataml/common/garbagecollector.py +151 -120
- teradataml/common/messagecodes.py +4 -1
- teradataml/common/messages.py +2 -1
- teradataml/common/sqlbundle.py +1 -1
- teradataml/common/utils.py +97 -11
- teradataml/common/wrapper_utils.py +1 -1
- teradataml/context/context.py +72 -2
- 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 +10 -0
- 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 +197 -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/Unpivoting.py +216 -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/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/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_Unpivoting.json +235 -0
- 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/load_example_data.py +8 -2
- teradataml/data/naivebayestextclassifier_example.json +1 -1
- teradataml/data/naivebayestextclassifierpredict_example.json +11 -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/sklearn/sklearn_fit.py +17 -10
- teradataml/data/scripts/sklearn/sklearn_fit_predict.py +2 -2
- teradataml/data/scripts/sklearn/sklearn_function.template +30 -7
- 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 +55 -4
- teradataml/data/star_pivot.csv +8 -0
- teradataml/data/templates/open_source_ml.json +2 -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/windowdfft.csv +16 -0
- teradataml/dataframe/copy_to.py +1 -1
- teradataml/dataframe/data_transfer.py +5 -3
- teradataml/dataframe/dataframe.py +474 -41
- teradataml/dataframe/fastload.py +3 -3
- teradataml/dataframe/functions.py +339 -0
- teradataml/dataframe/row.py +160 -0
- teradataml/dataframe/setop.py +2 -2
- teradataml/dataframe/sql.py +658 -20
- teradataml/dataframe/window.py +1 -1
- teradataml/dbutils/dbutils.py +322 -16
- 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 +154 -69
- teradataml/options/__init__.py +3 -1
- teradataml/options/configure.py +14 -2
- teradataml/options/display.py +2 -2
- teradataml/plot/axis.py +4 -4
- teradataml/scriptmgmt/UserEnv.py +10 -6
- teradataml/scriptmgmt/lls_utils.py +3 -2
- teradataml/table_operators/Script.py +2 -2
- teradataml/table_operators/TableOperator.py +106 -20
- 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 +1 -1
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.2.dist-info}/METADATA +115 -2
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.2.dist-info}/RECORD +200 -140
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.2.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.2.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.1.dist-info → teradataml-20.0.0.2.dist-info}/zip-safe +0 -0
teradataml/LICENSE.pdf
CHANGED
|
Binary file
|
teradataml/README.md
CHANGED
|
@@ -16,6 +16,118 @@ Copyright 2024, Teradata. All Rights Reserved.
|
|
|
16
16
|
* [License](#license)
|
|
17
17
|
|
|
18
18
|
## Release Notes:
|
|
19
|
+
#### teradataml 20.00.00.02
|
|
20
|
+
|
|
21
|
+
* teradataml will no longer be supported with SQLAlchemy < 2.0.
|
|
22
|
+
* teradataml no longer shows the warnings from Vantage by default.
|
|
23
|
+
* Users should set `display.suppress_vantage_runtime_warnings` to `False` to display warnings.
|
|
24
|
+
|
|
25
|
+
* ##### New Features/Functionality
|
|
26
|
+
* ##### teradataml: SQLE Engine Analytic Functions
|
|
27
|
+
* New Analytics Database Analytic Functions:
|
|
28
|
+
* `TFIDF()`
|
|
29
|
+
* `Pivoting()`
|
|
30
|
+
* `UnPivoting()`
|
|
31
|
+
* New Unbounded Array Framework(UAF) Functions:
|
|
32
|
+
* `AutoArima()`
|
|
33
|
+
* `DWT()`
|
|
34
|
+
* `DWT2D()`
|
|
35
|
+
* `FilterFactory1d()`
|
|
36
|
+
* `IDWT()`
|
|
37
|
+
* `IDWT2D()`
|
|
38
|
+
* `IQR()`
|
|
39
|
+
* `Matrix2Image()`
|
|
40
|
+
* `SAX()`
|
|
41
|
+
* `WindowDFFT()`
|
|
42
|
+
* ###### teradataml: Functions
|
|
43
|
+
* `udf()` - Creates a user defined function (UDF) and returns ColumnExpression.
|
|
44
|
+
* `set_session_param()` is added to set the database session parameters.
|
|
45
|
+
* `unset_session_param()` is added to unset database session parameters.
|
|
46
|
+
|
|
47
|
+
* ###### teradataml: DataFrame
|
|
48
|
+
* `materialize()` - Persists DataFrame into database for current session.
|
|
49
|
+
* `create_temp_view()` - Creates a temporary view for session on the DataFrame.
|
|
50
|
+
|
|
51
|
+
* ###### teradataml DataFrameColumn a.k.a. ColumnExpression
|
|
52
|
+
* _Date Time Functions_
|
|
53
|
+
* `DataFrameColumn.to_timestamp()` - Converts string or integer value to a TIMESTAMP data type or TIMESTAMP WITH TIME ZONE data type.
|
|
54
|
+
* `DataFrameColumn.extract()` - Extracts date component to a numeric value.
|
|
55
|
+
* `DataFrameColumn.to_interval()` - Converts a numeric value or string value into an INTERVAL_DAY_TO_SECOND or INTERVAL_YEAR_TO_MONTH value.
|
|
56
|
+
* _String Functions_
|
|
57
|
+
* `DataFrameColumn.parse_url()` - Extracts a part from a URL.
|
|
58
|
+
* _Arithmetic Functions_
|
|
59
|
+
* `DataFrameColumn.log` - Returns the logarithm value of the column with respect to 'base'.
|
|
60
|
+
|
|
61
|
+
* ##### teradataml: AutoML
|
|
62
|
+
* New methods added for `AutoML()`, `AutoRegressor()` and `AutoClassifier()`:
|
|
63
|
+
* `evaluate()` - Performs evaluation on the data using the best model or the model of users choice
|
|
64
|
+
from the leaderboard.
|
|
65
|
+
* `load()`: Loads the saved model from database.
|
|
66
|
+
* `deploy()`: Saves the trained model inside database.
|
|
67
|
+
* `remove_saved_model()`: Removes the saved model in database.
|
|
68
|
+
* `model_hyperparameters()`: Returns the hyperparameter of fitted or loaded models.
|
|
69
|
+
|
|
70
|
+
* ##### Updates
|
|
71
|
+
* ##### teradataml: AutoML
|
|
72
|
+
* `AutoML()`, `AutoRegressor()`
|
|
73
|
+
* New performance metrics added for task type regression i.e., "MAPE", "MPE", "ME", "EV", "MPD" and "MGD".
|
|
74
|
+
* `AutoML()`, `AutoRegressor()` and `AutoClassifier`
|
|
75
|
+
* New arguments added: `volatile`, `persist`.
|
|
76
|
+
* `predict()` - Data input is now mandatory for generating predictions. Default model
|
|
77
|
+
evaluation is now removed.
|
|
78
|
+
* `DataFrameColumn.cast()`: Accepts 2 new arguments `format` and `timezone`.
|
|
79
|
+
* `DataFrame.assign()`: Accepts ColumnExpressions returned by `udf()`.
|
|
80
|
+
|
|
81
|
+
* ##### teradataml: Options
|
|
82
|
+
* `set_config_params()`
|
|
83
|
+
* Following arguments will be deprecated in the future:
|
|
84
|
+
* `ues_url`
|
|
85
|
+
* `auth_token`
|
|
86
|
+
|
|
87
|
+
* ###### Database Utility
|
|
88
|
+
* `list_td_reserved_keywords()` - Accepts a list of strings as argument.
|
|
89
|
+
|
|
90
|
+
* ##### Updates to existing UAF Functions:
|
|
91
|
+
* `ACF()` - `round_results` parameter removed as it was used for internal testing.
|
|
92
|
+
* `BreuschGodfrey()` - Added default_value 0.05 for parameter `significance_level`.
|
|
93
|
+
* `GoldfeldQuandt()` -
|
|
94
|
+
* Removed parameters `weights` and `formula`.
|
|
95
|
+
Replaced parameter `orig_regr_paramcnt` with `const_term`.
|
|
96
|
+
Changed description for parameter `algorithm`. Please refer document for more details.
|
|
97
|
+
* Note: This will break backward compatibility.
|
|
98
|
+
* `HoltWintersForecaster()` - Default value of parameter `seasonal_periods` removed.
|
|
99
|
+
* `IDFFT2()` - Removed parameter `output_fmt_row_major` as it is used for internal testing.
|
|
100
|
+
* `Resample()` - Added parameter `output_fmt_index_style`.
|
|
101
|
+
|
|
102
|
+
* ##### Bug Fixes
|
|
103
|
+
* KNN `predict()` function can now predict on test data which does not contain target column.
|
|
104
|
+
* Metrics functions are supported on the Lake system.
|
|
105
|
+
* The following OpensourceML functions from different sklearn modules are fixed.
|
|
106
|
+
* `sklearn.ensemble`:
|
|
107
|
+
* ExtraTreesClassifier - `apply()`
|
|
108
|
+
* ExtraTreesRegressor - `apply()`
|
|
109
|
+
* RandomForestClassifier - `apply()`
|
|
110
|
+
* RandomForestRegressor - `apply()`
|
|
111
|
+
* `sklearn.impute`:
|
|
112
|
+
* SimpleImputer - `transform()`, `fit_transform()`, `inverse_transform()`
|
|
113
|
+
* MissingIndicator - `transform()`, `fit_transform()`
|
|
114
|
+
* `sklearn.kernel_approximations`:
|
|
115
|
+
* Nystroem - `transform()`, `fit_transform()`
|
|
116
|
+
* PolynomialCountSketch - `transform()`, `fit_transform()`
|
|
117
|
+
* RBFSampler - `transform()`, `fit_transform()`
|
|
118
|
+
* `sklearn.neighbours`:
|
|
119
|
+
* KNeighborsTransformer - `transform()`, `fit_transform()`
|
|
120
|
+
* RadiusNeighborsTransformer - `transform()`, `fit_transform()`
|
|
121
|
+
* `sklearn.preprocessing`:
|
|
122
|
+
* KernelCenterer - `transform()`
|
|
123
|
+
* OneHotEncoder - `transform()`, `inverse_transform()`
|
|
124
|
+
* OpensourceML returns teradataml objects for model attributes and functions instead of sklearn
|
|
125
|
+
objects so that the user can perform further operations like `score()`, `predict()` etc on top
|
|
126
|
+
of the returned objects.
|
|
127
|
+
* AutoML `predict()` function now generates correct ROC-AUC value for positive class.
|
|
128
|
+
* `deploy()` method of `Script` and `Apply` classes retries model deployment if there is any
|
|
129
|
+
intermittent network issues.
|
|
130
|
+
|
|
19
131
|
#### teradataml 20.00.00.01
|
|
20
132
|
* teradataml no longer supports Python versions less than 3.8.
|
|
21
133
|
|
teradataml/__init__.py
CHANGED
|
@@ -64,7 +64,10 @@ from teradataml.opensource import *
|
|
|
64
64
|
# Import AutoML
|
|
65
65
|
from teradataml.automl import AutoML, AutoRegressor, AutoClassifier
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
# Import global variable representing session_queryband.
|
|
68
|
+
from teradataml.telemetry_utils.queryband import session_queryband
|
|
69
|
+
# Configure app name and app version for teradataml querybands.
|
|
70
70
|
session_queryband.configure_queryband_parameters(app_name="TDML", app_version=__version__)
|
|
71
|
+
|
|
72
|
+
# Import functions.
|
|
73
|
+
from teradataml.dataframe.functions import *
|
teradataml/_version.py
CHANGED
teradataml/analytics/__init__.py
CHANGED
|
@@ -22,7 +22,7 @@ from .Transformations import Binning, Derive, OneHotEncoder, FillNa, LabelEncode
|
|
|
22
22
|
Retain, Sigmoid, ZScore
|
|
23
23
|
from teradataml.analytics.json_parser.utils import _get_json_data_from_tdml_repo, _process_paired_functions
|
|
24
24
|
from teradataml.analytics.analytic_function_executor import _SQLEFunctionExecutor, _TableOperatorExecutor,\
|
|
25
|
-
_UAFFunctionExecutor, _BYOMFunctionExecutor
|
|
25
|
+
_UAFFunctionExecutor, _BYOMFunctionExecutor, _StoredProcedureExecutor
|
|
26
26
|
from teradataml.common.constants import TeradataAnalyticFunctionTypes
|
|
27
27
|
|
|
28
28
|
|
|
@@ -76,6 +76,7 @@ def _get_executor_class_name(function_type):
|
|
|
76
76
|
TeradataAnalyticFunctionTypes.SQLE.value: _SQLEFunctionExecutor,
|
|
77
77
|
TeradataAnalyticFunctionTypes.TABLEOPERATOR.value: _TableOperatorExecutor,
|
|
78
78
|
TeradataAnalyticFunctionTypes.UAF.value: _UAFFunctionExecutor,
|
|
79
|
-
TeradataAnalyticFunctionTypes.BYOM.value: _BYOMFunctionExecutor
|
|
79
|
+
TeradataAnalyticFunctionTypes.BYOM.value: _BYOMFunctionExecutor,
|
|
80
|
+
TeradataAnalyticFunctionTypes.STORED_PROCEDURE.value: _StoredProcedureExecutor
|
|
80
81
|
}
|
|
81
82
|
return func_type_to_executor.get(function_type.upper(), _SQLEFunctionExecutor).__name__
|
|
@@ -14,11 +14,11 @@ File implements classes for following:
|
|
|
14
14
|
* _TableOperatorExecutor
|
|
15
15
|
* _BYOMFunctionExecutor
|
|
16
16
|
"""
|
|
17
|
-
|
|
17
|
+
from collections import OrderedDict
|
|
18
18
|
from teradataml.options.configure import configure
|
|
19
19
|
from teradataml.common.constants import TeradataConstants, TeradataAnalyticFunctionTypes
|
|
20
20
|
from teradataml.analytics.json_parser import PartitionKind
|
|
21
|
-
from teradataml.analytics.analytic_query_generator import AnalyticQueryGenerator, UAFQueryGenerator
|
|
21
|
+
from teradataml.analytics.analytic_query_generator import AnalyticQueryGenerator, UAFQueryGenerator, StoredProcedureQueryGenerator
|
|
22
22
|
from teradataml.analytics.json_parser.json_store import _JsonStore
|
|
23
23
|
from teradataml.analytics.utils import FuncSpecialCaseHandler
|
|
24
24
|
from teradataml.options.display import display
|
|
@@ -28,8 +28,11 @@ from teradataml.common.messages import Messages, MessageCodes
|
|
|
28
28
|
from teradataml.common.wrapper_utils import AnalyticsWrapperUtils
|
|
29
29
|
from teradataml.common.utils import UtilFuncs
|
|
30
30
|
from teradataml.context.context import _get_context_temp_databasename
|
|
31
|
+
from teradataml.dataframe.dataframe import in_schema
|
|
32
|
+
from teradataml.dbutils.dbutils import _create_table, db_drop_table
|
|
33
|
+
from teradatasqlalchemy.types import *
|
|
31
34
|
from teradataml.table_operators.table_operator_query_generator import TableOperatorQueryGenerator
|
|
32
|
-
from
|
|
35
|
+
from teradataml.telemetry_utils.queryband import collect_queryband
|
|
33
36
|
from teradataml.utils.dtypes import _ListOf
|
|
34
37
|
from teradataml.utils.validators import _Validators
|
|
35
38
|
|
|
@@ -155,7 +158,7 @@ class _AnlyticFunctionExecutor:
|
|
|
155
158
|
_Validators._validate_function_arguments([argument_info])
|
|
156
159
|
|
|
157
160
|
@collect_queryband(attr="func_name")
|
|
158
|
-
def _execute_query(self, persist=False, volatile=False):
|
|
161
|
+
def _execute_query(self, persist=False, volatile=False, display_table_name=True):
|
|
159
162
|
"""
|
|
160
163
|
DESCRIPTION:
|
|
161
164
|
Function to execute query on Vantage.
|
|
@@ -172,6 +175,13 @@ class _AnlyticFunctionExecutor:
|
|
|
172
175
|
Specifies whether to create a volatile table or not.
|
|
173
176
|
Default Value: False
|
|
174
177
|
Type: bool
|
|
178
|
+
|
|
179
|
+
display_table_name:
|
|
180
|
+
Optional Argument.
|
|
181
|
+
Specifies whether to display the table names or not when
|
|
182
|
+
persist is set to True.
|
|
183
|
+
Default Value: True
|
|
184
|
+
Type: bool
|
|
175
185
|
|
|
176
186
|
RETURNS:
|
|
177
187
|
None
|
|
@@ -206,7 +216,8 @@ class _AnlyticFunctionExecutor:
|
|
|
206
216
|
else:
|
|
207
217
|
self._function_output_table_map["result"] = sqlmr_stdout_temp_tablename
|
|
208
218
|
|
|
209
|
-
if
|
|
219
|
+
# Print the table/view names if display_table_name is set to True.
|
|
220
|
+
if persist and display_table_name:
|
|
210
221
|
# SQL is executed. So, print the table/view names.
|
|
211
222
|
for output_attribute, table_name in self._function_output_table_map.items():
|
|
212
223
|
print("{} data stored in table '{}'".format(output_attribute, table_name))
|
|
@@ -678,6 +689,7 @@ class _AnlyticFunctionExecutor:
|
|
|
678
689
|
start_time = time.time()
|
|
679
690
|
persist = kwargs.get("persist", False)
|
|
680
691
|
volatile = kwargs.get("volatile", False)
|
|
692
|
+
display_table_name = kwargs.get("display_table_name", True)
|
|
681
693
|
|
|
682
694
|
# Validate local_order_column argument type and values.
|
|
683
695
|
arg_info_matrix = [["persist", persist, True, bool], ["volatile", volatile, True, bool]]
|
|
@@ -716,13 +728,27 @@ class _AnlyticFunctionExecutor:
|
|
|
716
728
|
if not skip_other_arg_processing:
|
|
717
729
|
self._process_other_argument(**kwargs)
|
|
718
730
|
|
|
719
|
-
|
|
731
|
+
# When Analytic function is executed it stores the result in _function_output_table_map['result'].
|
|
732
|
+
# If we want to skip the query execution of the function then we need to pass result table in '_result_data'.
|
|
733
|
+
|
|
734
|
+
# Execute the query only if the '_result_data' is not passed as an argument in kwargs.
|
|
735
|
+
# Otherwise, store the result table in _function_output_table_map.
|
|
736
|
+
if kwargs.get("_result_data", None) is None:
|
|
737
|
+
self._generate_query(volatile=volatile)
|
|
720
738
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
739
|
+
# Print SQL-MR query if requested to do so.
|
|
740
|
+
if display.print_sqlmr_query:
|
|
741
|
+
print(self.sqlmr_query)
|
|
724
742
|
|
|
725
|
-
|
|
743
|
+
self._execute_query(persist, volatile, display_table_name)
|
|
744
|
+
else:
|
|
745
|
+
# This is useful when we already have the result table and
|
|
746
|
+
# need to pass function result as an object to another function
|
|
747
|
+
# without executing the function again.
|
|
748
|
+
|
|
749
|
+
# Store the result table in map.
|
|
750
|
+
self._function_output_table_map["result"] = kwargs.pop("_result_data")
|
|
751
|
+
self._dyn_cls_data_members['result'] = self._dyn_cls_data_members.pop('_result_data')
|
|
726
752
|
|
|
727
753
|
if not skip_func_output_processing:
|
|
728
754
|
self._process_function_output(**kwargs)
|
|
@@ -1489,7 +1515,7 @@ class _TableOperatorExecutor(_SQLEFunctionExecutor):
|
|
|
1489
1515
|
|
|
1490
1516
|
class _UAFFunctionExecutor(_SQLEFunctionExecutor):
|
|
1491
1517
|
""" Class to hold the attributes and provide methods to enable execution for UAF Functions. """
|
|
1492
|
-
def __init__(self, func_name):
|
|
1518
|
+
def __init__(self, func_name, func_type = TeradataAnalyticFunctionTypes.UAF.value):
|
|
1493
1519
|
"""
|
|
1494
1520
|
DESCRIPTION:
|
|
1495
1521
|
Constructor for the class.
|
|
@@ -1506,7 +1532,7 @@ class _UAFFunctionExecutor(_SQLEFunctionExecutor):
|
|
|
1506
1532
|
EXAMPLES:
|
|
1507
1533
|
_UAFFunctionExecutor("ArimaEstimate")
|
|
1508
1534
|
"""
|
|
1509
|
-
super().__init__(func_name,
|
|
1535
|
+
super().__init__(func_name, func_type)
|
|
1510
1536
|
self._func_other_args = {}
|
|
1511
1537
|
self._func_input_fmt_arguments = {}
|
|
1512
1538
|
self._func_output_fmt_arguments = {}
|
|
@@ -1534,6 +1560,7 @@ class _UAFFunctionExecutor(_SQLEFunctionExecutor):
|
|
|
1534
1560
|
EXAMPLES:
|
|
1535
1561
|
self._generate_query()
|
|
1536
1562
|
"""
|
|
1563
|
+
|
|
1537
1564
|
query_generator = UAFQueryGenerator(function_name=self._metadata.sql_function_name,
|
|
1538
1565
|
func_input_args=self._func_input_args,
|
|
1539
1566
|
func_input_filter_expr_args=self._func_input_filter_expr_args,
|
|
@@ -1936,7 +1963,7 @@ class _UAFFunctionExecutor(_SQLEFunctionExecutor):
|
|
|
1936
1963
|
**kwargs))
|
|
1937
1964
|
|
|
1938
1965
|
@collect_queryband(attr="func_name")
|
|
1939
|
-
def _execute_query(self, persist=False, volatile=None):
|
|
1966
|
+
def _execute_query(self, persist=False, volatile=None, display_table_name=True):
|
|
1940
1967
|
"""
|
|
1941
1968
|
DESCRIPTION:
|
|
1942
1969
|
Function to execute query on Vantage.
|
|
@@ -1947,6 +1974,13 @@ class _UAFFunctionExecutor(_SQLEFunctionExecutor):
|
|
|
1947
1974
|
Specifies whether to persist a table or not.
|
|
1948
1975
|
Default Value: False
|
|
1949
1976
|
Type: bool
|
|
1977
|
+
|
|
1978
|
+
display_table_name:
|
|
1979
|
+
Optional Argument.
|
|
1980
|
+
Specifies whether to display the table names or not when
|
|
1981
|
+
persist is set to True.
|
|
1982
|
+
Default Value: True
|
|
1983
|
+
Type: bool
|
|
1950
1984
|
|
|
1951
1985
|
RETURNS:
|
|
1952
1986
|
None
|
|
@@ -1960,9 +1994,10 @@ class _UAFFunctionExecutor(_SQLEFunctionExecutor):
|
|
|
1960
1994
|
try:
|
|
1961
1995
|
# Execute already generated query.
|
|
1962
1996
|
UtilFuncs._execute_query(query=self.sqlmr_query)
|
|
1963
|
-
|
|
1964
|
-
if
|
|
1965
|
-
|
|
1997
|
+
|
|
1998
|
+
# Print the table/view names if display_table_name is set to True.
|
|
1999
|
+
if persist and display_table_name:
|
|
2000
|
+
# SQL is executed. So, print the table/view names.
|
|
1966
2001
|
for output_attribute, table_name in self._function_output_table_map.items():
|
|
1967
2002
|
print("{} data stored in table '{}'".format(output_attribute, table_name))
|
|
1968
2003
|
|
|
@@ -2038,3 +2073,176 @@ class _BYOMFunctionExecutor(_SQLEFunctionExecutor):
|
|
|
2038
2073
|
|
|
2039
2074
|
# Invoke call to SQL-MR generation.
|
|
2040
2075
|
self.sqlmr_query = self.__aqg_obj._gen_sqlmr_select_stmt_sql()
|
|
2076
|
+
|
|
2077
|
+
class _StoredProcedureExecutor(_UAFFunctionExecutor):
|
|
2078
|
+
"""
|
|
2079
|
+
Class to hold the attributes and provide methods to enable execution for Stored Procedures.
|
|
2080
|
+
As the stored procedure JSONs are written like UAF Functions we will use
|
|
2081
|
+
_UAFFunctionExecutor as the base class.
|
|
2082
|
+
"""
|
|
2083
|
+
def __init__(self, func_name):
|
|
2084
|
+
"""
|
|
2085
|
+
DESCRIPTION:
|
|
2086
|
+
Constructor for the class.
|
|
2087
|
+
|
|
2088
|
+
PARAMETERS:
|
|
2089
|
+
func_name:
|
|
2090
|
+
Required Argument.
|
|
2091
|
+
Specifies the name of the analytic function, which is exposed to the user.
|
|
2092
|
+
Types: str
|
|
2093
|
+
|
|
2094
|
+
RAISES:
|
|
2095
|
+
None
|
|
2096
|
+
|
|
2097
|
+
EXAMPLES:
|
|
2098
|
+
_StoredProcedureExecutor("FilterFactory1d")
|
|
2099
|
+
"""
|
|
2100
|
+
super().__init__(func_name, TeradataAnalyticFunctionTypes.STORED_PROCEDURE.value)
|
|
2101
|
+
self._func_other_args = OrderedDict()
|
|
2102
|
+
|
|
2103
|
+
def _generate_query(self, volatile=False):
|
|
2104
|
+
"""
|
|
2105
|
+
DESCRIPTION:
|
|
2106
|
+
Function to generate the SQL query for Stored Procedures.
|
|
2107
|
+
|
|
2108
|
+
PARAMETERS:
|
|
2109
|
+
volatile:
|
|
2110
|
+
Optional Argument.
|
|
2111
|
+
Specifies whether to create a volatile table or not.
|
|
2112
|
+
Default Value: False
|
|
2113
|
+
Type: bool
|
|
2114
|
+
|
|
2115
|
+
RETURNS:
|
|
2116
|
+
None.
|
|
2117
|
+
|
|
2118
|
+
RAISES:
|
|
2119
|
+
None.
|
|
2120
|
+
|
|
2121
|
+
EXAMPLES:
|
|
2122
|
+
self._generate_query()
|
|
2123
|
+
"""
|
|
2124
|
+
# update the db_name.
|
|
2125
|
+
db_name = None
|
|
2126
|
+
if configure.stored_procedure_install_location is not None:
|
|
2127
|
+
db_name = configure.stored_procedure_install_location
|
|
2128
|
+
|
|
2129
|
+
self.__aqg_obj = StoredProcedureQueryGenerator(function_name=self._metadata.sql_function_name,
|
|
2130
|
+
func_other_args_values=self._func_other_args,
|
|
2131
|
+
db_name=db_name)
|
|
2132
|
+
|
|
2133
|
+
# Invoke call to SQL-MR generation.
|
|
2134
|
+
self.sqlmr_query = self.__aqg_obj._gen_call_stmt()
|
|
2135
|
+
|
|
2136
|
+
def _process_other_argument(self, **kwargs):
|
|
2137
|
+
"""
|
|
2138
|
+
DESCRIPTION:
|
|
2139
|
+
Internal function to process the arguments.
|
|
2140
|
+
1. The function does the following:
|
|
2141
|
+
* Checks the required arguments are passed or not.
|
|
2142
|
+
* Checks the type of the arguments are expected or not.
|
|
2143
|
+
* Checks for permitted values.
|
|
2144
|
+
* Checks for empty string.
|
|
2145
|
+
* If validations run fine,
|
|
2146
|
+
then returns a dict with the SQL name of the argument as key
|
|
2147
|
+
and user provided value as the value {arg_sql_name : value}
|
|
2148
|
+
|
|
2149
|
+
PARAMETERS:
|
|
2150
|
+
|
|
2151
|
+
kwargs:
|
|
2152
|
+
Specifies the keyword arguments passed to a function.
|
|
2153
|
+
|
|
2154
|
+
RETURNS:
|
|
2155
|
+
None.
|
|
2156
|
+
|
|
2157
|
+
RAISES:
|
|
2158
|
+
ValueError OR TypeError OR TeradataMlException.
|
|
2159
|
+
|
|
2160
|
+
EXAMPLES:
|
|
2161
|
+
self._process_other_arguments(argument, arg1="string", arg2="db", arg3=2)
|
|
2162
|
+
|
|
2163
|
+
"""
|
|
2164
|
+
## As the function 'FilterFactory1d' requries the output table to be created before the stored procedure call,
|
|
2165
|
+
## creating it and adding them as parameters as stored procedure requires them
|
|
2166
|
+
|
|
2167
|
+
if self.func_name == "FilterFactory1d":
|
|
2168
|
+
columns_to_create = {"ID": INTEGER,
|
|
2169
|
+
"row_i": INTEGER,
|
|
2170
|
+
"FilterMag": FLOAT,
|
|
2171
|
+
"description": VARCHAR}
|
|
2172
|
+
|
|
2173
|
+
schema_name = UtilFuncs._extract_db_name(self._func_output_args)
|
|
2174
|
+
table_name = UtilFuncs._extract_table_name(self._func_output_args)
|
|
2175
|
+
|
|
2176
|
+
_create_table(table_name=table_name,
|
|
2177
|
+
columns=columns_to_create,
|
|
2178
|
+
schema_name=schema_name,
|
|
2179
|
+
primary_index=["ID", "row_i"])
|
|
2180
|
+
self._func_other_args['database_name'] = UtilFuncs._teradata_quote_arg(schema_name, "\'", False)
|
|
2181
|
+
self._func_other_args['table_name'] = UtilFuncs._teradata_quote_arg(table_name, "\'", False)
|
|
2182
|
+
|
|
2183
|
+
for argument in self._metadata.arguments:
|
|
2184
|
+
sql_name = argument.get_name()
|
|
2185
|
+
lang_name = argument.get_lang_name()
|
|
2186
|
+
arg_value = kwargs.get(lang_name)
|
|
2187
|
+
# Set the "argument".
|
|
2188
|
+
self._spl_func_obj.set_arg_name(argument)
|
|
2189
|
+
# Let's get spl handler if function requires.
|
|
2190
|
+
special_case_handler = self._spl_func_obj._get_handle()
|
|
2191
|
+
|
|
2192
|
+
self._validate_analytic_function_argument(lang_name, arg_value, argument)
|
|
2193
|
+
# As stored procedures require the argument to passed in positional order and
|
|
2194
|
+
# NULL is required for arguments which are not present
|
|
2195
|
+
if arg_value is None:
|
|
2196
|
+
self._func_other_args[sql_name] = 'NULL'
|
|
2197
|
+
|
|
2198
|
+
# If argument is not None add the sql_name and arg_value to the dict.
|
|
2199
|
+
else:
|
|
2200
|
+
# If get_match_length_of_arguments is True, check if the arg_value is
|
|
2201
|
+
# a list and of the required size.
|
|
2202
|
+
if argument.get_match_length_of_arguments():
|
|
2203
|
+
required_length = argument.get_required_length()
|
|
2204
|
+
if (isinstance(arg_value, list) and len(arg_value) != required_length) or\
|
|
2205
|
+
(not isinstance(arg_value, list)):
|
|
2206
|
+
raise TeradataMlException(Messages.get_message(
|
|
2207
|
+
MessageCodes.INVALID_LIST_LENGTH).format(lang_name,
|
|
2208
|
+
required_length),
|
|
2209
|
+
MessageCodes.INVALID_LIST_LENGTH)
|
|
2210
|
+
|
|
2211
|
+
# Perform the checks which are specific to argument(_AnlyFuncArgument) type.
|
|
2212
|
+
# Check lower bound and upper bound for numeric arguments.
|
|
2213
|
+
if isinstance(arg_value, (int, float)):
|
|
2214
|
+
lower_bound_inclusive = argument.get_lower_bound_type() == "INCLUSIVE"
|
|
2215
|
+
upper_bound_inclusive = argument.get_upper_bound_type() == "INCLUSIVE"
|
|
2216
|
+
_Validators._validate_argument_range(arg_value,
|
|
2217
|
+
lang_name,
|
|
2218
|
+
lbound=argument.get_lower_bound(),
|
|
2219
|
+
ubound=argument.get_upper_bound(),
|
|
2220
|
+
lbound_inclusive=lower_bound_inclusive,
|
|
2221
|
+
ubound_inclusive=upper_bound_inclusive)
|
|
2222
|
+
|
|
2223
|
+
# If the argument is a bool type, convert it to integer since SQL do
|
|
2224
|
+
# not know boolean processing.
|
|
2225
|
+
if bool in argument.get_python_type() and isinstance(arg_value, bool):
|
|
2226
|
+
arg_value = int(arg_value)
|
|
2227
|
+
|
|
2228
|
+
# Handle special cases for "arg_values" based on handling method.
|
|
2229
|
+
arg_value = special_case_handler(arg_value) if special_case_handler is not None else arg_value
|
|
2230
|
+
self._func_other_args[sql_name] = arg_value
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
def _process_function_output(self, **kwargs):
|
|
2234
|
+
"""
|
|
2235
|
+
DESCRIPTION:
|
|
2236
|
+
Internal function to process the function output.
|
|
2237
|
+
"""
|
|
2238
|
+
for lang_name, table_name in self._function_output_table_map.items():
|
|
2239
|
+
out_table_name = UtilFuncs._extract_table_name(table_name)
|
|
2240
|
+
out_db_name = UtilFuncs._extract_db_name(table_name)
|
|
2241
|
+
df = self._awu._create_data_set_object(
|
|
2242
|
+
df_input=out_table_name, database_name=out_db_name, source_type="table")
|
|
2243
|
+
self._dyn_cls_data_members[lang_name] = df
|
|
2244
|
+
# Condition make sure that the first element always be result or output in _mlresults.
|
|
2245
|
+
if lang_name in ["output", "result"]:
|
|
2246
|
+
self._mlresults.insert(0, df)
|
|
2247
|
+
else:
|
|
2248
|
+
self._mlresults.append(df)
|
|
@@ -956,3 +956,95 @@ class UAFQueryGenerator:
|
|
|
956
956
|
sql,
|
|
957
957
|
on_preserve_clause)
|
|
958
958
|
return sql
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
class StoredProcedureQueryGenerator:
|
|
962
|
+
"""
|
|
963
|
+
This class creates a SQL-MR object, which can be used to generate
|
|
964
|
+
Stored Procedure Query Generator in FFE syntax for Teradata.
|
|
965
|
+
"""
|
|
966
|
+
|
|
967
|
+
def __init__(self, function_name,
|
|
968
|
+
func_other_args_values,
|
|
969
|
+
db_name="SYSLIB"):
|
|
970
|
+
"""
|
|
971
|
+
StoredProcedureQueryGenerator constructor, to create query for Stored Procedures.
|
|
972
|
+
|
|
973
|
+
PARAMETERS:
|
|
974
|
+
function_name:
|
|
975
|
+
Required Argument.
|
|
976
|
+
Specifies the name of the function.
|
|
977
|
+
|
|
978
|
+
func_other_args_values:
|
|
979
|
+
Required Argument.
|
|
980
|
+
Specifies a dict in the format: {'sql_name':'value'}.
|
|
981
|
+
|
|
982
|
+
db_name:
|
|
983
|
+
Optional Argument.
|
|
984
|
+
Specifies the install location of Stored Procedures.
|
|
985
|
+
Default Value: SYSLIB
|
|
986
|
+
|
|
987
|
+
RETURNS:
|
|
988
|
+
StoredProcedureQueryGenerator object.
|
|
989
|
+
|
|
990
|
+
EXAMPLES:
|
|
991
|
+
aqg_obj = StoredProcedureQueryGenerator(function_name, other_sql_args, db_name="mldb")
|
|
992
|
+
"""
|
|
993
|
+
self.__function_name = function_name
|
|
994
|
+
|
|
995
|
+
# If the db_name is provided, append it to the stored
|
|
996
|
+
# procedure function name.
|
|
997
|
+
self.__db_name = db_name
|
|
998
|
+
if self.__db_name:
|
|
999
|
+
self.__function_name = "\"{}\".{}".format(self.__db_name,
|
|
1000
|
+
self.__function_name)
|
|
1001
|
+
|
|
1002
|
+
self.__func_other_args_values = func_other_args_values
|
|
1003
|
+
self.__CALL_STMT_FMT = "Call {}({})"
|
|
1004
|
+
self.__QUERY_SIZE = self.__get_string_size(self.__CALL_STMT_FMT) + 20
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
def __generate_sqlmr_func_other_arg_sql(self):
|
|
1008
|
+
"""
|
|
1009
|
+
Private function to generate a SQL clause for other function arguments.
|
|
1010
|
+
For Example, two paramater values of {a:False, b:"BINOMIAL"} are
|
|
1011
|
+
appened like: False, "BINOMIAL", in the same order.
|
|
1012
|
+
|
|
1013
|
+
RETURNS:
|
|
1014
|
+
SQL string for other function arguments, as shown in example here.
|
|
1015
|
+
|
|
1016
|
+
EXAMPLES:
|
|
1017
|
+
__func_other_args_values = {"a":False, "b":"BINOMIAL"}
|
|
1018
|
+
other_arg_sql = self.__generate_sqlmr_func_other_arg_sql()
|
|
1019
|
+
# Output is as shown in example in description.
|
|
1020
|
+
|
|
1021
|
+
"""
|
|
1022
|
+
args_sql_str = ','.join(map(str, self.__func_other_args_values.values()))
|
|
1023
|
+
self.__QUERY_SIZE = self.__QUERY_SIZE + self.__get_string_size(args_sql_str)
|
|
1024
|
+
return args_sql_str
|
|
1025
|
+
|
|
1026
|
+
def _gen_call_stmt(self):
|
|
1027
|
+
"""
|
|
1028
|
+
Protected function to generate complete query.
|
|
1029
|
+
For Example,
|
|
1030
|
+
CALL SYSLIB.TD_FILTERFACTORY1D ('test', 'filters', 33, 'lowpass', 'blackman', NULL, 20.0, 40.0, NULL, 200, NULL);
|
|
1031
|
+
|
|
1032
|
+
PARAMETERS:
|
|
1033
|
+
|
|
1034
|
+
RETURNS:
|
|
1035
|
+
A SQL-MR/Analytical query, as shown in example here.
|
|
1036
|
+
|
|
1037
|
+
RAISES:
|
|
1038
|
+
|
|
1039
|
+
EXAMPLES:
|
|
1040
|
+
aqg_obj = StoredProcedureQueryGenerator(function_name=self._metadata.sql_function_name,
|
|
1041
|
+
func_other_args_values=self._func_other_args,
|
|
1042
|
+
db_name=db_name)
|
|
1043
|
+
anly_query = aqg_obj._gen_sqlmr_select_stmt_sql()
|
|
1044
|
+
# Output is as shown in example in description.
|
|
1045
|
+
|
|
1046
|
+
"""
|
|
1047
|
+
return self.__CALL_STMT_FMT.format(self.__function_name, self.__generate_sqlmr_func_other_arg_sql())
|
|
1048
|
+
|
|
1049
|
+
def __get_string_size(self, string):
|
|
1050
|
+
return len(string.encode("utf8"))
|
|
@@ -2,7 +2,7 @@ from teradataml.analytics.byom.H2OPredict import H2OPredict
|
|
|
2
2
|
from teradataml.analytics.byom.PMMLPredict import PMMLPredict
|
|
3
3
|
|
|
4
4
|
from teradataml.analytics.meta_class import _AnalyticFunction
|
|
5
|
-
from teradataml.analytics.meta_class import _common_init
|
|
5
|
+
from teradataml.analytics.meta_class import _common_init, _common_dir
|
|
6
6
|
|
|
7
7
|
_byom_functions = ['H2OPredict', 'PMMLPredict', 'ONNXPredict', 'DataikuPredict', 'DataRobotPredict']
|
|
8
8
|
|
|
@@ -12,4 +12,5 @@ for func in _byom_functions:
|
|
|
12
12
|
**kwargs: _common_init(self,
|
|
13
13
|
'byom',
|
|
14
14
|
**kwargs),
|
|
15
|
-
"__doc__": _AnalyticFunction.__doc__
|
|
15
|
+
"__doc__": _AnalyticFunction.__doc__,
|
|
16
|
+
"__dir__": _common_dir})
|
|
@@ -111,6 +111,7 @@ class _AnlyFuncMetadata:
|
|
|
111
111
|
TeradataAnalyticFunctionTypes.TABLEOPERATOR.value,
|
|
112
112
|
TeradataAnalyticFunctionTypes.UAF.value,
|
|
113
113
|
TeradataAnalyticFunctionTypes.BYOM.value,
|
|
114
|
+
TeradataAnalyticFunctionTypes.STORED_PROCEDURE.value,
|
|
114
115
|
None]])
|
|
115
116
|
arg_info_matrix.append(["json_file", json_file, False, str, True])
|
|
116
117
|
_Validators._validate_function_arguments(arg_info_matrix)
|
|
@@ -172,7 +172,7 @@ def __get_json_files_directory():
|
|
|
172
172
|
# Check if current function type is allowed on connected Vantage version or not.
|
|
173
173
|
if func_info.value["func_type"] in func_type_json_version.keys():
|
|
174
174
|
yield [UtilFuncs._get_data_directory(dir_name="jsons", func_type=func_info,
|
|
175
|
-
|
|
175
|
+
version=func_type_json_version[func_info.value["func_type"]]),
|
|
176
176
|
func_info.name]
|
|
177
177
|
else:
|
|
178
178
|
yield [UtilFuncs._get_data_directory(dir_name="jsons", func_type=func_info), func_info.name]
|
|
@@ -237,7 +237,7 @@ def _process_paired_functions():
|
|
|
237
237
|
"""
|
|
238
238
|
|
|
239
239
|
json_path = os.path.join(UtilFuncs._get_data_directory(), "jsons", "paired_functions.json")
|
|
240
|
-
with open(json_path) as fp:
|
|
240
|
+
with open(json_path, encoding="utf8") as fp:
|
|
241
241
|
_json = json.load(fp)
|
|
242
242
|
|
|
243
243
|
_available_functions, _ = _JsonStore._get_function_list()
|
|
@@ -556,8 +556,10 @@ class _KNNPredict:
|
|
|
556
556
|
"train_data": self.train_data,
|
|
557
557
|
"input_columns": self.input_columns,
|
|
558
558
|
"response_column": kwargs.get("response_column", self.response_column),
|
|
559
|
-
|
|
560
|
-
|
|
559
|
+
# Retrieve the accumulate value from kwargs if available.
|
|
560
|
+
# otherwise, no accumulation will occur.
|
|
561
|
+
"accumulate": kwargs.get("accumulate")
|
|
562
|
+
}
|
|
561
563
|
|
|
562
564
|
# KNN works in a different way. predict calls the same function with test data along with
|
|
563
565
|
# the arguments passed to the actual function. The above parameters are required
|