Skip to content

Commit 7b068c1

Browse files
committed
Merge branch '1.5_v3.8.0_bugfix_joinnpe' into '1.5_v3.8.0'
[flinksql][维表join npe,错误提示不友好][19240] See merge request !85
2 parents 56f9eda + e8d915e commit 7b068c1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

core/src/main/java/com/dtstack/flink/sql/side/SideSqlExec.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,16 @@ private SqlNode replaceOrderByTableName(SqlNode orderNode, String tableAlias) {
356356
private SqlNode replaceNodeInfo(SqlNode groupNode, HashBasedTable<String, String, String> mappingTable, String tableAlias){
357357
if(groupNode.getKind() == IDENTIFIER){
358358
SqlIdentifier sqlIdentifier = (SqlIdentifier) groupNode;
359+
// 如果没有表别名前缀,直接返回字段名称
360+
if (sqlIdentifier.names.size() == 1) {
361+
return groupNode;
362+
}
359363
String mappingFieldName = mappingTable.get(sqlIdentifier.getComponent(0).getSimple(), sqlIdentifier.getComponent(1).getSimple());
364+
// 如果有表别名前缀,但是在宽表中找不到映射,只需要设置别名,不需要替换映射
365+
if (null == mappingFieldName){
366+
// return sqlIdentifier.setName(0, tableAlias);
367+
throw new RuntimeException("Column '" + sqlIdentifier.getComponent(1).getSimple() + "' not found in table '" + sqlIdentifier.getComponent(0).getSimple() + "'");
368+
}
360369
sqlIdentifier = sqlIdentifier.setName(0, tableAlias);
361370
return sqlIdentifier.setName(1, mappingFieldName);
362371
}else if(groupNode instanceof SqlBasicCall){

v1.8.0_dev_bugfix_joinnpe

Whitespace-only changes.

0 commit comments

Comments
 (0)