use of com.hazelcast.jet.sql.impl.schema.HazelcastTableSourceFunction in project hazelcast by hazelcast.
the class HazelcastSqlValidator method containsStreamingSource.
/**
* Goes over all the referenced tables in the given {@link SqlNode}
* and returns true if any of them uses a streaming connector.
*/
public boolean containsStreamingSource(SqlNode node) {
class FindStreamingTablesVisitor extends SqlBasicVisitor<Void> {
boolean found;
@Override
public Void visit(SqlIdentifier id) {
SqlValidatorTable table = getCatalogReader().getTable(id.names);
// not every identifier is a table
if (table != null) {
HazelcastTable hazelcastTable = table.unwrap(HazelcastTable.class);
if (hazelcastTable.getTarget() instanceof ViewTable) {
found = ((ViewTable) hazelcastTable.getTarget()).isStream();
return null;
}
SqlConnector connector = getJetSqlConnector(hazelcastTable.getTarget());
if (connector.isStream()) {
found = true;
return null;
}
}
return super.visit(id);
}
@Override
public Void visit(SqlCall call) {
SqlOperator operator = call.getOperator();
if (operator instanceof HazelcastTableSourceFunction) {
if (((HazelcastTableSourceFunction) operator).isStream()) {
found = true;
return null;
}
}
return super.visit(call);
}
}
FindStreamingTablesVisitor visitor = new FindStreamingTablesVisitor();
node.accept(visitor);
return visitor.found;
}
Aggregations