XiaoMi / soar

SQL Optimizer And Rewriter
Apache License 2.0
8.67k stars 1.32k forks source link

Sampling Error,You have an error in your SQL syntax; #58

Closed hhyo closed 5 years ago

hhyo commented 5 years ago
2018/10/29 15:24:59.806 [D] [mysql.go:76] Execute SQL with DSN(mysql:3306/optimizer_ix4i4k7wMDiYHo1G) : CREATE TABLE `sql_workflow` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `workflow_name` varchar(50) NOT NULL ,
  `engineer` varchar(50) NOT NULL,
  `review_man` varchar(50) NOT NULL,
  `create_time` datetime(6) NOT NULL,
  `finish_time` datetime(6) DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  `is_backup` varchar(20) NOT NULL,
  `review_content` longtext NOT NULL,
  `cluster_name` varchar(50) NOT NULL,
  `reviewok_time` datetime(6) DEFAULT NULL,
  `sql_content` longtext NOT NULL,
  `execute_result` longtext NOT NULL,
  `is_manual` int(11) NOT NULL,
  `audit_remark` varchar(200) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8
2018/10/29 15:24:59.829 [D] [env.go:397] createTable, Start Sampling data from archer.sql_workflow to optimizer_ix4i4k7wMDiYHo1G.sql_workflow ...
2018/10/29 15:24:59.830 [D] [mysql.go:76] Execute SQL with DSN(mysql:3306/archer) : show table status where name = 'sql_workflow'
2018/10/29 15:24:59.832 [D] [mysql.go:76] Execute SQL with DSN(mysql:3306/archer) : show table status where name = 'sql_workflow'
2018/10/29 15:24:59.833 [D] [sampling.go:99] SamplingData, tableRows: 66, wantRowsCount: 30000, factor: 454.545455
2018/10/29 15:24:59.833 [D] [sampling.go:118] Sampling data execute: select DATA_TYPE from information_schema.COLUMNS where TABLE_SCHEMA='optimizer_ix4i4k
7wMDiYHo1G' and TABLE_NAME = 'sql_workflow'
2018/10/29 15:24:59.839 [E] [sampling.go:227] doSampling Error from optimizer_ix4i4k7wMDiYHo1G.sql_workflow: Received #1064 error from MySQL server: "You 
have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0_0_0'", "None", "0", "
"], [2, "CHECKED", 0, "Audit completed", "None", "create ' at line 1"
2018/10/29 15:24:59.839 [D] [sampling.go:215] 70 rows sampling out
2018/10/29 15:24:59.840 [D] [index.go:84] Enter: NewAdvisor(), Caller: main.main

./soar -print-config allow-online-as-test: false drop-test-temporary: true only-syntax-check: false sampling-statistic-target: 100 sampling: true profiling: false trace: false explain: true conn-time-out: 3 query-time-out: 30 delimiter: ; log-level: 7 log-output: /opt/archery/downloads/log/soar.log report-type: html report-css: "" report-javascript: "" report-title: SQL优化分析报告 markdown-extensions: 94 markdown-html-flags: 0 ignore-rules:

hhyo commented 5 years ago

@liipx 另外一个Sampling data的错误

LPX-E5BD8 commented 5 years ago

贴case的时候时候小心泄露隐私数据。

hhyo commented 5 years ago

贴case的时候时候小心泄露隐私数据。

谢谢提醒,是特意准备的测试数据,库名也是开源的项目测试库。不过问一句wantRowsCount: 30000是可配置还是固定的。

martianzhang commented 5 years ago
wantRowsCount := 300 * common.Config.SamplingStatisticTarget
soar -h | grep -i sampling
  -sampling-statistic-target int
        SamplingStatisticTarget, 数据采样因子,对应postgres的default_statistics_target (default 100)
lenovore commented 5 years ago

Received #1048 error from MySQL server: "Column 'v' cannot be null"

Sampling data会把空字符串转换成null?

hhyo commented 5 years ago

两个case测试都正常,谢谢~