Skip to content

Commit

Permalink
Updated udf_extractor: not filling IDs any more; need users to return…
Browse files Browse the repository at this point in the history
… NULL themselves
  • Loading branch information
zifeishan committed May 3, 2014
1 parent b34ad56 commit 5a6d651
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class PostgresExtractionDataStore extends ExtractionDataStore[JsObject] with Jdb

/* Builds a COPY statement for a given relation and column names */
def buildCopySql(relationName: String, keys: Set[String]) = {
val fields = List("id") ++ keys.filterNot(_ == "id").toList.sorted
// Zifei: do not fill ID any more
// val fields = List("id") ++ keys.filterNot(_ == "id").toList.sorted
val fields = keys.filterNot(_ == "id").toList.sorted
s"""COPY ${relationName}(${fields.mkString(", ")}) FROM STDIN CSV"""
}

Expand All @@ -61,9 +63,10 @@ class PostgresExtractionDataStore extends ExtractionDataStore[JsObject] with Jdb
for (obj <- data) {
val dataList = obj.value.filterKeys(_ != "id").toList.sortBy(_._1)
val strList = dataList.map (x => jsValueToString(x._2))
// We get a unique id for the record
val id = variableIdCounter.getAndIncrement().toString
writer.writeNext((Seq(id) ++ strList)toArray)
// // We get a unique id for the record
// val id = variableIdCounter.getAndIncrement().toString
// writer.writeNext((Seq(id) ++ strList)toArray)
writer.writeNext((strList)toArray)
}
}

Expand Down

0 comments on commit 5a6d651

Please sign in to comment.