Java Code Examples for org.apache.calcite.sql.SqlIdentifier#getComponentParserPosition()

The following examples show how to use org.apache.calcite.sql.SqlIdentifier#getComponentParserPosition() . 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: SqlAdvisorValidator.java    From Bats with Apache License 2.0 5 votes vote down vote up
private void registerId(SqlIdentifier id, SqlValidatorScope scope) {
  for (int i = 0; i < id.names.size(); i++) {
    final SqlParserPos subPos = id.getComponentParserPosition(i);
    SqlIdentifier subId =
        i == id.names.size() - 1
            ? id
            : new SqlIdentifier(id.names.subList(0, i + 1), subPos);
    idPositions.put(subPos.toString(), new IdInfo(scope, subId));
  }
}
 
Example 2
Source File: SqlConverter.java    From Bats with Apache License 2.0 5 votes vote down vote up
private void changeNamesIfTableIsTemporary(SqlIdentifier tempNode) {
  List<String> temporaryTableNames = ((SqlConverter.DrillCalciteCatalogReader) getCatalogReader()).getTemporaryNames(tempNode.names);
  if (temporaryTableNames != null) {
    SqlParserPos pos = tempNode.getComponentParserPosition(0);
    List<SqlParserPos> poses = Lists.newArrayList();
    for (int i = 0; i < temporaryTableNames.size(); i++) {
      poses.add(i, pos);
    }
    tempNode.setNames(temporaryTableNames, poses);
  }
}
 
Example 3
Source File: SqlAdvisorValidator.java    From calcite with Apache License 2.0 5 votes vote down vote up
private void registerId(SqlIdentifier id, SqlValidatorScope scope) {
  for (int i = 0; i < id.names.size(); i++) {
    final SqlParserPos subPos = id.getComponentParserPosition(i);
    SqlIdentifier subId =
        i == id.names.size() - 1
            ? id
            : new SqlIdentifier(id.names.subList(0, i + 1), subPos);
    idPositions.put(subPos.toString(), new IdInfo(scope, subId));
  }
}