libenchao commented on code in PR #2847: URL: https://github.com/apache/calcite/pull/2847#discussion_r1042836225
########## core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java: ########## @@ -104,14 +104,15 @@ public TypeCoercionImpl(RelDataTypeFactory typeFactory, SqlValidator validator) updateInferredColumnType(scope1, query, columnIndex, targetType); return true; case VALUES: + boolean coerceValues = true; for (SqlNode rowConstructor : ((SqlCall) query).getOperandList()) { if (!coerceOperandType(scope, (SqlCall) rowConstructor, columnIndex, targetType)) { - return false; + coerceValues = false; } } updateInferredColumnType( requireNonNull(scope, "scope"), query, columnIndex, targetType); - return true; + return coerceValues; Review Comment: > And the same logic should also be aligned in other similar methods Sorry about my this comment, which is something misleading. In `rowTypeCoercion` method, only `VALUES` branch is wrong now, we'd better to only change this, and keep others unchanged, which will make this PR more clean. ########## core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java: ########## @@ -94,27 +94,24 @@ public TypeCoercionImpl(RelDataTypeFactory typeFactory, SqlValidator validator) int columnIndex, RelDataType targetType) { final SqlKind kind = query.getKind(); + boolean coerced = false; switch (kind) { case SELECT: SqlSelect selectNode = (SqlSelect) query; SqlValidatorScope scope1 = validator.getSelectScope(selectNode); - if (!coerceColumnType(scope1, getSelectList(selectNode), columnIndex, targetType)) { - return false; - } - updateInferredColumnType(scope1, query, columnIndex, targetType); Review Comment: We are updating the `scope1` instead of `scope`, however, after your change, we'll update `scope`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org