MaxGekk commented on code in PR #50558:
URL: https://github.com/apache/spark/pull/50558#discussion_r2042301330


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala:
##########
@@ -650,6 +650,7 @@ object FunctionRegistry {
     expression[Now]("now"),
     expression[Quarter]("quarter"),
     expressionBuilder("second", SecondExpressionBuilder),
+    expression[SecondsOfTimeWithFraction]("secondoftime_with_fraction"),

Review Comment:
   Please, don't expose the expression with such name to the public API so far.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/timeExpressions.scala:
##########
@@ -297,6 +312,49 @@ object HourExpressionBuilder extends ExpressionBuilder {
   }
 }
 
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = """
+    _FUNC_(time_expr) - Returns the second component with fraction of the 
given time.
+  """,
+  examples = """
+    Examples:
+      > SELECT _FUNC_(TIME'23:59:59.999999');
+       59.999999
+  """,
+  since = "4.1.0",
+  group = "datetime_funcs")
+// scalastyle:on line.size.limit

Review Comment:
   Could you remove this since the expression should be exposed to users 
indirectly via `EXTRACT`.



##########
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala:
##########
@@ -4292,6 +4292,15 @@ class SQLQuerySuite extends QueryTest with 
SharedSparkSession with AdaptiveSpark
     }
   }
 
+  test("Extract time field from time should work in ANSI mode") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {

Review Comment:
   Does the behaviour of `EXTRACT` depend on the ANSI mode? Since we implement 
the new data type according to ANSI SQL standard, we shouldn't support non-ANSI 
mode.



##########
sql/core/src/test/resources/sql-tests/inputs/time.sql:
##########
@@ -18,3 +18,35 @@ select try_to_time('12:48:31 abc');
 select try_to_time('10:11:12.', 'HH:mm:ss.SSSSSS');
 select try_to_time("02-69", "HH-mm");
 select try_to_time('11:12:13', 'HH:mm:ss', 'SSSSSS');
+
+select secondoftime_with_fraction(to_time('23-59-59.987654', 
'HH-mm-ss.SSSSSS'));
+select second(to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+select minute(to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+select hour(to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+
+select extract(HOUR from  to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+select extract(H from  to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+select extract(HOURS from  to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+select extract(HR from  to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));
+select extract(HRS from  to_time('23-59-58.987654', 'HH-mm-ss.SSSSSS'));

Review Comment:
   As you are testing different `field` names, could you check different hours, 
for example:
   ```sql
   select extract(HOUR from  time'00:59:00.987654');
   select extract(H from  time'23:59:00.987654');
   ```
   especially check some corner cases like `00:00:00` and `23:59:59.999999`



##########
sql/core/src/test/resources/sql-functions/sql-expression-schema.md:
##########
@@ -288,6 +288,7 @@
 | org.apache.spark.sql.catalyst.expressions.SchemaOfXml | schema_of_xml | 
SELECT schema_of_xml('<p><a>1</a></p>') | 
struct<schema_of_xml(<p><a>1</a></p>):string> |
 | org.apache.spark.sql.catalyst.expressions.Sec | sec | SELECT sec(0) | 
struct<SEC(0):double> |
 | org.apache.spark.sql.catalyst.expressions.SecondExpressionBuilder | second | 
SELECT second('2018-02-14 12:58:59') | struct<second(2018-02-14 12:58:59):int> |
+| org.apache.spark.sql.catalyst.expressions.SecondsOfTimeWithFraction | 
secondoftime_with_fraction | SELECT 
secondoftime_with_fraction(TIME'23:59:59.999999') | 
struct<secondoftime_with_fraction(TIME '23:59:59.999999'):decimal(8,6)> |

Review Comment:
   This should disappear. Please, regenerate the file. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to