TestListReportTypes.golden 3.3 KB
Newer Older
martianzhang's avatar
martianzhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 支持的报告类型

[toc]

## lint
* **Description**:参考sqlint格式,以插件形式集成到代码编辑器,显示输出更加友好

* **Example**:

```bash
soar -report-type lint -query test.sql
```
## markdown
* **Description**:该格式为默认输出格式,以markdown格式展现,可以用网页浏览器插件直接打开,也可以用markdown编辑器打开

* **Example**:

```bash
echo "select * from film" | soar
```
## rewrite
martianzhang's avatar
martianzhang 已提交
22
* **Description**:SQL重写功能,配合-rewrite-rules参数一起使用,可以通过-list-rewrite-rules 查看所有支持的 SQL 重写规则
martianzhang's avatar
martianzhang 已提交
23 24 25 26 27 28 29

* **Example**:

```bash
echo "select * from film" | soar -rewrite-rules star2columns,delimiter -report-type rewrite
```
## ast
martianzhang's avatar
martianzhang 已提交
30
* **Description**:输出 SQL 的抽象语法树,主要用于测试
martianzhang's avatar
martianzhang 已提交
31 32 33 34 35 36 37

* **Example**:

```bash
echo "select * from film" | soar -report-type ast
```
## tiast
martianzhang's avatar
martianzhang 已提交
38
* **Description**:输出 SQL 的 TiDB抽象语法树,主要用于测试
martianzhang's avatar
martianzhang 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

* **Example**:

```bash
echo "select * from film" | soar -report-type tiast
```
## fingerprint
* **Description**:输出SQL的指纹

* **Example**:

```bash
echo "select * from film where language_id=1" | soar -report-type fingerprint
```
## md2html
martianzhang's avatar
martianzhang 已提交
54
* **Description**:markdown 格式转 html 格式小工具
martianzhang's avatar
martianzhang 已提交
55 56 57 58 59 60 61

* **Example**:

```bash
soar -list-heuristic-rules | soar -report-type md2html > heuristic_rules.html
```
## explain-digest
martianzhang's avatar
martianzhang 已提交
62
* **Description**:输入为EXPLAIN的表格,JSON 或 Vertical格式,对其进行分析,给出分析结果
martianzhang's avatar
martianzhang 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75

* **Example**:

```bash
soar -report-type explain-digest << EOF
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
|  1 | SIMPLE      | film  | ALL  | NULL          | NULL | NULL    | NULL | 1131 |       |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
EOF
```
## duplicate-key-checker
martianzhang's avatar
martianzhang 已提交
76
* **Description**:对 OnlineDsn 中指定的 database 进行索引重复检查
martianzhang's avatar
martianzhang 已提交
77 78 79 80

* **Example**:

```bash
martianzhang's avatar
martianzhang 已提交
81
soar -report-type duplicate-key-checker -online-dsn user:password@127.0.0.1:3306/db
martianzhang's avatar
martianzhang 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
```
## html
* **Description**:以HTML格式输出报表

* **Example**:

```bash
echo "select * from film" | soar -report-type html
```
## json
* **Description**:输出JSON格式报表,方便应用程序处理

* **Example**:

```bash
echo "select * from film" | soar -report-type json
```
## tokenize
* **Description**:对SQL进行切词,主要用于测试

* **Example**:

```bash
echo "select * from film" | soar -report-type tokenize
```
## compress
* **Description**:SQL压缩小工具,使用内置SQL压缩逻辑,测试中的功能

* **Example**:

```bash
echo "select
*
from
  film" | soar -report-type compress
```
## pretty
* **Description**:使用kr/pretty打印报告,主要用于测试

* **Example**:

```bash
echo "select * from film" | soar -report-type pretty
```
## remove-comment
* **Description**:去除SQL语句中的注释,支持单行多行注释的去除

* **Example**:

```bash
echo "select/*comment*/ * from film" | soar -report-type remove-comment
```
martianzhang's avatar
martianzhang 已提交
134 135 136 137 138 139 140 141
## chardet
* **Description**:猜测输入的 SQL 使用的字符集

* **Example**:

```bash
echo '中文' | soar -report-type chardet
```