code: def _createFromRDD(self, rdd, schema, samplingRatio):
          
          if schema is None or isinstance(schema, (list, tuple)):
              struct = self._inferSchema(rdd, samplingRatio, names=schema)
              converter = _create_converter(struct)
              rdd = rdd.map(converter)
              if isinstance(schema, (list, tuple)):
                  for i, name in enumerate(schema):
                      struct.fields[i].name = name
                      struct.names[i] = name
              schema = struct
  
          elif not isinstance(schema, StructType):
              raise TypeError("schema should be StructType or list or None, but got: %s" % schema)
  
          # convert python objects to sql data
          rdd = rdd.map(schema.toInternal)
          return rdd, schema
docs: Create an RDD for DataFrame from an existing RDD, returns the RDD and schema.