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 @@ -562,6 +562,10 @@ public static Literal getLiteralByMysqlType(MysqlColType mysqlType, boolean isUn
case MYSQL_TYPE_TIMESTAMP2:
literal = handleDateTimeLiteral(data);
break;
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VARSTRING:
literal = handleStringLiteral(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.doris.nereids.trees.expressions;

import org.apache.doris.catalog.MysqlColType;
import org.apache.doris.mysql.MysqlSerializer;
import org.apache.doris.nereids.trees.expressions.literal.ArrayLiteral;
import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
Expand All @@ -36,6 +38,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -57,6 +61,28 @@ public void testEqual() {
Assertions.assertTrue(Literal.of(false) instanceof BooleanLiteral);
}

@Test
public void testMysqlBlobParameter() {
String value = "Doris 数据";
for (MysqlColType mysqlType : Arrays.asList(
MysqlColType.MYSQL_TYPE_TINY_BLOB,
MysqlColType.MYSQL_TYPE_MEDIUM_BLOB,
MysqlColType.MYSQL_TYPE_LONG_BLOB,
MysqlColType.MYSQL_TYPE_BLOB)) {
MysqlSerializer serializer = MysqlSerializer.newInstance();
serializer.writeLenEncodedString(value);
serializer.writeInt1(0x7f);
ByteBuffer data = serializer.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN);

Literal literal = Literal.getLiteralByMysqlType(mysqlType, false, data);

Assertions.assertTrue(literal instanceof StringLiteral, mysqlType.name());
Assertions.assertEquals(value, literal.getStringValue(), mysqlType.name());
Assertions.assertEquals(1, data.remaining(), mysqlType.name());
Assertions.assertEquals(0x7f, Byte.toUnsignedInt(data.get()), mysqlType.name());
}
}

@Test
public void testGetResultExpressionArrayInt() {
int num = 10;
Expand Down