Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,8 @@ object QueryPlanSerde extends Logging with CometExprShim with CometTypeShim {
_: DoubleType | _: DecimalType | _: DateType | _: TimestampType | _: TimestampNTZType |
_: BooleanType | _: BinaryType | _: StringType =>
true
case dt if isTimeType(dt) =>
true
case _ =>
false
}
Expand Down
5 changes: 3 additions & 2 deletions spark/src/main/scala/org/apache/comet/serde/aggregates.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.apache.comet.CometConf.COMET_EXEC_STRICT_FLOATING_POINT
import org.apache.comet.CometSparkSessionExtensions.{isSpark41Plus, withFallbackReason}
import org.apache.comet.expressions.CometEvalMode
import org.apache.comet.serde.QueryPlanSerde.{evalModeToProto, exprToProto, serializeDataType}
import org.apache.comet.shims.CometEvalModeUtil
import org.apache.comet.shims.{CometEvalModeUtil, CometTypeShim}

object CometMin extends CometAggregateExpressionSerde[Min] {

Expand Down Expand Up @@ -897,7 +897,7 @@ object CometCollectSet extends CometAggregateExpressionSerde[CollectSet] {
}
}

object AggSerde {
object AggSerde extends CometTypeShim {
import org.apache.spark.sql.types._

def minMaxDataTypeSupported(dt: DataType): Boolean = {
Expand All @@ -907,6 +907,7 @@ object AggSerde {
case FloatType | DoubleType => true
case _: DecimalType => true
case DateType | TimestampType => true
case dt if isTimeType(dt) => true
case _ => false
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.

-- MinSparkVersion: 4.1
-- Config: spark.sql.timeType.enabled=true

statement
CREATE TABLE test_make_time_min_max(grp string, hours int, minutes int, secs decimal(16,6)) USING parquet

statement
INSERT INTO test_make_time_min_max VALUES
('a', 12, 30, 45.123456),
('a', 0, 0, 0.000000),
('a', NULL, NULL, NULL),
('b', 23, 59, 59.999999),
('b', 1, 2, 3.500000),
('c', NULL, 0, 0.000000),
('c', 12, NULL, 0.000000),
('c', 12, 30, NULL)

query
SELECT
min(make_time(hours, minutes, secs)) AS min_time,
max(make_time(hours, minutes, secs)) AS max_time
FROM test_make_time_min_max

query
SELECT
grp,
min(make_time(hours, minutes, secs)) AS min_time,
max(make_time(hours, minutes, secs)) AS max_time
FROM test_make_time_min_max
GROUP BY grp
ORDER BY grp

query
SELECT
min(make_time(hours, minutes, secs)) AS min_time,
max(make_time(hours, minutes, secs)) AS max_time
FROM test_make_time_min_max
WHERE grp = 'c'
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.

-- MinSparkVersion: 4.1
-- Config: spark.sql.timeType.enabled=true

statement
CREATE TABLE test_make_time_sort(id int, hours int, minutes int, secs decimal(16,6)) USING parquet

statement
INSERT INTO test_make_time_sort VALUES
(1, 12, 30, 45.123456),
(2, 0, 0, 0.000000),
(3, 23, 59, 59.999999),
(4, 1, 2, 3.500000),
(5, 0, 0, 0.000001),
(6, NULL, NULL, NULL)

query
SELECT id, t
FROM (
SELECT id, make_time(hours, minutes, secs) AS t
FROM test_make_time_sort
)
SORT BY t ASC NULLS FIRST

query
SELECT id, t
FROM (
SELECT id, make_time(hours, minutes, secs) AS t
FROM test_make_time_sort
)
SORT BY t DESC NULLS LAST