Skip to content

Commit

Permalink
Acxiom#175 Removed code that would attempt to create a list/object by…
Browse files Browse the repository at this point in the history
… parsing string contents that start with [ or {.
  • Loading branch information
dafreels committed Jan 21, 2021
1 parent 1692ee7 commit 90f1c29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.acxiom.pipeline
import com.acxiom.pipeline.utils.{DriverUtils, ReflectionUtils, ScalaScriptEngine}
import org.apache.log4j.Logger
import org.json4s.Formats
import org.json4s.native.JsonMethods.parse
import org.json4s.native.Serialization

import scala.annotation.tailrec
Expand Down Expand Up @@ -515,9 +514,7 @@ trait PipelineStepMapper {

private def mapByValue(value: Option[String], parameter: Parameter, pipelineContext: PipelineContext): Any = {
implicit val formats: Formats = pipelineContext.getJson4sFormats
if (value.getOrElse("").startsWith("[") || value.getOrElse("").startsWith("{")) {
parse(value.get).values // option 1: using the first byte of the string
} else if (value.isDefined) {
if (value.isDefined) {
value.get
} else if (parameter.defaultValue.isDefined) {
logger.debug(s"Parameter ${parameter.name.get} has a defaultValue of ${parameter.defaultValue.getOrElse("")}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.acxiom.pipeline

import java.io.File

import com.acxiom.pipeline.audits.{AuditType, ExecutionAudit}
import com.acxiom.pipeline.utils.DriverUtils
import org.apache.commons.io.FileUtils
Expand All @@ -11,6 +9,8 @@ import org.apache.spark.sql.SparkSession
import org.json4s.{DefaultFormats, Formats}
import org.scalatest.{BeforeAndAfterAll, FunSpec, GivenWhenThen, Suite}

import java.io.File

class PipelineStepMapperTests extends FunSpec with BeforeAndAfterAll with GivenWhenThen with Suite {
private val FIVE = 5
override def beforeAll() {
Expand Down Expand Up @@ -113,8 +113,6 @@ class PipelineStepMapperTests extends FunSpec with BeforeAndAfterAll with GivenW
("big int", Parameter(value = Some(BigInt("5")), `type` = Some("integer")), BigInt("5")),
("decimal", Parameter(value = Some(BigInt("5")), `type` = Some("integer")), BigInt("5")),
("list", Parameter(value = Some(List("5")), `type` = Some("integer")), List("5")),
("string list", Parameter(value = Some("[\"a\", \"b\", \"c\" \"d\"]"), `type` = Some("list")), List("a", "b", "c", "d")),
("int list", Parameter(value = Some("[1, 2, 3]"), `type` = Some("list")), List(1, 2, 3)),
("default value", Parameter(name = Some("fred"), defaultValue = Some("default value"), `type` = Some("string")), "default value"),
("string from global", Parameter(value = Some("!globalString"), `type` = Some("string")), "globalValue1"),
("GlobalLink overrides root global", Parameter(value = Some("!link9"), `type` = Some("string")), "link_override"),
Expand Down

0 comments on commit 90f1c29

Please sign in to comment.