UDFHelper { public static String generateUDFClause( final String inTableName, final String functionName, final String outputCol, final String[] selectedCols, final String[] reservedCols) { final String selectedColsStr = TableUtil.columnsToSqlClause(selectedCols); final String[] cleanedReservedCols = Arrays.stream(reservedCols) .filter(d -> !d.equals(outputCol)) .toArray(String[]::new); StringBuilder sb = new StringBuilder(); if (cleanedReservedCols.length > 0) { sb.append(TableUtil.columnsToSqlClause(cleanedReservedCols)).append(", "); } sb.append(functionName).append("(").append(selectedColsStr).append(") as `").append(outputCol).append("`"); return String.format("SELECT %s FROM %s", sb.toString(), inTableName); }  static String generateRandomFuncName(); static String generateUDFClause(
        final String inTableName, final String functionName,
        final String outputCol, final String[] selectedCols, final String[] reservedCols); static String generateUDTFClause(
        final String inTableName, final String functionName,
        final String[] outputCols, final String[] selectedCols, final String[] reservedCols);  }
@Test public void generateUDFClause() { String clause = UDFHelper.generateUDFClause( "input", "func", "c1", new String[]{"c0", "c1"}, new String[]{"c0", "c1", "c2"} ); assertEquals( "SELECT `c0`,`c2`, func(`c0`,`c1`) as `c1` FROM input", clause); }