code: private static boolean postAggregatorDirectColumnIsOk(
        final RowSignature aggregateRowSignature,
        final DruidExpression expression,
        final RexNode rexNode
    )
    {
      if (!expression.isDirectColumnAccess()) {
        return false;
      }
  
      // Check if a cast is necessary.
      final ExprType toExprType = Expressions.exprTypeForValueType(
          aggregateRowSignature.getColumnType(expression.getDirectColumn())
      );
  
      final ExprType fromExprType = Expressions.exprTypeForValueType(
          Calcites.getValueTypeForSqlTypeName(rexNode.getType().getSqlTypeName())
      );
  
      return toExprType.equals(fromExprType);
    }
docs: Returns true if a post-aggregation "expression" can be realized as a direct field access. This is true if it's
  a direct column access that doesn't require an implicit cast.
  
  @param aggregateRowSignature signature of the aggregation
  @param expression            post-aggregation expression
  @param rexNode               RexNode for the post-aggregation expression
  
  @return yes or no