[KYUUBI #4666] Support flink varbinary type in query operation

### _Why are the changes needed?_
closed #1770
Support flink `varbinary` type in query operation

### _How was this patch tested?_
- [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #4666 from yuruguo/support-flink-varbinary-type.

Closes #4666

e05675e03 [Ruguo Yu] Support flink varbinary type in query operation

Authored-by: Ruguo Yu <jiang7chengzitc@163.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
Ruguo Yu 2023-04-06 09:49:33 +08:00 committed by Cheng Pan
parent 015b800156
commit 1241a38914
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D
3 changed files with 13 additions and 2 deletions

View File

@ -177,7 +177,7 @@ class ExecuteStatement(
row.setField(i, d.toObjectArray(arrayType.getElementType))
case _ =>
}
case _: BinaryType =>
case _: BinaryType | _: VarBinaryType =>
row.setField(i, r.getBinary(i))
case _: BigIntType =>
row.setField(i, r.getLong(i))

View File

@ -307,6 +307,7 @@ object RowSet {
case _: MapType => TTypeId.MAP_TYPE
case _: RowType => TTypeId.STRUCT_TYPE
case _: BinaryType => TTypeId.BINARY_TYPE
case _: VarBinaryType => TTypeId.BINARY_TYPE
case _: TimeType => TTypeId.STRING_TYPE
case t @ (_: ZonedTimestampType | _: LocalZonedTimestampType | _: MultisetType |
_: YearMonthIntervalType | _: DayTimeIntervalType) =>
@ -369,7 +370,7 @@ object RowSet {
// Only match string in nested type values
"\"" + s + "\""
case (bin: Array[Byte], _: BinaryType) =>
case (bin: Array[Byte], _ @(_: BinaryType | _: VarBinaryType)) =>
new String(bin, StandardCharsets.UTF_8)
case (other, _) =>

View File

@ -812,6 +812,16 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper {
}
}
test("execute statement - select varbinary") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("select cast('kyuubi' as varbinary)")
assert(resultSet.next())
assert(resultSet.getString(1) == "kyuubi")
val metaData = resultSet.getMetaData
assert(metaData.getColumnType(1) === java.sql.Types.BINARY)
}
}
test("execute statement - select float") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SELECT cast(0.1 as float)")