Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 3 commits into from

Conversation

viirya
Copy link
Member

@viirya viirya commented Jul 14, 2015

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

@@ -43,12 +43,13 @@
* Finally is the unit name, ends with an optional "s".
*/
private static String unitRegex(String unit) {
return "(?:\\s+(-?\\d+)\\s+" + unit + "s?)?";
return "(?:\\s+(-?\\d+)\\s+" + unit + "s?\\s*)?";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort-of related question -- why is this class in 'unsafe', and why not use Joda time? the JDK already has a rich set of abstractions for time. It seems like it's only used in catalyst.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is the internal representation of interval type, written in Java for better performance, just like what we did for UTF8String, that's why it's in 'unsafe'.
Currently our date and timestamp internal representation is int and long, which is more efficient than Joda time I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan maybe I'm blind but how does this use Unsafe? I don't see how it benefits.
java.time.Duration is an int + long too. Is this really needed? at least, why in unsafe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srowen don't hang up on the package name for now. It's just a place to put all the data types implemented in Java. We will most likely rename the package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible thing that could happen with unsafe for interval is to support reading directly from a memory address rather than materializing it as a long + an int.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rxin I'm not worried about the package so much as the module; this doesn't have to do with bit-twiddling via Unsafe. Is there really a win for managing 96 bits via Unsafe?

It doesn't seem like the right place for this type; it's only used by catalyst (now) I think, so could live there or at least core. But more than that, the JDK itself has a standard class for this -- around which you could build utility functions. I understand this is in flux but I suppose I'm not seeing why it landed here and wondering if it's better to move it early.

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37207 has finished for PR 7390 at commit 57861f7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

instead of changing the regex, can we just call trim before pass the string to Interval.fromString?

@viirya
Copy link
Member Author

viirya commented Jul 14, 2015

Ok. Update later.

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37228 has finished for PR 7390 at commit 9eb6831.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Jul 14, 2015

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37258 has finished for PR 7390 at commit 9eb6831.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Jul 15, 2015

Thanks - I've merged this.

@asfgit asfgit closed this in 9716a72 Jul 15, 2015
@viirya viirya deleted the fix_interval_string branch December 27, 2023 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants