org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo Java Examples

The following examples show how to use org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo. 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: CatalogThriftHiveMetastore.java    From metacat with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public PrincipalPrivilegeSet get_privilege_set(final HiveObjectRef hiveObject, final String userName,
                                               final List<String> groupNames)
    throws TException {
    MetacatContextManager.getContext().setUserName(userName);
    return requestWrapper("get_privilege_set", new Object[]{hiveObject, userName, groupNames},
        () -> {
            Map<String, List<PrivilegeGrantInfo>> groupPrivilegeSet = null;
            Map<String, List<PrivilegeGrantInfo>> userPrivilegeSet = null;

            if (groupNames != null) {
                groupPrivilegeSet = groupNames.stream()
                    .collect(Collectors.toMap(p -> p, p -> Lists.newArrayList()));
            }
            if (userName != null) {
                userPrivilegeSet = ImmutableMap.of(userName, Lists.newArrayList());
            }
            return new PrincipalPrivilegeSet(userPrivilegeSet,
                groupPrivilegeSet,
                defaultRolesPrivilegeSet);
        });
}
 
Example #2
Source File: ThriftHiveMetastore.java    From presto with Apache License 2.0 6 votes vote down vote up
private PrivilegeBag buildPrivilegeBag(
        String databaseName,
        String tableName,
        HivePrincipal grantee,
        Set<PrivilegeGrantInfo> privilegeGrantInfos)
{
    ImmutableList.Builder<HiveObjectPrivilege> privilegeBagBuilder = ImmutableList.builder();
    for (PrivilegeGrantInfo privilegeGrantInfo : privilegeGrantInfos) {
        privilegeBagBuilder.add(
                new HiveObjectPrivilege(
                        new HiveObjectRef(TABLE, databaseName, tableName, null, null),
                        grantee.getName(),
                        fromPrestoPrincipalType(grantee.getType()),
                        privilegeGrantInfo));
    }
    return new PrivilegeBag(privilegeBagBuilder.build());
}
 
Example #3
Source File: ThriftMetastoreUtil.java    From presto with Apache License 2.0 6 votes vote down vote up
public static Set<HivePrivilegeInfo> parsePrivilege(PrivilegeGrantInfo userGrant, Optional<HivePrincipal> grantee)
{
    boolean grantOption = userGrant.isGrantOption();
    String name = userGrant.getPrivilege().toUpperCase(ENGLISH);
    HivePrincipal grantor = new HivePrincipal(fromMetastoreApiPrincipalType(userGrant.getGrantorType()), userGrant.getGrantor());
    switch (name) {
        case "ALL":
            return Arrays.stream(HivePrivilegeInfo.HivePrivilege.values())
                    .map(hivePrivilege -> new HivePrivilegeInfo(hivePrivilege, grantOption, grantor, grantee.orElse(grantor)))
                    .collect(toImmutableSet());
        case "SELECT":
            return ImmutableSet.of(new HivePrivilegeInfo(SELECT, grantOption, grantor, grantee.orElse(grantor)));
        case "INSERT":
            return ImmutableSet.of(new HivePrivilegeInfo(INSERT, grantOption, grantor, grantee.orElse(grantor)));
        case "UPDATE":
            return ImmutableSet.of(new HivePrivilegeInfo(UPDATE, grantOption, grantor, grantee.orElse(grantor)));
        case "DELETE":
            return ImmutableSet.of(new HivePrivilegeInfo(DELETE, grantOption, grantor, grantee.orElse(grantor)));
        case "OWNERSHIP":
            return ImmutableSet.of(new HivePrivilegeInfo(OWNERSHIP, grantOption, grantor, grantee.orElse(grantor)));
        default:
            throw new IllegalArgumentException("Unsupported privilege name: " + name);
    }
}
 
