From 4b489719ecddb8a7b096ef3c17fdcf9dd6b878ce Mon Sep 17 00:00:00 2001 From: Kent Yao Date: Tue, 10 Mar 2020 23:56:33 +0800 Subject: [PATCH] [SPARK-31111][SQL][Tests] Fix interval output issue in ExtractBenchmark --- .../benchmarks/ExtractBenchmark-results.txt | 208 +++++++++--------- .../benchmark/ExtractBenchmark.scala | 4 +- 2 files changed, 106 insertions(+), 106 deletions(-) diff --git a/sql/core/benchmarks/ExtractBenchmark-results.txt b/sql/core/benchmarks/ExtractBenchmark-results.txt index 317f107bd746c..95ed9a051b87a 100644 --- a/sql/core/benchmarks/ExtractBenchmark-results.txt +++ b/sql/core/benchmarks/ExtractBenchmark-results.txt @@ -1,119 +1,119 @@ -OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws -Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz +Java HotSpot(TM) 64-Bit Server VM 1.8.0_231-b11 on Mac OS X 10.15.3 +Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Invoke extract for timestamp: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative ------------------------------------------------------------------------------------------------------------------------ -cast to timestamp 409 457 45 24.5 40.9 1.0X -MILLENNIUM of timestamp 1240 1295 57 8.1 124.0 0.3X -CENTURY of timestamp 1186 1240 49 8.4 118.6 0.3X -DECADE of timestamp 1083 1104 20 9.2 108.3 0.4X -YEAR of timestamp 1061 1073 15 9.4 106.1 0.4X -ISOYEAR of timestamp 1198 1213 25 8.3 119.8 0.3X -QUARTER of timestamp 1304 1322 23 7.7 130.4 0.3X -MONTH of timestamp 1052 1067 19 9.5 105.2 0.4X -WEEK of timestamp 1534 1558 25 6.5 153.4 0.3X -DAY of timestamp 1038 1057 26 9.6 103.8 0.4X -DAYOFWEEK of timestamp 1226 1239 22 8.2 122.6 0.3X -DOW of timestamp 1212 1224 13 8.3 121.2 0.3X -ISODOW of timestamp 1148 1165 24 8.7 114.8 0.4X -DOY of timestamp 1066 1075 14 9.4 106.6 0.4X -HOUR of timestamp 358 362 6 27.9 35.8 1.1X -MINUTE of timestamp 364 369 4 27.4 36.4 1.1X -SECOND of timestamp 453 471 26 22.1 45.3 0.9X -MILLISECONDS of timestamp 497 500 2 20.1 49.7 0.8X -MICROSECONDS of timestamp 360 363 4 27.8 36.0 1.1X -EPOCH of timestamp 1100 1104 5 9.1 110.0 0.4X +cast to timestamp 200 224 28 50.0 20.0 1.0X +MILLENNIUM of timestamp 741 750 14 13.5 74.1 0.3X +CENTURY of timestamp 768 781 15 13.0 76.8 0.3X +DECADE of timestamp 671 680 7 14.9 67.1 0.3X +YEAR of timestamp 659 680 30 15.2 65.9 0.3X +ISOYEAR of timestamp 732 753 22 13.7 73.2 0.3X +QUARTER of timestamp 772 789 20 12.9 77.2 0.3X +MONTH of timestamp 643 673 47 15.6 64.3 0.3X +WEEK of timestamp 965 971 10 10.4 96.5 0.2X +DAY of timestamp 635 641 9 15.7 63.5 0.3X +DAYOFWEEK of timestamp 755 774 17 13.3 75.5 0.3X +DOW of timestamp 768 798 39 13.0 76.8 0.3X +ISODOW of timestamp 736 760 24 13.6 73.6 0.3X +DOY of timestamp 688 696 6 14.5 68.8 0.3X +HOUR of timestamp 490 498 7 20.4 49.0 0.4X +MINUTE of timestamp 484 497 13 20.7 48.4 0.4X +SECOND of timestamp 614 627 11 16.3 61.4 0.3X +MILLISECONDS of timestamp 610 631 24 16.4 61.0 0.3X +MICROSECONDS of timestamp 516 525 8 19.4 51.6 0.4X +EPOCH of timestamp 665 670 7 15.0 66.5 0.3X -OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws -Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz +Java HotSpot(TM) 64-Bit Server VM 1.8.0_231-b11 on Mac OS X 10.15.3 +Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Invoke date_part for timestamp: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative ------------------------------------------------------------------------------------------------------------------------ -cast to timestamp 315 317 2 31.8 31.5 1.0X -MILLENNIUM of timestamp 1155 1162 8 8.7 115.5 0.3X -CENTURY of timestamp 1146 1152 5 8.7 114.6 0.3X -DECADE of timestamp 1031 1043 11 9.7 103.1 0.3X -YEAR of timestamp 1033 1041 10 9.7 103.3 0.3X -ISOYEAR of timestamp 1274 1278 5 7.8 127.4 0.2X -QUARTER of timestamp 1326 1346 30 7.5 132.6 0.2X -MONTH of timestamp 1027 1031 7 9.7 102.7 0.3X -WEEK of timestamp 1529 1535 6 6.5 152.9 0.2X -DAY of timestamp 1024 1031 9 9.8 102.4 0.3X -DAYOFWEEK of timestamp 1197 1201 5 8.4 119.7 0.3X -DOW of timestamp 1201 1218 15 8.3 120.1 0.3X -ISODOW of timestamp 1143 1149 6 8.8 114.3 0.3X -DOY of timestamp 1074 1085 9 9.3 107.4 0.3X -HOUR of timestamp 354 354 0 28.3 35.4 0.9X -MINUTE of timestamp 358 361 5 27.9 35.8 0.9X -SECOND of timestamp 445 456 17 22.5 44.5 0.7X -MILLISECONDS of timestamp 504 514 12 19.8 50.4 0.6X -MICROSECONDS of timestamp 361 370 8 27.7 36.1 0.9X -EPOCH of timestamp 1111 1117 9 9.0 111.1 0.3X +cast to timestamp 171 177 5 58.4 17.1 1.0X +MILLENNIUM of timestamp 744 758 15 13.4 74.4 0.2X +CENTURY of timestamp 721 742 23 13.9 72.1 0.2X +DECADE of timestamp 650 657 6 15.4 65.0 0.3X +YEAR of timestamp 634 640 7 15.8 63.4 0.3X +ISOYEAR of timestamp 793 803 13 12.6 79.3 0.2X +QUARTER of timestamp 811 844 31 12.3 81.1 0.2X +MONTH of timestamp 642 652 13 15.6 64.2 0.3X +WEEK of timestamp 944 955 10 10.6 94.4 0.2X +DAY of timestamp 650 652 2 15.4 65.0 0.3X +DAYOFWEEK of timestamp 778 814 52 12.9 77.8 0.2X +DOW of timestamp 769 772 3 13.0 76.9 0.2X +ISODOW of timestamp 776 805 28 12.9 77.6 0.2X +DOY of timestamp 675 685 10 14.8 67.5 0.3X +HOUR of timestamp 552 573 22 18.1 55.2 0.3X +MINUTE of timestamp 486 496 9 20.6 48.6 0.4X +SECOND of timestamp 622 629 7 16.1 62.2 0.3X +MILLISECONDS of timestamp 685 720 35 14.6 68.5 0.2X +MICROSECONDS of timestamp 574 580 8 17.4 57.4 0.3X +EPOCH of timestamp 669 689 24 15.0 66.9 0.3X -OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws -Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz +Java HotSpot(TM) 64-Bit Server VM 1.8.0_231-b11 on Mac OS X 10.15.3 +Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Invoke extract for date: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative ------------------------------------------------------------------------------------------------------------------------ -cast to date 849 851 3 11.8 84.9 1.0X -MILLENNIUM of date 1129 1139 11 8.9 112.9 0.8X -CENTURY of date 1136 1143 7 8.8 113.6 0.7X -DECADE of date 1039 1043 5 9.6 103.9 0.8X -YEAR of date 1030 1037 10 9.7 103.0 0.8X -ISOYEAR of date 1269 1278 9 7.9 126.9 0.7X -QUARTER of date 1323 1330 6 7.6 132.3 0.6X -MONTH of date 1021 1023 2 9.8 102.1 0.8X -WEEK of date 1541 1549 8 6.5 154.1 0.6X -DAY of date 1021 1033 13 9.8 102.1 0.8X -DAYOFWEEK of date 1196 1209 11 8.4 119.6 0.7X -DOW of date 1214 1229 13 8.2 121.4 0.7X -ISODOW of date 1148 1153 7 8.7 114.8 0.7X -DOY of date 1073 1079 5 9.3 107.3 0.8X -HOUR of date 1311 1314 4 7.6 131.1 0.6X -MINUTE of date 1311 1311 1 7.6 131.1 0.6X -SECOND of date 1420 1434 13 7.0 142.0 0.6X -MILLISECONDS of date 1426 1442 14 7.0 142.6 0.6X -MICROSECONDS of date 1312 1318 6 7.6 131.2 0.6X -EPOCH of date 2034 2050 16 4.9 203.4 0.4X +cast to date 551 555 5 18.1 55.1 1.0X +MILLENNIUM of date 720 731 9 13.9 72.0 0.8X +CENTURY of date 724 735 11 13.8 72.4 0.8X +DECADE of date 666 725 55 15.0 66.6 0.8X +YEAR of date 628 648 20 15.9 62.8 0.9X +ISOYEAR of date 780 823 52 12.8 78.0 0.7X +QUARTER of date 819 828 10 12.2 81.9 0.7X +MONTH of date 653 714 56 15.3 65.3 0.8X +WEEK of date 930 942 10 10.8 93.0 0.6X +DAY of date 632 642 11 15.8 63.2 0.9X +DAYOFWEEK of date 746 760 20 13.4 74.6 0.7X +DOW of date 778 781 3 12.9 77.8 0.7X +ISODOW of date 748 761 12 13.4 74.8 0.7X +DOY of date 674 684 10 14.8 67.4 0.8X +HOUR of date 1312 1329 17 7.6 131.2 0.4X +MINUTE of date 1288 1308 29 7.8 128.8 0.4X +SECOND of date 1438 1451 14 7.0 143.8 0.4X +MILLISECONDS of date 1440 1444 6 6.9 144.0 0.4X +MICROSECONDS of date 1353 1371 27 7.4 135.3 0.4X +EPOCH of date 1495 1541 51 6.7 149.5 0.4X -OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws -Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz +Java HotSpot(TM) 64-Bit Server VM 1.8.0_231-b11 on Mac OS X 10.15.3 +Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Invoke date_part for date: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative ------------------------------------------------------------------------------------------------------------------------ -cast to date 852 879 42 11.7 85.2 1.0X -MILLENNIUM of date 1131 1136 7 8.8 113.1 0.8X -CENTURY of date 1138 1145 6 8.8 113.8 0.7X -DECADE of date 1030 1043 13 9.7 103.0 0.8X -YEAR of date 1022 1028 8 9.8 102.2 0.8X -ISOYEAR of date 1260 1265 6 7.9 126.0 0.7X -QUARTER of date 1326 1330 7 7.5 132.6 0.6X -MONTH of date 1014 1034 26 9.9 101.4 0.8X -WEEK of date 1523 1526 5 6.6 152.3 0.6X -DAY of date 1022 1023 2 9.8 102.2 0.8X -DAYOFWEEK of date 1197 1203 9 8.4 119.7 0.7X -DOW of date 1188 1198 16 8.4 118.8 0.7X -ISODOW of date 1143 1153 9 8.8 114.3 0.7X -DOY of date 1052 1058 7 9.5 105.2 0.8X -HOUR of date 1309 1311 4 7.6 130.9 0.7X -MINUTE of date 1302 1305 6 7.7 130.2 0.7X -SECOND of date 1414 1432 16 7.1 141.4 0.6X -MILLISECONDS of date 1441 1450 11 6.9 144.1 0.6X -MICROSECONDS of date 1292 1301 8 7.7 129.2 0.7X -EPOCH of date 2030 2036 8 4.9 203.0 0.4X +cast to date 553 559 9 18.1 55.3 1.0X +MILLENNIUM of date 735 752 18 13.6 73.5 0.8X +CENTURY of date 719 726 12 13.9 71.9 0.8X +DECADE of date 667 676 9 15.0 66.7 0.8X +YEAR of date 628 650 20 15.9 62.8 0.9X +ISOYEAR of date 815 815 1 12.3 81.5 0.7X +QUARTER of date 801 822 22 12.5 80.1 0.7X +MONTH of date 641 652 10 15.6 64.1 0.9X +WEEK of date 939 956 17 10.6 93.9 0.6X +DAY of date 630 661 44 15.9 63.0 0.9X +DAYOFWEEK of date 770 780 10 13.0 77.0 0.7X +DOW of date 763 792 38 13.1 76.3 0.7X +ISODOW of date 785 807 24 12.7 78.5 0.7X +DOY of date 681 694 14 14.7 68.1 0.8X +HOUR of date 1359 1417 53 7.4 135.9 0.4X +MINUTE of date 1338 1342 4 7.5 133.8 0.4X +SECOND of date 1483 1498 20 6.7 148.3 0.4X +MILLISECONDS of date 1473 1503 28 6.8 147.3 0.4X +MICROSECONDS of date 1379 1393 22 7.3 137.9 0.4X +EPOCH of date 1510 1546 60 6.6 151.0 0.4X -OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws -Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz +Java HotSpot(TM) 64-Bit Server VM 1.8.0_231-b11 on Mac OS X 10.15.3 +Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Invoke date_part for interval: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative ------------------------------------------------------------------------------------------------------------------------ -cast to interval 1249 1254 6 8.0 124.9 1.0X -MILLENNIUM of interval 1310 1316 9 7.6 131.0 1.0X -CENTURY of interval 1304 1315 10 7.7 130.4 1.0X -DECADE of interval 1306 1313 7 7.7 130.6 1.0X -YEAR of interval 1304 1313 11 7.7 130.4 1.0X -QUARTER of interval 1310 1317 7 7.6 131.0 1.0X -MONTH of interval 1311 1319 12 7.6 131.1 1.0X -DAY of interval 1295 1304 13 7.7 129.5 1.0X -HOUR of interval 1301 1306 8 7.7 130.1 1.0X -MINUTE of interval 1316 1319 3 7.6 131.6 0.9X -SECOND of interval 1437 1440 3 7.0 143.7 0.9X -MILLISECONDS of interval 1435 1449 16 7.0 143.5 0.9X -MICROSECONDS of interval 1304 1314 9 7.7 130.4 1.0X -EPOCH of interval 1440 1453 19 6.9 144.0 0.9X +cast to interval 3984 4034 79 2.5 398.4 1.0X +MILLENNIUM of interval 4764 4817 75 2.1 476.4 0.8X +CENTURY of interval 4844 4857 23 2.1 484.4 0.8X +DECADE of interval 4745 4785 46 2.1 474.5 0.8X +YEAR of interval 4741 4744 2 2.1 474.1 0.8X +QUARTER of interval 4691 4708 15 2.1 469.1 0.8X +MONTH of interval 4707 4746 36 2.1 470.7 0.8X +DAY of interval 4715 4889 249 2.1 471.5 0.8X +HOUR of interval 5237 5323 83 1.9 523.7 0.8X +MINUTE of interval 5146 5376 222 1.9 514.6 0.8X +SECOND of interval 5196 5345 229 1.9 519.6 0.8X +MILLISECONDS of interval 5567 5725 242 1.8 556.7 0.7X +MICROSECONDS of interval 5097 5119 21 2.0 509.7 0.8X +EPOCH of interval 5222 5379 172 1.9 522.2 0.8X diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ExtractBenchmark.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ExtractBenchmark.scala index de23132284dc8..4150200f0b0e2 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ExtractBenchmark.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ExtractBenchmark.scala @@ -59,8 +59,8 @@ object ExtractBenchmark extends SqlBasedBenchmark { private def castExpr(from: String): String = from match { case "timestamp" => "cast(id as timestamp)" case "date" => "cast(cast(id as timestamp) as date)" - case "interval" => "(cast(cast(id as timestamp) as date) - date'0001-01-01') + " + - "(cast(id as timestamp) - timestamp'1000-01-01 01:02:03.123456')" + case "interval" => "cast((cast(cast(id as timestamp) as date) - date'0001-01-01') + " + + "(cast(id as timestamp) - timestamp'1000-01-01 01:02:03.123456') as string)" case other => throw new IllegalArgumentException( s"Unsupported column type $other. Valid column types are 'timestamp' and 'date'") }