final public Properties getMetadata() { return MetaStoreUtils.getTableMetadata(tTable); }
/** * Retrieves the table properties as well as the properties from Serde. */ private static Map<String, String> getTableParameters(Table table) { Map<String, String> originalTableParameters = new HashMap<>(table.getParameters()); Properties tableMetadata = MetaStoreUtils.getTableMetadata(table); for (String property : tableMetadata.stringPropertyNames()) { if (!originalTableParameters.containsKey(property)) { originalTableParameters.put(property, tableMetadata.getProperty(property)); } } return originalTableParameters; }
public static Deserializer getDeserializer(Configuration conf, org.apache.hadoop.hive.metastore.api.Table table, boolean skipConfError, String lib) throws MetaException { try { Deserializer deserializer = ReflectionUtil.newInstance(conf.getClassByName(lib). asSubclass(Deserializer.class), conf); if (skipConfError) { SerDeUtils.initializeSerDeWithoutErrorCheck(deserializer, conf, MetaStoreUtils.getTableMetadata(table), null); } else { SerDeUtils.initializeSerDe(deserializer, conf, MetaStoreUtils.getTableMetadata(table), null); } return deserializer; } catch (RuntimeException e) { throw e; } catch (Throwable e) { LOG.error("error in initSerDe: " + e.getClass().getName() + " " + e.getMessage(), e); throw new MetaException(e.getClass().getName() + " " + e.getMessage()); } }
/** * Creates LazySimpleSerde * @return * @throws SerializationError if serde could not be initialized * @param tbl */ protected static LazySimpleSerDe createSerde(Table tbl, HiveConf conf, char serdeSeparator) throws SerializationError { try { Properties tableProps = MetaStoreUtils.getTableMetadata(tbl); tableProps.setProperty("field.delim", String.valueOf(serdeSeparator)); LazySimpleSerDe serde = new LazySimpleSerDe(); SerDeUtils.initializeSerDe(serde, conf, tableProps, null); return serde; } catch (SerDeException e) { throw new SerializationError("Error initializing serde", e); } }
/** * Creates RegexSerDe * @param tbl used to create serde * @param conf used to create serde * @param regex used to create serde * @return * @throws SerializationError if serde could not be initialized */ private static RegexSerDe createSerde(Table tbl, HiveConf conf, String regex) throws SerializationError { try { Properties tableProps = MetaStoreUtils.getTableMetadata(tbl); tableProps.setProperty(RegexSerDe.INPUT_REGEX, regex); ArrayList<String> tableColumns = getCols(tbl); tableProps.setProperty(serdeConstants.LIST_COLUMNS, StringUtils.join(tableColumns, ",")); RegexSerDe serde = new RegexSerDe(); SerDeUtils.initializeSerDe(serde, conf, tableProps, null); return serde; } catch (SerDeException e) { throw new SerializationError("Error initializing serde " + RegexSerDe.class.getName(), e); } }
/** * Creates JsonSerDe * @param tbl used to create serde * @param conf used to create serde * @return * @throws SerializationError if serde could not be initialized */ private static JsonSerDe createSerde(Table tbl, HiveConf conf) throws SerializationError { try { Properties tableProps = MetaStoreUtils.getTableMetadata(tbl); JsonSerDe serde = new JsonSerDe(); SerDeUtils.initializeSerDe(serde, conf, tableProps, null); return serde; } catch (SerDeException e) { throw new SerializationError("Error initializing serde " + JsonSerDe.class.getName(), e); } }
Deserializer deserializer = ReflectionUtil.newInstance(conf.getClassByName(lib). asSubclass(Deserializer.class), conf); SerDeUtils.initializeSerDe(deserializer, conf, MetaStoreUtils.getTableMetadata(table), MetaStoreUtils.getPartitionMetadata(part, table)); return deserializer;