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

Use date partitioning column in FileSource #1293

Merged
merged 2 commits into from
Jan 28, 2021
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 @@ -16,7 +16,7 @@
*/
package feast.ingestion.sources.file

import java.sql.Timestamp
import java.sql.{Timestamp, Date}

import feast.ingestion.FileSource
import org.apache.spark.sql.functions.col
Expand All @@ -30,9 +30,17 @@ object FileReader {
start: DateTime,
end: DateTime
): DataFrame = {
sqlContext.read
val reader = sqlContext.read
.parquet(source.path)
.filter(col(source.eventTimestampColumn) >= new Timestamp(start.getMillis))
.filter(col(source.eventTimestampColumn) < new Timestamp(end.getMillis))

source.datePartitionColumn match {
case Some(partitionColumn) if partitionColumn.nonEmpty =>
reader
.filter(col(partitionColumn) >= new Date(start.getMillis))
.filter(col(partitionColumn) <= new Date(end.getMillis))
case _ => reader
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BatchPipelineIT extends SparkSpec with ForAllTestContainer {
val rows = generateDistinctRows(gen, 10000, groupByEntity)
val tempPath = storeAsParquet(sparkSession, rows)
val configWithOfflineSource = config.copy(
source = FileSource(tempPath, Map.empty, "eventTimestamp")
source = FileSource(tempPath, Map.empty, "eventTimestamp", datePartitionColumn = Some("date"))
)

BatchPipeline.createPipeline(sparkSession, configWithOfflineSource)
Expand Down