teradataml 20.0.0.4__py3-none-any.whl → 20.0.0.6__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 (131) hide show
  1. teradataml/LICENSE-3RD-PARTY.pdf +0 -0
  2. teradataml/README.md +182 -13
  3. teradataml/__init__.py +2 -1
  4. teradataml/_version.py +2 -2
  5. teradataml/analytics/analytic_function_executor.py +8 -13
  6. teradataml/analytics/json_parser/analytic_functions_argument.py +4 -0
  7. teradataml/analytics/sqle/__init__.py +16 -1
  8. teradataml/analytics/utils.py +60 -1
  9. teradataml/automl/__init__.py +290 -106
  10. teradataml/automl/autodataprep/__init__.py +471 -0
  11. teradataml/automl/data_preparation.py +29 -10
  12. teradataml/automl/data_transformation.py +11 -0
  13. teradataml/automl/feature_engineering.py +64 -4
  14. teradataml/automl/feature_exploration.py +639 -25
  15. teradataml/automl/model_training.py +1 -1
  16. teradataml/clients/auth_client.py +12 -8
  17. teradataml/clients/keycloak_client.py +165 -0
  18. teradataml/common/constants.py +71 -26
  19. teradataml/common/exceptions.py +32 -0
  20. teradataml/common/messagecodes.py +28 -0
  21. teradataml/common/messages.py +13 -4
  22. teradataml/common/sqlbundle.py +3 -2
  23. teradataml/common/utils.py +345 -45
  24. teradataml/context/context.py +259 -93
  25. teradataml/data/apriori_example.json +22 -0
  26. teradataml/data/docs/sqle/docs_17_20/Apriori.py +138 -0
  27. teradataml/data/docs/sqle/docs_17_20/NERExtractor.py +121 -0
  28. teradataml/data/docs/sqle/docs_17_20/NGramSplitter.py +3 -3
  29. teradataml/data/docs/sqle/docs_17_20/SMOTE.py +212 -0
  30. teradataml/data/docs/sqle/docs_17_20/TextMorph.py +119 -0
  31. teradataml/data/docs/sqle/docs_17_20/TextParser.py +54 -3
  32. teradataml/data/docs/uaf/docs_17_20/ACF.py +1 -1
  33. teradataml/data/docs/uaf/docs_17_20/ArimaEstimate.py +2 -2
  34. teradataml/data/docs/uaf/docs_17_20/ArimaXEstimate.py +2 -2
  35. teradataml/data/docs/uaf/docs_17_20/DFFT.py +1 -1
  36. teradataml/data/docs/uaf/docs_17_20/DFFT2.py +1 -1
  37. teradataml/data/docs/uaf/docs_17_20/DFFT2Conv.py +1 -1
  38. teradataml/data/docs/uaf/docs_17_20/DFFTConv.py +1 -1
  39. teradataml/data/docs/uaf/docs_17_20/FilterFactory1d.py +4 -4
  40. teradataml/data/docs/uaf/docs_17_20/GenseriesSinusoids.py +2 -2
  41. teradataml/data/docs/uaf/docs_17_20/GoldfeldQuandt.py +2 -2
  42. teradataml/data/docs/uaf/docs_17_20/HoltWintersForecaster.py +6 -6
  43. teradataml/data/docs/uaf/docs_17_20/LineSpec.py +1 -1
  44. teradataml/data/docs/uaf/docs_17_20/LinearRegr.py +1 -1
  45. teradataml/data/docs/uaf/docs_17_20/Matrix2Image.py +4 -4
  46. teradataml/data/docs/uaf/docs_17_20/MultivarRegr.py +1 -1
  47. teradataml/data/docs/uaf/docs_17_20/PACF.py +1 -1
  48. teradataml/data/docs/uaf/docs_17_20/PowerSpec.py +2 -2
  49. teradataml/data/docs/uaf/docs_17_20/PowerTransform.py +3 -3
  50. teradataml/data/docs/uaf/docs_17_20/Resample.py +5 -5
  51. teradataml/data/docs/uaf/docs_17_20/SAX.py +3 -3
  52. teradataml/data/docs/uaf/docs_17_20/SignifPeriodicities.py +1 -1
  53. teradataml/data/docs/uaf/docs_17_20/SimpleExp.py +1 -1
  54. teradataml/data/docs/uaf/docs_17_20/Smoothma.py +3 -3
  55. teradataml/data/docs/uaf/docs_17_20/UNDIFF.py +1 -1
  56. teradataml/data/jsons/byom/onnxembeddings.json +1 -0
  57. teradataml/data/jsons/sqle/17.20/NGramSplitter.json +6 -6
  58. teradataml/data/jsons/sqle/17.20/TD_Apriori.json +181 -0
  59. teradataml/data/jsons/sqle/17.20/TD_NERExtractor.json +145 -0
  60. teradataml/data/jsons/sqle/17.20/TD_SMOTE.json +267 -0
  61. teradataml/data/jsons/sqle/17.20/TD_TextMorph.json +134 -0
  62. teradataml/data/jsons/sqle/17.20/TD_TextParser.json +114 -9
  63. teradataml/data/jsons/sqle/20.00/AI_AnalyzeSentiment.json +328 -0
  64. teradataml/data/jsons/sqle/20.00/AI_AskLLM.json +420 -0
  65. teradataml/data/jsons/sqle/20.00/AI_DetectLanguage.json +343 -0
  66. teradataml/data/jsons/sqle/20.00/AI_ExtractKeyPhrases.json +328 -0
  67. teradataml/data/jsons/sqle/20.00/AI_MaskPII.json +328 -0
  68. teradataml/data/jsons/sqle/20.00/AI_RecognizeEntities.json +328 -0
  69. teradataml/data/jsons/sqle/20.00/AI_RecognizePIIEntities.json +328 -0
  70. teradataml/data/jsons/sqle/20.00/AI_TextClassifier.json +359 -0
  71. teradataml/data/jsons/sqle/20.00/AI_TextEmbeddings.json +360 -0
  72. teradataml/data/jsons/sqle/20.00/AI_TextSummarize.json +343 -0
  73. teradataml/data/jsons/sqle/20.00/AI_TextTranslate.json +343 -0
  74. teradataml/data/jsons/sqle/20.00/TD_SMOTE.json +2 -2
  75. teradataml/data/jsons/sqle/20.00/TD_VectorDistance.json +1 -1
  76. teradataml/data/ner_dict.csv +8 -0
  77. teradataml/data/ner_input_eng.csv +7 -0
  78. teradataml/data/ner_rule.csv +5 -0
  79. teradataml/data/pattern_matching_data.csv +11 -0
  80. teradataml/data/pos_input.csv +40 -0
  81. teradataml/data/sdk/modelops/modelops_spec.json +101737 -0
  82. teradataml/data/tdnerextractor_example.json +14 -0
  83. teradataml/data/teradataml_example.json +21 -1
  84. teradataml/data/textmorph_example.json +5 -0
  85. teradataml/data/to_num_data.csv +4 -0
  86. teradataml/data/tochar_data.csv +5 -0
  87. teradataml/data/trans_dense.csv +16 -0
  88. teradataml/data/trans_sparse.csv +55 -0
  89. teradataml/data/url_data.csv +10 -9
  90. teradataml/dataframe/copy_to.py +38 -27
  91. teradataml/dataframe/data_transfer.py +61 -45
  92. teradataml/dataframe/dataframe.py +1110 -132
  93. teradataml/dataframe/dataframe_utils.py +73 -27
  94. teradataml/dataframe/functions.py +1070 -9
  95. teradataml/dataframe/sql.py +750 -959
  96. teradataml/dbutils/dbutils.py +33 -13
  97. teradataml/dbutils/filemgr.py +14 -10
  98. teradataml/hyperparameter_tuner/utils.py +4 -2
  99. teradataml/lib/aed_0_1.dll +0 -0
  100. teradataml/opensource/_base.py +12 -157
  101. teradataml/options/configure.py +24 -9
  102. teradataml/scriptmgmt/UserEnv.py +317 -39
  103. teradataml/scriptmgmt/lls_utils.py +456 -135
  104. teradataml/sdk/README.md +79 -0
  105. teradataml/sdk/__init__.py +4 -0
  106. teradataml/sdk/_auth_modes.py +422 -0
  107. teradataml/sdk/_func_params.py +487 -0
  108. teradataml/sdk/_json_parser.py +453 -0
  109. teradataml/sdk/_openapi_spec_constants.py +249 -0
  110. teradataml/sdk/_utils.py +236 -0
  111. teradataml/sdk/api_client.py +897 -0
  112. teradataml/sdk/constants.py +62 -0
  113. teradataml/sdk/modelops/__init__.py +98 -0
  114. teradataml/sdk/modelops/_client.py +406 -0
  115. teradataml/sdk/modelops/_constants.py +304 -0
  116. teradataml/sdk/modelops/models.py +2308 -0
  117. teradataml/sdk/spinner.py +107 -0
  118. teradataml/store/__init__.py +1 -1
  119. teradataml/table_operators/Apply.py +16 -1
  120. teradataml/table_operators/Script.py +20 -1
  121. teradataml/table_operators/query_generator.py +4 -21
  122. teradataml/table_operators/table_operator_util.py +58 -9
  123. teradataml/utils/dtypes.py +4 -2
  124. teradataml/utils/internal_buffer.py +22 -2
  125. teradataml/utils/utils.py +0 -1
  126. teradataml/utils/validators.py +318 -58
  127. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/METADATA +188 -14
  128. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/RECORD +131 -84
  129. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/WHEEL +0 -0
  130. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/top_level.txt +0 -0
  131. {teradataml-20.0.0.4.dist-info → teradataml-20.0.0.6.dist-info}/zip-safe +0 -0
