Skip to content

Instantly share code, notes, and snippets.

@timgent
Last active August 8, 2020 09:16
Show Gist options
  • Save timgent/9ff5e462bb0bdfcc7065aba38b6c34d2 to your computer and use it in GitHub Desktop.
Save timgent/9ff5e462bb0bdfcc7065aba38b6c34d2 to your computer and use it in GitHub Desktop.
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