Java Code Examples for org.apache.hadoop.hive.metastore.api.SerDeInfo#setName()
The following examples show how to use
org.apache.hadoop.hive.metastore.api.SerDeInfo#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalogToHiveConverter.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
public static SerDeInfo convertSerDeInfo(com.amazonaws.services.glue.model.SerDeInfo catalogSerDeInfo){ SerDeInfo hiveSerDeInfo = new SerDeInfo(); hiveSerDeInfo.setName(catalogSerDeInfo.getName()); hiveSerDeInfo.setParameters(firstNonNull(catalogSerDeInfo.getParameters(), Maps.<String, String>newHashMap())); hiveSerDeInfo.setSerializationLib(catalogSerDeInfo.getSerializationLibrary()); return hiveSerDeInfo; }
Example 2
Source File: ThriftMetastoreUtil.java From presto with Apache License 2.0 | 5 votes |
private static StorageDescriptor makeStorageDescriptor(String tableName, List<Column> columns, Storage storage) { SerDeInfo serdeInfo = new SerDeInfo(); serdeInfo.setName(tableName); serdeInfo.setSerializationLib(storage.getStorageFormat().getSerDeNullable()); serdeInfo.setParameters(storage.getSerdeParameters()); StorageDescriptor sd = new StorageDescriptor(); sd.setLocation(emptyToNull(storage.getLocation())); sd.setCols(columns.stream() .map(ThriftMetastoreUtil::toMetastoreApiFieldSchema) .collect(toImmutableList())); sd.setSerdeInfo(serdeInfo); sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable()); sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable()); sd.setSkewedInfoIsSet(storage.isSkewed()); sd.setParameters(ImmutableMap.of()); Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty(); if (bucketProperty.isPresent()) { sd.setNumBuckets(bucketProperty.get().getBucketCount()); sd.setBucketCols(bucketProperty.get().getBucketedBy()); if (!bucketProperty.get().getSortedBy().isEmpty()) { sd.setSortCols(bucketProperty.get().getSortedBy().stream() .map(column -> new Order(column.getColumnName(), column.getOrder().getHiveOrder())) .collect(toImmutableList())); } } return sd; }
Example 3
Source File: HiveMetaStoreUtils.java From incubator-gobblin with Apache License 2.0 | 5 votes |
public static SerDeInfo getSerDeInfo(HiveRegistrationUnit unit) { State props = unit.getSerDeProps(); SerDeInfo si = new SerDeInfo(); si.setParameters(getParameters(props)); si.setName(unit.getTableName()); if (unit.getSerDeType().isPresent()) { si.setSerializationLib(unit.getSerDeType().get()); } return si; }
Example 4
Source File: MetaStoreRestApiTest.java From submarine with Apache License 2.0 | 4 votes |
@Before public void createDatabase() { Database database = new Database(); database.setName("testdb"); database.setDescription("testdb"); database.setLocationUri("hdfs://mycluster/user/hive/warehouse/testdb.db"); Map<String, String> map = new HashMap<>(); map.put("key", "value"); database.setParameters(map); database.setOwnerName("root"); database.setOwnerType(PrincipalType.USER); Gson gson = new Gson(); String databaseJson = gson.toJson(database); metaStoreApi.createDatabase(databaseJson); Response databaseCountResponse = metaStoreApi.getDatabaseCount(); assertEquals(databaseCountResponse.getStatus(), Response.Status.OK.getStatusCode()); assertTrue(((String) databaseCountResponse.getEntity()).contains("\"result\":1")); Table table = new Table(); table.setTableName("testtable"); table.setDbName("testdb"); table.setOwner("root"); table.setCreateTime((int) new java.util.Date().getTime() / 1000); table.setLastAccessTime((int) new Date().getTime() / 1000); table.setRetention(0); StorageDescriptor sd = new StorageDescriptor(); List<FieldSchema> fieldSchemas = new ArrayList<>(); FieldSchema fieldSchema = new FieldSchema(); fieldSchema.setName("a"); fieldSchema.setType("int"); fieldSchema.setComment("a"); fieldSchemas.add(fieldSchema); sd.setCols(fieldSchemas); sd.setLocation("hdfs://mycluster/user/hive/warehouse/testdb.db/testtable"); sd.setInputFormat("org.apache.hadoop.mapred.TextInputFormat"); sd.setOutputFormat("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"); sd.setCompressed(false); sd.setNumBuckets(-1); SerDeInfo serdeInfo = new SerDeInfo(); serdeInfo.setName("test"); serdeInfo.setSerializationLib("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"); Map<String, String> parametersMap = new HashMap<>(); parametersMap.put("serialization.format", "|"); parametersMap.put("field.delim", "|"); serdeInfo.setParameters(parametersMap); sd.setSerdeInfo(serdeInfo); table.setSd(sd); List<FieldSchema> partitionKeys = new ArrayList<>(); table.setPartitionKeys(partitionKeys); Map<String, String> parameters = new HashMap<>(); table.setParameters(parameters); String viewOriginalText = ""; table.setViewOriginalText(viewOriginalText); String viewExpandedText = ""; table.setViewExpandedText(viewExpandedText); String tableType = "MANAGED_TABLE"; table.setTableType(tableType); String tableJson = gson.toJson(table); metaStoreApi.createTable(tableJson); Response tableResponse = metaStoreApi.getTable("testdb", "testtable"); assertEquals(tableResponse.getStatus(), Response.Status.OK.getStatusCode()); assertTrue(((String) tableResponse.getEntity()).contains("\"tableName\":\"testtable\"")); Response tableCountResponse = metaStoreApi.getTableCount(); assertEquals(tableCountResponse.getStatus(), Response.Status.OK.getStatusCode()); assertTrue(((String) tableCountResponse.getEntity()).contains("\"result\":1")); }
Example 5
Source File: SubmarineMetaStoreTest.java From submarine with Apache License 2.0 | 4 votes |
@Before public void createDatabase() throws InvalidObjectException, MetaException { listTables(); Database database = new Database(); database.setName("testdb"); database.setDescription("testdb"); database.setLocationUri("hdfs://mycluster/user/hive/warehouse/testdb.db"); Map map = new HashMap(); map.put("key", "value"); database.setParameters(map); database.setOwnerName("root"); database.setOwnerType(PrincipalType.USER); submarineMetaStore.createDatabase(database); assertEquals(1, submarineMetaStore.getDatabaseCount()); Table table = new Table(); table.setTableName("testtable"); table.setDbName("testdb"); table.setOwner("root"); table.setCreateTime((int) new Date().getTime() / 1000); table.setLastAccessTime((int) new Date().getTime() / 1000); table.setRetention(0); StorageDescriptor sd = new StorageDescriptor(); List<FieldSchema> fieldSchemas = new ArrayList<>(); FieldSchema fieldSchema = new FieldSchema(); fieldSchema.setName("a"); fieldSchema.setType("int"); fieldSchema.setComment("a"); fieldSchemas.add(fieldSchema); sd.setCols(fieldSchemas); sd.setLocation("hdfs://mycluster/user/hive/warehouse/testdb.db/testtable"); sd.setInputFormat("org.apache.hadoop.mapred.TextInputFormat"); sd.setOutputFormat("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"); sd.setCompressed(false); sd.setNumBuckets(-1); SerDeInfo serdeInfo = new SerDeInfo(); serdeInfo.setName("test"); serdeInfo.setSerializationLib("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"); Map<String, String> parametersMap = new HashMap(); parametersMap.put("serialization.format", "|"); parametersMap.put("field.delim", "|"); serdeInfo.setParameters(parametersMap); sd.setSerdeInfo(serdeInfo); table.setSd(sd); List<FieldSchema> partitionKeys = new ArrayList<>(); table.setPartitionKeys(partitionKeys); Map<String, String> parameters = new HashMap<>(); table.setParameters(parameters); String viewOriginalText = ""; table.setViewOriginalText(viewOriginalText); String viewExpandedText = ""; table.setViewExpandedText(viewExpandedText); String tableType = "MANAGED_TABLE"; table.setTableType(tableType); submarineMetaStore.createTable(table); Table tableTest = submarineMetaStore.getTable("testdb", "testtable"); assertEquals("testtable", tableTest.getTableName()); int tableCount = submarineMetaStore.getTableCount(); assertEquals(1, tableCount); }