static String discoverJsonFieldName ( Settings settings , FieldAlias alias ) { Set < String > virtualColumnsToBeRemoved = new HashSet < String > ( HiveConstants . VIRTUAL_COLUMNS . length ) ; Collections . addAll ( virtualColumnsToBeRemoved , HiveConstants . VIRTUAL_COLUMNS ) ; List < String > columnNames = StringUtils . tokenize ( settings . getProperty ( HiveConstants . COLUMNS ) , "," ) ; Iterator < String > nameIter = columnNames . iterator ( ) ; List < String > columnTypes = StringUtils . tokenize ( settings . getProperty ( HiveConstants . COLUMNS_TYPES ) , ":" ) ; Iterator < String > typeIter = columnTypes . iterator ( ) ; String candidateField = null ; while ( nameIter . hasNext ( ) && candidateField == null ) { String columnName = nameIter . next ( ) ; String type = typeIter . next ( ) ; if ( "string" . equalsIgnoreCase ( type ) && ! virtualColumnsToBeRemoved . contains ( columnName ) ) { candidateField = columnName ; } } Assert . hasText ( candidateField , "Could not identify a field to insert JSON data into " + "from the given fields : {" + columnNames + "} of types {" + columnTypes + "}" ) ; // If the candidate field is aliased to something else, find the alias name and use that for the field name: candidateField = alias . toES ( candidateField ) ; return candidateField ; }
Selects an appropriate field from the given Hive table schema to insert JSON data into if the feature is enabled