lowka commented on code in PR #5145:
URL: https://github.com/apache/ignite-3/pull/5145#discussion_r1939301095
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/TypeUtils.java:
##########
@@ -735,6 +743,15 @@ public static <RowT> RowT
validateCharactersOverflowAndTrimIfPossible(
RelDataType colType = rowType.getFieldList().get(i).getType();
Object data = rowHandler.get(i, row);
+ if (BINARY_TYPES.contains(colType.getSqlTypeName()) && data !=
null) {
+ assert data instanceof ByteString;
+ assert colType.getPrecision() !=
RelDataType.PRECISION_NOT_SPECIFIED;
+
+ if (((ByteString) data).length() > colType.getPrecision()) {
+ throw new SqlException(STMT_VALIDATION_ERR, format("Value
too long for type binary({})", colType.getPrecision()));
Review Comment:
Perhaps we should use the same error message we use in case of string errors:
> "Value too long for type: " + colType
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/TypeUtils.java:
##########
@@ -735,6 +743,15 @@ public static <RowT> RowT
validateCharactersOverflowAndTrimIfPossible(
RelDataType colType = rowType.getFieldList().get(i).getType();
Object data = rowHandler.get(i, row);
+ if (BINARY_TYPES.contains(colType.getSqlTypeName()) && data !=
null) {
+ assert data instanceof ByteString;
+ assert colType.getPrecision() !=
RelDataType.PRECISION_NOT_SPECIFIED;
+
+ if (((ByteString) data).length() > colType.getPrecision()) {
+ throw new SqlException(STMT_VALIDATION_ERR, format("Value
too long for type binary({})", colType.getPrecision()));
+ }
+ }
+
// Skip null values and non-character types.
if (!CHAR_TYPES.contains(colType.getSqlTypeName()) || data ==
null) {
Review Comment:
I think it would be better just to skip null values first, and only it is
not null do type checks.
// if data is null -> skip
// if binary types -> ...
// if char types -> ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]