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

Background information

In most cases, you need to set an SQL flag when you submit SQL statements in the DataWorks console or on the MaxCompute client. For example, if you want to enable the MaxCompute V2.0 data type edition at the session level, you must add the set odps.sql.type.system.odps2=true; command before the SQL statements that involve the data types supported by the MaxCompute V2.0 data type edition. The set odps.sql.type.system.odps2=true; command is used to set an SQL flag.

Example

If you use MaxCompute SDK for Java to submit SQL query statements, you cannot set the SQL flag by adding the set odps.sql.type.system.odps2=true; command before SQL 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();