Skip to content

Commit 2e5a428

Browse files
authored
[fix](nereids) Interval.equals() should consider timeUnit (#59316)
1 parent 016e2db commit 2e5a428

File tree

2 files changed

+37
-0
lines changed
  • fe/fe-core/src
    • main/java/org/apache/doris/nereids/trees/expressions/literal
    • test/java/org/apache/doris/nereids/trees/expressions/literal

2 files changed

+37
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/Interval.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public String toDigest() {
7979
return sb.toString();
8080
}
8181

82+
@Override
83+
protected boolean extraEquals(Expression that) {
84+
return that instanceof Interval && this.timeUnit().equals(((Interval) that).timeUnit());
85+
}
86+
8287
/**
8388
* Supported time unit.
8489
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.doris.nereids.trees.expressions.literal;
19+
20+
import org.apache.doris.nereids.trees.expressions.literal.Interval.TimeUnit;
21+
22+
import org.junit.jupiter.api.Assertions;
23+
import org.junit.jupiter.api.Test;
24+
25+
public class IntervalTest {
26+
@Test
27+
public void testIntervalEquals() {
28+
Interval i1 = new Interval(new IntegerLiteral(1), TimeUnit.DAY);
29+
Interval i2 = new Interval(new IntegerLiteral(1), TimeUnit.SECOND);
30+
Assertions.assertNotEquals(i1, i2);
31+
}
32+
}

0 commit comments

Comments
 (0)