Skip to content

Commit

Permalink
fix: Add user-friendly error message for SELECT null AS column (#8276)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrrr authored Oct 25, 2021
1 parent 2cb82cd commit 57b7dea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public static LogicalSchema buildProjectionSchema(
} else {
final Expression expression = select.getExpression();
final SqlType type = expressionTypeManager.getExpressionSqlType(expression);
if (type == null) {
throw new IllegalArgumentException("Can't infer a type of null. Please explicitly cast "
+ "it to a required type, e.g. CAST(null AS VARCHAR).");
}
builder.valueColumn(select.getAlias(), type);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@
"message": "Invalid comparison expression 'null' in join '(L.A = null)'. Each side of the join comparision must contain references from exactly one source."
}
},
{
"name": "null as column",
"statements": [
"CREATE STREAM INPUT (COL0 INT KEY) WITH (kafka_topic='test_topic', value_format='JSON');",
"CREATE STREAM OUTPUT AS SELECT COL0, null as COL2 FROM INPUT;"
],
"expectedException": {
"type": "io.confluent.ksql.util.KsqlStatementException",
"message": "Can't infer a type of null. Please explicitly cast it to a required type, e.g. CAST(null AS VARCHAR)."
}
},
{
"name": "null if",
"statements": [
Expand Down

0 comments on commit 57b7dea

Please sign in to comment.