Skip to content
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

[Driver] Group By Streaming Error Handling #706

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions spark/src/main/scala/ai/chronon/spark/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -875,34 +875,28 @@ object Driver {

def main(baseArgs: Array[String]): Unit = {
val args = new Args(baseArgs)
var shouldExit = true
args.subcommand match {
case Some(x) =>
x match {
case args.JoinBackFillArgs => JoinBackfill.run(args.JoinBackFillArgs)
case args.GroupByBackfillArgs => GroupByBackfill.run(args.GroupByBackfillArgs)
case args.StagingQueryBackfillArgs => StagingQueryBackfill.run(args.StagingQueryBackfillArgs)
case args.GroupByUploadArgs => GroupByUploader.run(args.GroupByUploadArgs)
case args.GroupByStreamingArgs =>
shouldExit = false
GroupByStreaming.run(args.GroupByStreamingArgs)

case args.MetadataUploaderArgs => MetadataUploader.run(args.MetadataUploaderArgs)
case args.FetcherCliArgs => FetcherCli.run(args.FetcherCliArgs)
case args.LogFlattenerArgs => LogFlattener.run(args.LogFlattenerArgs)
case args.ConsistencyMetricsArgs => ConsistencyMetricsCompute.run(args.ConsistencyMetricsArgs)
case args.CompareJoinQueryArgs => CompareJoinQuery.run(args.CompareJoinQueryArgs)
case args.AnalyzerArgs => Analyzer.run(args.AnalyzerArgs)
case args.DailyStatsArgs => DailyStats.run(args.DailyStatsArgs)
case args.LogStatsArgs => LogStats.run(args.LogStatsArgs)
case args.MetadataExportArgs => MetadataExport.run(args.MetadataExportArgs)
case args.LabelJoinArgs => LabelJoin.run(args.LabelJoinArgs)
case _ => logger.info(s"Unknown subcommand: $x")
case args.GroupByStreamingArgs => GroupByStreaming.run(args.GroupByStreamingArgs)
case args.MetadataUploaderArgs => MetadataUploader.run(args.MetadataUploaderArgs)
case args.FetcherCliArgs => FetcherCli.run(args.FetcherCliArgs)
case args.LogFlattenerArgs => LogFlattener.run(args.LogFlattenerArgs)
case args.ConsistencyMetricsArgs => ConsistencyMetricsCompute.run(args.ConsistencyMetricsArgs)
case args.CompareJoinQueryArgs => CompareJoinQuery.run(args.CompareJoinQueryArgs)
case args.AnalyzerArgs => Analyzer.run(args.AnalyzerArgs)
case args.DailyStatsArgs => DailyStats.run(args.DailyStatsArgs)
case args.LogStatsArgs => LogStats.run(args.LogStatsArgs)
case args.MetadataExportArgs => MetadataExport.run(args.MetadataExportArgs)
case args.LabelJoinArgs => LabelJoin.run(args.LabelJoinArgs)
case _ => logger.info(s"Unknown subcommand: $x")
}
case None => logger.info(s"specify a subcommand please")
}
if (shouldExit) {
System.exit(0)
}
System.exit(0)
}
}
10 changes: 8 additions & 2 deletions spark/src/main/scala/ai/chronon/spark/streaming/GroupBy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import java.time.{Instant, ZoneId, ZoneOffset}
import java.util.Base64
import scala.collection.JavaConverters._
import scala.concurrent.duration.{DurationInt}
import scala.util.{Failure, Success}

class GroupBy(inputStream: DataFrame,
session: SparkSession,
Expand Down Expand Up @@ -82,8 +83,13 @@ class GroupBy(inputStream: DataFrame,
def buildDataStream(local: Boolean = false): DataStreamWriter[KVStore.PutRequest] = {
val streamingTable = groupByConf.metaData.cleanName + "_stream"
val fetcher = onlineImpl.buildFetcher(local)
val groupByServingInfo = fetcher.getGroupByServingInfo(groupByConf.getMetaData.getName).get

val groupByServingInfoOpt = fetcher.getGroupByServingInfo(groupByConf.getMetaData.getName)
if (groupByServingInfoOpt.isFailure) {
logger.error(s"Failed to retrieve groupByServingInfo: ${groupByServingInfoOpt.failed.get.getMessage}")
session.stop()
sys.exit(1)
}
val groupByServingInfo = groupByServingInfoOpt.get
val streamDecoder = onlineImpl.streamDecoder(groupByServingInfo)
assert(groupByConf.streamingSource.isDefined,
"No streaming source defined in GroupBy. Please set a topic/mutationTopic.")
Expand Down