teradataml 20.0.0.2__py3-none-any.whl → 20.0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of teradataml might be problematic. Click here for more details.
- teradataml/LICENSE-3RD-PARTY.pdf +0 -0
- teradataml/README.md +315 -2
- teradataml/__init__.py +4 -0
- teradataml/_version.py +1 -1
- teradataml/analytics/analytic_function_executor.py +95 -8
- teradataml/analytics/byom/__init__.py +1 -1
- teradataml/analytics/json_parser/metadata.py +12 -3
- teradataml/analytics/json_parser/utils.py +7 -2
- teradataml/analytics/sqle/__init__.py +5 -1
- teradataml/analytics/table_operator/__init__.py +1 -1
- teradataml/analytics/uaf/__init__.py +1 -1
- teradataml/analytics/utils.py +4 -0
- teradataml/analytics/valib.py +18 -4
- teradataml/automl/__init__.py +51 -6
- teradataml/automl/data_preparation.py +59 -35
- teradataml/automl/data_transformation.py +58 -33
- teradataml/automl/feature_engineering.py +27 -12
- teradataml/automl/model_training.py +73 -46
- teradataml/common/constants.py +88 -29
- teradataml/common/garbagecollector.py +2 -1
- teradataml/common/messagecodes.py +19 -3
- teradataml/common/messages.py +6 -1
- teradataml/common/sqlbundle.py +64 -12
- teradataml/common/utils.py +246 -47
- teradataml/common/warnings.py +11 -0
- teradataml/context/context.py +161 -27
- teradataml/data/amazon_reviews_25.csv +26 -0
- teradataml/data/byom_example.json +11 -0
- teradataml/data/dataframe_example.json +18 -2
- teradataml/data/docs/byom/docs/DataRobotPredict.py +2 -2
- teradataml/data/docs/byom/docs/DataikuPredict.py +40 -1
- teradataml/data/docs/byom/docs/H2OPredict.py +2 -2
- teradataml/data/docs/byom/docs/ONNXEmbeddings.py +242 -0
- teradataml/data/docs/byom/docs/ONNXPredict.py +2 -2
- teradataml/data/docs/byom/docs/PMMLPredict.py +2 -2
- teradataml/data/docs/sqle/docs_17_20/NaiveBayes.py +1 -1
- teradataml/data/docs/sqle/docs_17_20/Shap.py +34 -6
- teradataml/data/docs/sqle/docs_17_20/TDNaiveBayesPredict.py +4 -4
- teradataml/data/docs/sqle/docs_17_20/TextParser.py +3 -3
- teradataml/data/docs/tableoperator/docs_17_20/Image2Matrix.py +118 -0
- teradataml/data/docs/uaf/docs_17_20/CopyArt.py +145 -0
- teradataml/data/docs/uaf/docs_17_20/DWT2D.py +4 -1
- teradataml/data/docs/uaf/docs_17_20/DickeyFuller.py +18 -21
- teradataml/data/hnsw_alter_data.csv +5 -0
- teradataml/data/hnsw_data.csv +10 -0
- teradataml/data/jsons/byom/h2opredict.json +1 -1
- teradataml/data/jsons/byom/onnxembeddings.json +266 -0
- teradataml/data/jsons/sqle/17.20/TD_Shap.json +0 -1
- teradataml/data/jsons/sqle/17.20/TD_TextParser.json +1 -1
- teradataml/data/jsons/sqle/20.00/TD_HNSW.json +296 -0
- teradataml/data/jsons/sqle/20.00/TD_HNSWPredict.json +206 -0
- teradataml/data/jsons/sqle/20.00/TD_HNSWSummary.json +32 -0
- teradataml/data/jsons/sqle/20.00/TD_KMeans.json +250 -0
- teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +266 -0
- teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +278 -0
- teradataml/data/jsons/storedprocedure/17.20/TD_COPYART.json +71 -0
- teradataml/data/jsons/tableoperator/17.20/IMAGE2MATRIX.json +53 -0
- teradataml/data/jsons/uaf/17.20/TD_DICKEY_FULLER.json +10 -19
- teradataml/data/jsons/uaf/17.20/TD_SAX.json +3 -1
- teradataml/data/jsons/uaf/17.20/TD_WINDOWDFFT.json +15 -5
- teradataml/data/medical_readings.csv +101 -0
- teradataml/data/patient_profile.csv +101 -0
- teradataml/data/scripts/lightgbm/dataset.template +157 -0
- teradataml/data/scripts/lightgbm/lightgbm_class_functions.template +247 -0
- teradataml/data/scripts/lightgbm/lightgbm_function.template +216 -0
- teradataml/data/scripts/lightgbm/lightgbm_sklearn.template +159 -0
- teradataml/data/scripts/sklearn/sklearn_fit.py +194 -167
- teradataml/data/scripts/sklearn/sklearn_fit_predict.py +136 -115
- teradataml/data/scripts/sklearn/sklearn_function.template +14 -19
- teradataml/data/scripts/sklearn/sklearn_model_selection_split.py +155 -137
- teradataml/data/scripts/sklearn/sklearn_transform.py +129 -42
- teradataml/data/target_udt_data.csv +8 -0
- teradataml/data/templates/open_source_ml.json +3 -2
- teradataml/data/teradataml_example.json +8 -0
- teradataml/data/vectordistance_example.json +4 -0
- teradataml/dataframe/copy_to.py +8 -3
- teradataml/dataframe/data_transfer.py +11 -1
- teradataml/dataframe/dataframe.py +1049 -285
- teradataml/dataframe/dataframe_utils.py +152 -20
- teradataml/dataframe/functions.py +578 -35
- teradataml/dataframe/setop.py +11 -6
- teradataml/dataframe/sql.py +185 -16
- teradataml/dbutils/dbutils.py +1049 -115
- teradataml/dbutils/filemgr.py +48 -1
- teradataml/hyperparameter_tuner/optimizer.py +12 -1
- teradataml/lib/aed_0_1.dll +0 -0
- teradataml/opensource/__init__.py +1 -1
- teradataml/opensource/_base.py +1466 -0
- teradataml/opensource/_class.py +464 -0
- teradataml/opensource/{sklearn/constants.py → _constants.py} +21 -14
- teradataml/opensource/_lightgbm.py +949 -0
- teradataml/opensource/_sklearn.py +1008 -0
- teradataml/opensource/{sklearn/_wrapper_utils.py → _wrapper_utils.py} +5 -6
- teradataml/options/__init__.py +54 -38
- teradataml/options/configure.py +131 -27
- teradataml/options/display.py +13 -2
- teradataml/plot/axis.py +47 -8
- teradataml/plot/figure.py +33 -0
- teradataml/plot/plot.py +63 -13
- teradataml/scriptmgmt/UserEnv.py +5 -5
- teradataml/scriptmgmt/lls_utils.py +130 -40
- teradataml/store/__init__.py +12 -0
- teradataml/store/feature_store/__init__.py +0 -0
- teradataml/store/feature_store/constants.py +291 -0
- teradataml/store/feature_store/feature_store.py +2318 -0
- teradataml/store/feature_store/models.py +1505 -0
- teradataml/table_operators/Apply.py +32 -18
- teradataml/table_operators/Script.py +3 -1
- teradataml/table_operators/TableOperator.py +3 -1
- teradataml/table_operators/query_generator.py +3 -0
- teradataml/table_operators/table_operator_query_generator.py +3 -1
- teradataml/table_operators/table_operator_util.py +37 -38
- teradataml/table_operators/templates/dataframe_register.template +69 -0
- teradataml/utils/dtypes.py +51 -2
- teradataml/utils/internal_buffer.py +18 -0
- teradataml/utils/validators.py +99 -8
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/METADATA +321 -5
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/RECORD +121 -94
- teradataml/libaed_0_1.dylib +0 -0
- teradataml/libaed_0_1.so +0 -0
- teradataml/opensource/sklearn/__init__.py +0 -1
- teradataml/opensource/sklearn/_class.py +0 -255
- teradataml/opensource/sklearn/_sklearn_wrapper.py +0 -1800
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/WHEEL +0 -0
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/top_level.txt +0 -0
- {teradataml-20.0.0.2.dist-info → teradataml-20.0.0.4.dist-info}/zip-safe +0 -0
|
@@ -86,6 +86,7 @@ class ErrorInfoCodes(Enum):
|
|
|
86
86
|
LIST_DB_TABLES_FAILED = 'TDML_2053'
|
|
87
87
|
INVALID_CONTEXT_CONNECTION = 'TDML_2054'
|
|
88
88
|
TDMLDF_REQUIRED_TABLE_ALIAS = "TDML_2055"
|
|
89
|
+
TDMLDF_ALIAS_REQUIRED = TDMLDF_REQUIRED_TABLE_ALIAS
|
|
89
90
|
TDMLDF_COLUMN_ALREADY_EXISTS = "TDML_2056"
|
|
90
91
|
TDMLDF_AGGREGATE_INVALID_COLUMN = 'TDML_2057'
|
|
91
92
|
TDMLDF_AGGREGATE_COMBINED_ERR = 'TDML_2058'
|
|
@@ -163,7 +164,7 @@ class ErrorInfoCodes(Enum):
|
|
|
163
164
|
AED_SETOP_INPUT_TABLE_COLUMNS_COUNT_MISMATCH = 'TDML_2111'
|
|
164
165
|
AED_SHOW_QUERY_MULTIPLE_OPTIONS = 'TDML_2112'
|
|
165
166
|
|
|
166
|
-
# Table Operator Error Codes starting from 2300 - Reserved till
|
|
167
|
+
# Table Operator Error Codes starting from 2300 - Reserved till 2314
|
|
167
168
|
INPUT_FILE_NOT_FOUND = 'TDML_2300'
|
|
168
169
|
REMOVE_FILE_FAILED = 'TDML_2301'
|
|
169
170
|
INSTALL_FILE_FAILED = 'TDML_2302'
|
|
@@ -174,6 +175,8 @@ class ErrorInfoCodes(Enum):
|
|
|
174
175
|
NOT_ALLOWED_VALUES = 'TDML_2307'
|
|
175
176
|
ARGUMENT_VALUE_SAME = 'TDML_2308'
|
|
176
177
|
PYTHON_NOT_INSTALLED = 'TDML_2309'
|
|
178
|
+
PYTHON_VERSION_MISMATCH = 'TDML_2310'
|
|
179
|
+
PYTHON_VERSION_MISMATCH_OAF = 'TDML_2416'
|
|
177
180
|
EMPTY_FILE = 'TDML_2311'
|
|
178
181
|
ARG_NONE = 'TDML_2312'
|
|
179
182
|
EITHER_FUNCTION_OR_ARGS = 'TDML_2313'
|
|
@@ -221,6 +224,9 @@ class ErrorInfoCodes(Enum):
|
|
|
221
224
|
INVALID_PARTITIONING_COLS = 'TDML_2540'
|
|
222
225
|
TARGET_COL_NOT_FOUND_FOR_EVALUATE = 'TDML_2541'
|
|
223
226
|
|
|
227
|
+
# OpenAF Error codes starting from 2551 - Reserved till 2560.
|
|
228
|
+
SET_REQUIRED_PARAMS = 'TDML_2551'
|
|
229
|
+
|
|
224
230
|
class MessageCodes(Enum):
|
|
225
231
|
"""
|
|
226
232
|
MessageCodes contains all the messages that are displayed to the user which are informational
|
|
@@ -274,6 +280,7 @@ class MessageCodes(Enum):
|
|
|
274
280
|
"and df.select([['col1', 'col2', 'col3']])."
|
|
275
281
|
TDMLDF_INVALID_TABLE_ALIAS = "{} should not be equal."
|
|
276
282
|
TDMLDF_REQUIRED_TABLE_ALIAS = "All arguments lsuffix, rsuffix, lprefix and rprefix should not be None as TeradataML DataFrames contains common column(s)."
|
|
283
|
+
TDMLDF_ALIAS_REQUIRED = "Use aliased DataFrames for self {}."
|
|
277
284
|
TDMLDF_COLUMN_ALREADY_EXISTS = "Column name with alias '{}' already exists in {} TeradataML DataFrame, change '{}'"
|
|
278
285
|
TDMLDF_INVALID_JOIN_CONDITION = "Invalid 'on' condition(s): '{}', check documentation for valid conditions."
|
|
279
286
|
TDMLDF_UNEQUAL_NUMBER_OF_COLUMNS = "Number of columns in '{}' and '{}' should be equal."
|
|
@@ -391,6 +398,10 @@ class MessageCodes(Enum):
|
|
|
391
398
|
|
|
392
399
|
PYTHON_NOT_INSTALLED = "Python is not installed on Vantage. " \
|
|
393
400
|
"Please install Python interpreter and add-on packages on Vantage."
|
|
401
|
+
PYTHON_VERSION_MISMATCH = "Python version on Vantage is not same as that of local environment. " \
|
|
402
|
+
"Use the same Python version '{}' or '{}.x' in local environment."
|
|
403
|
+
PYTHON_VERSION_MISMATCH_OAF = "Python version of Lake user environment '{}' is not same as that of local environment '{}'. " \
|
|
404
|
+
"Maintain similar version of Python between Lake user environment and local environment."
|
|
394
405
|
IMPORT_PYTHON_PACKAGE = "Module '{}' not found. Install '{}' before running {}()."
|
|
395
406
|
INT_ARGUMENT_COMPARISON = "Argument '{}' must be {} to argument '{}'"
|
|
396
407
|
EXECUTION_FAILED = "Failed to {}. {}"
|
|
@@ -419,9 +430,14 @@ class MessageCodes(Enum):
|
|
|
419
430
|
"they should be present in '{}' DataFrame."
|
|
420
431
|
PARTITIONING_COLS_IN_FEATURE_COLS = "Columns in '{}' argument should not be part of"\
|
|
421
432
|
" feature columns."
|
|
422
|
-
PARTITION_VALUES_NOT_MATCHING = "Values in
|
|
433
|
+
PARTITION_VALUES_NOT_MATCHING = "Values in {} and {} data partition columns should be same."
|
|
423
434
|
PARTITION_IN_BOTH_FIT_AND_PREDICT = "Use \"partition_columns\" only if model is fitted with partition_column(s)."
|
|
424
435
|
INVALID_PARTITIONING_COLS = "Provided partition_column(s) '{}' is/are not present in parent of '{}' DataFrame(s)."
|
|
425
436
|
PATH_NOT_FOUND = "Specified local path '{}' not found. Please check the path."
|
|
426
437
|
TARGET_COL_NOT_FOUND_FOR_EVALUATE = "Target column '{}' not found in the passed dataFrame. "\
|
|
427
|
-
"evaluate() requires target column to be present in the dataFrame."
|
|
438
|
+
"evaluate() requires target column to be present in the dataFrame."
|
|
439
|
+
SET_REQUIRED_PARAMS = "{} is required to run '{}'. Set it using {}()."
|
|
440
|
+
CONNECTION_PARAMS = "Required connection parameters are missing. Connection parameters should either be " \
|
|
441
|
+
"explicitly passed to function or specified using a configuration file, or setting up " \
|
|
442
|
+
"the environment variables."
|
|
443
|
+
|
teradataml/common/messages.py
CHANGED
|
@@ -88,6 +88,7 @@ class Messages():
|
|
|
88
88
|
[ErrorInfoCodes.TDMLDF_INVALID_JOIN_CONDITION, MessageCodes.TDMLDF_INVALID_JOIN_CONDITION],
|
|
89
89
|
[ErrorInfoCodes.TDMLDF_INVALID_TABLE_ALIAS, MessageCodes.TDMLDF_INVALID_TABLE_ALIAS],
|
|
90
90
|
[ErrorInfoCodes.TDMLDF_REQUIRED_TABLE_ALIAS, MessageCodes.TDMLDF_REQUIRED_TABLE_ALIAS],
|
|
91
|
+
[ErrorInfoCodes.TDMLDF_ALIAS_REQUIRED, MessageCodes.TDMLDF_ALIAS_REQUIRED],
|
|
91
92
|
[ErrorInfoCodes.TDMLDF_COLUMN_ALREADY_EXISTS, MessageCodes.TDMLDF_COLUMN_ALREADY_EXISTS],
|
|
92
93
|
[ErrorInfoCodes.INVALID_LENGTH_ARGS, MessageCodes.INVALID_LENGTH_ARGS],
|
|
93
94
|
[ErrorInfoCodes.TDMLDF_AGGREGATE_UNSUPPORTED, MessageCodes.TDMLDF_AGGREGATE_UNSUPPORTED],
|
|
@@ -167,6 +168,8 @@ class Messages():
|
|
|
167
168
|
[ErrorInfoCodes.UNSUPPORTED_FILE_EXTENSION, MessageCodes.UNSUPPORTED_FILE_EXTENSION],
|
|
168
169
|
[ErrorInfoCodes.FILE_EMPTY, MessageCodes.FILE_EMPTY],
|
|
169
170
|
[ErrorInfoCodes.PYTHON_NOT_INSTALLED, MessageCodes.PYTHON_NOT_INSTALLED],
|
|
171
|
+
[ErrorInfoCodes.PYTHON_VERSION_MISMATCH, MessageCodes.PYTHON_VERSION_MISMATCH],
|
|
172
|
+
[ErrorInfoCodes.PYTHON_VERSION_MISMATCH_OAF, MessageCodes.PYTHON_VERSION_MISMATCH_OAF],
|
|
170
173
|
[ErrorInfoCodes.INT_ARGUMENT_COMPARISON, MessageCodes.INT_ARGUMENT_COMPARISON],
|
|
171
174
|
[ErrorInfoCodes.EXECUTION_FAILED, MessageCodes.EXECUTION_FAILED],
|
|
172
175
|
[ErrorInfoCodes.INVALID_COLUMN_DATATYPE, MessageCodes.INVALID_COLUMN_DATATYPE],
|
|
@@ -190,7 +193,9 @@ class Messages():
|
|
|
190
193
|
[ErrorInfoCodes.PARTITION_IN_BOTH_FIT_AND_PREDICT, MessageCodes.PARTITION_IN_BOTH_FIT_AND_PREDICT],
|
|
191
194
|
[ErrorInfoCodes.INVALID_PARTITIONING_COLS, MessageCodes.INVALID_PARTITIONING_COLS],
|
|
192
195
|
[ErrorInfoCodes.PATH_NOT_FOUND, MessageCodes.PATH_NOT_FOUND],
|
|
193
|
-
[ErrorInfoCodes.TARGET_COL_NOT_FOUND_FOR_EVALUATE, MessageCodes.TARGET_COL_NOT_FOUND_FOR_EVALUATE]
|
|
196
|
+
[ErrorInfoCodes.TARGET_COL_NOT_FOUND_FOR_EVALUATE, MessageCodes.TARGET_COL_NOT_FOUND_FOR_EVALUATE],
|
|
197
|
+
[ErrorInfoCodes.SET_REQUIRED_PARAMS, MessageCodes.SET_REQUIRED_PARAMS],
|
|
198
|
+
[ErrorInfoCodes.MISSING_ARGS, MessageCodes.CONNECTION_PARAMS]
|
|
194
199
|
]
|
|
195
200
|
|
|
196
201
|
@staticmethod
|
teradataml/common/sqlbundle.py
CHANGED
|
@@ -40,9 +40,9 @@ class SQLBundle:
|
|
|
40
40
|
[SQLConstants.SQL_BASE_QUERY, "SELECT * FROM {0}"],
|
|
41
41
|
[SQLConstants.SQL_SAMPLE_QUERY, " {0} SAMPLE {1}"],
|
|
42
42
|
[SQLConstants.SQL_SAMPLE_WITH_WHERE_QUERY, " {0} WHERE {1} SAMPLE {2}"],
|
|
43
|
-
[SQLConstants.SQL_CREATE_VOLATILE_TABLE_FROM_QUERY_WITH_DATA, "CREATE MULTISET VOLATILE TABLE {0} AS ({1}) WITH DATA ON COMMIT PRESERVE ROWS"],
|
|
44
|
-
[SQLConstants.SQL_CREATE_VOLATILE_TABLE_FROM_QUERY_WITHOUT_DATA, "CREATE MULTISET VOLATILE TABLE {0} AS ({1}) WITH NO DATA"],
|
|
45
|
-
[SQLConstants.SQL_CREATE_VOLATILE_TABLE_USING_COLUMNS, "CREATE MULTISET VOLATILE TABLE {0}( {1} )"],
|
|
43
|
+
[SQLConstants.SQL_CREATE_VOLATILE_TABLE_FROM_QUERY_WITH_DATA, "CREATE MULTISET VOLATILE TABLE {0} AS ({1}) WITH DATA NO PRIMARY INDEX ON COMMIT PRESERVE ROWS"],
|
|
44
|
+
[SQLConstants.SQL_CREATE_VOLATILE_TABLE_FROM_QUERY_WITHOUT_DATA, "CREATE MULTISET VOLATILE TABLE {0} AS ({1}) WITH NO DATA NO PRIMARY INDEX"],
|
|
45
|
+
[SQLConstants.SQL_CREATE_VOLATILE_TABLE_USING_COLUMNS, "CREATE MULTISET VOLATILE TABLE {0}( {1} ) NO PRIMARY INDEX"],
|
|
46
46
|
[SQLConstants.SQL_CREATE_TABLE_FROM_QUERY_WITH_DATA, "CREATE MULTISET TABLE {0} AS ({1}) WITH DATA"],
|
|
47
47
|
[SQLConstants.SQL_HELP_COLUMNS, "help column {0}.*"],
|
|
48
48
|
[SQLConstants.SQL_DROP_TABLE, "DROP TABLE {0}"],
|
|
@@ -67,7 +67,10 @@ class SQLBundle:
|
|
|
67
67
|
[SQLConstants.SQL_DELETE_ALL_ROWS, "DELETE FROM {0}"],
|
|
68
68
|
[SQLConstants.SQL_DELETE_SPECIFIC_ROW, "DELETE FROM {0} WHERE {1}"],
|
|
69
69
|
[SQLConstants.SQL_CREATE_TABLE_USING_COLUMNS, "CREATE MULTISET TABLE {0}( {1} )"],
|
|
70
|
-
[SQLConstants.SQL_EXEC_STORED_PROCEDURE, "call {0}"]
|
|
70
|
+
[SQLConstants.SQL_EXEC_STORED_PROCEDURE, "call {0}"],
|
|
71
|
+
[SQLConstants.SQL_SELECT_COLUMNNAMES_WITH_WHERE, "sel {0} from {1} where {2}"],
|
|
72
|
+
[SQLConstants.SQL_HELP_DATABASE, "HELP DATABASE {0}"],
|
|
73
|
+
[SQLConstants.SQL_HELP_DATALAKE, "HELP DATALAKE {0}"]
|
|
71
74
|
|
|
72
75
|
]
|
|
73
76
|
self._add_sql_version()
|
|
@@ -256,14 +259,15 @@ class SQLBundle:
|
|
|
256
259
|
return query.format(tablename, select_query)
|
|
257
260
|
|
|
258
261
|
@staticmethod
|
|
259
|
-
def _build_drop_table(tablename):
|
|
262
|
+
def _build_drop_table(tablename, purge_clause=None):
|
|
260
263
|
"""
|
|
261
264
|
Returns a drop table DDL statement for a table.
|
|
262
265
|
Example:
|
|
263
266
|
drop table mytab
|
|
264
267
|
|
|
265
268
|
PARAMETERS:
|
|
266
|
-
tablename - The table to drop
|
|
269
|
+
tablename - The table to drop.
|
|
270
|
+
purge_clause - String representing purge clause.
|
|
267
271
|
|
|
268
272
|
RETURNS:
|
|
269
273
|
Returns a drop table DDL statement for the table.
|
|
@@ -272,12 +276,17 @@ class SQLBundle:
|
|
|
272
276
|
None
|
|
273
277
|
|
|
274
278
|
EXAMPLES:
|
|
275
|
-
|
|
276
|
-
|
|
279
|
+
drop_stmt = SQLBundle._build_drop_table('my_tab')
|
|
280
|
+
drop_stmt = SQLBundle._build_drop_table("my_lake"."my_db"."my_tab",
|
|
281
|
+
purge_clause='PURGE ALL')
|
|
282
|
+
drop_stmt = SQLBundle._build_drop_table("my_lake"."my_db"."my_tab",
|
|
283
|
+
purge_clause='NO PURGE')
|
|
277
284
|
"""
|
|
278
285
|
sqlbundle = SQLBundle()
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
drop_stmt = sqlbundle._get_sql_query(SQLConstants.SQL_DROP_TABLE).format(tablename)
|
|
287
|
+
if purge_clause:
|
|
288
|
+
drop_stmt = "{} {}".format(drop_stmt, purge_clause)
|
|
289
|
+
return drop_stmt
|
|
281
290
|
|
|
282
291
|
@staticmethod
|
|
283
292
|
def _build_drop_view(viewname):
|
|
@@ -399,6 +408,28 @@ class SQLBundle:
|
|
|
399
408
|
return sqlbundle._get_sql_query(SQLConstants.SQL_HELP_VOLATILE_TABLE)
|
|
400
409
|
|
|
401
410
|
@staticmethod
|
|
411
|
+
def _build_help_datalake(datalake_name):
|
|
412
|
+
"""
|
|
413
|
+
Builds a query to get help on datalake.
|
|
414
|
+
|
|
415
|
+
Example:
|
|
416
|
+
"HELP DATALAKE datalake_name;"
|
|
417
|
+
|
|
418
|
+
PARAMETERS:
|
|
419
|
+
|
|
420
|
+
RETURNS:
|
|
421
|
+
returns a HELP DATALAKE <datalake_name> command.
|
|
422
|
+
|
|
423
|
+
RAISES:
|
|
424
|
+
None
|
|
425
|
+
|
|
426
|
+
EXAMPLES:
|
|
427
|
+
query = SQLBundle._build_help_datalake(datalake_name)
|
|
428
|
+
"""
|
|
429
|
+
sqlbundle = SQLBundle()
|
|
430
|
+
help_datalake_sql = sqlbundle._get_sql_query(SQLConstants.SQL_HELP_DATALAKE)
|
|
431
|
+
return help_datalake_sql.format(datalake_name)
|
|
432
|
+
|
|
402
433
|
def _build_select_table_name(tab_name):
|
|
403
434
|
"""
|
|
404
435
|
Builds a query to get table name from DBC.TABLESV
|
|
@@ -446,11 +477,32 @@ class SQLBundle:
|
|
|
446
477
|
query = sqlbundle._get_sql_query(SQLConstants.SQL_SELECT_DATABASENAME).format(schema_name)
|
|
447
478
|
if table_name:
|
|
448
479
|
if '%' in table_name:
|
|
449
|
-
|
|
480
|
+
# Check if '%' is present in the between of table name excluding first and last character
|
|
481
|
+
# as '%' can be present at the start or end of table name
|
|
482
|
+
# and replace single quotes with empty string
|
|
483
|
+
# Checking for following cases with % in between table name:
|
|
484
|
+
# eg: table_name = 'ab%c', '%a%bc', '%ab%c%' or 'ab%c%'
|
|
485
|
+
|
|
486
|
+
# table_name[1:-1] - Removing single quotes from table name
|
|
487
|
+
# table_name[1:-1][1:-1] - Removing first and last character from table_name[1:-1]
|
|
488
|
+
if '%' in table_name[1:-1][1:-1]:
|
|
489
|
+
query = "{0}{1}".format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_NAME_LIKE).format(table_name))
|
|
490
|
+
else:
|
|
491
|
+
# Checking for following cases with % at the start or end of table name:
|
|
492
|
+
# eg: table_name = '%abc', 'abc%', '%abc%'
|
|
493
|
+
# Extracting table name without '%' character
|
|
494
|
+
table_name_str = table_name.replace('%', '')
|
|
495
|
+
|
|
496
|
+
# Adding condition to check if table name contains the string using POSITION function.
|
|
497
|
+
# POSITION function returns the position index of the substring in the string if found,
|
|
498
|
+
# else returns 0
|
|
499
|
+
query = "{0}{1}{2}".format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_NAME_LIKE).format(table_name), \
|
|
500
|
+
" AND POSITION({0} IN TABLENAME) > 0".format(table_name_str))
|
|
450
501
|
else:
|
|
451
|
-
query = "{0}{1}".format(query, sqlbundle._get_sql_query(SQLConstants.
|
|
502
|
+
query = "{0}{1}".format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_NAME_LIKE).format(table_name))
|
|
452
503
|
if table_kind:
|
|
453
504
|
query = '{0}{1}'.format(query, sqlbundle._get_sql_query(SQLConstants.SQL_AND_TABLE_KIND).format(table_kind))
|
|
505
|
+
|
|
454
506
|
return query
|
|
455
507
|
|
|
456
508
|
# TODO :: Following SQLConstants needs to be implemented as and when needed.
|