String Functions | SQLAlchemy | teradataml - 17.00 - String Functions - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.00
Release Date
November 2021
Content Type
User Guide
Publication ID
B700-4006-070K
Language
English (United States)
Examples for all string functions can be found at: <pkg_install_location>\teradataml\data\notebooks\sqlalchemy\Teradata Vantage String Functions Using SQLAlchemy.ipynb.

Supported functions

S/N Function Name Description Comment
1 ASCII Returns the decimal representation of the first character in string_expr as a NUMBER value. The decimal representation will reflect the character set of the input string.  
2 CHAR2HEXINT Returns the hexadecimal representation for a character string.  
3 CHR Returns the Latin ASCII character given a numeric code value.  
4 CONCAT Concatenates string expressions.  
5 EDITDISTANCE Returns the minimum number of edit operations (insertions, deletions, substitutions and transpositions) required to transform string1 into string2.  
6 INDEX Returns the position in string_expression_1 where string_expression_2 starts.  
7 INITCAP Modifies a string argument and returns the string with the first character in each word in uppercase and all other characters in lowercase. Words are delimited by white space or characters that are not alphanumeric.  
8 INSTR Searches the source_string argument for occurrences of search_string.  
9 LEFT

Truncates in input string to a specified number of characters.

The LEFT function can be called with the 'LEFT' or 'TD_LEFT' alias names.

 
10 LENGTH Returns the number of characters in the expression.  
11 LOCATE Returns the position of the first occurrence of string_expr1 within string_expr2. The search for the first occurrence of string_expr1 begins with the first character position in string_expr2 unless the optional argument, n1, is specified.  
12 LOWER Returns a character string identical to character_string_expression, except that all uppercase letters are replaced with their lowercase equivalents.  
13 LPAD Returns the source_string padded to the left with the characters in fill_string so that the resulting string is length characters.  
14 LTRIM Returns the argument expr1, with its left-most characters removed up to the first character that is not in the argument expr2.  
15 NGRAM Returns the number of n-gram matches between string1 and string2.  
16 NVP Extracts the value of a name-value pair where the name in the pair matches the name and the number of the occurrence specified.  
17 OREPLACE Replaces every occurrence of search_string in the source_string with the replace_string. Use this function either to replace or remove portions of a string.  
18 OTRANSLATE Returns source_string with every occurrence of each character in from_string replaced with the corresponding character in to_string.  
19 REVERSE Reverses the input string.  
20 RIGHT

Starting from the end of the input string, a substring is created with the number of characters specified by the second parameter.

The RIGHT function can be called with the 'RIGHT' or 'TD_RIGHT' alias names.

 
21 RPAD Returns the source_string padded to the right with the characters in fill_string so that the resulting string is length characters.  
22 RTRIM Returns the argument expr1, with its right-most characters removed up to the first character that is not in the argument expr2.  
23 SOUNDEX Returns a character string that represents the Soundex code for string_expression.  
24 STRING_CS Returns a heuristically derived integer value that you can use to help determine which KANJI1-compatible client character set was used to encode string_expression.  
25 SUNSTRING / SUBSTR Extracts a substring from a named string based on position. Only Teradata Syntax is supported. ANSI syntax is not supported. In SQL, both are supported. Check SQL functions documentation.
26 TRIM Takes a character or byte string_expression argument, trims the specified pad characters or bytes, and returns the trimmed string.

Following clauses from SQL are not supported:

  • BOTH
  • Leading
  • Trailing
  • From
  • character_Set
27 UPPER / UCASE Returns a character string identical to character_string_expression, except that all lowercase letters are replaced by their uppercase equivalents.  

Unsupported functions

  • CSV
  • CSVLD
  • POSITION
  • STROK
  • STRTOK_SPLIT_TO_TABLE
  • TRANSLATE
  • TRANSLATE_CHK
  • VARGRAPHIC