Skip to content

Commit

Permalink
Problem due to missing method in spark 3 solving #86 (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: Alfonso Roa <[email protected]>
  • Loading branch information
alfonsorr and Alfonso Roa authored Feb 14, 2021
1 parent cc2a2ec commit c06b8de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.github.mrpowers.spark.fast.tests

import java.sql.Date

import com.github.mrpowers.spark.fast.tests.ufansi.EscapeAttr
import java.time.format.DateTimeFormatter
import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.catalyst.util.DateTimeUtils

object ArrayPrettyPrint {

Expand All @@ -16,7 +15,7 @@ object ArrayPrettyPrint {
case binary: Array[Byte] => binary.map("%02X".format(_)).mkString("[", " ", "]")
case array: Array[_] => array.mkString("[", ", ", "]")
case seq: Seq[_] => seq.mkString("[", ", ", "]")
case d: Date => DateTimeUtils.dateToString(DateTimeUtils.fromJavaDate(d))
case d: Date => d.toLocalDate.format(DateTimeFormatter.ISO_DATE)
case _ => cell.toString
}
if (truncate > 0 && str.length > truncate) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.mrpowers.spark.fast.tests

import java.sql.Date

import java.time.format.DateTimeFormatter
import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.{DataFrame, Dataset}
import org.apache.spark.sql.catalyst.util.DateTimeUtils

import org.apache.spark.sql.DataFrame

object DataFramePrettyPrint {

Expand Down Expand Up @@ -42,7 +42,7 @@ object DataFramePrettyPrint {
"]"
)
case d: Date =>
DateTimeUtils.dateToString(DateTimeUtils.fromJavaDate(d))
d.toLocalDate.format(DateTimeFormatter.ISO_DATE)
case _ => cell.toString
}
if (truncate > 0 && str.length > truncate) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.mrpowers.spark.fast.tests

import java.sql.Date
import java.time.LocalDate
import org.scalatest.FreeSpec

class ArrayPrettyPrintTest extends FreeSpec {
Expand All @@ -15,6 +17,13 @@ class ArrayPrettyPrintTest extends FreeSpec {
println(ArrayPrettyPrint.showTwoColumnString(arr, 10))
}

"showTwoColumnDate" in {
val now = LocalDate.now()
val arr: Array[(Any, Any)] =
Array(("word1", "word2"), (Date.valueOf(now), Date.valueOf(now)), (Date.valueOf(now.plusDays(-1)), Date.valueOf(now)))
println(ArrayPrettyPrint.showTwoColumnString(arr, 10))
}

"dumbshowTwoColumnString" in {
val arr: Array[(Any, Any)] = Array(("word1", "word2"), ("hi", "there"), ("fun", "train"))
val rowEqual = Array(true, false)
Expand Down

0 comments on commit c06b8de

Please sign in to comment.