You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "lancelly (via GitHub)" <gi...@apache.org> on 2023/08/26 08:26:07 UTC
[GitHub] [shardingsphere] lancelly opened a new pull request, #28265: [Oracle SQL] Support parsing of XMLElement and XMLCdata Function
lancelly opened a new pull request, #28265:
URL: https://github.com/apache/shardingsphere/pull/28265
In this pr, I supported the parsing of basic components of XMLElement and XMLCdata Function of Oracle.
Now, the HR-5-204 & HR-5-208 can be parsed correcly.
The Example SQL is :
`SELECT XMLELEMENT("PurchaseOrder", XMLAttributes(dummy as "pono"), XMLCdata('<!DOCTYPE po_dom_group [ <!ELEMENT po_dom_group(student_name)*> <!ELEMENT po_purch_name (#PCDATA)> <!ATTLIST po_name po_no ID #REQUIRED> <!ATTLIST po_name trust_1 IDREF #IMPLIED> <!ATTLIST po_name trust_2 IDREF #IMPLIED>]>')) "XMLCData" FROM DUAL;`
I refered to the offical doc of Oracle:
https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/XMLELEMENT.html#GUID-DEA75423-00EA-4034-A246-4A774ADC988E
https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/XMLCDATA.html#GUID-FB517A52-6F1A-4D8D-B632-F91EFA606691
<img width="773" alt="截屏2023-08-26 16 25 29" src="https://github.com/apache/shardingsphere/assets/108499334/cbcc4ddf-face-4815-8aeb-4b3297580452">
<img width="931" alt="截屏2023-08-26 14 22 26" src="https://github.com/apache/shardingsphere/assets/108499334/8aaafccb-bc82-452e-841e-bd3e9736f967">
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] lancelly commented on pull request #28265: [Oracle SQL] Support parsing of XMLElement and XMLCdata Function
Posted by "lancelly (via GitHub)" <gi...@apache.org>.
lancelly commented on PR #28265:
URL: https://github.com/apache/shardingsphere/pull/28265#issuecomment-1694227154
It seems that test cases which contains certain special characters are not allowed:
<img width="1830" alt="截屏2023-08-26 16 27 15" src="https://github.com/apache/shardingsphere/assets/108499334/2feb1df0-10e4-4730-ab94-705e68a33b6f">
So for this function, I did not add test cases in the IT.
However, I checked the result statement manually and it seems alright:
<img width="1879" alt="截屏2023-08-26 16 29 25" src="https://github.com/apache/shardingsphere/assets/108499334/fb52b77e-d3e1-4844-b16a-98fcf6db39f0">
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang merged pull request #28265: [Oracle SQL] Support parsing of XMLElement and XMLCdata Function
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang merged PR #28265:
URL: https://github.com/apache/shardingsphere/pull/28265
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #28265: [Oracle SQL] Support parsing of XMLElement and XMLCdata Function
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on code in PR #28265:
URL: https://github.com/apache/shardingsphere/pull/28265#discussion_r1314487673
##########
parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java:
##########
@@ -687,11 +688,34 @@ public ASTNode visitXmlFunction(final XmlFunctionContext ctx) {
if (null != ctx.xmlTableFunction()) {
return visit(ctx.xmlTableFunction());
}
+ if (null != ctx.xmlElementFunction()) {
+ return visit(ctx.xmlElementFunction());
+ }
FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.specifiedFunctionName.getText(), getOriginalText(ctx));
result.getParameters().addAll(getExpressions(ctx.exprList()));
return result;
}
+ @Override
+ public ASTNode visitXmlElementFunction(final OracleStatementParser.XmlElementFunctionContext ctx) {
Review Comment:
Please import context class directly.
##########
parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java:
##########
@@ -687,11 +688,34 @@ public ASTNode visitXmlFunction(final XmlFunctionContext ctx) {
if (null != ctx.xmlTableFunction()) {
return visit(ctx.xmlTableFunction());
}
+ if (null != ctx.xmlElementFunction()) {
+ return visit(ctx.xmlElementFunction());
+ }
FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.specifiedFunctionName.getText(), getOriginalText(ctx));
result.getParameters().addAll(getExpressions(ctx.exprList()));
return result;
}
+ @Override
+ public ASTNode visitXmlElementFunction(final OracleStatementParser.XmlElementFunctionContext ctx) {
+ XmlElementFunctionSegment result =
+ new XmlElementFunctionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), ctx.XMLELEMENT().getText(), (IdentifierValue) visit(ctx.identifier()), getOriginalText(ctx));
+ Collection<ExpressionSegment> expressionSegments = ctx.exprWithAlias().stream().map(each -> (ExpressionSegment) visit(each.expr())).collect(Collectors.toList());
+ result.getParameters().addAll(expressionSegments);
+ if (null != ctx.xmlAttributes()) {
+ Collection<ExpressionSegment> xmlAttributes = ctx.xmlAttributes().exprWithAlias().stream().map(each -> (ExpressionSegment) visit(each.expr())).collect(Collectors.toList());
+ result.getXmlAttributes().addAll(xmlAttributes);
+ }
+ return result;
+ }
+
+ @Override
+ public ASTNode visitXmlCdataFunction(final OracleStatementParser.XmlCdataFunctionContext ctx) {
Review Comment:
Please import context class directly.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] lancelly commented on a diff in pull request #28265: [Oracle SQL] Support parsing of XMLElement and XMLCdata Function
Posted by "lancelly (via GitHub)" <gi...@apache.org>.
lancelly commented on code in PR #28265:
URL: https://github.com/apache/shardingsphere/pull/28265#discussion_r1314561111
##########
parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java:
##########
@@ -687,11 +688,34 @@ public ASTNode visitXmlFunction(final XmlFunctionContext ctx) {
if (null != ctx.xmlTableFunction()) {
return visit(ctx.xmlTableFunction());
}
+ if (null != ctx.xmlElementFunction()) {
+ return visit(ctx.xmlElementFunction());
+ }
FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.specifiedFunctionName.getText(), getOriginalText(ctx));
result.getParameters().addAll(getExpressions(ctx.exprList()));
return result;
}
+ @Override
+ public ASTNode visitXmlElementFunction(final OracleStatementParser.XmlElementFunctionContext ctx) {
+ XmlElementFunctionSegment result =
+ new XmlElementFunctionSegment(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), ctx.XMLELEMENT().getText(), (IdentifierValue) visit(ctx.identifier()), getOriginalText(ctx));
+ Collection<ExpressionSegment> expressionSegments = ctx.exprWithAlias().stream().map(each -> (ExpressionSegment) visit(each.expr())).collect(Collectors.toList());
+ result.getParameters().addAll(expressionSegments);
+ if (null != ctx.xmlAttributes()) {
+ Collection<ExpressionSegment> xmlAttributes = ctx.xmlAttributes().exprWithAlias().stream().map(each -> (ExpressionSegment) visit(each.expr())).collect(Collectors.toList());
+ result.getXmlAttributes().addAll(xmlAttributes);
+ }
+ return result;
+ }
+
+ @Override
+ public ASTNode visitXmlCdataFunction(final OracleStatementParser.XmlCdataFunctionContext ctx) {
Review Comment:
done.
##########
parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java:
##########
@@ -687,11 +688,34 @@ public ASTNode visitXmlFunction(final XmlFunctionContext ctx) {
if (null != ctx.xmlTableFunction()) {
return visit(ctx.xmlTableFunction());
}
+ if (null != ctx.xmlElementFunction()) {
+ return visit(ctx.xmlElementFunction());
+ }
FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.specifiedFunctionName.getText(), getOriginalText(ctx));
result.getParameters().addAll(getExpressions(ctx.exprList()));
return result;
}
+ @Override
+ public ASTNode visitXmlElementFunction(final OracleStatementParser.XmlElementFunctionContext ctx) {
Review Comment:
done.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org