/** * Adds column to RR, checking for duplicate columns. Needed because CBO cannot handle the Hive * behavior of blindly overwriting old mapping in RR and still somehow working after that. * * @return True if mapping was added without duplicates. */ public boolean putWithCheck( String tabAlias, String colAlias, String internalName, ColumnInfo newCI) throws SemanticException { ColumnInfo existing = get(tabAlias, colAlias); // Hive adds the same mapping twice... I wish we could fix stuff like that. if (existing == null) { put(tabAlias, colAlias, newCI); return true; } else if (existing.isSameColumnForRR(newCI)) { return true; } LOG.warn( "Found duplicate column alias in RR: " + existing.toMappingString(tabAlias, colAlias) + " adding " + newCI.toMappingString(tabAlias, colAlias)); if (internalName != null) { existing = get(tabAlias, internalName); if (existing == null) { put(tabAlias, internalName, newCI); return true; } else if (existing.isSameColumnForRR(newCI)) { return true; } LOG.warn( "Failed to use internal name after finding a duplicate: " + existing.toMappingString(tabAlias, internalName)); } return false; }