I'm assuming you are using Python.
In order to use the IntegerType, you first have to import it with the following statement:
from pyspark.sql.types import IntegerType
If you plan to have various conversions, it will make sense to import all types. This can be done as follows:
from pyspark.sql.types import *
For further reference, you can check the Spark documentation:
https://spark.apache.org/docs/latest/sql-reference.html