Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Maynard committed May 9, 2024
1 parent e9cb9d2 commit fc77ed0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import scala.util.control.NonFatal

import com.fasterxml.jackson.core._
import org.apache.hadoop.fs.PositionedReadable
import org.apache.spark.SparkUpgradeException

import org.apache.spark.SparkUpgradeException
import org.apache.spark.internal.Logging
import org.apache.spark.sql.catalyst.{InternalRow, NoopFilters, StructFilters}
import org.apache.spark.sql.catalyst.expressions._
Expand Down Expand Up @@ -277,6 +277,7 @@ class JacksonParser(
}

case _: StringType => (parser: JsonParser) => {
// This must be enabled if we will retrieve the bytes directly from the raw content:
val includeSourceInLocation = JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION
val originalMask = if (includeSourceInLocation.enabledIn(parser.getFeatureMask)) {
1
Expand Down Expand Up @@ -328,6 +329,7 @@ class JacksonParser(
UTF8String.fromBytes(writer.toByteArray)
}
}
// Reset back to the original configuration:
parser.overrideStdFeatures(includeSourceInLocation.getMask, originalMask)
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3899,22 +3899,22 @@ abstract class JsonSuite
}
}
}
// extractData(
// """{"data": {"white": "space"}}""",
// expectedInexactData = Seq("""{"white":"space"}"""),
// expectedExactData = Seq("""{"white": "space"}""")
// )
// extractData(
// """{"data": ["white", "space"]}""",
// expectedInexactData = Seq("""["white","space"]"""),
// expectedExactData = Seq("""["white", "space"]""")
// )
// val granularFloat = "-999.99999999999999999999999999999999995"
// extractData(
// s"""{"data": {"v": ${granularFloat}}}""",
// expectedInexactData = Seq("""{"v":-1000.0}"""),
// expectedExactData = Seq(s"""{"v": ${granularFloat}}""")
// )
extractData(
"""{"data": {"white": "space"}}""",
expectedInexactData = Seq("""{"white":"space"}"""),
expectedExactData = Seq("""{"white": "space"}""")
)
extractData(
"""{"data": ["white", "space"]}""",
expectedInexactData = Seq("""["white","space"]"""),
expectedExactData = Seq("""["white", "space"]""")
)
val granularFloat = "-999.99999999999999999999999999999999995"
extractData(
s"""{"data": {"v": ${granularFloat}}}""",
expectedInexactData = Seq("""{"v":-1000.0}"""),
expectedExactData = Seq(s"""{"v": ${granularFloat}}""")
)
extractData(
s"""{"data": {"white":\n"space"}}""",
expectedInexactData = Seq("""{"white":"space"}"""),
Expand Down

0 comments on commit fc77ed0

Please sign in to comment.