Example #4
Source File: PartitionAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 6 votes vote down vote up
@Test
public void allShortCircuit() {
  left.getPartition().getParameters().put("com.company.key", "value");
  left.getPartition().setValues(ImmutableList.of("p1", "p2"));
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getPartition().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  left.getPartition().getSd().setLocation("left");
  left.getPartition().getSd().setInputFormat("LeftInputFormat");
  left.getPartition().getSd().setOutputFormat("LeftOutputFormat");
  left.getPartition().getSd().getParameters().put("com.company.key", "value");
  left.getPartition().getSd().getSerdeInfo().setName("left serde info");
  left.getPartition().getSd().getSkewedInfo().setSkewedColNames(ImmutableList.of("left skewed col"));
  left.getPartition().getSd().setCols(ImmutableList.of(new FieldSchema("left", "type", "comment")));
  left.getPartition().getSd().setSortCols(ImmutableList.of(new Order()));
  left.getPartition().getSd().setBucketCols(ImmutableList.of("bucket"));
  left.getPartition().getSd().setNumBuckets(9000);

  List<Diff<Object, Object>> diffs = newPartitionAndMetadataComparator(SHORT_CIRCUIT).compare(left, right);

  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(1));
  assertThat(diffs.get(0), is(newPropertyDiff(PartitionAndMetadata.class, "partition.parameters",
      left.getPartition().getParameters(), right.getPartition().getParameters())));
}
 
Example #5
Source File: HiveTableManagerTest.java    From data-highway with Apache License 2.0 5 votes vote down vote up
@Test
public void grantPublicSelect() throws Exception {
  underTest.grantPublicSelect(TABLE, "grantor");

  ArgumentCaptor<PrivilegeBag> privilegeBagCaptor = ArgumentCaptor.forClass(PrivilegeBag.class);
  verify(metaStoreClient).grant_privileges(privilegeBagCaptor.capture());

  PrivilegeBag privilegeBag = privilegeBagCaptor.getValue();
  assertThat(privilegeBag.getPrivilegesSize(), is(1));
  HiveObjectPrivilege privilege = privilegeBag.getPrivileges().get(0);

  HiveObjectRef hiveObject = privilege.getHiveObject();
  assertThat(hiveObject.getObjectType(), is(HiveObjectType.TABLE));
  assertThat(hiveObject.getDbName(), is(DATABASE));
  assertThat(hiveObject.getObjectName(), is(TABLE));
  assertThat(hiveObject.getPartValues(), is(nullValue()));
  assertThat(hiveObject.getColumnName(), is(nullValue()));

  assertThat(privilege.getPrincipalName(), is("public"));
  assertThat(privilege.getPrincipalType(), is(ROLE));

  PrivilegeGrantInfo grantInfo = privilege.getGrantInfo();
  assertThat(grantInfo.getPrivilege(), is("SELECT"));
  assertThat(grantInfo.getCreateTime(), is(0));
  assertThat(grantInfo.getGrantor(), is("grantor"));
  assertThat(grantInfo.getGrantorType(), is(ROLE));
  assertThat(grantInfo.isGrantOption(), is(false));
}
 
Example #6
Source File: PartitionTransformationTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
  partition = new Partition();
  partition.setDbName("database");
  partition.setTableName("table");
  partition.setValues(ImmutableList.of("part"));

  Map<String, List<PrivilegeGrantInfo>> userPrivileges = new HashMap<>();
  userPrivileges.put("read", ImmutableList.of(new PrivilegeGrantInfo()));
  PrincipalPrivilegeSet privileges = new PrincipalPrivilegeSet();
  privileges.setUserPrivileges(userPrivileges);
  partition.setPrivileges(privileges);

  StorageDescriptor storageDescriptor = new StorageDescriptor();
  storageDescriptor.setCols(Arrays.asList(new FieldSchema("a", "int", null)));
  storageDescriptor.setInputFormat("input_format");
  storageDescriptor.setOutputFormat("output_format");
  storageDescriptor.setSerdeInfo(new SerDeInfo("serde", "lib", new HashMap<String, String>()));
  storageDescriptor.setSkewedInfo(new SkewedInfo());
  storageDescriptor.setParameters(new HashMap<String, String>());
  storageDescriptor.setLocation("database/table/part/");
  partition.setSd(storageDescriptor);

  Map<String, String> parameters = new HashMap<>();
  parameters.put("com.company.parameter", "abc");
  partition.setParameters(parameters);
}
 
