teradataml 17.20.0.7__py3-none-any.whl → 20.0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (1285) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/LICENSE.pdf +0 -0
  3. teradataml/README.md +1864 -1640
  4. teradataml/__init__.py +70 -60
  5. teradataml/_version.py +11 -11
  6. teradataml/analytics/Transformations.py +2995 -2995
  7. teradataml/analytics/__init__.py +81 -83
  8. teradataml/analytics/analytic_function_executor.py +2013 -2010
  9. teradataml/analytics/analytic_query_generator.py +958 -958
  10. teradataml/analytics/byom/H2OPredict.py +514 -514
  11. teradataml/analytics/byom/PMMLPredict.py +437 -437
  12. teradataml/analytics/byom/__init__.py +14 -14
  13. teradataml/analytics/json_parser/__init__.py +130 -130
  14. teradataml/analytics/json_parser/analytic_functions_argument.py +1707 -1707
  15. teradataml/analytics/json_parser/json_store.py +191 -191
  16. teradataml/analytics/json_parser/metadata.py +1637 -1637
  17. teradataml/analytics/json_parser/utils.py +804 -803
  18. teradataml/analytics/meta_class.py +196 -196
  19. teradataml/analytics/sqle/DecisionTreePredict.py +455 -470
  20. teradataml/analytics/sqle/NaiveBayesPredict.py +419 -428
  21. teradataml/analytics/sqle/__init__.py +97 -110
  22. teradataml/analytics/sqle/json/decisiontreepredict_sqle.json +78 -78
  23. teradataml/analytics/sqle/json/naivebayespredict_sqle.json +62 -62
  24. teradataml/analytics/table_operator/__init__.py +10 -10
  25. teradataml/analytics/uaf/__init__.py +63 -63
  26. teradataml/analytics/utils.py +693 -692
  27. teradataml/analytics/valib.py +1603 -1600
  28. teradataml/automl/__init__.py +1628 -0
  29. teradataml/automl/custom_json_utils.py +1270 -0
  30. teradataml/automl/data_preparation.py +993 -0
  31. teradataml/automl/data_transformation.py +727 -0
  32. teradataml/automl/feature_engineering.py +1648 -0
  33. teradataml/automl/feature_exploration.py +547 -0
  34. teradataml/automl/model_evaluation.py +163 -0
  35. teradataml/automl/model_training.py +887 -0
  36. teradataml/catalog/__init__.py +1 -3
  37. teradataml/catalog/byom.py +1759 -1716
  38. teradataml/catalog/function_argument_mapper.py +859 -861
  39. teradataml/catalog/model_cataloging_utils.py +491 -1510
  40. teradataml/clients/pkce_client.py +481 -481
  41. teradataml/common/aed_utils.py +6 -2
  42. teradataml/common/bulk_exposed_utils.py +111 -111
  43. teradataml/common/constants.py +1433 -1441
  44. teradataml/common/deprecations.py +160 -0
  45. teradataml/common/exceptions.py +73 -73
  46. teradataml/common/formula.py +742 -742
  47. teradataml/common/garbagecollector.py +592 -635
  48. teradataml/common/messagecodes.py +422 -431
  49. teradataml/common/messages.py +227 -231
  50. teradataml/common/sqlbundle.py +693 -693
  51. teradataml/common/td_coltype_code_to_tdtype.py +48 -48
  52. teradataml/common/utils.py +2418 -2500
  53. teradataml/common/warnings.py +25 -25
  54. teradataml/common/wrapper_utils.py +1 -110
  55. teradataml/config/dummy_file1.cfg +4 -4
  56. teradataml/config/dummy_file2.cfg +2 -2
  57. teradataml/config/sqlengine_alias_definitions_v1.0 +13 -13
  58. teradataml/config/sqlengine_alias_definitions_v1.1 +19 -19
  59. teradataml/config/sqlengine_alias_definitions_v1.3 +18 -18
  60. teradataml/context/aed_context.py +217 -217
  61. teradataml/context/context.py +1071 -999
  62. teradataml/data/A_loan.csv +19 -19
  63. teradataml/data/BINARY_REALS_LEFT.csv +11 -11
  64. teradataml/data/BINARY_REALS_RIGHT.csv +11 -11
  65. teradataml/data/B_loan.csv +49 -49
  66. teradataml/data/BuoyData2.csv +17 -17
  67. teradataml/data/CONVOLVE2_COMPLEX_LEFT.csv +5 -5
  68. teradataml/data/CONVOLVE2_COMPLEX_RIGHT.csv +5 -5
  69. teradataml/data/Convolve2RealsLeft.csv +5 -5
  70. teradataml/data/Convolve2RealsRight.csv +5 -5
  71. teradataml/data/Convolve2ValidLeft.csv +11 -11
  72. teradataml/data/Convolve2ValidRight.csv +11 -11
  73. teradataml/data/DFFTConv_Real_8_8.csv +65 -65
  74. teradataml/data/Orders1_12mf.csv +24 -24
  75. teradataml/data/Pi_loan.csv +7 -7
  76. teradataml/data/SMOOTHED_DATA.csv +7 -7
  77. teradataml/data/TestDFFT8.csv +9 -9
  78. teradataml/data/TestRiver.csv +109 -109
  79. teradataml/data/Traindata.csv +28 -28
  80. teradataml/data/acf.csv +17 -17
  81. teradataml/data/adaboost_example.json +34 -34
  82. teradataml/data/adaboostpredict_example.json +24 -24
  83. teradataml/data/additional_table.csv +10 -10
  84. teradataml/data/admissions_test.csv +21 -21
  85. teradataml/data/admissions_train.csv +41 -41
  86. teradataml/data/admissions_train_nulls.csv +41 -41
  87. teradataml/data/ageandheight.csv +13 -13
  88. teradataml/data/ageandpressure.csv +31 -31
  89. teradataml/data/antiselect_example.json +36 -36
  90. teradataml/data/antiselect_input.csv +8 -8
  91. teradataml/data/antiselect_input_mixed_case.csv +8 -8
  92. teradataml/data/applicant_external.csv +6 -6
  93. teradataml/data/applicant_reference.csv +6 -6
  94. teradataml/data/arima_example.json +9 -9
  95. teradataml/data/assortedtext_input.csv +8 -8
  96. teradataml/data/attribution_example.json +33 -33
  97. teradataml/data/attribution_sample_table.csv +27 -27
  98. teradataml/data/attribution_sample_table1.csv +6 -6
  99. teradataml/data/attribution_sample_table2.csv +11 -11
  100. teradataml/data/bank_churn.csv +10001 -0
  101. teradataml/data/bank_web_clicks1.csv +42 -42
  102. teradataml/data/bank_web_clicks2.csv +91 -91
  103. teradataml/data/bank_web_url.csv +85 -85
  104. teradataml/data/barrier.csv +2 -2
  105. teradataml/data/barrier_new.csv +3 -3
  106. teradataml/data/betweenness_example.json +13 -13
  107. teradataml/data/bin_breaks.csv +8 -8
  108. teradataml/data/bin_fit_ip.csv +3 -3
  109. teradataml/data/binary_complex_left.csv +11 -11
  110. teradataml/data/binary_complex_right.csv +11 -11
  111. teradataml/data/binary_matrix_complex_left.csv +21 -21
  112. teradataml/data/binary_matrix_complex_right.csv +21 -21
  113. teradataml/data/binary_matrix_real_left.csv +21 -21
  114. teradataml/data/binary_matrix_real_right.csv +21 -21
  115. teradataml/data/blood2ageandweight.csv +26 -26
  116. teradataml/data/bmi.csv +501 -0
  117. teradataml/data/boston.csv +507 -507
  118. teradataml/data/buoydata_mix.csv +11 -11
  119. teradataml/data/burst_data.csv +5 -5
  120. teradataml/data/burst_example.json +20 -20
  121. teradataml/data/byom_example.json +17 -17
  122. teradataml/data/bytes_table.csv +3 -3
  123. teradataml/data/cal_housing_ex_raw.csv +70 -70
  124. teradataml/data/callers.csv +7 -7
  125. teradataml/data/calls.csv +10 -10
  126. teradataml/data/cars_hist.csv +33 -33
  127. teradataml/data/cat_table.csv +24 -24
  128. teradataml/data/ccm_example.json +31 -31
  129. teradataml/data/ccm_input.csv +91 -91
  130. teradataml/data/ccm_input2.csv +13 -13
  131. teradataml/data/ccmexample.csv +101 -101
  132. teradataml/data/ccmprepare_example.json +8 -8
  133. teradataml/data/ccmprepare_input.csv +91 -91
  134. teradataml/data/cfilter_example.json +12 -12
  135. teradataml/data/changepointdetection_example.json +18 -18
  136. teradataml/data/changepointdetectionrt_example.json +8 -8
  137. teradataml/data/chi_sq.csv +2 -2
  138. teradataml/data/churn_data.csv +14 -14
  139. teradataml/data/churn_emission.csv +35 -35
  140. teradataml/data/churn_initial.csv +3 -3
  141. teradataml/data/churn_state_transition.csv +5 -5
  142. teradataml/data/citedges_2.csv +745 -745
  143. teradataml/data/citvertices_2.csv +1210 -1210
  144. teradataml/data/clicks2.csv +16 -16
  145. teradataml/data/clickstream.csv +12 -12
  146. teradataml/data/clickstream1.csv +11 -11
  147. teradataml/data/closeness_example.json +15 -15
  148. teradataml/data/complaints.csv +21 -21
  149. teradataml/data/complaints_mini.csv +3 -3
  150. teradataml/data/complaints_testtoken.csv +224 -224
  151. teradataml/data/complaints_tokens_test.csv +353 -353
  152. teradataml/data/complaints_traintoken.csv +472 -472
  153. teradataml/data/computers_category.csv +1001 -1001
  154. teradataml/data/computers_test1.csv +1252 -1252
  155. teradataml/data/computers_train1.csv +5009 -5009
  156. teradataml/data/computers_train1_clustered.csv +5009 -5009
  157. teradataml/data/confusionmatrix_example.json +9 -9
  158. teradataml/data/conversion_event_table.csv +3 -3
  159. teradataml/data/corr_input.csv +17 -17
  160. teradataml/data/correlation_example.json +11 -11
  161. teradataml/data/coxhazardratio_example.json +39 -39
  162. teradataml/data/coxph_example.json +15 -15
  163. teradataml/data/coxsurvival_example.json +28 -28
  164. teradataml/data/cpt.csv +41 -41
  165. teradataml/data/credit_ex_merged.csv +45 -45
  166. teradataml/data/customer_loyalty.csv +301 -301
  167. teradataml/data/customer_loyalty_newseq.csv +31 -31
  168. teradataml/data/dataframe_example.json +146 -146
  169. teradataml/data/decisionforest_example.json +37 -37
  170. teradataml/data/decisionforestpredict_example.json +38 -38
  171. teradataml/data/decisiontree_example.json +21 -21
  172. teradataml/data/decisiontreepredict_example.json +45 -45
  173. teradataml/data/dfft2_size4_real.csv +17 -17
  174. teradataml/data/dfft2_test_matrix16.csv +17 -17
  175. teradataml/data/dfft2conv_real_4_4.csv +65 -65
  176. teradataml/data/diabetes.csv +443 -443
  177. teradataml/data/diabetes_test.csv +89 -89
  178. teradataml/data/dict_table.csv +5 -5
  179. teradataml/data/docperterm_table.csv +4 -4
  180. teradataml/data/docs/__init__.py +1 -1
  181. teradataml/data/docs/byom/docs/DataRobotPredict.py +180 -180
  182. teradataml/data/docs/byom/docs/DataikuPredict.py +177 -177
  183. teradataml/data/docs/byom/docs/H2OPredict.py +324 -324
  184. teradataml/data/docs/byom/docs/ONNXPredict.py +283 -283
  185. teradataml/data/docs/byom/docs/PMMLPredict.py +277 -277
  186. teradataml/data/docs/sqle/docs_17_10/Antiselect.py +82 -82
  187. teradataml/data/docs/sqle/docs_17_10/Attribution.py +199 -199
  188. teradataml/data/docs/sqle/docs_17_10/BincodeFit.py +171 -171
  189. teradataml/data/docs/sqle/docs_17_10/BincodeTransform.py +131 -130
  190. teradataml/data/docs/sqle/docs_17_10/CategoricalSummary.py +86 -86
  191. teradataml/data/docs/sqle/docs_17_10/ChiSq.py +90 -90
  192. teradataml/data/docs/sqle/docs_17_10/ColumnSummary.py +85 -85
  193. teradataml/data/docs/sqle/docs_17_10/ConvertTo.py +95 -95
  194. teradataml/data/docs/sqle/docs_17_10/DecisionForestPredict.py +139 -139
  195. teradataml/data/docs/sqle/docs_17_10/DecisionTreePredict.py +151 -151
  196. teradataml/data/docs/sqle/docs_17_10/FTest.py +160 -160
  197. teradataml/data/docs/sqle/docs_17_10/FillRowId.py +82 -82
  198. teradataml/data/docs/sqle/docs_17_10/Fit.py +87 -87
  199. teradataml/data/docs/sqle/docs_17_10/GLMPredict.py +144 -144
  200. teradataml/data/docs/sqle/docs_17_10/GetRowsWithMissingValues.py +84 -84
  201. teradataml/data/docs/sqle/docs_17_10/GetRowsWithoutMissingValues.py +81 -81
  202. teradataml/data/docs/sqle/docs_17_10/Histogram.py +164 -164
  203. teradataml/data/docs/sqle/docs_17_10/MovingAverage.py +134 -134
  204. teradataml/data/docs/sqle/docs_17_10/NGramSplitter.py +208 -208
  205. teradataml/data/docs/sqle/docs_17_10/NPath.py +265 -265
  206. teradataml/data/docs/sqle/docs_17_10/NaiveBayesPredict.py +116 -116
  207. teradataml/data/docs/sqle/docs_17_10/NaiveBayesTextClassifierPredict.py +176 -176
  208. teradataml/data/docs/sqle/docs_17_10/NumApply.py +147 -147
  209. teradataml/data/docs/sqle/docs_17_10/OneHotEncodingFit.py +132 -132
  210. teradataml/data/docs/sqle/docs_17_10/OneHotEncodingTransform.py +103 -103
  211. teradataml/data/docs/sqle/docs_17_10/OutlierFilterFit.py +165 -165
  212. teradataml/data/docs/sqle/docs_17_10/OutlierFilterTransform.py +101 -101
  213. teradataml/data/docs/sqle/docs_17_10/Pack.py +128 -128
  214. teradataml/data/docs/sqle/docs_17_10/PolynomialFeaturesFit.py +111 -111
  215. teradataml/data/docs/sqle/docs_17_10/PolynomialFeaturesTransform.py +102 -102
  216. teradataml/data/docs/sqle/docs_17_10/QQNorm.py +104 -104
  217. teradataml/data/docs/sqle/docs_17_10/RoundColumns.py +109 -109
  218. teradataml/data/docs/sqle/docs_17_10/RowNormalizeFit.py +117 -117
  219. teradataml/data/docs/sqle/docs_17_10/RowNormalizeTransform.py +99 -98
  220. teradataml/data/docs/sqle/docs_17_10/SVMSparsePredict.py +152 -152
  221. teradataml/data/docs/sqle/docs_17_10/ScaleFit.py +197 -197
  222. teradataml/data/docs/sqle/docs_17_10/ScaleTransform.py +99 -98
  223. teradataml/data/docs/sqle/docs_17_10/Sessionize.py +113 -113
  224. teradataml/data/docs/sqle/docs_17_10/SimpleImputeFit.py +116 -116
  225. teradataml/data/docs/sqle/docs_17_10/SimpleImputeTransform.py +98 -98
  226. teradataml/data/docs/sqle/docs_17_10/StrApply.py +187 -187
  227. teradataml/data/docs/sqle/docs_17_10/StringSimilarity.py +145 -145
  228. teradataml/data/docs/sqle/docs_17_10/Transform.py +105 -104
  229. teradataml/data/docs/sqle/docs_17_10/UnivariateStatistics.py +141 -141
  230. teradataml/data/docs/sqle/docs_17_10/Unpack.py +214 -214
  231. teradataml/data/docs/sqle/docs_17_10/WhichMax.py +83 -83
  232. teradataml/data/docs/sqle/docs_17_10/WhichMin.py +83 -83
  233. teradataml/data/docs/sqle/docs_17_10/ZTest.py +155 -155
  234. teradataml/data/docs/sqle/docs_17_20/ANOVA.py +126 -126
  235. teradataml/data/docs/sqle/docs_17_20/Antiselect.py +82 -82
  236. teradataml/data/docs/sqle/docs_17_20/Attribution.py +200 -200
  237. teradataml/data/docs/sqle/docs_17_20/BincodeFit.py +171 -171
  238. teradataml/data/docs/sqle/docs_17_20/BincodeTransform.py +139 -138
  239. teradataml/data/docs/sqle/docs_17_20/CategoricalSummary.py +86 -86
  240. teradataml/data/docs/sqle/docs_17_20/ChiSq.py +90 -90
  241. teradataml/data/docs/sqle/docs_17_20/ClassificationEvaluator.py +166 -166
  242. teradataml/data/docs/sqle/docs_17_20/ColumnSummary.py +85 -85
  243. teradataml/data/docs/sqle/docs_17_20/ColumnTransformer.py +243 -243
  244. teradataml/data/docs/sqle/docs_17_20/ConvertTo.py +113 -113
  245. teradataml/data/docs/sqle/docs_17_20/DecisionForest.py +279 -279
  246. teradataml/data/docs/sqle/docs_17_20/DecisionForestPredict.py +144 -144
  247. teradataml/data/docs/sqle/docs_17_20/DecisionTreePredict.py +135 -135
  248. teradataml/data/docs/sqle/docs_17_20/FTest.py +160 -160
  249. teradataml/data/docs/sqle/docs_17_20/FillRowId.py +82 -82
  250. teradataml/data/docs/sqle/docs_17_20/Fit.py +87 -87
  251. teradataml/data/docs/sqle/docs_17_20/GLM.py +380 -380
  252. teradataml/data/docs/sqle/docs_17_20/GLMPerSegment.py +414 -414
  253. teradataml/data/docs/sqle/docs_17_20/GLMPredict.py +144 -144
  254. teradataml/data/docs/sqle/docs_17_20/GLMPredictPerSegment.py +233 -234
  255. teradataml/data/docs/sqle/docs_17_20/GetFutileColumns.py +123 -123
  256. teradataml/data/docs/sqle/docs_17_20/GetRowsWithMissingValues.py +108 -108
  257. teradataml/data/docs/sqle/docs_17_20/GetRowsWithoutMissingValues.py +105 -105
  258. teradataml/data/docs/sqle/docs_17_20/Histogram.py +223 -223
  259. teradataml/data/docs/sqle/docs_17_20/KMeans.py +204 -204
  260. teradataml/data/docs/sqle/docs_17_20/KMeansPredict.py +144 -143
  261. teradataml/data/docs/sqle/docs_17_20/KNN.py +214 -214
  262. teradataml/data/docs/sqle/docs_17_20/MovingAverage.py +134 -134
  263. teradataml/data/docs/sqle/docs_17_20/NGramSplitter.py +208 -208
  264. teradataml/data/docs/sqle/docs_17_20/NPath.py +265 -265
  265. teradataml/data/docs/sqle/docs_17_20/NaiveBayesPredict.py +116 -116
  266. teradataml/data/docs/sqle/docs_17_20/NaiveBayesTextClassifierPredict.py +177 -176
  267. teradataml/data/docs/sqle/docs_17_20/NaiveBayesTextClassifierTrainer.py +126 -126
  268. teradataml/data/docs/sqle/docs_17_20/NonLinearCombineFit.py +117 -117
  269. teradataml/data/docs/sqle/docs_17_20/NonLinearCombineTransform.py +112 -112
  270. teradataml/data/docs/sqle/docs_17_20/NumApply.py +147 -147
  271. teradataml/data/docs/sqle/docs_17_20/OneClassSVM.py +307 -307
  272. teradataml/data/docs/sqle/docs_17_20/OneClassSVMPredict.py +185 -184
  273. teradataml/data/docs/sqle/docs_17_20/OneHotEncodingFit.py +225 -225
  274. teradataml/data/docs/sqle/docs_17_20/OneHotEncodingTransform.py +115 -115
  275. teradataml/data/docs/sqle/docs_17_20/OrdinalEncodingFit.py +219 -219
  276. teradataml/data/docs/sqle/docs_17_20/OrdinalEncodingTransform.py +127 -127
  277. teradataml/data/docs/sqle/docs_17_20/OutlierFilterFit.py +189 -189
  278. teradataml/data/docs/sqle/docs_17_20/OutlierFilterTransform.py +117 -112
  279. teradataml/data/docs/sqle/docs_17_20/Pack.py +128 -128
  280. teradataml/data/docs/sqle/docs_17_20/PolynomialFeaturesFit.py +111 -111
  281. teradataml/data/docs/sqle/docs_17_20/PolynomialFeaturesTransform.py +112 -111
  282. teradataml/data/docs/sqle/docs_17_20/QQNorm.py +104 -104
  283. teradataml/data/docs/sqle/docs_17_20/ROC.py +163 -163
  284. teradataml/data/docs/sqle/docs_17_20/RandomProjectionFit.py +154 -154
  285. teradataml/data/docs/sqle/docs_17_20/RandomProjectionMinComponents.py +106 -106
  286. teradataml/data/docs/sqle/docs_17_20/RandomProjectionTransform.py +120 -120
  287. teradataml/data/docs/sqle/docs_17_20/RegressionEvaluator.py +211 -211
  288. teradataml/data/docs/sqle/docs_17_20/RoundColumns.py +108 -108
  289. teradataml/data/docs/sqle/docs_17_20/RowNormalizeFit.py +117 -117
  290. teradataml/data/docs/sqle/docs_17_20/RowNormalizeTransform.py +111 -110
  291. teradataml/data/docs/sqle/docs_17_20/SVM.py +413 -413
  292. teradataml/data/docs/sqle/docs_17_20/SVMPredict.py +202 -202
  293. teradataml/data/docs/sqle/docs_17_20/SVMSparsePredict.py +152 -152
  294. teradataml/data/docs/sqle/docs_17_20/ScaleFit.py +197 -197
  295. teradataml/data/docs/sqle/docs_17_20/ScaleTransform.py +110 -109
  296. teradataml/data/docs/sqle/docs_17_20/SentimentExtractor.py +206 -206
  297. teradataml/data/docs/sqle/docs_17_20/Sessionize.py +113 -113
  298. teradataml/data/docs/sqle/docs_17_20/Silhouette.py +152 -152
  299. teradataml/data/docs/sqle/docs_17_20/SimpleImputeFit.py +116 -116
  300. teradataml/data/docs/sqle/docs_17_20/SimpleImputeTransform.py +109 -108
  301. teradataml/data/docs/sqle/docs_17_20/StrApply.py +187 -187
  302. teradataml/data/docs/sqle/docs_17_20/StringSimilarity.py +145 -145
  303. teradataml/data/docs/sqle/docs_17_20/TDDecisionForestPredict.py +207 -207
  304. teradataml/data/docs/sqle/docs_17_20/TDGLMPredict.py +171 -171
  305. teradataml/data/docs/sqle/docs_17_20/TargetEncodingFit.py +266 -266
  306. teradataml/data/docs/sqle/docs_17_20/TargetEncodingTransform.py +141 -140
  307. teradataml/data/docs/sqle/docs_17_20/TextParser.py +172 -172
  308. teradataml/data/docs/sqle/docs_17_20/TrainTestSplit.py +159 -159
  309. teradataml/data/docs/sqle/docs_17_20/Transform.py +123 -123
  310. teradataml/data/docs/sqle/docs_17_20/UnivariateStatistics.py +141 -141
  311. teradataml/data/docs/sqle/docs_17_20/Unpack.py +214 -214
  312. teradataml/data/docs/sqle/docs_17_20/VectorDistance.py +168 -168
  313. teradataml/data/docs/sqle/docs_17_20/WhichMax.py +83 -83
  314. teradataml/data/docs/sqle/docs_17_20/WhichMin.py +83 -83
  315. teradataml/data/docs/sqle/docs_17_20/WordEmbeddings.py +236 -236
  316. teradataml/data/docs/sqle/docs_17_20/XGBoost.py +353 -353
  317. teradataml/data/docs/sqle/docs_17_20/XGBoostPredict.py +275 -275
  318. teradataml/data/docs/sqle/docs_17_20/ZTest.py +155 -155
  319. teradataml/data/docs/tableoperator/docs_17_00/ReadNOS.py +429 -429
  320. teradataml/data/docs/tableoperator/docs_17_05/ReadNOS.py +429 -429
  321. teradataml/data/docs/tableoperator/docs_17_05/WriteNOS.py +347 -347
  322. teradataml/data/docs/tableoperator/docs_17_10/ReadNOS.py +428 -428
  323. teradataml/data/docs/tableoperator/docs_17_10/WriteNOS.py +347 -347
  324. teradataml/data/docs/tableoperator/docs_17_20/ReadNOS.py +439 -439
  325. teradataml/data/docs/tableoperator/docs_17_20/WriteNOS.py +386 -386
  326. teradataml/data/docs/uaf/docs_17_20/ACF.py +195 -195
  327. teradataml/data/docs/uaf/docs_17_20/ArimaEstimate.py +369 -369
  328. teradataml/data/docs/uaf/docs_17_20/ArimaForecast.py +142 -142
  329. teradataml/data/docs/uaf/docs_17_20/ArimaValidate.py +159 -159
  330. teradataml/data/docs/uaf/docs_17_20/BinaryMatrixOp.py +247 -247
  331. teradataml/data/docs/uaf/docs_17_20/BinarySeriesOp.py +252 -252
  332. teradataml/data/docs/uaf/docs_17_20/BreuschGodfrey.py +177 -177
  333. teradataml/data/docs/uaf/docs_17_20/BreuschPaganGodfrey.py +174 -174
  334. teradataml/data/docs/uaf/docs_17_20/Convolve.py +226 -226
  335. teradataml/data/docs/uaf/docs_17_20/Convolve2.py +214 -214
  336. teradataml/data/docs/uaf/docs_17_20/CumulPeriodogram.py +183 -183
  337. teradataml/data/docs/uaf/docs_17_20/DFFT.py +203 -203
  338. teradataml/data/docs/uaf/docs_17_20/DFFT2.py +216 -216
  339. teradataml/data/docs/uaf/docs_17_20/DFFT2Conv.py +215 -215
  340. teradataml/data/docs/uaf/docs_17_20/DFFTConv.py +191 -191
  341. teradataml/data/docs/uaf/docs_17_20/DTW.py +179 -179
  342. teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +144 -144
  343. teradataml/data/docs/uaf/docs_17_20/DurbinWatson.py +183 -183
  344. teradataml/data/docs/uaf/docs_17_20/ExtractResults.py +184 -184
  345. teradataml/data/docs/uaf/docs_17_20/FitMetrics.py +172 -172
  346. teradataml/data/docs/uaf/docs_17_20/GenseriesFormula.py +205 -205
  347. teradataml/data/docs/uaf/docs_17_20/GenseriesSinusoids.py +142 -142
  348. teradataml/data/docs/uaf/docs_17_20/HoltWintersForecaster.py +258 -258
  349. teradataml/data/docs/uaf/docs_17_20/IDFFT.py +164 -164
  350. teradataml/data/docs/uaf/docs_17_20/IDFFT2.py +198 -198
  351. teradataml/data/docs/uaf/docs_17_20/InputValidator.py +120 -120
  352. teradataml/data/docs/uaf/docs_17_20/LineSpec.py +155 -155
  353. teradataml/data/docs/uaf/docs_17_20/LinearRegr.py +214 -214
  354. teradataml/data/docs/uaf/docs_17_20/MAMean.py +173 -173
  355. teradataml/data/docs/uaf/docs_17_20/MInfo.py +133 -133
  356. teradataml/data/docs/uaf/docs_17_20/MatrixMultiply.py +135 -135
  357. teradataml/data/docs/uaf/docs_17_20/MultivarRegr.py +190 -190
  358. teradataml/data/docs/uaf/docs_17_20/PACF.py +158 -158
  359. teradataml/data/docs/uaf/docs_17_20/Portman.py +216 -216
  360. teradataml/data/docs/uaf/docs_17_20/PowerTransform.py +154 -154
  361. teradataml/data/docs/uaf/docs_17_20/Resample.py +228 -228
  362. teradataml/data/docs/uaf/docs_17_20/SInfo.py +122 -122
  363. teradataml/data/docs/uaf/docs_17_20/SeasonalNormalize.py +165 -165
  364. teradataml/data/docs/uaf/docs_17_20/SelectionCriteria.py +173 -173
  365. teradataml/data/docs/uaf/docs_17_20/SignifPeriodicities.py +170 -170
  366. teradataml/data/docs/uaf/docs_17_20/SignifResidmean.py +163 -163
  367. teradataml/data/docs/uaf/docs_17_20/SimpleExp.py +179 -179
  368. teradataml/data/docs/uaf/docs_17_20/Smoothma.py +207 -207
  369. teradataml/data/docs/uaf/docs_17_20/TrackingOp.py +150 -150
  370. teradataml/data/docs/uaf/docs_17_20/UNDIFF.py +171 -171
  371. teradataml/data/docs/uaf/docs_17_20/Unnormalize.py +201 -201
  372. teradataml/data/docs/uaf/docs_17_20/WhitesGeneral.py +169 -169
  373. teradataml/data/dtw_example.json +17 -17
  374. teradataml/data/dtw_t1.csv +11 -11
  375. teradataml/data/dtw_t2.csv +4 -4
  376. teradataml/data/dwt2d_example.json +15 -15
  377. teradataml/data/dwt_example.json +14 -14
  378. teradataml/data/dwt_filter_dim.csv +5 -5
  379. teradataml/data/emission.csv +9 -9
  380. teradataml/data/emp_table_by_dept.csv +19 -19
  381. teradataml/data/employee_info.csv +4 -4
  382. teradataml/data/employee_table.csv +6 -6
  383. teradataml/data/excluding_event_table.csv +2 -2
  384. teradataml/data/finance_data.csv +6 -6
  385. teradataml/data/finance_data2.csv +61 -61
  386. teradataml/data/finance_data3.csv +93 -93
  387. teradataml/data/fish.csv +160 -0
  388. teradataml/data/fm_blood2ageandweight.csv +26 -26
  389. teradataml/data/fmeasure_example.json +11 -11
  390. teradataml/data/followers_leaders.csv +10 -10
  391. teradataml/data/fpgrowth_example.json +12 -12
  392. teradataml/data/frequentpaths_example.json +29 -29
  393. teradataml/data/friends.csv +9 -9
  394. teradataml/data/fs_input.csv +33 -33
  395. teradataml/data/fs_input1.csv +33 -33
  396. teradataml/data/genData.csv +513 -513
  397. teradataml/data/geodataframe_example.json +39 -39
  398. teradataml/data/glass_types.csv +215 -0
  399. teradataml/data/glm_admissions_model.csv +12 -12
  400. teradataml/data/glm_example.json +29 -29
  401. teradataml/data/glml1l2_example.json +28 -28
  402. teradataml/data/glml1l2predict_example.json +54 -54
  403. teradataml/data/glmpredict_example.json +54 -54
  404. teradataml/data/gq_t1.csv +21 -21
  405. teradataml/data/hconvolve_complex_right.csv +5 -5
  406. teradataml/data/hconvolve_complex_rightmulti.csv +5 -5
  407. teradataml/data/histogram_example.json +11 -11
  408. teradataml/data/hmmdecoder_example.json +78 -78
  409. teradataml/data/hmmevaluator_example.json +24 -24
  410. teradataml/data/hmmsupervised_example.json +10 -10
  411. teradataml/data/hmmunsupervised_example.json +7 -7
  412. teradataml/data/house_values.csv +12 -12
  413. teradataml/data/house_values2.csv +13 -13
  414. teradataml/data/housing_cat.csv +7 -7
  415. teradataml/data/housing_data.csv +9 -9
  416. teradataml/data/housing_test.csv +47 -47
  417. teradataml/data/housing_test_binary.csv +47 -47
  418. teradataml/data/housing_train.csv +493 -493
  419. teradataml/data/housing_train_attribute.csv +4 -4
  420. teradataml/data/housing_train_binary.csv +437 -437
  421. teradataml/data/housing_train_parameter.csv +2 -2
  422. teradataml/data/housing_train_response.csv +493 -493
  423. teradataml/data/ibm_stock.csv +370 -370
  424. teradataml/data/ibm_stock1.csv +370 -370
  425. teradataml/data/identitymatch_example.json +21 -21
  426. teradataml/data/idf_table.csv +4 -4
  427. teradataml/data/impressions.csv +101 -101
  428. teradataml/data/inflation.csv +21 -21
  429. teradataml/data/initial.csv +3 -3
  430. teradataml/data/insect_sprays.csv +12 -12
  431. teradataml/data/insurance.csv +1339 -1339
  432. teradataml/data/interpolator_example.json +12 -12
  433. teradataml/data/iris_altinput.csv +481 -481
  434. teradataml/data/iris_attribute_output.csv +8 -8
  435. teradataml/data/iris_attribute_test.csv +121 -121
  436. teradataml/data/iris_attribute_train.csv +481 -481
  437. teradataml/data/iris_category_expect_predict.csv +31 -31
  438. teradataml/data/iris_data.csv +151 -0
  439. teradataml/data/iris_input.csv +151 -151
  440. teradataml/data/iris_response_train.csv +121 -121
  441. teradataml/data/iris_test.csv +31 -31
  442. teradataml/data/iris_train.csv +121 -121
  443. teradataml/data/join_table1.csv +4 -4
  444. teradataml/data/join_table2.csv +4 -4
  445. teradataml/data/jsons/anly_function_name.json +6 -6
  446. teradataml/data/jsons/byom/dataikupredict.json +147 -147
  447. teradataml/data/jsons/byom/datarobotpredict.json +146 -146
  448. teradataml/data/jsons/byom/h2opredict.json +194 -194
  449. teradataml/data/jsons/byom/onnxpredict.json +186 -186
  450. teradataml/data/jsons/byom/pmmlpredict.json +146 -146
  451. teradataml/data/jsons/paired_functions.json +435 -435
  452. teradataml/data/jsons/sqle/16.20/Antiselect.json +56 -56
  453. teradataml/data/jsons/sqle/16.20/Attribution.json +249 -249
  454. teradataml/data/jsons/sqle/16.20/DecisionForestPredict.json +156 -156
  455. teradataml/data/jsons/sqle/16.20/DecisionTreePredict.json +170 -170
  456. teradataml/data/jsons/sqle/16.20/GLMPredict.json +122 -122
  457. teradataml/data/jsons/sqle/16.20/MovingAverage.json +367 -367
  458. teradataml/data/jsons/sqle/16.20/NGramSplitter.json +239 -239
  459. teradataml/data/jsons/sqle/16.20/NaiveBayesPredict.json +136 -136
  460. teradataml/data/jsons/sqle/16.20/NaiveBayesTextClassifierPredict.json +235 -235
  461. teradataml/data/jsons/sqle/16.20/Pack.json +98 -98
  462. teradataml/data/jsons/sqle/16.20/SVMSparsePredict.json +162 -162
  463. teradataml/data/jsons/sqle/16.20/Sessionize.json +105 -105
  464. teradataml/data/jsons/sqle/16.20/StringSimilarity.json +86 -86
  465. teradataml/data/jsons/sqle/16.20/Unpack.json +166 -166
  466. teradataml/data/jsons/sqle/16.20/nPath.json +269 -269
  467. teradataml/data/jsons/sqle/17.00/Antiselect.json +56 -56
  468. teradataml/data/jsons/sqle/17.00/Attribution.json +249 -249
  469. teradataml/data/jsons/sqle/17.00/DecisionForestPredict.json +156 -156
  470. teradataml/data/jsons/sqle/17.00/DecisionTreePredict.json +170 -170
  471. teradataml/data/jsons/sqle/17.00/GLMPredict.json +122 -122
  472. teradataml/data/jsons/sqle/17.00/MovingAverage.json +367 -367
  473. teradataml/data/jsons/sqle/17.00/NGramSplitter.json +239 -239
  474. teradataml/data/jsons/sqle/17.00/NaiveBayesPredict.json +136 -136
  475. teradataml/data/jsons/sqle/17.00/NaiveBayesTextClassifierPredict.json +235 -235
  476. teradataml/data/jsons/sqle/17.00/Pack.json +98 -98
  477. teradataml/data/jsons/sqle/17.00/SVMSparsePredict.json +162 -162
  478. teradataml/data/jsons/sqle/17.00/Sessionize.json +105 -105
  479. teradataml/data/jsons/sqle/17.00/StringSimilarity.json +86 -86
  480. teradataml/data/jsons/sqle/17.00/Unpack.json +166 -166
  481. teradataml/data/jsons/sqle/17.00/nPath.json +269 -269
  482. teradataml/data/jsons/sqle/17.05/Antiselect.json +56 -56
  483. teradataml/data/jsons/sqle/17.05/Attribution.json +249 -249
  484. teradataml/data/jsons/sqle/17.05/DecisionForestPredict.json +156 -156
  485. teradataml/data/jsons/sqle/17.05/DecisionTreePredict.json +170 -170
  486. teradataml/data/jsons/sqle/17.05/GLMPredict.json +122 -122
  487. teradataml/data/jsons/sqle/17.05/MovingAverage.json +367 -367
  488. teradataml/data/jsons/sqle/17.05/NGramSplitter.json +239 -239
  489. teradataml/data/jsons/sqle/17.05/NaiveBayesPredict.json +136 -136
  490. teradataml/data/jsons/sqle/17.05/NaiveBayesTextClassifierPredict.json +235 -235
  491. teradataml/data/jsons/sqle/17.05/Pack.json +98 -98
  492. teradataml/data/jsons/sqle/17.05/SVMSparsePredict.json +162 -162
  493. teradataml/data/jsons/sqle/17.05/Sessionize.json +105 -105
  494. teradataml/data/jsons/sqle/17.05/StringSimilarity.json +86 -86
  495. teradataml/data/jsons/sqle/17.05/Unpack.json +166 -166
  496. teradataml/data/jsons/sqle/17.05/nPath.json +269 -269
  497. teradataml/data/jsons/sqle/17.10/Antiselect.json +56 -56
  498. teradataml/data/jsons/sqle/17.10/Attribution.json +249 -249
  499. teradataml/data/jsons/sqle/17.10/DecisionForestPredict.json +185 -185
  500. teradataml/data/jsons/sqle/17.10/DecisionTreePredict.json +171 -171
  501. teradataml/data/jsons/sqle/17.10/GLMPredict.json +151 -151
  502. teradataml/data/jsons/sqle/17.10/MovingAverage.json +368 -368
  503. teradataml/data/jsons/sqle/17.10/NGramSplitter.json +239 -239
  504. teradataml/data/jsons/sqle/17.10/NaiveBayesPredict.json +149 -149
  505. teradataml/data/jsons/sqle/17.10/NaiveBayesTextClassifierPredict.json +288 -288
  506. teradataml/data/jsons/sqle/17.10/Pack.json +133 -133
  507. teradataml/data/jsons/sqle/17.10/SVMSparsePredict.json +193 -193
  508. teradataml/data/jsons/sqle/17.10/Sessionize.json +105 -105
  509. teradataml/data/jsons/sqle/17.10/StringSimilarity.json +86 -86
  510. teradataml/data/jsons/sqle/17.10/TD_BinCodeFit.json +239 -239
  511. teradataml/data/jsons/sqle/17.10/TD_BinCodeTransform.json +70 -70
  512. teradataml/data/jsons/sqle/17.10/TD_CategoricalSummary.json +53 -53
  513. teradataml/data/jsons/sqle/17.10/TD_Chisq.json +67 -67
  514. teradataml/data/jsons/sqle/17.10/TD_ColumnSummary.json +53 -53
  515. teradataml/data/jsons/sqle/17.10/TD_ConvertTo.json +68 -68
  516. teradataml/data/jsons/sqle/17.10/TD_FTest.json +187 -187
  517. teradataml/data/jsons/sqle/17.10/TD_FillRowID.json +51 -51
  518. teradataml/data/jsons/sqle/17.10/TD_FunctionFit.json +46 -46
  519. teradataml/data/jsons/sqle/17.10/TD_FunctionTransform.json +72 -71
  520. teradataml/data/jsons/sqle/17.10/TD_GetRowsWithMissingValues.json +52 -52
  521. teradataml/data/jsons/sqle/17.10/TD_GetRowsWithoutMissingValues.json +52 -52
  522. teradataml/data/jsons/sqle/17.10/TD_Histogram.json +132 -132
  523. teradataml/data/jsons/sqle/17.10/TD_NumApply.json +147 -147
  524. teradataml/data/jsons/sqle/17.10/TD_OneHotEncodingFit.json +182 -182
  525. teradataml/data/jsons/sqle/17.10/TD_OneHotEncodingTransform.json +65 -64
  526. teradataml/data/jsons/sqle/17.10/TD_OutlierFilterFit.json +196 -196
  527. teradataml/data/jsons/sqle/17.10/TD_OutlierFilterTransform.json +48 -47
  528. teradataml/data/jsons/sqle/17.10/TD_PolynomialFeaturesFit.json +114 -114
  529. teradataml/data/jsons/sqle/17.10/TD_PolynomialFeaturesTransform.json +72 -71
  530. teradataml/data/jsons/sqle/17.10/TD_QQNorm.json +111 -111
  531. teradataml/data/jsons/sqle/17.10/TD_RoundColumns.json +93 -93
  532. teradataml/data/jsons/sqle/17.10/TD_RowNormalizeFit.json +127 -127
  533. teradataml/data/jsons/sqle/17.10/TD_RowNormalizeTransform.json +70 -69
  534. teradataml/data/jsons/sqle/17.10/TD_ScaleFit.json +156 -156
  535. teradataml/data/jsons/sqle/17.10/TD_ScaleTransform.json +70 -69
  536. teradataml/data/jsons/sqle/17.10/TD_SimpleImputeFit.json +147 -147
  537. teradataml/data/jsons/sqle/17.10/TD_SimpleImputeTransform.json +48 -47
  538. teradataml/data/jsons/sqle/17.10/TD_StrApply.json +240 -240
  539. teradataml/data/jsons/sqle/17.10/TD_UnivariateStatistics.json +118 -118
  540. teradataml/data/jsons/sqle/17.10/TD_WhichMax.json +52 -52
  541. teradataml/data/jsons/sqle/17.10/TD_WhichMin.json +52 -52
  542. teradataml/data/jsons/sqle/17.10/TD_ZTest.json +171 -171
  543. teradataml/data/jsons/sqle/17.10/Unpack.json +188 -188
  544. teradataml/data/jsons/sqle/17.10/nPath.json +269 -269
  545. teradataml/data/jsons/sqle/17.20/Antiselect.json +56 -56
  546. teradataml/data/jsons/sqle/17.20/Attribution.json +249 -249
  547. teradataml/data/jsons/sqle/17.20/DecisionForestPredict.json +185 -185
  548. teradataml/data/jsons/sqle/17.20/DecisionTreePredict.json +172 -172
  549. teradataml/data/jsons/sqle/17.20/GLMPredict.json +151 -151
  550. teradataml/data/jsons/sqle/17.20/MovingAverage.json +367 -367
  551. teradataml/data/jsons/sqle/17.20/NGramSplitter.json +239 -239
  552. teradataml/data/jsons/sqle/17.20/NaiveBayesPredict.json +149 -149
  553. teradataml/data/jsons/sqle/17.20/NaiveBayesTextClassifierPredict.json +287 -287
  554. teradataml/data/jsons/sqle/17.20/Pack.json +133 -133
  555. teradataml/data/jsons/sqle/17.20/SVMSparsePredict.json +192 -192
  556. teradataml/data/jsons/sqle/17.20/Sessionize.json +105 -105
  557. teradataml/data/jsons/sqle/17.20/StringSimilarity.json +86 -86
  558. teradataml/data/jsons/sqle/17.20/TD_ANOVA.json +76 -76
  559. teradataml/data/jsons/sqle/17.20/TD_BinCodeFit.json +239 -239
  560. teradataml/data/jsons/sqle/17.20/TD_BinCodeTransform.json +71 -71
  561. teradataml/data/jsons/sqle/17.20/TD_CategoricalSummary.json +53 -53
  562. teradataml/data/jsons/sqle/17.20/TD_Chisq.json +67 -67
  563. teradataml/data/jsons/sqle/17.20/TD_ClassificationEvaluator.json +145 -145
  564. teradataml/data/jsons/sqle/17.20/TD_ColumnSummary.json +53 -53
  565. teradataml/data/jsons/sqle/17.20/TD_ColumnTransformer.json +218 -218
  566. teradataml/data/jsons/sqle/17.20/TD_ConvertTo.json +92 -92
  567. teradataml/data/jsons/sqle/17.20/TD_DecisionForest.json +259 -259
  568. teradataml/data/jsons/sqle/17.20/TD_DecisionForestPredict.json +139 -139
  569. teradataml/data/jsons/sqle/17.20/TD_FTest.json +186 -186
  570. teradataml/data/jsons/sqle/17.20/TD_FillRowID.json +52 -52
  571. teradataml/data/jsons/sqle/17.20/TD_FunctionFit.json +46 -46
  572. teradataml/data/jsons/sqle/17.20/TD_FunctionTransform.json +72 -72
  573. teradataml/data/jsons/sqle/17.20/TD_GLM.json +431 -431
  574. teradataml/data/jsons/sqle/17.20/TD_GLMPREDICT.json +125 -125
  575. teradataml/data/jsons/sqle/17.20/TD_GLMPerSegment.json +411 -411
  576. teradataml/data/jsons/sqle/17.20/TD_GLMPredictPerSegment.json +146 -146
  577. teradataml/data/jsons/sqle/17.20/TD_GetFutileColumns.json +91 -91
  578. teradataml/data/jsons/sqle/17.20/TD_GetRowsWithMissingValues.json +76 -76
  579. teradataml/data/jsons/sqle/17.20/TD_GetRowsWithoutMissingValues.json +76 -76
  580. teradataml/data/jsons/sqle/17.20/TD_Histogram.json +152 -152
  581. teradataml/data/jsons/sqle/17.20/TD_KMeans.json +211 -211
  582. teradataml/data/jsons/sqle/17.20/TD_KMeansPredict.json +86 -86
  583. teradataml/data/jsons/sqle/17.20/TD_KNN.json +262 -262
  584. teradataml/data/jsons/sqle/17.20/TD_NaiveBayesTextClassifierTrainer.json +137 -137
  585. teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineFit.json +101 -101
  586. teradataml/data/jsons/sqle/17.20/TD_NonLinearCombineTransform.json +71 -71
  587. teradataml/data/jsons/sqle/17.20/TD_NumApply.json +147 -147
  588. teradataml/data/jsons/sqle/17.20/TD_OneClassSVM.json +315 -315
  589. teradataml/data/jsons/sqle/17.20/TD_OneClassSVMPredict.json +123 -123
  590. teradataml/data/jsons/sqle/17.20/TD_OneHotEncodingFit.json +271 -271
  591. teradataml/data/jsons/sqle/17.20/TD_OneHotEncodingTransform.json +65 -65
  592. teradataml/data/jsons/sqle/17.20/TD_OrdinalEncodingFit.json +229 -229
  593. teradataml/data/jsons/sqle/17.20/TD_OrdinalEncodingTransform.json +75 -75
  594. teradataml/data/jsons/sqle/17.20/TD_OutlierFilterFit.json +217 -217
  595. teradataml/data/jsons/sqle/17.20/TD_OutlierFilterTransform.json +48 -48
  596. teradataml/data/jsons/sqle/17.20/TD_PolynomialFeaturesFit.json +114 -114
  597. teradataml/data/jsons/sqle/17.20/TD_PolynomialFeaturesTransform.json +72 -72
  598. teradataml/data/jsons/sqle/17.20/TD_QQNorm.json +111 -111
  599. teradataml/data/jsons/sqle/17.20/TD_ROC.json +177 -177
  600. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionFit.json +178 -178
  601. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionMinComponents.json +73 -73
  602. teradataml/data/jsons/sqle/17.20/TD_RandomProjectionTransform.json +74 -74
  603. teradataml/data/jsons/sqle/17.20/TD_RegressionEvaluator.json +137 -137
  604. teradataml/data/jsons/sqle/17.20/TD_RoundColumns.json +93 -93
  605. teradataml/data/jsons/sqle/17.20/TD_RowNormalizeFit.json +127 -127
  606. teradataml/data/jsons/sqle/17.20/TD_RowNormalizeTransform.json +70 -70
  607. teradataml/data/jsons/sqle/17.20/TD_SVM.json +389 -389
  608. teradataml/data/jsons/sqle/17.20/TD_SVMPredict.json +124 -124
  609. teradataml/data/jsons/sqle/17.20/TD_ScaleFit.json +156 -156
  610. teradataml/data/jsons/sqle/17.20/TD_ScaleTransform.json +70 -70
  611. teradataml/data/jsons/sqle/17.20/TD_SentimentExtractor.json +193 -193
  612. teradataml/data/jsons/sqle/17.20/TD_Silhouette.json +142 -142
  613. teradataml/data/jsons/sqle/17.20/TD_SimpleImputeFit.json +147 -147
  614. teradataml/data/jsons/sqle/17.20/TD_SimpleImputeTransform.json +48 -48
  615. teradataml/data/jsons/sqle/17.20/TD_StrApply.json +240 -240
  616. teradataml/data/jsons/sqle/17.20/TD_TargetEncodingFit.json +248 -248
  617. teradataml/data/jsons/sqle/17.20/TD_TargetEncodingTransform.json +75 -75
  618. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +192 -192
  619. teradataml/data/jsons/sqle/17.20/TD_TrainTestSplit.json +142 -142
  620. teradataml/data/jsons/sqle/17.20/TD_UnivariateStatistics.json +117 -117
  621. teradataml/data/jsons/sqle/17.20/TD_VectorDistance.json +182 -182
  622. teradataml/data/jsons/sqle/17.20/TD_WhichMax.json +52 -52
  623. teradataml/data/jsons/sqle/17.20/TD_WhichMin.json +52 -52
  624. teradataml/data/jsons/sqle/17.20/TD_WordEmbeddings.json +241 -241
  625. teradataml/data/jsons/sqle/17.20/TD_XGBoost.json +312 -312
  626. teradataml/data/jsons/sqle/17.20/TD_XGBoostPredict.json +182 -182
  627. teradataml/data/jsons/sqle/17.20/TD_ZTest.json +170 -170
  628. teradataml/data/jsons/sqle/17.20/Unpack.json +188 -188
  629. teradataml/data/jsons/sqle/17.20/nPath.json +269 -269
  630. teradataml/data/jsons/tableoperator/17.00/read_nos.json +197 -197
  631. teradataml/data/jsons/tableoperator/17.05/read_nos.json +197 -197
  632. teradataml/data/jsons/tableoperator/17.05/write_nos.json +194 -194
  633. teradataml/data/jsons/tableoperator/17.10/read_nos.json +183 -183
  634. teradataml/data/jsons/tableoperator/17.10/write_nos.json +194 -194
  635. teradataml/data/jsons/tableoperator/17.20/read_nos.json +182 -182
  636. teradataml/data/jsons/tableoperator/17.20/write_nos.json +223 -223
  637. teradataml/data/jsons/uaf/17.20/TD_ACF.json +149 -149
  638. teradataml/data/jsons/uaf/17.20/TD_ARIMAESTIMATE.json +409 -409
  639. teradataml/data/jsons/uaf/17.20/TD_ARIMAFORECAST.json +79 -79
  640. teradataml/data/jsons/uaf/17.20/TD_ARIMAVALIDATE.json +151 -151
  641. teradataml/data/jsons/uaf/17.20/TD_BINARYMATRIXOP.json +109 -109
  642. teradataml/data/jsons/uaf/17.20/TD_BINARYSERIESOP.json +107 -107
  643. teradataml/data/jsons/uaf/17.20/TD_BREUSCH_GODFREY.json +87 -87
  644. teradataml/data/jsons/uaf/17.20/TD_BREUSCH_PAGAN_GODFREY.json +106 -106
  645. teradataml/data/jsons/uaf/17.20/TD_CONVOLVE.json +80 -80
  646. teradataml/data/jsons/uaf/17.20/TD_CONVOLVE2.json +67 -67
  647. teradataml/data/jsons/uaf/17.20/TD_CUMUL_PERIODOGRAM.json +91 -91
  648. teradataml/data/jsons/uaf/17.20/TD_DFFT.json +136 -136
  649. teradataml/data/jsons/uaf/17.20/TD_DFFT2.json +148 -148
  650. teradataml/data/jsons/uaf/17.20/TD_DFFT2CONV.json +108 -108
  651. teradataml/data/jsons/uaf/17.20/TD_DFFTCONV.json +109 -109
  652. teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +86 -86
  653. teradataml/data/jsons/uaf/17.20/TD_DIFF.json +91 -91
  654. teradataml/data/jsons/uaf/17.20/TD_DTW.json +116 -116
  655. teradataml/data/jsons/uaf/17.20/TD_DURBIN_WATSON.json +100 -100
  656. teradataml/data/jsons/uaf/17.20/TD_EXTRACT_RESULTS.json +38 -38
  657. teradataml/data/jsons/uaf/17.20/TD_FITMETRICS.json +100 -100
  658. teradataml/data/jsons/uaf/17.20/TD_GENSERIES4FORMULA.json +84 -84
  659. teradataml/data/jsons/uaf/17.20/TD_GENSERIES4SINUSOIDS.json +70 -70
  660. teradataml/data/jsons/uaf/17.20/TD_GOLDFELD_QUANDT.json +152 -152
  661. teradataml/data/jsons/uaf/17.20/TD_HOLT_WINTERS_FORECAST.json +313 -313
  662. teradataml/data/jsons/uaf/17.20/TD_IDFFT.json +57 -57
  663. teradataml/data/jsons/uaf/17.20/TD_IDFFT2.json +94 -94
  664. teradataml/data/jsons/uaf/17.20/TD_INPUTVALIDATOR.json +63 -63
  665. teradataml/data/jsons/uaf/17.20/TD_LINEAR_REGR.json +181 -181
  666. teradataml/data/jsons/uaf/17.20/TD_LINESPEC.json +102 -102
  667. teradataml/data/jsons/uaf/17.20/TD_MAMEAN.json +182 -182
  668. teradataml/data/jsons/uaf/17.20/TD_MATRIXMULTIPLY.json +67 -67
  669. teradataml/data/jsons/uaf/17.20/TD_MINFO.json +66 -66
  670. teradataml/data/jsons/uaf/17.20/TD_MULTIVAR_REGR.json +178 -178
  671. teradataml/data/jsons/uaf/17.20/TD_PACF.json +114 -114
  672. teradataml/data/jsons/uaf/17.20/TD_PORTMAN.json +118 -118
  673. teradataml/data/jsons/uaf/17.20/TD_POWERSPEC.json +175 -175
  674. teradataml/data/jsons/uaf/17.20/TD_POWERTRANSFORM.json +97 -97
  675. teradataml/data/jsons/uaf/17.20/TD_RESAMPLE.json +173 -173
  676. teradataml/data/jsons/uaf/17.20/TD_SEASONALNORMALIZE.json +136 -136
  677. teradataml/data/jsons/uaf/17.20/TD_SELECTION_CRITERIA.json +89 -89
  678. teradataml/data/jsons/uaf/17.20/TD_SIGNIF_PERIODICITIES.json +79 -79
  679. teradataml/data/jsons/uaf/17.20/TD_SIGNIF_RESIDMEAN.json +67 -67
  680. teradataml/data/jsons/uaf/17.20/TD_SIMPLEEXP.json +184 -184
  681. teradataml/data/jsons/uaf/17.20/TD_SINFO.json +57 -57
  682. teradataml/data/jsons/uaf/17.20/TD_SMOOTHMA.json +162 -162
  683. teradataml/data/jsons/uaf/17.20/TD_TRACKINGOP.json +100 -100
  684. teradataml/data/jsons/uaf/17.20/TD_UNDIFF.json +111 -111
  685. teradataml/data/jsons/uaf/17.20/TD_UNNORMALIZE.json +95 -95
  686. teradataml/data/jsons/uaf/17.20/TD_WHITES_GENERAL.json +77 -77
  687. teradataml/data/kmeans_example.json +17 -17
  688. teradataml/data/kmeans_us_arrests_data.csv +0 -0
  689. teradataml/data/knn_example.json +18 -18
  690. teradataml/data/knnrecommender_example.json +6 -6
  691. teradataml/data/knnrecommenderpredict_example.json +12 -12
  692. teradataml/data/lar_example.json +17 -17
  693. teradataml/data/larpredict_example.json +30 -30
  694. teradataml/data/lc_new_predictors.csv +5 -5
  695. teradataml/data/lc_new_reference.csv +9 -9
  696. teradataml/data/lda_example.json +8 -8
  697. teradataml/data/ldainference_example.json +14 -14
  698. teradataml/data/ldatopicsummary_example.json +8 -8
  699. teradataml/data/levendist_input.csv +13 -13
  700. teradataml/data/levenshteindistance_example.json +10 -10
  701. teradataml/data/linreg_example.json +9 -9
  702. teradataml/data/load_example_data.py +326 -323
  703. teradataml/data/loan_prediction.csv +295 -295
  704. teradataml/data/lungcancer.csv +138 -138
  705. teradataml/data/mappingdata.csv +12 -12
  706. teradataml/data/milk_timeseries.csv +157 -157
  707. teradataml/data/min_max_titanic.csv +4 -4
  708. teradataml/data/minhash_example.json +6 -6
  709. teradataml/data/ml_ratings.csv +7547 -7547
  710. teradataml/data/ml_ratings_10.csv +2445 -2445
  711. teradataml/data/model1_table.csv +5 -5
  712. teradataml/data/model2_table.csv +5 -5
  713. teradataml/data/models/iris_db_glm_model.pmml +56 -56
  714. teradataml/data/models/iris_db_xgb_model.pmml +4471 -4471
  715. teradataml/data/modularity_example.json +12 -12
  716. teradataml/data/movavg_example.json +7 -7
  717. teradataml/data/mtx1.csv +7 -7
  718. teradataml/data/mtx2.csv +13 -13
  719. teradataml/data/multi_model_classification.csv +401 -0
  720. teradataml/data/multi_model_regression.csv +401 -0
  721. teradataml/data/mvdfft8.csv +9 -9
  722. teradataml/data/naivebayes_example.json +9 -9
  723. teradataml/data/naivebayespredict_example.json +19 -19
  724. teradataml/data/naivebayestextclassifier2_example.json +6 -6
  725. teradataml/data/naivebayestextclassifier_example.json +8 -8
  726. teradataml/data/naivebayestextclassifierpredict_example.json +20 -20
  727. teradataml/data/name_Find_configure.csv +10 -10
  728. teradataml/data/namedentityfinder_example.json +14 -14
  729. teradataml/data/namedentityfinderevaluator_example.json +10 -10
  730. teradataml/data/namedentityfindertrainer_example.json +6 -6
  731. teradataml/data/nb_iris_input_test.csv +31 -31
  732. teradataml/data/nb_iris_input_train.csv +121 -121
  733. teradataml/data/nbp_iris_model.csv +13 -13
  734. teradataml/data/ner_extractor_text.csv +2 -2
  735. teradataml/data/ner_sports_test2.csv +29 -29
  736. teradataml/data/ner_sports_train.csv +501 -501
  737. teradataml/data/nerevaluator_example.json +5 -5
  738. teradataml/data/nerextractor_example.json +18 -18
  739. teradataml/data/nermem_sports_test.csv +17 -17
  740. teradataml/data/nermem_sports_train.csv +50 -50
  741. teradataml/data/nertrainer_example.json +6 -6
  742. teradataml/data/ngrams_example.json +6 -6
  743. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Aggregate Functions using SQLAlchemy.ipynb +1455 -1455
  744. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Arithmetic Functions Using SQLAlchemy.ipynb +1993 -1993
  745. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Bit-Byte Manipulation Functions using SQLAlchemy.ipynb +1492 -1492
  746. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Built-in functions using SQLAlchemy.ipynb +536 -536
  747. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Regular Expressions Using SQLAlchemy.ipynb +570 -570
  748. teradataml/data/notebooks/sqlalchemy/Teradata Vantage String Functions Using SQLAlchemy.ipynb +2559 -2559
  749. teradataml/data/notebooks/sqlalchemy/Teradata Vantage Window Aggregate Functions using SQLAlchemy.ipynb +2911 -2911
  750. teradataml/data/notebooks/sqlalchemy/Using Generic SQLAlchemy ClauseElements teradataml DataFrame assign method.ipynb +698 -698
  751. teradataml/data/notebooks/sqlalchemy/teradataml filtering using SQLAlchemy ClauseElements.ipynb +784 -784
  752. teradataml/data/npath_example.json +23 -23
  753. teradataml/data/ntree_example.json +14 -14
  754. teradataml/data/numeric_strings.csv +4 -4
  755. teradataml/data/numerics.csv +4 -4
  756. teradataml/data/ocean_buoy.csv +17 -17
  757. teradataml/data/ocean_buoy2.csv +17 -17
  758. teradataml/data/ocean_buoys.csv +27 -27
  759. teradataml/data/ocean_buoys2.csv +10 -10
  760. teradataml/data/ocean_buoys_nonpti.csv +28 -28
  761. teradataml/data/ocean_buoys_seq.csv +29 -29
  762. teradataml/data/openml_example.json +63 -0
  763. teradataml/data/optional_event_table.csv +4 -4
  764. teradataml/data/orders1.csv +11 -11
  765. teradataml/data/orders1_12.csv +12 -12
  766. teradataml/data/orders_ex.csv +4 -4
  767. teradataml/data/pack_example.json +8 -8
  768. teradataml/data/package_tracking.csv +19 -19
  769. teradataml/data/package_tracking_pti.csv +18 -18
  770. teradataml/data/pagerank_example.json +13 -13
  771. teradataml/data/paragraphs_input.csv +6 -6
  772. teradataml/data/pathanalyzer_example.json +7 -7
  773. teradataml/data/pathgenerator_example.json +7 -7
  774. teradataml/data/phrases.csv +7 -7
  775. teradataml/data/pivot_example.json +8 -8
  776. teradataml/data/pivot_input.csv +22 -22
  777. teradataml/data/playerRating.csv +31 -31
  778. teradataml/data/postagger_example.json +6 -6
  779. teradataml/data/posttagger_output.csv +44 -44
  780. teradataml/data/production_data.csv +16 -16
  781. teradataml/data/production_data2.csv +7 -7
  782. teradataml/data/randomsample_example.json +31 -31
  783. teradataml/data/randomwalksample_example.json +8 -8
  784. teradataml/data/rank_table.csv +6 -6
  785. teradataml/data/ref_mobile_data.csv +4 -4
  786. teradataml/data/ref_mobile_data_dense.csv +2 -2
  787. teradataml/data/ref_url.csv +17 -17
  788. teradataml/data/restaurant_reviews.csv +7 -7
  789. teradataml/data/river_data.csv +145 -145
  790. teradataml/data/roc_example.json +7 -7
  791. teradataml/data/roc_input.csv +101 -101
  792. teradataml/data/rule_inputs.csv +6 -6
  793. teradataml/data/rule_table.csv +2 -2
  794. teradataml/data/sales.csv +7 -7
  795. teradataml/data/sales_transaction.csv +501 -501
  796. teradataml/data/salesdata.csv +342 -342
  797. teradataml/data/sample_cities.csv +2 -2
  798. teradataml/data/sample_shapes.csv +10 -10
  799. teradataml/data/sample_streets.csv +2 -2
  800. teradataml/data/sampling_example.json +15 -15
  801. teradataml/data/sax_example.json +8 -8
  802. teradataml/data/scale_example.json +23 -23
  803. teradataml/data/scale_housing.csv +11 -11
  804. teradataml/data/scale_housing_test.csv +6 -6
  805. teradataml/data/scale_stat.csv +11 -11
  806. teradataml/data/scalebypartition_example.json +13 -13
  807. teradataml/data/scalemap_example.json +13 -13
  808. teradataml/data/scalesummary_example.json +12 -12
  809. teradataml/data/score_category.csv +101 -101
  810. teradataml/data/score_summary.csv +4 -4
  811. teradataml/data/script_example.json +9 -9
  812. teradataml/data/scripts/deploy_script.py +65 -0
  813. teradataml/data/scripts/mapper.R +20 -0
  814. teradataml/data/scripts/mapper.py +15 -15
  815. teradataml/data/scripts/mapper_replace.py +15 -15
  816. teradataml/data/scripts/sklearn/__init__.py +0 -0
  817. teradataml/data/scripts/sklearn/sklearn_fit.py +175 -0
  818. teradataml/data/scripts/sklearn/sklearn_fit_predict.py +135 -0
  819. teradataml/data/scripts/sklearn/sklearn_function.template +113 -0
  820. teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +158 -0
  821. teradataml/data/scripts/sklearn/sklearn_neighbors.py +152 -0
  822. teradataml/data/scripts/sklearn/sklearn_score.py +128 -0
  823. teradataml/data/scripts/sklearn/sklearn_transform.py +179 -0
  824. teradataml/data/seeds.csv +10 -10
  825. teradataml/data/sentenceextractor_example.json +6 -6
  826. teradataml/data/sentiment_extract_input.csv +11 -11
  827. teradataml/data/sentiment_train.csv +16 -16
  828. teradataml/data/sentiment_word.csv +20 -20
  829. teradataml/data/sentiment_word_input.csv +19 -19
  830. teradataml/data/sentimentextractor_example.json +24 -24
  831. teradataml/data/sentimenttrainer_example.json +8 -8
  832. teradataml/data/sequence_table.csv +10 -10
  833. teradataml/data/seriessplitter_example.json +7 -7
  834. teradataml/data/sessionize_example.json +17 -17
  835. teradataml/data/sessionize_table.csv +116 -116
  836. teradataml/data/setop_test1.csv +24 -24
  837. teradataml/data/setop_test2.csv +22 -22
  838. teradataml/data/soc_nw_edges.csv +10 -10
  839. teradataml/data/soc_nw_vertices.csv +7 -7
  840. teradataml/data/souvenir_timeseries.csv +167 -167
  841. teradataml/data/sparse_iris_attribute.csv +5 -5
  842. teradataml/data/sparse_iris_test.csv +121 -121
  843. teradataml/data/sparse_iris_train.csv +601 -601
  844. teradataml/data/star1.csv +6 -6
  845. teradataml/data/state_transition.csv +5 -5
  846. teradataml/data/stock_data.csv +53 -53
  847. teradataml/data/stock_movement.csv +11 -11
  848. teradataml/data/stock_vol.csv +76 -76
  849. teradataml/data/stop_words.csv +8 -8
  850. teradataml/data/store_sales.csv +37 -37
  851. teradataml/data/stringsimilarity_example.json +7 -7
  852. teradataml/data/strsimilarity_input.csv +13 -13
  853. teradataml/data/students.csv +101 -101
  854. teradataml/data/svm_iris_input_test.csv +121 -121
  855. teradataml/data/svm_iris_input_train.csv +481 -481
  856. teradataml/data/svm_iris_model.csv +7 -7
  857. teradataml/data/svmdense_example.json +9 -9
  858. teradataml/data/svmdensepredict_example.json +18 -18
  859. teradataml/data/svmsparse_example.json +7 -7
  860. teradataml/data/svmsparsepredict_example.json +13 -13
  861. teradataml/data/svmsparsesummary_example.json +7 -7
  862. teradataml/data/target_mobile_data.csv +13 -13
  863. teradataml/data/target_mobile_data_dense.csv +5 -5
  864. teradataml/data/templatedata.csv +1201 -1201
  865. teradataml/data/templates/open_source_ml.json +9 -0
  866. teradataml/data/teradataml_example.json +73 -1
  867. teradataml/data/test_classification.csv +101 -0
  868. teradataml/data/test_loan_prediction.csv +53 -53
  869. teradataml/data/test_pacf_12.csv +37 -37
  870. teradataml/data/test_prediction.csv +101 -0
  871. teradataml/data/test_regression.csv +101 -0
  872. teradataml/data/test_river2.csv +109 -109
  873. teradataml/data/text_inputs.csv +6 -6
  874. teradataml/data/textchunker_example.json +7 -7
  875. teradataml/data/textclassifier_example.json +6 -6
  876. teradataml/data/textclassifier_input.csv +7 -7
  877. teradataml/data/textclassifiertrainer_example.json +6 -6
  878. teradataml/data/textmorph_example.json +5 -5
  879. teradataml/data/textparser_example.json +15 -15
  880. teradataml/data/texttagger_example.json +11 -11
  881. teradataml/data/texttokenizer_example.json +6 -6
  882. teradataml/data/texttrainer_input.csv +11 -11
  883. teradataml/data/tf_example.json +6 -6
  884. teradataml/data/tfidf_example.json +13 -13
  885. teradataml/data/tfidf_input1.csv +201 -201
  886. teradataml/data/tfidf_train.csv +6 -6
  887. teradataml/data/time_table1.csv +535 -535
  888. teradataml/data/time_table2.csv +14 -14
  889. teradataml/data/timeseriesdata.csv +1601 -1601
  890. teradataml/data/timeseriesdatasetsd4.csv +105 -105
  891. teradataml/data/titanic.csv +892 -892
  892. teradataml/data/token_table.csv +696 -696
  893. teradataml/data/train_multiclass.csv +101 -0
  894. teradataml/data/train_regression.csv +101 -0
  895. teradataml/data/train_regression_multiple_labels.csv +101 -0
  896. teradataml/data/train_tracking.csv +27 -27
  897. teradataml/data/transformation_table.csv +5 -5
  898. teradataml/data/transformation_table_new.csv +1 -1
  899. teradataml/data/tv_spots.csv +16 -16
  900. teradataml/data/twod_climate_data.csv +117 -117
  901. teradataml/data/uaf_example.json +475 -475
  902. teradataml/data/univariatestatistics_example.json +8 -8
  903. teradataml/data/unpack_example.json +9 -9
  904. teradataml/data/unpivot_example.json +9 -9
  905. teradataml/data/unpivot_input.csv +8 -8
  906. teradataml/data/us_air_pass.csv +36 -36
  907. teradataml/data/us_population.csv +624 -624
  908. teradataml/data/us_states_shapes.csv +52 -52
  909. teradataml/data/varmax_example.json +17 -17
  910. teradataml/data/vectordistance_example.json +25 -25
  911. teradataml/data/ville_climatedata.csv +121 -121
  912. teradataml/data/ville_tempdata.csv +12 -12
  913. teradataml/data/ville_tempdata1.csv +12 -12
  914. teradataml/data/ville_temperature.csv +11 -11
  915. teradataml/data/waveletTable.csv +1605 -1605
  916. teradataml/data/waveletTable2.csv +1605 -1605
  917. teradataml/data/weightedmovavg_example.json +8 -8
  918. teradataml/data/wft_testing.csv +5 -5
  919. teradataml/data/wine_data.csv +1600 -0
  920. teradataml/data/word_embed_input_table1.csv +5 -5
  921. teradataml/data/word_embed_input_table2.csv +4 -4
  922. teradataml/data/word_embed_model.csv +22 -22
  923. teradataml/data/words_input.csv +13 -13
  924. teradataml/data/xconvolve_complex_left.csv +6 -6
  925. teradataml/data/xconvolve_complex_leftmulti.csv +6 -6
  926. teradataml/data/xgboost_example.json +35 -35
  927. teradataml/data/xgboostpredict_example.json +31 -31
  928. teradataml/dataframe/copy_to.py +1764 -1698
  929. teradataml/dataframe/data_transfer.py +2753 -2745
  930. teradataml/dataframe/dataframe.py +17545 -16946
  931. teradataml/dataframe/dataframe_utils.py +1837 -1740
  932. teradataml/dataframe/fastload.py +611 -603
  933. teradataml/dataframe/indexer.py +424 -424
  934. teradataml/dataframe/setop.py +1179 -1166
  935. teradataml/dataframe/sql.py +10090 -6432
  936. teradataml/dataframe/sql_function_parameters.py +439 -388
  937. teradataml/dataframe/sql_functions.py +652 -652
  938. teradataml/dataframe/sql_interfaces.py +220 -220
  939. teradataml/dataframe/vantage_function_types.py +674 -630
  940. teradataml/dataframe/window.py +693 -692
  941. teradataml/dbutils/__init__.py +3 -3
  942. teradataml/dbutils/dbutils.py +1167 -1150
  943. teradataml/dbutils/filemgr.py +267 -267
  944. teradataml/gen_ai/__init__.py +2 -2
  945. teradataml/gen_ai/convAI.py +472 -472
  946. teradataml/geospatial/__init__.py +3 -3
  947. teradataml/geospatial/geodataframe.py +1105 -1094
  948. teradataml/geospatial/geodataframecolumn.py +392 -387
  949. teradataml/geospatial/geometry_types.py +925 -925
  950. teradataml/hyperparameter_tuner/__init__.py +1 -1
  951. teradataml/hyperparameter_tuner/optimizer.py +3783 -2993
  952. teradataml/hyperparameter_tuner/utils.py +281 -187
  953. teradataml/lib/aed_0_1.dll +0 -0
  954. teradataml/lib/libaed_0_1.dylib +0 -0
  955. teradataml/lib/libaed_0_1.so +0 -0
  956. teradataml/libaed_0_1.dylib +0 -0
  957. teradataml/libaed_0_1.so +0 -0
  958. teradataml/opensource/__init__.py +1 -0
  959. teradataml/opensource/sklearn/__init__.py +1 -0
  960. teradataml/opensource/sklearn/_class.py +255 -0
  961. teradataml/opensource/sklearn/_sklearn_wrapper.py +1668 -0
  962. teradataml/opensource/sklearn/_wrapper_utils.py +268 -0
  963. teradataml/opensource/sklearn/constants.py +54 -0
  964. teradataml/options/__init__.py +121 -124
  965. teradataml/options/configure.py +337 -336
  966. teradataml/options/display.py +176 -176
  967. teradataml/plot/__init__.py +2 -2
  968. teradataml/plot/axis.py +1388 -1388
  969. teradataml/plot/constants.py +15 -15
  970. teradataml/plot/figure.py +398 -398
  971. teradataml/plot/plot.py +760 -760
  972. teradataml/plot/query_generator.py +83 -83
  973. teradataml/plot/subplot.py +216 -216
  974. teradataml/scriptmgmt/UserEnv.py +3788 -3761
  975. teradataml/scriptmgmt/__init__.py +3 -3
  976. teradataml/scriptmgmt/lls_utils.py +1616 -1604
  977. teradataml/series/series.py +532 -532
  978. teradataml/series/series_utils.py +71 -71
  979. teradataml/table_operators/Apply.py +949 -917
  980. teradataml/table_operators/Script.py +1719 -1982
  981. teradataml/table_operators/TableOperator.py +1207 -1616
  982. teradataml/table_operators/__init__.py +2 -3
  983. teradataml/table_operators/apply_query_generator.py +262 -262
  984. teradataml/table_operators/query_generator.py +507 -507
  985. teradataml/table_operators/table_operator_query_generator.py +460 -460
  986. teradataml/table_operators/table_operator_util.py +631 -639
  987. teradataml/table_operators/templates/dataframe_apply.template +184 -184
  988. teradataml/table_operators/templates/dataframe_map.template +176 -176
  989. teradataml/table_operators/templates/script_executor.template +170 -170
  990. teradataml/utils/dtypes.py +684 -684
  991. teradataml/utils/internal_buffer.py +84 -84
  992. teradataml/utils/print_versions.py +205 -205
  993. teradataml/utils/utils.py +410 -410
  994. teradataml/utils/validators.py +2239 -2115
  995. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.0.dist-info}/METADATA +270 -41
  996. teradataml-20.0.0.0.dist-info/RECORD +1038 -0
  997. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.0.dist-info}/WHEEL +1 -1
  998. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.0.dist-info}/zip-safe +1 -1
  999. teradataml/analytics/mle/AdaBoost.py +0 -651
  1000. teradataml/analytics/mle/AdaBoostPredict.py +0 -564
  1001. teradataml/analytics/mle/Antiselect.py +0 -342
  1002. teradataml/analytics/mle/Arima.py +0 -641
  1003. teradataml/analytics/mle/ArimaPredict.py +0 -477
  1004. teradataml/analytics/mle/Attribution.py +0 -1070
  1005. teradataml/analytics/mle/Betweenness.py +0 -658
  1006. teradataml/analytics/mle/Burst.py +0 -711
  1007. teradataml/analytics/mle/CCM.py +0 -600
  1008. teradataml/analytics/mle/CCMPrepare.py +0 -324
  1009. teradataml/analytics/mle/CFilter.py +0 -460
  1010. teradataml/analytics/mle/ChangePointDetection.py +0 -572
  1011. teradataml/analytics/mle/ChangePointDetectionRT.py +0 -477
  1012. teradataml/analytics/mle/Closeness.py +0 -737
  1013. teradataml/analytics/mle/ConfusionMatrix.py +0 -420
  1014. teradataml/analytics/mle/Correlation.py +0 -477
  1015. teradataml/analytics/mle/Correlation2.py +0 -573
  1016. teradataml/analytics/mle/CoxHazardRatio.py +0 -679
  1017. teradataml/analytics/mle/CoxPH.py +0 -556
  1018. teradataml/analytics/mle/CoxSurvival.py +0 -478
  1019. teradataml/analytics/mle/CumulativeMovAvg.py +0 -363
  1020. teradataml/analytics/mle/DTW.py +0 -623
  1021. teradataml/analytics/mle/DWT.py +0 -564
  1022. teradataml/analytics/mle/DWT2D.py +0 -599
  1023. teradataml/analytics/mle/DecisionForest.py +0 -716
  1024. teradataml/analytics/mle/DecisionForestEvaluator.py +0 -363
  1025. teradataml/analytics/mle/DecisionForestPredict.py +0 -561
  1026. teradataml/analytics/mle/DecisionTree.py +0 -830
  1027. teradataml/analytics/mle/DecisionTreePredict.py +0 -528
  1028. teradataml/analytics/mle/ExponentialMovAvg.py +0 -418
  1029. teradataml/analytics/mle/FMeasure.py +0 -402
  1030. teradataml/analytics/mle/FPGrowth.py +0 -734
  1031. teradataml/analytics/mle/FrequentPaths.py +0 -695
  1032. teradataml/analytics/mle/GLM.py +0 -558
  1033. teradataml/analytics/mle/GLML1L2.py +0 -547
  1034. teradataml/analytics/mle/GLML1L2Predict.py +0 -519
  1035. teradataml/analytics/mle/GLMPredict.py +0 -529
  1036. teradataml/analytics/mle/HMMDecoder.py +0 -945
  1037. teradataml/analytics/mle/HMMEvaluator.py +0 -901
  1038. teradataml/analytics/mle/HMMSupervised.py +0 -521
  1039. teradataml/analytics/mle/HMMUnsupervised.py +0 -572
  1040. teradataml/analytics/mle/Histogram.py +0 -561
  1041. teradataml/analytics/mle/IDWT.py +0 -476
  1042. teradataml/analytics/mle/IDWT2D.py +0 -493
  1043. teradataml/analytics/mle/IdentityMatch.py +0 -763
  1044. teradataml/analytics/mle/Interpolator.py +0 -918
  1045. teradataml/analytics/mle/KMeans.py +0 -485
  1046. teradataml/analytics/mle/KNN.py +0 -627
  1047. teradataml/analytics/mle/KNNRecommender.py +0 -488
  1048. teradataml/analytics/mle/KNNRecommenderPredict.py +0 -581
  1049. teradataml/analytics/mle/LAR.py +0 -439
  1050. teradataml/analytics/mle/LARPredict.py +0 -478
  1051. teradataml/analytics/mle/LDA.py +0 -548
  1052. teradataml/analytics/mle/LDAInference.py +0 -492
  1053. teradataml/analytics/mle/LDATopicSummary.py +0 -464
  1054. teradataml/analytics/mle/LevenshteinDistance.py +0 -450
  1055. teradataml/analytics/mle/LinReg.py +0 -433
  1056. teradataml/analytics/mle/LinRegPredict.py +0 -438
  1057. teradataml/analytics/mle/MinHash.py +0 -544
  1058. teradataml/analytics/mle/Modularity.py +0 -587
  1059. teradataml/analytics/mle/NEREvaluator.py +0 -410
  1060. teradataml/analytics/mle/NERExtractor.py +0 -595
  1061. teradataml/analytics/mle/NERTrainer.py +0 -458
  1062. teradataml/analytics/mle/NGrams.py +0 -570
  1063. teradataml/analytics/mle/NPath.py +0 -634
  1064. teradataml/analytics/mle/NTree.py +0 -549
  1065. teradataml/analytics/mle/NaiveBayes.py +0 -462
  1066. teradataml/analytics/mle/NaiveBayesPredict.py +0 -513
  1067. teradataml/analytics/mle/NaiveBayesTextClassifier.py +0 -607
  1068. teradataml/analytics/mle/NaiveBayesTextClassifier2.py +0 -531
  1069. teradataml/analytics/mle/NaiveBayesTextClassifierPredict.py +0 -799
  1070. teradataml/analytics/mle/NamedEntityFinder.py +0 -529
  1071. teradataml/analytics/mle/NamedEntityFinderEvaluator.py +0 -414
  1072. teradataml/analytics/mle/NamedEntityFinderTrainer.py +0 -396
  1073. teradataml/analytics/mle/POSTagger.py +0 -417
  1074. teradataml/analytics/mle/Pack.py +0 -411
  1075. teradataml/analytics/mle/PageRank.py +0 -535
  1076. teradataml/analytics/mle/PathAnalyzer.py +0 -426
  1077. teradataml/analytics/mle/PathGenerator.py +0 -367
  1078. teradataml/analytics/mle/PathStart.py +0 -464
  1079. teradataml/analytics/mle/PathSummarizer.py +0 -470
  1080. teradataml/analytics/mle/Pivot.py +0 -471
  1081. teradataml/analytics/mle/ROC.py +0 -425
  1082. teradataml/analytics/mle/RandomSample.py +0 -637
  1083. teradataml/analytics/mle/RandomWalkSample.py +0 -490
  1084. teradataml/analytics/mle/SAX.py +0 -779
  1085. teradataml/analytics/mle/SVMDense.py +0 -677
  1086. teradataml/analytics/mle/SVMDensePredict.py +0 -536
  1087. teradataml/analytics/mle/SVMDenseSummary.py +0 -437
  1088. teradataml/analytics/mle/SVMSparse.py +0 -557
  1089. teradataml/analytics/mle/SVMSparsePredict.py +0 -553
  1090. teradataml/analytics/mle/SVMSparseSummary.py +0 -435
  1091. teradataml/analytics/mle/Sampling.py +0 -549
  1092. teradataml/analytics/mle/Scale.py +0 -565
  1093. teradataml/analytics/mle/ScaleByPartition.py +0 -496
  1094. teradataml/analytics/mle/ScaleMap.py +0 -378
  1095. teradataml/analytics/mle/ScaleSummary.py +0 -320
  1096. teradataml/analytics/mle/SentenceExtractor.py +0 -363
  1097. teradataml/analytics/mle/SentimentEvaluator.py +0 -432
  1098. teradataml/analytics/mle/SentimentExtractor.py +0 -578
  1099. teradataml/analytics/mle/SentimentTrainer.py +0 -405
  1100. teradataml/analytics/mle/SeriesSplitter.py +0 -641
  1101. teradataml/analytics/mle/Sessionize.py +0 -475
  1102. teradataml/analytics/mle/SimpleMovAvg.py +0 -397
  1103. teradataml/analytics/mle/StringSimilarity.py +0 -425
  1104. teradataml/analytics/mle/TF.py +0 -389
  1105. teradataml/analytics/mle/TFIDF.py +0 -504
  1106. teradataml/analytics/mle/TextChunker.py +0 -414
  1107. teradataml/analytics/mle/TextClassifier.py +0 -399
  1108. teradataml/analytics/mle/TextClassifierEvaluator.py +0 -413
  1109. teradataml/analytics/mle/TextClassifierTrainer.py +0 -565
  1110. teradataml/analytics/mle/TextMorph.py +0 -494
  1111. teradataml/analytics/mle/TextParser.py +0 -623
  1112. teradataml/analytics/mle/TextTagger.py +0 -530
  1113. teradataml/analytics/mle/TextTokenizer.py +0 -502
  1114. teradataml/analytics/mle/UnivariateStatistics.py +0 -488
  1115. teradataml/analytics/mle/Unpack.py +0 -526
  1116. teradataml/analytics/mle/Unpivot.py +0 -438
  1117. teradataml/analytics/mle/VarMax.py +0 -776
  1118. teradataml/analytics/mle/VectorDistance.py +0 -762
  1119. teradataml/analytics/mle/WeightedMovAvg.py +0 -400
  1120. teradataml/analytics/mle/XGBoost.py +0 -842
  1121. teradataml/analytics/mle/XGBoostPredict.py +0 -627
  1122. teradataml/analytics/mle/__init__.py +0 -123
  1123. teradataml/analytics/mle/json/adaboost_mle.json +0 -135
  1124. teradataml/analytics/mle/json/adaboostpredict_mle.json +0 -85
  1125. teradataml/analytics/mle/json/antiselect_mle.json +0 -34
  1126. teradataml/analytics/mle/json/antiselect_mle_mle.json +0 -34
  1127. teradataml/analytics/mle/json/arima_mle.json +0 -172
  1128. teradataml/analytics/mle/json/arimapredict_mle.json +0 -52
  1129. teradataml/analytics/mle/json/attribution_mle_mle.json +0 -143
  1130. teradataml/analytics/mle/json/betweenness_mle.json +0 -97
  1131. teradataml/analytics/mle/json/burst_mle.json +0 -140
  1132. teradataml/analytics/mle/json/ccm_mle.json +0 -124
  1133. teradataml/analytics/mle/json/ccmprepare_mle.json +0 -14
  1134. teradataml/analytics/mle/json/cfilter_mle.json +0 -93
  1135. teradataml/analytics/mle/json/changepointdetection_mle.json +0 -92
  1136. teradataml/analytics/mle/json/changepointdetectionrt_mle.json +0 -78
  1137. teradataml/analytics/mle/json/closeness_mle.json +0 -104
  1138. teradataml/analytics/mle/json/confusionmatrix_mle.json +0 -79
  1139. teradataml/analytics/mle/json/correlation_mle.json +0 -86
  1140. teradataml/analytics/mle/json/correlationreduce_mle.json +0 -49
  1141. teradataml/analytics/mle/json/coxhazardratio_mle.json +0 -89
  1142. teradataml/analytics/mle/json/coxph_mle.json +0 -98
  1143. teradataml/analytics/mle/json/coxsurvival_mle.json +0 -79
  1144. teradataml/analytics/mle/json/cumulativemovavg_mle.json +0 -34
  1145. teradataml/analytics/mle/json/decisionforest_mle.json +0 -167
  1146. teradataml/analytics/mle/json/decisionforestevaluator_mle.json +0 -33
  1147. teradataml/analytics/mle/json/decisionforestpredict_mle_mle.json +0 -74
  1148. teradataml/analytics/mle/json/decisiontree_mle.json +0 -194
  1149. teradataml/analytics/mle/json/decisiontreepredict_mle_mle.json +0 -86
  1150. teradataml/analytics/mle/json/dtw_mle.json +0 -97
  1151. teradataml/analytics/mle/json/dwt2d_mle.json +0 -116
  1152. teradataml/analytics/mle/json/dwt_mle.json +0 -101
  1153. teradataml/analytics/mle/json/exponentialmovavg_mle.json +0 -55
  1154. teradataml/analytics/mle/json/fmeasure_mle.json +0 -58
  1155. teradataml/analytics/mle/json/fpgrowth_mle.json +0 -159
  1156. teradataml/analytics/mle/json/frequentpaths_mle.json +0 -129
  1157. teradataml/analytics/mle/json/glm_mle.json +0 -111
  1158. teradataml/analytics/mle/json/glml1l2_mle.json +0 -106
  1159. teradataml/analytics/mle/json/glml1l2predict_mle.json +0 -57
  1160. teradataml/analytics/mle/json/glmpredict_mle_mle.json +0 -74
  1161. teradataml/analytics/mle/json/histogram_mle.json +0 -100
  1162. teradataml/analytics/mle/json/hmmdecoder_mle.json +0 -192
  1163. teradataml/analytics/mle/json/hmmevaluator_mle.json +0 -206
  1164. teradataml/analytics/mle/json/hmmsupervised_mle.json +0 -91
  1165. teradataml/analytics/mle/json/hmmunsupervised_mle.json +0 -114
  1166. teradataml/analytics/mle/json/identitymatch_mle.json +0 -88
  1167. teradataml/analytics/mle/json/idwt2d_mle.json +0 -73
  1168. teradataml/analytics/mle/json/idwt_mle.json +0 -66
  1169. teradataml/analytics/mle/json/interpolator_mle.json +0 -151
  1170. teradataml/analytics/mle/json/kmeans_mle.json +0 -97
  1171. teradataml/analytics/mle/json/knn_mle.json +0 -141
  1172. teradataml/analytics/mle/json/knnrecommender_mle.json +0 -111
  1173. teradataml/analytics/mle/json/knnrecommenderpredict_mle.json +0 -75
  1174. teradataml/analytics/mle/json/lar_mle.json +0 -78
  1175. teradataml/analytics/mle/json/larpredict_mle.json +0 -69
  1176. teradataml/analytics/mle/json/lda_mle.json +0 -130
  1177. teradataml/analytics/mle/json/ldainference_mle.json +0 -78
  1178. teradataml/analytics/mle/json/ldatopicsummary_mle.json +0 -64
  1179. teradataml/analytics/mle/json/levenshteindistance_mle.json +0 -92
  1180. teradataml/analytics/mle/json/linreg_mle.json +0 -42
  1181. teradataml/analytics/mle/json/linregpredict_mle.json +0 -56
  1182. teradataml/analytics/mle/json/minhash_mle.json +0 -113
  1183. teradataml/analytics/mle/json/modularity_mle.json +0 -91
  1184. teradataml/analytics/mle/json/naivebayespredict_mle_mle.json +0 -85
  1185. teradataml/analytics/mle/json/naivebayesreduce_mle.json +0 -52
  1186. teradataml/analytics/mle/json/naivebayestextclassifierpredict_mle_mle.json +0 -147
  1187. teradataml/analytics/mle/json/naivebayestextclassifiertrainer2_mle.json +0 -108
  1188. teradataml/analytics/mle/json/naivebayestextclassifiertrainer_mle.json +0 -102
  1189. teradataml/analytics/mle/json/namedentityfinder_mle.json +0 -84
  1190. teradataml/analytics/mle/json/namedentityfinderevaluatorreduce_mle.json +0 -43
  1191. teradataml/analytics/mle/json/namedentityfindertrainer_mle.json +0 -64
  1192. teradataml/analytics/mle/json/nerevaluator_mle.json +0 -54
  1193. teradataml/analytics/mle/json/nerextractor_mle.json +0 -87
  1194. teradataml/analytics/mle/json/nertrainer_mle.json +0 -89
  1195. teradataml/analytics/mle/json/ngrams_mle.json +0 -137
  1196. teradataml/analytics/mle/json/ngramsplitter_mle_mle.json +0 -137
  1197. teradataml/analytics/mle/json/npath@coprocessor_mle.json +0 -73
  1198. teradataml/analytics/mle/json/ntree@coprocessor_mle.json +0 -123
  1199. teradataml/analytics/mle/json/pack_mle.json +0 -58
  1200. teradataml/analytics/mle/json/pack_mle_mle.json +0 -58
  1201. teradataml/analytics/mle/json/pagerank_mle.json +0 -81
  1202. teradataml/analytics/mle/json/pathanalyzer_mle.json +0 -63
  1203. teradataml/analytics/mle/json/pathgenerator_mle.json +0 -40
  1204. teradataml/analytics/mle/json/pathstart_mle.json +0 -62
  1205. teradataml/analytics/mle/json/pathsummarizer_mle.json +0 -72
  1206. teradataml/analytics/mle/json/pivoting_mle.json +0 -71
  1207. teradataml/analytics/mle/json/postagger_mle.json +0 -51
  1208. teradataml/analytics/mle/json/randomsample_mle.json +0 -131
  1209. teradataml/analytics/mle/json/randomwalksample_mle.json +0 -85
  1210. teradataml/analytics/mle/json/roc_mle.json +0 -73
  1211. teradataml/analytics/mle/json/sampling_mle.json +0 -75
  1212. teradataml/analytics/mle/json/sax_mle.json +0 -154
  1213. teradataml/analytics/mle/json/scale_mle.json +0 -93
  1214. teradataml/analytics/mle/json/scalebypartition_mle.json +0 -89
  1215. teradataml/analytics/mle/json/scalemap_mle.json +0 -44
  1216. teradataml/analytics/mle/json/scalesummary_mle.json +0 -14
  1217. teradataml/analytics/mle/json/sentenceextractor_mle.json +0 -41
  1218. teradataml/analytics/mle/json/sentimentevaluator_mle.json +0 -43
  1219. teradataml/analytics/mle/json/sentimentextractor_mle.json +0 -100
  1220. teradataml/analytics/mle/json/sentimenttrainer_mle.json +0 -68
  1221. teradataml/analytics/mle/json/seriessplitter_mle.json +0 -133
  1222. teradataml/analytics/mle/json/sessionize_mle_mle.json +0 -62
  1223. teradataml/analytics/mle/json/simplemovavg_mle.json +0 -48
  1224. teradataml/analytics/mle/json/stringsimilarity_mle.json +0 -50
  1225. teradataml/analytics/mle/json/stringsimilarity_mle_mle.json +0 -50
  1226. teradataml/analytics/mle/json/svmdense_mle.json +0 -165
  1227. teradataml/analytics/mle/json/svmdensepredict_mle.json +0 -95
  1228. teradataml/analytics/mle/json/svmdensesummary_mle.json +0 -58
  1229. teradataml/analytics/mle/json/svmsparse_mle.json +0 -148
  1230. teradataml/analytics/mle/json/svmsparsepredict_mle_mle.json +0 -103
  1231. teradataml/analytics/mle/json/svmsparsesummary_mle.json +0 -57
  1232. teradataml/analytics/mle/json/textchunker_mle.json +0 -40
  1233. teradataml/analytics/mle/json/textclassifier_mle.json +0 -51
  1234. teradataml/analytics/mle/json/textclassifierevaluator_mle.json +0 -43
  1235. teradataml/analytics/mle/json/textclassifiertrainer_mle.json +0 -103
  1236. teradataml/analytics/mle/json/textmorph_mle.json +0 -63
  1237. teradataml/analytics/mle/json/textparser_mle.json +0 -166
  1238. teradataml/analytics/mle/json/texttagger_mle.json +0 -81
  1239. teradataml/analytics/mle/json/texttokenizer_mle.json +0 -91
  1240. teradataml/analytics/mle/json/tf_mle.json +0 -33
  1241. teradataml/analytics/mle/json/tfidf_mle.json +0 -34
  1242. teradataml/analytics/mle/json/univariatestatistics_mle.json +0 -81
  1243. teradataml/analytics/mle/json/unpack_mle.json +0 -91
  1244. teradataml/analytics/mle/json/unpack_mle_mle.json +0 -91
  1245. teradataml/analytics/mle/json/unpivoting_mle.json +0 -63
  1246. teradataml/analytics/mle/json/varmax_mle.json +0 -176
  1247. teradataml/analytics/mle/json/vectordistance_mle.json +0 -179
  1248. teradataml/analytics/mle/json/weightedmovavg_mle.json +0 -48
  1249. teradataml/analytics/mle/json/xgboost_mle.json +0 -178
  1250. teradataml/analytics/mle/json/xgboostpredict_mle.json +0 -104
  1251. teradataml/analytics/sqle/Antiselect.py +0 -321
  1252. teradataml/analytics/sqle/Attribution.py +0 -603
  1253. teradataml/analytics/sqle/DecisionForestPredict.py +0 -408
  1254. teradataml/analytics/sqle/GLMPredict.py +0 -430
  1255. teradataml/analytics/sqle/MovingAverage.py +0 -543
  1256. teradataml/analytics/sqle/NGramSplitter.py +0 -548
  1257. teradataml/analytics/sqle/NPath.py +0 -632
  1258. teradataml/analytics/sqle/NaiveBayesTextClassifierPredict.py +0 -515
  1259. teradataml/analytics/sqle/Pack.py +0 -388
  1260. teradataml/analytics/sqle/SVMSparsePredict.py +0 -464
  1261. teradataml/analytics/sqle/Sessionize.py +0 -390
  1262. teradataml/analytics/sqle/StringSimilarity.py +0 -400
  1263. teradataml/analytics/sqle/Unpack.py +0 -503
  1264. teradataml/analytics/sqle/json/antiselect_sqle.json +0 -21
  1265. teradataml/analytics/sqle/json/attribution_sqle.json +0 -92
  1266. teradataml/analytics/sqle/json/decisionforestpredict_sqle.json +0 -48
  1267. teradataml/analytics/sqle/json/glmpredict_sqle.json +0 -48
  1268. teradataml/analytics/sqle/json/h2opredict_sqle.json +0 -63
  1269. teradataml/analytics/sqle/json/movingaverage_sqle.json +0 -58
  1270. teradataml/analytics/sqle/json/naivebayestextclassifierpredict_sqle.json +0 -76
  1271. teradataml/analytics/sqle/json/ngramsplitter_sqle.json +0 -126
  1272. teradataml/analytics/sqle/json/npath_sqle.json +0 -67
  1273. teradataml/analytics/sqle/json/pack_sqle.json +0 -47
  1274. teradataml/analytics/sqle/json/pmmlpredict_sqle.json +0 -55
  1275. teradataml/analytics/sqle/json/sessionize_sqle.json +0 -43
  1276. teradataml/analytics/sqle/json/stringsimilarity_sqle.json +0 -39
  1277. teradataml/analytics/sqle/json/svmsparsepredict_sqle.json +0 -74
  1278. teradataml/analytics/sqle/json/unpack_sqle.json +0 -80
  1279. teradataml/catalog/model_cataloging.py +0 -980
  1280. teradataml/config/mlengine_alias_definitions_v1.0 +0 -118
  1281. teradataml/config/mlengine_alias_definitions_v1.1 +0 -127
  1282. teradataml/config/mlengine_alias_definitions_v1.3 +0 -129
  1283. teradataml/table_operators/sandbox_container_util.py +0 -643
  1284. teradataml-17.20.0.7.dist-info/RECORD +0 -1280
  1285. {teradataml-17.20.0.7.dist-info → teradataml-20.0.0.0.dist-info}/top_level.txt +0 -0
