You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2024/01/15 02:20:15 UTC

(kyuubi) branch master updated: [KYUUBI #5969] Trino engine add default schema

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 fcad8b520 [KYUUBI #5969] Trino engine add default schema
fcad8b520 is described below

commit fcad8b520cd2e028b9103aaaf06fe9d5e7a337f7
Author: senmiaoliu <se...@trip.com>
AuthorDate: Mon Jan 15 10:20:06 2024 +0800

    [KYUUBI #5969] Trino engine add default schema
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pull request fixes #5969
    
    ## Describe Your Solution ๐Ÿ”ง
    
    Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
    
    ## Types of changes :bookmark:
    
    - [x] Bugfix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing functionality to change)
    
    ## Test Plan ๐Ÿงช
    
    #### Behavior Without This Pull Request :coffin:
    
    #### Behavior With This Pull Request :tada:
    
    #### Related Unit Tests
    
    ---
    
    # Checklist ๐Ÿ“
    
    - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #5971 from lsm1/branch-kyuubi-trino-schema.
    
    Closes #5969
    
    dfc987e03 [senmiaoliu] trino engine add default result schema
    
    Authored-by: senmiaoliu <se...@trip.com>
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 .../main/scala/org/apache/kyuubi/engine/trino/TrinoStatement.scala | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/TrinoStatement.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/TrinoStatement.scala
index 2508f326e..65a0a3cde 100644
--- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/TrinoStatement.scala
+++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/TrinoStatement.scala
@@ -25,6 +25,7 @@ import scala.concurrent.ExecutionContext
 
 import com.google.common.base.Verify
 import io.trino.client.ClientSession
+import io.trino.client.ClientTypeSignature
 import io.trino.client.Column
 import io.trino.client.StatementClient
 import io.trino.client.StatementClientFactory
@@ -46,6 +47,9 @@ class TrinoStatement(
     sql: String,
     operationLog: Option[OperationLog]) extends Logging {
 
+  private val defaultSchema: List[Column] =
+    List(new Column("Result", "VARCHAR", new ClientTypeSignature("VARCHAR")))
+
   private lazy val trino = StatementClientFactory
     .newStatementClient(trinoContext.httpClient, trinoContext.clientSession.get, sql)
 
@@ -68,6 +72,9 @@ class TrinoStatement(
       val columns = results.getColumns()
       if (columns != null) {
         info(s"Execute with Trino query id: ${results.getId}")
+        if (columns.isEmpty) {
+          return defaultSchema
+        }
         return columns.asScala.toList
       }
       trino.advance()