Function mapping is a new database object you can use to specify a simple name to execute a function.
An authorized database can be used to create function mappings for READ_NOS and WRITE _NOS functions with name user desires. User can also store argument value which the user believes to stay constant, for example, "authorization".
The following example demonstrates creation of function mapping for both functions.
# Create definer trusted authorization object. def_trustes_auth_cmd = """CREATE AUTHORIZATION DefAuth AS DEFINER TRUSTED USER 'YOUR-ACCESS-KEY-ID' PASSWORD 'YOUR-SECRET-ACCESS-KEY';"""
fm_name = "<CUSTOM READ_NOS FUNCTION MAPPING NAME>" location = "<EXTERNAL STORE LOCATION>" ReadNOS_fm_create_cmd = '''CREATE FUNCTION MAPPING {fm_name} FOR READ_NOS EXTERNAL SECURITY DEFINER TRUSTED DefAuth USING ANY in TABLE, LOCATION('{location}'), BUFFERSIZE, RETURNTYPE, SAMPLE_PERC, STOREDAS, FULLSCAN, MANIFEST, ROWFORMAT, HEADER;'''.format(fm_name, location) td_context.execute(auth_obj_cmd)
fm_name = "<CUSTOM WRITE_NOS FUNCTION MAPPING NAME>" WriteNOS_fm_create_cmd = '''CREATE FUNCTION MAPPING {fm_name} FOR WRITE_NOS EXTERNAL SECURITY DEFINER TRUSTED DefAuth USING ANY in TABLE, LOCATION('{location}'), STOREDAS('PARQUET'), NAMING, MANIFESTFILE, MANIFESTONLY, OVERWRITE, INCLUDE_ORDERING, INCLUDE_HASHBY, MAXOBJECTSIZE, COMPRESSION;'''.format(fm_name, location) td_context.execute(auth_obj_cmd)
Set the function mappings created by setting configuration options.
from teradataml.options.configure import configure
configure.write_nos_function_mapping = "<CUSTOM WRITE_NOS FUNCTION MAPPING NAME>"
configure.read_nos_function_mapping = "<CUSTOM READ_NOS FUNCTION MAPPING NAME>"
Use function without specifying argument that is stored in function mapping.
wn_obj = WriteNOS(data=titanic_data, stored_as='PARQUET') # Print the result DataFrame. print(wn_obj.result)
rn_obj = ReadNOS() # Print the result DataFame. print(obj.result)