Links

SPRKPY1027

pyspark.sql.readwriter.DataFrameReader.json has a workaround

Category

Warning.

Description

This issue appears when the tool detects the usage of pyspark.sql.readwriter.DataFrameReader.json which has a workaround.
Input code:
df = (spark.read.json("dbfs:/mnt/datalake/VMS/raw_data/df.json", sep=',', inferSchema=True, header=True, multiLine=False, escape='\\', quote='"')
.select('attributename','attributevalue','objecttypecode','value'))
Output code:
#EWI: SPRKPY1027 => pyspark.sql.readwriter.DataFrameReader.json has a workaround, see documentation for more info
df = (spark.read.json("dbfs:/mnt/datalake/VMS/raw_data/df.json", sep=',', inferSchema=True, header=True, multiLine=False, escape='\\', quote='"')
.select('attributename','attributevalue','objecttypecode','value'))

Scenario:

json(path: str, mode: Optional[str], compression: Optional[str], dateFormat: Optional[str], timestampFormat: Optional[str], lineSep: Optional[str], encoding: Optional[str], ignoreNullFields: Optional[Union[bool, str]]) Action: The optional parameters "schema", "sep" and "quote" are not supported in snowpark. So try to replace those uses by the following ones: sep(',') -> option("field delimeter", ","), escape = '\\' -> option("escape", "\\"), Quote='"' -> option("FIELD_OPTIONALLY_ENCLOSED_BY",'"'. InferSchema parameter is not supported at all.
import snowflake.snowpark.DataFrameReader as dfr
df = (spark.read.json("dbfs:/mnt/datalake/VMS/raw_data/df.json", dfr.option("field delimeter", ","),
header=True, multiLine=False, escape=dfr.option("escape", "\\"), quote=dfr.option("FIELD_OPTIONALLY_ENCLOSED_BY",'"'))
.select('attributename','attributevalue','objecttypecode','value'))

Recommendation