You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/03/22 12:12:29 UTC
[GitHub] [incubator-shardingsphere] tristaZero opened a new issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
tristaZero opened a new issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890
Hi, we are glad you can fix this issue to become a contributor to Apache Sharding Sphere.
Welcome! 😃
By doing this assignment, you can learn more about how a query SQL is parsed and how to verify the parsing result of a SQL in Apache ShardingSphere.
**This issue is to** add the parsing assertion for `ConstraintDefinitionSegment ` by adding the `start-index` and `stop-index` attributes in `parsing-result.xml`.
It is not difficult, and the following comment also gives you the detailed instruction. BTW, if you need any help, please be free to reply this one.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] tristaZero commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602191085
### How to find the targets to be fixed?
1. Open class `ConstraintDefinitionAssert` and clear the comment of
```
// assertThat(assertContext.getText("Constraint definition start index assertion error: "), actual.getStartIndex(), is(expected.getStartIndex()));
// assertThat(assertContext.getText("Constraint definition stop index assertion error: "), actual.getStopIndex(), is(expected.getStopIndex()));
``` in `assertIs`.
2. run `SQLParserParameterizedTest`
3. All the SQL cases which have the error assertion results are our targets to be fixed.
### How to fix the above assertion results?
1. Look at the exception log and find the corresponding `SQL Case ID` and `SQL`.
2. Find out the `parsing result` of this `SQL Case ID` in `./incubator-shardingsphere/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/dml`
3. Calculate the correct `start-index` and `stop-index` of `add-constraint` and `constraint-definition` segments of this `SQL`.
4. Add the calculated `start-index` and `stop-index` labels of `add-constraint` and `constraint-definition` segments to `parsing result` of this `SQL Case ID`, like
```
<constraint-definition start-index="10" stop-index="11" />
```
5. Add the correct `literal-start-index` and `literal-stop-index` of `literal-expression` segment to `parsing result` of this `SQL Case ID` when it is necessary, like
```
constraint-definition value="init" literal-start-index="10" literal-stop-index="11" />
```
6. Run `SQLParserParameterizedTest` again to check whether this `SQL Case ID` does not stay in the list of `SQL` with `bad assertion result`.
### Note
1. What are the definitions of `constraint-definition` and `add-constraint`?
For instance, here is a SQL,
```
CREATE TABLE t_order (order_id INT, user_id INT, status VARCHAR(10), column1 VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10), CONSTRAINT pk_order_id PRIMARY KEY (order_id))
```
The segment of `CONSTRAINT pk_order_id PRIMARY KEY (order_id))` is a `constraint-definition`.
```
ALTER TABLE t_order ADD CONSTRAINT pk_user_id PRIMARY KEY (user_id)
```
The segment of `ADD CONSTRAINT pk_user_id PRIMARY KEY (user_id)` is `add-constraint`.
2. What is the difference between `literal-start-index` and `start-index`?
When a SQL does not contain parameter maker, i.e.,`?`, this SQL only has one form; Otherwise, you will see two forms of this SQL, i.e, a SQL form filled with parameter and a SQL form only with parameter marks. For instance,
```
Case1 One SQL without parameter mark,
select * from table where id = 1;
Case2 One SQL with parameter mark,
Original SQL: select * from table where id = ?;
SQL filled with Parameter: select * from table where id = 1;
```
Replace `the parameter mark` with `the actual parameter` will change the position of the segment. Therefore we need to add `start-index` to represent the start position of a segment for `Original SQL`, and `literal-start-index` is used to represent the start position of a segment for `SQL filled with Parameter`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] tristaZero commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602342539
I assigned this issue to you, waiting for your feedback later.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] strongduanmu commented on issue #4890:
Add start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-605424809
Can I try to solve this issue?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] tristaZero commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602340321
@ssaify Hi guy, this is the first time for me to see your activity in ShardingSphere community, welcome!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] tristaZero edited a comment on issue
#4890: Add start-index and stop-index assertion for
ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602191085
### How to find the targets to be fixed?
1. Open class `ConstraintDefinitionAssert` and clear the following comments in `assertIs`.
```
// assertThat(assertContext.getText("Constraint definition start index assertion error: "), actual.getStartIndex(), is(expected.getStartIndex()));
// assertThat(assertContext.getText("Constraint definition stop index assertion error: "), actual.getStopIndex(), is(expected.getStopIndex()));
```
2. run `SQLParserParameterizedTest`
3. All the SQL cases which have the error assertion results are our targets to be fixed.
### How to fix the above assertion results?
1. Look at the exception log and find the corresponding `SQL Case ID` and `SQL`.
2. Find out the `parsing result` of this `SQL Case ID` in `./incubator-shardingsphere/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/dml`
3. Calculate the correct `start-index` and `stop-index` of `add-constraint` and `constraint-definition` segments of this `SQL`.
4. Add the calculated `start-index` and `stop-index` labels of `add-constraint` and `constraint-definition` segments to `parsing result` of this `SQL Case ID`, like
```
<constraint-definition start-index="10" stop-index="11" />
```
5. Add the correct `literal-start-index` and `literal-stop-index` of `literal-expression` segment to `parsing result` of this `SQL Case ID` when it is necessary, like
```
<constraint-definition value="init" literal-start-index="10" literal-stop-index="11" />
```
6. Run `SQLParserParameterizedTest` again to check whether this `SQL Case ID` does not stay in the list of `SQL` with `bad assertion result`.
### Note
1. What are the definitions of `constraint-definition` and `add-constraint`?
For instance, here is a SQL,
```
CREATE TABLE t_order (order_id INT, user_id INT, status VARCHAR(10), column1 VARCHAR(10), column2 VARCHAR(10), column3 VARCHAR(10), CONSTRAINT pk_order_id PRIMARY KEY (order_id))
```
The segment of `CONSTRAINT pk_order_id PRIMARY KEY (order_id))` is a `constraint-definition`.
```
ALTER TABLE t_order ADD CONSTRAINT pk_user_id PRIMARY KEY (user_id)
```
The segment of `ADD CONSTRAINT pk_user_id PRIMARY KEY (user_id)` is `add-constraint`.
2. What is the difference between `literal-start-index` and `start-index`?
When a SQL does not contain parameter maker, i.e.,`?`, this SQL only has one form; Otherwise, you will see two forms of this SQL, i.e, a SQL form filled with parameter and a SQL form only with parameter marks. For instance,
```
Case1 One SQL without parameter mark,
select * from table where id = 1;
Case2 One SQL with parameter mark,
Original SQL: select * from table where id = ?;
SQL filled with Parameter: select * from table where id = 1;
```
Replace `the parameter mark` with `the actual parameter` will change the position of the segment. Therefore we need to add `start-index` to represent the start position of a segment for `Original SQL`, and `literal-start-index` is used to represent the start position of a segment for `SQL filled with Parameter`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu closed issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] ssaify commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
ssaify commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602381891
Thanks for assigning me this issue. I am new to open source community. I have started working on the issue. Would it be okay if I contact you if I have any doubts or any problem?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] tristaZero commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602975012
Of course, please be free to contact us if you have any problems.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] ssaify commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
ssaify commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602238402
I would like to work on this issue.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] ssaify commented on issue #4890: Add
start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
ssaify commented on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602378563
> @ssaify Hi guy, this is the first time for me to see your activity in ShardingSphere community, welcome!
Thanks for assigning me this issue. I am new to open source community. I have started working on the issue. Would it be okay if I contact you if I have any doubts or any problem?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] ssaify removed a comment on issue #4890:
Add start-index and stop-index assertion for ConstraintDefinitionSegment
Posted by GitBox <gi...@apache.org>.
ssaify removed a comment on issue #4890: Add start-index and stop-index assertion for ConstraintDefinitionSegment
URL: https://github.com/apache/incubator-shardingsphere/issues/4890#issuecomment-602378563
> @ssaify Hi guy, this is the first time for me to see your activity in ShardingSphere community, welcome!
Thanks for assigning me this issue. I am new to open source community. I have started working on the issue. Would it be okay if I contact you if I have any doubts or any problem?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services