This topic describes how to use MaxCompute SDK for Java to set an SQL flag.
Background information
In most cases, you must 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.
Example
When using MaxCompute SDK for Java to submit SQL query statements, you cannot set the SQL flag by directly adding the set statement 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();