@@ -1,2115 +1,2239 @@
1
- import numbers
2
- import os
3
- import pandas as pd
4
- from pathlib import Path
5
- import re
6
- from teradataml.common.constants import TeradataConstants, PTITableConstants, PythonTypes
7
- from teradataml.common.exceptions import TeradataMlException
8
- from teradataml.common.messages import MessageCodes, Messages
9
- from teradataml.utils.dtypes import _Dtypes, _DtypesMappers, _ListOf, _TupleOf
10
- from teradataml.options.configure import configure
11
- from teradataml.dataframe.sql_interfaces import ColumnExpression
12
-
13
- class _Validators:
14
- """
15
- A class containing set of utilities that can be used for validations of various kinds.
16
- Currently, this facilitates the validations done for:
17
- 1. Analytic function execution engine: (_validate_engine)
18
- 2. Validation for the vantage_version: (_validate_vantage_version)
19
- 3. Validate whether argument has passed with empty string or not: (_validate_input_columns_not_empty)
20
- 4. Validate for permitted values of the argument: (_validate_permitted_values)
21
- 5. Validate function arguments. (_validate_function_arguments) This specifically validates for
22
- 1. Argument types check.
23
- 2. Argument is empty or not.
24
- 3. Permitted values check.
25
- 6. Validate for missing required arguments.
26
- 7. Validate column exists in a DataFrame or not. (_validate_column_exists_in_dataframe)
27
- 8. Validate required arguments are missing or not. (_validate_missing_required_arguments)
28
- 9. Validate whether function install location is set.
29
- 10. Validate whether the table exist in the schema or not
30
- 11. Validate whether the given file is not empty, given absolute file path.
31
- 12. Validate whether "arg1" and "arg2" are mutually inclusive.
32
- """
33
- @staticmethod
34
- def __getTypeAsStr(type_list):
35
- """
36
- Function to convert type to string.
37
-
38
- PARAMETERS:
39
- type_list
40
- Required Argument.
41
- A tuple of types or a type to be converted to string.
42
-
43
- RAISES:
44
- None
45
-
46
- RETURNS:
47
- A list of strings representing types in type_list.
48
-
49
- EXAMPLES:
50
- _Validators.__getTypeAsStr(type_list)
51
- """
52
- type_as_str = []
53
- if isinstance(type_list, tuple):
54
- for typ in type_list:
55
- if isinstance(typ, tuple):
56
- for typ1 in typ:
57
- type_as_str.append(typ1.__name__)
58
- elif isinstance(typ, (_ListOf, _TupleOf)):
59
- type_as_str.append(str(typ))
60
- elif typ.__name__ == "DataFrame":
61
- type_as_str.append("teradataml DataFrame")
62
- else:
63
- type_as_str.append(typ.__name__)
64
-
65
- if isinstance(type_list, type):
66
- if type_list.__name__ == "DataFrame":
67
- type_as_str.append("teradataml DataFrame")
68
- else:
69
- type_as_str.append(type_list.__name__)
70
-
71
- if isinstance(type_list, (_ListOf, _TupleOf)):
72
- type_as_str.append(str(type_list))
73
-
74
- return type_as_str
75
-
76
- @staticmethod
77
- def _check_isinstance(obj, class_or_tuple):
78
- """
79
- Function checks whether an object is an instance of a class.
80
-
81
- PARAMETER
82
- obj:
83
- Required Argument.
84
- Specifies the object to check instance of.
85
-
86
- class_or_tuple:
87
- Required Argument.
88
- Specifies the type or tuple of types to check instance against.
89
-
90
- RAISES:
91
- None.
92
-
93
- RETURNS:
94
- True, if obj is instance of class_or_tuple
95
-
96
- EXAMPLES:
97
- _Validators._check_isinstance(obj, (int, list, str))
98
- """
99
- # If obj is of type bool and type to check against contains int, then we must
100
- # check/validate the instance as type(obj) == class_or_tuple.
101
- # bool is subclass of int, hence isinstance(True, int) will always return true.
102
- # And we would like to return false, as bool is not a int.
103
- if not isinstance(obj, bool):
104
- # If obj of any type other than bool, then we shall use "isinstance()"
105
- # to perform type checks.
106
- return isinstance(obj, class_or_tuple)
107
-
108
- else:
109
- # 'obj' is of type bool.
110
- if isinstance(class_or_tuple, tuple):
111
- if int not in class_or_tuple:
112
- # If class_or_tuple is instance of tuple and int is not in class_or_tuple
113
- # use "isinstance()" to validate type check for obj.
114
- return isinstance(obj, class_or_tuple)
115
- else:
116
- return type(obj) in class_or_tuple
117
-
118
- else: # isinstance(class_or_tuple, type):
119
- if int != class_or_tuple:
120
- # If class_or_tuple is instance of type and class_or_tuple is not an int
121
- # use "isinstance()" to validate type check for obj.
122
- return isinstance(obj, class_or_tuple)
123
- else:
124
- return type(obj) == class_or_tuple
125
-
126
- @staticmethod
127
- def _validate_columnexpression_dataframe_has_columns(columns,
128
- arg_name,
129
- column_expression):
130
- """
131
- DESCRIPTION:
132
- Function to check whether column name(s) available in dataframe
133
- or not from a given column. This function is used currently
134
- only for Window Aggregates.
135
-
136
- PARAMETERS:
137
- columns:
138
- Required Argument.
139
- Specifies the name or list of names of columns to be validated
140
- for existence.
141
- Types: str or List of strings
142
-
143
- arg_name:
144
- Required Argument.
145
- Specifies the name of the argument.
146
- Types: str
147
-
148
- column_expression:
149
- Required Argument.
150
- Specifies teradataml DataFrame Column to check against for
151
- column existence.
152
- Types: ColumnExpression
153
-
154
- RAISES:
155
- ValueError
156
-
157
- RETURNS:
158
- bool
159
-
160
- EXAMPLES:
161
- _Validators._validate_dataframe_has_argument_columns_from_column(self.data_sequence_column,
162
- "data_sequence_column",
163
- self.data.col)
164
- """
165
- if not columns:
166
- return True
167
-
168
- # Converting columns to a list if string is passed.
169
- if not isinstance(columns, list):
170
- columns = [columns]
171
-
172
- df_columns = [df_column.name for df_column in column_expression.table.columns]
173
-
174
- # Let's validate existence of each column one by one.
175
- for column_name in columns:
176
- # If column name does not exist in DataFrame of a column, raise the exception.
177
- if column_name not in df_columns:
178
- message = "{}. Check the argument '{}'".format(sorted(df_columns), arg_name)
179
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
180
- column_name,
181
- message
182
- ))
183
- return True
184
-
185
- @staticmethod
186
- def _validate_dataframe_has_argument_columns(columns, column_arg, data, data_arg, is_partition_arg=False):
187
- """
188
- Function to check whether column names in columns are present in given dataframe or not.
189
- This function is used currently only for Analytics wrappers.
190
-
191
- PARAMETERS:
192
- columns:
193
- Required Argument.
194
- Specifies name or list of names of columns to be validated for existence.
195
- Types: str or List of strings
196
-
197
- column_arg:
198
- Required Argument.
199
- Specifies the name of the argument.
200
- Types: str
201
-
202
- data:
203
- Required Argument.
204
- Specifies teradataml DataFrame to check against for column existence.
205
- Types: teradataml DataFrame
206
-
207
- data_arg:
208
- Required Argument.
209
- Specifies the name of the dataframe argument.
210
- Types: str
211
-
212
- isPartitionArg:
213
- Optional Argument.
214
- Specifies a bool argument notifying, whether argument being validate is
215
- Partition argument or not.
216
- Types: bool
217
-
218
- RAISES:
219
- TeradataMlException - TDMLDF_COLUMN_IN_ARG_NOT_FOUND column(s) does not exist in a dataframe.
220
-
221
- EXAMPLES:
222
- _Validators._validate_dataframe_has_argument_columns(self.data_sequence_column, "data_sequence_column", self.data, "data")
223
- _Validators._validate_dataframe_has_argument_columns(self.data_partition_column, "data_sequence_column", self.data, "data", true)
224
- """
225
- if is_partition_arg and columns is None:
226
- return True
227
-
228
- if columns is None:
229
- return True
230
-
231
- _Validators._validate_dependent_argument(column_arg, columns, data_arg, data)
232
-
233
- # Converting columns to a list if string is passed.
234
- if not isinstance(columns, list) and columns is not None:
235
- columns = [columns]
236
-
237
- total_columns = []
238
-
239
- for column in columns:
240
- for separator in TeradataConstants.RANGE_SEPARATORS.value:
241
- if column is None:
242
- total_columns.append(column)
243
- elif column[0] == "-":
244
- # If column has exclude operator "-".
245
- # For example incase of "-[50]", let database handle validation.
246
- if re.match(r'-\[\d+\]', column) is not None:
247
- continue
248
- total_columns.append(column[1:])
249
- elif column.count(separator) == 1:
250
- # Following cases can occur:
251
- # '3:5' or 'colA:colE'
252
- # ':4' or ':columnD' specifies all columns up to and including the column with index 4(or columnD).
253
- # '4:' or 'columnD:' specifies the column with index 4(or columnD) and all columns after it.
254
- # ':' specifies all columns in the table.
255
-
256
- try:
257
- # Check if its a sinlge column with one separator. For e.g. column:A.
258
- # If yes, just continue.
259
- _Validators._validate_column_exists_in_dataframe(column, data._metaexpr)
260
- continue
261
- except:
262
- # User has provided range value.
263
- column_names = column.split(separator)
264
- if (len(column_names) == 2 and
265
- any([column_names[0].isdigit(), column_names[1].isdigit()]) and
266
- not all([column_names[0].isdigit(), column_names[1].isdigit()]) and
267
- not "" in column_names):
268
- # Raises Exception if column range has mixed types. For e.g. "4:XYZ".
269
- err_msg = Messages.get_message(MessageCodes.MIXED_TYPES_IN_COLUMN_RANGE)
270
- raise ValueError(err_msg.format(column_arg))
271
-
272
- for col in column_names:
273
- if not col.isdigit() and col != "":
274
- total_columns.append(col)
275
-
276
- elif column.count(separator) > 1:
277
- continue
278
- else:
279
- total_columns.append(column)
280
-
281
- return _Validators._validate_column_exists_in_dataframe(total_columns, data._metaexpr, column_arg=column_arg,
282
- data_arg=data_arg)
283
-
284
- @staticmethod
285
- def _validate_column_exists_in_dataframe(columns, metaexpr, case_insensitive=False, column_arg=None,
286
- data_arg=None, for_table=False):
287
- """
288
- Method to check whether column or list of columns exists in a teradataml DataFrame or not.
289
-
290
- PARAMETERS:
291
- columns:
292
- Required Argument.
293
- Specifies name or list of names of columns to be validated for existence.
294
- Types: str or List of strings
295
-
296
- metaexpr:
297
- Required Argument.
298
- Specifies a teradataml DataFrame metaexpr to be validated against.
299
- Types: MetaExpression
300
-
301
- case_insensitive:
302
- Optional Argument.
303
- Specifies a flag, that determines whether to check for column existence in
304
- case_insensitive manner or not.
305
- Default Value: False (Case-Sensitive lookup)
306
- Types: bool
307
-
308
- column_arg:
309
- Optional Argument.
310
- Specifies the name of the argument.
311
- Types: str
312
-
313
- data_arg:
314
- Optional Argument.
315
- Specifies the name of the dataframe argument or name of the table.
316
- Types: str
317
-
318
- for_table:
319
- Optional Argument.
320
- Specifies whether error should be raised against table or DataFrame, i.e.,
321
- when columns are not available and "for_table" is set to False, then
322
- exception message mentions column(s) not available in DataFrame. When
323
- columns are not available and "for_table" is set to true, then exception
324
- message mentions column(s) not available in Table.
325
- Types: str
326
-
327
- RAISES:
328
- ValueError
329
- TDMLDF_DROP_INVALID_COL - If columns not found in metaexpr.
330
-
331
- RETURNS:
332
- None
333
-
334
- EXAMPLES:
335
- _Validators._validate_column_exists_in_dataframe(["col1", "col2"], self.metaexpr)
336
-
337
- """
338
- if columns is None:
339
- return True
340
-
341
- # If just a column name is passed, convert it to a list.
342
- if isinstance(columns, str):
343
- columns = [columns]
344
-
345
- # Constructing New unquotted column names for selected columns ONLY using Parent _metaexpr
346
- if case_insensitive:
347
- # If lookup has to be a case insensitive then convert the
348
- # metaexpr columns name to lower case.
349
- unquoted_df_columns = [c.name.replace('"', "").lower() for c in metaexpr.c]
350
- else:
351
- unquoted_df_columns = [c.name.replace('"', "") for c in metaexpr.c]
352
-
353
- # Let's validate existence of each column one by one.
354
- for column_name in columns:
355
- if column_name is None:
356
- column_name = str(column_name)
357
-
358
- if case_insensitive:
359
- # If lookup has to be a case insensitive then convert the
360
- # column name to lower case.
361
- column_name = column_name.lower()
362
-
363
- # If column name does not exist in metaexpr, raise the exception
364
- if not column_name.replace('"', "") in unquoted_df_columns:
365
- if column_arg and data_arg:
366
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_COLUMN_IN_ARG_NOT_FOUND,
367
- column_name,
368
- column_arg,
369
- data_arg,
370
- "Table" if for_table else "DataFrame"))
371
- else:
372
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
373
- column_name, sorted(unquoted_df_columns)))
374
-
375
- return True
376
-
377
- @staticmethod
378
- def _validate_engine(engine):
379
- """
380
- Function to validate whether the argument engine is supported or not.
381
-
382
- PARAMETERS:
383
- engine:
384
- Required Argument.
385
- Specifies the type of the engine.
386
-
387
- RETURNS:
388
- True, if engine is supported.
389
-
390
- RAISES:
391
- TeradataMLException
392
-
393
- EXAMPLES:
394
- _Validators._validate_engine("ENGINE_SQL")
395
- """
396
- supported_engines = TeradataConstants.SUPPORTED_ENGINES.value
397
- if engine not in supported_engines.keys():
398
- raise TeradataMlException(Messages.get_message(
399
- MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED).format(engine,
400
- ", ".join(supported_engines.keys())),
401
- MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED)
402
-
403
- return True
404
-
405
- @staticmethod
406
- def _validate_function_arguments(arg_list, skip_empty_check = None):
407
- """
408
- Method to verify that the input arguments are of valid data type except for
409
- argument of DataFrameType.
410
-
411
- PARAMETERS:
412
- arg_list:
413
- Required Argument.
414
- Specifies a list of arguments, expected types are mentioned as type or tuple.
415
- argInfoMatrix = []
416
- argInfoMatrix.append(["data", data, False, (DataFrame)])
417
- argInfoMatrix.append(["centers", centers, True, (int, list)])
418
- argInfoMatrix.append(["threshold", threshold, True, (float)])
419
- Types: List of Lists
420
- skip_empty_check:
421
- Optional Argument.
422
- Specifies column name and values for which to skip check.
423
- Types: Dictionary specifying column name to values mapping.
424
-
425
- RAISES:
426
- Error if arguments are not of valid datatype
427
-
428
- EXAMPLES:
429
- _Validators._validate_function_arguments(arg_list)
430
- """
431
- invalid_arg_names = []
432
- invalid_arg_types = []
433
-
434
- typeCheckFailed = False
435
-
436
- for args in arg_list:
437
- num_args = len(args)
438
- if not isinstance(args[0], str):
439
- raise TypeError("First element in argument information matrix should be str.")
440
-
441
- if not isinstance(args[2], bool):
442
- raise TypeError("Third element in argument information matrix should be bool.")
443
-
444
- if not (isinstance(args[3], tuple) or isinstance(args[3], type) or
445
- isinstance(args[3], (_ListOf, _TupleOf))):
446
- err_msg = "Fourth element in argument information matrix should be a 'tuple of types' or 'type' type."
447
- raise TypeError(err_msg)
448
-
449
- if num_args >= 5:
450
- if not isinstance(args[4], bool):
451
- raise TypeError("Fifth element in argument information matrix should be bool.")
452
-
453
- #
454
- # Let's validate argument types.
455
- #
456
- # Verify datatypes for arguments which are required or the optional arguments are not None
457
- if ((args[2] == True and args[1] is not None) or (args[2] == False)):
458
- # Validate the types of argument, if expected types are instance of tuple or type
459
- dtype_list = _Validators.__getTypeAsStr(args[3])
460
-
461
- if isinstance(args[3], tuple) and list in args[3]:
462
- # If list of data types contain 'list', which means argument can accept list of values.
463
- dtype_list.remove('list')
464
- valid_types_str = ", ".join(dtype_list) + " or list of values of type(s): " + ", ".join(
465
- dtype_list)
466
-
467
- if isinstance(args[1], list):
468
- # If argument contains list of values, check each value.
469
- for value in args[1]:
470
- # If not valid datatype add invalid_arg to dictionary and break
471
- if not _Validators._check_isinstance(value, args[3]):
472
- invalid_arg_names.append(args[0])
473
- invalid_arg_types.append(valid_types_str)
474
- typeCheckFailed = True
475
- break
476
- elif not _Validators._check_isinstance(args[1], args[3]):
477
- # Argument is not of type list.
478
- invalid_arg_names.append(args[0])
479
- invalid_arg_types.append(valid_types_str)
480
- typeCheckFailed = True
481
-
482
- elif isinstance(args[3], tuple):
483
- # Argument can accept values of multiple types, but not list.
484
- valid_types_str = " or ".join(dtype_list)
485
- if not _Validators._check_isinstance(args[1], args[3]):
486
- invalid_arg_names.append(args[0])
487
- invalid_arg_types.append(valid_types_str)
488
- typeCheckFailed = True
489
- else:
490
- # Argument can accept values of single type.
491
- valid_types_str = " or ".join(dtype_list)
492
- if not _Validators._check_isinstance(args[1], args[3]):
493
- invalid_arg_names.append(args[0])
494
- invalid_arg_types.append(valid_types_str)
495
- typeCheckFailed = True
496
-
497
- #
498
- # Validate the arguments for empty value
499
- #
500
- if not typeCheckFailed and len(args) >= 5:
501
- if args[4]:
502
- _Validators._validate_input_columns_not_empty(args[1], args[0], skip_empty_check)
503
-
504
- #
505
- # Validate the arguments for permitted values
506
- #
507
- if not typeCheckFailed and len(args) >= 6:
508
- if args[5] is not None:
509
- _Validators._validate_permitted_values(args[1], args[5], args[0], supported_types=args[3])
510
-
511
- if typeCheckFailed:
512
- if len(invalid_arg_names) != 0:
513
- raise TypeError(Messages.get_message(MessageCodes.UNSUPPORTED_DATATYPE,
514
- invalid_arg_names, invalid_arg_types))
515
-
516
- return True
517
-
518
- @staticmethod
519
- def _validate_input_columns_not_empty(arg, arg_name, skip_empty_check = None):
520
- """
521
- Function to check whether argument is empty string or not.
522
-
523
- PARAMETERS:
524
- arg:
525
- Required Argument.
526
- Argument value (string) to be checked whether it is empty or not.
527
- skip_empty_check:
528
- Optional Argument.
529
- Specifies column name and values for which to skip check.
530
- Types: Dictionary specifying column name to values mapping.
531
- Example: When '\n', '\t' are valid values for argument 'arg_name', this check should be skipped.
532
-
533
- RAISES:
534
- Error if argument contains empty string
535
-
536
- EXAMPLES:
537
- _Validators._validate_input_columns_not_empty(arg)
538
- """
539
- if isinstance(arg, str):
540
- if not (skip_empty_check and arg_name in skip_empty_check.keys() and arg in skip_empty_check[arg_name]):
541
- if ((len(arg.strip()) == 0)):
542
- raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
543
-
544
- if isinstance(arg, list):
545
- if len(arg) == 0:
546
- raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name).replace("empty string", "an empty list"))
547
-
548
- for col in arg:
549
- if not (skip_empty_check and arg_name in skip_empty_check.keys() and col in skip_empty_check[arg_name]):
550
- if isinstance(col, str):
551
- if (not (col is None) and ((len(col.strip()) == 0))):
552
- raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
553
- return True
554
-
555
- @staticmethod
556
- def _validate_missing_required_arguments(arg_list):
557
- """
558
- Method to check whether the required arguments passed to the function are missing
559
- or not. Only wrapper's use this function.
560
-
561
- PARAMETERS:
562
- arg_list - A list
563
- The argument is expected to be a list of arguments
564
-
565
- RAISES:
566
- If any arguments are missing exception raised with missing arguments which are
567
- required.
568
-
569
- EXAMPLES:
570
- An example input matrix will be:
571
- arg_info_matrix = []
572
- arg_info_matrix.append(["data", data, False, DataFrame])
573
- arg_info_matrix.append(["centers", centers, True, int])
574
- arg_info_matrix.append(["threshold", threshold, True, "float"])
575
- awu = AnalyticsWrapperUtils()
576
- awu._validate_missing_required_arguments(arg_info_matrix)
577
- """
578
- miss_args = []
579
- for args in arg_list:
580
- '''
581
- Check for missing arguments which are required. If args[2] is false
582
- the argument is required.
583
- The following conditions are true :
584
- 1. The argument should not be None and an empty string.
585
- then argument is required which is missing and Raises exception.
586
- '''
587
- if args[2] == False and args[1] is None:
588
- miss_args.append(args[0])
589
-
590
- if (len(miss_args)>0):
591
- raise TeradataMlException(Messages.get_message(MessageCodes.MISSING_ARGS,miss_args),
592
- MessageCodes.MISSING_ARGS)
593
- return True
594
-
595
- @staticmethod
596
- def _validate_permitted_values(arg, permitted_values, arg_name, case_insensitive=True, includeNone=True, supported_types=None):
597
- """
598
- Function to check the permitted values for the argument.
599
-
600
- PARAMETERS:
601
- arg:
602
- Required Argument.
603
- Argument value to be checked against permitted values from the list.
604
- Types: string
605
-
606
- permitted_values:
607
- Required Argument.
608
- A list of strings/ints/floats containing permitted values for the argument.
609
- Types: string
610
-
611
- arg_name:
612
- Required Argument.
613
- Name of the argument to be printed in the error message.
614
- Types: string
615
-
616
- case_insensitive:
617
- Optional Argument.
618
- Specifies whether values in permitted_values could be case sensitive.
619
- Types: bool
620
-
621
- includeNone:
622
- Optional Argument.
623
- Specifies whether 'None' can be included as valid value.
624
- Types: bool
625
-
626
- supported_types:
627
- Optional Argument.
628
- Specifies the supported datatypes for the argument.
629
- Types: str
630
-
631
- RAISES:
632
- Error if argument is not present in the list
633
-
634
- EXAMPLES:
635
- permitted_values = ["LOGISTIC", "BINOMIAL", "POISSON", "GAUSSIAN", "GAMMA", "INVERSE_GAUSSIAN", "NEGATIVE_BINOMIAL"]
636
- arg = "LOGISTIC"
637
- _Validators._validate_permitted_values(arg, permitted_values, argument_name)
638
- """
639
- # validating permitted_values type which has to be a list.
640
- _Validators._validate_function_arguments([["permitted_values", permitted_values, False, (list)]])
641
-
642
- if case_insensitive:
643
- permitted_values = [item.upper() if isinstance(item, str) else item for item in permitted_values]
644
-
645
- # Validate whether argument has value from permitted values list or not.
646
- if not isinstance(arg, list) and arg is not None:
647
- arg = [arg]
648
-
649
- if arg is not None:
650
- # Getting arguments in uppercase to compare with 'permitted_values'
651
- arg_upper = []
652
- for element in arg:
653
- if element is None:
654
- # If element is None, then we shall add a string "None"
655
- if includeNone:
656
- continue
657
- arg_upper.append(str(element))
658
- elif isinstance(element, str):
659
- # If element is of type str, then we will convert it to upper case.
660
- if case_insensitive:
661
- arg_upper.append(element.upper())
662
- else:
663
- arg_upper.append(element)
664
- else:
665
- # For any other type of element, we will keep it as is.
666
- arg_upper.append(element)
667
-
668
- # Form the list of datatypes not present in the datatypes of permitted_values.
669
- add_types = ()
670
- if supported_types is not None:
671
- # Convert type and tuple to list.
672
- supported_types = [supported_types] if isinstance(supported_types, type) else supported_types
673
- # Form a list for types which are not there in type of permitted_values.
674
- add_types = tuple(set(list(supported_types)) - set(list(map(type, permitted_values))) - set([list]))
675
- # Remove the arguments from arg_upper which are an instance of the add_types.
676
- if len(add_types) > 0:
677
- [arg_upper.remove(arg) for arg in arg_upper if isinstance(arg, add_types)]
678
-
679
- # If any of the arguments in 'arg_upper' not in 'permitted_values',
680
- # then, raise exception
681
- upper_invalid_values = list(set(arg_upper).difference(set(permitted_values)))
682
-
683
- if len(upper_invalid_values) > 0:
684
- # Getting actual invalid arguments (non-upper)
685
- invalid_values = []
686
- for element in arg:
687
- if element is None:
688
- if includeNone:
689
- continue
690
- invalid_values.append(str(element))
691
- elif isinstance(element, str) and element.upper() in upper_invalid_values:
692
- invalid_values.append(element)
693
- elif element in upper_invalid_values:
694
- invalid_values.append(element)
695
- invalid_values.sort()
696
-
697
- # Concatenate the message for datatypes not present in datatypes of permitted_values.
698
- if len(add_types) > 0 :
699
- add_types = _Validators.__getTypeAsStr(add_types)
700
- add_types = " or ".join(add_types)
701
- permitted_values = "{} {}".format(permitted_values, "or any values of type {}".format(add_types))
702
-
703
- raise ValueError(
704
- Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
705
- ', '.join([str(item) if not isinstance(item, str) else item for item in invalid_values]),
706
- arg_name, permitted_values))
707
- # If any of the arguments doesn't want to include None as valid value
708
- # then, raise exception.
709
- else:
710
- if not includeNone:
711
- raise ValueError(
712
- Messages.get_message(MessageCodes.INVALID_ARG_VALUE, None,
713
- arg_name, permitted_values), MessageCodes.INVALID_ARG_VALUE)
714
- # Returns True when arg is None or there is no Exception
715
- return True
716
-
717
- @staticmethod
718
- def _validate_positive_int(arg, arg_name, lbound=0, ubound=None, lbound_inclusive=False):
719
- """
720
- Validation to check arg values is a positive int.
721
-
722
- PARAMETERS:
723
- arg:
724
- Required Argument.
725
- Specifies the number to be validated for positive INT.
726
- Types: int
727
-
728
- arg_name:
729
- Required Argument.
730
- Specifies the name of the argument to be printed in error message.
731
- Types: str
732
-
733
- lbound:
734
- Optional Argument.
735
- Specifies the lower bound value for arg.
736
- Note: Value provided to this argument is exclusive, i.e., if value provided
737
- to this argument 10, then error will be raised for any value of arg <= 10.
738
- It can be made inclusive, if lbound_inclusive is set to 'True'.
739
- Types: int
740
-
741
- ubound:
742
- Optional Argument.
743
- Specifies the upper bound value for arg.
744
- Note: Value provided to this argument is inclusive, i.e., if value provided
745
- to this argument 10, then error will be raised for any value of arg > 10.
746
- Types: int
747
-
748
- lbound_inclusive:
749
- Optional Argument.
750
- Specifies a boolean flag telling API whether to lbound value is inclusive or not.
751
- Types: bool
752
-
753
- RAISES:
754
- ValueError - If arg is not a positive int.
755
-
756
- RETURNS:
757
- True - If success
758
-
759
- EXAMPLES:
760
- # Validate n for value > 0
761
- _Validators._validate_positive_int(n, "n")
762
- # Validate n for value > 0 and value <= 32767
763
- _Validators._validate_positive_int(n, "n", ubound="32767")
764
- """
765
- if arg is None:
766
- return True
767
-
768
- if ubound is None:
769
- if lbound_inclusive:
770
- if not isinstance(arg, numbers.Integral) or arg < lbound:
771
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than or equal to"))
772
- else:
773
- if not isinstance(arg, numbers.Integral) or arg <= lbound:
774
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than"))
775
- else:
776
- if not isinstance(arg, numbers.Integral) or arg <= lbound or arg > ubound:
777
- raise ValueError(Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(
778
- arg_name, "greater than {}".format(lbound),
779
- " and less than or equal to {}".format(ubound)))
780
-
781
- return True
782
-
783
- @staticmethod
784
- def _validate_argument_range(arg,
785
- arg_name,
786
- lbound=None,
787
- ubound=None,
788
- lbound_inclusive=False,
789
- ubound_inclusive=False):
790
- """
791
- DESCRIPTION:
792
- Validation to check arg is in specified range.
793
-
794
- PARAMETERS:
795
- arg:
796
- Required Argument.
797
- Specifies the number to be validated for range check.
798
- Types: int
799
-
800
- arg_name:
801
- Required Argument.
802
- Specifies the name of the argument to be printed in error message.
803
- Types: str
804
-
805
- lbound:
806
- Optional Argument.
807
- Specifies the lower bound value for arg.
808
- Note:
809
- Value provided to this argument is exclusive, i.e., if
810
- value provided to this argument 10, then error will be
811
- raised for any value of arg < 10. It can be made inclusive,
812
- if lbound_inclusive is set to 'True'.
813
- Types: int OR float
814
-
815
- ubound:
816
- Optional Argument.
817
- Specifies the upper bound value for arg.
818
- Note:
819
- Value provided to this argument is exclusive, i.e., if
820
- value provided to this argument 10, then error will be
821
- raised for any value of arg > 10. It can be made inclusive,
822
- if ubound_inclusive is set to 'True'.
823
- Types: int OR float
824
-
825
- lbound_inclusive:
826
- Optional Argument.
827
- Specifies whether lbound value is inclusive or not. When set to True,
828
- value is inclusive, otherwise exclusive.
829
- Default Value: False
830
- Types: bool
831
-
832
- ubound_inclusive:
833
- Optional Argument.
834
- Specifies whether ubound value is inclusive or not. When set to True,
835
- value is inclusive, otherwise exclusive.
836
- Default Value: False
837
- Types: bool
838
-
839
- RAISES:
840
- ValueError - If arg is not in the specified range.
841
-
842
- RETURNS:
843
- True - If success
844
-
845
- EXAMPLES:
846
- # Validate n for value in between of 10 and 20.
847
- _Validators._validate_argument_range(n, 10, 20)
848
- """
849
- if lbound is None and ubound is None:
850
- return True
851
-
852
- # Raise error if lower bound is greater than upper bound.
853
- if lbound is not None and ubound is not None and (lbound > ubound):
854
- raise ValueError("Lowerbound value '{}' must be less than upperbound value '{}'.".format(lbound, ubound))
855
-
856
- # If argument is None, do not validate the argument.
857
- if arg is None:
858
- return True
859
-
860
- is_arg_in_lower_bound, is_arg_in_upper_bound = True, True
861
- lbound_msg, ubound_msg = "", ""
862
-
863
- # Check for lower bound.
864
- if lbound is not None:
865
- if lbound_inclusive:
866
- is_arg_in_lower_bound = arg >= lbound
867
- lbound_msg = "greater than or equal to {}".format(lbound)
868
- else:
869
- is_arg_in_lower_bound = arg > lbound
870
- lbound_msg = "greater than {}".format(lbound)
871
-
872
- # Check for upper bound.
873
- if ubound is not None:
874
- if ubound_inclusive:
875
- is_arg_in_upper_bound = arg <= ubound
876
- ubound_msg = "less than or equal to {}".format(ubound)
877
- else:
878
- is_arg_in_upper_bound = arg < ubound
879
- ubound_msg = "less than {}".format(ubound)
880
-
881
- if not (is_arg_in_lower_bound and is_arg_in_upper_bound):
882
- # If both lower bound and upper bound error messages available, append 'and' to
883
- # upper bound message.
884
- if lbound_msg and ubound_msg:
885
- ubound_msg = " and {}".format(ubound_msg)
886
- raise ValueError(
887
- Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(arg_name, lbound_msg, ubound_msg))
888
-
889
- return True
890
-
891
- @staticmethod
892
- def _validate_vantage_version(vantage_version):
893
- """
894
- Function to verify whether the given vantage_version is
895
- supported or not.
896
-
897
- PARAMETERS:
898
- vantage_version:
899
- Required Argument.
900
- Specifies the vantage version.
901
-
902
- RETURNS:
903
- True, if the current vantage version is supported or not.
904
-
905
- RAISES:
906
- TeradataMLException
907
-
908
- EXAMPLES:
909
- _Validators._validate_vantage_version("vantage1.0")
910
- """
911
- supported_vantage_versions = TeradataConstants.SUPPORTED_VANTAGE_VERSIONS.value
912
-
913
- # Raise exception if the vantage version is not supported.
914
- if vantage_version not in supported_vantage_versions.keys():
915
- err_ = Messages.get_message(MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED). \
916
- format(vantage_version, ", ".join(supported_vantage_versions.keys()))
917
- raise TeradataMlException(err_,
918
- MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED)
919
-
920
- return True
921
-
922
- @staticmethod
923
- def _validate_timebucket_duration(timebucket_duration, timebucket_duration_arg_name='timebucket_duration'):
924
- """
925
- Internal function to validate timeduration_bucket specified when creating a
926
- Primary Time Index (PTI) table.
927
-
928
- PARAMETERS:
929
- timebucket_duration:
930
- Specifies the timebucket_duration passed to a function().
931
- Types: str
932
-
933
- timebucket_duration_arg_name:
934
- Specifies the name of the argument to be displayed in the error message.
935
- Types: str
936
-
937
- RETURNS:
938
- True if the value is valid.
939
-
940
- RAISES:
941
- ValueError or TeradataMlException when the value is invalid.
942
-
943
- EXAMPLES:
944
- _Validators._validate_timebucket_duration('HOURS(2)')
945
- _Validators._validate_timebucket_duration('2hours')
946
- _Validators._validate_timebucket_duration('ayear') # Invalid
947
- """
948
- # Return True is it is not specified or is None since it is optional
949
- if timebucket_duration is None:
950
- return True
951
-
952
- # Check if notation if formal or shorthand (beginning with a digit)
953
- if timebucket_duration[0].isdigit():
954
- valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_SHORTHAND.value
955
- pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_SHORT.value
956
- normalized_timebucket_duration = timebucket_duration.lower()
957
- else:
958
- valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_FORMAL.value
959
- pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_FORMAL.value
960
- normalized_timebucket_duration = timebucket_duration.upper()
961
-
962
- for timebucket_duration_notation in valid_timebucket_durations:
963
- pattern = re.compile(pattern_to_use.format(timebucket_duration_notation))
964
- match = pattern.match(normalized_timebucket_duration)
965
- if match is not None:
966
- n = int(match.group(1))
967
- _Validators._validate_positive_int(n, "n", ubound=32767)
968
-
969
- # Looks like the value is valid
970
- return True
971
-
972
- # Match not found
973
- raise ValueError(Messages.get_message(
974
- MessageCodes.INVALID_ARG_VALUE).format(timebucket_duration, timebucket_duration_arg_name,
975
- 'a valid time unit of format time_unit(n) or it\'s short hand '
976
- 'equivalent notation'))
977
-
978
- @staticmethod
979
- def _validate_column_type(df, col, col_arg, expected_types, raiseError = True):
980
- """
981
- Internal function to validate the type of an input DataFrame column against
982
- a list of expected types.
983
-
984
- PARAMETERS
985
- df:
986
- Required Argument.
987
- Specifies the input teradataml DataFrame which has the column to be tested
988
- for type.
989
- Types: teradataml DataFrame
990
-
991
- col:
992
- Required Argument.
993
- Specifies the column in the input DataFrame to be tested for type.
994
- Types: str
995
-
996
- col_arg:
997
- Required Argument.
998
- Specifies the name of the argument used to pass the column name.
999
- Types: str
1000
-
1001
- expected_types:
1002
- Required Argument.
1003
- Specifies a list of teradatasqlachemy datatypes that the column is
1004
- expected to be of type.
1005
- Types: list of SQLAlchemy types
1006
-
1007
- raiseError:
1008
- Optional Argument.
1009
- Specifies a boolean flag that decides whether to raise error or just return True or False.
1010
- Default Values: True, raise exception if column is not of desired type.
1011
- Types: bool
1012
-
1013
- RETURNS:
1014
- True, when the columns is of an expected type.
1015
-
1016
- RAISES:
1017
- TeradataMlException, when the columns is not one of the expected types.
1018
-
1019
- EXAMPLES:
1020
- _Validators._validate_column_type(df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1021
- """
1022
- if not any(isinstance(df[col].type, t) for t in expected_types):
1023
- if raiseError:
1024
- raise TeradataMlException(Messages.get_message(MessageCodes.INVALID_COLUMN_TYPE).
1025
- format(col_arg, df[col].type, ' or '.join(expected_type.__visit_name__
1026
- for expected_type in expected_types)),
1027
- MessageCodes.INVALID_COLUMN_TYPE)
1028
- else:
1029
- return False
1030
-
1031
- return True
1032
-
1033
- @staticmethod
1034
- def _validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1035
- """
1036
- Internal function to validate the for unsupported data types of an input DataFrame column for
1037
- an aggreagate function.
1038
-
1039
- PARAMETERS
1040
- operation:
1041
- Required Argument.
1042
- Specifies the name of the aggregate operation.
1043
- Types: str
1044
-
1045
- columns:
1046
- Required Argument.
1047
- Specifies the column names to be validated for datatype check.
1048
- Types: str
1049
-
1050
- td_column_names_and_types:
1051
- Required Argument.
1052
- Specifies the input teradataml DataFrames column name to SQLAlchemy type mapper.
1053
- Types: str
1054
-
1055
- RETURNS:
1056
- None
1057
-
1058
- RAISES:
1059
- TeradataMlException, when the columns is not one of the expected types.
1060
-
1061
- EXAMPLES:
1062
- _Validators._validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1063
- """
1064
- # Check if the user provided columns has unsupported datatype for aggregate operation or not.
1065
- # Get the list of unsupported types for aggregate function.
1066
- unsupported_types = _Dtypes._get_unsupported_data_types_for_aggregate_operations(operation)
1067
- invalid_columns = []
1068
-
1069
- for column in columns:
1070
- if isinstance(td_column_names_and_types[column.lower()], tuple(unsupported_types)):
1071
- invalid_columns.append(
1072
- "({0} - {1})".format(column, td_column_names_and_types[column.lower()]))
1073
-
1074
- if len(invalid_columns) > 0:
1075
- invalid_columns.sort() # helps in catching the columns in
1076
- # lexicographic order
1077
- error = MessageCodes.TDMLDF_AGGREGATE_UNSUPPORTED.value.format(
1078
- ", ".join(invalid_columns), operation)
1079
- msg = Messages.get_message(MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR). \
1080
- format(error)
1081
- raise TeradataMlException(msg, MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR)
1082
-
1083
- @staticmethod
1084
- def _validate_str_arg_length(arg_name, arg_value, op, length):
1085
- """
1086
- Internal function to validate the length of a string passed as an argument.
1087
-
1088
- PARAMETERS
1089
- arg_name:
1090
- Required Argument.
1091
- Specifies the name of the argument for which we need to validate the value length.
1092
- Types: str
1093
-
1094
- arg_value:
1095
- Required Argument.
1096
- Specifies the value passed to the argument.
1097
- Types: str
1098
-
1099
- op:
1100
- Required Argument.
1101
- Specifies the type of check, and can be one of:
1102
- * LT - Less than
1103
- * LE - less than or equal to
1104
- * GT - greater than
1105
- * GE - greater than or equal to
1106
- * EQ - equal to
1107
- * NE - not equal to
1108
- Types: str
1109
- Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1110
-
1111
- length:
1112
- Required Argument.
1113
- Specifies the length against which the 'op' check for the argument value length will be made.
1114
- Types: int
1115
-
1116
- RETURNS:
1117
- None
1118
-
1119
- RAISES:
1120
- ValueError.
1121
-
1122
- EXAMPLES:
1123
- _Validators._validate_str_arg_length("name", "The value", 10):
1124
- """
1125
- return _Validators._validate_arg_length(arg_name=arg_name, arg_value=arg_value, op=op, length=length)
1126
-
1127
- @staticmethod
1128
- def _validate_arg_length(arg_name, arg_value, op, length):
1129
- """
1130
- Internal function to validate the length of an argument.
1131
-
1132
- PARAMETERS
1133
- arg_name:
1134
- Required Argument.
1135
- Specifies the name of the argument for which we need to validate the value length.
1136
- Types: str
1137
-
1138
- arg_value:
1139
- Required Argument.
1140
- Specifies the value passed to the argument.
1141
- Types: str or list or tuple or set or dict
1142
-
1143
- op:
1144
- Required Argument.
1145
- Specifies the type of check, and can be one of:
1146
- * LT - Less than
1147
- * LE - less than or equal to
1148
- * GT - greater than
1149
- * GE - greater than or equal to
1150
- * EQ - equal to
1151
- * NE - not equal to
1152
- Types: str
1153
- Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1154
-
1155
- length:
1156
- Required Argument.
1157
- Specifies the length against which the 'op' check for the argument value length will be made.
1158
- Types: int
1159
-
1160
- RETURNS:
1161
- None
1162
-
1163
- RAISES:
1164
- ValueError.
1165
-
1166
- EXAMPLES:
1167
- _Validators._validate_arg_length("name", [1, 2, 3], 3):
1168
- """
1169
- # Check if the length of the string value for the argument is acceptable.
1170
- # First, check if op is an acceptable operation.
1171
- acceptable_op = {'LT': int.__lt__,
1172
- 'LE': int.__le__,
1173
- 'GT': int.__gt__,
1174
- 'GE': int.__ge__,
1175
- 'EQ': int.__eq__,
1176
- 'NE': int.__ne__
1177
- }
1178
- if op not in acceptable_op:
1179
- raise ValueError(Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
1180
- op, "op", acceptable_op))
1181
-
1182
- # Format the error message with the substring based on the op type.
1183
- errors = {'LT': "less than {}",
1184
- 'LE': "less than or equal to {}",
1185
- 'GT': "greater than {}",
1186
- 'GE': "greater than or equal to {}",
1187
- 'EQ': "equal to {}",
1188
- 'NE': "not equal to {}"
1189
- }
1190
- if not acceptable_op[op](len(arg_value), length):
1191
- if isinstance(arg_value, str):
1192
- raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_STRING_ARG,
1193
- arg_name, errors[op].format(length)))
1194
- raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_ARG, type(arg_value).__name__,
1195
- arg_name, errors[op].format(length)))
1196
- return True
1197
-
1198
- @staticmethod
1199
- def _validate_file_exists(file_path):
1200
- """
1201
- DESCRIPTION:
1202
- Function to validate whether the path specified is a file and if it exists.
1203
-
1204
- PARAMETERS:
1205
- file_path:
1206
- Required Argument.
1207
- Specifies the path of the file.
1208
- Types: str
1209
-
1210
- RETURNS:
1211
- True, if the path is a file and it exists.
1212
-
1213
- RAISES:
1214
- TeradataMLException
1215
-
1216
- EXAMPLES:
1217
- _Validators._validate_file_exists("/data/mapper.py")
1218
- """
1219
- if not Path(file_path).exists() or not os.path.isfile(file_path):
1220
- raise TeradataMlException(
1221
- Messages.get_message(MessageCodes.INPUT_FILE_NOT_FOUND).format(file_path),
1222
- MessageCodes.INPUT_FILE_NOT_FOUND)
1223
-
1224
- return True
1225
-
1226
- @staticmethod
1227
- def _validate_mutually_exclusive_arguments(arg1, err_disp_arg1_name, arg2,
1228
- err_disp_arg2_name, skip_all_none_check=False):
1229
- """
1230
- DESCRIPTION:
1231
- Function to validate whether "arg1" and "arg2" are mutually exclusive.
1232
-
1233
- PARAMETERS:
1234
- arg1:
1235
- Required Argument.
1236
- Specifies the value of argument1.
1237
- Types: Any
1238
-
1239
- err_disp_arg1_name:
1240
- Required Argument.
1241
- Specifies the name of argument1.
1242
- Types: str
1243
-
1244
- arg2:
1245
- Required Argument.
1246
- Specifies the value of argument2.
1247
- Types: Any
1248
-
1249
- err_disp_arg2_name:
1250
- Required Argument.
1251
- Specifies the name of argument2.
1252
- Types: str
1253
-
1254
- skip_all_none_check:
1255
- Optional Argument.
1256
- Specifies whether to skip check when arg1 and arg2 both are None.
1257
- Default Value: False
1258
- Types: bool
1259
-
1260
- RETURNS:
1261
- True, if either arg1 or arg2 is None or both are None.
1262
-
1263
- RAISES:
1264
- TeradataMLException
1265
-
1266
- EXAMPLES:
1267
- _Validators._validate_mutually_exclusive_arguments(arg1, "arg1", arg2, "arg2")
1268
- """
1269
- both_args_none = arg1 is None and arg2 is None
1270
- if skip_all_none_check:
1271
- both_args_none = False
1272
-
1273
- # Either both the arguments are specified or both are None.
1274
- if all([arg1, arg2]) or both_args_none:
1275
- raise TeradataMlException(Messages.get_message(
1276
- MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT, err_disp_arg1_name,
1277
- err_disp_arg2_name), MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT)
1278
- return True
1279
-
1280
- @staticmethod
1281
- def _validate_unexpected_column_type(df, col, col_arg, unexpected_types, check_exist=True, raise_error=True):
1282
- """
1283
- Internal function to validate the column existence and type of an input DataFrame column against
1284
- a list of unexpected types.
1285
-
1286
- PARAMETERS
1287
- df:
1288
- Required Argument.
1289
- Specifies the input teradataml DataFrame which has the column(s) to be tested
1290
- for type.
1291
- Types: teradataml DataFrame
1292
-
1293
- col:
1294
- Required Argument.
1295
- Specifies the column(s) in the input DataFrame to be tested for type.
1296
- Types: str (or) ColumnExpression (or) List of strings(str)
1297
- or ColumnExpressions
1298
-
1299
- col_arg:
1300
- Required Argument.
1301
- Specifies the name of the argument used to pass the column(s) name.
1302
- Types: str
1303
-
1304
- unexpected_types:
1305
- Required Argument.
1306
- Specifies unsupported teradatasqlalcehmy datatypes for the column is
1307
- unexpected to be of type.
1308
- Types: list of SQLAlchemy types
1309
-
1310
- check_exist:
1311
- Optional Argument.
1312
- Specifies a boolean flag that decides whether to check for column is
1313
- existed in DataFrame or not.
1314
- Default Values: True, raise exception if column is not of desired type.
1315
- Types: bool
1316
-
1317
- raise_error:
1318
- Optional Argument.
1319
- Specifies a boolean flag that decides whether to raise error or just return True or False.
1320
- Default Values: True, raise exception if column is not of desired type.
1321
- Types: bool
1322
-
1323
- RETURNS:
1324
- True, when the columns is of an expected type.
1325
-
1326
- RAISES:
1327
- TeradataMlException, when the columns is not one of the expected types.
1328
-
1329
- EXAMPLES:
1330
- _Validators._validate_unexpected_column_type(
1331
- df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1332
- """
1333
-
1334
- columns = [col] if not isinstance(col, list) else col
1335
-
1336
- # Converting "unexpected_types" to tuple as isinstance can accept Tuple
1337
- # of types too.
1338
- unexpected_types = tuple(unexpected_types)
1339
-
1340
- for col in columns:
1341
- # Get the name of the column if "col" is ColumnExpression.
1342
- if not isinstance(col, str):
1343
- col = col.name
1344
-
1345
- # Check for column existence.
1346
- if check_exist:
1347
- _Validators._validate_column_exists_in_dataframe(col, df._metaexpr)
1348
-
1349
- if isinstance(df[col].type, unexpected_types):
1350
- if raise_error:
1351
- invalid_column_types = (col_type.__name__ for col_type in
1352
- unexpected_types)
1353
- error_message = Messages.get_message(MessageCodes.INVALID_COLUMN_DATATYPE,
1354
- col,
1355
- col_arg,
1356
- "Unsupported",
1357
- ", ".join(invalid_column_types))
1358
- raise TeradataMlException(error_message, MessageCodes.INVALID_COLUMN_DATATYPE)
1359
-
1360
- else:
1361
- return False
1362
-
1363
- return True
1364
-
1365
- @staticmethod
1366
- def _validate_dependent_argument(dependent_arg, dependent_arg_value, independent_arg, independent_arg_value,
1367
- msg_arg_value=None):
1368
- """
1369
- DESCRIPTION:
1370
- Function validates if an independent argument is specified or not when
1371
- dependent argument is specified. Raises error, if independent argument
1372
- is not specified and dependent argument is specified, otherwise returns True.
1373
-
1374
- PARAMETERS:
1375
- dependent_arg:
1376
- Required Argument.
1377
- Specifies the name of dependent argument.
1378
- Types: String
1379
-
1380
- dependent_arg_value:
1381
- Required Argument.
1382
- Specifies the value of dependent argument.
1383
- Types: Any
1384
-
1385
- independent_arg:
1386
- Required Argument.
1387
- Specifies the name of independent argument.
1388
- Types: String
1389
-
1390
- independent_arg_value:
1391
- Required Argument.
1392
- Specifies the value of independent argument.
1393
- Types: Any
1394
-
1395
- msg_arg_value:
1396
- Optional Argument.
1397
- Specifies the independent argument value to be printed in message
1398
- instead of "(not None)".
1399
- Types: String
1400
-
1401
- RETURNS:
1402
- True, when the independent argument is present for the dependent
1403
- argument.
1404
-
1405
- RAISES:
1406
- TeradataMlException, when independent argument is not specified and
1407
- dependent argument is specified.
1408
-
1409
- EXAMPLES:
1410
- _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1411
- "independent_arg_name", None)
1412
- _Validators._validate_dependent_argument("dependent_arg_name", None,
1413
- "independent_arg_name", admissions_train)
1414
- _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1415
- "independent_arg_name", admissions_train)
1416
- _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1417
- "independent_arg_name", admissions_train,
1418
- "arg_val")
1419
- """
1420
- if dependent_arg_value is not None and independent_arg_value is None:
1421
- error_code = MessageCodes.DEPENDENT_ARGUMENT
1422
- error_msg = Messages.get_message(error_code, dependent_arg, independent_arg)
1423
- if msg_arg_value is None:
1424
- raise TeradataMlException(error_msg, error_code)
1425
- else:
1426
- raise TeradataMlException(error_msg.replace("(not None)", "as '{}'".format(msg_arg_value)),
1427
- MessageCodes.DEPENDENT_ARGUMENT)
1428
- return True
1429
-
1430
- @staticmethod
1431
- def _validate_py_type_for_td_type_conversion(py_type, py_type_arg_name):
1432
- """
1433
- DESCRIPTION:
1434
- Function to validate python type, which needs to be converted to TD Type.
1435
- This function checks whether the python type can be converted to a TD
1436
- type or not. If PY type is not able to convert TD Type, it then raises
1437
- an error.
1438
-
1439
- PARAMETERS:
1440
- py_type:
1441
- Required Argument.
1442
- Specifies the python type.
1443
- Types: Any
1444
-
1445
- py_type_arg_name:
1446
- Required Argument.
1447
- Specifies the name of argument which holds python variable.
1448
- Types: str
1449
-
1450
- RETURNS:
1451
- None
1452
-
1453
- RAISES:
1454
- TeradataMLException
1455
-
1456
- EXAMPLES:
1457
- _Validators._validate_py_type_for_td_type_conversion(int, "arg1")
1458
- """
1459
- if py_type not in _DtypesMappers.PY_TD_MAPPER:
1460
- error_code = MessageCodes.UNSUPPORTED_DATATYPE
1461
- error_msg = Messages.get_message(
1462
- error_code, py_type_arg_name, '[{}]'.format(", ".join((t.__name__ for t in _DtypesMappers.PY_TD_MAPPER))))
1463
- raise TeradataMlException(error_msg, error_code)
1464
-
1465
- @staticmethod
1466
- def _validate_function_install_location_is_set(option, function_type, option_name):
1467
- """
1468
- DESCRIPTION:
1469
- Function to validate whether install location for functions is set.
1470
-
1471
- PARAMETERS:
1472
- option:
1473
- Required Argument.
1474
- Specifies the configuration option value to validate.
1475
- Types: str
1476
-
1477
- function_type:
1478
- Required Argument.
1479
- Specifies the type of function to check installed location for.
1480
- Types: str
1481
-
1482
- option_name:
1483
- Required Argument.
1484
- Specifies the configuration option name.
1485
- Types: str
1486
-
1487
- RETURNS:
1488
- None
1489
-
1490
- RAISES:
1491
- TeradataMLException
1492
-
1493
- EXAMPLES:
1494
- _Validators._validate_function_install_location_is_set(
1495
- configure.byom_install_location,
1496
- "Bring Your Own Model",
1497
- "configure.byom_install_location")
1498
- """
1499
- # Check whether an empty string is passed to "option".
1500
- _Validators._validate_input_columns_not_empty(option, option_name)
1501
-
1502
- if option is None:
1503
- message = Messages.get_message(MessageCodes.UNKNOWN_INSTALL_LOCATION,
1504
- "{} functions".format(function_type),
1505
- "option '{}'".format(option_name))
1506
- raise TeradataMlException(message, MessageCodes.MISSING_ARGS)
1507
-
1508
- @staticmethod
1509
- def _check_table_exists(conn, table_name,
1510
- schema_name,
1511
- raise_error_if_does_not_exists=True,
1512
- additional_error=''):
1513
- """
1514
- DESCRIPTION:
1515
- Check whether table specified exists or not.
1516
-
1517
- PARAMETERS:
1518
- raise_error_if_does_not_exists:
1519
- Optional Argument.
1520
- Specifies the flag to decide whether to raise error when table name specified does not exist.
1521
- Default Value: True (Raise exception)
1522
- Types: bool
1523
-
1524
- additional_error:
1525
- Optional Argument.
1526
- Specifies the additional error message to display along with standard message.
1527
- Default Value: ''
1528
- Types: String
1529
-
1530
- RAISES:
1531
- TeradataMlException.
1532
-
1533
- RETURNS:
1534
- True, if table exists, else False.
1535
-
1536
- EXAMPLES:
1537
- >>> _check_table_exists('model_table_name','model_schema_name')
1538
- """
1539
-
1540
- # Check whether table exists on the system or not.
1541
- table_exists = conn.dialect.has_table(conn, table_name=table_name,
1542
- schema=schema_name)
1543
-
1544
- # If tables exists, return True.
1545
- if table_exists:
1546
- return True
1547
-
1548
- # We are here means the specified table does not exist.
1549
- # Let's raise error if 'raise_error_if_does_not_exists' set to True.
1550
- if raise_error_if_does_not_exists:
1551
- # Raise error, as the specified table_name does not exist.
1552
- # TABLE_DOES_NOT_EXIST
1553
- raise TeradataMlException(Messages.get_message(MessageCodes.TABLE_DOES_NOT_EXIST,
1554
- schema_name, table_name, additional_error),
1555
- MessageCodes.TABLE_DOES_NOT_EXIST)
1556
- return False
1557
-
1558
- @staticmethod
1559
- def _check_empty_file(file_path):
1560
- """
1561
- Description:
1562
- Function to validate whether the given file is not empty,
1563
- given absolute file path.
1564
-
1565
- PARAMETERS:
1566
- file_path:
1567
- Required Argument.
1568
- Specifies absolute file path of the file.
1569
- Types: str
1570
-
1571
- RETURNS:
1572
- Boolean
1573
-
1574
- RAISES:
1575
- TeradataMlException
1576
-
1577
- EXAMPLES:
1578
- _check_empty_file("/abc/xyz.txt")
1579
- """
1580
-
1581
- if os.stat(file_path).st_size == 0:
1582
- raise TeradataMlException(
1583
- Messages.get_message(MessageCodes.EMPTY_FILE,
1584
- "{}".format(file_path)),
1585
- MessageCodes.EMPTY_FILE)
1586
- return True
1587
-
1588
- @staticmethod
1589
- def _validate_mutually_inclusive_arguments(arg1, err_disp_arg1_name, arg2,
1590
- err_disp_arg2_name):
1591
- """
1592
- DESCRIPTION:
1593
- Function to validate whether "arg1" and "arg2" are mutually inclusive.
1594
-
1595
- PARAMETERS:
1596
- arg1:
1597
- Required Argument.
1598
- Specifies the value of argument1.
1599
- Types: Any
1600
-
1601
- err_disp_arg1_name:
1602
- Required Argument.
1603
- Specifies the name of argument1.
1604
- Types: str
1605
-
1606
- arg2:
1607
- Required Argument.
1608
- Specifies the value of argument2.
1609
- Types: Any
1610
-
1611
- err_disp_arg2_name:
1612
- Required Argument.
1613
- Specifies the name of argument2.
1614
- Types: str
1615
-
1616
- RETURNS:
1617
- True, if both arg1 and arg2 are present or both are None.
1618
-
1619
- RAISES:
1620
- TeradataMLException
1621
-
1622
- EXAMPLES:
1623
- _Validators._validate_mutually_inclusive_arguments(arg1, "arg1", arg2, "arg2")
1624
- """
1625
- both_args_none = arg1 is None and arg2 is None
1626
- # If below handles 0 value.
1627
- # 0 turns to False using bool(0) but 0 is a valid value and should return True.
1628
- arg1 = True if arg1 == 0 else bool(arg1)
1629
- arg2 = True if arg2 == 0 else bool(arg2)
1630
-
1631
- # Either both the arguments are specified or both are None.
1632
- if not(all([arg1, arg2]) or both_args_none):
1633
- arg_order = [err_disp_arg1_name, err_disp_arg2_name] if arg1 \
1634
- else [err_disp_arg2_name, err_disp_arg1_name]
1635
- raise TeradataMlException(Messages.get_message(
1636
- MessageCodes.DEPENDENT_ARGUMENT, arg_order[0],
1637
- arg_order[1]), MessageCodes.DEPENDENT_ARGUMENT)
1638
- return True
1639
-
1640
- @staticmethod
1641
- def _validate_file_extension(file_path, extension):
1642
- """
1643
- DESCRIPTION:
1644
- Function to validate whether the file has a specified extension.
1645
-
1646
- PARAMETERS:
1647
- file_path:
1648
- Required Argument.
1649
- Specifies the file path or file name.
1650
- Types: str
1651
-
1652
- extension:
1653
- Required Argument.
1654
- Specifies the extension of the file.
1655
- Types: str OR list of Strings (str)
1656
-
1657
- RETURNS:
1658
- True, if the file has specified extension.
1659
-
1660
- RAISES:
1661
- TeradataMLException
1662
-
1663
- EXAMPLES:
1664
-
1665
- _Validators._validate_file_extension("/data/mapper.py",".py")
1666
- _Validators._validate_file_extension("ml__demoenv_requirements_1605727131624097.txt",".txt")
1667
- """
1668
- extension = extension if isinstance(extension, list) else[extension]
1669
- file_extension = file_path.lower().split('.')[-1]
1670
- if file_extension not in extension:
1671
- raise TeradataMlException(
1672
- Messages.get_message(MessageCodes.UNSUPPORTED_FILE_EXTENSION).format("{}".format(extension)),
1673
- MessageCodes.UNSUPPORTED_FILE_EXTENSION)
1674
-
1675
- return True
1676
-
1677
- @staticmethod
1678
- def _validate_argument_is_not_None(arg, arg_name, additional_error="", reverse=False):
1679
- """
1680
- DESCRIPTION:
1681
- Check whether the argument provided is not None.
1682
- If parameter reverse is set to True, the validation is reversed to
1683
- check whether argument provided is None.
1684
-
1685
- PARAMETERS:
1686
- arg:
1687
- Required Argument.
1688
- Specifies the argument to be validated.
1689
- Types: str
1690
-
1691
- arg_name:
1692
- Required Argument.
1693
- Specifies the name of the argument to be printed in error message.
1694
- Types: str
1695
-
1696
- additional_error:
1697
- Optional Argument.
1698
- Specifies the additional error message to display along with standard message.
1699
- Default value=""
1700
- Types: str
1701
-
1702
- reverse:
1703
- Optional Argument.
1704
- Specifies whether to reverse the validation.
1705
- Returns True if arg is None, False if arg is not None.
1706
- Default value=False
1707
- Types: bool
1708
-
1709
-
1710
- RAISES:
1711
- ValueError.
1712
-
1713
- RETURNS:
1714
- True, if the argument is not None, else False.
1715
-
1716
- EXAMPLES:
1717
- >>> _validate_argument_is_not_None(table_name, "table_name", additional_error)
1718
- """
1719
- if not reverse:
1720
- # Raise an error if the argument is None.
1721
- if arg is None:
1722
- raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name, "None", additional_error))
1723
- return True
1724
- else:
1725
- # Raise an error if the argument is not None.
1726
- if arg is not None:
1727
- raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name,
1728
- "provided {}".format(additional_error), ""))
1729
- return True
1730
-
1731
-
1732
- @staticmethod
1733
- def _validate_dataframe(df, raise_error=True):
1734
- """
1735
- This is an internal function checks whether the dataframe is none
1736
- or not. If not none then checks the dataframe type and length of columns.
1737
-
1738
- PARAMETERS:
1739
- df:
1740
- Required Argument.
1741
- Specifies the dataframe.
1742
- Types: pandas.DataFrame or teradataml.dataframe.dataframe.DataFrame
1743
-
1744
- raise_error:
1745
- Optional Argument.
1746
- Specifies whether to raise an exception or not.
1747
- Default Values: True
1748
- Types: bool
1749
-
1750
- RETURNS:
1751
- None
1752
-
1753
- RAISES:
1754
- TeradataMlException
1755
-
1756
- EXAMPLES:
1757
- _validate_dataframe(df)
1758
-
1759
- """
1760
- from teradataml.dataframe import dataframe as tdmldf
1761
-
1762
- valid = False
1763
- if df is not None:
1764
- if isinstance(df, pd.DataFrame) and len(df.columns) > 0:
1765
- valid = True
1766
- elif isinstance(df, tdmldf.DataFrame) and len(df._metaexpr.c) > 0:
1767
- valid = True
1768
- else:
1769
- valid = False
1770
-
1771
- if raise_error and not valid:
1772
- raise TeradataMlException(Messages.get_message(MessageCodes.IS_NOT_VALID_DF),
1773
- MessageCodes.IS_NOT_VALID_DF)
1774
-
1775
-
1776
- @staticmethod
1777
- def _validate_column_value_length(argument_name, argument_value, allowed_length,
1778
- operation='perform the operation'):
1779
- """
1780
- DESCRIPTION:
1781
- Function to validate length of string against permitted value.
1782
-
1783
- PARAMETERS:
1784
- argument_name:
1785
- Required Argument.
1786
- Specifies the name of the argument whose value
1787
- will be checked against permitted length.
1788
- This is used while raising an error.
1789
- Types: str.
1790
-
1791
- argument_value:
1792
- Required Argument.
1793
- Specifies the string whose length will be checked against permitted length.
1794
- Types: str.
1795
-
1796
- allowed_length:
1797
- Required Argument.
1798
- Specifies the allowed length for argument value.
1799
- Types: int.
1800
-
1801
- operation:
1802
- Optional Argument.
1803
- Specifies the name of operation which will fail, if this check fails.
1804
- Default value: 'perform the operation'.
1805
- Types: str.
1806
-
1807
- RETURNS:
1808
- None.
1809
-
1810
- RAISES:
1811
- TeradataMlException - EXECUTION_FAILED, ValueError
1812
-
1813
- EXAMPLES:
1814
- >>> _validate_column_value_length("Description", "KMeans model", 150, "save the model")
1815
- """
1816
- try:
1817
- _Validators._validate_str_arg_length(argument_name, argument_value, 'LE', allowed_length)
1818
- except ValueError:
1819
- error_code = MessageCodes.EXECUTION_FAILED
1820
- error_msg = Messages.get_message(
1821
- error_code, operation,
1822
- 'Length of argument {0} ({1}) is more than the allowed length ({2}).'
1823
- .format(argument_name, len(argument_value), allowed_length))
1824
- raise TeradataMlException(error_msg, error_code)
1825
- return True
1826
-
1827
-
1828
- @staticmethod
1829
- def _validate_list_lengths_equal(list1, arg_name1, list2, arg_name2):
1830
- """
1831
- DESCRIPTION:
1832
- Check if length of the lists is same or not.
1833
-
1834
- PARAMETERS:
1835
- list1:
1836
- Required Argument.
1837
- Specifies the first list to check the length against "list2".
1838
- Types: list
1839
-
1840
- arg_name1:
1841
- Required Argument.
1842
- Specifies the name of the argument that accepts "list1" as input.
1843
- This is used while raising an error.
1844
- Types: str
1845
-
1846
- list2:
1847
- Required Argument.
1848
- Specifies the second list to check the length against "list1".
1849
- Types: list
1850
-
1851
- arg_name2:
1852
- Required Argument.
1853
- Specifies the name of the argument that accepts "list2" as input.
1854
- This is used while raising an error.
1855
- Types: str
1856
-
1857
- RETURNS:
1858
- None.
1859
-
1860
- RAISES:
1861
- ValueError
1862
-
1863
- EXAMPLES:
1864
- _Validators._validate_list_lengths_equal(self.coordinates, "coordinates",
1865
- self.timestamps, "timestamps")
1866
- """
1867
- if len(list1) != len(list2):
1868
- # Raise error, if length of both lists is not same.
1869
- err_ = Messages.get_message(MessageCodes.INVALID_LENGTH_ARGS,
1870
- "'{}' and '{}'".format(arg_name1, arg_name2))
1871
- raise ValueError(err_)
1872
- return True
1873
-
1874
- @staticmethod
1875
- def _validate_dict_argument_key_value(arg_name, arg_dict, key_types=None, value_types=None,
1876
- key_permitted_values=None, value_permitted_values=None,
1877
- value_empty_string=True):
1878
- """
1879
- DESCRIPTION:
1880
- Internal function to validate type and permitted values
1881
- for keys and values in a dictionary argument.
1882
-
1883
- PARAMETERS:
1884
- arg_name:
1885
- Required Argument.
1886
- Specifies the name of the dictionary argument.
1887
- Types: str
1888
-
1889
- arg_dict:
1890
- Required Argument.
1891
- Specifies the dictonary value of "arg_name".
1892
- Types: dict
1893
-
1894
- key_types:
1895
- Optional Argument.
1896
- Specifies the types, 'keys' of the "arg_dict" can take.
1897
- Types: Any type or tuple of types
1898
-
1899
- value_types:
1900
- Optional Argument.
1901
- Specifies the types, 'values' assigned to 'keys' of
1902
- "arg_dict" can take.
1903
- Types: Any type or tuple of types
1904
-
1905
- key_permitted_values:
1906
- Optional Argument.
1907
- Specifies the permitted values for the 'keys' of "arg_dict".
1908
- Types: list
1909
-
1910
- value_permitted_values:
1911
- Optional Argument.
1912
- Specifies the permitted values for the 'values' assgined to 'keys'
1913
- of "arg_dict".
1914
- Types: list
1915
-
1916
- value_empty_string:
1917
- Optional Argument.
1918
- Specifies the whether 'values' assigned to 'keys' of "arg_dict"
1919
- can accept empty string.
1920
- Set to True, dictionary value with empty string is accepted.
1921
- Set to False, dictionary value with empty string is not accepted.
1922
- Default Value: True
1923
- Types: bool
1924
-
1925
- RETURNS:
1926
- bool
1927
-
1928
- RAISES:
1929
- TypeError, ValueError
1930
-
1931
- EXAMPLES:
1932
- _Validators._validate_dict_argument_key_value("name", {"a":3, "b":4}, (str), (int))
1933
- _Validators._validate_dict_argument_key_value(arg_name="columns", arg_dict=columns,
1934
- key_types=(ColumnExpression, _TupleOf(ColumnExpression)),
1935
- value_types=(str, int, float, NoneType))
1936
-
1937
- """
1938
- info_matrix = []
1939
- dict_keys_list = set()
1940
- from teradataml.common.utils import UtilFuncs
1941
-
1942
- try:
1943
- for key, value in arg_dict.items():
1944
- # Validate duplicate keys exists or not.
1945
- # If keys are not of type tuple, convert it to tuple.
1946
- keys_list = (key,) if not isinstance(key, tuple) else key
1947
-
1948
- # If duplicate key exists raise exception. E.g.
1949
- # di = {("key1", "key2"): "my_keys1",
1950
- # ("key1", "key3"): "my_keys2",
1951
- # "key2" : "my_keys3"}
1952
- for k in keys_list:
1953
- # If ColumnExpression, get the column name.
1954
- if isinstance(k, ColumnExpression):
1955
- k_name, name = k.name, "ColumnExpression(s)"
1956
- else:
1957
- k_name, name = k, "Key names"
1958
-
1959
- # If duplicate key exists raise exception.
1960
- if k_name in dict_keys_list:
1961
- raise TeradataMlException(Messages.get_message(
1962
- MessageCodes.DUPLICATE_DICT_KEYS_NAMES,
1963
- name, arg_name),
1964
- MessageCodes.DUPLICATE_PARAMETER)
1965
- else:
1966
- dict_keys_list.add(k_name)
1967
-
1968
- # Append "keys" and "values" into arg info matrix for type validation.
1969
- if key_types is not None:
1970
- info_matrix.append(["<dict_key>", key, True, key_types, True])
1971
-
1972
- if value_types is not None:
1973
- info_matrix.append(
1974
- ["<dict_value>", value, True, value_types, not value_empty_string])
1975
-
1976
- # Validate permitted values for both "key" and "value" if permitted values
1977
- # are provided.
1978
- if key_permitted_values is not None:
1979
- _Validators._validate_permitted_values(arg=key,
1980
- permitted_values=key_permitted_values,
1981
- arg_name="<dict_key>",
1982
- case_insensitive=False,
1983
- includeNone=True)
1984
-
1985
- if value_permitted_values is not None:
1986
- _Validators._validate_permitted_values(arg=value,
1987
- permitted_values=value_permitted_values,
1988
- arg_name="<dict_value>",
1989
- case_insensitive=False,
1990
- includeNone=True)
1991
-
1992
- if key_types is not None or value_types is not None:
1993
- # Validate types using already existing validator.
1994
- _Validators._validate_function_arguments(info_matrix)
1995
-
1996
- except ValueError as ve:
1997
- # Catch ValueError raised by '_validate_permitted_values' to
1998
- # raise proper error message for dictionary argument.
1999
- if "TDML_2007" in str(ve):
2000
- permitted_values = value_permitted_values
2001
- err_str = "value"
2002
- err_val = value
2003
- if "<dict_key>" in str(ve):
2004
- permitted_values = key_permitted_values
2005
- err_str = "key"
2006
- err_val = key
2007
- raise ValueError(
2008
- Messages.get_message(MessageCodes.INVALID_DICT_ARG_VALUE, err_val,
2009
- err_str, arg_name, permitted_values))
2010
-
2011
- # Catch ValueError raised by '_validate_function_arguments'
2012
- # for empty string value.
2013
- elif "TDML_2004" in str(ve):
2014
- err_str = "Key" if "<dict_key>" in str(ve) else "Value"
2015
- raise ValueError(
2016
- Messages.get_message(MessageCodes.DICT_ARG_KEY_VALUE_EMPTY,
2017
- err_str, arg_name))
2018
-
2019
- except TypeError as te:
2020
- # Catch TypeError raised by '_validate_function_arguments' to
2021
- # raise proper error message for dictionary argument.
2022
- permitted_types = value_types
2023
- err_str = "value"
2024
- if "<dict_key>" in str(te):
2025
- permitted_types = key_types
2026
- err_str = "key"
2027
-
2028
- permitted_types = [''.join(_Validators.__getTypeAsStr(kv_type))
2029
- if isinstance(kv_type, (_TupleOf, _ListOf)) else
2030
- kv_type.__name__ for kv_type in permitted_types]
2031
-
2032
- raise TypeError(
2033
- Messages.get_message(MessageCodes.UNSUPPORTED_DICT_KEY_VALUE_DTYPE, err_str,
2034
- arg_name, permitted_types))
2035
-
2036
- return True
2037
-
2038
- @staticmethod
2039
- def _validate_http_response(http_response, valid_status_code, error_msg):
2040
- """
2041
- DESCRIPTION:
2042
- Internal function to validate the HTTP response.
2043
-
2044
- PARAMETERS:
2045
- http_response:
2046
- Required Argument.
2047
- Specifies the response object recieved from HTTP request.
2048
- Types: requests.models.Response OR httpx.Response
2049
-
2050
- valid_status_code:
2051
- Required Argument.
2052
- Specifies the HTTP response code of a request.
2053
- Types: int
2054
-
2055
- error_msg:
2056
- Required Argument.
2057
- Specifies the error message to be displayed when response code is
2058
- not equal to "valid_status_code".
2059
- Types: str
2060
-
2061
- RETURNS:
2062
- bool
2063
-
2064
- RAISES:
2065
- TeradatamlException
2066
-
2067
- EXAMPLES:
2068
- _Validators._validate_http_response(resp, 200, "test1")
2069
- """
2070
- if http_response.status_code != valid_status_code:
2071
- err_ = Messages.get_message(MessageCodes.EXECUTION_FAILED,
2072
- error_msg,
2073
- "Error-details: ({}){}".format(http_response.status_code, http_response.text))
2074
- raise TeradataMlException(err_, MessageCodes.EXECUTION_FAILED)
2075
-
2076
- return True
2077
-
2078
- @staticmethod
2079
- def _validate_module_presence(module_name, function_name):
2080
- """
2081
- DESCRIPTION:
2082
- Check if module being imported is present.
2083
-
2084
- PARAMETERS:
2085
- module_name:
2086
- Required Argument.
2087
- Specifies the name of the module to import.
2088
- Types: str
2089
-
2090
- function_name:
2091
- Required Argument.
2092
- Specifies the name of the function from where module is imported.
2093
- Types: str
2094
-
2095
- RETURNS:
2096
- None.
2097
-
2098
- RAISES:
2099
- TeradataMlException
2100
-
2101
- EXAMPLES:
2102
- _Validators._validate_module_presence("docker", "setup_sandbox_env")
2103
- """
2104
- import importlib
2105
-
2106
- try:
2107
- importlib.import_module(module_name, package=None)
2108
- except Exception as err:
2109
- message = \
2110
- Messages.get_message(
2111
- MessageCodes.IMPORT_PYTHON_PACKAGE,
2112
- module_name, module_name, function_name)
2113
- raise TeradataMlException(message,
2114
- MessageCodes.IMPORT_PYTHON_PACKAGE)
2115
- return True
1
+ import numbers
2
+ import os
3
+ import pandas as pd
4
+ from pathlib import Path
5
+ import re
6
+ from teradataml.common.constants import TeradataConstants, PTITableConstants, PythonTypes
7
+ from teradataml.common.exceptions import TeradataMlException
8
+ from teradataml.common.messages import MessageCodes, Messages
9
+ from teradataml.utils.dtypes import _Dtypes, _DtypesMappers, _ListOf, _TupleOf
10
+ from teradataml.options.configure import configure
11
+ from teradataml.dataframe.sql_interfaces import ColumnExpression
12
+ from functools import wraps, reduce
13
+
14
+
15
+ def skip_validation():
16
+ """
17
+ DESCRIPTION:
18
+ Define for skipping the validation.
19
+
20
+ PARAMETERS:
21
+ None
22
+
23
+ EXAMPLES:
24
+ @skip_validation(skip_all=True)
25
+ def validation_func(): ...
26
+
27
+ """
28
+ def decorator(func):
29
+ def wrapper(*args, **kwargs):
30
+ # If "skip_all" flag is set to False,
31
+ # skip all validation execution.
32
+ if not _Validators.skip_all:
33
+ return func(*args, **kwargs)
34
+ return wraps(func)(wrapper)
35
+ return decorator
36
+
37
+
38
+ class _Validators:
39
+ """
40
+ A class containing set of utilities that can be used for validations of various kinds.
41
+ Currently, this facilitates the validations done for:
42
+ 1. Analytic function execution engine: (_validate_engine)
43
+ 2. Validation for the vantage_version: (_validate_vantage_version)
44
+ 3. Validate whether argument has passed with empty string or not: (_validate_input_columns_not_empty)
45
+ 4. Validate for permitted values of the argument: (_validate_permitted_values)
46
+ 5. Validate function arguments. (_validate_function_arguments) This specifically validates for
47
+ 1. Argument types check.
48
+ 2. Argument is empty or not.
49
+ 3. Permitted values check.
50
+ 6. Validate for missing required arguments.
51
+ 7. Validate column exists in a DataFrame or not. (_validate_column_exists_in_dataframe)
52
+ 8. Validate required arguments are missing or not. (_validate_missing_required_arguments)
53
+ 9. Validate whether function install location is set.
54
+ 10. Validate whether the table exist in the schema or not
55
+ 11. Validate whether the given file is not empty, given absolute file path.
56
+ 12. Validate whether "arg1" and "arg2" are mutually inclusive.
57
+ """
58
+
59
+ # "skip_all" specifies to skip all the executions.
60
+ skip_all = False
61
+
62
+ @staticmethod
63
+ @skip_validation()
64
+ def __getTypeAsStr(type_list):
65
+ """
66
+ Function to convert type to string.
67
+
68
+ PARAMETERS:
69
+ type_list
70
+ Required Argument.
71
+ A tuple of types or a type to be converted to string.
72
+
73
+ RAISES:
74
+ None
75
+
76
+ RETURNS:
77
+ A list of strings representing types in type_list.
78
+
79
+ EXAMPLES:
80
+ _Validators.__getTypeAsStr(type_list)
81
+ """
82
+ type_as_str = []
83
+ if isinstance(type_list, tuple):
84
+ for typ in type_list:
85
+ if isinstance(typ, tuple):
86
+ for typ1 in typ:
87
+ type_as_str.append(typ1.__name__)
88
+ elif isinstance(typ, (_ListOf, _TupleOf)):
89
+ type_as_str.append(str(typ))
90
+ elif typ.__name__ == "DataFrame":
91
+ type_as_str.append("teradataml DataFrame")
92
+ else:
93
+ type_as_str.append(typ.__name__)
94
+
95
+ if isinstance(type_list, type):
96
+ if type_list.__name__ == "DataFrame":
97
+ type_as_str.append("teradataml DataFrame")
98
+ else:
99
+ type_as_str.append(type_list.__name__)
100
+
101
+ if isinstance(type_list, (_ListOf, _TupleOf)):
102
+ type_as_str.append(str(type_list))
103
+
104
+ return type_as_str
105
+
106
+ @staticmethod
107
+ @skip_validation()
108
+ def _check_isinstance(obj, class_or_tuple):
109
+ """
110
+ Function checks whether an object is an instance of a class.
111
+
112
+ PARAMETER
113
+ obj:
114
+ Required Argument.
115
+ Specifies the object to check instance of.
116
+
117
+ class_or_tuple:
118
+ Required Argument.
119
+ Specifies the type or tuple of types to check instance against.
120
+
121
+ RAISES:
122
+ None.
123
+
124
+ RETURNS:
125
+ True, if obj is instance of class_or_tuple
126
+
127
+ EXAMPLES:
128
+ _Validators._check_isinstance(obj, (int, list, str))
129
+ """
130
+ # If obj is of type bool and type to check against contains int, then we must
131
+ # check/validate the instance as type(obj) == class_or_tuple.
132
+ # bool is subclass of int, hence isinstance(True, int) will always return true.
133
+ # And we would like to return false, as bool is not a int.
134
+ if not isinstance(obj, bool):
135
+ # If obj of any type other than bool, then we shall use "isinstance()"
136
+ # to perform type checks.
137
+ return isinstance(obj, class_or_tuple)
138
+
139
+ else:
140
+ # 'obj' is of type bool.
141
+ if isinstance(class_or_tuple, tuple):
142
+ if int not in class_or_tuple:
143
+ # If class_or_tuple is instance of tuple and int is not in class_or_tuple
144
+ # use "isinstance()" to validate type check for obj.
145
+ return isinstance(obj, class_or_tuple)
146
+ else:
147
+ return type(obj) in class_or_tuple
148
+
149
+ else: # isinstance(class_or_tuple, type):
150
+ if int != class_or_tuple:
151
+ # If class_or_tuple is instance of type and class_or_tuple is not an int
152
+ # use "isinstance()" to validate type check for obj.
153
+ return isinstance(obj, class_or_tuple)
154
+ else:
155
+ return type(obj) == class_or_tuple
156
+
157
+ @staticmethod
158
+ @skip_validation()
159
+ def _validate_columnexpression_dataframe_has_columns(columns,
160
+ arg_name,
161
+ column_expression):
162
+ """
163
+ DESCRIPTION:
164
+ Function to check whether column name(s) available in dataframe
165
+ or not from a given column. This function is used currently
166
+ only for Window Aggregates.
167
+
168
+ PARAMETERS:
169
+ columns:
170
+ Required Argument.
171
+ Specifies the name or list of names of columns to be validated
172
+ for existence.
173
+ Types: str or List of strings
174
+
175
+ arg_name:
176
+ Required Argument.
177
+ Specifies the name of the argument.
178
+ Types: str
179
+
180
+ column_expression:
181
+ Required Argument.
182
+ Specifies teradataml DataFrame Column to check against for
183
+ column existence.
184
+ Types: ColumnExpression
185
+
186
+ RAISES:
187
+ ValueError
188
+
189
+ RETURNS:
190
+ bool
191
+
192
+ EXAMPLES:
193
+ _Validators._validate_dataframe_has_argument_columns_from_column(self.data_sequence_column,
194
+ "data_sequence_column",
195
+ self.data.col)
196
+ """
197
+ if not columns:
198
+ return True
199
+ from teradataml.common.utils import UtilFuncs
200
+ # Converting columns to a list if string is passed.
201
+ if not isinstance(columns, list):
202
+ columns = [columns]
203
+
204
+ df_columns = UtilFuncs._all_df_columns(column_expression)
205
+
206
+ # Let's validate existence of each column one by one.
207
+ for column_name in columns:
208
+ # If column name does not exist in DataFrame of a column, raise the exception.
209
+ if column_name not in df_columns:
210
+ message = "{}. Check the argument '{}'".format(sorted(df_columns), arg_name)
211
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
212
+ column_name,
213
+ message
214
+ ))
215
+ return True
216
+
217
+ @staticmethod
218
+ @skip_validation()
219
+ def _validate_invalid_column_types(all_columns, column_arg, columns_to_check, invalid_types):
220
+ """
221
+ DESCRIPTION:
222
+ Function to validate the invalid types for "columns_to_check" from "all_columns".
223
+
224
+ PARAMETERS:
225
+ all_columns:
226
+ Required Argument.
227
+ Specifies the ColumnExpressions.
228
+ Types: List of ColumnExpression
229
+
230
+ column_arg:
231
+ Required Argument.
232
+ Specifies the name of the argument.
233
+ Types: str
234
+
235
+ columns_to_check:
236
+ Required Argument.
237
+ Specifies columns to check for invalid types.
238
+ Types: str OR list of str OR ColumnExpression OR list of ColumnExpression
239
+
240
+ invalid_types:
241
+ Required Argument.
242
+ Specifies list of invalid teradata types to check against "columns".
243
+ Types: list
244
+
245
+ RAISES:
246
+ ValueError
247
+
248
+ RETURNS:
249
+ bool
250
+
251
+ EXAMPLES:
252
+ _Validators._validate_invalid_column_types(columns, column_arg, invalid_types)
253
+ """
254
+ columns_and_types = {c.name.lower(): type(c.type) for c in all_columns}
255
+ get_col_type = lambda column: columns_and_types[column.lower()].__name__ if isinstance(
256
+ column, str) else column.type.__class__.__name__
257
+
258
+ invalid_types = ["{}({})".format(column if isinstance(column, str) else column.name, get_col_type(column))
259
+ for column in columns_to_check if get_col_type(column)
260
+ in [t.__name__ for t in _Dtypes._get_sort_unsupported_data_types()]
261
+ ]
262
+
263
+ if invalid_types:
264
+ invalid_column_types = (col_type.__name__ for col_type in
265
+ _Dtypes._get_sort_unsupported_data_types())
266
+ error_message = Messages.get_message(MessageCodes.INVALID_COLUMN_DATATYPE,
267
+ ", ".join(invalid_types),
268
+ column_arg,
269
+ "Unsupported",
270
+ ", ".join(invalid_column_types))
271
+
272
+ raise ValueError(error_message)
273
+
274
+ return True
275
+
276
+ @staticmethod
277
+ @skip_validation()
278
+ def _validate_dataframe_has_argument_columns(columns, column_arg, data, data_arg, is_partition_arg=False):
279
+ """
280
+ Function to check whether column names in columns are present in given dataframe or not.
281
+ This function is used currently only for Analytics wrappers.
282
+
283
+ PARAMETERS:
284
+ columns:
285
+ Required Argument.
286
+ Specifies name or list of names of columns to be validated for existence.
287
+ Types: str or List of strings
288
+
289
+ column_arg:
290
+ Required Argument.
291
+ Specifies the name of the argument.
292
+ Types: str
293
+
294
+ data:
295
+ Required Argument.
296
+ Specifies teradataml DataFrame to check against for column existence.
297
+ Types: teradataml DataFrame
298
+
299
+ data_arg:
300
+ Required Argument.
301
+ Specifies the name of the dataframe argument.
302
+ Types: str
303
+
304
+ isPartitionArg:
305
+ Optional Argument.
306
+ Specifies a bool argument notifying, whether argument being validate is
307
+ Partition argument or not.
308
+ Types: bool
309
+
310
+ RAISES:
311
+ TeradataMlException - TDMLDF_COLUMN_IN_ARG_NOT_FOUND column(s) does not exist in a dataframe.
312
+
313
+ EXAMPLES:
314
+ _Validators._validate_dataframe_has_argument_columns(self.data_sequence_column, "data_sequence_column", self.data, "data")
315
+ _Validators._validate_dataframe_has_argument_columns(self.data_partition_column, "data_sequence_column", self.data, "data", true)
316
+ """
317
+ if is_partition_arg and columns is None:
318
+ return True
319
+
320
+ if columns is None:
321
+ return True
322
+
323
+ _Validators._validate_dependent_argument(column_arg, columns, data_arg, data)
324
+
325
+ # Converting columns to a list if string is passed.
326
+ if not isinstance(columns, list) and columns is not None:
327
+ columns = [columns]
328
+
329
+ total_columns = []
330
+
331
+ for column in columns:
332
+ for separator in TeradataConstants.RANGE_SEPARATORS.value:
333
+ if column is None:
334
+ total_columns.append(column)
335
+ elif column[0] == "-":
336
+ # If column has exclude operator "-".
337
+ # For example incase of "-[50]", let database handle validation.
338
+ if re.match(r'-\[\d+\]', column) is not None:
339
+ continue
340
+ total_columns.append(column[1:])
341
+ elif column.count(separator) == 1:
342
+ # Following cases can occur:
343
+ # '3:5' or 'colA:colE'
344
+ # ':4' or ':columnD' specifies all columns up to and including the column with index 4(or columnD).
345
+ # '4:' or 'columnD:' specifies the column with index 4(or columnD) and all columns after it.
346
+ # ':' specifies all columns in the table.
347
+
348
+ try:
349
+ # Check if its a sinlge column with one separator. For e.g. column:A.
350
+ # If yes, just continue.
351
+ _Validators._validate_column_exists_in_dataframe(column, data._metaexpr)
352
+ continue
353
+ except:
354
+ # User has provided range value.
355
+ column_names = column.split(separator)
356
+ if (len(column_names) == 2 and
357
+ any([column_names[0].isdigit(), column_names[1].isdigit()]) and
358
+ not all([column_names[0].isdigit(), column_names[1].isdigit()]) and
359
+ not "" in column_names):
360
+ # Raises Exception if column range has mixed types. For e.g. "4:XYZ".
361
+ err_msg = Messages.get_message(MessageCodes.MIXED_TYPES_IN_COLUMN_RANGE)
362
+ raise ValueError(err_msg.format(column_arg))
363
+
364
+ for col in column_names:
365
+ if not col.isdigit() and col != "":
366
+ total_columns.append(col)
367
+
368
+ elif column.count(separator) > 1:
369
+ continue
370
+ else:
371
+ total_columns.append(column)
372
+
373
+ return _Validators._validate_column_exists_in_dataframe(total_columns, data._metaexpr, column_arg=column_arg,
374
+ data_arg=data_arg)
375
+
376
+ @staticmethod
377
+ @skip_validation()
378
+ def _validate_column_exists_in_dataframe(columns, metaexpr, case_insensitive=False, column_arg=None,
379
+ data_arg=None, for_table=False):
380
+ """
381
+ Method to check whether column or list of columns exists in a teradataml DataFrame or not.
382
+
383
+ PARAMETERS:
384
+ columns:
385
+ Required Argument.
386
+ Specifies name or list of names of columns to be validated for existence.
387
+ Types: str or List of strings
388
+
389
+ metaexpr:
390
+ Required Argument.
391
+ Specifies a teradataml DataFrame metaexpr to be validated against.
392
+ Types: MetaExpression
393
+
394
+ case_insensitive:
395
+ Optional Argument.
396
+ Specifies a flag, that determines whether to check for column existence in
397
+ case_insensitive manner or not.
398
+ Default Value: False (Case-Sensitive lookup)
399
+ Types: bool
400
+
401
+ column_arg:
402
+ Optional Argument.
403
+ Specifies the name of the argument.
404
+ Types: str
405
+
406
+ data_arg:
407
+ Optional Argument.
408
+ Specifies the name of the dataframe argument or name of the table.
409
+ Types: str
410
+
411
+ for_table:
412
+ Optional Argument.
413
+ Specifies whether error should be raised against table or DataFrame, i.e.,
414
+ when columns are not available and "for_table" is set to False, then
415
+ exception message mentions column(s) not available in DataFrame. When
416
+ columns are not available and "for_table" is set to true, then exception
417
+ message mentions column(s) not available in Table.
418
+ Types: str
419
+
420
+ RAISES:
421
+ ValueError
422
+ TDMLDF_DROP_INVALID_COL - If columns not found in metaexpr.
423
+
424
+ RETURNS:
425
+ None
426
+
427
+ EXAMPLES:
428
+ _Validators._validate_column_exists_in_dataframe(["col1", "col2"], self.metaexpr)
429
+
430
+ """
431
+ if columns is None:
432
+ return True
433
+
434
+ # If just a column name is passed, convert it to a list.
435
+ if isinstance(columns, str):
436
+ columns = [columns]
437
+
438
+ # Constructing New unquotted column names for selected columns ONLY using Parent _metaexpr
439
+ if case_insensitive:
440
+ # If lookup has to be a case insensitive then convert the
441
+ # metaexpr columns name to lower case.
442
+ unquoted_df_columns = [c.name.replace('"', "").lower() for c in metaexpr.c]
443
+ else:
444
+ unquoted_df_columns = [c.name.replace('"', "") for c in metaexpr.c]
445
+
446
+ # Let's validate existence of each column one by one.
447
+ for column_name in columns:
448
+ if column_name is None:
449
+ column_name = str(column_name)
450
+
451
+ if case_insensitive:
452
+ # If lookup has to be a case insensitive then convert the
453
+ # column name to lower case.
454
+ column_name = column_name.lower()
455
+
456
+ # If column name does not exist in metaexpr, raise the exception
457
+ if not column_name.replace('"', "") in unquoted_df_columns:
458
+ if column_arg and data_arg:
459
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_COLUMN_IN_ARG_NOT_FOUND,
460
+ column_name,
461
+ column_arg,
462
+ data_arg,
463
+ "Table" if for_table else "DataFrame"))
464
+ else:
465
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_DROP_INVALID_COL,
466
+ column_name, sorted(unquoted_df_columns)))
467
+
468
+ return True
469
+
470
+ @staticmethod
471
+ @skip_validation()
472
+ def _validate_engine(engine):
473
+ """
474
+ Function to validate whether the argument engine is supported or not.
475
+
476
+ PARAMETERS:
477
+ engine:
478
+ Required Argument.
479
+ Specifies the type of the engine.
480
+
481
+ RETURNS:
482
+ True, if engine is supported.
483
+
484
+ RAISES:
485
+ TeradataMLException
486
+
487
+ EXAMPLES:
488
+ _Validators._validate_engine("ENGINE_SQL")
489
+ """
490
+ supported_engines = TeradataConstants.SUPPORTED_ENGINES.value
491
+ if engine not in supported_engines.keys():
492
+ raise TeradataMlException(Messages.get_message(
493
+ MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED).format(engine,
494
+ ", ".join(supported_engines.keys())),
495
+ MessageCodes.CONFIG_ALIAS_ENGINE_NOT_SUPPORTED)
496
+
497
+ return True
498
+
499
+ @staticmethod
500
+ @skip_validation()
501
+ def _validate_function_arguments(arg_list, skip_empty_check = None):
502
+ """
503
+ Method to verify that the input arguments are of valid data type except for
504
+ argument of DataFrameType.
505
+
506
+ PARAMETERS:
507
+ arg_list:
508
+ Required Argument.
509
+ Specifies a list of arguments, expected types are mentioned as type or tuple.
510
+ argInfoMatrix = []
511
+ argInfoMatrix.append(["data", data, False, (DataFrame)])
512
+ argInfoMatrix.append(["centers", centers, True, (int, list)])
513
+ argInfoMatrix.append(["threshold", threshold, True, (float)])
514
+ Types: List of Lists
515
+ skip_empty_check:
516
+ Optional Argument.
517
+ Specifies column name and values for which to skip check.
518
+ Types: Dictionary specifying column name to values mapping.
519
+
520
+ RAISES:
521
+ Error if arguments are not of valid datatype
522
+
523
+ EXAMPLES:
524
+ _Validators._validate_function_arguments(arg_list)
525
+ """
526
+ invalid_arg_names = []
527
+ invalid_arg_types = []
528
+
529
+ typeCheckFailed = False
530
+
531
+ for args in arg_list:
532
+ num_args = len(args)
533
+ if not isinstance(args[0], str):
534
+ raise TypeError("First element in argument information matrix should be str.")
535
+
536
+ if not isinstance(args[2], bool):
537
+ raise TypeError("Third element in argument information matrix should be bool.")
538
+
539
+ if not (isinstance(args[3], tuple) or isinstance(args[3], type) or
540
+ isinstance(args[3], (_ListOf, _TupleOf))):
541
+ err_msg = "Fourth element in argument information matrix should be a 'tuple of types' or 'type' type."
542
+ raise TypeError(err_msg)
543
+
544
+ if num_args >= 5:
545
+ if not isinstance(args[4], bool):
546
+ raise TypeError("Fifth element in argument information matrix should be bool.")
547
+
548
+ #
549
+ # Let's validate argument types.
550
+ #
551
+ # Verify datatypes for arguments which are required or the optional arguments are not None
552
+ if ((args[2] == True and args[1] is not None) or (args[2] == False)):
553
+ # Validate the types of argument, if expected types are instance of tuple or type
554
+ dtype_list = _Validators.__getTypeAsStr(args[3])
555
+
556
+ if isinstance(args[3], tuple) and list in args[3]:
557
+ # If list of data types contain 'list', which means argument can accept list of values.
558
+ dtype_list.remove('list')
559
+ valid_types_str = ", ".join(dtype_list) + " or list of values of type(s): " + ", ".join(
560
+ dtype_list)
561
+
562
+ if isinstance(args[1], list):
563
+ # If argument contains list of values, check each value.
564
+ for value in args[1]:
565
+ # If not valid datatype add invalid_arg to dictionary and break
566
+ if not _Validators._check_isinstance(value, args[3]):
567
+ invalid_arg_names.append(args[0])
568
+ invalid_arg_types.append(valid_types_str)
569
+ typeCheckFailed = True
570
+ break
571
+ elif not _Validators._check_isinstance(args[1], args[3]):
572
+ # Argument is not of type list.
573
+ invalid_arg_names.append(args[0])
574
+ invalid_arg_types.append(valid_types_str)
575
+ typeCheckFailed = True
576
+
577
+ elif isinstance(args[3], tuple):
578
+ # Argument can accept values of multiple types, but not list.
579
+ valid_types_str = " or ".join(dtype_list)
580
+ if not _Validators._check_isinstance(args[1], args[3]):
581
+ invalid_arg_names.append(args[0])
582
+ invalid_arg_types.append(valid_types_str)
583
+ typeCheckFailed = True
584
+ else:
585
+ # Argument can accept values of single type.
586
+ valid_types_str = " or ".join(dtype_list)
587
+ if not _Validators._check_isinstance(args[1], args[3]):
588
+ invalid_arg_names.append(args[0])
589
+ invalid_arg_types.append(valid_types_str)
590
+ typeCheckFailed = True
591
+
592
+ #
593
+ # Validate the arguments for empty value
594
+ #
595
+ if not typeCheckFailed and len(args) >= 5:
596
+ if args[4]:
597
+ _Validators._validate_input_columns_not_empty(args[1], args[0], skip_empty_check)
598
+
599
+ #
600
+ # Validate the arguments for permitted values
601
+ #
602
+ if not typeCheckFailed and len(args) >= 6:
603
+ if args[5] is not None:
604
+ _Validators._validate_permitted_values(args[1], args[5], args[0], supported_types=args[3])
605
+
606
+ if typeCheckFailed:
607
+ if len(invalid_arg_names) != 0:
608
+ raise TypeError(Messages.get_message(MessageCodes.UNSUPPORTED_DATATYPE,
609
+ invalid_arg_names, invalid_arg_types))
610
+
611
+ return True
612
+
613
+ @staticmethod
614
+ @skip_validation()
615
+ def _validate_input_columns_not_empty(arg, arg_name, skip_empty_check = None):
616
+ """
617
+ Function to check whether argument is empty string or not.
618
+
619
+ PARAMETERS:
620
+ arg:
621
+ Required Argument.
622
+ Argument value (string) to be checked whether it is empty or not.
623
+ skip_empty_check:
624
+ Optional Argument.
625
+ Specifies column name and values for which to skip check.
626
+ Types: Dictionary specifying column name to values mapping.
627
+ Example: When '\n', '\t' are valid values for argument 'arg_name', this check should be skipped.
628
+
629
+ RAISES:
630
+ Error if argument contains empty string
631
+
632
+ EXAMPLES:
633
+ _Validators._validate_input_columns_not_empty(arg)
634
+ """
635
+ if isinstance(arg, str):
636
+ if not (skip_empty_check and arg_name in skip_empty_check.keys() and arg in skip_empty_check[arg_name]):
637
+ if ((len(arg.strip()) == 0)):
638
+ raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
639
+
640
+ if isinstance(arg, list):
641
+ if len(arg) == 0:
642
+ raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name).replace("empty string", "an empty list"))
643
+
644
+ for col in arg:
645
+ if not (skip_empty_check and arg_name in skip_empty_check.keys() and col in skip_empty_check[arg_name]):
646
+ if isinstance(col, str):
647
+ if (not (col is None) and ((len(col.strip()) == 0))):
648
+ raise ValueError(Messages.get_message(MessageCodes.ARG_EMPTY, arg_name))
649
+ return True
650
+
651
+ @staticmethod
652
+ @skip_validation()
653
+ def _validate_missing_required_arguments(arg_list):
654
+ """
655
+ Method to check whether the required arguments passed to the function are missing
656
+ or not. Only wrapper's use this function.
657
+
658
+ PARAMETERS:
659
+ arg_list - A list
660
+ The argument is expected to be a list of arguments
661
+
662
+ RAISES:
663
+ If any arguments are missing exception raised with missing arguments which are
664
+ required.
665
+
666
+ EXAMPLES:
667
+ An example input matrix will be:
668
+ arg_info_matrix = []
669
+ arg_info_matrix.append(["data", data, False, DataFrame])
670
+ arg_info_matrix.append(["centers", centers, True, int])
671
+ arg_info_matrix.append(["threshold", threshold, True, "float"])
672
+ awu = AnalyticsWrapperUtils()
673
+ awu._validate_missing_required_arguments(arg_info_matrix)
674
+ """
675
+ miss_args = []
676
+ for args in arg_list:
677
+ '''
678
+ Check for missing arguments which are required. If args[2] is false
679
+ the argument is required.
680
+ The following conditions are true :
681
+ 1. The argument should not be None and an empty string.
682
+ then argument is required which is missing and Raises exception.
683
+ '''
684
+ if args[2] == False and args[1] is None:
685
+ miss_args.append(args[0])
686
+
687
+ if (len(miss_args)>0):
688
+ raise TeradataMlException(Messages.get_message(MessageCodes.MISSING_ARGS,miss_args),
689
+ MessageCodes.MISSING_ARGS)
690
+ return True
691
+
692
+ @staticmethod
693
+ @skip_validation()
694
+ def _validate_permitted_values(arg, permitted_values, arg_name, case_insensitive=True, includeNone=True, supported_types=None):
695
+ """
696
+ Function to check the permitted values for the argument.
697
+
698
+ PARAMETERS:
699
+ arg:
700
+ Required Argument.
701
+ Argument value to be checked against permitted values from the list.
702
+ Types: string
703
+
704
+ permitted_values:
705
+ Required Argument.
706
+ A list of strings/ints/floats containing permitted values for the argument.
707
+ Types: string
708
+
709
+ arg_name:
710
+ Required Argument.
711
+ Name of the argument to be printed in the error message.
712
+ Types: string
713
+
714
+ case_insensitive:
715
+ Optional Argument.
716
+ Specifies whether values in permitted_values could be case sensitive.
717
+ Types: bool
718
+
719
+ includeNone:
720
+ Optional Argument.
721
+ Specifies whether 'None' can be included as valid value.
722
+ Types: bool
723
+
724
+ supported_types:
725
+ Optional Argument.
726
+ Specifies the supported datatypes for the argument.
727
+ Types: str
728
+
729
+ RAISES:
730
+ Error if argument is not present in the list
731
+
732
+ EXAMPLES:
733
+ permitted_values = ["LOGISTIC", "BINOMIAL", "POISSON", "GAUSSIAN", "GAMMA", "INVERSE_GAUSSIAN", "NEGATIVE_BINOMIAL"]
734
+ arg = "LOGISTIC"
735
+ _Validators._validate_permitted_values(arg, permitted_values, argument_name)
736
+ """
737
+ # validating permitted_values type which has to be a list.
738
+ _Validators._validate_function_arguments([["permitted_values", permitted_values, False, (list)]])
739
+
740
+ if case_insensitive:
741
+ permitted_values = [item.upper() if isinstance(item, str) else item for item in permitted_values]
742
+
743
+ # Validate whether argument has value from permitted values list or not.
744
+ if not isinstance(arg, list) and arg is not None:
745
+ arg = [arg]
746
+
747
+ if arg is not None:
748
+ # Getting arguments in uppercase to compare with 'permitted_values'
749
+ arg_upper = []
750
+ for element in arg:
751
+ if element is None:
752
+ # If element is None, then we shall add a string "None"
753
+ if includeNone:
754
+ continue
755
+ arg_upper.append(str(element))
756
+ elif isinstance(element, str):
757
+ # If element is of type str, then we will convert it to upper case.
758
+ if case_insensitive:
759
+ arg_upper.append(element.upper())
760
+ else:
761
+ arg_upper.append(element)
762
+ else:
763
+ # For any other type of element, we will keep it as is.
764
+ arg_upper.append(element)
765
+
766
+ # Form the list of datatypes not present in the datatypes of permitted_values.
767
+ add_types = ()
768
+ if supported_types is not None:
769
+ # Convert type and tuple to list.
770
+ supported_types = [supported_types] if isinstance(supported_types, type) else supported_types
771
+ # Form a list for types which are not there in type of permitted_values.
772
+ add_types = tuple(set(list(supported_types)) - set(list(map(type, permitted_values))) - set([list]))
773
+ # Remove the arguments from arg_upper which are an instance of the add_types.
774
+ if len(add_types) > 0:
775
+ [arg_upper.remove(arg) for arg in arg_upper if isinstance(arg, add_types)]
776
+
777
+ # If any of the arguments in 'arg_upper' not in 'permitted_values',
778
+ # then, raise exception
779
+ upper_invalid_values = list(set(arg_upper).difference(set(permitted_values)))
780
+
781
+ if len(upper_invalid_values) > 0:
782
+ # Getting actual invalid arguments (non-upper)
783
+ invalid_values = []
784
+ for element in arg:
785
+ if element is None:
786
+ if includeNone:
787
+ continue
788
+ invalid_values.append(str(element))
789
+ elif isinstance(element, str) and element.upper() in upper_invalid_values:
790
+ invalid_values.append(element)
791
+ elif element in upper_invalid_values:
792
+ invalid_values.append(element)
793
+ invalid_values.sort()
794
+
795
+ # Concatenate the message for datatypes not present in datatypes of permitted_values.
796
+ if len(add_types) > 0 :
797
+ add_types = _Validators.__getTypeAsStr(add_types)
798
+ add_types = " or ".join(add_types)
799
+ permitted_values = "{} {}".format(permitted_values, "or any values of type {}".format(add_types))
800
+
801
+ raise ValueError(
802
+ Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
803
+ ', '.join([str(item) if not isinstance(item, str) else item for item in invalid_values]),
804
+ arg_name, permitted_values))
805
+ # If any of the arguments doesn't want to include None as valid value
806
+ # then, raise exception.
807
+ else:
808
+ if not includeNone:
809
+ raise ValueError(
810
+ Messages.get_message(MessageCodes.INVALID_ARG_VALUE, None,
811
+ arg_name, permitted_values), MessageCodes.INVALID_ARG_VALUE)
812
+ # Returns True when arg is None or there is no Exception
813
+ return True
814
+
815
+ @staticmethod
816
+ @skip_validation()
817
+ def _validate_positive_int(arg, arg_name, lbound=0, ubound=None, lbound_inclusive=False):
818
+ """
819
+ Validation to check arg values is a positive int.
820
+
821
+ PARAMETERS:
822
+ arg:
823
+ Required Argument.
824
+ Specifies the number to be validated for positive INT.
825
+ Types: int
826
+
827
+ arg_name:
828
+ Required Argument.
829
+ Specifies the name of the argument to be printed in error message.
830
+ Types: str
831
+
832
+ lbound:
833
+ Optional Argument.
834
+ Specifies the lower bound value for arg.
835
+ Note: Value provided to this argument is exclusive, i.e., if value provided
836
+ to this argument 10, then error will be raised for any value of arg <= 10.
837
+ It can be made inclusive, if lbound_inclusive is set to 'True'.
838
+ Types: int
839
+
840
+ ubound:
841
+ Optional Argument.
842
+ Specifies the upper bound value for arg.
843
+ Note: Value provided to this argument is inclusive, i.e., if value provided
844
+ to this argument 10, then error will be raised for any value of arg > 10.
845
+ Types: int
846
+
847
+ lbound_inclusive:
848
+ Optional Argument.
849
+ Specifies a boolean flag telling API whether to lbound value is inclusive or not.
850
+ Types: bool
851
+
852
+ RAISES:
853
+ ValueError - If arg is not a positive int.
854
+
855
+ RETURNS:
856
+ True - If success
857
+
858
+ EXAMPLES:
859
+ # Validate n for value > 0
860
+ _Validators._validate_positive_int(n, "n")
861
+ # Validate n for value > 0 and value <= 32767
862
+ _Validators._validate_positive_int(n, "n", ubound="32767")
863
+ """
864
+ if arg is None:
865
+ return True
866
+
867
+ if ubound is None:
868
+ if lbound_inclusive:
869
+ if not isinstance(arg, numbers.Integral) or arg < lbound:
870
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than or equal to"))
871
+ else:
872
+ if not isinstance(arg, numbers.Integral) or arg <= lbound:
873
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_POSITIVE_INT).format(arg_name, "greater than"))
874
+ else:
875
+ if not isinstance(arg, numbers.Integral) or arg <= lbound or arg > ubound:
876
+ raise ValueError(Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(
877
+ arg_name, "greater than {}".format(lbound),
878
+ " and less than or equal to {}".format(ubound)))
879
+
880
+ return True
881
+
882
+ @staticmethod
883
+ @skip_validation()
884
+ def _validate_argument_range(arg,
885
+ arg_name,
886
+ lbound=None,
887
+ ubound=None,
888
+ lbound_inclusive=False,
889
+ ubound_inclusive=False):
890
+ """
891
+ DESCRIPTION:
892
+ Validation to check arg is in specified range.
893
+
894
+ PARAMETERS:
895
+ arg:
896
+ Required Argument.
897
+ Specifies the number to be validated for range check.
898
+ Types: int
899
+
900
+ arg_name:
901
+ Required Argument.
902
+ Specifies the name of the argument to be printed in error message.
903
+ Types: str
904
+
905
+ lbound:
906
+ Optional Argument.
907
+ Specifies the lower bound value for arg.
908
+ Note:
909
+ Value provided to this argument is exclusive, i.e., if
910
+ value provided to this argument 10, then error will be
911
+ raised for any value of arg < 10. It can be made inclusive,
912
+ if lbound_inclusive is set to 'True'.
913
+ Types: int OR float
914
+
915
+ ubound:
916
+ Optional Argument.
917
+ Specifies the upper bound value for arg.
918
+ Note:
919
+ Value provided to this argument is exclusive, i.e., if
920
+ value provided to this argument 10, then error will be
921
+ raised for any value of arg > 10. It can be made inclusive,
922
+ if ubound_inclusive is set to 'True'.
923
+ Types: int OR float
924
+
925
+ lbound_inclusive:
926
+ Optional Argument.
927
+ Specifies whether lbound value is inclusive or not. When set to True,
928
+ value is inclusive, otherwise exclusive.
929
+ Default Value: False
930
+ Types: bool
931
+
932
+ ubound_inclusive:
933
+ Optional Argument.
934
+ Specifies whether ubound value is inclusive or not. When set to True,
935
+ value is inclusive, otherwise exclusive.
936
+ Default Value: False
937
+ Types: bool
938
+
939
+ RAISES:
940
+ ValueError - If arg is not in the specified range.
941
+
942
+ RETURNS:
943
+ True - If success
944
+
945
+ EXAMPLES:
946
+ # Validate n for value in between of 10 and 20.
947
+ _Validators._validate_argument_range(n, 10, 20)
948
+ """
949
+ if lbound is None and ubound is None:
950
+ return True
951
+
952
+ # Raise error if lower bound is greater than upper bound.
953
+ if lbound is not None and ubound is not None and (lbound > ubound):
954
+ raise ValueError("Lowerbound value '{}' must be less than upperbound value '{}'.".format(lbound, ubound))
955
+
956
+ # If argument is None, do not validate the argument.
957
+ if arg is None:
958
+ return True
959
+
960
+ is_arg_in_lower_bound, is_arg_in_upper_bound = True, True
961
+ lbound_msg, ubound_msg = "", ""
962
+
963
+ # Check for lower bound.
964
+ if lbound is not None:
965
+ if lbound_inclusive:
966
+ is_arg_in_lower_bound = arg >= lbound
967
+ lbound_msg = "greater than or equal to {}".format(lbound)
968
+ else:
969
+ is_arg_in_lower_bound = arg > lbound
970
+ lbound_msg = "greater than {}".format(lbound)
971
+
972
+ # Check for upper bound.
973
+ if ubound is not None:
974
+ if ubound_inclusive:
975
+ is_arg_in_upper_bound = arg <= ubound
976
+ ubound_msg = "less than or equal to {}".format(ubound)
977
+ else:
978
+ is_arg_in_upper_bound = arg < ubound
979
+ ubound_msg = "less than {}".format(ubound)
980
+
981
+ if not (is_arg_in_lower_bound and is_arg_in_upper_bound):
982
+ # If both lower bound and upper bound error messages available, append 'and' to
983
+ # upper bound message.
984
+ if lbound_msg and ubound_msg:
985
+ ubound_msg = " and {}".format(ubound_msg)
986
+ raise ValueError(
987
+ Messages.get_message(MessageCodes.TDMLDF_LBOUND_UBOUND).format(arg_name, lbound_msg, ubound_msg))
988
+
989
+ return True
990
+
991
+ @staticmethod
992
+ @skip_validation()
993
+ def _validate_vantage_version(vantage_version):
994
+ """
995
+ Function to verify whether the given vantage_version is
996
+ supported or not.
997
+
998
+ PARAMETERS:
999
+ vantage_version:
1000
+ Required Argument.
1001
+ Specifies the vantage version.
1002
+
1003
+ RETURNS:
1004
+ True, if the current vantage version is supported or not.
1005
+
1006
+ RAISES:
1007
+ TeradataMLException
1008
+
1009
+ EXAMPLES:
1010
+ _Validators._validate_vantage_version("vantage1.0")
1011
+ """
1012
+ supported_vantage_versions = TeradataConstants.SUPPORTED_VANTAGE_VERSIONS.value
1013
+
1014
+ # Raise exception if the vantage version is not supported.
1015
+ if vantage_version not in supported_vantage_versions.keys():
1016
+ err_ = Messages.get_message(MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED). \
1017
+ format(vantage_version, ", ".join(supported_vantage_versions.keys()))
1018
+ raise TeradataMlException(err_,
1019
+ MessageCodes.CONFIG_ALIAS_VANTAGE_VERSION_NOT_SUPPORTED)
1020
+
1021
+ return True
1022
+
1023
+ @staticmethod
1024
+ @skip_validation()
1025
+ def _validate_timebucket_duration(timebucket_duration, timebucket_duration_arg_name='timebucket_duration'):
1026
+ """
1027
+ Internal function to validate timeduration_bucket specified when creating a
1028
+ Primary Time Index (PTI) table.
1029
+
1030
+ PARAMETERS:
1031
+ timebucket_duration:
1032
+ Specifies the timebucket_duration passed to a function().
1033
+ Types: str
1034
+
1035
+ timebucket_duration_arg_name:
1036
+ Specifies the name of the argument to be displayed in the error message.
1037
+ Types: str
1038
+
1039
+ RETURNS:
1040
+ True if the value is valid.
1041
+
1042
+ RAISES:
1043
+ ValueError or TeradataMlException when the value is invalid.
1044
+
1045
+ EXAMPLES:
1046
+ _Validators._validate_timebucket_duration('HOURS(2)')
1047
+ _Validators._validate_timebucket_duration('2hours')
1048
+ _Validators._validate_timebucket_duration('ayear') # Invalid
1049
+ """
1050
+ # Return True is it is not specified or is None since it is optional
1051
+ if timebucket_duration is None:
1052
+ return True
1053
+
1054
+ # Check if notation if formal or shorthand (beginning with a digit)
1055
+ if timebucket_duration[0].isdigit():
1056
+ valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_SHORTHAND.value
1057
+ pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_SHORT.value
1058
+ normalized_timebucket_duration = timebucket_duration.lower()
1059
+ else:
1060
+ valid_timebucket_durations = PTITableConstants.VALID_TIMEBUCKET_DURATIONS_FORMAL.value
1061
+ pattern_to_use = PTITableConstants.PATTERN_TIMEBUCKET_DURATION_FORMAL.value
1062
+ normalized_timebucket_duration = timebucket_duration.upper()
1063
+
1064
+ for timebucket_duration_notation in valid_timebucket_durations:
1065
+ pattern = re.compile(pattern_to_use.format(timebucket_duration_notation))
1066
+ match = pattern.match(normalized_timebucket_duration)
1067
+ if match is not None:
1068
+ n = int(match.group(1))
1069
+ _Validators._validate_positive_int(n, "n", ubound=32767)
1070
+
1071
+ # Looks like the value is valid
1072
+ return True
1073
+
1074
+ # Match not found
1075
+ raise ValueError(Messages.get_message(
1076
+ MessageCodes.INVALID_ARG_VALUE).format(timebucket_duration, timebucket_duration_arg_name,
1077
+ 'a valid time unit of format time_unit(n) or it\'s short hand '
1078
+ 'equivalent notation'))
1079
+
1080
+ @staticmethod
1081
+ @skip_validation()
1082
+ def _validate_column_type(df, col, col_arg, expected_types, raiseError = True):
1083
+ """
1084
+ Internal function to validate the type of an input DataFrame column against
1085
+ a list of expected types.
1086
+
1087
+ PARAMETERS
1088
+ df:
1089
+ Required Argument.
1090
+ Specifies the input teradataml DataFrame which has the column to be tested
1091
+ for type.
1092
+ Types: teradataml DataFrame
1093
+
1094
+ col:
1095
+ Required Argument.
1096
+ Specifies the column in the input DataFrame to be tested for type.
1097
+ Types: str
1098
+
1099
+ col_arg:
1100
+ Required Argument.
1101
+ Specifies the name of the argument used to pass the column name.
1102
+ Types: str
1103
+
1104
+ expected_types:
1105
+ Required Argument.
1106
+ Specifies a list of teradatasqlachemy datatypes that the column is
1107
+ expected to be of type.
1108
+ Types: list of teradatasqlalchemy types
1109
+
1110
+ raiseError:
1111
+ Optional Argument.
1112
+ Specifies a boolean flag that decides whether to raise error or just return True or False.
1113
+ Default Values: True, raise exception if column is not of desired type.
1114
+ Types: bool
1115
+
1116
+ RETURNS:
1117
+ True, when the columns is of an expected type.
1118
+
1119
+ RAISES:
1120
+ TeradataMlException, when the columns is not one of the expected types.
1121
+
1122
+ EXAMPLES:
1123
+ _Validators._validate_column_type(df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1124
+ """
1125
+ if not any(isinstance(df[col].type, t) for t in expected_types):
1126
+ if raiseError:
1127
+ raise TeradataMlException(Messages.get_message(MessageCodes.INVALID_COLUMN_TYPE).
1128
+ format(col_arg, df[col].type, ' or '.join(expected_type.__visit_name__
1129
+ for expected_type in expected_types)),
1130
+ MessageCodes.INVALID_COLUMN_TYPE)
1131
+ else:
1132
+ return False
1133
+
1134
+ return True
1135
+
1136
+ @staticmethod
1137
+ @skip_validation()
1138
+ def _validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1139
+ """
1140
+ Internal function to validate the for unsupported data types of an input DataFrame column for
1141
+ an aggreagate function.
1142
+
1143
+ PARAMETERS
1144
+ operation:
1145
+ Required Argument.
1146
+ Specifies the name of the aggregate operation.
1147
+ Types: str
1148
+
1149
+ columns:
1150
+ Required Argument.
1151
+ Specifies the column names to be validated for datatype check.
1152
+ Types: str
1153
+
1154
+ td_column_names_and_types:
1155
+ Required Argument.
1156
+ Specifies the input teradataml DataFrames column name to SQLAlchemy type mapper.
1157
+ Types: str
1158
+
1159
+ RETURNS:
1160
+ None
1161
+
1162
+ RAISES:
1163
+ TeradataMlException, when the columns is not one of the expected types.
1164
+
1165
+ EXAMPLES:
1166
+ _Validators._validate_aggr_operation_unsupported_datatype(operation, columns, td_column_names_and_types):
1167
+ """
1168
+ # Check if the user provided columns has unsupported datatype for aggregate operation or not.
1169
+ # Get the list of unsupported types for aggregate function.
1170
+ unsupported_types = _Dtypes._get_unsupported_data_types_for_aggregate_operations(operation)
1171
+ invalid_columns = []
1172
+
1173
+ for column in columns:
1174
+ if isinstance(td_column_names_and_types[column.lower()], tuple(unsupported_types)):
1175
+ invalid_columns.append(
1176
+ "({0} - {1})".format(column, td_column_names_and_types[column.lower()]))
1177
+
1178
+ if len(invalid_columns) > 0:
1179
+ invalid_columns.sort() # helps in catching the columns in
1180
+ # lexicographic order
1181
+ error = MessageCodes.TDMLDF_AGGREGATE_UNSUPPORTED.value.format(
1182
+ ", ".join(invalid_columns), operation)
1183
+ msg = Messages.get_message(MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR). \
1184
+ format(error)
1185
+ raise TeradataMlException(msg, MessageCodes.TDMLDF_AGGREGATE_COMBINED_ERR)
1186
+
1187
+ @staticmethod
1188
+ @skip_validation()
1189
+ def _validate_str_arg_length(arg_name, arg_value, op, length):
1190
+ """
1191
+ Internal function to validate the length of a string passed as an argument.
1192
+
1193
+ PARAMETERS
1194
+ arg_name:
1195
+ Required Argument.
1196
+ Specifies the name of the argument for which we need to validate the value length.
1197
+ Types: str
1198
+
1199
+ arg_value:
1200
+ Required Argument.
1201
+ Specifies the value passed to the argument.
1202
+ Types: str
1203
+
1204
+ op:
1205
+ Required Argument.
1206
+ Specifies the type of check, and can be one of:
1207
+ * LT - Less than
1208
+ * LE - less than or equal to
1209
+ * GT - greater than
1210
+ * GE - greater than or equal to
1211
+ * EQ - equal to
1212
+ * NE - not equal to
1213
+ Types: str
1214
+ Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1215
+
1216
+ length:
1217
+ Required Argument.
1218
+ Specifies the length against which the 'op' check for the argument value length will be made.
1219
+ Types: int
1220
+
1221
+ RETURNS:
1222
+ None
1223
+
1224
+ RAISES:
1225
+ ValueError.
1226
+
1227
+ EXAMPLES:
1228
+ _Validators._validate_str_arg_length("name", "The value", 10):
1229
+ """
1230
+ return _Validators._validate_arg_length(arg_name=arg_name, arg_value=arg_value, op=op, length=length)
1231
+
1232
+ @staticmethod
1233
+ @skip_validation()
1234
+ def _validate_arg_length(arg_name, arg_value, op, length):
1235
+ """
1236
+ Internal function to validate the length of an argument.
1237
+
1238
+ PARAMETERS
1239
+ arg_name:
1240
+ Required Argument.
1241
+ Specifies the name of the argument for which we need to validate the value length.
1242
+ Types: str
1243
+
1244
+ arg_value:
1245
+ Required Argument.
1246
+ Specifies the value passed to the argument.
1247
+ Types: str or list or tuple or set or dict
1248
+
1249
+ op:
1250
+ Required Argument.
1251
+ Specifies the type of check, and can be one of:
1252
+ * LT - Less than
1253
+ * LE - less than or equal to
1254
+ * GT - greater than
1255
+ * GE - greater than or equal to
1256
+ * EQ - equal to
1257
+ * NE - not equal to
1258
+ Types: str
1259
+ Permitted Values: ['LT', 'LE', 'GT', 'GE', 'EQ', 'NE']
1260
+
1261
+ length:
1262
+ Required Argument.
1263
+ Specifies the length against which the 'op' check for the argument value length will be made.
1264
+ Types: int
1265
+
1266
+ RETURNS:
1267
+ None
1268
+
1269
+ RAISES:
1270
+ ValueError.
1271
+
1272
+ EXAMPLES:
1273
+ _Validators._validate_arg_length("name", [1, 2, 3], 3):
1274
+ """
1275
+ # Check if the length of the string value for the argument is acceptable.
1276
+ # First, check if op is an acceptable operation.
1277
+ acceptable_op = {'LT': int.__lt__,
1278
+ 'LE': int.__le__,
1279
+ 'GT': int.__gt__,
1280
+ 'GE': int.__ge__,
1281
+ 'EQ': int.__eq__,
1282
+ 'NE': int.__ne__
1283
+ }
1284
+ if op not in acceptable_op:
1285
+ raise ValueError(Messages.get_message(MessageCodes.INVALID_ARG_VALUE,
1286
+ op, "op", acceptable_op))
1287
+
1288
+ # Format the error message with the substring based on the op type.
1289
+ errors = {'LT': "less than {}",
1290
+ 'LE': "less than or equal to {}",
1291
+ 'GT': "greater than {}",
1292
+ 'GE': "greater than or equal to {}",
1293
+ 'EQ': "equal to {}",
1294
+ 'NE': "not equal to {}"
1295
+ }
1296
+ if not acceptable_op[op](len(arg_value), length):
1297
+ if isinstance(arg_value, str):
1298
+ raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_STRING_ARG,
1299
+ arg_name, errors[op].format(length)))
1300
+ raise ValueError(Messages.get_message(MessageCodes.INVALID_LENGTH_ARG, type(arg_value).__name__,
1301
+ arg_name, errors[op].format(length)))
1302
+ return True
1303
+
1304
+ @staticmethod
1305
+ @skip_validation()
1306
+ def _validate_file_exists(file_path):
1307
+ """
1308
+ DESCRIPTION:
1309
+ Function to validate whether the path specified is a file and if it exists.
1310
+
1311
+ PARAMETERS:
1312
+ file_path:
1313
+ Required Argument.
1314
+ Specifies the path of the file.
1315
+ Types: str
1316
+
1317
+ RETURNS:
1318
+ True, if the path is a file and it exists.
1319
+
1320
+ RAISES:
1321
+ TeradataMLException
1322
+
1323
+ EXAMPLES:
1324
+ _Validators._validate_file_exists("/data/mapper.py")
1325
+ """
1326
+ if not Path(file_path).exists() or not os.path.isfile(file_path):
1327
+ raise TeradataMlException(
1328
+ Messages.get_message(MessageCodes.INPUT_FILE_NOT_FOUND).format(file_path),
1329
+ MessageCodes.INPUT_FILE_NOT_FOUND)
1330
+
1331
+ return True
1332
+
1333
+ @staticmethod
1334
+ @skip_validation()
1335
+ def _validate_mutually_exclusive_arguments(arg1, err_disp_arg1_name, arg2,
1336
+ err_disp_arg2_name, skip_all_none_check=False):
1337
+ """
1338
+ DESCRIPTION:
1339
+ Function to validate whether "arg1" and "arg2" are mutually exclusive.
1340
+
1341
+ PARAMETERS:
1342
+ arg1:
1343
+ Required Argument.
1344
+ Specifies the value of argument1.
1345
+ Types: Any
1346
+
1347
+ err_disp_arg1_name:
1348
+ Required Argument.
1349
+ Specifies the name of argument1.
1350
+ Types: str
1351
+
1352
+ arg2:
1353
+ Required Argument.
1354
+ Specifies the value of argument2.
1355
+ Types: Any
1356
+
1357
+ err_disp_arg2_name:
1358
+ Required Argument.
1359
+ Specifies the name of argument2.
1360
+ Types: str
1361
+
1362
+ skip_all_none_check:
1363
+ Optional Argument.
1364
+ Specifies whether to skip check when arg1 and arg2 both are None.
1365
+ Default Value: False
1366
+ Types: bool
1367
+
1368
+ RETURNS:
1369
+ True, if either arg1 or arg2 is None or both are None.
1370
+
1371
+ RAISES:
1372
+ TeradataMLException
1373
+
1374
+ EXAMPLES:
1375
+ _Validators._validate_mutually_exclusive_arguments(arg1, "arg1", arg2, "arg2")
1376
+ """
1377
+ both_args_none = arg1 is None and arg2 is None
1378
+ if skip_all_none_check:
1379
+ both_args_none = False
1380
+
1381
+ # Either both the arguments are specified or both are None.
1382
+ if all([arg1, arg2]) or both_args_none:
1383
+ raise TeradataMlException(Messages.get_message(
1384
+ MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT, err_disp_arg1_name,
1385
+ err_disp_arg2_name), MessageCodes.EITHER_THIS_OR_THAT_ARGUMENT)
1386
+ return True
1387
+
1388
+ @staticmethod
1389
+ @skip_validation()
1390
+ def _validate_unexpected_column_type(df, col, col_arg, unexpected_types, check_exist=True, raise_error=True):
1391
+ """
1392
+ Internal function to validate the column existence and type of an input DataFrame column against
1393
+ a list of unexpected types.
1394
+
1395
+ PARAMETERS
1396
+ df:
1397
+ Required Argument.
1398
+ Specifies the input teradataml DataFrame which has the column(s) to be tested
1399
+ for type.
1400
+ Types: teradataml DataFrame
1401
+
1402
+ col:
1403
+ Required Argument.
1404
+ Specifies the column(s) in the input DataFrame to be tested for type.
1405
+ Types: str (or) ColumnExpression (or) List of strings(str)
1406
+ or ColumnExpressions
1407
+
1408
+ col_arg:
1409
+ Required Argument.
1410
+ Specifies the name of the argument used to pass the column(s) name.
1411
+ Types: str
1412
+
1413
+ unexpected_types:
1414
+ Required Argument.
1415
+ Specifies unsupported teradatasqlalcehmy datatypes for the column is
1416
+ unexpected to be of type.
1417
+ Types: list of SQLAlchemy types
1418
+
1419
+ check_exist:
1420
+ Optional Argument.
1421
+ Specifies a boolean flag that decides whether to check for column is
1422
+ existed in DataFrame or not.
1423
+ Default Values: True, raise exception if column is not of desired type.
1424
+ Types: bool
1425
+
1426
+ raise_error:
1427
+ Optional Argument.
1428
+ Specifies a boolean flag that decides whether to raise error or just return True or False.
1429
+ Default Values: True, raise exception if column is not of desired type.
1430
+ Types: bool
1431
+
1432
+ RETURNS:
1433
+ True, when the columns is of an expected type.
1434
+
1435
+ RAISES:
1436
+ TeradataMlException, when the columns is not one of the expected types.
1437
+
1438
+ EXAMPLES:
1439
+ _Validators._validate_unexpected_column_type(
1440
+ df, timecode_column, 'timecode_column', PTITableConstants.VALID_TIMECODE_DATATYPES)
1441
+ """
1442
+
1443
+ columns = [col] if not isinstance(col, list) else col
1444
+
1445
+ # Converting "unexpected_types" to tuple as isinstance can accept Tuple
1446
+ # of types too.
1447
+ unexpected_types = tuple(unexpected_types)
1448
+
1449
+ for col in columns:
1450
+ # Get the name of the column if "col" is ColumnExpression.
1451
+ if not isinstance(col, str):
1452
+ col = col.name
1453
+
1454
+ # Check for column existence.
1455
+ if check_exist:
1456
+ _Validators._validate_column_exists_in_dataframe(col, df._metaexpr)
1457
+
1458
+ if isinstance(df[col].type, unexpected_types):
1459
+ if raise_error:
1460
+ invalid_column_types = (col_type.__name__ for col_type in
1461
+ unexpected_types)
1462
+ error_message = Messages.get_message(MessageCodes.INVALID_COLUMN_DATATYPE,
1463
+ col,
1464
+ col_arg,
1465
+ "Unsupported",
1466
+ ", ".join(invalid_column_types))
1467
+ raise TeradataMlException(error_message, MessageCodes.INVALID_COLUMN_DATATYPE)
1468
+
1469
+ else:
1470
+ return False
1471
+
1472
+ return True
1473
+
1474
+ @staticmethod
1475
+ @skip_validation()
1476
+ def _validate_dependent_argument(dependent_arg, dependent_arg_value, independent_arg, independent_arg_value,
1477
+ msg_arg_value=None):
1478
+ """
1479
+ DESCRIPTION:
1480
+ Function validates if an independent argument is specified or not when
1481
+ dependent argument is specified. Raises error, if independent argument
1482
+ is not specified and dependent argument is specified, otherwise returns True.
1483
+
1484
+ PARAMETERS:
1485
+ dependent_arg:
1486
+ Required Argument.
1487
+ Specifies the name of dependent argument.
1488
+ Types: String
1489
+
1490
+ dependent_arg_value:
1491
+ Required Argument.
1492
+ Specifies the value of dependent argument.
1493
+ Types: Any
1494
+
1495
+ independent_arg:
1496
+ Required Argument.
1497
+ Specifies the name of independent argument.
1498
+ Types: String
1499
+
1500
+ independent_arg_value:
1501
+ Required Argument.
1502
+ Specifies the value of independent argument.
1503
+ Types: Any
1504
+
1505
+ msg_arg_value:
1506
+ Optional Argument.
1507
+ Specifies the independent argument value to be printed in message
1508
+ instead of "(not None)".
1509
+ Types: String
1510
+
1511
+ RETURNS:
1512
+ True, when the independent argument is present for the dependent
1513
+ argument.
1514
+
1515
+ RAISES:
1516
+ TeradataMlException, when independent argument is not specified and
1517
+ dependent argument is specified.
1518
+
1519
+ EXAMPLES:
1520
+ _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1521
+ "independent_arg_name", None)
1522
+ _Validators._validate_dependent_argument("dependent_arg_name", None,
1523
+ "independent_arg_name", admissions_train)
1524
+ _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1525
+ "independent_arg_name", admissions_train)
1526
+ _Validators._validate_dependent_argument("dependent_arg_name", admissions_train,
1527
+ "independent_arg_name", admissions_train,
1528
+ "arg_val")
1529
+ """
1530
+ if dependent_arg_value is not None and independent_arg_value is None:
1531
+ error_code = MessageCodes.DEPENDENT_ARGUMENT
1532
+ error_msg = Messages.get_message(error_code, dependent_arg, independent_arg)
1533
+ if msg_arg_value is None:
1534
+ raise TeradataMlException(error_msg, error_code)
1535
+ else:
1536
+ raise TeradataMlException(error_msg.replace("(not None)", "as '{}'".format(msg_arg_value)),
1537
+ MessageCodes.DEPENDENT_ARGUMENT)
1538
+ return True
1539
+
1540
+ @staticmethod
1541
+ @skip_validation()
1542
+ def _validate_py_type_for_td_type_conversion(py_type, py_type_arg_name):
1543
+ """
1544
+ DESCRIPTION:
1545
+ Function to validate python type, which needs to be converted to TD Type.
1546
+ This function checks whether the python type can be converted to a TD
1547
+ type or not. If PY type is not able to convert TD Type, it then raises
1548
+ an error.
1549
+
1550
+ PARAMETERS:
1551
+ py_type:
1552
+ Required Argument.
1553
+ Specifies the python type.
1554
+ Types: Any
1555
+
1556
+ py_type_arg_name:
1557
+ Required Argument.
1558
+ Specifies the name of argument which holds python variable.
1559
+ Types: str
1560
+
1561
+ RETURNS:
1562
+ None
1563
+
1564
+ RAISES:
1565
+ TeradataMLException
1566
+
1567
+ EXAMPLES:
1568
+ _Validators._validate_py_type_for_td_type_conversion(int, "arg1")
1569
+ """
1570
+ if py_type not in _DtypesMappers.PY_TD_MAPPER:
1571
+ error_code = MessageCodes.UNSUPPORTED_DATATYPE
1572
+ error_msg = Messages.get_message(
1573
+ error_code, py_type_arg_name, '[{}]'.format(", ".join((t.__name__ for t in _DtypesMappers.PY_TD_MAPPER))))
1574
+ raise TeradataMlException(error_msg, error_code)
1575
+
1576
+ @staticmethod
1577
+ @skip_validation()
1578
+ def _validate_function_install_location_is_set(option, function_type, option_name):
1579
+ """
1580
+ DESCRIPTION:
1581
+ Function to validate whether install location for functions is set.
1582
+
1583
+ PARAMETERS:
1584
+ option:
1585
+ Required Argument.
1586
+ Specifies the configuration option value to validate.
1587
+ Types: str
1588
+
1589
+ function_type:
1590
+ Required Argument.
1591
+ Specifies the type of function to check installed location for.
1592
+ Types: str
1593
+
1594
+ option_name:
1595
+ Required Argument.
1596
+ Specifies the configuration option name.
1597
+ Types: str
1598
+
1599
+ RETURNS:
1600
+ None
1601
+
1602
+ RAISES:
1603
+ TeradataMLException
1604
+
1605
+ EXAMPLES:
1606
+ _Validators._validate_function_install_location_is_set(
1607
+ configure.byom_install_location,
1608
+ "Bring Your Own Model",
1609
+ "configure.byom_install_location")
1610
+ """
1611
+ # Check whether an empty string is passed to "option".
1612
+ _Validators._validate_input_columns_not_empty(option, option_name)
1613
+
1614
+ if option is None:
1615
+ message = Messages.get_message(MessageCodes.UNKNOWN_INSTALL_LOCATION,
1616
+ "{} functions".format(function_type),
1617
+ "option '{}'".format(option_name))
1618
+ raise TeradataMlException(message, MessageCodes.MISSING_ARGS)
1619
+
1620
+ @staticmethod
1621
+ @skip_validation()
1622
+ def _check_table_exists(conn, table_name,
1623
+ schema_name,
1624
+ raise_error_if_does_not_exists=True,
1625
+ additional_error=''):
1626
+ """
1627
+ DESCRIPTION:
1628
+ Check whether table specified exists or not.
1629
+
1630
+ PARAMETERS:
1631
+ raise_error_if_does_not_exists:
1632
+ Optional Argument.
1633
+ Specifies the flag to decide whether to raise error when table name specified does not exist.
1634
+ Default Value: True (Raise exception)
1635
+ Types: bool
1636
+
1637
+ additional_error:
1638
+ Optional Argument.
1639
+ Specifies the additional error message to display along with standard message.
1640
+ Default Value: ''
1641
+ Types: String
1642
+
1643
+ RAISES:
1644
+ TeradataMlException.
1645
+
1646
+ RETURNS:
1647
+ True, if table exists, else False.
1648
+
1649
+ EXAMPLES:
1650
+ >>> _check_table_exists('model_table_name','model_schema_name')
1651
+ """
1652
+
1653
+ # Check whether table exists on the system or not.
1654
+ table_exists = conn.dialect.has_table(conn, table_name=table_name,
1655
+ schema=schema_name)
1656
+
1657
+ # If tables exists, return True.
1658
+ if table_exists:
1659
+ return True
1660
+
1661
+ # We are here means the specified table does not exist.
1662
+ # Let's raise error if 'raise_error_if_does_not_exists' set to True.
1663
+ if raise_error_if_does_not_exists:
1664
+ # Raise error, as the specified table_name does not exist.
1665
+ # TABLE_DOES_NOT_EXIST
1666
+ raise TeradataMlException(Messages.get_message(MessageCodes.TABLE_DOES_NOT_EXIST,
1667
+ schema_name, table_name, additional_error),
1668
+ MessageCodes.TABLE_DOES_NOT_EXIST)
1669
+ return False
1670
+
1671
+ @staticmethod
1672
+ @skip_validation()
1673
+ def _check_empty_file(file_path):
1674
+ """
1675
+ Description:
1676
+ Function to validate whether the given file is not empty,
1677
+ given absolute file path.
1678
+
1679
+ PARAMETERS:
1680
+ file_path:
1681
+ Required Argument.
1682
+ Specifies absolute file path of the file.
1683
+ Types: str
1684
+
1685
+ RETURNS:
1686
+ Boolean
1687
+
1688
+ RAISES:
1689
+ TeradataMlException
1690
+
1691
+ EXAMPLES:
1692
+ _check_empty_file("/abc/xyz.txt")
1693
+ """
1694
+
1695
+ if os.stat(file_path).st_size == 0:
1696
+ raise TeradataMlException(
1697
+ Messages.get_message(MessageCodes.EMPTY_FILE,
1698
+ "{}".format(file_path)),
1699
+ MessageCodes.EMPTY_FILE)
1700
+ return True
1701
+
1702
+ @staticmethod
1703
+ @skip_validation()
1704
+ def _validate_mutually_inclusive_arguments(arg1, err_disp_arg1_name, arg2,
1705
+ err_disp_arg2_name):
1706
+ """
1707
+ DESCRIPTION:
1708
+ Function to validate whether "arg1" and "arg2" are mutually inclusive.
1709
+
1710
+ PARAMETERS:
1711
+ arg1:
1712
+ Required Argument.
1713
+ Specifies the value of argument1.
1714
+ Types: Any
1715
+
1716
+ err_disp_arg1_name:
1717
+ Required Argument.
1718
+ Specifies the name of argument1.
1719
+ Types: str
1720
+
1721
+ arg2:
1722
+ Required Argument.
1723
+ Specifies the value of argument2.
1724
+ Types: Any
1725
+
1726
+ err_disp_arg2_name:
1727
+ Required Argument.
1728
+ Specifies the name of argument2.
1729
+ Types: str
1730
+
1731
+ RETURNS:
1732
+ True, if both arg1 and arg2 are present or both are None.
1733
+
1734
+ RAISES:
1735
+ TeradataMLException
1736
+
1737
+ EXAMPLES:
1738
+ _Validators._validate_mutually_inclusive_arguments(arg1, "arg1", arg2, "arg2")
1739
+ """
1740
+ both_args_none = arg1 is None and arg2 is None
1741
+ # If below handles 0 value.
1742
+ # 0 turns to False using bool(0) but 0 is a valid value and should return True.
1743
+ arg1 = True if arg1 == 0 else bool(arg1)
1744
+ arg2 = True if arg2 == 0 else bool(arg2)
1745
+
1746
+ # Either both the arguments are specified or both are None.
1747
+ if not(all([arg1, arg2]) or both_args_none):
1748
+ arg_order = [err_disp_arg1_name, err_disp_arg2_name] if arg1 \
1749
+ else [err_disp_arg2_name, err_disp_arg1_name]
1750
+ raise TeradataMlException(Messages.get_message(
1751
+ MessageCodes.DEPENDENT_ARGUMENT, arg_order[0],
1752
+ arg_order[1]), MessageCodes.DEPENDENT_ARGUMENT)
1753
+ return True
1754
+
1755
+ @staticmethod
1756
+ @skip_validation()
1757
+ def _validate_file_extension(file_path, extension):
1758
+ """
1759
+ DESCRIPTION:
1760
+ Function to validate whether the file has a specified extension.
1761
+
1762
+ PARAMETERS:
1763
+ file_path:
1764
+ Required Argument.
1765
+ Specifies the file path or file name.
1766
+ Types: str
1767
+
1768
+ extension:
1769
+ Required Argument.
1770
+ Specifies the extension of the file.
1771
+ Types: str OR list of Strings (str)
1772
+
1773
+ RETURNS:
1774
+ True, if the file has specified extension.
1775
+
1776
+ RAISES:
1777
+ TeradataMLException
1778
+
1779
+ EXAMPLES:
1780
+
1781
+ _Validators._validate_file_extension("/data/mapper.py",".py")
1782
+ _Validators._validate_file_extension("ml__demoenv_requirements_1605727131624097.txt",".txt")
1783
+ """
1784
+ extension = extension if isinstance(extension, list) else[extension]
1785
+ file_extension = file_path.lower().split('.')[-1]
1786
+ if file_extension not in extension:
1787
+ raise TeradataMlException(
1788
+ Messages.get_message(MessageCodes.UNSUPPORTED_FILE_EXTENSION).format("{}".format(extension)),
1789
+ MessageCodes.UNSUPPORTED_FILE_EXTENSION)
1790
+
1791
+ return True
1792
+
1793
+
1794
+ @staticmethod
1795
+ @skip_validation()
1796
+ def _validate_argument_is_not_None(arg, arg_name, additional_error="", reverse=False):
1797
+ """
1798
+ DESCRIPTION:
1799
+ Check whether the argument provided is not None.
1800
+ If parameter reverse is set to True, the validation is reversed to
1801
+ check whether argument provided is None.
1802
+
1803
+ PARAMETERS:
1804
+ arg:
1805
+ Required Argument.
1806
+ Specifies the argument to be validated.
1807
+ Types: str
1808
+
1809
+ arg_name:
1810
+ Required Argument.
1811
+ Specifies the name of the argument to be printed in error message.
1812
+ Types: str
1813
+
1814
+ additional_error:
1815
+ Optional Argument.
1816
+ Specifies the additional error message to display along with standard message.
1817
+ Default value=""
1818
+ Types: str
1819
+
1820
+ reverse:
1821
+ Optional Argument.
1822
+ Specifies whether to reverse the validation.
1823
+ Returns True if arg is None, False if arg is not None.
1824
+ Default value=False
1825
+ Types: bool
1826
+
1827
+
1828
+ RAISES:
1829
+ ValueError.
1830
+
1831
+ RETURNS:
1832
+ True, if the argument is not None, else False.
1833
+
1834
+ EXAMPLES:
1835
+ >>> _validate_argument_is_not_None(table_name, "table_name", additional_error)
1836
+ """
1837
+ if not reverse:
1838
+ # Raise an error if the argument is None.
1839
+ if arg is None:
1840
+ raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name, "None", additional_error))
1841
+ return True
1842
+ else:
1843
+ # Raise an error if the argument is not None.
1844
+ if arg is not None:
1845
+ raise ValueError(Messages.get_message(MessageCodes.ARG_NONE, arg_name,
1846
+ "provided {}".format(additional_error), ""))
1847
+ return True
1848
+
1849
+
1850
+ @staticmethod
1851
+ @skip_validation()
1852
+ def _validate_dataframe(df, raise_error=True):
1853
+ """
1854
+ This is an internal function checks whether the dataframe is none
1855
+ or not. If not none then checks the dataframe type and length of columns.
1856
+
1857
+ PARAMETERS:
1858
+ df:
1859
+ Required Argument.
1860
+ Specifies the dataframe.
1861
+ Types: pandas.DataFrame or teradataml.dataframe.dataframe.DataFrame
1862
+
1863
+ raise_error:
1864
+ Optional Argument.
1865
+ Specifies whether to raise an exception or not.
1866
+ Default Values: True
1867
+ Types: bool
1868
+
1869
+ RETURNS:
1870
+ None
1871
+
1872
+ RAISES:
1873
+ TeradataMlException
1874
+
1875
+ EXAMPLES:
1876
+ _validate_dataframe(df)
1877
+
1878
+ """
1879
+ from teradataml.dataframe import dataframe as tdmldf
1880
+
1881
+ valid = False
1882
+ if df is not None:
1883
+ if isinstance(df, pd.DataFrame) and len(df.columns) > 0:
1884
+ valid = True
1885
+ elif isinstance(df, tdmldf.DataFrame) and len(df._metaexpr.c) > 0:
1886
+ valid = True
1887
+ else:
1888
+ valid = False
1889
+
1890
+ if raise_error and not valid:
1891
+ raise TeradataMlException(Messages.get_message(MessageCodes.IS_NOT_VALID_DF),
1892
+ MessageCodes.IS_NOT_VALID_DF)
1893
+
1894
+
1895
+ @staticmethod
1896
+ @skip_validation()
1897
+ def _validate_column_value_length(argument_name, argument_value, allowed_length,
1898
+ operation='perform the operation'):
1899
+ """
1900
+ DESCRIPTION:
1901
+ Function to validate length of string against permitted value.
1902
+
1903
+ PARAMETERS:
1904
+ argument_name:
1905
+ Required Argument.
1906
+ Specifies the name of the argument whose value
1907
+ will be checked against permitted length.
1908
+ This is used while raising an error.
1909
+ Types: str.
1910
+
1911
+ argument_value:
1912
+ Required Argument.
1913
+ Specifies the string whose length will be checked against permitted length.
1914
+ Types: str.
1915
+
1916
+ allowed_length:
1917
+ Required Argument.
1918
+ Specifies the allowed length for argument value.
1919
+ Types: int.
1920
+
1921
+ operation:
1922
+ Optional Argument.
1923
+ Specifies the name of operation which will fail, if this check fails.
1924
+ Default value: 'perform the operation'.
1925
+ Types: str.
1926
+
1927
+ RETURNS:
1928
+ None.
1929
+
1930
+ RAISES:
1931
+ TeradataMlException - EXECUTION_FAILED, ValueError
1932
+
1933
+ EXAMPLES:
1934
+ >>> _validate_column_value_length("Description", "KMeans model", 150, "save the model")
1935
+ """
1936
+ try:
1937
+ _Validators._validate_str_arg_length(argument_name, argument_value, 'LE', allowed_length)
1938
+ except ValueError:
1939
+ error_code = MessageCodes.EXECUTION_FAILED
1940
+ error_msg = Messages.get_message(
1941
+ error_code, operation,
1942
+ 'Length of argument {0} ({1}) is more than the allowed length ({2}).'
1943
+ .format(argument_name, len(argument_value), allowed_length))
1944
+ raise TeradataMlException(error_msg, error_code)
1945
+ return True
1946
+
1947
+
1948
+ @staticmethod
1949
+ @skip_validation()
1950
+ def _validate_list_lengths_equal(list1, arg_name1, list2, arg_name2):
1951
+ """
1952
+ DESCRIPTION:
1953
+ Check if length of the lists is same or not.
1954
+
1955
+ PARAMETERS:
1956
+ list1:
1957
+ Required Argument.
1958
+ Specifies the first list to check the length against "list2".
1959
+ Types: list
1960
+
1961
+ arg_name1:
1962
+ Required Argument.
1963
+ Specifies the name of the argument that accepts "list1" as input.
1964
+ This is used while raising an error.
1965
+ Types: str
1966
+
1967
+ list2:
1968
+ Required Argument.
1969
+ Specifies the second list to check the length against "list1".
1970
+ Types: list
1971
+
1972
+ arg_name2:
1973
+ Required Argument.
1974
+ Specifies the name of the argument that accepts "list2" as input.
1975
+ This is used while raising an error.
1976
+ Types: str
1977
+
1978
+ RETURNS:
1979
+ None.
1980
+
1981
+ RAISES:
1982
+ ValueError
1983
+
1984
+ EXAMPLES:
1985
+ _Validators._validate_list_lengths_equal(self.coordinates, "coordinates",
1986
+ self.timestamps, "timestamps")
1987
+ """
1988
+ if len(list1) != len(list2):
1989
+ # Raise error, if length of both lists is not same.
1990
+ err_ = Messages.get_message(MessageCodes.INVALID_LENGTH_ARGS,
1991
+ "'{}' and '{}'".format(arg_name1, arg_name2))
1992
+ raise ValueError(err_)
1993
+ return True
1994
+
1995
+ @staticmethod
1996
+ @skip_validation()
1997
+ def _validate_dict_argument_key_value(arg_name, arg_dict, key_types=None, value_types=None,
1998
+ key_permitted_values=None, value_permitted_values=None,
1999
+ value_empty_string=True):
2000
+ """
2001
+ DESCRIPTION:
2002
+ Internal function to validate type and permitted values
2003
+ for keys and values in a dictionary argument.
2004
+
2005
+ PARAMETERS:
2006
+ arg_name:
2007
+ Required Argument.
2008
+ Specifies the name of the dictionary argument.
2009
+ Types: str
2010
+
2011
+ arg_dict:
2012
+ Required Argument.
2013
+ Specifies the dictonary value of "arg_name".
2014
+ Types: dict
2015
+
2016
+ key_types:
2017
+ Optional Argument.
2018
+ Specifies the types, 'keys' of the "arg_dict" can take.
2019
+ Types: Any type or tuple of types
2020
+
2021
+ value_types:
2022
+ Optional Argument.
2023
+ Specifies the types, 'values' assigned to 'keys' of
2024
+ "arg_dict" can take.
2025
+ Types: Any type or tuple of types
2026
+
2027
+ key_permitted_values:
2028
+ Optional Argument.
2029
+ Specifies the permitted values for the 'keys' of "arg_dict".
2030
+ Types: list
2031
+
2032
+ value_permitted_values:
2033
+ Optional Argument.
2034
+ Specifies the permitted values for the 'values' assgined to 'keys'
2035
+ of "arg_dict".
2036
+ Types: list
2037
+
2038
+ value_empty_string:
2039
+ Optional Argument.
2040
+ Specifies the whether 'values' assigned to 'keys' of "arg_dict"
2041
+ can accept empty string.
2042
+ Set to True, dictionary value with empty string is accepted.
2043
+ Set to False, dictionary value with empty string is not accepted.
2044
+ Default Value: True
2045
+ Types: bool
2046
+
2047
+ RETURNS:
2048
+ bool
2049
+
2050
+ RAISES:
2051
+ TypeError, ValueError
2052
+
2053
+ EXAMPLES:
2054
+ _Validators._validate_dict_argument_key_value("name", {"a":3, "b":4}, (str), (int))
2055
+ _Validators._validate_dict_argument_key_value(arg_name="columns", arg_dict=columns,
2056
+ key_types=(ColumnExpression, _TupleOf(ColumnExpression)),
2057
+ value_types=(str, int, float, NoneType))
2058
+
2059
+ """
2060
+ info_matrix = []
2061
+ dict_keys_list = set()
2062
+ from teradataml.common.utils import UtilFuncs
2063
+
2064
+ try:
2065
+ for key, value in arg_dict.items():
2066
+ # Validate duplicate keys exists or not.
2067
+ # If keys are not of type tuple, convert it to tuple.
2068
+ keys_list = (key,) if not isinstance(key, tuple) else key
2069
+
2070
+ # If duplicate key exists raise exception. E.g.
2071
+ # di = {("key1", "key2"): "my_keys1",
2072
+ # ("key1", "key3"): "my_keys2",
2073
+ # "key2" : "my_keys3"}
2074
+ for k in keys_list:
2075
+ # If ColumnExpression, get the column name.
2076
+ if isinstance(k, ColumnExpression):
2077
+ k_name, name = k.name, "ColumnExpression(s)"
2078
+ else:
2079
+ k_name, name = k, "Key names"
2080
+
2081
+ # If duplicate key exists raise exception.
2082
+ if k_name in dict_keys_list:
2083
+ raise TeradataMlException(Messages.get_message(
2084
+ MessageCodes.DUPLICATE_DICT_KEYS_NAMES,
2085
+ name, arg_name),
2086
+ MessageCodes.DUPLICATE_PARAMETER)
2087
+ else:
2088
+ dict_keys_list.add(k_name)
2089
+
2090
+ # Append "keys" and "values" into arg info matrix for type validation.
2091
+ if key_types is not None:
2092
+ info_matrix.append(["<dict_key>", key, True, key_types, True])
2093
+
2094
+ if value_types is not None:
2095
+ info_matrix.append(
2096
+ ["<dict_value>", value, True, value_types, not value_empty_string])
2097
+
2098
+ # Validate permitted values for both "key" and "value" if permitted values
2099
+ # are provided.
2100
+ if key_permitted_values is not None:
2101
+ _Validators._validate_permitted_values(arg=key,
2102
+ permitted_values=key_permitted_values,
2103
+ arg_name="<dict_key>",
2104
+ case_insensitive=False,
2105
+ includeNone=True)
2106
+
2107
+ if value_permitted_values is not None:
2108
+ _Validators._validate_permitted_values(arg=value,
2109
+ permitted_values=value_permitted_values,
2110
+ arg_name="<dict_value>",
2111
+ case_insensitive=False,
2112
+ includeNone=True)
2113
+
2114
+ if key_types is not None or value_types is not None:
2115
+ # Validate types using already existing validator.
2116
+ _Validators._validate_function_arguments(info_matrix)
2117
+
2118
+ except ValueError as ve:
2119
+ # Catch ValueError raised by '_validate_permitted_values' to
2120
+ # raise proper error message for dictionary argument.
2121
+ if "TDML_2007" in str(ve):
2122
+ permitted_values = value_permitted_values
2123
+ err_str = "value"
2124
+ err_val = value
2125
+ if "<dict_key>" in str(ve):
2126
+ permitted_values = key_permitted_values
2127
+ err_str = "key"
2128
+ err_val = key
2129
+ raise ValueError(
2130
+ Messages.get_message(MessageCodes.INVALID_DICT_ARG_VALUE, err_val,
2131
+ err_str, arg_name, permitted_values))
2132
+
2133
+ # Catch ValueError raised by '_validate_function_arguments'
2134
+ # for empty string value.
2135
+ elif "TDML_2004" in str(ve):
2136
+ err_str = "Key" if "<dict_key>" in str(ve) else "Value"
2137
+ raise ValueError(
2138
+ Messages.get_message(MessageCodes.DICT_ARG_KEY_VALUE_EMPTY,
2139
+ err_str, arg_name))
2140
+
2141
+ except TypeError as te:
2142
+ # Catch TypeError raised by '_validate_function_arguments' to
2143
+ # raise proper error message for dictionary argument.
2144
+ permitted_types = value_types
2145
+ err_str = "value"
2146
+ if "<dict_key>" in str(te):
2147
+ permitted_types = key_types
2148
+ err_str = "key"
2149
+
2150
+ permitted_types = [''.join(_Validators.__getTypeAsStr(kv_type))
2151
+ if isinstance(kv_type, (_TupleOf, _ListOf)) else
2152
+ kv_type.__name__ for kv_type in permitted_types]
2153
+
2154
+ raise TypeError(
2155
+ Messages.get_message(MessageCodes.UNSUPPORTED_DICT_KEY_VALUE_DTYPE, err_str,
2156
+ arg_name, permitted_types))
2157
+
2158
+ return True
2159
+
2160
+ @staticmethod
2161
+ @skip_validation()
2162
+ def _validate_http_response(http_response, valid_status_code, error_msg):
2163
+ """
2164
+ DESCRIPTION:
2165
+ Internal function to validate the HTTP response.
2166
+
2167
+ PARAMETERS:
2168
+ http_response:
2169
+ Required Argument.
2170
+ Specifies the response object recieved from HTTP request.
2171
+ Types: requests.models.Response OR httpx.Response
2172
+
2173
+ valid_status_code:
2174
+ Required Argument.
2175
+ Specifies the HTTP response code of a request.
2176
+ Types: int
2177
+
2178
+ error_msg:
2179
+ Required Argument.
2180
+ Specifies the error message to be displayed when response code is
2181
+ not equal to "valid_status_code".
2182
+ Types: str
2183
+
2184
+ RETURNS:
2185
+ bool
2186
+
2187
+ RAISES:
2188
+ TeradatamlException
2189
+
2190
+ EXAMPLES:
2191
+ _Validators._validate_http_response(resp, 200, "test1")
2192
+ """
2193
+ if http_response.status_code != valid_status_code:
2194
+ err_ = Messages.get_message(MessageCodes.EXECUTION_FAILED,
2195
+ error_msg,
2196
+ "Error-details: ({}){}".format(http_response.status_code, http_response.text))
2197
+ raise TeradataMlException(err_, MessageCodes.EXECUTION_FAILED)
2198
+
2199
+ return True
2200
+
2201
+ @staticmethod
2202
+ @skip_validation()
2203
+ def _validate_module_presence(module_name, function_name):
2204
+ """
2205
+ DESCRIPTION:
2206
+ Check if module being imported is present.
2207
+
2208
+ PARAMETERS:
2209
+ module_name:
2210
+ Required Argument.
2211
+ Specifies the name of the module to import.
2212
+ Types: str
2213
+
2214
+ function_name:
2215
+ Required Argument.
2216
+ Specifies the name of the function from where module is imported.
2217
+ Types: str
2218
+
2219
+ RETURNS:
2220
+ None.
2221
+
2222
+ RAISES:
2223
+ TeradataMlException
2224
+
2225
+ EXAMPLES:
2226
+ _Validators._validate_module_presence("docker", "setup_sandbox_env")
2227
+ """
2228
+ import importlib
2229
+
2230
+ try:
2231
+ importlib.import_module(module_name, package=None)
2232
+ except Exception as err:
2233
+ message = \
2234
+ Messages.get_message(
2235
+ MessageCodes.IMPORT_PYTHON_PACKAGE,
2236
+ module_name, module_name, function_name)
2237
+ raise TeradataMlException(message,
2238
+ MessageCodes.IMPORT_PYTHON_PACKAGE)
2239
+ return True