This is an automated email from the ASF dual-hosted git repository. chengpan pushed a commit to branch branch-1.8 in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.8 by this push: new 1814eaa7e [KYUUBI #5282] Support configure Trino session conf in `kyuubi-default.conf` 1814eaa7e is described below commit 1814eaa7e11369afd03871db0c2082c9dda3eba4 Author: liupeiyue <liupei...@yy.com> AuthorDate: Tue Oct 24 16:19:44 2023 +0800 [KYUUBI #5282] Support configure Trino session conf in `kyuubi-default.conf` ### _Why are the changes needed?_ Refer to spark and flink settings conf, support configure Trino session conf in kyuubi-default.conf issue : https://github.com/apache/kyuubi/issues/5282 ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests) locally before make a pull request ### _Was this patch authored or co-authored using generative AI tooling?_ No Closes #5283 from ASiegeLion/kyuubi-master-trino. Closes #5282 87a3f57b4 [Cheng Pan] Apply suggestions from code review effdd79f4 [liupeiyue] [KYUUBI #5282]Add trino's session conf to kyuubi-default.xml 399a200f7 [liupeiyue] [KYUUBI #5282]Add trino's session conf to kyuubi-default.xml 7462b32c2 [liupeiyue] [KYUUBI #5282]Add trino's session conf to kyuubi-default.xml--Update documentation 5295f5f94 [liupeiyue] [KYUUBI #5282]Add trino's session conf to kyuubi-default.xml Lead-authored-by: liupeiyue <liupei...@yy.com> Co-authored-by: Cheng Pan <pan3...@gmail.com> Signed-off-by: Cheng Pan <cheng...@apache.org> (cherry picked from commit 9a409956a1566220867518ee60bf60e20dc5636c) Signed-off-by: Cheng Pan <cheng...@apache.org> --- docs/configuration/settings.md | 27 +++++++++++++++++++ .../engine/trino/session/TrinoSessionImpl.scala | 12 ++++++++- .../kyuubi/config/AllKyuubiConfiguration.scala | 30 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/docs/configuration/settings.md b/docs/configuration/settings.md index bf96c5996..d7cea9789 100644 --- a/docs/configuration/settings.md +++ b/docs/configuration/settings.md @@ -533,6 +533,33 @@ Setting them in the JDBC Connection URL supplies session-specific for each SQL e Please refer to the Flink official online documentation for [SET Statements](https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/sql/set/) +## Trino Configurations + +### Via config.properties + +Setting them in `$TRINO_HOME/etc/config.properties` supplies with default values for SQL engine application. Available properties can be found at Trino official online documentation for [Trino Configurations](https://trino.io/docs/current/admin/properties.html) + +### Via kyuubi-defaults.conf + +Setting them in `$KYUUBI_HOME/conf/kyuubi-defaults.conf` supplies with default values for SQL engine application too. You can use properties with the additional prefix `trino.` to override settings in `$TRINO_HOME/etc/config.properties`. + +For example: + +``` +trino.query_max_stage_count 500 +trino.parse_decimal_literals_as_double true +``` + +The below options in `kyuubi-defaults.conf` will set `query_max_stage_count: 500` and `parse_decimal_literals_as_double: true` into trino session properties. + +### Via JDBC Connection URL + +Setting them in the JDBC Connection URL supplies session-specific for each SQL engine. For example: ```jdbc:hive2://localhost:10009/default;#trino.query_max_stage_count=500;trino.parse_decimal_literals_as_double=true``` + +### Via SET Statements + +Please refer to the Trino official online documentation for [SET Statements](https://trino.io/docs/current/sql/set-session.html) + ## Logging Kyuubi uses [log4j](https://logging.apache.org/log4j/2.x/) for logging. You can configure it using `$KYUUBI_HOME/conf/log4j2.xml`, see `$KYUUBI_HOME/conf/log4j2.xml.template` as an example. diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala index 362ee3ed0..0b3ac01a9 100644 --- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala +++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala @@ -22,6 +22,8 @@ import java.time.ZoneId import java.util.{Collections, Locale, Optional} import java.util.concurrent.TimeUnit +import scala.collection.JavaConverters._ + import io.airlift.units.Duration import io.trino.client.ClientSession import io.trino.client.OkHttpUtil @@ -89,6 +91,8 @@ class TrinoSessionImpl( val clientRequestTimeout = sessionConf.get(TrinoConf.CLIENT_REQUEST_TIMEOUT) + val properties = getTrinoSessionConf(sessionConf).asJava + new ClientSession( URI.create(connectionUrl), username, @@ -104,7 +108,7 @@ class TrinoSessionImpl( Locale.getDefault, Collections.emptyMap(), Collections.emptyMap(), - Collections.emptyMap(), + properties, Collections.emptyMap(), Collections.emptyMap(), null, @@ -170,6 +174,12 @@ class TrinoSessionImpl( resultSet.next().head.toString } + private def getTrinoSessionConf(sessionConf: KyuubiConf): Map[String, String] = { + val trinoSessionConf = sessionConf.getAll.filterKeys(_.startsWith("trino.")) + .map { case (k, v) => (k.stripPrefix("trino."), v) } + trinoSessionConf.toMap + } + override def close(): Unit = { sessionEvent.endTime = System.currentTimeMillis() EventBus.post(sessionEvent) diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/config/AllKyuubiConfiguration.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/config/AllKyuubiConfiguration.scala index f53fb3a61..8c0806ba3 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/config/AllKyuubiConfiguration.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/config/AllKyuubiConfiguration.scala @@ -177,6 +177,36 @@ class AllKyuubiConfiguration extends KyuubiFunSuite { """Please refer to the Flink official online documentation for [SET Statements] |(https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/sql/set/)""" + builder ++= + """## Trino Configurations + |### Via config.properties""" += """Setting them in `$TRINO_HOME/etc/config.properties` + | + | supplies with default values for SQL engine application. + | Available properties can be found at Trino official online documentation for + | [Trino Configurations] + |(https://trino.io/docs/current/admin/properties.html)""" += + "### Via kyuubi-defaults.conf" += + """Setting them in `$KYUUBI_HOME/conf/kyuubi-defaults.conf` + | supplies with default values for SQL engine application too. + | You can use properties with the additional prefix `trino.` to override settings in + | `$TRINO_HOME/etc/config.properties`.""" ++= + """ + |For example: + |``` + |trino.query_max_stage_count 500 + |trino.parse_decimal_literals_as_double true + |```""" += + """The below options in `kyuubi-defaults.conf` will set `query_max_stage_count: 500` + | and `parse_decimal_literals_as_double: true` into trino session properties.""" += + "### Via JDBC Connection URL" += + """Setting them in the JDBC Connection URL supplies session-specific + | for each SQL engine. For example: ```jdbc:hive2://localhost:10009/default; + |#trino.query_max_stage_count=500;trino.parse_decimal_literals_as_double=true``` + |""" += + "### Via SET Statements" += + """Please refer to the Trino official online documentation for [SET Statements] + |(https://trino.io/docs/current/sql/set-session.html)""" + builder += "## Logging" += """Kyuubi uses [log4j](https://logging.apache.org/log4j/2.x/) for logging. | You can configure it using `$KYUUBI_HOME/conf/log4j2.xml`, see