@Test public void getCategoricalColsTest() { TableSchema tableSchema = new TableSchema(new String[]{"f0", "f1", "f2", "f3"}, new TypeInformation[]{Types.INT, Types.LONG, Types.STRING, Types.BOOLEAN}); Assert.assertArrayEquals(TableUtil.getCategoricalCols(tableSchema, tableSchema.getFieldNames(), null), new String[]{"f2", "f3"}); Assert.assertArrayEquals( TableUtil.getCategoricalCols(tableSchema, new String[]{"f2", "f1", "f0", "f3"}, new String[]{"f0"}), new String[]{"f2", "f0", "f3"}); thrown.expect(IllegalArgumentException.class); Assert.assertArrayEquals( TableUtil.getCategoricalCols(tableSchema, new String[]{"f3", "f0"}, new String[]{"f2"}), new String[]{"f3", "f2"}); }
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]); }
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]); } }
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]); }  }
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]); }  static synchronized String getTempTableName(); static int findColIndex(String[] tableCols, String targetCol); static int findColIndexWithAssert(String[] tableCols, String targetCol); static int findColIndexWithAssertAndHint(String[] tableCols, String targetCol); static int findColIndex(TableSchema tableSchema, String targetCol); static int findColIndexWithAssert(TableSchema tableSchema, String targetCol); static int findColIndexWithAssertAndHint(TableSchema tableSchema, String targetCol); static int[] findColIndices(String[] tableCols, String[] targetCols); static int[] findColIndicesWithAssert(String[] tableCols, String[] targetCols); static int[] findColIndicesWithAssertAndHint(String[] tableCols, String[] targetCols); static int[] findColIndices(TableSchema tableSchema, String[] targetCols); static int[] findColIndicesWithAssert(TableSchema tableSchema, String[] targetCols); static int[] findColIndicesWithAssertAndHint(TableSchema tableSchema, String[] targetCols); static TypeInformation[] findColTypes(TableSchema tableSchema, String[] targetCols); static TypeInformation[] findColTypesWithAssert(TableSchema tableSchema, String[] targetCols); static TypeInformation[] findColTypesWithAssertAndHint(TableSchema tableSchema, String[] targetCols); static TypeInformation findColType(TableSchema tableSchema, String targetCol); static TypeInformation findColTypeWithAssert(TableSchema tableSchema, String targetCol); static TypeInformation findColTypeWithAssertAndHint(TableSchema tableSchema, String targetCol); static boolean isNumber(TypeInformation dataType); static boolean isString(TypeInformation dataType); static boolean isVector(TypeInformation dataType); static void assertSelectedColExist(String[] tableCols, String... selectedCols); static void assertNumericalCols(TableSchema tableSchema, String... selectedCols); static void assertStringCols(TableSchema tableSchema, String... selectedCols); static void assertVectorCols(TableSchema tableSchema, String... selectedCols); static String[] getStringCols(TableSchema tableSchema); static String[] getStringCols(TableSchema tableSchema, String[] excludeCols); static String[] getNumericCols(TableSchema tableSchema); static String[] getNumericCols(TableSchema tableSchema, String[] excludeCols); static String[] getCategoricalCols(
        TableSchema tableSchema, String[] featureCols, String[] categoricalCols); static String formatTitle(String[] colNames); static String formatRows(Row row); static String format(String[] colNames, List<Row> data); static String columnsToSqlClause(String[] colNames); static String toSchemaJson(TableSchema schema); static TableSchema fromSchemaJson(String schemaJson); static Table concatTables(Table[] tables, Long sessionId); static Table[] splitTable(Table table); static Row getRow(Row row, int... keepIdxs); }
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]); }  static synchronized String getTempTableName(); static int findColIndex(String[] tableCols, String targetCol); static int findColIndexWithAssert(String[] tableCols, String targetCol); static int findColIndexWithAssertAndHint(String[] tableCols, String targetCol); static int findColIndex(TableSchema tableSchema, String targetCol); static int findColIndexWithAssert(TableSchema tableSchema, String targetCol); static int findColIndexWithAssertAndHint(TableSchema tableSchema, String targetCol); static int[] findColIndices(String[] tableCols, String[] targetCols); static int[] findColIndicesWithAssert(String[] tableCols, String[] targetCols); static int[] findColIndicesWithAssertAndHint(String[] tableCols, String[] targetCols); static int[] findColIndices(TableSchema tableSchema, String[] targetCols); static int[] findColIndicesWithAssert(TableSchema tableSchema, String[] targetCols); static int[] findColIndicesWithAssertAndHint(TableSchema tableSchema, String[] targetCols); static TypeInformation[] findColTypes(TableSchema tableSchema, String[] targetCols); static TypeInformation[] findColTypesWithAssert(TableSchema tableSchema, String[] targetCols); static TypeInformation[] findColTypesWithAssertAndHint(TableSchema tableSchema, String[] targetCols); static TypeInformation findColType(TableSchema tableSchema, String targetCol); static TypeInformation findColTypeWithAssert(TableSchema tableSchema, String targetCol); static TypeInformation findColTypeWithAssertAndHint(TableSchema tableSchema, String targetCol); static boolean isNumber(TypeInformation dataType); static boolean isString(TypeInformation dataType); static boolean isVector(TypeInformation dataType); static void assertSelectedColExist(String[] tableCols, String... selectedCols); static void assertNumericalCols(TableSchema tableSchema, String... selectedCols); static void assertStringCols(TableSchema tableSchema, String... selectedCols); static void assertVectorCols(TableSchema tableSchema, String... selectedCols); static String[] getStringCols(TableSchema tableSchema); static String[] getStringCols(TableSchema tableSchema, String[] excludeCols); static String[] getNumericCols(TableSchema tableSchema); static String[] getNumericCols(TableSchema tableSchema, String[] excludeCols); static String[] getCategoricalCols(
        TableSchema tableSchema, String[] featureCols, String[] categoricalCols); static String formatTitle(String[] colNames); static String formatRows(Row row); static String format(String[] colNames, List<Row> data); static String columnsToSqlClause(String[] colNames); static String toSchemaJson(TableSchema schema); static TableSchema fromSchemaJson(String schemaJson); static Table concatTables(Table[] tables, Long sessionId); static Table[] splitTable(Table table); static Row getRow(Row row, int... keepIdxs);  }