Mateusz Jerzyk created KYLIN-4731: ------------------------------------- Summary: Kylin query failing with 'null while executing SQL' Key: KYLIN-4731 URL: https://issues.apache.org/jira/browse/KYLIN-4731 Project: Kylin Issue Type: Bug Components: Query Engine Affects Versions: v3.1.0 Reporter: Mateusz Jerzyk Attachments: error_logs, test_null_date_lookup_cube.json, test_null_date_lookup_model.json
Hello, we've recently upgraded Kylin from version 3.0.2 to 3.1.0 and some of the queries that worked well before started returning an error message `null while executing SQL: ...`. After some investigation, we've found that the problem happens while executing left join on a date column, where the value in the left table is null and it is defined as derived dimension in the cube. Here are the steps to reproduce the issue: # Creating tables in Hive and filling it with some values {code:java} CREATE TABLE `default.test_null_date` ( `key1` string, `key2` string, `date_segment` date, `other_date` date ) STORED AS ORC; CREATE TABLE `default.test_null_date_lookup` ( `date` date, `some_field` string ) STORED AS ORC; INSERT INTO TABLE default.test_null_date VALUES ('SOMETHING', 'SOMETHING', '2020-01-01', null), ('SOMETHING', 'SOMETHING', '2020-01-01', '2020-01-02'), ('SOMETHING', 'SOMETHING', '2020-01-01', '2020-01-03'); INSERT INTO TABLE default.test_null_date_lookup VALUES ('2020-01-01', 'SOMETHING'), ('2020-01-02', 'SOMETHING'), ('2020-01-03', 'SOMETHING'); {code} # Model definition in Kylin [^test_null_date_lookup_model.json] # Cube definition in Kylin [^test_null_date_lookup_cube.json] # The example query that fails {code:java} SELECT COUNT(*), "SOME_FIELD" FROM "DEFAULT"."TEST_NULL_DATE" LEFT JOIN "DEFAULT"."TEST_NULL_DATE_LOOKUP" ON "TEST_NULL_DATE"."OTHER_DATE" = "TEST_NULL_DATE_LOOKUP"."DATE" GROUP BY "SOME_FIELD"{code} # Please see also logs of query execution [^error_logs] We think that the issue was introduced here: [https://github.com/apache/kylin/commit/6bd5b43bb06b6bf19d1a096d99146396aab8d5b2#diff-fa3dad06dc4edd4d139777c53492c9c2R303] where the method [https://github.com/apache/kylin/blob/kylin-3.1.0/core-common/src/main/java/org/apache/kylin/common/util/DateFormat.java#L158-L168] is not protected from getting null values and throws NullPointerException -- This message was sent by Atlassian Jira (v8.3.4#803005)