public static List<String> parseColumnsFromPath(String filePath, List<String> columnsFromPath)
            throws SparkDppException {
        if (columnsFromPath == null || columnsFromPath.isEmpty()) {
            return Collections.emptyList();
        }
        String[] strings = filePath.split("/");
        if (strings.length < 2) {
            System.err
                    .println("Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " + filePath);
            throw new SparkDppException(
                    "Reason: Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " + filePath);
        }
        String[] columns = new String[columnsFromPath.size()];
        int size = 0;
        for (int i = strings.length - 2; i >= 0; i--) {
            String str = strings[i];
            if (str != null && str.isEmpty()) {
                continue;
            }
            if (str == null || !str.contains("=")) {
                System.err.println(
                        "Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " + filePath);
                throw new SparkDppException(
                        "Reason: Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " +
                                filePath);
            }
            String[] pair = str.split("=", 2);
            if (pair.length != 2) {
                System.err.println(
                        "Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " + filePath);
                throw new SparkDppException(
                        "Reason: Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " +
                                filePath);
            }
            int index = columnsFromPath.indexOf(pair[0]);
            if (index == -1) {
                continue;
            }
            columns[index] = pair[1];
            size++;
            if (size >= columnsFromPath.size()) {
                break;
            }
        }
        if (size != columnsFromPath.size()) {
            System.err
                    .println("Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " + filePath);
            throw new SparkDppException(
                    "Reason: Fail to parse columnsFromPath, expected: " + columnsFromPath + ", filePath: " + filePath);
        }
        return Lists.newArrayList(columns);
    }
@Test
    public void testParseColumnsFromPath() {
        DppUtils dppUtils = new DppUtils();

        String path = "/path/to/file/city=beijing/date=2020-04-10/data";
        List<String> columnFromPaths = new ArrayList<>();
        columnFromPaths.add("city");
        columnFromPaths.add("date");
        try {
            List<String> columnFromPathValues = dppUtils.parseColumnsFromPath(path, columnFromPaths);
            Assert.assertEquals(2, columnFromPathValues.size());
            Assert.assertEquals("beijing", columnFromPathValues.get(0));
            Assert.assertEquals("2020-04-10", columnFromPathValues.get(1));
        } catch (Exception e) {
            Assert.assertTrue(false);
        }
    }