The MaxCompute compiler is built on the next-generation SQL engine of MaxCompute 2.0, which enhances the usability and expressiveness of the SQL language. This topic describes how to use compiler errors and alerts to troubleshoot scripts.
Background
-
To take full advantage of the MaxCompute compiler, we recommend using MaxCompute Studio. For installation instructions, see Install MaxCompute Studio.
-
Before submitting a script, run static compilation checks with the MaxCompute compiler. We also recommend that you enable syntax highlighting by selecting Enable syntax coloring in the MaxCompute SQL configuration items. For configuration details, see MaxCompute SQL configuration items.
Error example
-
Compiler display
Hover over the red error marker in the following code. The compiler displays the following error: expect 1 columns, actually have 2.
create table if not exists src(k bigint COMMENT '', V String COMMENT ''); insert overwrite table src select a, wm_concat(',', a) from values(1,'a'),(1,'b'),(2,'x'),(2) t (a, b) group by a; -- Error: expect 1 columns, actually have 2 -
Execution result
1> 2021-10-14 11:33:37 Status: FAILED 1> ODPS-0130071:[3,36] Semantic analysis exception - expect 1 columns, actually have 2 -
Error description
The src table has two columns. However, when you use the insert statement, one row in the values clause contains only one column. This mismatch causes the compiler to report an error.
Alert example
-
Compiler display
Hover over the alert marker in the following code. The compiler displays the following alert: implicit conversion from STRING to DOUBLE, potential data loss, use CAST function to suppress.
create table if not exists dest(k bigint COMMENT '', V String COMMENT ''); create table if not exists upper_stream(id String COMMENT '', Value String COMMENT '') partitioned by (dt String); insert overwrite table dest select k, value from src join upper_stream u on u.id = k; -- Compiler alert: implicit conversion from STRING to DOUBLE, potential data loss, use CAST function to suppress -
Alert description
An implicit conversion from STRING to DOUBLE can cause potential data loss. To avoid this, use the CAST function to explicitly convert the data type. For more information about data conversions, see Data type conversions.
Note-
To save time and resources, resolve all alerts before running a script.
-
Submitting a script with errors lowers your health score, which can reduce the priority of your future jobs. Unresolved alerts will also lower your health score in the future. Therefore, addressing all errors and alerts flagged by the MaxCompute compiler can help you maintain your job priority.
-