This topic describes how to use MaxCompute SDK for Java to set the SQL flag.

Background information

You must set the SQL flag when you submit SQL statements in the DataWorks console or on the MaxCompute client. If you want to enable the MaxCompute V2.0 data type edition at the session level, you must execute the set odps.sql.type.system.odps2=true; statement to set the SQL flag before the SQL query statement that involves the new data type.

Example

When you use MaxCompute SDK for Java to submit SQL query statements, do not insert the statement that is used to set the SQL flag into the SQL query statements. You can use the following method to set the SQL flag:
String sql ="SELECT..." ;
HashMap<String, String> hints = new LinkedHashMap<String, String>();
hints.put("SQL flag name, e.g. odps.sql.type.system.odps2", "SQL flag value");
hints.put("SQL flag name, e.g. odps.sql.type.system.odps2", "SQL flag value");
hints.put("SQL flag name, e.g. odps.sql.type.system.odps2", "SQL flag value");
Instance i = SQLTask.run(odps, odps.getDefaultProject(), sql, hints, null);
i.waitForSuccess();