Example #7
Source File: TableTransformationTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
  table = new Table();
  table.setDbName("database");
  table.setTableName("table");
  table.setTableType("type");

  Map<String, List<PrivilegeGrantInfo>> userPrivileges = new HashMap<>();
  userPrivileges.put("read", ImmutableList.of(new PrivilegeGrantInfo()));
  PrincipalPrivilegeSet privileges = new PrincipalPrivilegeSet();
  privileges.setUserPrivileges(userPrivileges);
  table.setPrivileges(privileges);

  StorageDescriptor storageDescriptor = new StorageDescriptor();
  storageDescriptor.setCols(Arrays.asList(new FieldSchema("a", "int", null)));
  storageDescriptor.setInputFormat("input_format");
  storageDescriptor.setOutputFormat("output_format");
  storageDescriptor.setSerdeInfo(new SerDeInfo("serde", "lib", new HashMap<String, String>()));
  storageDescriptor.setSkewedInfo(new SkewedInfo());
  storageDescriptor.setParameters(new HashMap<String, String>());
  storageDescriptor.setLocation("database/table/");
  table.setSd(storageDescriptor);

  Map<String, String> parameters = new HashMap<>();
  parameters.put("com.company.parameter", "abc");
  table.setParameters(parameters);
}
 
Example #8
Source File: TestUtils.java    From circus-train with Apache License 2.0 5 votes vote down vote up
public static Partition newPartition(String database, String tableName, String partitionValue) {
  Partition partition = new Partition();
  partition.setDbName(database);
  partition.setTableName(tableName);
  partition.setCreateTime(CREATE_TIME);
  partition.setValues(ImmutableList.of(partitionValue));

  Map<String, List<PrivilegeGrantInfo>> userPrivileges = new HashMap<>();
  userPrivileges.put("read", ImmutableList.of(new PrivilegeGrantInfo()));
  PrincipalPrivilegeSet privileges = new PrincipalPrivilegeSet();
  privileges.setUserPrivileges(userPrivileges);
  partition.setPrivileges(privileges);

  StorageDescriptor storageDescriptor = new StorageDescriptor();
  storageDescriptor.setCols(COLS);
  storageDescriptor.setInputFormat(INPUT_FORMAT);
  storageDescriptor.setOutputFormat(OUTPUT_FORMAT);
  storageDescriptor.setSerdeInfo(new SerDeInfo(SERDE_INFO_NAME, SERIALIZATION_LIB, new HashMap<String, String>()));
  storageDescriptor.setSkewedInfo(new SkewedInfo());
  storageDescriptor.setParameters(new HashMap<String, String>());
  storageDescriptor.setLocation(DATABASE + "/" + tableName + "/" + partitionValue + "/");
  partition.setSd(storageDescriptor);

  Map<String, String> parameters = new HashMap<>();
  parameters.put("com.company.parameter", "abc");
  partition.setParameters(parameters);

  return partition;
}
 
Example #9
Source File: TestUtils.java    From circus-train with Apache License 2.0 5 votes vote down vote up
public static Table newTable(String database, String tableName) {
  Table table = new Table();
  table.setDbName(database);
  table.setTableName(tableName);
  table.setTableType(TABLE_TYPE);
  table.setOwner(OWNER);
  table.setCreateTime(CREATE_TIME);
  table.setRetention(RETENTION);

  Map<String, List<PrivilegeGrantInfo>> userPrivileges = new HashMap<>();
  userPrivileges.put("read", ImmutableList.of(new PrivilegeGrantInfo()));
  PrincipalPrivilegeSet privileges = new PrincipalPrivilegeSet();
  privileges.setUserPrivileges(userPrivileges);
  table.setPrivileges(privileges);

  StorageDescriptor storageDescriptor = new StorageDescriptor();
  storageDescriptor.setCols(COLS);
  storageDescriptor.setInputFormat(INPUT_FORMAT);
  storageDescriptor.setOutputFormat(OUTPUT_FORMAT);
  storageDescriptor.setSerdeInfo(new SerDeInfo(SERDE_INFO_NAME, SERIALIZATION_LIB, new HashMap<String, String>()));
  storageDescriptor.setSkewedInfo(new SkewedInfo());
  storageDescriptor.setParameters(new HashMap<String, String>());
  storageDescriptor.setLocation(DATABASE + "/" + tableName + "/");
  table.setSd(storageDescriptor);

  Map<String, String> parameters = new HashMap<>();
  parameters.put("com.company.parameter", "abc");
  table.setParameters(parameters);

  return table;
}
 
