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

Jing Zhang edited comment on FLINK-28741 at 11/22/22 11:11 AM:
---------------------------------------------------------------

>  I'm wondering is there some  Hive2  users may expect the string *"false"*  
> to be cast to the boolean value *true* since that what Hive2's behavior.

I'm afraid it is not what the user expected that cast ('false' to boolean) 
returns true.

However there might different voices for cast('' to boolean) or cast ('XXX' to 
boolean).


was (Author: qingru zhang):
>  I'm wondering is there some  Hive2  users may expect the string *"false"*  
> to be cast to the boolean value *true* since that what Hive2's behavior.

> Unexpected result if insert 'false' to boolean column
> -----------------------------------------------------
>
>                 Key: FLINK-28741
>                 URL: https://issues.apache.org/jira/browse/FLINK-28741
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Connectors / Hive
>    Affects Versions: 1.15.0, 1.15.1
>            Reporter: Jing Zhang
>            Priority: Major
>
> Using hive dialect to insert a string 'false' to boolean column, the result 
> is true. It seems to treat all non-empty string as true.
> The error could be reproduced in the following ITCase.
> {code:java}
> @Test
> public void testUnExpectedResult() throws ExecutionException, 
> InterruptedException {
>     HiveModule hiveModule = new HiveModule(hiveCatalog.getHiveVersion());
>     CoreModule coreModule = CoreModule.INSTANCE;
>     for (String loaded : tableEnv.listModules()) {
>         tableEnv.unloadModule(loaded);
>     }
>     tableEnv.loadModule("hive", hiveModule);
>     tableEnv.loadModule("core", coreModule);
> // create source table
>     tableEnv.executeSql(
>             "CREATE TABLE test_table (params string) PARTITIONED BY (`p_date` 
> string)");
> // prepare a data which value is 'false'
>     tableEnv.executeSql("insert overwrite test_table partition(p_date = 
> '20220612') values ('false')")
>             .await();
> // create target table which only contain one boolean column 
>     tableEnv.executeSql(
>             "CREATE TABLE target_table (flag boolean) PARTITIONED BY 
> (`p_date` string)");
> // 
>     tableEnv.executeSql(
>             "insert overwrite table target_table partition(p_date = 
> '20220724') "
>                     + "SELECT params FROM test_table WHERE 
> p_date='20220612'").await();
>     TableImpl flinkTable =
>             (TableImpl) tableEnv.sqlQuery("select flag from target_table 
> where p_date = '20220724'");
>    List<Row> results = 
> CollectionUtil.iteratorToList(flinkTable.execute().collect());
>     assertEquals(
>             "[false]", results.toString());
> } {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to