morningman commented on code in PR #69567:
URL: https://github.com/apache/doris/pull/69567#discussion_r4366910063
##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonWriteBinding.java:
##########
@@ -165,6 +187,9 @@ static Map<String, String>
resolveStaticPartition(FileStoreTable table, Connecto
if (type.getTypeRoot() == DataTypeRoot.CHAR &&
charPaddedFields.test(canonicalName)) {
value = padChar(value, ((CharType) type).getLength());
}
+ if (isBinary(type)) {
+ value = binaryStaticValue(canonicalName, value);
Review Comment:
Confirmed, thanks. Paimon BINARY(n) / VARBINARY(n) map to Doris
VARBINARY(n), while the parser types `X'4142'` as VARBINARY of the maximum
length, and `castStaticPartitionSpec` cast it with `Literal.checkedCastTo`,
which casts a VARBINARY to no other length. The rows were not affected:
BindSink's cast of a row value is not folded on FE and BE keeps the bytes. So
only the static spec failed, only BYTES reached the decoding this PR adds, and
the unit test, which fed the cast value through a fake handle, missed it.
Fixed in `2c95fb189ac`: `castStaticPartitionSpec` gives a binary literal the
VARBINARY type of its column with its bytes unchanged, as BE does for the rows.
I also checked what Paimon 2.1.0 makes of the value afterwards (its static
overwrite parses it with `TypeUtils.castFromString`): for BINARY(n) it keeps
the bytes whatever their length, as the rows keep them; for VARBINARY(n) it
fails the commit, after the BE has written its files, when the bytes are longer
than n, so the connector now rejects such a value while the write is planned.
`PluginDrivenTableSinkBindingTest#staticPartitionBinaryValueKeepsItsBytesForAColumnOfAnyLength`
casts `X'41'`, `X'4142'` and `X'414243'` for a VARBINARY(2) column through the
sink binding (without the fix it fails with `Cast from 4142 to VARBINARY(2) not
supported`), and
`PaimonWriteBindingTest#staticBinaryPartitionKeepsTheLengthOfTheBytes` covers
both length rules. `binaryStaticValue` also moved so that `padChar` has its
Javadoc again.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]