This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new bac2dfb3875 Support oracle custom table function parsing (#28323)
bac2dfb3875 is described below

commit bac2dfb38751b2a4c32926a8725ae2c02a39aaab
Author: ZhangCheng <[email protected]>
AuthorDate: Thu Aug 31 15:19:23 2023 +0800

    Support oracle custom table function parsing (#28323)
    
    * Support oracle custom table function parsing
    
    * Support oracle custom table function parsing
    
    * Support oracle custom table function parsing
    
    * Support oracle custom table function parsing
    
    * Support oracle custom table function parsing
    
    * Support oracle custom table function parsing
---
 .../src/main/antlr4/imports/oracle/BaseRule.g4     |  6 +--
 .../src/main/antlr4/imports/oracle/DMLStatement.g4 | 10 +----
 .../statement/type/OracleDMLStatementVisitor.java  | 32 +++++++-------
 ...TableSegment.java => FunctionTableSegment.java} | 24 ++++++-----
 .../asserts/segment/table/TableAssert.java         | 45 +++++++++++--------
 ...bleFunction.java => ExpectedTableFunction.java} |  4 +-
 ...tedXmlTable.java => ExpectedFunctionTable.java} | 13 +++---
 .../jaxb/segment/impl/table/ExpectedTable.java     |  4 +-
 .../parser/src/main/resources/case/dml/select.xml  | 50 ++++++++++++++++++++--
 .../main/resources/sql/supported/dml/select.xml    |  1 +
 10 files changed, 117 insertions(+), 72 deletions(-)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index fe8241a2d8b..be5bce3d07a 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -87,7 +87,7 @@ unreservedWord1
     : TRUNCATE | FUNCTION | PROCEDURE | CASE | WHEN | CAST | TRIM | SUBSTRING
     | NATURAL | JOIN | FULL | INNER | OUTER | LEFT | RIGHT
     | CROSS | USING | IF | TRUE | FALSE | LIMIT | OFFSET
-    | BEGIN | COMMIT | ROLLBACK | SAVEPOINT | BOOLEAN | DOUBLE | CHARACTER
+    | BEGIN | COMMIT | ROLLBACK | SAVEPOINT
     | ARRAY | INTERVAL | TIME | TIMESTAMP | LOCALTIME | LOCALTIMESTAMP | YEAR
     | QUARTER | MONTH | WEEK | DAY | HOUR | MINUTE | SECOND
     | MICROSECOND | MAX | MIN | SUM | COUNT | AVG | ENABLE
@@ -97,7 +97,7 @@ unreservedWord1
     | FLASHBACK | ARCHIVE | REFRESH | QUERY | REWRITE | KEEP | SEQUENCE
     | INHERIT | TRANSLATE | SQL | MERGE | AT | BITMAP | CACHE | CHECKPOINT
     | CONSTRAINTS | CYCLE | DBTIMEZONE | ENCRYPT | DECRYPT | DEFERRABLE
-    | DEFERRED | EDITION | ELEMENT | END | EXCEPTIONS | FORCE | GLOBAL
+    | DEFERRED | EDITION | ELEMENT | EXCEPTIONS | FORCE | GLOBAL
     | IDENTITY | INITIALLY | INVALIDATE | JAVA | LEVELS | LOCAL | MAXVALUE
     | MINVALUE | NOMAXVALUE | NOMINVALUE | MINING | MODEL | NATIONAL | NEW
     | NOCACHE | NOCYCLE | NOORDER | NORELY | NOVALIDATE | ONLY | PRESERVE
@@ -118,7 +118,7 @@ unreservedWord1
     | CONSTRAINT | PRIMARY | FOREIGN | KEY | POSITION | PRECISION | FUNCTION | 
PROCEDURE | SPECIFICATION | CASE
     | WHEN | CAST | TRIM | SUBSTRING | FULL | INNER | OUTER | LEFT | RIGHT | 
CROSS
     | USING | FALSE | SAVEPOINT | BODY | CHARACTER | ARRAY | TIME | TIMEOUT | 
TIMESTAMP | LOCALTIME
-    | DAY | ENABLE | DISABLE | CALL | INSTANCE | CLOSE | NEXT | NAME | INT | 
NUMERIC
+    | DAY | ENABLE | DISABLE | CALL | INSTANCE | CLOSE | NEXT | NAME | NUMERIC
     | TRIGGERS | GLOBAL_NAME | BINARY | MOD | XOR | UNKNOWN | ALWAYS | CASCADE 
