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/12/11 02:43:07 UTC

[GitHub] [shardingsphere] jingshanglu opened a new pull request #8575: add doc for sql format

jingshanglu opened a new pull request #8575:
URL: https://github.com/apache/shardingsphere/pull/8575


   
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #8575: add doc for sql format

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #8575:
URL: https://github.com/apache/shardingsphere/pull/8575#discussion_r540747674



##########
File path: docs/document/content/features/sharding/principle/parse.cn.md
##########
@@ -103,3 +103,108 @@ SQLVisitorEngine sqlVisitorEngine = new SQLVisitorEngine(databaseType, "STATEMEN
 SQLStatement sqlStatement = sqlVisitorEngine.visit(tree);
 
 ```
+
+- SQL格式化
+
+```
+/**
+ * databaseType type:String 可能值 MySQL
+ * useCache type:boolean 是否使用缓存
+ * @return String
+ */
+ParseTree tree = new SQLParserEngine(databaseType).parse(sql, useCache); 
+SQLVisitorEngine sqlVisitorEngine = new SQLVisitorEngine(databaseType, "FORMAT");
+String formatedSql = sqlVisitorEngine.visit(tree);
+
+//例子
+sql1 : select a+1 as b, name n from table1 join table2 where id=1 and name='lu';
+sql2 : select id, name, age, sex, ss, yy from table1 where id=1;
+sql3 : select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1;

Review comment:
       @tristaZero Ok.




----------------------------------------------------------------
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



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #8575: add doc for sql format

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #8575:
URL: https://github.com/apache/shardingsphere/pull/8575#discussion_r540668956



##########
File path: docs/document/content/features/sharding/principle/parse.cn.md
##########
@@ -103,3 +103,108 @@ SQLVisitorEngine sqlVisitorEngine = new SQLVisitorEngine(databaseType, "STATEMEN
 SQLStatement sqlStatement = sqlVisitorEngine.visit(tree);
 
 ```
+
+- SQL格式化
+
+```
+/**
+ * databaseType type:String 可能值 MySQL
+ * useCache type:boolean 是否使用缓存
+ * @return String
+ */
+ParseTree tree = new SQLParserEngine(databaseType).parse(sql, useCache); 
+SQLVisitorEngine sqlVisitorEngine = new SQLVisitorEngine(databaseType, "FORMAT");
+String formatedSql = sqlVisitorEngine.visit(tree);
+
+//例子
+sql1 : select a+1 as b, name n from table1 join table2 where id=1 and name='lu';
+sql2 : select id, name, age, sex, ss, yy from table1 where id=1;
+sql3 : select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1;

Review comment:
       Could you put these SQL cases and their formatted result into a table? For example, one row of a table contains one SQL column and its formatted output in another column. Therefore users can get a quick comparison, I guess.




----------------------------------------------------------------
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



[GitHub] [shardingsphere] codecov-io commented on pull request #8575: add doc for sql format

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #8575:
URL: https://github.com/apache/shardingsphere/pull/8575#issuecomment-742954561


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=h1) Report
   > Merging [#8575](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=desc) (a68d5e6) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3e350c1265bbc08b062bb8853b547ceafddf99d3?el=desc) (3e350c1) will **decrease** coverage by `0.17%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/8575/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #8575      +/-   ##
   ============================================
   - Coverage     72.22%   72.05%   -0.18%     
   + Complexity      602      601       -1     
   ============================================
     Files          1547     1547              
     Lines         24537    24537              
     Branches       4325     4325              
   ============================================
   - Hits          17721    17679      -42     
   - Misses         5659     5688      +29     
   - Partials       1157     1170      +13     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...rdingsphere/agent/metrics/api/MetricsProvider.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtcGx1Z2lucy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1wbHVnaW4tbWV0cmljcy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1tZXRyaWNzLWFwaS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvbWV0cmljcy9hcGkvTWV0cmljc1Byb3ZpZGVyLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...re/agent/core/config/AgentConfigurationLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9jb25maWcvQWdlbnRDb25maWd1cmF0aW9uTG9hZGVyLmphdmE=) | `0.00% <0.00%> (-83.34%)` | `0.00% <0.00%> (ø%)` | |
   | [...che/shardingsphere/agent/core/yaml/YamlEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS95YW1sL1lhbWxFbmdpbmUuamF2YQ==) | `0.00% <0.00%> (-36.37%)` | `0.00% <0.00%> (ø%)` | |
   | [...i/prometheus/PrometheusMetricsRegisterFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtcGx1Z2lucy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1wbHVnaW4tbWV0cmljcy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1tZXRyaWNzLWFwaS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvbWV0cmljcy9hcGkvcHJvbWV0aGV1cy9Qcm9tZXRoZXVzTWV0cmljc1JlZ2lzdGVyRmFjdG9yeS5qYXZh) | `0.00% <0.00%> (-33.34%)` | `0.00% <0.00%> (-1.00%)` | |
   | [...osition/resume/ResumeBreakPointManagerFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvcG9zaXRpb24vcmVzdW1lL1Jlc3VtZUJyZWFrUG9pbnRNYW5hZ2VyRmFjdG9yeS5qYXZh) | `75.00% <0.00%> (-12.50%)` | `0.00% <0.00%> (ø%)` | |
   | [...scaling/core/execute/engine/TaskExecuteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9leGVjdXRlL2VuZ2luZS9UYXNrRXhlY3V0ZUVuZ2luZS5qYXZh) | `88.88% <0.00%> (-11.12%)` | `0.00% <0.00%> (ø%)` | |
   | [...rdingsphere/proxy/database/DatabaseServerInfo.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYm9vdHN0cmFwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9wcm94eS9kYXRhYmFzZS9EYXRhYmFzZVNlcnZlckluZm8uamF2YQ==) | `90.00% <0.00%> (-10.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...re/scaling/core/schedule/ScalingTaskScheduler.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9zY2hlZHVsZS9TY2FsaW5nVGFza1NjaGVkdWxlci5qYXZh) | `74.54% <0.00%> (-7.28%)` | `0.00% <0.00%> (ø%)` | |
   | [...scaling/core/job/task/inventory/InventoryTask.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvdGFzay9pbnZlbnRvcnkvSW52ZW50b3J5VGFzay5qYXZh) | `71.11% <0.00%> (-6.67%)` | `0.00% <0.00%> (ø%)` | |
   | [...ext/transaction/GovernanceTransactionContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvbnRleHQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29udGV4dC90cmFuc2FjdGlvbi9Hb3Zlcm5hbmNlVHJhbnNhY3Rpb25Db250ZXh0cy5qYXZh) | `93.33% <0.00%> (-6.67%)` | `0.00% <0.00%> (ø%)` | |
   | ... and [9 more](https://codecov.io/gh/apache/shardingsphere/pull/8575/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=footer). Last update [3e350c1...a68d5e6](https://codecov.io/gh/apache/shardingsphere/pull/8575?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere] tristaZero merged pull request #8575: add doc for sql format

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #8575:
URL: https://github.com/apache/shardingsphere/pull/8575


   


----------------------------------------------------------------
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