[Fix](Create View) support create view from tvf (#18087)
Support create view as select * from tvf()
This commit is contained in:
@ -24,6 +24,7 @@ import org.apache.doris.planner.ScanNode;
|
||||
import org.apache.doris.tablefunction.TableValuedFunctionIf;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TableValuedFunctionRef extends TableRef {
|
||||
|
||||
@ -64,6 +65,29 @@ public class TableValuedFunctionRef extends TableRef {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String tableNameToSql() {
|
||||
String aliasSql = null;
|
||||
String alias = getExplicitAlias();
|
||||
if (alias != null) {
|
||||
aliasSql = ToSqlUtils.getIdentSql(alias);
|
||||
}
|
||||
|
||||
// set tableName
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(funcName);
|
||||
stringBuilder.append('(');
|
||||
String paramsString = params.entrySet().stream().map(kv -> "\"" + kv.getKey() + "\""
|
||||
+ " = " + "\"" + kv.getValue() + "\"")
|
||||
.collect(Collectors.joining(","));
|
||||
stringBuilder.append(paramsString);
|
||||
stringBuilder.append(')');
|
||||
|
||||
// set alias
|
||||
stringBuilder.append((aliasSql != null) ? " " + aliasSql : "");
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this table ref and then analyze the Join clause.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user