Example #10
Source File: TableAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Test
public void allShortCircuit() {
  left.getTable().getParameters().put("com.company.key", "value");
  left.getTable().setPartitionKeys(ImmutableList.of(new FieldSchema("p", "string", "p comment")));
  left.getTable().setOwner("left owner");
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getTable().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  left.getTable().setRetention(2);
  left.getTable().setTableType("internal");
  left.getTable().getSd().setLocation("left");
  left.getTable().getSd().setInputFormat("LeftInputFormat");
  left.getTable().getSd().setOutputFormat("LeftOutputFormat");
  left.getTable().getSd().getParameters().put("com.company.key", "value");
  left.getTable().getSd().getSerdeInfo().setName("left serde info");
  left.getTable().getSd().getSkewedInfo().setSkewedColNames(ImmutableList.of("left skewed col"));
  left.getTable().getSd().setCols(ImmutableList.of(new FieldSchema("left", "type", "comment")));
  left.getTable().getSd().setSortCols(ImmutableList.of(new Order()));
  left.getTable().getSd().setBucketCols(ImmutableList.of("bucket"));
  left.getTable().getSd().setNumBuckets(9000);

  List<Diff<Object, Object>> diffs = newTableAndMetadataComparator(SHORT_CIRCUIT).compare(left, right);

  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(1));
  assertThat(diffs.get(0), is(newPropertyDiff(TableAndMetadata.class, "table.parameters",
      left.getTable().getParameters(), right.getTable().getParameters())));
}
 
Example #11
Source File: TableAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Test
public void privilegesFullComparison() {
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getTable().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  List<Diff<Object, Object>> diffs = newTableAndMetadataComparator(FULL_COMPARISON).compare(left, right);
  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(0));
}
 
Example #12
Source File: TableAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Test
public void privilegesShortCircuit() {
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getTable().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  List<Diff<Object, Object>> diffs = newTableAndMetadataComparator(SHORT_CIRCUIT).compare(left, right);
  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(0));
}
 
Example #13
Source File: PartitionAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Test
public void privilegesFullComparison() {
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getPartition().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  List<Diff<Object, Object>> diffs = newPartitionAndMetadataComparator(FULL_COMPARISON).compare(left, right);
  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(0));
}
 
Example #14
Source File: PartitionAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Test
public void privilegesShortCircuit() {
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getPartition().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  List<Diff<Object, Object>> diffs = newPartitionAndMetadataComparator(SHORT_CIRCUIT).compare(left, right);
  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(0));
}
 
Example #15
Source File: ThriftMetastoreUtil.java    From presto with Apache License 2.0 5 votes vote down vote up
public static PrivilegeGrantInfo toMetastoreApiPrivilegeGrantInfo(HivePrivilegeInfo privilegeInfo)
{
    return new PrivilegeGrantInfo(
            privilegeInfo.getHivePrivilege().name().toLowerCase(ENGLISH),
            0,
            privilegeInfo.getGrantor().getName(),
            fromPrestoPrincipalType(privilegeInfo.getGrantor().getType()),
            privilegeInfo.isGrantOption());
}
 
