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

[wip] backfill prototype #1125

Open
wants to merge 2 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,11 @@ private[offline] class SlidingWindowAggregationJoiner(

contextDF = if (swaHandler.isDefined) swaHandler.get.join(labelDataDef, factDataDefs.toList) else SlidingWindowJoin.join(labelDataDef, factDataDefs.toList)

val missingFeatures = factDataDefs.flatMap (factData => factData.aggFeatures.map(feature => feature.name)) diff (contextDF.columns diff origContextObsColumns)
log.warn("The following features are missing because of an IO Exception" + missingFeatures)
val finalJoinedFeatures = joinedFeatures diff missingFeatures
contextDF = if (shouldFilterNulls && !factDataRowsWithNulls.isEmpty) {
val nullDfWithFeatureCols = joinedFeatures.foldLeft(factDataRowsWithNulls)((s, x) => s.withColumn(x, lit(null)))
val nullDfWithFeatureCols = finalJoinedFeatures.foldLeft(factDataRowsWithNulls)((s, x) => s.withColumn(x, lit(null)))
contextDF.union(nullDfWithFeatureCols)
} else contextDF

Expand All @@ -272,13 +275,13 @@ private[offline] class SlidingWindowAggregationJoiner(
.asInstanceOf[TimeWindowConfigurableAnchorExtractor].features(nameToFeatureAnchor._1).columnFormat)

val FeatureDataFrame(withFDSFeatureDF, inferredTypes) =
SlidingWindowFeatureUtils.convertSWADFToFDS(contextDF, joinedFeatures.toSet, featureNameToColumnFormat, userSpecifiedTypesConfig)
SlidingWindowFeatureUtils.convertSWADFToFDS(contextDF, finalJoinedFeatures.toSet, featureNameToColumnFormat, userSpecifiedTypesConfig)
// apply default on FDS dataset
val withFeatureContextDF =
substituteDefaults(withFDSFeatureDF, defaults.keys.filter(joinedFeatures.contains).toSeq, defaults, userSpecifiedTypesConfig, ss)
substituteDefaults(withFDSFeatureDF, defaults.keys.filter(finalJoinedFeatures.contains).toSeq, defaults, userSpecifiedTypesConfig, ss)

allInferredFeatureTypes ++= inferredTypes
contextDF = standardizeFeatureColumnNames(origContextObsColumns, withFeatureContextDF, joinedFeatures, keyTags.map(keyTagList))
contextDF = standardizeFeatureColumnNames(origContextObsColumns, withFeatureContextDF, finalJoinedFeatures, keyTags.map(keyTagList))
if (shouldCheckPoint(ss)) {
// checkpoint complicated dataframe for each stage to avoid Spark failure
contextDF = contextDF.checkpoint(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,119 +1,119 @@
{
"schema": {
"type": "record",
"name": "NTVObs",
"doc": "Daily or multi-day aggregated a activity features generated from similar data sources.",
"namespace": "com.linkedin.feathr.offline.data",
"fields": [
{
"name": "x",
"type": [
"null",
"string"
],
"doc": ""
},
{
"name": "y",
"type": "string",
"doc": ""
},
{
"name": "timestamp",
"type": "string"
},
{
"name": "passthroughFeatures",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "features",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "term",
"type": "string"
},
{
"name": "value",
"type": "float"
}
]
}
}
"type" : "record",
"name" : "NTVObs2",
"fields" : [ {
"name" : "header",
"type" : {
"type" : "record",
"name" : "EventHeader",
"fields" : [ {
"name" : "memberId",
"type" : "long",
"doc" : "The LinkedIn member ID of the user initiating the action. LinkedIn member IDs are integers greater than zero. Guests are represented either as zero or a negative number."
}, {
"name" : "time",
"type" : "long",
"doc" : "The time of the event"
}, {
"name" : "bucket_time",
"type" : "long",
"doc" : "The time of the event"
}]
}
]
}]
},
"data": [
{
"x": {
"string": "a1"
},
"y": "a2",
"timestamp": "2018-05-03",
"passthroughFeatures": [
{
"name": "f1f1",
"term": "f1t1",
"value": 12
}
]
"header" : {
"memberId" : 1561,
"time" : 1613361620,
"bucket_time": 1613361600
}
},
{
"header" : {
"memberId" : 1561,
"time" : 1613361679,
"bucket_time": 1613361600
}
},
{
"x": {
"string": "a2"
},
"y": "a1",
"timestamp": "2018-05-03",
"passthroughFeatures": [
{
"name": "f1f1",
"term": "f1t1",
"value": 12
}
]
"header": {
"memberId": 1561,
"time": 1613361610,
"bucket_time": 1613361600
}
},
{
"x": null,
"y": "a5",
"timestamp": "2018-05-03",
"passthroughFeatures": [
{
"name": "f1f1",
"term": "f1t1",
"value": 12
}
]
"header" : {
"memberId" : 1561,
"time" : 1613361643,
"bucket_time": 1613361600
}
},
{
"x": null,
"y": "a8",
"timestamp": "2018-05-03",
"passthroughFeatures": [
{
"name": "f1f1",
"term": "f1t1",
"value": 12
}
]
"header" : {
"memberId" : 1561,
"time" : 1613361650,
"bucket_time": 1613361600
}
},
{
"x": {
"string": "xyz"
},
"y": "abc",
"timestamp": "2018-04-30",
"passthroughFeatures": [
{
"name": "f2f2",
"term": "f2t2",
"value": 12
}
]
"header" : {
"memberId" : 1561,
"time" : 1613361249,
"bucket_time": 1613361000
}
},
{
"header" : {
"memberId" : 1561,
"time" : 1613358000,
"bucket_time": 1613358000
}
},
{
"header" : {
"memberId" : 1561,
"time" : 1613358300,
"bucket_time": 1613358300
}
},
{
"header" : {
"memberId" : 1561,
"time" : 1613361248,
"bucket_time": 1613361000
}
},
{
"header" : {
"memberId" : 1561,
"time" : 1613361049,
"bucket_time": 1613361000
}
},
{
"header" : {
"memberId" : 1561,
"time" : 1613358660,
"bucket_time": 1613358600
}
},
{
"header": {
"memberId": 1561,
"time": 1613358900,
"bucket_time": 1613358900
}
},
{
"header": {
"memberId": 1561,
"time": 1613362200,
"bucket_time": 1613362200
}
}
]
}