Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@throws(classOf[ReadDBFeaturesException])
def getRequirementFeaturesFromDBByProject(project: String): Option[DataFrame] ={
var result: Option[DataFrame] = None
try{
val storedRFsDF = spark
.sqlContext
.read
.format("com.microsoft.azure.cosmosdb.spark")
.cosmosDB(featuresStorageMap)
.toDF()
result = Some(storedRFsDF.filter($"project" === project))
}catch{
case(e: Exception) => {
logger.error(s"Error reading from database. reason: ${e}")
throw new ReadDBFeaturesException(s"Error reading from database. reason: ${e}")
}
}
result
}
@throws(classOf[ReadDBFeaturesException])
def getRequirementFeatureFromDBByID(feature_id: String): RequirementFeaturePersistence = {
try{
val fId: Int = feature_id.toInt
val rfp: RequirementFeaturePersistence = this.datastore
.createQuery(classOf[RequirementFeaturePersistence])
.filter("feature_id =" , feature_id)
.get()
rfp
}catch{
case e: Exception => throw new ReadDBFeaturesException(s"Error getting RFP from DB. Reason: ${e}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.