Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18746#discussion_r131223795
  
    --- Diff: python/pyspark/ml/base.py ---
    @@ -116,3 +121,53 @@ class Model(Transformer):
         """
     
         __metaclass__ = ABCMeta
    +
    +
    +@inherit_doc
    +class UnaryTransformer(HasInputCol, HasOutputCol, Transformer):
    +    """
    +    Abstract class for transformers that tae one input column, apply a 
transoformation to it,
    +    and output the result as a new column.
    +
    +    .. versionadded:: 2.3.0
    +    """
    +
    +    @abstractmethod
    +    def createTransformFunc(self):
    +        """
    +        Creates the transoform function using the given param map.
    +        """
    +        raise NotImplementedError()
    +
    +    @abstractmethod
    +    def outputDataType(self):
    +        """
    +        Returns the data type of the output column as a sql type
    +        """
    +        raise NotImplementedError()
    +
    +    @abstractmethod
    +    def validateInputType(self, inputType):
    +        """
    +        Validates the input type. Throws an exception if it is invalid.
    +        """
    +        raise NotImplementedError()
    +
    +    def transformSchema(self, schema):
    +        inputType = schema[self.getInputCol()].dataType
    +        self.validateInputType(inputType)
    +        if self.getOutputCol() in schema.names:
    +            raise ValueError("Output column %s already exists." % 
self.getOutputCol())
    +        outputFields = copy.copy(schema.fields)
    +        outputFields.append(StructField(self.getOutputCol(),
    +                                        self.outputDataType(),
    +                                        nullable=False))
    +        return StructType(outputFields)
    +
    +    def _transform(self, dataset):
    +        self.transformSchema(dataset.schema)
    +        transformFunc = self.createTransformFunc()
    --- End diff --
    
    remove


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to