Skip to content

Commit

Permalink
[KYUUBI #5969] Trino engine add default schema
Browse files Browse the repository at this point in the history
# 🔍 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 🔖

- [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 ⚰️

#### Behavior With This Pull Request 🎉

#### 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

dfc987e [senmiaoliu] trino engine add default result schema

Authored-by: senmiaoliu <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit fcad8b5)
Signed-off-by: Cheng Pan <[email protected]>
  • Loading branch information
lsm1 authored and pan3793 committed Jan 15, 2024
1 parent baed87c commit 583d616
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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()
Expand Down

0 comments on commit 583d616

Please sign in to comment.