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 ab3c33312 [KYUUBI #5117] [Minor] Code improvements for Java and Scala
code
ab3c33312 is described below
commit ab3c3331221451dbc01b796f4e729190c6365278
Author: liangbowen <[email protected]>
AuthorDate: Tue Aug 1 11:36:18 2023 +0800
[KYUUBI #5117] [Minor] Code improvements for Java and Scala code
### _Why are the changes needed?_
- remove duplicated assignment for the same variable in adjacent lines in
`FastHiveDecimalImpl`
- replace redundant `putAll` with collection initialization in
`BatchRestApi`
- use `try-with-resources` statement with the reader and avoid declaring
two variables in the same line of code in `KyuubiCommands`
- fix `warning: Tag 'return:' is not recognised` compilation warning in
`KyuubiGetSqlClassification:L53`
### _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
- [x] [Run
test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests)
locally before make a pull request
Closes #5117 from bowenliang123/fastsignum.
Closes #5117
595b5747d [liangbowen] simplify
be530fac4 [liangbowen] fix warning: Tag '@return:' is not recognised
compilation warning in KyuubiGetSqlClassification:L53
249706905 [liangbowen] use try-with-resources in KyuubiCommands
a54a97fdd [liangbowen] remove redundant addAll call to collection
initialization
cc76d5d0f [liangbowen] remove repeated assignment
Authored-by: liangbowen <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../sql/sqlclassification/KyuubiGetSqlClassification.scala | 2 +-
.../main/java/org/apache/hive/beeline/KyuubiCommands.java | 12 ++++--------
.../apache/kyuubi/jdbc/hive/common/FastHiveDecimalImpl.java | 1 -
.../src/main/java/org/apache/kyuubi/client/BatchRestApi.java | 3 +--
4 files changed, 6 insertions(+), 12 deletions(-)
diff --git
a/extensions/spark/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
b/extensions/spark/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
index e8aadc850..b94cdf346 100644
---
a/extensions/spark/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
+++
b/extensions/spark/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/sqlclassification/KyuubiGetSqlClassification.scala
@@ -55,7 +55,7 @@ object KyuubiGetSqlClassification extends Logging {
* You need to make sure that the configuration item:
SQL_CLASSIFICATION_ENABLED
* is true
* @param simpleName: the analyzied_logical_plan's getSimpleName
- * @return: This sql's classification
+ * @return This sql's classification
*/
def getSqlClassification(simpleName: String): String = {
jsonNode.map { json =>
diff --git
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
index af294ac6f..fcfee49ed 100644
---
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
+++
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
@@ -21,6 +21,7 @@ import static
org.apache.kyuubi.jdbc.hive.JdbcConnectionParams.*;
import com.google.common.annotations.VisibleForTesting;
import java.io.*;
+import java.nio.file.Files;
import java.sql.*;
import java.util.*;
import org.apache.hive.beeline.logs.KyuubiBeelineInPlaceUpdateStream;
@@ -86,10 +87,9 @@ public class KyuubiCommands extends Commands {
}
private boolean sourceFileInternal(File sourceFile) throws IOException {
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(sourceFile));
- String lines = null, extra;
+ try (BufferedReader reader = Files.newBufferedReader(sourceFile.toPath()))
{
+ String lines = null;
+ String extra;
while ((extra = reader.readLine()) != null) {
if (beeLine.isComment(extra)) {
continue;
@@ -107,10 +107,6 @@ public class KyuubiCommands extends Commands {
return false;
}
}
- } finally {
- if (reader != null) {
- reader.close();
- }
}
return true;
}
diff --git
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/common/FastHiveDecimalImpl.java
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/common/FastHiveDecimalImpl.java
index d3dba0f7b..65f17e734 100644
---
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/common/FastHiveDecimalImpl.java
+++
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/common/FastHiveDecimalImpl.java
@@ -5182,7 +5182,6 @@ public class FastHiveDecimalImpl extends FastHiveDecimal {
fastResult.fastIntegerDigitCount = 0;
fastResult.fastScale = 0;
} else {
- fastResult.fastSignum = 0;
fastResult.fastSignum = fastSignum;
fastResult.fastIntegerDigitCount = fastRawPrecision(fastResult);
fastResult.fastScale = 0;
diff --git
a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/BatchRestApi.java
b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/BatchRestApi.java
index afcfe77d3..7d113308d 100644
---
a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/BatchRestApi.java
+++
b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/BatchRestApi.java
@@ -115,8 +115,7 @@ public class BatchRestApi {
private void setClientVersion(BatchRequest request) {
if (request != null) {
- Map<String, String> newConf = new HashMap<>();
- newConf.putAll(request.getConf());
+ Map<String, String> newConf = new HashMap<>(request.getConf());
newConf.put(VersionUtils.KYUUBI_CLIENT_VERSION_KEY,
VersionUtils.getVersion());
request.setConf(newConf);
}