MSCEWI2086

Shell variables found, running this code in a shell script is required.

This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.

Severity

Low

Description

In Teradata scripts, shell variables are used to store temporary values that can be accessed and manipulated throughout the script. Shell variables are defined using the dollar sign ($) followed by a name (which can be enclosed by curly braces), and their values can be set using the assignment operator (=).

#!/bin/bash

# define a shell variable
tablename="mytable"

# use the variable in a Teradata SQL query
bteq <<EOF
    .LOGON myhost/myuser,mypassword
    SELECT * FROM ${tablename};
    .LOGOFF
EOF

You can think of shell variables having the same or similar function as string interpolation. Thus, it is important to keep this functionality when transformed. When converting Scripts to Python, shell variables keep their functionality by running the converted code in a shell script (.sh file). For this reason, these shell variables must keep the same format as the input code.

Example code

Input code

SELECT $column FROM ${tablename}

Output code

#*** Generated code is based on the SnowConvert Python Helpers version 2.0.6 ***
 
import os
import sys
import snowconvert.helpers
from snowconvert.helpers import Export
from snowconvert.helpers import exec
con = None
#** MSC-WARNING - MSCEWI2086 - SHELL VARIABLES FOUND, RUNNING THIS CODE IN A SHELL SCRIPT IS REQUIRED **
def main():
  snowconvert.helpers.configure_log()
  con = snowconvert.helpers.log_on()
  exec(f"""
SELECT
   $column
FROM
   ${tablename}
""")
  snowconvert.helpers.quit_application()

if __name__ == "__main__":
  main()

Recommendations

Last updated