class TableUtil {

    public static String[] getCategoricalCols(
        TableSchema tableSchema, String[] featureCols, String[] categoricalCols) {
        if (null == featureCols) {
            return categoricalCols;
        }
        List<String> categoricalList = null == categoricalCols ? null : Arrays.asList(categoricalCols);
        List<String> featureList = Arrays.asList(featureCols);
        if (null != categoricalCols && !featureList.containsAll(categoricalList)) {
            throw new IllegalArgumentException("CategoricalCols must be included in featureCols!");
        }

        TypeInformation[] featureColTypes = findColTypes(tableSchema, featureCols);
        List<String> res = new ArrayList<>();
        for (int i = 0; i < featureCols.length; i++) {
            boolean included = null != categoricalList && categoricalList.contains(featureCols[i]);
            if (included || Types.BOOLEAN == featureColTypes[i] || Types.STRING == featureColTypes[i]) {
                res.add(featureCols[i]);
            }
        }

        return res.toArray(new String[0]);
    }

}