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

fix: better error message on illegal arithmetic with NULL values #7554

Merged
merged 13 commits into from
May 20, 2021
Prev Previous commit
Next Next commit
move tests from RQTT to QTT
  • Loading branch information
Chittaranjan Prasad committed May 19, 2021
commit 726bbb3d68cdd1b8e8d6e5e5221457282064b7d5
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,66 @@
}
]
}
},
{
"name": "NULL Arithmetic Behavior - INTEGER addition",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT 1 + NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (1 + null). Arithmetic on types INTEGER and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - MAP addition",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT MAP(1 := 'cat') + NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (MAP(1:='cat') + null). Arithmetic on types MAP<INTEGER, STRING> and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - ARRAY addition",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT Array[1,2,3] + NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (ARRAY[1, 2, 3] + null). Arithmetic on types ARRAY<INTEGER> and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - DECIMAL division",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT 5.0 / NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (5.0 / null). Arithmetic on types DECIMAL(2, 1) and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - NULL NULL multiplication",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT NULL * NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (null * null). Arithmetic on types null and null are not supported.",
"status": 400
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -927,66 +927,6 @@
{"finalMessage":"Limit Reached"}
]}
]
},
{
"name": "NULL Arithmetic Behavior - INTEGER addition",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT 1 + NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (1 + null). Arithmetic on types INTEGER and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - MAP addition",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT MAP(1 := 'cat') + NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (MAP(1:='cat') + null). Arithmetic on types MAP<INTEGER, STRING> and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - ARRAY addition",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT Array[1,2,3] + NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (ARRAY[1, 2, 3] + null). Arithmetic on types ARRAY<INTEGER> and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - DECIMAL division",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT 5.0 / NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (5.0 / null). Arithmetic on types DECIMAL(2, 1) and null are not supported.",
"status": 400
}
},
{
"name": "NULL Arithmetic Behavior - NULL NULL multiplication",
"statements": [
"CREATE STREAM INPUT (ID INT) WITH (kafka_topic='test_topic', value_format='JSON');",
"SELECT NULL * NULL FROM INPUT EMIT CHANGES;"
],
"expectedError": {
"type": "io.confluent.ksql.rest.entity.KsqlErrorMessage",
"message": "Error processing expression: (null * null). Arithmetic on types null and null are not supported.",
"status": 400
}
}
]
}