You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/09/08 10:38:53 UTC
[GitHub] [doris] 924060929 opened a new pull request, #12481: (feature)(Nereids) Support function registry
924060929 opened a new pull request, #12481:
URL: https://github.com/apache/doris/pull/12481
# Proposed changes
Support function registry.
The classes:
- FunctionRegistry: used to register scalar functions and aggregate functions
- FunctionBuilder: used to resolve a BoundFunction, extract the constructor, and build to a BoundFunction by arguments(`List<Expression>`)
Register example:
```java
public class FunctionRegistry {
public static final List<ScalarFunc> SCALAR_FUNCTIONS = ImmutableList.of(
scalar(Substring.class, "substr", "substring"),
scalar(WeekOfYear.class),
scalar(Year.class)
);
public static final ImmutableList<AggregateFunc> AGGREGATE_FUNCTIONS = ImmutableList.of(
agg(Avg.class),
agg(Count.class),
agg(Max.class),
agg(Min.class),
agg(Sum.class)
);
}
```
Note:
- Currently, we only support register scalar functions add aggregate functions, we will support register table functions.
- Currently, we only support resolve function by function name and difference arity, but can not resolve the same arity override function, e.g. `some_function(Expression)` and `some_function(Literal)`
## Checklist(Required)
1. Does it affect the original behavior:
- [ ] Yes
- [x] No
- [ ] I don't know
2. Has unit tests been added:
- [x] Yes
- [ ] No
- [ ] No Need
3. Has document been added or modified:
- [ ] Yes
- [ ] No
- [x] No Need
4. Does it need to update dependencies:
- [ ] Yes
- [x] No
5. Are there any changes that cannot be rolled back:
- [ ] Yes (If Yes, please explain WHY)
- [x] No
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] morrySnow merged pull request #12481: [feature](Nereids) Support function registry
Posted by GitBox <gi...@apache.org>.
morrySnow merged PR #12481:
URL: https://github.com/apache/doris/pull/12481
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] 924060929 commented on a diff in pull request #12481: (feature)(Nereids) Support function registry
Posted by GitBox <gi...@apache.org>.
924060929 commented on code in PR #12481:
URL: https://github.com/apache/doris/pull/12481#discussion_r965963869
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java:
##########
@@ -0,0 +1,176 @@
+// 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.catalog;
+
+import org.apache.doris.nereids.annotation.Developing;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AggregateFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Avg;
+import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Count;
+import org.apache.doris.nereids.trees.expressions.functions.FunctionBuilder;
+import org.apache.doris.nereids.trees.expressions.functions.Max;
+import org.apache.doris.nereids.trees.expressions.functions.Min;
+import org.apache.doris.nereids.trees.expressions.functions.ScalarFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Substring;
+import org.apache.doris.nereids.trees.expressions.functions.Sum;
+import org.apache.doris.nereids.trees.expressions.functions.WeekOfYear;
+import org.apache.doris.nereids.trees.expressions.functions.Year;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import javax.annotation.concurrent.ThreadSafe;
+
+/**
+ * New function registry for nereids.
+ *
+ * this class is developing for more functions.
+ */
+@Developing
+@ThreadSafe
+public class FunctionRegistry {
+ public static final List<ScalarFunc> SCALAR_FUNCTIONS = ImmutableList.of(
+ scalar(Substring.class, "substr", "substring"),
+ scalar(WeekOfYear.class),
+ scalar(Year.class)
+ );
+
+ public static final ImmutableList<AggregateFunc> AGGREGATE_FUNCTIONS = ImmutableList.of(
+ agg(Avg.class),
+ agg(Count.class),
+ agg(Max.class),
+ agg(Min.class),
+ agg(Sum.class)
+ );
Review Comment:
The function in the lists is always builtin function, add a builtin function means add the function in this lists.
So what specify is the `BuiltinFunctions`?
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] wangshuo128 commented on a diff in pull request #12481: (feature)(Nereids) Support function registry
Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #12481:
URL: https://github.com/apache/doris/pull/12481#discussion_r965867603
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java:
##########
@@ -0,0 +1,176 @@
+// 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.catalog;
+
+import org.apache.doris.nereids.annotation.Developing;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AggregateFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Avg;
+import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Count;
+import org.apache.doris.nereids.trees.expressions.functions.FunctionBuilder;
+import org.apache.doris.nereids.trees.expressions.functions.Max;
+import org.apache.doris.nereids.trees.expressions.functions.Min;
+import org.apache.doris.nereids.trees.expressions.functions.ScalarFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Substring;
+import org.apache.doris.nereids.trees.expressions.functions.Sum;
+import org.apache.doris.nereids.trees.expressions.functions.WeekOfYear;
+import org.apache.doris.nereids.trees.expressions.functions.Year;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import javax.annotation.concurrent.ThreadSafe;
+
+/**
+ * New function registry for nereids.
+ *
+ * this class is developing for more functions.
+ */
+@Developing
+@ThreadSafe
+public class FunctionRegistry {
+ public static final List<ScalarFunc> SCALAR_FUNCTIONS = ImmutableList.of(
+ scalar(Substring.class, "substr", "substring"),
+ scalar(WeekOfYear.class),
+ scalar(Year.class)
+ );
+
+ public static final ImmutableList<AggregateFunc> AGGREGATE_FUNCTIONS = ImmutableList.of(
+ agg(Avg.class),
+ agg(Count.class),
+ agg(Max.class),
+ agg(Min.class),
+ agg(Sum.class)
+ );
Review Comment:
We'd better have a dedicated class to hold these functions to let developers add functions easily, such as `BuiltinFuncions.`
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] 924060929 commented on a diff in pull request #12481: (feature)(Nereids) Support function registry
Posted by GitBox <gi...@apache.org>.
924060929 commented on code in PR #12481:
URL: https://github.com/apache/doris/pull/12481#discussion_r965963869
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java:
##########
@@ -0,0 +1,176 @@
+// 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.catalog;
+
+import org.apache.doris.nereids.annotation.Developing;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AggregateFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Avg;
+import org.apache.doris.nereids.trees.expressions.functions.BoundFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Count;
+import org.apache.doris.nereids.trees.expressions.functions.FunctionBuilder;
+import org.apache.doris.nereids.trees.expressions.functions.Max;
+import org.apache.doris.nereids.trees.expressions.functions.Min;
+import org.apache.doris.nereids.trees.expressions.functions.ScalarFunction;
+import org.apache.doris.nereids.trees.expressions.functions.Substring;
+import org.apache.doris.nereids.trees.expressions.functions.Sum;
+import org.apache.doris.nereids.trees.expressions.functions.WeekOfYear;
+import org.apache.doris.nereids.trees.expressions.functions.Year;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import javax.annotation.concurrent.ThreadSafe;
+
+/**
+ * New function registry for nereids.
+ *
+ * this class is developing for more functions.
+ */
+@Developing
+@ThreadSafe
+public class FunctionRegistry {
+ public static final List<ScalarFunc> SCALAR_FUNCTIONS = ImmutableList.of(
+ scalar(Substring.class, "substr", "substring"),
+ scalar(WeekOfYear.class),
+ scalar(Year.class)
+ );
+
+ public static final ImmutableList<AggregateFunc> AGGREGATE_FUNCTIONS = ImmutableList.of(
+ agg(Avg.class),
+ agg(Count.class),
+ agg(Max.class),
+ agg(Min.class),
+ agg(Sum.class)
+ );
Review Comment:
The function in the lists is always builtin function, add a builtin function means add the function in this lists.
So What is special about `BuiltinFunctions`?
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org