You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2015/07/15 19:46:27 UTC

spark git commit: [Minor][SQL] Allow spaces in the beginning and ending of string for Interval

Repository: spark
Updated Branches:
  refs/heads/master a9385271a -> 9716a727f


[Minor][SQL] Allow spaces in the beginning and ending of string for Interval

This is a minor fixing for #7355 to allow spaces in the beginning and ending of string parsed to `Interval`.

Author: Liang-Chi Hsieh <vi...@appier.com>

Closes #7390 from viirya/fix_interval_string and squashes the following commits:

9eb6831 [Liang-Chi Hsieh] Use trim instead of modifying regex.
57861f7 [Liang-Chi Hsieh] Fix scala style.
815a9cb [Liang-Chi Hsieh] Slightly modify regex to allow spaces in the beginning and ending of string.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/9716a727
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/9716a727
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/9716a727

Branch: refs/heads/master
Commit: 9716a727fb2d11380794549039e12e53c771e120
Parents: a938527
Author: Liang-Chi Hsieh <vi...@appier.com>
Authored: Wed Jul 15 10:46:22 2015 -0700
Committer: Reynold Xin <rx...@databricks.com>
Committed: Wed Jul 15 10:46:22 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/spark/unsafe/types/Interval.java  | 1 +
 .../test/java/org/apache/spark/unsafe/types/IntervalSuite.java | 6 ++++++
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/9716a727/unsafe/src/main/java/org/apache/spark/unsafe/types/Interval.java
----------------------------------------------------------------------
diff --git a/unsafe/src/main/java/org/apache/spark/unsafe/types/Interval.java b/unsafe/src/main/java/org/apache/spark/unsafe/types/Interval.java
index eb7475e..905ea0b 100644
--- a/unsafe/src/main/java/org/apache/spark/unsafe/types/Interval.java
+++ b/unsafe/src/main/java/org/apache/spark/unsafe/types/Interval.java
@@ -62,6 +62,7 @@ public final class Interval implements Serializable {
     if (s == null) {
       return null;
     }
+    s = s.trim();
     Matcher m = p.matcher(s);
     if (!m.matches() || s.equals("interval")) {
       return null;

http://git-wip-us.apache.org/repos/asf/spark/blob/9716a727/unsafe/src/test/java/org/apache/spark/unsafe/types/IntervalSuite.java
----------------------------------------------------------------------
diff --git a/unsafe/src/test/java/org/apache/spark/unsafe/types/IntervalSuite.java b/unsafe/src/test/java/org/apache/spark/unsafe/types/IntervalSuite.java
index 44a949a..1832d0b 100644
--- a/unsafe/src/test/java/org/apache/spark/unsafe/types/IntervalSuite.java
+++ b/unsafe/src/test/java/org/apache/spark/unsafe/types/IntervalSuite.java
@@ -75,6 +75,12 @@ public class IntervalSuite {
     Interval result = new Interval(-5 * 12 + 23, 0);
     assertEquals(Interval.fromString(input), result);
 
+    input = "interval   -5  years  23   month   ";
+    assertEquals(Interval.fromString(input), result);
+
+    input = "  interval   -5  years  23   month   ";
+    assertEquals(Interval.fromString(input), result);
+
     // Error cases
     input = "interval   3month 1 hour";
     assertEquals(Interval.fromString(input), null);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org