Skip to content

Commit

Permalink
feat: improved error messages for Substrait conversion failures (#221) (
Browse files Browse the repository at this point in the history
  • Loading branch information
rkondakov authored Jan 18, 2024
1 parent 750220e commit 8c70245
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public TypeExpression visitBinaryExpr(final SubstraitTypeParser.BinaryExprContex
case "OR" -> TypeExpression.BinaryOperation.OpType.OR;
case "=" -> TypeExpression.BinaryOperation.OpType.EQ;
case ":=" -> TypeExpression.BinaryOperation.OpType.COVERS;
default -> throw new IllegalStateException();
default -> throw new IllegalStateException("Unexpected value: " + ctx.op.getText());
};
return TypeExpression.BinaryOperation.builder()
.opType(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public Type from(io.substrait.proto.Type type) {
var t = lookup.getType(userDefined.getTypeReference(), extensions);
yield n(userDefined.getNullability()).userDefined(t.uri(), t.name());
}
case USER_DEFINED_TYPE_REFERENCE, KIND_NOT_SET -> throw new UnsupportedOperationException();
case USER_DEFINED_TYPE_REFERENCE -> throw new UnsupportedOperationException(
"Unsupported user defined reference: " + type);
case KIND_NOT_SET -> throw new UnsupportedOperationException("Type is not set: " + type);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.substrait.type.TypeCreator;
import io.substrait.type.TypeVisitor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.calcite.rel.type.RelDataType;
Expand Down Expand Up @@ -328,7 +329,8 @@ private RelDataType t(boolean nullable, SqlTypeName typeName, Integer... props)
case 0 -> typeFactory.createSqlType(typeName);
case 1 -> typeFactory.createSqlType(typeName, props[0]);
case 2 -> typeFactory.createSqlType(typeName, props[0], props[1]);
default -> throw new IllegalArgumentException();
default -> throw new IllegalArgumentException(
"Unexpected properties length: " + Arrays.toString(props));
};

return typeFactory.createTypeWithNullability(baseType, nullable);
Expand Down

0 comments on commit 8c70245

Please sign in to comment.