Class FlinkSqlNameMatcher

java.lang.Object
org.apache.flink.table.planner.calcite.FlinkSqlNameMatcher
All Implemented Interfaces:
org.apache.calcite.sql.validate.SqlNameMatcher

public class FlinkSqlNameMatcher extends Object implements org.apache.calcite.sql.validate.SqlNameMatcher
A workaround for adjusting types of ROW nested fields.

The SqlNameMatcher is used in SqlValidatorImpl when deriving a type of a nested field of a Table. E.g SELECT `row`.`nested` FROM table. See field(RelDataType, String) for more information.

  • Constructor Details

    • FlinkSqlNameMatcher

      public FlinkSqlNameMatcher(org.apache.calcite.sql.validate.SqlNameMatcher baseMatcher, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
  • Method Details

    • isCaseSensitive

      public boolean isCaseSensitive()
      Specified by:
      isCaseSensitive in interface org.apache.calcite.sql.validate.SqlNameMatcher
    • matches

      public boolean matches(String string, String name)
      Specified by:
      matches in interface org.apache.calcite.sql.validate.SqlNameMatcher
    • get

      public <K extends List<String>, V> V get(Map<K,V> map, List<String> prefixNames, List<String> names)
      Specified by:
      get in interface org.apache.calcite.sql.validate.SqlNameMatcher
    • bestString

      public String bestString()
      Specified by:
      bestString in interface org.apache.calcite.sql.validate.SqlNameMatcher
    • field

      public org.apache.calcite.rel.type.RelDataTypeField field(org.apache.calcite.rel.type.RelDataType rowType, String fieldName)
      Compared to the original method we adjust the nullability of the nested column based on the nullability of the enclosing type.

      If the fields type is NOT NULL, but the enclosing ROW is nullable we still can produce nulls.

      Specified by:
      field in interface org.apache.calcite.sql.validate.SqlNameMatcher
    • frequency

      public int frequency(Iterable<String> names, String name)
      Specified by:
      frequency in interface org.apache.calcite.sql.validate.SqlNameMatcher
    • createSet

      public Set<String> createSet()
      Specified by:
      createSet in interface org.apache.calcite.sql.validate.SqlNameMatcher