Last active
August 8, 2020 09:16
-
-
Save timgent/9ff5e462bb0bdfcc7065aba38b6c34d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArbSingleDsCheck("less than 5 flash sales per customer") { ds => | |
val tooManyFlashSaleCustomerCount = ds | |
.filter(col("orderType") === "Flash Sale") | |
.groupBy("customerId").agg(count("orderId").as("flashSaleCount")) | |
.filter(col("flashSaleCount") > 5) | |
.count | |
if (tooManyFlashSaleCustomerCount > 0) | |
RawCheckResult(CheckStatus.Error, s"$tooManyFlashSaleCustomerCount customers had too many flash sales") | |
else | |
RawCheckResult(CheckStatus.Success, "No customers had more than 5 flash sales :)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment