File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed
src/main/scala/com/databricks/spark/csv/util Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,7 @@ object TypeCast {
3636 * @param castType SparkSQL type
3737 */
3838 private [csv] def castTo (datum : String , castType : DataType , nullable : Boolean = true ): Any = {
39- if (castType.isInstanceOf [StringType ]){
40- datum
41- } else if (nullable && datum == " " ){
39+ if (datum == " " && nullable && ! castType.isInstanceOf [StringType ]){
4240 null
4341 } else {
4442 castType match {
@@ -54,6 +52,7 @@ object TypeCast {
5452 case _ : TimestampType => Timestamp .valueOf(datum)
5553 // TODO(hossein): would be good to support other common date formats
5654 case _ : DateType => Date .valueOf(datum)
55+ case _ : StringType => datum
5756 case _ => throw new RuntimeException (s " Unsupported type: ${castType.typeName}" )
5857 }
5958 }
You can’t perform that action at this time.
0 commit comments