/** * Obtain Hive database names. The returned {@link Iterable} contains the database name returned by * {@link #getDatabaseName(Path)} (if present) plus additional database names specified in * {@link #ADDITIONAL_HIVE_DATABASE_NAMES}. * */ protected Iterable<String> getDatabaseNames(Path path) { List<String> databaseNames = Lists.newArrayList(); Optional<String> databaseName; if ((databaseName = getDatabaseName(path)).isPresent()) { databaseNames.add(databaseName.get()); } if (!Strings.isNullOrEmpty(this.props.getProp(ADDITIONAL_HIVE_DATABASE_NAMES))) { for (String additionalDbName : this.props.getPropAsList(ADDITIONAL_HIVE_DATABASE_NAMES)) { databaseNames.add(this.dbNamePrefix + additionalDbName + this.dbNameSuffix); } } Preconditions.checkState(!databaseNames.isEmpty(), "Hive database name not specified"); return databaseNames; }
/** * Create a {@link State} object that contains Hive table properties. These properties are obtained from * {@link #HIVE_TABLE_PARTITION_PROPS}, which is a list of comma-separated properties. Each property is in the form * of '[key]=[value]'. */ private State createHiveProps(String propKey) { State state = new State(); if (!contains(propKey)) { return state; } for (String propValue : getPropAsList(propKey)) { List<String> tokens = SPLITTER.splitToList(propValue); Preconditions.checkState(tokens.size() == 2, propValue + " is not a valid Hive table/partition property"); state.setProp(tokens.get(0), tokens.get(1)); } return state; }
for (String additionalTableName : this.props.getPropAsList(additionalNamesProp)) { String resolvedTableName = primaryTableName.isPresent() ? StringUtils.replace(additionalTableName, PRIMARY_TABLE_TOKEN,
/** * Obtain Hive database names. The returned {@link Iterable} contains the database name returned by * {@link #getDatabaseName(Path)} (if present) plus additional database names specified in * {@link #ADDITIONAL_HIVE_DATABASE_NAMES}. * */ protected Iterable<String> getDatabaseNames(Path path) { List<String> databaseNames = Lists.newArrayList(); Optional<String> databaseName; if ((databaseName = getDatabaseName(path)).isPresent()) { databaseNames.add(databaseName.get()); } if (!Strings.isNullOrEmpty(this.props.getProp(ADDITIONAL_HIVE_DATABASE_NAMES))) { for (String additionalDbName : this.props.getPropAsList(ADDITIONAL_HIVE_DATABASE_NAMES)) { databaseNames.add(this.dbNamePrefix + additionalDbName + this.dbNameSuffix); } } Preconditions.checkState(!databaseNames.isEmpty(), "Hive database name not specified"); return databaseNames; }
/** * Create a {@link State} object that contains Hive table properties. These properties are obtained from * {@link #HIVE_TABLE_PARTITION_PROPS}, which is a list of comma-separated properties. Each property is in the form * of '[key]=[value]'. */ private State createHiveProps(String propKey) { State state = new State(); if (!contains(propKey)) { return state; } for (String propValue : getPropAsList(propKey)) { List<String> tokens = SPLITTER.splitToList(propValue); Preconditions.checkState(tokens.size() == 2, propValue + " is not a valid Hive table/partition property"); state.setProp(tokens.get(0), tokens.get(1)); } return state; }
for (String additionalTableName : this.props.getPropAsList(additionalNamesProp)) { String resolvedTableName = primaryTableName.isPresent() ? StringUtils.replace(additionalTableName, PRIMARY_TABLE_TOKEN,