Java Code Examples for org.apache.calcite.plan.RelOptTable#getQualifiedName()

The following examples show how to use org.apache.calcite.plan.RelOptTable#getQualifiedName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelMetadataTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
public static void checkColumnOrigin(
    RelColumnOrigin rco,
    String expectedTableName,
    String expectedColumnName,
    boolean expectedDerived) {
  RelOptTable actualTable = rco.getOriginTable();
  List<String> actualTableName = actualTable.getQualifiedName();
  assertThat(
      Iterables.getLast(actualTableName),
      equalTo(expectedTableName));
  assertThat(
      actualTable.getRowType()
          .getFieldList()
          .get(rco.getOriginColumnOrdinal())
          .getName(),
      equalTo(expectedColumnName));
  assertThat(rco.isDerived(), equalTo(expectedDerived));
}
 
Example 2
Source File: RelNodeConvertor.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
private static Schema logicalTableScan(RelNode relNode) {
    LogicalTableScan tableScan = (LogicalTableScan) relNode;
    RelOptTable table = tableScan.getTable();
    RelDataType rowType = tableScan.getRowType();
    List<String> inputFieldNames = rowType.getFieldNames();
    List<String> outputFieldNames1 = table.getRowType().getFieldNames();

    List<String> qualifiedName = table.getQualifiedName();

    return new FromTableSchema(new ArrayList<>(qualifiedName));
}
 
Example 3
Source File: RelBuilder.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public RelNode visit(TableScan scan) {
  final RelOptTable scanTable = scan.getTable();
  final List<String> qualifiedName = scanTable.getQualifiedName();
  if (qualifiedName.get(qualifiedName.size() - 1).equals(tableName)) {
    relOptTable = scanTable;
  }
  return super.visit(scan);
}
 
Example 4
Source File: MaterializationTest.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public void visit(RelNode node, int ordinal, RelNode parent) {
  if (node instanceof TableScan) {
    RelOptTable table = node.getTable();
    List<String> qName = table.getQualifiedName();
    names.add(qName);
  }
  super.visit(node, ordinal, parent);
}
 
Example 5
Source File: RelMetadataTest.java    From calcite with Apache License 2.0 5 votes vote down vote up
private void checkTwoColumnOrigin(
    String sql,
    String expectedTableName1,
    String expectedColumnName1,
    String expectedTableName2,
    String expectedColumnName2,
    boolean expectedDerived) {
  Set<RelColumnOrigin> result = checkColumnOrigin(sql);
  assertNotNull(result);
  assertThat(result.size(), is(2));
  for (RelColumnOrigin rco : result) {
    RelOptTable actualTable = rco.getOriginTable();
    List<String> actualTableName = actualTable.getQualifiedName();
    String actualUnqualifiedName = Iterables.getLast(actualTableName);
    if (actualUnqualifiedName.equals(expectedTableName1)) {
      checkColumnOrigin(
          rco,
          expectedTableName1,
          expectedColumnName1,
          expectedDerived);
    } else {
      checkColumnOrigin(
          rco,
          expectedTableName2,
          expectedColumnName2,
          expectedDerived);
    }
  }
}
 
Example 6
Source File: RexTableInputRef.java    From Bats with Apache License 2.0 4 votes vote down vote up
private RelTableRef(RelOptTable table, int entityNumber) {
  this.table = table;
  this.entityNumber = entityNumber;
  this.digest = table.getQualifiedName() + ".#" + entityNumber;
}
 
Example 7
Source File: ElasticsearchRelNode.java    From dk-fitting with Apache License 2.0 4 votes vote down vote up
public String getTableName(RelNode input) {
    RelOptTable table = input.getInputs().get(0).getTable();
    List<String> qualifiedName1 = table.getQualifiedName();
    String s = qualifiedName1.get(qualifiedName1.size() - 1);
    return qualifiedName1.get(qualifiedName1.size() - 1);
}
 
Example 8
Source File: ElasticsearchRelNode.java    From dk-fitting with Apache License 2.0 4 votes vote down vote up
public String getTableName(RelNode input) {
    RelOptTable table = input.getInputs().get(0).getTable();
    List<String> qualifiedName1 = table.getQualifiedName();
    String s = qualifiedName1.get(qualifiedName1.size() - 1);
    return qualifiedName1.get(qualifiedName1.size() - 1);
}
 
Example 9
Source File: RexTableInputRef.java    From calcite with Apache License 2.0 4 votes vote down vote up
private RelTableRef(RelOptTable table, int entityNumber) {
  this.table = table;
  this.entityNumber = entityNumber;
  this.digest = table.getQualifiedName() + ".#" + entityNumber;
}