This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 1241a3891 [KYUUBI #4666] Support flink varbinary type in query 
operation
1241a3891 is described below

commit 1241a3891431cda602269bd49dcb8621ad77bbb5
Author: Ruguo Yu <[email protected]>
AuthorDate: Thu Apr 6 09:49:33 2023 +0800

    [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 <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../kyuubi/engine/flink/operation/ExecuteStatement.scala       |  2 +-
 .../scala/org/apache/kyuubi/engine/flink/schema/RowSet.scala   |  3 ++-
 .../kyuubi/engine/flink/operation/FlinkOperationSuite.scala    | 10 ++++++++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/ExecuteStatement.scala
 
b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/ExecuteStatement.scala
index 0438b98d1..de104150f 100644
--- 
a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/ExecuteStatement.scala
+++ 
b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/operation/ExecuteStatement.scala
@@ -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))
diff --git 
a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/schema/RowSet.scala
 
b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/schema/RowSet.scala
index ad83f9c2b..13cf5e717 100644
--- 
a/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/schema/RowSet.scala
+++ 
b/externals/kyuubi-flink-sql-engine/src/main/scala/org/apache/kyuubi/engine/flink/schema/RowSet.scala
@@ -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, _) =>
diff --git 
a/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala
 
b/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala
index 5026fd411..8345d4f9f 100644
--- 
a/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala
+++ 
b/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala
@@ -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)")

Reply via email to