@Override
    public AbstractTableInfo getTableInfo(String tableName, String fieldsInfo, Map<String, Object> props) throws Exception {
        ImpalaTableInfo impalaTableInfo = new ImpalaTableInfo();
        impalaTableInfo.setName(tableName);
        parseFieldsInfo(fieldsInfo, impalaTableInfo);

        impalaTableInfo.setParallelism(MathUtil.getIntegerVal(props.get(PARALLELISM_KEY.toLowerCase())));
        impalaTableInfo.setUrl(MathUtil.getString(props.get(URL_KEY.toLowerCase())));
        impalaTableInfo.setTableName(MathUtil.getString(props.get(TABLE_NAME_KEY.toLowerCase())));
        impalaTableInfo.setBatchSize(MathUtil.getIntegerVal(props.get(BATCH_SIZE_KEY.toLowerCase())));
        impalaTableInfo.setBatchWaitInterval(MathUtil.getLongVal(props.get(BATCH_WAIT_INTERVAL_KEY.toLowerCase())));
        impalaTableInfo.setBufferSize(MathUtil.getString(props.get(BUFFER_SIZE_KEY.toLowerCase())));
        impalaTableInfo.setFlushIntervalMs(MathUtil.getString(props.get(FLUSH_INTERVAL_MS_KEY.toLowerCase())));
        impalaTableInfo.setSchema(MathUtil.getString(props.get(SCHEMA_KEY.toLowerCase())));
        impalaTableInfo.setUpdateMode(MathUtil.getString(props.get(UPDATE_KEY.toLowerCase())));
        impalaTableInfo.setDriverName("com.cloudera.impala.jdbc41.Driver");

        Integer authMech = MathUtil.getIntegerVal(props.get(AUTH_MECH_KEY.toLowerCase()));
        authMech = authMech == null ? 0 : authMech;
        impalaTableInfo.setAuthMech(authMech);
        List<Integer> authMechs = Arrays.asList(0, 1, 2, 3);

        if (!authMechs.contains(authMech)) {
            throw new IllegalArgumentException("The value of authMech is illegal, Please select 0, 1, 2, 3");
        } else if (authMech == 1) {
            impalaTableInfo.setPrincipal(MathUtil.getString(props.get(PRINCIPAL_KEY.toLowerCase())));
            impalaTableInfo.setKeyTabFilePath(MathUtil.getString(props.get(KEY_TAB_FILE_PATH_KEY.toLowerCase())));
            impalaTableInfo.setKrb5FilePath(MathUtil.getString(props.get(KRB5FILEPATH_KEY.toLowerCase())));
            String krbRealm = MathUtil.getString(props.get(KRB_REALM_KEY.toLowerCase()));
            krbRealm = krbRealm == null ? KRB_DEFAULT_REALM : krbRealm;
            impalaTableInfo.setKrbRealm(krbRealm);
            impalaTableInfo.setKrbHostFQDN(MathUtil.getString(props.get(KRB_HOST_FQDN_KEY.toLowerCase())));
            impalaTableInfo.setKrbServiceName(MathUtil.getString(props.get(KRB_SERVICE_NAME_KEY.toLowerCase())));
        } else if (authMech == 2) {
            impalaTableInfo.setUserName(MathUtil.getString(props.get(USER_NAME_KEY.toLowerCase())));
        } else if (authMech == 3) {
            impalaTableInfo.setUserName(MathUtil.getString(props.get(USER_NAME_KEY.toLowerCase())));
            impalaTableInfo.setPassword(MathUtil.getString(props.get(PASSWORD_KEY.toLowerCase())));
        }

        String storeType = MathUtil.getString(props.get(STORE_TYPE_KEY.toLowerCase()));
        impalaTableInfo.setStoreType(Objects.isNull(storeType) ? DEFAULT_STORE_TYPE : storeType);

        String enablePartitionStr = (String) props.get(ENABLE_PARTITION_KEY.toLowerCase());
        boolean enablePartition = MathUtil.getBoolean(enablePartitionStr == null ? "false" : enablePartitionStr);
        impalaTableInfo.setEnablePartition(enablePartition);

        if (!impalaTableInfo.getStoreType().equalsIgnoreCase(KUDU_TYPE) && enablePartition) {
            String partitionFields = MathUtil.getString(props.get(PARTITION_FIELDS_KEY.toLowerCase()));
            impalaTableInfo.setPartitionFields(partitionFields);
        }

        impalaTableInfo.setType(CURRENT_TYPE);

        impalaTableInfo.check();
        return impalaTableInfo;
    }
Date: 2020/10/14
Company: www.dtstack.com

@author tiezhu
impala/impala-sink/src/main/java/com/dtstack/flink/sql/sink/impala/table/ImpalaSinkParser.java