spark-instrumented-optimizer/sql/core/benchmarks/IntervalBenchmark-results.txt
Kent Yao d06a9cc4bd [SPARK-29822][SQL] Fix cast error when there are white spaces between signs and values
### What changes were proposed in this pull request?

With the latest string to literal optimization https://github.com/apache/spark/pull/26256, some interval strings can not be cast when there are some spaces between signs and unit values. After state `PARSE_SIGN`, it directly goes to  `PARSE_UNIT_VALUE` when takes a space character as the end. So when there are some white spaces come before the real unit value, it fails to parse, we should add a new state like `TRIM_VALUE` to trim all these spaces.

How to re-produce, which aim the revisions since  https://github.com/apache/spark/pull/26256 is merged

```sql
select cast(v as interval) from values ('+     1 second') t(v);
select cast(v as interval) from values ('-     1 second') t(v);
```

### Why are the changes needed?

bug fix
### Does this PR introduce any user-facing change?

no
### How was this patch tested?

1. ut
2. new benchmark test

Closes #26449 from yaooqinn/SPARK-29605.

Authored-by: Kent Yao <yaooqinn@hotmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
2019-11-11 21:53:33 +08:00

30 lines
3.2 KiB
Plaintext

Java HotSpot(TM) 64-Bit Server VM 1.8.0_231-b11 on Mac OS X 10.14.6
Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
cast strings to intervals: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
prepare string w/ interval 531 566 34 1.9 530.5 1.0X
prepare string w/o interval 466 479 21 2.1 466.5 1.1X
1 units w/ interval 475 521 63 2.1 475.0 1.1X
1 units w/o interval 440 457 25 2.3 440.1 1.2X
2 units w/ interval 614 621 11 1.6 613.7 0.9X
2 units w/o interval 596 605 8 1.7 596.5 0.9X
3 units w/ interval 1115 1120 4 0.9 1115.0 0.5X
3 units w/o interval 1100 1107 6 0.9 1100.2 0.5X
4 units w/ interval 1255 1263 9 0.8 1255.1 0.4X
4 units w/o interval 1254 1393 130 0.8 1253.8 0.4X
5 units w/ interval 1367 1373 5 0.7 1367.2 0.4X
5 units w/o interval 1366 1376 9 0.7 1366.2 0.4X
6 units w/ interval 1526 1530 6 0.7 1526.0 0.3X
6 units w/o interval 1504 1510 7 0.7 1504.0 0.4X
7 units w/ interval 1748 1778 27 0.6 1748.0 0.3X
7 units w/o interval 1740 1744 5 0.6 1740.0 0.3X
8 units w/ interval 2092 2107 14 0.5 2092.5 0.3X
8 units w/o interval 2094 2098 5 0.5 2094.4 0.3X
9 units w/ interval 1874 1880 5 0.5 1873.9 0.3X
9 units w/o interval 1867 1872 4 0.5 1867.3 0.3X
10 units w/ interval 2127 2134 13 0.5 2126.5 0.2X
10 units w/o interval 2045 2049 6 0.5 2045.0 0.3X
11 units w/ interval 2242 2254 13 0.4 2241.9 0.2X
11 units w/o interval 2221 2227 6 0.5 2221.1 0.2X