@@ -1,25 +1,24 @@
1
1
  import pandas as pd
2
2
  from inspect import getsource
3
3
  import re
4
- from types import FunctionType
4
+ from teradataml.dataframe.copy_to import copy_to_sql
5
+ from teradataml.dataframe.dataframe import DataFrame
5
6
  from teradataml.dbutils.filemgr import install_file, list_files, remove_file
6
- from teradataml.options.configure import configure
7
+ from teradataml.utils.utils import execute_sql
7
8
  import teradatasqlalchemy as tdsqlalchemy
8
9
  from teradataml.utils.validators import _Validators
9
10
  from teradataml.dataframe.sql import _SQLColumnExpression
10
11
  from teradatasqlalchemy import VARCHAR, CLOB, CHAR
11
- from teradataml.common.constants import TeradataTypes
12
+ from teradataml.common.constants import TableOperatorConstants, TeradataConstants, TeradataTypes
12
13
  from teradataml.common.utils import UtilFuncs
13
- from teradataml.utils.dtypes import _Dtypes
14
14
  from teradataml.dataframe.sql_interfaces import ColumnExpression
15
15
  from teradataml.table_operators.table_operator_util import _TableOperatorUtils
16
- from teradataml.utils.internal_buffer import _InternalBuffer
17
16
  from teradataml.common.exceptions import TeradataMlException
18
17
  from teradataml.common.messages import Messages
19
18
  from teradataml.common.messagecodes import MessageCodes
20
19
  from teradataml.scriptmgmt.lls_utils import get_env
21
20
 
