You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "thomasg19930417 (via GitHub)" <gi...@apache.org> on 2023/02/17 04:56:36 UTC
[GitHub] [kyuubi] thomasg19930417 opened a new pull request, #4354: [Kyuubi#4343] Add support initializationSQLs from file
thomasg19930417 opened a new pull request, #4354:
URL: https://github.com/apache/kyuubi/pull/4354
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/CONTRIBUTING.html
2. If the PR is related to an issue in https://github.com/apache/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
### _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/develop_tools/testing.html#running-tests) locally before make a pull request
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#discussion_r1109519040
##########
kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala:
##########
@@ -1391,6 +1393,30 @@ object KyuubiConf {
.toSequence(";")
.createWithDefault(Nil)
+ val ENGINE_INITIALIZE_SQL_TYPE: ConfigEntry[String] =
+ buildConf("kyuubi.engine.initialize.sql.type")
+ .doc(s"When set kyuubi.engine.initialize.sql.type=${InitSqlType.PATH}" +
+ s",you can use the hdfs path set ${ENGINE_SESSION_INITIALIZE_SQL} " +
+ s"and ${ENGINE_INITIALIZE_SQL}")
+ .version("1.6.2")
Review Comment:
it should be 1.8.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] thomasg19930417 commented on pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "thomasg19930417 (via GitHub)" <gi...@apache.org>.
thomasg19930417 commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-1436804989
@bowenliang123
At present, initialization sql is controlled by two parameters, kyuubi.engine.initialize.sql and kyuubi.engine.session.initialize.sql. These two configurations are configured in kyuubi-defult. Assuming that there are many initial udf functions to be created, I think it would be better to configure them in a separate file, Therefore, I added a parameter kyuubi.engine.initialize.sql.type here to control whether to initialize or read the initialized sql from the file
About initSql, I think the current implementation only supports sql.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] thomasg19930417 commented on pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "thomasg19930417 (via GitHub)" <gi...@apache.org>.
thomasg19930417 commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-1436802818
> @thomasg19930417 Can you show more detailed concerns and add more description to this PR, including and not limited to the purpose, the changes, the config it provides, the range this PR covering and the consequence and sequence of them.
>
> As for me, I would suggest,
>
> 1. provide a config to decide the source(s) type of initial SQLs, rather than just chaining them in preset oreder
> 2. please clarify the source type you suggested to support, local file, any remote filesystem or else. HDFS from the issue description might not be urgent for first choice to introduced.
> 3. the limitation to the path(s), either one or more paths supported, any other limit to this.
> 4. what's the init sql file meant or treated to non-SQL language type, as Scala, Python and etc also supported now in Kyuubi.
> @thomasg19930417 Can you show more detailed concerns and add more description to this PR, including and not limited to the purpose, the changes, the config it provides, the range this PR covering and the consequence and sequence of them.
>
> As for me, I would suggest,
>
> 1. provide a config to decide the source(s) type of initial SQLs, rather than just chaining them in preset oreder
> 2. please clarify the source type you suggested to support, local file, any remote filesystem or else. HDFS from the issue description might not be urgent for first choice to introduced.
> 3. the limitation to the path(s), either one or more paths supported, any other limit to this.
> 4. what's the init sql file meant or treated to non-SQL language type, as Scala, Python and etc also supported now in Kyuubi.
At present, initialization sql is controlled by two parameters, kyuubi.engine.initialize.sql and kyuubi.engine.session.initialize.sql. These two configurations are configured in kyuubi-defult. Assuming that there are many initial udf functions to be created, I think it would be better to configure them in a separate file, Therefore, I added a parameter kyuubi.engine.initialize.sql.type here to control whether to initialize or read the initialized sql from the file
About initSql, I think the current implementation only supports sql.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] pan3793 commented on pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-1434389160
@thomasg19930417 Thanks for your contribution, some tips for new contributors, please follow the [developer guide](https://kyuubi.readthedocs.io/en/master/develop_tools/developer.html#format-all-code) to fix code style and regenerate docs since you add new configurations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] thomasg19930417 commented on a diff in pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "thomasg19930417 (via GitHub)" <gi...@apache.org>.
thomasg19930417 commented on code in PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#discussion_r1110536914
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala:
##########
@@ -52,7 +59,49 @@ object KyuubiSparkUtil extends Logging {
}
}
+ def getInitializeSql(sparkSession: SparkSession, config: Seq[String]): Seq[String] = {
+
+ def getSqlTextFromFile(path: Option[String]): Seq[String] = {
+ path.map(filePath => {
+ var reader: BufferedReader = null
+ try {
+ info(s"========>load init sql from file: ${filePath}")
+ val engineInitSqlFilePath = new Path(filePath)
+ val hadoopConf = sparkSession.sparkContext.hadoopConfiguration
+ val fs: FileSystem = engineInitSqlFilePath.getFileSystem(hadoopConf)
+ if (fs.exists(engineInitSqlFilePath)) {
+ val sqlInputStream: FSDataInputStream = fs.open(engineInitSqlFilePath)
+ reader = new BufferedReader(new InputStreamReader(sqlInputStream))
+ // Filter out the sql using '--' comment
+ val sqlText = ListBuffer[String]()
+ Stream.continually(reader.readLine())
+ .takeWhile(null != _).filter(item => !item.startsWith("--") && item.length > 0)
+ .map(item => item.replace(";", "")).foreach(item => sqlText.append(item))
Review Comment:
OK, I will modify it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] bowenliang123 commented on pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-1435691760
@thomasg19930417 Can you show more detailed concerns and add more description to this PR, including and not limited to the purpose, the changes, the config it provides, the range this PR covering and the consequence and sequence of them.
As for me, I would suggest,
1. provide a config to decide the source(s) type of initial SQLs, rather than just chaining them in preset oreder
2. please clarify the source type you suggested to support, local file, any remote filesystem or else. HDFS from the issue description might not be urgent for first choice to introduced.
3. the limitation to the path(s), either one or more paths supported, any other limit to this.
4. what's the init sql file meant or treated to non-SQL language type, as Scala, Python and etc also supported now in Kyuubi.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] thomasg19930417 commented on pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "thomasg19930417 (via GitHub)" <gi...@apache.org>.
thomasg19930417 commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-1437818112
@pan3793
I resubmitted the code. Thank you for your help under review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
Re: [PR] [KYUUBI#4343] Add support initializationSQLs from file [kyuubi]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-2803411230
Thanks for the PR! This PR is being closed due to inactivity. This isn't a judgement on the merit of the PR in any way. If this is still an issue with the latest version of Kyuubi, please reopen it and ask a committer to remove the Stale tag!
Thank you for using Kyuubi!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
Re: [PR] [KYUUBI#4343] Add support initializationSQLs from file [kyuubi]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
URL: https://github.com/apache/kyuubi/pull/4354
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] codecov-commenter commented on pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#issuecomment-1437849143
# [Codecov](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#4354](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3d53dbd) into [branch-1.6](https://codecov.io/gh/apache/kyuubi/commit/3405586590cfe8adb4c08dca5385e6d3ba4e766c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3405586) will **increase** coverage by `0.01%`.
> The diff coverage is `32.58%`.
```diff
@@ Coverage Diff @@
## branch-1.6 #4354 +/- ##
================================================
+ Coverage 51.44% 51.46% +0.01%
Complexity 13 13
================================================
Files 470 470
Lines 26380 26457 +77
Branches 3660 3679 +19
================================================
+ Hits 13571 13615 +44
- Misses 11507 11532 +25
- Partials 1302 1310 +8
```
| [Impacted Files](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...in/java/org/apache/hive/beeline/KyuubiBeeLine.java](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWhpdmUtYmVlbGluZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaGl2ZS9iZWVsaW5lL0t5dXViaUJlZUxpbmUuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...n/java/org/apache/hive/beeline/KyuubiCommands.java](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWhpdmUtYmVlbGluZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvaGl2ZS9iZWVsaW5lL0t5dXViaUNvbW1hbmRzLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...g/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9LeXV1YmlTcGFya1V0aWwuc2NhbGE=) | `51.51% <6.89%> (-34.98%)` | :arrow_down: |
| [...in/scala/org/apache/kyuubi/config/KyuubiConf.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jb25maWcvS3l1dWJpQ29uZi5zY2FsYQ==) | `96.58% <64.28%> (-0.46%)` | :arrow_down: |
| [...c/main/java/org/apache/kyuubi/jdbc/hive/Utils.java](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWhpdmUtamRiYy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUva3l1dWJpL2pkYmMvaGl2ZS9VdGlscy5qYXZh) | `39.48% <87.50%> (+1.72%)` | :arrow_up: |
| [...rg/apache/kyuubi/engine/spark/SparkSQLEngine.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9TcGFya1NRTEVuZ2luZS5zY2FsYQ==) | `75.29% <100.00%> (+0.29%)` | :arrow_up: |
| [.../engine/spark/session/SparkSQLSessionManager.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9zZXNzaW9uL1NwYXJrU1FMU2Vzc2lvbk1hbmFnZXIuc2NhbGE=) | `79.01% <100.00%> (+0.53%)` | :arrow_up: |
| [...he/kyuubi/engine/spark/shim/CatalogShim\_v2\_4.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9zaGltL0NhdGFsb2dTaGltX3YyXzQuc2NhbGE=) | `67.18% <100.00%> (+3.12%)` | :arrow_up: |
| [...he/kyuubi/engine/spark/shim/CatalogShim\_v3\_0.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZXh0ZXJuYWxzL2t5dXViaS1zcGFyay1zcWwtZW5naW5lL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2VuZ2luZS9zcGFyay9zaGltL0NhdGFsb2dTaGltX3YzXzAuc2NhbGE=) | `81.11% <100.00%> (-0.42%)` | :arrow_down: |
| [.../kyuubi/server/mysql/constant/MySQLErrorCode.scala](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2ZXIvbXlzcWwvY29uc3RhbnQvTXlTUUxFcnJvckNvZGUuc2NhbGE=) | `13.84% <0.00%> (-6.16%)` | :arrow_down: |
| ... and [13 more](https://codecov.io/gh/apache/kyuubi/pull/4354?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#discussion_r1109517689
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala:
##########
@@ -52,7 +59,49 @@ object KyuubiSparkUtil extends Logging {
}
}
+ def getInitializeSql(sparkSession: SparkSession, config: Seq[String]): Seq[String] = {
+
+ def getSqlTextFromFile(path: Option[String]): Seq[String] = {
+ path.map(filePath => {
+ var reader: BufferedReader = null
+ try {
+ info(s"========>load init sql from file: ${filePath}")
+ val engineInitSqlFilePath = new Path(filePath)
+ val hadoopConf = sparkSession.sparkContext.hadoopConfiguration
+ val fs: FileSystem = engineInitSqlFilePath.getFileSystem(hadoopConf)
+ if (fs.exists(engineInitSqlFilePath)) {
+ val sqlInputStream: FSDataInputStream = fs.open(engineInitSqlFilePath)
+ reader = new BufferedReader(new InputStreamReader(sqlInputStream))
+ // Filter out the sql using '--' comment
+ val sqlText = ListBuffer[String]()
+ Stream.continually(reader.readLine())
+ .takeWhile(null != _).filter(item => !item.startsWith("--") && item.length > 0)
+ .map(item => item.replace(";", "")).foreach(item => sqlText.append(item))
Review Comment:
The implementation looks fragile ... have you considered
```
select regexp_replace(html, '\\\\n|\\\\\t|\\\\\r', ';')
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4354: [KYUUBI#4343] Add support initializationSQLs from file
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4354:
URL: https://github.com/apache/kyuubi/pull/4354#discussion_r1109565560
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala:
##########
@@ -52,7 +59,49 @@ object KyuubiSparkUtil extends Logging {
}
}
+ def getInitializeSql(sparkSession: SparkSession, config: Seq[String]): Seq[String] = {
+
+ def getSqlTextFromFile(path: Option[String]): Seq[String] = {
+ path.map(filePath => {
+ var reader: BufferedReader = null
+ try {
+ info(s"========>load init sql from file: ${filePath}")
Review Comment:
please remove the leading `========>`, and keep log clear and simple
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org