morningman commented on a change in pull request #7940: URL: https://github.com/apache/incubator-doris/pull/7940#discussion_r800158250
########## File path: fe/fe-core/src/main/java/org/apache/doris/tablefunction/TableFunction.java ########## @@ -0,0 +1,50 @@ +// 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.tablefunction; + +import org.apache.doris.analysis.TupleDescriptor; +import org.apache.doris.catalog.Column; +import org.apache.doris.catalog.Table; +import org.apache.doris.catalog.Table.TableType; +import org.apache.doris.common.UserException; +import org.apache.doris.planner.PlanNodeId; +import org.apache.doris.planner.ScanNode; + +import java.util.List; + +public abstract class TableFunction { Review comment: I think we should use another name for this class. Because it is not a real table function. It more likes a kind of "scan node" or some "source node". For a "table function", it should support common expr as its parameter, such as referring a column from a table, or an Expression. ########## File path: fe/fe-core/src/main/java/org/apache/doris/tablefunction/TableFunction.java ########## @@ -0,0 +1,50 @@ +// 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.tablefunction; + +import org.apache.doris.analysis.TupleDescriptor; +import org.apache.doris.catalog.Column; +import org.apache.doris.catalog.Table; +import org.apache.doris.catalog.Table.TableType; +import org.apache.doris.common.UserException; +import org.apache.doris.planner.PlanNodeId; +import org.apache.doris.planner.ScanNode; + +import java.util.List; + +public abstract class TableFunction { + + public abstract String getTableName(); + + public abstract List<Column> getTableColumns(); + + public abstract ScanNode getScanNode(PlanNodeId id, TupleDescriptor desc); + + public Table getTable() { + Table table = new Table(-1, getTableName(), TableType.TABLE_FUNCTION, getTableColumns()); + return table; + } + + // All table functions should be registered here + public static TableFunction getTableFunction(String funcName, List<String> params) throws UserException { + if (funcName.equalsIgnoreCase(TableFunctionNumbers.NAME)) { + return new TableFunctionNumbers(params); + } + throw new UserException("Could not find table function " + funcName); + } Review comment: tab to space. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
