Skip to content

Commit

Permalink
Merge pull request #79 from timgent/filter-helper-constructors
Browse files Browse the repository at this point in the history
Add helpers for defining metric filters with less boilerplate
  • Loading branch information
timgent authored Jul 12, 2020
2 parents cdd90d5 + 8a0b300 commit 3ebc29a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.timgent.sparkdataquality.metrics

import org.apache.spark.sql.Column
import org.apache.spark.sql.functions.lit
import org.apache.spark.sql.functions.{lit, col}

/**
* Defines a filter to be applied before a metric is calculated
Expand All @@ -12,6 +12,9 @@ case class MetricFilter(filter: Column, filterDescription: String)

object MetricFilter {

def apply(filter: Column): MetricFilter = MetricFilter(filter, filter.toString)
def apply(filter: String): MetricFilter = MetricFilter(col(filter), filter)

/**
* Don't apply any filter
* @return A MetricFilter that doesn't filter records at all
Expand Down

0 comments on commit 3ebc29a

Please sign in to comment.