Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-33200

ItemAt Expression validation fail in Table API due to type mismatch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.18.0, 1.17.1
    • None
    • Table SQL / API
    • None

    Description

      The table schema is defined as below:

      public static final DataType DATA_TYPE = DataTypes.ROW(
      DataTypes.FIELD("id", DataTypes.STRING()),
      DataTypes.FIELD("events", DataTypes.ARRAY(DataTypes.MAP(DataTypes.STRING(), DataTypes.STRING())))
      );

      public static final Schema SCHEMA = Schema.newBuilder().fromRowDataType(DATA_TYPE).build();

      inTable.select(Expressions.$("events").at(1).at("eventType").as("firstEventType")

      The validation fail as "eventType" is inferred as BasicTypeInfo.STRING_TYPE_INFO, the table key internally is a StringDataTypeInfo. The validation fail at

      case mti: MapTypeInfo[_, _] =>
      if (key.resultType == mti.getKeyTypeInfo)

      { ValidationSuccess }

      else {
      ValidationFailure(
      s"Map entry access needs a valid key of type " +
      s"'${mti.getKeyTypeInfo}', found '${key.resultType}'.")
      }

      Attachments

        1. IssueDemo.java
          6 kB
          Andriy Onyshchuk

        Activity

          People

            Unassigned Unassigned
            ZhenqiuHuang Zhenqiu Huang
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated: