Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid CASTed timestamps as strings are not seen as "null" by IFNULL. #9311

Closed
jnh5y opened this issue Jul 18, 2022 · 1 comment
Closed
Assignees
Labels
bug P0 Denotes must-have for a given milestone streaming-engine Tickets owned by the ksqlDB Streaming Team

Comments

@jnh5y
Copy link
Member

jnh5y commented Jul 18, 2022

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

CREATE STREAM test (id INT KEY, data STRING) WITH (kafka_topic='test', key_format='json', value_format='json');
// Insert a good record: 
INSERT INTO test VALUES (1, '2022-01-01');
// Insert a bad record: 
INSERT INTO test VALUES (2, 'xxxx');
INSERT INTO test VALUES (3, null);
// Substitute null for parsed timestamp and see the result: 
SELECT  ifnull(cast(PARSE_DATE(null, 'yyyy-MM-dd') as string),'1900-01-01') from test;```

Output:

```+------------------------------------------------------------------------------+
|KSQL_COL_0                                                                    |
+------------------------------------------------------------------------------+
|2022-01-01                                                                    |
|null                                                                          |
|1900-01-01                                                                    |
Query terminated

Expected behavior
Non-null values.

@jnh5y jnh5y added bug needs-triage streaming-engine Tickets owned by the ksqlDB Streaming Team labels Jul 18, 2022
@jnh5y
Copy link
Member Author

jnh5y commented Jul 18, 2022

@stevenpyzhang suggests a fix like this here:

String code = genCastCode(expr,to);
      code = evaluateOrReturnNull(code, node.getType().toString());
      return Pair.of(code, to);```

@colinhicks colinhicks added the P0 Denotes must-have for a given milestone label Jul 19, 2022
@colinhicks colinhicks removed their assignment Jul 19, 2022
@jnh5y jnh5y self-assigned this Jul 19, 2022
jnh5y added a commit that referenced this issue Jul 25, 2022
jnh5y added a commit that referenced this issue Jul 26, 2022
* fix: Map invalid casts to null.

Addresses #9311
@jnh5y jnh5y closed this as completed Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P0 Denotes must-have for a given milestone streaming-engine Tickets owned by the ksqlDB Streaming Team
Projects
None yet
Development

No branches or pull requests

2 participants