[jira] [Created] (FLINK-18003) Table hints support multi Options

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-18003) Table hints support multi Options

Shang Yuanchun (Jira)
hailong wang created FLINK-18003:
------------------------------------

             Summary: Table hints support multi Options
                 Key: FLINK-18003
                 URL: https://issues.apache.org/jira/browse/FLINK-18003
             Project: Flink
          Issue Type: Improvement
          Components: Table SQL / Planner
    Affects Versions: 1.10.0
            Reporter: hailong wang
             Fix For: 1.11.0


For now, if we write mutil options in table hint, only the first takes effect. For Example:
{code:java}
select * from t1/*+ OPTIONS(k5='v5', 'a.b.c'='fakeVal'), OPTIONS(k6='v6') */"
{code}
only k5='v5', 'a.b.c'='fakeVal' will be added to dynamic options.

For in FlinkHints#getHintedOptions, we only find the first relHint.
{code:java}
public static Map<String, String> getHintedOptions(List<RelHint> tableHints) {
   return tableHints.stream().filter(hint ->
         hint.hintName.equalsIgnoreCase(HINT_NAME_OPTIONS))
         .findFirst()
         .map(hint -> hint.kvOptions)
         .orElse(Collections.emptyMap());
}{code}
So I think we can  replace with:
{code:java}
public static Map<String, String> getHintedOptions(List<RelHint> tableHints) {
   return tableHints.stream().filter(hint ->
         hint.hintName.equalsIgnoreCase(HINT_NAME_OPTIONS))
         .map(hint -> hint.kvOptions)
         .map(Map::entrySet)
         .flatMap(Set::stream)
         .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
{code}
By this, k6='v2' will take effect.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)