0
我使用下面的代碼來獲取選定的列。但是在列項中,爲什麼table.getName()是別名t1或t2而table.getAlias()是null?請幫助CCJSqlParser問題
是否有任何示例代碼在同一時間獲取表名(Spark_Test_1,Spark_Test_2)和別名表名(t1,t2)?
String sql = "SELECT t1.AsOfD,t1.ValidD,t1.urn,t1.Money FROM Spark_Test_1 as t1 join Spark_Test_2 as t2 on (t1.AsOfD = t2.AsOfD)";
Statement statement = CCJSqlParserUtil.parse(sqlStr);
Select selectStatement = (Select) statement;
for (int i = 0; i < size; i++) {
Expression expression = ((SelectExpressionItem) selectitems.get(i))
.getExpression();
//System.out.println("Expression:" + expression);
if(expression instanceof Column){
Column col = (Column) expression;
Table table = col.getTable();
logger.info(table.getFullyQualifiedName());
logger.info(table.getAlias());
logger.info(table.getName());
}
}