| GENERATED | PRIVILEGES
     | READ | WRITE | ROLE | VISIBLE | INVISIBLE | EXECUTE | USE | DEBUG | 
UNDER | FLASHBACK
     | ARCHIVE | REFRESH | QUERY | REWRITE | CHECKPOINT | ENCRYPT | DIRECTORY | 
CREDENTIALS | EXCEPT | NOFORCE
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DMLStatement.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
index 2f230d27517..17342ab5f54 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
@@ -443,15 +443,7 @@ fromClauseOption
     | LP_ joinClause RP_
     | selectTableReference
     | inlineAnalyticView
-    | xmlTable
-    ;
-
-xmlTable
-    : xmlTableFunction xmlTableFunctionAlias?
-    ;
-
-xmlTableFunctionAlias
-    : alias
+    | (regularFunction | xmlTableFunction) alias?
     ;
 
 selectTableReference
diff --git 
a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
 
b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
index 331a9681580..681a7baadc6 100644
--- 
a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
+++ 
b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
@@ -102,7 +102,6 @@ import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.Update
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.UsingClauseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.WhereClauseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.WithClauseContext;
-import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.XmlTableContext;
 import 
org.apache.shardingsphere.sql.parser.oracle.visitor.statement.OracleStatementVisitor;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.JoinType;
 import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
@@ -157,11 +156,11 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.ModelSegm
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.CollectionTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.FunctionTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.JoinTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SubqueryTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.XmlTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
 import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtils;
@@ -849,23 +848,26 @@ public final class OracleDMLStatementVisitor extends 
OracleStatementVisitor impl
     
     @Override
     public ASTNode visitFromClauseOption(final FromClauseOptionContext ctx) {
-        if (null != ctx.xmlTable()) {
-            return visit(ctx.xmlTable());
-        }
         if (null != ctx.joinClause()) {
             return visit(ctx.joinClause());
         }
-        return visit(ctx.selectTableReference());
-    }
-    
-    @Override
-    public ASTNode visitXmlTable(final XmlTableContext ctx) {
-        XmlTableSegment result = new 
XmlTableSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(),
-                (XmlTableFunctionSegment) visit(ctx.xmlTableFunction()));
-        if (null != ctx.xmlTableFunctionAlias()) {
-            
result.setXmlTableFunctionAlias(ctx.xmlTableFunctionAlias().alias().getText());
+        if (null != ctx.regularFunction()) {
+            FunctionSegment functionSegment = (FunctionSegment) 
visit(ctx.regularFunction());
+            FunctionTableSegment result = new 
FunctionTableSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), 
functionSegment);
+            if (null != ctx.alias()) {
+                result.setAlias((AliasSegment) visit(ctx.alias()));
+            }
+            return result;
         }
-        return result;
+        if (null != ctx.xmlTableFunction()) {
+            XmlTableFunctionSegment functionSegment = 
(XmlTableFunctionSegment) visit(ctx.xmlTableFunction());
+            FunctionTableSegment result = new 
FunctionTableSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), 
functionSegment);
+            if (null != ctx.alias()) {
+                result.setAlias((AliasSegment) visit(ctx.alias()));
+            }
+            return result;
+        }
+        return visit(ctx.selectTableReference());
     }
     
     @Override
diff --git 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/XmlTableSegment.java
 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/FunctionTableSegment.java
similarity index 73%
rename from 
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/XmlTableSegment.java
rename to 
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/FunctionTableSegment.java
index 82a78abe280..4611decb5ab 100644
--- 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/XmlTableSegment.java
+++ 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/table/FunctionTableSegment.java
@@ -20,40 +20,44 @@ package 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import lombok.Setter;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.XmlTableFunctionSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.AliasSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 
 import java.util.Optional;
 
 /**
- * XML table segment.
+ * Function table segment.
  */
 @RequiredArgsConstructor
 @Getter
 @Setter
