-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enhance](nereids) date_add, date_sub, date_diff, date_floor, date_ce…
…il function implement Monotonic (#44943) date_add, date_sub, date_diff, date_floor, date_ceil function implement Monotonic, so we can do prune range partition for this functions, for example `date_add(dt, 1) = '2024-01-01'`
- Loading branch information
1 parent
0ab4eae
commit f6071a3
Showing
46 changed files
with
1,019 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...c/main/java/org/apache/doris/nereids/trees/expressions/functions/DateAddSubMonotonic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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. | ||
|
||
package org.apache.doris.nereids.trees.expressions.functions; | ||
|
||
import org.apache.doris.nereids.trees.expressions.literal.Literal; | ||
|
||
/** monotonicity for XX_ADD XX_SUB */ | ||
public interface DateAddSubMonotonic extends Monotonic { | ||
@Override | ||
default boolean isMonotonic(Literal lower, Literal upper) { | ||
return child(1) instanceof Literal; | ||
} | ||
|
||
@Override | ||
default boolean isPositive() { | ||
return true; | ||
} | ||
|
||
@Override | ||
default int getMonotonicFunctionChildIndex() { | ||
return 0; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ain/java/org/apache/doris/nereids/trees/expressions/functions/DateCeilFloorMonotonic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
package org.apache.doris.nereids.trees.expressions.functions; | ||
|
||
import org.apache.doris.nereids.trees.expressions.literal.Literal; | ||
|
||
/** monotonicity of XX_CEIL and XX_FLOOR */ | ||
public interface DateCeilFloorMonotonic extends Monotonic { | ||
@Override | ||
default boolean isMonotonic(Literal lower, Literal upper) { | ||
switch (arity()) { | ||
case 1: | ||
return true; | ||
case 2: | ||
return !(child(0) instanceof Literal) && child(1) instanceof Literal; | ||
case 3: | ||
return !(child(0) instanceof Literal) && child(1) instanceof Literal && child(2) instanceof Literal; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
default boolean isPositive() { | ||
return true; | ||
} | ||
|
||
@Override | ||
default int getMonotonicFunctionChildIndex() { | ||
return 0; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...src/main/java/org/apache/doris/nereids/trees/expressions/functions/DateDiffMonotonic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// 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. | ||
|
||
package org.apache.doris.nereids.trees.expressions.functions; | ||
|
||
import org.apache.doris.nereids.trees.expressions.literal.Literal; | ||
|
||
/** monotonicity for XX_DIFF */ | ||
public interface DateDiffMonotonic extends Monotonic { | ||
@Override | ||
default boolean isMonotonic(Literal lower, Literal upper) { | ||
return !(child(0) instanceof Literal) && child(1) instanceof Literal | ||
|| child(0) instanceof Literal && !(child(1) instanceof Literal); | ||
} | ||
|
||
@Override | ||
default boolean isPositive() { | ||
return child(1) instanceof Literal; | ||
} | ||
|
||
@Override | ||
default int getMonotonicFunctionChildIndex() { | ||
return child(1) instanceof Literal ? 0 : 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.