Example #16
Source File: HiveTableManager.java    From data-highway with Apache License 2.0 5 votes vote down vote up
public void grantPublicSelect(String tableName, String grantor) {
  HiveObjectRef hiveObject = new HiveObjectRef(TABLE, databaseName, tableName, null, null);
  PrivilegeGrantInfo grantInfo = new PrivilegeGrantInfo("SELECT", 0, grantor, ROLE, false);
  HiveObjectPrivilege privilege = new HiveObjectPrivilege(hiveObject, "public", ROLE, grantInfo);
  PrivilegeBag privilegeBag = new PrivilegeBag(singletonList(privilege));
  try {
    metaStoreClient.grant_privileges(privilegeBag);
  } catch (TException e) {
    throw new MetaStoreException(e);
  }
}
 
Example #17
Source File: PartitionAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 4 votes vote down vote up
@Test
public void allFullComparison() {
  left.getPartition().getParameters().put("com.company.key", "value");
  left.getPartition().setValues(ImmutableList.of("p1", "p2"));
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getPartition().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  left.getPartition().getSd().setLocation("left");
  left.getPartition().getSd().setInputFormat("LeftInputFormat");
  left.getPartition().getSd().setOutputFormat("LeftOutputFormat");
  left.getPartition().getSd().getParameters().put("com.company.key", "value");
  left.getPartition().getSd().getSerdeInfo().setName("left serde info");
  left.getPartition().getSd().getSkewedInfo().setSkewedColNames(ImmutableList.of("left skewed col"));
  left.getPartition().getSd().setCols(ImmutableList.of(new FieldSchema("left", "type", "comment")));
  left.getPartition().getSd().setSortCols(ImmutableList.of(new Order()));
  left.getPartition().getSd().setBucketCols(ImmutableList.of("bucket"));
  left.getPartition().getSd().setNumBuckets(9000);

  List<Diff<Object, Object>> diffs = newPartitionAndMetadataComparator(FULL_COMPARISON).compare(left, right);

  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(10));
  assertThat(diffs.get(0), is(newPropertyDiff(PartitionAndMetadata.class, "partition.parameters",
      left.getPartition().getParameters(), right.getPartition().getParameters())));
  assertThat(diffs.get(1), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.inputFormat",
      left.getPartition().getSd().getInputFormat(), right.getPartition().getSd().getInputFormat())));
  assertThat(diffs.get(2), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.outputFormat",
      left.getPartition().getSd().getOutputFormat(), right.getPartition().getSd().getOutputFormat())));
  assertThat(diffs.get(3), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.parameters",
      left.getPartition().getSd().getParameters(), right.getPartition().getSd().getParameters())));
  assertThat(diffs.get(4), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.serdeInfo",
      left.getPartition().getSd().getSerdeInfo(), right.getPartition().getSd().getSerdeInfo())));
  assertThat(diffs.get(5), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.skewedInfo",
      left.getPartition().getSd().getSkewedInfo(), right.getPartition().getSd().getSkewedInfo())));
  assertThat(diffs.get(6),
      is(newDiff(
          "Collection partition.sd.cols of class com.google.common.collect.SingletonImmutableList has different size: left.size()=1 and right.size()=2",
          left.getPartition().getSd().getCols(), right.getPartition().getSd().getCols())));
  assertThat(diffs.get(7), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.sortCols",
      left.getPartition().getSd().getSortCols(), right.getPartition().getSd().getSortCols())));
  assertThat(diffs.get(8), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.bucketCols",
      left.getPartition().getSd().getBucketCols(), right.getPartition().getSd().getBucketCols())));
  assertThat(diffs.get(9), is(newPropertyDiff(PartitionAndMetadata.class, "partition.sd.numBuckets",
      left.getPartition().getSd().getNumBuckets(), right.getPartition().getSd().getNumBuckets())));
}
 
