[ 
https://issues.apache.org/jira/browse/FLINK-22207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17319061#comment-17319061
 ] 

wangzeyu edited comment on FLINK-22207 at 4/12/21, 6:50 AM:
------------------------------------------------------------

So here's my solution , change replace to replaceFirst , and it is work in my 
project
{code:java}
private static Map<String, String> retrieveFlinkProperties(
        Map<String, String> hiveTableParams) {
    return hiveTableParams.entrySet().stream()
            .filter(
                    e ->
                            e.getKey().startsWith(FLINK_PROPERTY_PREFIX)
                                    || 
e.getKey().equals(CatalogConfig.IS_GENERIC))
            .collect(
                    Collectors.toMap(
                            e -> e.getKey().replaceFirst(FLINK_PROPERTY_PREFIX, 
""),
                            e -> e.getValue()));
}
{code}


was (Author: wangzeyu):
So here's my solution , change replace to replaceFirst
{code:java}
private static Map<String, String> retrieveFlinkProperties(
        Map<String, String> hiveTableParams) {
    return hiveTableParams.entrySet().stream()
            .filter(
                    e ->
                            e.getKey().startsWith(FLINK_PROPERTY_PREFIX)
                                    || 
e.getKey().equals(CatalogConfig.IS_GENERIC))
            .collect(
                    Collectors.toMap(
                            e -> e.getKey().replaceFirst(FLINK_PROPERTY_PREFIX, 
""),
                            e -> e.getValue()));
}
{code}

> Hive Catalog retrieve Flink Properties error
> --------------------------------------------
>
>                 Key: FLINK-22207
>                 URL: https://issues.apache.org/jira/browse/FLINK-22207
>             Project: Flink
>          Issue Type: Bug
>          Components: Connectors / Hive
>    Affects Versions: 1.12.1
>            Reporter: wangzeyu
>            Priority: Major
>             Fix For: 1.12.1
>
>
> If we use hive catalog and set flink propertie eg."url",and then when we add 
> the other propertie like start with string "flink." like "flink.url" will 
> show we the error "java.lang.IllegalStateException: Duplicate key" , and 
> what's worse is because of this error we can`t drop or alter this tabel more.
> I found in this method , 
> "org.apache.flink.table.catalog.hive.HiveCatalog.retrieveFlinkProperties", 
> replace all "flink." of propertie. So , the  propertie of HiveCatalog 
> "flink.url" and "flink.flink.url" both result to "url". 
> I think in the method 
> "org.apache.flink.table.catalog.hive.HiveCatalog.retrieveFlinkProperties" we 
> should use replaceFirst but not replace to handle propertie.



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

Reply via email to