22
- def udf(user_function=None, returns=VARCHAR(1024), env_name = None, delimiter=',', quotechar=None):
21
+ def udf(user_function=None, returns=VARCHAR(1024), env_name = None, delimiter=',', quotechar=None, debug=False):
23
22
  """
24
23
  DESCRIPTION:
25
24
  Creates a user defined function (UDF).
@@ -85,6 +84,15 @@ def udf(user_function=None, returns=VARCHAR(1024), env_name = None, delimiter=',
85
84
  * This argument cannot be same as "delimiter" argument.
86
85
  * This argument cannot be a newline character.
87
86
 
87
+ debug:
88
+ Optional Argument.
89
+ Specifies whether to display the script file path generated during function execution or not. This
90
+ argument helps in debugging when there are any failures during function execution. When set
91
+ to True, function displays the path of the script and does not remove the file from local file system.
92
+ Otherwise, file is removed from the local file system.
93
+ Default Value: False
94
+ Types: bool
95
+
88
96
  RETURNS:
89
97
  ColumnExpression
90
98
 
@@ -324,14 +332,14 @@ def udf(user_function=None, returns=VARCHAR(1024), env_name = None, delimiter=',
324
332
  def wrapper(f):
325
333
  def func_(*args):
326
334
  return _SQLColumnExpression(expression=None, udf=f, udf_type=returns, udf_args=args,\
327
- env_name=env_name, delimiter=delimiter, quotechar=quotechar)
335
+ env_name=env_name, delimiter=delimiter, quotechar=quotechar, debug=debug)
328
336
  return func_
329
337
  return wrapper
330
338
  # Notation: @udf
331
339
  else:
332
340
  def func_(*args):
333
341
  return _SQLColumnExpression(expression=None, udf=user_function, udf_type=returns, udf_args=args,\
334
- env_name=env_name, delimiter=delimiter, quotechar=quotechar)
342
+ env_name=env_name, delimiter=delimiter, quotechar=quotechar, debug=debug)
335
343
  return func_
336
344
 
337
345
 
@@ -879,4 +887,1057 @@ def _create_return_type(returns):
879
887
  return_str = str(returns)
880
888
  # Replace the space with underscore in the return type.
881
889
  return_str = return_str.replace(" ", "_")
882
- return return_str
890
+ return return_str
891
+
892
+ def td_range(start, end=None, step=1):
893
+ """
894
+ DESCRIPTION:
895
+ Creates a DataFrame with a specified range of numbers.
896
+
897
+ Notes:
898
+ 1. The range is inclusive of the start and exclusive of the end.
899
+ 2. If only start is provided, then end is set to start and start is set to 0.
900
+
901
+ PARAMETERS:
902
+ start:
903
+ Required Argument.
904
+ Specifies the starting number of the range.
905
+ Types: int
906
+
907
+ end:
908
+ Optional Argument.
909
+ Specifies the end number of the range(exclusive).
910
+ Default Value: None
911
+ Types: int
912
+
913
+ step:
914
+ Optional Argument.
915
+ Specifies the step size of the range.
916
+ Default Value: 1
917
+ Types: int
918
+
919
+ RETURNS:
920
+ teradataml DataFrame
921
+
922
+ RAISES:
923
+ TeradataMlException
924
+
925
+ EXAMPLES:
926
+ # Example 1: Create a DataFrame with a range of numbers from 0 to 5.
927
+ >>> from teradataml.dataframe.functions import td_range
928
+ >>> df = td_range(5)
929
+ >>> df.sort('id')
930
+ id
931
+ 0 0
932
+ 1 1
933
+ 2 2
934
+ 3 3
935
+ 4 4
936
+
937
+ # Example 2: Create a DataFrame with a range of numbers from 5 to 1 with step size of -2.
938
+ >>> from teradataml.dataframe.functions import td_range
939
+ >>> td_range(5, 1, -2)
940
+ id
941
+ 0 3
942
+ 1 5
943
+
944
+ >>> Example 3: Create a DataFrame with a range of numbers from 1 to 5 with default step size of 1.
945
+ >>> from teradataml.dataframe.functions import td_range
946
+ >>> td_range(1, 5)
947
+ id
948
+ 0 3
949
+ 1 4
950
+ 2 2
951
+ 3 1
952
+
953
+ """
954
+ # Validate the arguments.
955
+ arg_matrix = []
956
+ arg_matrix.append(["start", start, False, int])
957
+ arg_matrix.append(["end", end, True, int])
958
+ arg_matrix.append(["step", step, True, int])
959
+ _Validators._validate_function_arguments(arg_matrix)
960
+
961
+ # If only start is provided, then set end to start and start to 0.
962
+ if end is None:
963
+ end = start
964
+ start = 0
965
+
966
+ # If start is greater than end, then set the operation to "-" and operator to ">".
967
+ # If end is less than start, then set the operation to "+" and operator to "<".
968
+ if end < start:
969
+ operation, operator, step = "-", ">", -step
970
+ else:
971
+ operation, operator = "+", "<"
972
+
973
+ # Create a temporary table with the start value.
974
+ table_name = UtilFuncs._generate_temp_table_name(prefix="tdml_range_df",
975
+ table_type=TeradataConstants.TERADATA_TABLE)
976
+ execute_sql(f"CREATE MULTISET TABLE {table_name} AS (SELECT {start} AS id) WITH DATA;")
977
+
978
+ # Create a DataFrame from the range query.
979
+ range_query = TableOperatorConstants.RANGE_QUERY.value \
980
+ .format(table_name, step, end, operation, operator)
981
+ df = DataFrame.from_query(range_query)
982
+ return df
983
+
984
+ def get_formatters(formatter_type = None):
985
+ """
986
+ DESCRIPTION:
987
+ Function to get the formatters for NUMERIC, DATE and CHAR types.
988
+
989
+ PARAMETERS:
990
+ formatter_type:
991
+ Optional Argument.
992
+ Specifies the category of formatter to format data.
993
+ Default Value: None
994
+ Permitted values:
995
+ "NUMERIC" - Formatters to convert given data to a numeric type.
996
+ "DATE" - Formatters to convert given data to a date type.
997
+ "CHAR" - Formatters to convert given data to a character type.
998
+ Types: str
999
+ RAISES:
1000
+ ValueError
1001
+
1002
+ RETURNS:
1003
+ None
1004
+
1005
+ EXAMPLES:
1006
+ # Example 1: Get the formatters for the NUMERIC type.
1007
+ >>> from teradataml.dataframe.functions import get_formatters
1008
+ >>> get_formatters("NUMERIC")
1009
+
1010
+ """
1011
+ numeric_formatters = """
1012
+ Formatters to convert given data to a Numeric type:
1013
+ +--------------------------------------------------------------------------------------------------+
1014
+ | FORMATTER DESCRIPTION |
1015
+ +--------------------------------------------------------------------------------------------------+
1016
+ | , (comma) A comma in the specified position. |
1017
+ | A comma cannot begin a number format. |
1018
+ | A comma cannot appear to the right of a decimal |
1019
+ | character or period in a number format. |
1020
+ | Example: |
1021
+ | +-------------------------------------------------+ |
1022
+ | | data formatter result | |
1023
+ | +-------------------------------------------------+ |
1024
+ | | "1,234" "9,999" 1234 | |
1025
+ | +-------------------------------------------------+ |
1026
+ +--------------------------------------------------------------------------------------------------+
1027
+ | . (period) A decimal point. Only one allowed in a format. |
1028
+ | Example: |
1029
+ | +-------------------------------------------------+ |
1030
+ | | data formatter result | |
1031
+ | +-------------------------------------------------+ |
1032
+ | | "12.34" "99.99" 12.34 | |
1033
+ | +-------------------------------------------------+ |
1034
+ +--------------------------------------------------------------------------------------------------+
1035
+ | $ A value with a leading dollar sign. |
1036
+ | Example: |
1037
+ | +-------------------------------------------------+ |
1038
+ | | data formatter result | |
1039
+ | +-------------------------------------------------+ |
1040
+ | | "$1234" "$9999" 1234 | |
1041
+ | +-------------------------------------------------+ |
1042
+ +--------------------------------------------------------------------------------------------------+
1043
+ | 0 Leading or trailing zeros. |
1044
+ | Example: |
1045
+ | +-------------------------------------------------+ |
1046
+ | | data formatter result | |
1047
+ | +-------------------------------------------------+ |
1048
+ | | "0123" "0999" 123 | |
1049
+ | | "1230" "9990" 1230 | |
1050
+ | +-------------------------------------------------+ |
1051
+ +--------------------------------------------------------------------------------------------------+
1052
+ | 9 Specified number of digits. |
1053
+ | Leading space if positive, minus if negative. |
1054
+ | Example: |
1055
+ | +-------------------------------------------------+ |
1056
+ | | data formatter result | |
1057
+ | +-------------------------------------------------+ |
1058
+ | | "1234" "9999" 1234 | |
1059
+ | | "-1234" "9999" -1234 | |
1060
+ | +-------------------------------------------------+ |
1061
+ +--------------------------------------------------------------------------------------------------+
1062
+ | B Blanks if integer part is zero. |
1063
+ | Example: |
1064
+ | +-------------------------------------------------+ |
1065
+ | | data formatter result | |
1066
+ | +-------------------------------------------------+ |
1067
+ | | "0" "B9999" 0 | |
1068
+ | +-------------------------------------------------+ |
1069
+ +--------------------------------------------------------------------------------------------------+
1070
+ | C ISO currency symbol (from SDF ISOCurrency). |
1071
+ | Example: |
1072
+ | +-------------------------------------------------+ |
1073
+ | | data formatter result | |
1074
+ | +-------------------------------------------------+ |
1075
+ | | "USD123" "C999" 123 | |
1076
+ | +-------------------------------------------------+ |
1077
+ +--------------------------------------------------------------------------------------------------+
1078
+ | D Radix separator for non-monetary values. |
1079
+ | From SDF RadixSeparator. |
1080
+ | Example: |
1081
+ | +-------------------------------------------------+ |
1082
+ | | data formatter result | |
1083
+ | +-------------------------------------------------+ |
1084
+ | | "12.34" "99D99" 12.34 | |
1085
+ | +-------------------------------------------------+ |
1086
+ +--------------------------------------------------------------------------------------------------+
1087
+ | EEEE Scientific notation. |
1088
+ | Example: |
1089
+ | +-------------------------------------------------+ |
1090
+ | | data formatter result | |
1091
+ | +-------------------------------------------------+ |
1092
+ | | "1.2E+04" "9.9EEEE" 12000 | |
1093
+ | +-------------------------------------------------+ |
1094
+ +--------------------------------------------------------------------------------------------------+
1095
+ | G Group separator for non-monetary values. |
1096
+ | From SDF GroupSeparator. |
1097
+ | Example: |
1098
+ | +-------------------------------------------------+ |
1099
+ | | data formatter result | |
1100
+ | +-------------------------------------------------+ |
1101
+ | | "1,234,567" "9G999G999" 1234567 | |
1102
+ | +-------------------------------------------------+ |
1103
+ +--------------------------------------------------------------------------------------------------+
1104
+ | L Local currency (from SDF Currency element). |
1105
+ | Example: |
1106
+ | +-------------------------------------------------+ |
1107
+ | | data formatter result | |
1108
+ | +-------------------------------------------------+ |
1109
+ | | "$123" "L999" 123 | |
1110
+ | +-------------------------------------------------+ |
1111
+ +--------------------------------------------------------------------------------------------------+
1112
+ | MI Trailing minus sign if value is negative. |
1113
+ | Can only appear in the last position. |
1114
+ | Example: |
1115
+ | +-------------------------------------------------+ |
1116
+ | | data formatter result | |
1117
+ | +-------------------------------------------------+ |
1118
+ | | "1234-" "9999MI" -1234 | |
1119
+ | +-------------------------------------------------+ |
1120
+ +--------------------------------------------------------------------------------------------------+
1121
+ | PR Negative value in angle brackets. |
1122
+ | Positive value with leading/trailing blank. |
1123
+ | Only in the last position. |
1124
+ | Example: |
1125
+ | +-------------------------------------------------+ |
1126
+ | | data formatter result | |
1127
+ | +-------------------------------------------------+ |
1128
+ | | " 123 " "9999PR" 123 | |
1129
+ | +-------------------------------------------------+ |
1130
+ +--------------------------------------------------------------------------------------------------+
1131
+ | S Sign indicator: + / - at beginning or end. |
1132
+ | Can only appear in first or last position. |
1133
+ | Example: |
1134
+ | +-------------------------------------------------+ |
1135
+ | | data formatter result | |
1136
+ | +-------------------------------------------------+ |
1137
+ | | "-1234" "S9999" -1234 | |
1138
+ | +-------------------------------------------------+ |
1139
+ +--------------------------------------------------------------------------------------------------+
1140
+ | U Dual currency (from SDF DualCurrency). |
1141
+ | Example: |
1142
+ | +-------------------------------------------------+ |
1143
+ | | data formatter result | |
1144
+ | +-------------------------------------------------+ |
1145
+ | | "$123" "U999" 123 | |
1146
+ | +-------------------------------------------------+ |
1147
+ +--------------------------------------------------------------------------------------------------+
1148
+ | X Hexadecimal format. |
1149
+ | Accepts only non-negative values. |
1150
+ | Must be preceded by 0 or FM. |
1151
+ | Example: |
1152
+ | +-------------------------------------------------+ |
1153
+ | | data formatter result | |
1154
+ | +-------------------------------------------------+ |
1155
+ | | "FF" "XX" 255 | |
1156
+ | +-------------------------------------------------+ |
1157
+ +--------------------------------------------------------------------------------------------------+
1158
+ """
1159
+
1160
+ date_formatters = """
1161
+ Formatters to convert given data to a Date type:
1162
+ +--------------------------------------------------------------------------------------------------+
1163
+ | FORMATTER DESCRIPTION |
1164
+ +--------------------------------------------------------------------------------------------------+
1165
+ | - |
1166
+ | / |
1167
+ | , Punctuation characters are ignored and text enclosed in |
1168
+ | . quotation marks is ignored. |
1169
+ | ; |
1170
+ | : |
1171
+ | "text" |
1172
+ | Example: Date with value '2003-12-10' |
1173
+ | +-------------------------------------------------+ |
1174
+ | | data formatter value | |
1175
+ | +-------------------------------------------------+ |
1176
+ | | '2003-12-10' YYYY-MM-DD 03/12/10 | |
1177
+ | +-------------------------------------------------+ |
1178
+ +--------------------------------------------------------------------------------------------------+
1179
+ | D Day of week (1-7). |
1180
+ | Example: day of week with value '2' |
1181
+ | +-------------------------------------------------+ |
1182
+ | | data formatter value | |
1183
+ | +-------------------------------------------------+ |
1184
+ | | 2 D 24/01/01 | |
1185
+ | +-------------------------------------------------+ |
1186
+ +--------------------------------------------------------------------------------------------------+
1187
+ | DAY Name of day. |
1188
+ | Example: Date with value '2024-TUESDAY-01-30' |
1189
+ | +-------------------------------------------------+ |
1190
+ | | data formatter value | |
1191
+ | +-------------------------------------------------+ |
1192
+ | | 2024-TUESDAY-01-30 YYYY-DAY-MM-DD 24/01/30 | |
1193
+ | +-------------------------------------------------+ |
1194
+ +--------------------------------------------------------------------------------------------------+
1195
+ | DD Day of month (1-31). |
1196
+ | Example: Date with value '2003-10-25' |
1197
+ | +-------------------------------------------------+ |
1198
+ | | data formatter value | |
1199
+ | +-------------------------------------------------+ |
1200
+ | | 2003-10-25 YYYY-MM-DD 03/10/25 | |
1201
+ | +-------------------------------------------------+ |
1202
+ +--------------------------------------------------------------------------------------------------+
1203
+ | DDD Day of year (1-366). |
1204
+ | Example: Date with value '2024-366' |
1205
+ | +-------------------------------------------------+ |
1206
+ | | data formatter value | |
1207
+ | +-------------------------------------------------+ |
1208
+ | | 2024-366 YYYY-DDD 24/12/31 | |
1209
+ | +-------------------------------------------------+ |
1210
+ +--------------------------------------------------------------------------------------------------+
1211
+ | DY abbreviated name of day. |
1212
+ | Example: Date with value '2024-Mon-01-29' |
1213
+ | +-------------------------------------------------+ |
1214
+ | | data formatter value | |
1215
+ | +-------------------------------------------------+ |
1216
+ | | 2024-Mon-01-29 YYYY-DY-MM-DD 24/01/29 | |
1217
+ | +-------------------------------------------------+ |
1218
+ +--------------------------------------------------------------------------------------------------+
1219
+ | HH |
1220
+ | HH12 Hour of day (1-12). |
1221
+ | Example: Date with value '2016-01-06 09:08:01' |
1222
+ | +-------------------------------------------------+ |
1223
+ | | data formatter value | |
1224
+ | +-------------------------------------------------+ |
1225
+ | | 2016-01-06 09:08:01 YYYY-MM-DD HH:MI:SS 6/01/06| |
1226
+ | +-------------------------------------------------+ |
1227
+ +--------------------------------------------------------------------------------------------------+
1228
+ | HH24 Hour of the day (0-23). |
1229
+ | Example: Date with value '2016-01-06 23:08:01' |
1230
+ | +----------------------------------------------------+ |
1231
+ | | data formatter value | |
1232
+ | +----------------------------------------------------+ |
1233
+ | | 2016-01-06 23:08:01 YYYY-MM-DD HH24:MI:SS 6/01/06 | |
1234
+ | +----------------------------------------------------+ |
1235
+ +--------------------------------------------------------------------------------------------------+
1236
+ | J Julian day, the number of days since January 1, 4713 BC. |
1237
+ | Number specified with J must be integers. |
1238
+ | Teradata uses the Gregorian calendar in calculations to |
1239
+ | and from Julian Days. |
1240
+ | Example: Number of julian days with value '2457394' |
1241
+ | +-------------------------------------------------+ |
1242
+ | | data formatter value | |
1243
+ | +-------------------------------------------------+ |
1244
+ | | 2457394 J 16/01/06 | |
1245
+ | +-------------------------------------------------+ |
1246
+ +--------------------------------------------------------------------------------------------------+
1247
+ | MI Minute (0-59). |
1248
+ | Example: Date with value '2016-01-06 23:08:01' |
1249
+ | +----------------------------------------------------+ |
1250
+ | | data formatter value | |
1251
+ | +----------------------------------------------------+ |
1252
+ | | 2016-01-06 23:08:01 YYYY-MM-DD HH24:MI:SS 6/01/06 | |
1253
+ | +----------------------------------------------------+ |
1254
+ +--------------------------------------------------------------------------------------------------+
1255
+ | MM Month (01-12). |
1256
+ | Example: Date with value '2016-01-06 23:08:01' |
1257
+ | +----------------------------------------------------+ |
1258
+ | | data formatter value | |
1259
+ | +----------------------------------------------------+ |
1260
+ | | 2016-01-06 23:08:01 YYYY-MM-DD HH24:MI:SS 6/01/06 | |
1261
+ | +----------------------------------------------------+ |
1262
+ +--------------------------------------------------------------------------------------------------+
1263
+ | MON Abbreviated name of month. |
1264
+ | Example: Date with value '2016-JAN-06' |
1265
+ | +----------------------------------------------------+ |
1266
+ | | data formatter value | |
1267
+ | +----------------------------------------------------+ |
1268
+ | | 2016-JAN-06 YYYY-MON-DD 16/01/06 | |
1269
+ | +----------------------------------------------------+ |
1270
+ +--------------------------------------------------------------------------------------------------+
1271
+ | MONTH Name of month. |
1272
+ | Example: Date with value '2016-JANUARY-06' |
1273
+ | +-------------------------------------------------+ |
1274
+ | | data formatter value | |
1275
+ | +-------------------------------------------------+ |
1276
+ | | 2016-JANUARY-06 YYYY-MONTH-DD 16/01/06 | |
1277
+ | +-------------------------------------------------+ |
1278
+ +--------------------------------------------------------------------------------------------------+
1279
+ | PM |
1280
+ | P.M. Meridian indicator. |
1281
+ | Example: Date with value '2016-01-06 23:08:01 PM' |
1282
+ | +---------------------------------------------------------+ |
1283
+ | | data formatter value | |
1284
+ | +---------------------------------------------------------+ |
1285
+ | | 2016-01-06 23:08:01 PM YYYY-MM-DD HH24:MI:SS PM 16/01/06| |
1286
+ | +---------------------------------------------------------+ |
1287
+ +--------------------------------------------------------------------------------------------------+
1288
+ | RM Roman numeral month (I - XII). |
1289
+ | Example: Date with value '2024-XII' |
1290
+ | +-------------------------------------------------+ |
1291
+ | | data formatter value | |
1292
+ | +-------------------------------------------------+ |
1293
+ | | 2024-XII YYYY-RM 24/12/01 | |
1294
+ | +-------------------------------------------------+ |
1295
+ +--------------------------------------------------------------------------------------------------+
1296
+ | RR Stores 20th century dates in the 21st century using only |
1297
+ | 2 digits. If the current year and the specified year are |
1298
+ | both in the range of 0-49, the date is in the current |
1299
+ | century. |
1300
+ | Example: Date with value '2024-365, 21' |
1301
+ | +-------------------------------------------------+ |
1302
+ | | data formatter value | |
1303
+ | +-------------------------------------------------+ |
1304
+ | | 2024-365, 21 YYYY-DDD, RR 21/12/31 | |
1305
+ | +-------------------------------------------------+ |
1306
+ +--------------------------------------------------------------------------------------------------+
1307
+ | RRRR Round year. Accepts either 4-digit or 2-digit input. |
1308
+ | 2-digit input provides the same return as RR. |
1309
+ | Example: Date with value '2024-365, 21' |
1310
+ | +-------------------------------------------------+ |
1311
+ | | data formatter value | |
1312
+ | +-------------------------------------------------+ |
1313
+ | | 2024-365, 21 YYYY-DDD, RRRR 24/12/31 | |
1314
+ | +-------------------------------------------------+ |
1315
+ +--------------------------------------------------------------------------------------------------+
1316
+ | SS Second (0-59). |
1317
+ | Example: Date with value '2016-01-06 23:08:01' |
1318
+ | +----------------------------------------------------+ |
1319
+ | | data formatter value | |
1320
+ | +----------------------------------------------------+ |
1321
+ | | 2016-01-06 23:08:01 YYYY-MM-DD HH24:MI:SS 6/01/06 | |
1322
+ | +----------------------------------------------------+ |
1323
+ +--------------------------------------------------------------------------------------------------+
1324
+ | SSSSS Seconds past midnight (0-86399). |
1325
+ +--------------------------------------------------------------------------------------------------+
1326
+ | TZH Time zone hour. |
1327
+ +--------------------------------------------------------------------------------------------------+
1328
+ | TZM Time zone minute. |
1329
+ +--------------------------------------------------------------------------------------------------+
1330
+ | X Local radix character. |
1331
+ | Example: Date with value '2024.366' |
1332
+ | +-------------------------------------------------+ |
1333
+ | | data formatter value | |
1334
+ | +-------------------------------------------------+ |
1335
+ | | 2024.366 YYYYXDDD 24/12/31 | |
1336
+ | +-------------------------------------------------+ |
1337
+ +--------------------------------------------------------------------------------------------------+
1338
+ | Y,YYY Year with comma in this position. |
1339
+ | Example: Date with value '2,024-366' |
1340
+ | +-------------------------------------------------+ |
1341
+ | | data formatter value | |
1342
+ | +-------------------------------------------------+ |
1343
+ | | 2,024-366 Y,YYY-DDD 24/12/31 | |
1344
+ | +-------------------------------------------------+ |
1345
+ +--------------------------------------------------------------------------------------------------+
1346
+ | YYYY |
1347
+ | SYYYY 4-digit year. S prefixes BC dates with a minus sign. |
1348
+ | Example: Date with value '2024-366' |
1349
+ | +-------------------------------------------------+ |
1350
+ | | data formatter value | |
1351
+ | +-------------------------------------------------+ |
1352
+ | | 2024-366 YYYY-DDD 24/12/31 | |
1353
+ | +-------------------------------------------------+ |
1354
+ +--------------------------------------------------------------------------------------------------+
1355
+ | YYY Last 3, 2, or 1 digit of year. |
1356
+ | YY If the current year and the specified year are both in |
1357
+ | Y the range of 0-49, the date is in the current century. |
1358
+ | Example: Date with value '24-366' |
1359
+ | +-------------------------------------------------+ |
1360
+ | | data formatter value | |
1361
+ | +-------------------------------------------------+ |
1362
+ | | 24-366 YY-DDD 24/12/31 | |
1363
+ | +-------------------------------------------------+ |
1364
+ +--------------------------------------------------------------------------------------------------+
1365
+ """
1366
+
1367
+ char_formatters = """
1368
+ Formatters to convert given data to a Char type:
1369
+ +--------------------------------------------------------------------------------------------------+
1370
+ | FORMATTER DESCRIPTION |
1371
+ +--------------------------------------------------------------------------------------------------+
1372
+ | , (comma) A comma in the specified position. |
1373
+ | A comma cannot begin a number format. |
1374
+ | A comma cannot appear to the right of a decimal |
1375
+ | character or period in a number format. |
1376
+ | Example: |
1377
+ | +-------------------------------------------------+ |
1378
+ | | data formatter result | |
1379
+ | +-------------------------------------------------+ |
1380
+ | | 1234 9,999 1,234 | |
1381
+ | +-------------------------------------------------+ |
1382
+ +--------------------------------------------------------------------------------------------------+
1383
+ | . (period) A decimal point. |
1384
+ | User can only specify one period in a number format. |
1385
+ | Example: |
1386
+ | +-------------------------------------------------+ |
1387
+ | | data formatter result | |
1388
+ | +-------------------------------------------------+ |
1389
+ | | 123.46 9999.9 123.5 | |
1390
+ | +-------------------------------------------------+ |
1391
+ +--------------------------------------------------------------------------------------------------+
1392
+ | $ A value with a leading dollar sign. |
1393
+ | Example: |
1394
+ | +-------------------------------------------------+ |
1395
+ | | data formatter result | |
1396
+ | +-------------------------------------------------+ |
1397
+ | | 1234 $9999 $1234 | |
1398
+ | +-------------------------------------------------+ |
1399
+ +--------------------------------------------------------------------------------------------------+
1400
+ | 0 Leading zeros. |
1401
+ | Trailing zeros. |
1402
+ | Example: |
1403
+ | +-------------------------------------------------+ |
1404
+ | | data formatter result | |
1405
+ | +-------------------------------------------------+ |
1406
+ | | 1234 09999 01234 | |
1407
+ | +-------------------------------------------------+ |
1408
+ +--------------------------------------------------------------------------------------------------+
1409
+ | 9 A value with the specified number of digits with a |
1410
+ | leading space if positive or with a leading minus |
1411
+ | if negative. |
1412
+ | Example: |
1413
+ | +-------------------------------------------------+ |
1414
+ | | data formatter result | |
1415
+ | +-------------------------------------------------+ |
1416
+ | | 1234 9999 1234 | |
1417
+ | | 1234 999 #### | |
1418
+ | +-------------------------------------------------+ |
1419
+ +--------------------------------------------------------------------------------------------------+
1420
+ | B Blank space for the integer part of a fixed point number|
1421
+ | when the integer part is zero. |
1422
+ | Example: |
1423
+ | +-------------------------------------------------+ |
1424
+ | | data formatter result | |
1425
+ | +-------------------------------------------------+ |
1426
+ | | 0.1234 B.999 Blank space| |
1427
+ | +-------------------------------------------------+ |
1428
+ +--------------------------------------------------------------------------------------------------+
1429
+ | C The ISO currency symbol as specified in the ISOCurrency |
1430
+ | element in the SDF file. |
1431
+ | Example: |
1432
+ | +-------------------------------------------------+ |
1433
+ | | data formatter result | |
1434
+ | +-------------------------------------------------+ |
1435
+ | | 234 C999 USD234 | |
1436
+ | +-------------------------------------------------+ |
1437
+ +--------------------------------------------------------------------------------------------------+
1438
+ | D The character that separates the integer and fractional |
1439
+ | part of non-monetary values. |
1440
+ | Example: |
1441
+ | +-------------------------------------------------+ |
1442
+ | | data formatter result | |
1443
+ | +-------------------------------------------------+ |
1444
+ | | 234.56 999D9 234.6 | |
1445
+ | +-------------------------------------------------+ |
1446
+ +--------------------------------------------------------------------------------------------------+
1447
+ | EEEE A value in scientific notation. |
1448
+ | Example: |
1449
+ | +-------------------------------------------------+ |
1450
+ | | data formatter result | |
1451
+ | +-------------------------------------------------+ |
1452
+ | | 234.56 9.9EEEE 2.3E+02 | |
1453
+ | +-------------------------------------------------+ |
1454
+ +--------------------------------------------------------------------------------------------------+
1455
+ | G The character that separates groups of digits in the |
1456
+ | integer part of non-monetary values. |
1457
+ | +-------------------------------------------------+ |
1458
+ | | data formatter result | |
1459
+ | +-------------------------------------------------+ |
1460
+ | | 123456 9G99G99 1,234,56 | |
1461
+ | +-------------------------------------------------+ |
1462
+ +--------------------------------------------------------------------------------------------------+
1463
+ | L The string representing the local currency as specified |
1464
+ | in the Currency element according to system settings. |
1465
+ | Example: |
1466
+ | +-------------------------------------------------+ |
1467
+ | | data formatter result | |
1468
+ | +-------------------------------------------------+ |
1469
+ | | 234 L999 $234 | |
1470
+ | +-------------------------------------------------+ |
1471
+ +--------------------------------------------------------------------------------------------------+
1472
+ | MI A trailing minus sign if the value is negative. |
1473
+ | The MI format element can appear only in the last |
1474
+ | position of a number format. |
1475
+ | Example: |
1476
+ | +-------------------------------------------------+ |
1477
+ | | data formatter result | |
1478
+ | +-------------------------------------------------+ |
1479
+ | | -1234 9999MI 1234- | |
1480
+ | +-------------------------------------------------+ |
1481
+ +--------------------------------------------------------------------------------------------------+
1482
+ | PR A negative value in <angle brackets>, or |
1483
+ | a positive value with a leading and trailing blank. |
1484
+ | The PR format element can appear only in the last |
1485
+ | position of a number format. |
1486
+ | Example: |
1487
+ | +-------------------------------------------------+ |
1488
+ | | data formatter result | |
1489
+ | +-------------------------------------------------+ |
1490
+ | | -1234 9999PR <1234> | |
1491
+ | +-------------------------------------------------+ |
1492
+ +--------------------------------------------------------------------------------------------------+
1493
+ | S A negative value with a leading or trailing minus sign. |
1494
+ | a positive value with a leading or trailing plus sign. |
1495
+ | The S format element can appear only in the first or |
1496
+ | last position of a number format. |
1497
+ | Example: |
1498
+ | +-------------------------------------------------+ |
1499
+ | | data formatter result | |
1500
+ | +-------------------------------------------------+ |
1501
+ | | +1234 S9999 +1234 | |
1502
+ | +-------------------------------------------------+ |
1503
+ +--------------------------------------------------------------------------------------------------+
1504
+ | TM (text minimum format) Returns the smallest number of |
1505
+ | characters possible. This element is case insensitive. |
1506
+ | TM or TM9 return the number in fixed notation unless |
1507
+ | the output exceeds 64 characters. If the output exceeds |
1508
+ | 64 characters, the number is returned in scientific |
1509
+ | notation. |
1510
+ | TME returns the number in scientific notation with the |
1511
+ | smallest number of characters. |
1512
+ | You cannot precede this element with an other element. |
1513
+ | You can follow this element only with one 9 or one E |
1514
+ | (or e), but not with any combination of these. |
1515
+ | Example: |
1516
+ | +-------------------------------------------------+ |
1517
+ | | data formatter result | |
1518
+ | +-------------------------------------------------+ |
1519
+ | | 1234 TM 1234 | |
1520
+ | +-------------------------------------------------+ |
1521
+ +--------------------------------------------------------------------------------------------------+
1522
+ | U (dual currency) The string that represents the dual |
1523
+ | currency as specified in the DualCurrency element |
1524
+ | according to system settings. |
1525
+ | Example: |
1526
+ | +-------------------------------------------------+ |
1527
+ | | data formatter result | |
1528
+ | +-------------------------------------------------+ |
1529
+ | | 1234 U9999 $1234 | |
1530
+ | +-------------------------------------------------+ |
1531
+ +--------------------------------------------------------------------------------------------------+
1532
+ | V A value multiplied by 10 to the n (and, if necessary, |
1533
+ | rounded up), where n is the number of 9's after the V. |
1534
+ | Example: |
1535
+ | +-------------------------------------------------+ |
1536
+ | | data formatter result | |
1537
+ | +-------------------------------------------------+ |
1538
+ | | 1234 9999V99 123400 | |
1539
+ | +-------------------------------------------------+ |
1540
+ +--------------------------------------------------------------------------------------------------+
1541
+ | X The hexadecimal value of the specified number of digits.|
1542
+ | If the specified number is not an integer, the function |
1543
+ | will round it to an integer. |
1544
+ | This element accepts only positive values or zero. |
1545
+ | Negative values return an error. You can precede this |
1546
+ | element only with zero (which returns leading zeros) or |
1547
+ | FM. Any other elements return an error. If you do not |
1548
+ | specify zero or FM, the return always has one leading |
1549
+ | blank. |
1550
+ | Example: |
1551
+ | +-------------------------------------------------+ |
1552
+ | | data formatter result | |
1553
+ | +-------------------------------------------------+ |
1554
+ | | 1234 XXXX 4D2 | |
1555
+ | +-------------------------------------------------+ |
1556
+ +--------------------------------------------------------------------------------------------------+
1557
+ +--------------------------------------------------------------------------------------------------+
1558
+ | FORMATTER DESCRIPTION |
1559
+ +--------------------------------------------------------------------------------------------------+
1560
+ | - |
1561
+ | / |
1562
+ | , Punctuation characters are ignored and text enclosed in |
1563
+ | . quotation marks is ignored. |
1564
+ | ; |
1565
+ | : |
1566
+ | "text" |
1567
+ | Example: |
1568
+ | +-------------------------------------------------+ |
1569
+ | | data formatter result | |
1570
+ | +-------------------------------------------------+ |
1571
+ | | 03/09/17 MM-DD 09-17 | |
1572
+ | +-------------------------------------------------+ |
1573
+ +--------------------------------------------------------------------------------------------------+
1574
+ | AD AD indicator. |
1575
+ | A.D. |
1576
+ | Example: |
1577
+ | +-------------------------------------------------+ |
1578
+ | | data formatter result | |
1579
+ | +-------------------------------------------------+ |
1580
+ | | 03/09/17 CCAD 21AD | |
1581
+ | +-------------------------------------------------+ |
1582
+ +--------------------------------------------------------------------------------------------------+
1583
+ | AM Meridian indicator. |
1584
+ | A.M. |
1585
+ | Example: |
1586
+ | +-------------------------------------------------+ |
1587
+ | | data formatter result | |
1588
+ | +-------------------------------------------------+ |
1589
+ | | 03/09/17 CCAM 21AM | |
1590
+ | +-------------------------------------------------+ |
1591
+ +--------------------------------------------------------------------------------------------------+
1592
+ | BC |
1593
+ | B.C. BC indicator. |
1594
+ | Example: |
1595
+ | +-------------------------------------------------+ |
1596
+ | | data formatter result | |
1597
+ | +-------------------------------------------------+ |
1598
+ | | 03/09/17 CCBC 21BC | |
1599
+ | +-------------------------------------------------+ |
1600
+ +--------------------------------------------------------------------------------------------------+
1601
+ | CC Century. |
1602
+ | SCC If the last 2 digits of a 4-digit year are between 01 |
1603
+ | and 99 inclusive, the century is 1 greater than the |
1604
+ | first 2 digits of that year. |
1605
+ | If the last 2 digits of a 4-digit year are 00, the |
1606
+ | century is the same as the first 2 digits of that year. |
1607
+ | Example: |
1608
+ | +-------------------------------------------------+ |
1609
+ | | data formatter result | |
1610
+ | +-------------------------------------------------+ |
1611
+ | | 03/09/17 CCBC 21BC | |
1612
+ | +-------------------------------------------------+ |
1613
+ +--------------------------------------------------------------------------------------------------+
1614
+ | D Day of week (1-7). |
1615
+ | Example: |
1616
+ | +-------------------------------------------------+ |
1617
+ | | data formatter result | |
1618
+ | +-------------------------------------------------+ |
1619
+ | | 03/09/17 D 4 | |
1620
+ | +-------------------------------------------------+ |
1621
+ +--------------------------------------------------------------------------------------------------+
1622
+ | DAY Name of day. |
1623
+ | Example: |
1624
+ | +-------------------------------------------------+ |
1625
+ | | data formatter result | |
1626
+ | +-------------------------------------------------+ |
1627
+ | | 03/09/17 DAY WEDNESDAY | |
1628
+ | +-------------------------------------------------+ |
1629
+ +--------------------------------------------------------------------------------------------------+
1630
+ | DD Day of month (1-31). |
1631
+ | Example: |
1632
+ | +-------------------------------------------------+ |
1633
+ | | data formatter result | |
1634
+ | +-------------------------------------------------+ |
1635
+ | | 03/09/17 DD 17 | |
1636
+ | +-------------------------------------------------+ |
1637
+ +--------------------------------------------------------------------------------------------------+
1638
+ | DDD Day of year (1-366). |
1639
+ | Example: |
1640
+ | +-------------------------------------------------+ |
1641
+ | | data formatter result | |
1642
+ | +-------------------------------------------------+ |
1643
+ | | 03/09/17 DDD 260 | |
1644
+ | +-------------------------------------------------+ |
1645
+ +--------------------------------------------------------------------------------------------------+
1646
+ | DL Date Long. Equivalent to the format string ‘FMDay, |
1647
+ | Month FMDD, YYYY’. |
1648
+ | Example: |
1649
+ | +-------------------------------------------------+ |
1650
+ | | data formatter result | |
1651
+ | +-------------------------------------------------+ |
1652
+ | | 03/09/17 DL Wednesday, September 17, 2003| |
1653
+ | +-------------------------------------------------+ |
1654
+ +--------------------------------------------------------------------------------------------------+
1655
+ | DS Date Short. Equivalent to the format string |
1656
+ | ‘FMMM/DD/YYYYFM’. |
1657
+ | Example: |
1658
+ | +-------------------------------------------------+ |
1659
+ | | data formatter result | |
1660
+ | +-------------------------------------------------+ |
1661
+ | | 03/09/17 DS 9/17/2003 | |
1662
+ | +-------------------------------------------------+ |
1663
+ +--------------------------------------------------------------------------------------------------+
1664
+ | DY abbreviated name of day. |
1665
+ | Example: |
1666
+ | +-------------------------------------------------+ |
1667
+ | | data formatter result | |
1668
+ | +-------------------------------------------------+ |
1669
+ | | 03/09/17 DY WED | |
1670
+ | +-------------------------------------------------+ |
1671
+ +--------------------------------------------------------------------------------------------------+
1672
+ | FF [1..9] Fractional seconds. |
1673
+ | Use [1..9] to specify the number of fractional digits. |
1674
+ | FF without any number following it prints a decimal |
1675
+ | followed by digits equal to the number of fractional |
1676
+ | seconds in the input data type. If the data type has no |
1677
+ | fractional digits, FF prints nothing. |
1678
+ | Any fractional digits beyond 6 digits are truncated. |
1679
+ | Example: |
1680
+ | +-------------------------------------------------+ |
1681
+ | | data formatter result | |
1682
+ | +-------------------------------------------------+ |
1683
+ | | 2016-01-06 09:08:01.000000 FF 000000 | |
1684
+ | +-------------------------------------------------+ |
1685
+ +--------------------------------------------------------------------------------------------------+
1686
+ | HH |
1687
+ | HH12 Hour of day (1-12). |
1688
+ | Example: |
1689
+ | +-------------------------------------------------+ |
1690
+ | | data formatter result | |
1691
+ | +-------------------------------------------------+ |
1692
+ | | 2016-01-06 09:08:01.000000 HH 09 | |
1693
+ | +-------------------------------------------------+ |
1694
+ +--------------------------------------------------------------------------------------------------+
1695
+ | HH24 Hour of the day (0-23). |
1696
+ | Example: |
1697
+ | +-------------------------------------------------+ |
1698
+ | | data formatter result | |
1699
+ | +-------------------------------------------------+ |
1700
+ | | 2016-01-06 09:08:01.000000 HH24 09 | |
1701
+ | +-------------------------------------------------+ |
1702
+ +--------------------------------------------------------------------------------------------------+
1703
+ | IW Week of year (1-52 or 1-53) based on ISO model. |
1704
+ | Example: |
1705
+ | +-------------------------------------------------+ |
1706
+ | | data formatter result | |
1707
+ | +-------------------------------------------------+ |
1708
+ | | 2016-01-06 09:08:01.000000 IW 01 | |
1709
+ | +-------------------------------------------------+ |
1710
+ +--------------------------------------------------------------------------------------------------+
1711
+ | IYY |
1712
+ | IY Last 3, 2, or 1 digits of ISO year. |
1713
+ | I |
1714
+ | Example: |
1715
+ | +-------------------------------------------------+ |
1716
+ | | data formatter result | |
1717
+ | +-------------------------------------------------+ |
1718
+ | | 2016-01-06 09:08:01.000000 IY 16 | |
1719
+ | +-------------------------------------------------+ |
1720
+ +--------------------------------------------------------------------------------------------------+
1721
+ | IYYY 4-digit year based on the ISO standard. |
1722
+ | Example: |
1723
+ | +-------------------------------------------------+ |
1724
+ | | data formatter result | |
1725
+ | +-------------------------------------------------+ |
1726
+ | | 2016-01-06 09:08:01.000000 IYYY 2016 | |
1727
+ | +-------------------------------------------------+ |
1728
+ +--------------------------------------------------------------------------------------------------+
1729
+ | J Julian day, the number of days since January 1, 4713 BC. |
1730
+ | Number specified with J must be integers. |
1731
+ | Teradata uses the Gregorian calendar in calculations to |
1732
+ | and from Julian Days. |
1733
+ | Example: |
1734
+ | +-------------------------------------------------+ |
1735
+ | | data formatter result | |
1736
+ | +-------------------------------------------------+ |
1737
+ | | 2016-01-06 09:08:01.000000 J 2457394 | |
1738
+ | +-------------------------------------------------+ |
1739
+ +--------------------------------------------------------------------------------------------------+
1740
+ | MI Minute (0-59). |
1741
+ | Example: |
1742
+ | +-------------------------------------------------+ |
1743
+ | | data formatter result | |
1744
+ | +-------------------------------------------------+ |
1745
+ | | 2016-01-06 09:08:01.000000 MI 08 | |
1746
+ | +-------------------------------------------------+ |
1747
+ +--------------------------------------------------------------------------------------------------+
1748
+ | MM Month (01-12). |
1749
+ | Example: |
1750
+ | +-------------------------------------------------+ |
1751
+ | | data formatter result | |
1752
+ | +-------------------------------------------------+ |
1753
+ | | 2016-01-06 09:08:01.000000 MM 01 | |
1754
+ | +-------------------------------------------------+ |
1755
+ +--------------------------------------------------------------------------------------------------+
1756
+ | MON Abbreviated name of month. |
1757
+ | Example: |
1758
+ | +-------------------------------------------------+ |
1759
+ | | data formatter result | |
1760
+ | +-------------------------------------------------+ |
1761
+ | | 2016-01-06 09:08:01.000000 MON JAN | |
1762
+ | +-------------------------------------------------+ |
1763
+ +--------------------------------------------------------------------------------------------------+
1764
+ | MONTH Name of month. |
1765
+ | Example: |
1766
+ | +-------------------------------------------------+ |
1767
+ | | data formatter result | |
1768
+ | +-------------------------------------------------+ |
1769
+ | | 2016-01-06 09:08:01.000000 MONTH JANUARY | |
1770
+ | +-------------------------------------------------+ |
1771
+ +--------------------------------------------------------------------------------------------------+
1772
+ | PM |
1773
+ | P.M. Meridian indicator. |
1774
+ | Example: |
1775
+ | +-------------------------------------------------+ |
1776
+ | | data formatter result | |
1777
+ | +-------------------------------------------------+ |
1778
+ | | 2016-01-06 09:08:01.000000 HHPM 09PM | |
1779
+ | +-------------------------------------------------+ |
1780
+ +--------------------------------------------------------------------------------------------------+
1781
+ | Q Quarter of year (1, 2, 3, 4). |
1782
+ | Example: |
1783
+ | +-------------------------------------------------+ |
1784
+ | | data formatter result | |
1785
+ | +-------------------------------------------------+ |
1786
+ | | 2016-01-06 09:08:01.000000 Q 1 | |
1787
+ | +-------------------------------------------------+ |
1788
+ +--------------------------------------------------------------------------------------------------+
1789
+ | RM Roman numeral month (I - XII). |
1790
+ | Example: |
1791
+ | +-------------------------------------------------+ |
1792
+ | | data formatter result | |
1793
+ | +-------------------------------------------------+ |
1794
+ | | 2016-01-06 09:08:01.000000 RM I | |
1795
+ | +-------------------------------------------------+ |
1796
+ +--------------------------------------------------------------------------------------------------+
1797
+ | SP Spelled. Any numeric element followed by SP is spelled in|
1798
+ | English words. The words are capitalized according to how|
1799
+ | the element is capitalized. |
1800
+ | For example: 'DDDSP' specifies all uppercase, 'DddSP' |
1801
+ | specifies that the first letter is capitalized, and |
1802
+ | 'dddSP' specifies all lowercase. |
1803
+ | Example: |
1804
+ | +-------------------------------------------------+ |
1805
+ | | data formatter result | |
1806
+ | +-------------------------------------------------+ |
1807
+ | | 2016-01-06 09:08:01.000000 HHSP NINE | |
1808
+ | +-------------------------------------------------+ |
1809
+ +--------------------------------------------------------------------------------------------------+
1810
+ | SS Second (0-59). |
1811
+ | Example: |
1812
+ | +-------------------------------------------------+ |
1813
+ | | data formatter result | |
1814
+ | +-------------------------------------------------+ |
1815
+ | | 2016-01-06 09:08:01.000000 SS 03 | |
1816
+ | +-------------------------------------------------+ |
1817
+ +--------------------------------------------------------------------------------------------------+
1818
+ | SSSSS Seconds past midnight (0-86399). |
1819
+ | Example: |
1820
+ | +-------------------------------------------------+ |
1821
+ | | data formatter result | |
1822
+ | +-------------------------------------------------+ |
1823
+ | | 2016-01-06 09:08:01.000000 SSSSS 32883 | |
1824
+ | +-------------------------------------------------+ |
1825
+ +--------------------------------------------------------------------------------------------------+
1826
+ | TS Time Short. Equivalent to the format string |
1827
+ | 'HH:MI:SS AM'. |
1828
+ | Example: |
1829
+ | +-------------------------------------------------+ |
1830
+ | | data formatter result | |
1831
+ | +-------------------------------------------------+ |
1832
+ | | 2016-01-06 09:08:01.000000 TS 09:08:01 AM | |
1833
+ | +-------------------------------------------------+ |
1834
+ +--------------------------------------------------------------------------------------------------+
1835
+ | TZH Time zone hour. |
1836
+ | Example: |
1837
+ | +-------------------------------------------------+ |
1838
+ | | data formatter result | |
1839
+ | +-------------------------------------------------+ |
1840
+ | | 2016-01-06 09:08:01.000000 TZH +00 | |
1841
+ | +-------------------------------------------------+ |
1842
+ +--------------------------------------------------------------------------------------------------+
1843
+ | TZM Time zone minute. |
1844
+ | Example: |
1845
+ | +-------------------------------------------------+ |
1846
+ | | data formatter result | |
1847
+ | +-------------------------------------------------+ |
1848
+ | | 2016-01-06 09:08:01.000000 TZM 00 | |
1849
+ | +-------------------------------------------------+ |
1850
+ +--------------------------------------------------------------------------------------------------+
1851
+ | TZR Time zone region. Equivalent to the format string |
1852
+ | 'TZH:TZM'. |
1853
+ | Example: |
1854
+ | +-------------------------------------------------+ |
1855
+ | | data formatter result | |
1856
+ | +-------------------------------------------------+ |
1857
+ | | 2016-01-06 09:08:01.000000 TZR +00:00 | |
1858
+ | +-------------------------------------------------+ |
1859
+ +--------------------------------------------------------------------------------------------------+
1860
+ | WW Week of year (1-53) where week 1 starts on the first day |
1861
+ | of the year and continues to the 7th day of the year. |
1862
+ | Example: |
1863
+ | +-------------------------------------------------+ |
1864
+ | | data formatter result | |
1865
+ | +-------------------------------------------------+ |
1866
+ | | 2016-01-06 09:08:01.000000 WW 01 | |
1867
+ | +-------------------------------------------------+ |
1868
+ +--------------------------------------------------------------------------------------------------+
1869
+ | W Week of month (1-5) where week 1 starts on the first day |
1870
+ | of the month and ends on the seventh. |
1871
+ | Example: |
1872
+ | +-------------------------------------------------+ |
1873
+ | | data formatter result | |
1874
+ | +-------------------------------------------------+ |
1875
+ | | 2016-01-06 09:08:01.000000 W 1 | |
1876
+ | +-------------------------------------------------+ |
1877
+ +--------------------------------------------------------------------------------------------------+
1878
+ | X Local radix character. |
1879
+ | Example: |
1880
+ | +-------------------------------------------------+ |
1881
+ | | data formatter result | |
1882
+ | +-------------------------------------------------+ |
1883
+ | | 2016-01-06 09:08:01.000000 MMXYY 01.16 | |
1884
+ | +-------------------------------------------------+ |
1885
+ +--------------------------------------------------------------------------------------------------+
1886
+ | Y,YYY Year with comma in this position. |
1887
+ | Example: |
1888
+ | +-------------------------------------------------+ |
1889
+ | | data formatter result | |
1890
+ | +-------------------------------------------------+ |
1891
+ | | 2016-01-06 09:08:01.000000 Y,YYY 2,016 | |
1892
+ | +-------------------------------------------------+ |
1893
+ +--------------------------------------------------------------------------------------------------+
1894
+ | YEAR Year, spelled out. S prefixes BC dates with a minus sign.|
1895
+ | SYEAR |
1896
+ | Example: |
1897
+ | +-------------------------------------------------+ |
1898
+ | | data formatter result | |
1899
+ | +-------------------------------------------------+ |
1900
+ | | 2016-01-06 09:08:01.000000 YEAR TWENTY SIXTEEN| |
1901
+ | +-------------------------------------------------+ |
1902
+ +--------------------------------------------------------------------------------------------------+
1903
+ | YYYY |
1904
+ | SYYYY 4-digit year. S prefixes BC dates with a minus sign. |
1905
+ | Example: |
1906
+ | +-------------------------------------------------+ |
1907
+ | | data formatter result | |
1908
+ | +-------------------------------------------------+ |
1909
+ | | 2016-01-06 09:08:01.000000 YYYY 2016 | |
1910
+ | +-------------------------------------------------+ |
1911
+ +--------------------------------------------------------------------------------------------------+
1912
+ | YYY Last 3, 2, or 1 digit of year. |
1913
+ | YY If the current year and the specified year are both in |
1914
+ | Y the range of 0-49, the date is in the current century. |
1915
+ | Example: |
1916
+ | +-------------------------------------------------+ |
1917
+ | | data formatter result | |
1918
+ | +-------------------------------------------------+ |
1919
+ | | 2016-01-06 09:08:01.000000 YY 16 | |
1920
+ | +-------------------------------------------------+ |
1921
+ +--------------------------------------------------------------------------------------------------+
1922
+ """
1923
+ # Validate formatter_type
1924
+ if formatter_type not in [None, "NUMERIC", "DATE", "CHAR"]:
1925
+ raise ValueError(
1926
+ "formatter_type must be one of 'NUMERIC', 'DATE', 'CHAR' or None."
1927
+ )
1928
+ if formatter_type is None:
1929
+ formatter = (
1930
+ numeric_formatters
1931
+ + "\n\n"
1932
+ + date_formatters
1933
+ + "\n\n"
1934
+ + char_formatters
1935
+ + "\n\n"
1936
+ )
1937
+ elif formatter_type == "NUMERIC":
1938
+ formatter = numeric_formatters
1939
+ elif formatter_type == "DATE":
1940
+ formatter = date_formatters
1941
+ elif formatter_type == "CHAR":
1942
+ formatter = char_formatters
1943
+ print(formatter)