Example #18
Source File: TableAndMetadataComparatorTest.java    From circus-train with Apache License 2.0 4 votes vote down vote up
@Test
public void allFullComparison() {
  left.getTable().getParameters().put("com.company.key", "value");
  left.getTable().setPartitionKeys(ImmutableList.of(new FieldSchema("p", "string", "p comment")));
  left.getTable().setOwner("left owner");
  List<PrivilegeGrantInfo> privilege = ImmutableList.of(new PrivilegeGrantInfo());
  left.getTable().setPrivileges(new PrincipalPrivilegeSet(ImmutableMap.of("write", privilege), null, null));
  left.getTable().setRetention(2);
  left.getTable().setTableType("internal");
  left.getTable().getSd().setLocation("left");
  left.getTable().getSd().setInputFormat("LeftInputFormat");
  left.getTable().getSd().setOutputFormat("LeftOutputFormat");
  left.getTable().getSd().getParameters().put("com.company.key", "value");
  left.getTable().getSd().getSerdeInfo().setName("left serde info");
  left.getTable().getSd().getSkewedInfo().setSkewedColNames(ImmutableList.of("left skewed col"));
  left.getTable().getSd().setCols(ImmutableList.of(new FieldSchema("left", "type", "comment")));
  left.getTable().getSd().setSortCols(ImmutableList.of(new Order()));
  left.getTable().getSd().setBucketCols(ImmutableList.of("bucket"));
  left.getTable().getSd().setNumBuckets(9000);

  List<Diff<Object, Object>> diffs = newTableAndMetadataComparator(FULL_COMPARISON).compare(left, right);

  assertThat(diffs, is(notNullValue()));
  assertThat(diffs.size(), is(12));
  assertThat(diffs.get(0), is(newPropertyDiff(TableAndMetadata.class, "table.parameters",
      left.getTable().getParameters(), right.getTable().getParameters())));
  assertThat(diffs.get(1), is(newPropertyDiff(TableAndMetadata.class, "table.partitionKeys",
      left.getTable().getPartitionKeys(), right.getTable().getPartitionKeys())));
  assertThat(diffs.get(2), is(newPropertyDiff(TableAndMetadata.class, "table.retention",
      left.getTable().getRetention(), right.getTable().getRetention())));
  assertThat(diffs.get(3), is(newPropertyDiff(TableAndMetadata.class, "table.sd.inputFormat",
      left.getTable().getSd().getInputFormat(), right.getTable().getSd().getInputFormat())));
  assertThat(diffs.get(4), is(newPropertyDiff(TableAndMetadata.class, "table.sd.outputFormat",
      left.getTable().getSd().getOutputFormat(), right.getTable().getSd().getOutputFormat())));
  assertThat(diffs.get(5), is(newPropertyDiff(TableAndMetadata.class, "table.sd.parameters",
      left.getTable().getSd().getParameters(), right.getTable().getSd().getParameters())));
  assertThat(diffs.get(6), is(newPropertyDiff(TableAndMetadata.class, "table.sd.serdeInfo",
      left.getTable().getSd().getSerdeInfo(), right.getTable().getSd().getSerdeInfo())));
  assertThat(diffs.get(7), is(newPropertyDiff(TableAndMetadata.class, "table.sd.skewedInfo",
      left.getTable().getSd().getSkewedInfo(), right.getTable().getSd().getSkewedInfo())));
  assertThat(diffs.get(8),
      is(newDiff(
          "Collection table.sd.cols of class com.google.common.collect.SingletonImmutableList has different size: left.size()=1 and right.size()=2",
          left.getTable().getSd().getCols(), right.getTable().getSd().getCols())));
  assertThat(diffs.get(9), is(newPropertyDiff(TableAndMetadata.class, "table.sd.sortCols",
      left.getTable().getSd().getSortCols(), right.getTable().getSd().getSortCols())));
  assertThat(diffs.get(10), is(newPropertyDiff(TableAndMetadata.class, "table.sd.bucketCols",
      left.getTable().getSd().getBucketCols(), right.getTable().getSd().getBucketCols())));
  assertThat(diffs.get(11), is(newPropertyDiff(TableAndMetadata.class, "table.sd.numBuckets",
      left.getTable().getSd().getNumBuckets(), right.getTable().getSd().getNumBuckets())));
}
 
Example #19
Source File: ThriftHiveMetastore.java    From presto with Apache License 2.0 4 votes vote down vote up
private boolean containsAllPrivilege(Set<PrivilegeGrantInfo> requestedPrivileges)
{
    return requestedPrivileges.stream()
            .anyMatch(privilege -> privilege.getPrivilege().equalsIgnoreCase("all"));
}