-public final class XmlTableSegment implements TableSegment {
+public final class FunctionTableSegment implements TableSegment {
     
     private final int startIndex;
     
     private final int stopIndex;
     
-    private final XmlTableFunctionSegment xmlTableFunction;
+    private final ExpressionSegment tableFunction;
     
     @Setter
-    private String xmlTableFunctionAlias;
+    private AliasSegment alias;
     
-    @Override
     public Optional<String> getAliasName() {
-        return Optional.empty();
+        return null == alias ? Optional.empty() : 
Optional.ofNullable(alias.getIdentifier().getValue());
     }
     
     @Override
     public Optional<IdentifierValue> getAlias() {
-        return Optional.empty();
+        return Optional.ofNullable(alias).map(AliasSegment::getIdentifier);
     }
     
-    @Override
-    public void setAlias(final AliasSegment alias) {
+    /**
+     * Get alias segment.
+     *
+     * @return alias segment
+     */
+    public Optional<AliasSegment> getAliasSegment() {
+        return Optional.ofNullable(alias);
     }
 }
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/table/TableAssert.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/table/TableAssert.java
index ca21f9b371c..9115fc2d68e 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/table/TableAssert.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/table/TableAssert.java
@@ -20,13 +20,15 @@ package 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.ta
 import com.google.common.base.Strings;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.FunctionSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.XmlTableFunctionSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.CollectionTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.FunctionTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.JoinTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SubqueryTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.XmlTableSegment;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQLSegmentAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.column.ColumnAssert;
@@ -35,13 +37,13 @@ import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.ide
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dml.impl.SelectStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.column.ExpectedColumn;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.expr.ExpectedXmlTableFunction;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.expr.ExpectedTableFunction;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedCollectionTable;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedJoinTable;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedSimpleTable;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedSubqueryTable;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedTable;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedXmlTable;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.table.ExpectedFunctionTable;
 
 import java.util.Collection;
 import java.util.List;
@@ -72,8 +74,8 @@ public final class TableAssert {
             assertIs(assertContext, (SimpleTableSegment) actual, 
expected.getSimpleTable());
         } else if (actual instanceof SubqueryTableSegment) {
             assertIs(assertContext, (SubqueryTableSegment) actual, 
expected.getSubqueryTable());
-        } else if (actual instanceof XmlTableSegment) {
-            assertIs(assertContext, (XmlTableSegment) actual, 
expected.getXmlTable());
+        } else if (actual instanceof FunctionTableSegment) {
+            assertIs(assertContext, (FunctionTableSegment) actual, 
expected.getFunctionTable());
         } else if (actual instanceof CollectionTableSegment) {
             assertIs(assertContext, (CollectionTableSegment) actual, 
expected.getCollectionTable());
         } else {
@@ -95,17 +97,15 @@ public final class TableAssert {
     }
     
     /**
-     * Assert actual xml table segment is correct with expected xml table.
+     * Assert actual function table segment is correct with expected table.
      *
      * @param assertContext assert context
-     * @param actual actual xml table
-     * @param expected expected xml table
+     * @param actual actual function table
+     * @param expected expected function table
      */
-    private static void assertIs(final SQLCaseAssertContext assertContext, 
final XmlTableSegment actual, final ExpectedXmlTable expected) {
-        assertXmlTableFunction(assertContext, actual.getXmlTableFunction(), 
expected.getXmlTableFunction());
-        if (null != actual.getXmlTableFunctionAlias()) {
-            assertThat(assertContext.getText("Xml table function alias 
assertion error"), actual.getXmlTableFunctionAlias(), 
is(expected.getXmlTableFunctionAlias()));
-        }
+    private static void assertIs(final SQLCaseAssertContext assertContext, 
final FunctionTableSegment actual, final ExpectedFunctionTable expected) {
+        assertTableFunction(assertContext, actual.getTableFunction(), 
expected.getTableFunction());
+        actual.getAliasName().ifPresent(optional -> 
assertThat(assertContext.getText("Table function alias assertion error"), 
optional, is(expected.getTableAlias())));
     }
     
     /**
@@ -200,14 +200,21 @@ public final class TableAssert {
     }
     
     /**
-     * Assert actual xml table function segment is correct with expected xml 
table function.
+     * Assert actual table function segment is correct with expected table 
function.
      *
      * @param assertContext assert context
-     * @param actual actual xml table function
-     * @param expected expected xml table function
+     * @param actual actual table function
+     * @param expected expected table function
      */
-    private static void assertXmlTableFunction(final SQLCaseAssertContext 
assertContext, final XmlTableFunctionSegment actual, final 
ExpectedXmlTableFunction expected) {
-        assertThat(assertContext.getText("Function name assertion error"), 
actual.getFunctionName(), is(expected.getFunctionName()));
-        assertThat(assertContext.getText("Function text assert error"), 
actual.getText(), is(expected.getText()));
+    private static void assertTableFunction(final SQLCaseAssertContext 
assertContext, final ExpressionSegment actual, final ExpectedTableFunction 
expected) {
+        if (actual instanceof XmlTableFunctionSegment) {
+            XmlTableFunctionSegment actualXmlTableFunction = 
(XmlTableFunctionSegment) actual;
+            assertThat(assertContext.getText("Function name assertion error"), 
actualXmlTableFunction.getFunctionName(), is(expected.getFunctionName()));
+            assertThat(assertContext.getText("Function text assert error"), 
actual.getText(), is(expected.getText()));
+        } else if (actual instanceof FunctionSegment) {
+            FunctionSegment actualTableFunction = (FunctionSegment) actual;
+            assertThat(assertContext.getText("Function name assertion error"), 
actualTableFunction.getFunctionName(), is(expected.getFunctionName()));
+            assertThat(assertContext.getText("Function text assert error"), 
actual.getText(), is(expected.getText()));
+        }
     }
 }
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/expr/ExpectedXmlTableFunction.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/expr/ExpectedTableFunction.java
similarity index 89%
rename from 
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/expr/ExpectedXmlTableFunction.java
rename to 
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/expr/ExpectedTableFunction.java
index 34340e0e683..e050331c87a 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/expr/ExpectedXmlTableFunction.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/expr/ExpectedTableFunction.java
@@ -24,11 +24,11 @@ import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
 import javax.xml.bind.annotation.XmlAttribute;
 
 /**
- * Expected xml table function.
+ * Expected table function.
  */
 @Getter
 @Setter
-public final class ExpectedXmlTableFunction extends AbstractExpectedSQLSegment 
implements ExpectedExpressionSegment {
+public final class ExpectedTableFunction extends AbstractExpectedSQLSegment 
implements ExpectedExpressionSegment {
     
     @XmlAttribute(name = "function-name")
     private String functionName;
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedXmlTable.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedFunctionTable.java
similarity index 79%
rename from 
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedXmlTable.java
rename to 
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedFunctionTable.java
index d23712e7f84..7c3fac4c24b 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedXmlTable.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedFunctionTable.java
@@ -20,17 +20,17 @@ package 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.AbstractExpectedDelimiterSQLSegment;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.expr.ExpectedXmlTableFunction;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.expr.ExpectedTableFunction;
 
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 
 /**
- * Expected xml table.
+ * Expected function table.
  */
 @Getter
 @Setter
-public final class ExpectedXmlTable extends 
AbstractExpectedDelimiterSQLSegment {
+public final class ExpectedFunctionTable extends 
AbstractExpectedDelimiterSQLSegment {
     
     @XmlAttribute(name = "table-name")
     private String tableName;
@@ -38,9 +38,6 @@ public final class ExpectedXmlTable extends 
AbstractExpectedDelimiterSQLSegment
     @XmlAttribute(name = "table-alias")
     private String tableAlias;
     
-    @XmlElement(name = "xml-table-function")
-    private ExpectedXmlTableFunction xmlTableFunction;
-    
-    @XmlAttribute(name = "xml-table-function-alias")
-    private String xmlTableFunctionAlias;
+    @XmlElement(name = "table-function")
+    private ExpectedTableFunction tableFunction;
 }
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedTable.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedTable.java
index e102dd9bdae..0917f3cfdee 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedTable.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/cases/parser/jaxb/segment/impl/table/ExpectedTable.java
@@ -39,8 +39,8 @@ public final class ExpectedTable extends 
AbstractExpectedDelimiterSQLSegment {
     @XmlElement(name = "join-table")
     private ExpectedJoinTable joinTable;
     
-    @XmlElement(name = "xml-table")
-    private ExpectedXmlTable xmlTable;
+    @XmlElement(name = "function-table")
+    private ExpectedFunctionTable functionTable;
     
     @XmlElement(name = "collection-table")
     private ExpectedCollectionTable collectionTable;
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml 
b/test/it/parser/src/main/resources/case/dml/select.xml
index 18e3d27ac04..93a2758e5d7 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -5702,7 +5702,7 @@
 
     <select sql-case-id="select_from_xmltable_function">
         <projections start-index="7" stop-index="65">
-            <column-projection name="warehouse_name" alias="warehouse" 
start-index="7" stop-index="30" />
+            <column-projection alias="warehouse" name="warehouse_name" 
start-index="7" stop-index="30" />
             <column-projection name="Water" start-index="33" stop-index="48">
                 <owner name="warehouse2" start-index="33" stop-index="42" />
             </column-projection>
@@ -5716,9 +5716,10 @@
                     <simple-table name="warehouses" start-index="72" 
stop-index="81" />
                 </left>
                 <right>
-                    <xml-table xml-table-function-alias="warehouse2" 
start-index="76" stop-index="238">
-                        <xml-table-function function-name="XMLTABLE" 
text="XMLTABLE('/Warehouse' PASSING warehouses.warehouse_spec COLUMNS 
&quot;Water&quot; varchar2(6) PATH 'WaterAccess',&quot;Rail&quot; varchar2(6) 
PATH 'RailAccess')" start-index="88" stop-index="227" />
-                    </xml-table>
+                    <function-table table-alias="warehouse2">
+                        <table-function function-name="XMLTABLE"
+                                        text="XMLTABLE('/Warehouse' PASSING 
warehouses.warehouse_spec COLUMNS &quot;Water&quot; varchar2(6) PATH 
'WaterAccess',&quot;Rail&quot; varchar2(6) PATH 'RailAccess')"/>
+                    </function-table>
                 </right>
             </join-table>
         </from>
@@ -6909,4 +6910,45 @@
             <simple-table alias="aWHERE" name="employee" start-index="88" 
stop-index="102" literal-start-index="88" literal-stop-index="102" />
         </from>
     </select>
+    <select sql-case-id="select_with_custom_table_function">
+        <projections start-index="7" stop-index="18" literal-start-index="7" 
literal-stop-index="18">
+            <aggregation-projection type="COUNT" expression="COUNT(empid)" 
start-index="7" stop-index="18"
+                                    literal-start-index="7" 
literal-stop-index="18"/>
+        </projections>
+        <from>
+            <join-table join-type="COMMA" natural="false">
+                <left>
+                    <simple-table alias="b" name="EMPLOYEE" start-index="25" 
stop-index="34" literal-start-index="25"
+                                  literal-stop-index="34"/>
+                </left>
+                <right>
+                    <function-table table-alias="a">
+                        <table-function function-name="custom_function" 
text="custom_function(b.orgid)"/>
+                    </function-table>
+                </right>
+            </join-table>
+        </from>
+        <where start-index="64" stop-index="88" literal-start-index="64" 
literal-stop-index="88">
+            <expr>
+                <binary-operation-expression start-index="70" stop-index="88" 
literal-start-index="70"
+                                             literal-stop-index="88">
+                    <left>
+                        <column name="postid" start-index="70" stop-index="77" 
literal-start-index="70"
+                                literal-stop-index="77">
+                            <owner name="a" start-index="70" stop-index="70" 
literal-start-index="70"
+                                   literal-stop-index="70"/>
+                        </column>
+                    </left>
+                    <operator>=</operator>
+                    <right>
+                        <column name="postid" start-index="81" stop-index="88" 
literal-start-index="81"
+                                literal-stop-index="88">
+                            <owner name="b" start-index="81" stop-index="81" 
literal-start-index="81"
+                                   literal-stop-index="81"/>
+                        </column>
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index ac5ee474bba..de98b86d525 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -209,4 +209,5 @@
     <sql-case id="select_with_group_by_and_having" value="select cfg_name from 
bmsql_config group by cfg_name having cfg_name='1';" db-types="openGauss" />
     <sql-case id="select_with_to_date_function" value="SELECT TO_DATE('Febuary 
15, 2016, 11:00 A.M.' DEFAULT 'January 01, 2016 12:00 A.M.' ON CONVERSION 
ERROR, 'Month dd, YYYY, HH:MI A.M.') FROM DUAL;" db-types="Oracle" />
     <sql-case id="select_with_expressions_in_projection" value="SELECT 
((a.enddate - term + term2 + 1) / (last_day(term) - term + 1)) cnt, a.empid 
FROM employee aWHERE nvl(disabled, 0) = 1  AND enddate BETWEEN term AND 
last_day(term)  AND EXISTS (SELECT 1 FROM post d WHERE a.orgid = d.orgid   AND 
a.postid = d.postid   AND d.title != 'TEST'   AND nvl(d.postid, 0) != 0)" 
db-types="Oracle" />
+    <sql-case id="select_with_custom_table_function" value="SELECT 
COUNT(empid) FROM EMPLOYEE b, custom_function(b.orgid) a WHERE a.postid = 
b.postid" db-types="Oracle" />
 </sql-cases>

Reply via email to