-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Column Count Analyzer and Check #555
Conversation
import com.amazon.deequ.metrics.Entity | ||
import org.apache.spark.sql.DataFrame | ||
|
||
case class ColumnCount(where: Option[String] = None) extends Analyzer[NumMatches, DoubleMetric] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove where
? Or is that a requirement from Analyzer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
if (state.isDefined) { | ||
Analyzers.metricFromValue(state.get.metricValue(), name, instance, entity) | ||
} else { | ||
Analyzers.metricFromEmpty(this, name, instance, entity) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
val metricValue = if(state.isDefined) state.get.metricValue() else this
Analyzers.metricFromEmpty(metricValue, name, instance, entity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's Analyzers.metricFromValue
if defined and Analyzers.metricFromEmpty
otherwise so this won't work. I'll do a map though.
@@ -26,6 +26,17 @@ import scala.util.Failure | |||
import scala.util.Success | |||
import scala.util.Try | |||
|
|||
case class CustomSqlState(stateOrError: Either[Double, String]) extends DoubleValuedState[CustomSqlState] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either is right biased in Scala, which means the right sided value is what you would operate on when doing map
or flatMap
. In the case of storing exceptions or error messages, usually they are stored as the left sided value of the Either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just moving this from Size.scala to its own class, I can address that in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
* Fix flaky KLL test * Move CustomSql state to CustomSql analyzer * Implement new Analyzer to count columns * Improve documentation, remove unused parameter, replace if/else with map --------- Co-authored-by: Yannis Mentekidis <[email protected]>
Issue #, if available:
Description of changes:
This adds a dataset-scope analyzer that counts the number of columns in a dataset, and uses the analyzer in a Deequ Check
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.