Skip to content

Commit

Permalink
fix (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGe00 authored Oct 3, 2023
1 parent 221a453 commit a886a95
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.linkedin.coral.vis;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;

Expand All @@ -20,6 +21,7 @@
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlNodeList;
import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.util.SqlVisitor;

import guru.nidi.graphviz.attribute.Label;
Expand All @@ -28,6 +30,7 @@
import guru.nidi.graphviz.model.LinkTarget;
import guru.nidi.graphviz.model.Node;

import static com.linkedin.coral.common.calcite.CalciteUtil.*;
import static guru.nidi.graphviz.model.Factory.*;


Expand Down Expand Up @@ -59,6 +62,8 @@ public Node visit(SqlCall call) {
}
if (sqlSelect.getSelectList() != null) {
edges.add(edge(sqlSelect.getSelectList(), "select_list"));
} else {
edges.add(edge(createSelectStarSqlNodeList(), "select_list"));
}
if (sqlSelect.getOrderList() != null) {
edges.add(edge(sqlSelect.getOrderList(), "order_by_list"));
Expand Down Expand Up @@ -122,4 +127,11 @@ private Link edge(SqlNode target, String label) {
private static Node node(String label) {
return Factory.node(UUID.randomUUID().toString()).with(Label.of(label));
}

private static SqlNodeList createSelectStarSqlNodeList() {
Collection<SqlNode> sqlNodeList = new ArrayList();
sqlNodeList.add(createStarIdentifier(SqlParserPos.ZERO));
SqlNodeList selectStar = createSqlNodeList(sqlNodeList);
return selectStar;
}
}

0 comments on commit a886a95

Please sign in to comment.