-
Notifications
You must be signed in to change notification settings - Fork 9
Add Driver verb to bulk load GBU data to KV store #172
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
Changes from 4 commits
1d44c1b
712f86f
aa71445
078d378
a7a8bf3
79e703f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -714,6 +714,38 @@ object Driver { | |||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| object GroupByUploadToKVBulkLoad { | ||||||||||||||||||||||||||||||||||||||||||||||
| @transient lazy val logger: Logger = LoggerFactory.getLogger(getClass) | ||||||||||||||||||||||||||||||||||||||||||||||
| class Args extends Subcommand("groupby-upload-bulk-load") with OnlineSubcommand { | ||||||||||||||||||||||||||||||||||||||||||||||
| val srcOfflineTable: ScallopOption[String] = | ||||||||||||||||||||||||||||||||||||||||||||||
| opt[String](required = true, descr = "Name of the source GroupBy Upload table") | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| val groupbyName: ScallopOption[String] = | ||||||||||||||||||||||||||||||||||||||||||||||
| opt[String](required = true, descr = "Name of the GroupBy that we're triggering this upload for") | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| val partitionString: ScallopOption[String] = | ||||||||||||||||||||||||||||||||||||||||||||||
| opt[String](required = true, descr = "Partition string (in 'yyyy-MM-dd' format) that we are uploading") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+720
to
+727
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for partition string format. Ensure the partition string matches 'yyyy-MM-dd' format to prevent runtime errors. val partitionString: ScallopOption[String] =
opt[String](required = true, descr = "Partition string (in 'yyyy-MM-dd' format) that we are uploading")
+ validate(s => try {
+ java.time.LocalDate.parse(s, java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ true
+ } catch {
+ case _: Exception => false
+ })📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def run(args: Args): Unit = { | ||||||||||||||||||||||||||||||||||||||||||||||
| logger.info(s"Triggering bulk load for GroupBy: ${args.groupbyName()} for partition: ${args | ||||||||||||||||||||||||||||||||||||||||||||||
| .partitionString()} from table: ${args.srcOfflineTable()}") | ||||||||||||||||||||||||||||||||||||||||||||||
| val kvStore = args.api.genKvStore | ||||||||||||||||||||||||||||||||||||||||||||||
| val startTime = System.currentTimeMillis() | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| kvStore.bulkPut(args.srcOfflineTable(), args.groupbyName(), args.partitionString()) | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
| case e: Exception => | ||||||||||||||||||||||||||||||||||||||||||||||
| logger.error(s"Failed to upload GroupBy: ${args.groupbyName()} for partition: ${args | ||||||||||||||||||||||||||||||||||||||||||||||
| .partitionString()} from table: ${args.srcOfflineTable()}", | ||||||||||||||||||||||||||||||||||||||||||||||
| e) | ||||||||||||||||||||||||||||||||||||||||||||||
| throw e | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| logger.info(s"Uploaded GroupByUpload data to KV store for GroupBy: ${args.groupbyName()}; partition: ${args | ||||||||||||||||||||||||||||||||||||||||||||||
| .partitionString()} in ${(System.currentTimeMillis() - startTime) / 1000} seconds") | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| object LogFlattener { | ||||||||||||||||||||||||||||||||||||||||||||||
| class Args extends Subcommand("log-flattener") with OfflineSubcommand { | ||||||||||||||||||||||||||||||||||||||||||||||
| val logTable: ScallopOption[String] = | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -913,6 +945,8 @@ object Driver { | |||||||||||||||||||||||||||||||||||||||||||||
| addSubcommand(FetcherCliArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| object MetadataUploaderArgs extends MetadataUploader.Args | ||||||||||||||||||||||||||||||||||||||||||||||
| addSubcommand(MetadataUploaderArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| object GroupByUploadToKVBulkLoadArgs extends GroupByUploadToKVBulkLoad.Args | ||||||||||||||||||||||||||||||||||||||||||||||
| addSubcommand(GroupByUploadToKVBulkLoadArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| object GroupByStreamingArgs extends GroupByStreaming.Args | ||||||||||||||||||||||||||||||||||||||||||||||
| addSubcommand(GroupByStreamingArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| object AnalyzerArgs extends Analyzer.Args | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -958,7 +992,9 @@ object Driver { | |||||||||||||||||||||||||||||||||||||||||||||
| shouldExit = false | ||||||||||||||||||||||||||||||||||||||||||||||
| GroupByStreaming.run(args.GroupByStreamingArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| case args.MetadataUploaderArgs => MetadataUploader.run(args.MetadataUploaderArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| case args.MetadataUploaderArgs => MetadataUploader.run(args.MetadataUploaderArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| case args.GroupByUploadToKVBulkLoadArgs => | ||||||||||||||||||||||||||||||||||||||||||||||
| GroupByUploadToKVBulkLoad.run(args.GroupByUploadToKVBulkLoadArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| case args.FetcherCliArgs => FetcherCli.run(args.FetcherCliArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| case args.LogFlattenerArgs => LogFlattener.run(args.LogFlattenerArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
| case args.ConsistencyMetricsArgs => ConsistencyMetricsCompute.run(args.ConsistencyMetricsArgs) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
Is this string supposed to match whatever's configured at:
chronon/spark/src/main/scala/ai/chronon/spark/TableUtils.scala
Lines 71 to 72 in 3aa7369
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.
yeah this needs to match what we're writing out.
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.
okay I think there's some form of this where we can DRY things up but wouldn't block the PR. Thanks for clarifying it!