Skip to content

Commit

Permalink
CDF-20182: fix fdm deduplication logic: use (space, externalId) inste…
Browse files Browse the repository at this point in the history
…ad of just (space)

During scan we have deduplication of items, it was done by just `externalId`.
But `externalId` can be reused between different spaces in dms case.

So let's pass `space` around and use `space`+`externalId` for deduplication.
We do have `space` value available, just a matter of using it.

[CDF-20182]
  • Loading branch information
dmivankov committed Nov 3, 2023
1 parent 913920d commit 7b3eb28
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ abstract class FlexibleDataModelBaseRelation(config: RelationConfig, sqlContext:
with WritableRelation {

override def buildScan(selectedColumns: Array[String], filters: Array[Filter]): RDD[Row] =
SdkV1Rdd[ProjectedFlexibleDataModelInstance, String](
SdkV1Rdd[ProjectedFlexibleDataModelInstance, (String, String)](
sqlContext.sparkContext,
config,
(item: ProjectedFlexibleDataModelInstance, _) => toRow(item),
_.externalId,
instance => (instance.space, instance.externalId),
getStreams(filters, selectedColumns)
)

Expand Down Expand Up @@ -201,7 +201,8 @@ abstract class FlexibleDataModelBaseRelation(config: RelationConfig, sqlContext:
case s if s.equalsIgnoreCase("spaceExternalId") => n.space
case s if s.equalsIgnoreCase("externalId") => n.externalId
case p => allAvailablePropValues.get(p).map(extractInstancePropertyValue).orNull
}
},
space = n.space
)
case e: InstanceDefinition.EdgeDefinition =>
ProjectedFlexibleDataModelInstance(
Expand All @@ -214,7 +215,8 @@ abstract class FlexibleDataModelBaseRelation(config: RelationConfig, sqlContext:
case s if s.equalsIgnoreCase("endNode") => Array(e.endNode.space, e.endNode.externalId)
case s if s.equalsIgnoreCase("type") => Array(e.`type`.space, e.`type`.externalId)
case p => allAvailablePropValues.get(p).map(extractInstancePropertyValue).orNull
}
},
space = e.space
)
}
}
Expand Down Expand Up @@ -485,5 +487,8 @@ abstract class FlexibleDataModelBaseRelation(config: RelationConfig, sqlContext:
}

object FlexibleDataModelBaseRelation {
final case class ProjectedFlexibleDataModelInstance(externalId: String, properties: Array[Any])
final case class ProjectedFlexibleDataModelInstance(
space: String,
externalId: String,
properties: Array[Any])
}

0 comments on commit 7b3eb28

Please sign in to comment.