Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ case class GroupByPlanner(groupBy: GroupBy)(implicit outputPartitionSpec: Partit
groupBy.metaData.name + "__upload",
groupByTableDeps,
Some(stepDays),
Some(groupBy.metaData.uploadTable))
Some(groupBy.metaData.uploadTable))(PartitionSpec.daily)

val node = new GroupByUploadNode().setGroupBy(eraseExecutionInfo)
toNode(metaData, _.setGroupByUpload(node), semanticGroupBy(groupBy))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class GroupByPlannerTest extends AnyFlatSpec with Matchers {
uploadNode.get.content should not be null
uploadNode.get.content.getGroupByUpload should not be null
uploadNode.get.content.getGroupByUpload.groupBy should not be null
// upload node should use the daily partition spec
uploadNode.get.metaData.executionInfo.outputTableInfo.partitionColumn should equal(PartitionSpec.daily.column)
uploadNode.get.metaData.executionInfo.outputTableInfo.partitionFormat should equal(PartitionSpec.daily.format)

// Backfill node should have content
backfillNode.get.content should not be null
Expand Down
6 changes: 4 additions & 2 deletions spark/src/main/scala/ai/chronon/spark/GroupByUpload.scala
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ object GroupByUpload {
kvDf
.union(metaDf)
.withColumn("ds", lit(endDs))
.save(groupByConf.metaData.uploadTable, groupByConf.metaData.tableProps, partitionColumns = List.empty)
.save(groupByConf.metaData.uploadTable, groupByConf.metaData.tableProps, partitionColumns = List("ds"))

val kvDfReloaded = tableUtils
.loadTable(groupByConf.metaData.uploadTable)
Expand All @@ -294,6 +294,8 @@ object GroupByUpload {
throw new RuntimeException("GroupBy upload resulted in zero rows.")
}

context.gauge(Metrics.Name.LatencyMinutes, (System.currentTimeMillis() - startTs) / (60 * 1000))
val jobDuration = (System.currentTimeMillis() - startTs) / 1000
context.gauge(Metrics.Name.LatencyMinutes, (jobDuration / 60))
logger.info(s"GroupBy upload completed in $jobDuration seconds")
}
}
8 changes: 4 additions & 4 deletions spark/src/main/scala/ai/chronon/spark/catalog/Iceberg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ case object Iceberg extends Format {
throw new NotImplementedError("subPartitionsFilter is not supported on this format")
}

getIcebergPartitions(tableName, partitionFilters)
getIcebergPartitions(tableName, partitionColumn)
}

override def partitions(tableName: String, partitionFilters: String)(implicit
Expand All @@ -26,7 +26,7 @@ case object Iceberg extends Format {
"For single partition retrieval, please use 'partition' method.")
}

private def getIcebergPartitions(tableName: String, partitionFilters: String)(implicit
private def getIcebergPartitions(tableName: String, partitionColumn: String)(implicit
sparkSession: SparkSession): List[String] = {

val partitionsDf = sparkSession.read
Expand All @@ -40,7 +40,7 @@ case object Iceberg extends Format {
// Hour filter is currently buggy in iceberg. https://github.com/apache/iceberg/issues/4718
// so we collect and then filter.
partitionsDf
.select(date_format(col(s"partition.${tableUtils.partitionColumn}"), partitionFmt), col("partition.hr"))
.select(date_format(col(s"partition.$partitionColumn"), partitionFmt), col("partition.hr"))
.collect()
.filter(_.get(1) == null)
.map(_.getString(0))
Expand All @@ -49,7 +49,7 @@ case object Iceberg extends Format {
} else {

partitionsDf
.select(date_format(col(s"partition.${tableUtils.partitionColumn}"), partitionFmt))
.select(date_format(col(s"partition.$partitionColumn"), partitionFmt))
.collect()
.map(_.getString(0))
.toList
Expand Down