-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some bugs with Groupby
and CacheTable
#14
base: master
Are you sure you want to change the base?
Changes from all commits
b27c140
26aa92a
e4be464
cf4f7cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import java.util.*; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.hive.service.rpc.thrift.TStatus; | ||
import org.apache.hive.service.rpc.thrift.TStatusCode; | ||
import org.slf4j.Logger; | ||
|
@@ -193,12 +194,20 @@ public static JdbcConnectionParams extractURLComponents(String uri, Properties i | |
} | ||
} | ||
|
||
Pattern confPattern = Pattern.compile("([^;]*)([^;]*);?"); | ||
|
||
// parse hive conf settings | ||
String confStr = jdbcURI.getQuery(); | ||
if (confStr != null) { | ||
Matcher confMatcher = pattern.matcher(confStr); | ||
Matcher confMatcher = confPattern.matcher(confStr); | ||
while (confMatcher.find()) { | ||
connParams.getHiveConfs().put(confMatcher.group(1), confMatcher.group(2)); | ||
String connParam = confMatcher.group(1); | ||
if (StringUtils.isNotBlank(connParam) && connParam.contains("=")) { | ||
int symbolIndex = connParam.indexOf('='); | ||
connParams | ||
.getHiveConfs() | ||
.put(connParam.substring(0, symbolIndex), connParam.substring(symbolIndex + 1)); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -477,4 +486,4 @@ public static String getCanonicalHostName(String hostName) { | |
public static boolean isKyuubiOperationHint(String hint) { | ||
return KYUUBI_OPERATION_HINT_PATTERN.matcher(hint).matches(); | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码主要进行了以下工作:
可能存在的风险/bug: 1.没有捕获解析URL过程中可能存在的异常,需要增加异常处理机制来提醒错误并尽可能减小错误对整体代码运行的影响。 可以改进的地方:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,12 @@ SCOPE_TABLE: 'SCOPE_TABLE'; | |
SOURCE_DATA_TYPE: 'SOURCE_DATA_TYPE'; | ||
IS_AUTOINCREMENT: 'IS_AUTOINCREMENT'; | ||
IS_GENERATEDCOLUMN: 'IS_GENERATEDCOLUMN'; | ||
VARCHAR: 'VARCHAR'; | ||
SMALLINT: 'SMALLINT'; | ||
CAST: 'CAST'; | ||
AS: 'AS'; | ||
KEY_SEQ: 'KEY_SEQ'; | ||
PK_NAME: 'PK_NAME'; | ||
|
||
fragment SEARCH_STRING_ESCAPE: '\'' '\\' '\''; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码看起来只是定义了几个常量,没有什么明显的错误风险。以下是一些改进建议:
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,13 @@ statement | |
SOURCE_DATA_TYPE COMMA IS_AUTOINCREMENT COMMA IS_GENERATEDCOLUMN FROM SYSTEM_JDBC_COLUMNS | ||
(WHERE tableCatalogFilter? AND? tableSchemaFilter? AND? tableNameFilter? AND? colNameFilter?)? | ||
ORDER BY TABLE_CAT COMMA TABLE_SCHEM COMMA TABLE_NAME COMMA ORDINAL_POSITION #getColumns | ||
| SELECT CAST LEFT_PAREN NULL AS VARCHAR RIGHT_PAREN TABLE_CAT COMMA | ||
CAST LEFT_PAREN NULL AS VARCHAR RIGHT_PAREN TABLE_SCHEM COMMA | ||
CAST LEFT_PAREN NULL AS VARCHAR RIGHT_PAREN TABLE_NAME COMMA | ||
CAST LEFT_PAREN NULL AS VARCHAR RIGHT_PAREN COLUMN_NAME COMMA | ||
CAST LEFT_PAREN NULL AS SMALLINT RIGHT_PAREN KEY_SEQ COMMA | ||
CAST LEFT_PAREN NULL AS VARCHAR RIGHT_PAREN PK_NAME | ||
WHERE FALSE #getPrimaryKeys | ||
| .*? #passThrough | ||
; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码是一个patch,对应多行SQL语句。以下是对每一行的简要说明: 第一行:
第二行到第五行: 这里定义了一个SQL语句模板,用于从数据库中获取表格中所有的列名和相关信息。 第六行到第十二行: 这也是一个SQL语句模板,用于从数据库中获取主键的信息。这个查询使用了常量值 NULL 作为占位符。 第十三行:
总体而言,这段代码逻辑上没有显著的缺陷和风险。但如果能提供更多上下文,我们可以更准确地给出更多有价值的改进建议。 |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该代码补丁涉及 SparkSQL 中一些列的代码修改,主要改动包括:
此外代码的可读性较好,有一些无用代码需要清理。历史版本中可能有已修复的 bug 或者有待优化的部分,但是在当前代码的语境下无法评估。