Jing Zhang created FLINK-28741:
----------------------------------

             Summary: Unexpected result if insert 'false' to boolean column
                 Key: FLINK-28741
                 URL: https://issues.apache.org/jira/browse/FLINK-28741
             Project: Flink
          Issue Type: Bug
          Components: Connectors / Hive
            Reporter: Jing Zhang


Using hive dialect to insert a string 'false' to boolean column, the result is 
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