[ https://issues.apache.org/jira/browse/FLINK-22196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lsw_aka_laplace updated FLINK-22196: ------------------------------------ Description: Well since we have supported project push-down, some primary-key in original schema may not exist no longer more, so the non-existed column shall be filtered out. Current code: {code:java} val columns = relOptTable.getRowType.getFieldNames val columnIndices = schema.getPrimaryKey.get().getColumns map { c => columns.indexOf(c) } {code} May be supposed to correct to: {code:java} val columns = relOptTable.getRowType.getFieldNames val columnIndices = schema .getPrimaryKey .get() .getColumns .map(columns.indexOf) .filterNot(_ == -1) // filter out the non-exist column {code} > FlinkRelMdUniqueKeys#getTableUniqueKeys should filter out the column indices > which the does not exist in current row schema > ---------------------------------------------------------------------------------------------------------------------------- > > Key: FLINK-22196 > URL: https://issues.apache.org/jira/browse/FLINK-22196 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Affects Versions: 1.12.2 > Reporter: Lsw_aka_laplace > Priority: Major > > Well since we have supported project push-down, some primary-key in original > schema may not exist no longer more, so the non-existed column shall be > filtered out. > > Current code: > {code:java} > val columns = relOptTable.getRowType.getFieldNames > val columnIndices = schema.getPrimaryKey.get().getColumns map { c => > columns.indexOf(c) > } > {code} > May be supposed to correct to: > {code:java} > val columns = relOptTable.getRowType.getFieldNames > val columnIndices = schema > .getPrimaryKey > .get() > .getColumns > .map(columns.indexOf) > .filterNot(_ == -1) // filter out the non-exist column > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)