Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ public Optional<DataType> inferArgumentType(
if (Objects.equals(expectedNullability, Boolean.FALSE) && actualType.isNullable()) {
return callContext.fail(
throwOnFailure,
"Unsupported argument type. Expected nullable type of family '%s' but actual type was '%s'.",
"Unsupported argument type. Expected NOT NULL type of family '%s' but actual type was '%s'.",
expectedFamily,
actualType);
}

// type is part of the family
if (actualType.getTypeRoot().getFamilies().contains(expectedFamily)) {
if (Objects.equals(expectedNullability, Boolean.TRUE) && !actualType.isNullable()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful for the issue text / PR text to give SQL examples of the reported issue and the expected behaviour - currently descriptions are very low level and require table planner knowledge. This would help users find and identify this issue at the SQL level

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion! I have updated the PR description. Please let me know if you have any further feedback.

return Optional.of(actualDataType.nullable());
}
return Optional.of(actualDataType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,23 +549,33 @@ ANY, explicit(DataTypes.INT())
sequence(
logical(LogicalTypeFamily.CHARACTER_STRING, true),
logical(LogicalTypeFamily.EXACT_NUMERIC),
logical(LogicalTypeFamily.EXACT_NUMERIC, true),
logical(LogicalTypeFamily.APPROXIMATE_NUMERIC),
logical(LogicalTypeFamily.APPROXIMATE_NUMERIC),
logical(LogicalTypeFamily.APPROXIMATE_NUMERIC, false)))
.calledWithArgumentTypes(
DataTypes.NULL(),
DataTypes.TINYINT(),
DataTypes.SMALLINT().notNull(),
DataTypes.INT(),
DataTypes.BIGINT().notNull(),
DataTypes.DECIMAL(10, 2).notNull())
.expectSignature(
"f(<CHARACTER_STRING NULL>, <EXACT_NUMERIC>, <APPROXIMATE_NUMERIC>, <APPROXIMATE_NUMERIC>, <APPROXIMATE_NUMERIC NOT NULL>)")
"f(<CHARACTER_STRING NULL>, <EXACT_NUMERIC>, <EXACT_NUMERIC NULL>, <APPROXIMATE_NUMERIC>, <APPROXIMATE_NUMERIC>, <APPROXIMATE_NUMERIC NOT NULL>)")
.expectArgumentTypes(
DataTypes.VARCHAR(1),
DataTypes.TINYINT(),
DataTypes.SMALLINT(),
DataTypes.DOUBLE(), // widening with preserved nullability
DataTypes.DOUBLE().notNull(), // widening with preserved nullability
DataTypes.DOUBLE().notNull()),
TestSpec.forStrategy(
"Logical type family with invalid nullability",
sequence(logical(LogicalTypeFamily.EXACT_NUMERIC, false)))
.calledWithArgumentTypes(DataTypes.INT())
.expectSignature("f(<EXACT_NUMERIC NOT NULL>)")
.expectErrorMessage(
"Unsupported argument type. Expected NOT NULL type of family 'EXACT_NUMERIC' but actual type was 'INT'."),
TestSpec.forStrategy(
"Logical type family with invalid type",
sequence(logical(LogicalTypeFamily.EXACT_NUMERIC)))
Expand Down