diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/ConstraintBuilder.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/ConstraintBuilder.java new file mode 100644 index 0000000000..50e779a22b --- /dev/null +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/ConstraintBuilder.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+/**
+ * Base builder for all types of constraints. Database name, table name, and column name
+ * must be provided.
+ * @param
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
+import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
+import org.apache.thrift.TException;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A builder for {@link Database}. The name of the new database is required. Everything else
+ * selects reasonable defaults.
+ */
+public class DatabaseBuilder {
+ private String name, description, location;
+ private Map
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.GrantRevokePrivilegeRequest;
+import org.apache.hadoop.hive.metastore.api.GrantRevokeType;
+import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
+
+/**
+ * A builder for {@link GrantRevokePrivilegeRequest}. The revoke of grant option defaults to
+ * false. The request Type and the privileges must be provided.
+ */
+public class GrantRevokePrivilegeRequestBuilder {
+ private GrantRevokeType requestType;
+ private PrivilegeBag privileges;
+ private boolean revokeGrantOption;
+
+ public GrantRevokePrivilegeRequestBuilder() {
+ privileges = new PrivilegeBag();
+ revokeGrantOption = false;
+ }
+
+ public GrantRevokePrivilegeRequestBuilder setRequestType(GrantRevokeType requestType) {
+ this.requestType = requestType;
+ return this;
+ }
+
+ public GrantRevokePrivilegeRequestBuilder setRevokeGrantOption(boolean revokeGrantOption) {
+ this.revokeGrantOption = revokeGrantOption;
+ return this;
+ }
+
+ public GrantRevokePrivilegeRequestBuilder addPrivilege(HiveObjectPrivilege privilege) {
+ privileges.addToPrivileges(privilege);
+ return this;
+ }
+
+ public GrantRevokePrivilegeRequest build() throws MetaException {
+ if (requestType == null || privileges.getPrivilegesSize() == 0) {
+ throw new MetaException("The request type and at least one privilege must be provided.");
+ }
+ GrantRevokePrivilegeRequest rqst = new GrantRevokePrivilegeRequest(requestType, privileges);
+ if (revokeGrantOption) rqst.setRevokeGrantOption(revokeGrantOption);
+ return rqst;
+ }
+}
diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveObjectPrivilegeBuilder.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveObjectPrivilegeBuilder.java
new file mode 100644
index 0000000000..d802e1a971
--- /dev/null
+++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveObjectPrivilegeBuilder.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
+import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
+import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo;
+
+/**
+ * Builder for {@link HiveObjectPrivilege}. All values must be set.
+ */
+public class HiveObjectPrivilegeBuilder {
+ private HiveObjectRef hiveObjectRef;
+ private String principleName;
+ private PrincipalType principalType;
+ private PrivilegeGrantInfo grantInfo;
+
+ public HiveObjectPrivilegeBuilder setHiveObjectRef(HiveObjectRef hiveObjectRef) {
+ this.hiveObjectRef = hiveObjectRef;
+ return this;
+ }
+
+ public HiveObjectPrivilegeBuilder setPrincipleName(String principleName) {
+ this.principleName = principleName;
+ return this;
+ }
+
+ public HiveObjectPrivilegeBuilder setPrincipalType(PrincipalType principalType) {
+ this.principalType = principalType;
+ return this;
+ }
+
+ public HiveObjectPrivilegeBuilder setGrantInfo(PrivilegeGrantInfo grantInfo) {
+ this.grantInfo = grantInfo;
+ return this;
+ }
+
+ public HiveObjectPrivilege build() throws MetaException {
+ if (hiveObjectRef == null || principleName == null || principalType == null ||
+ grantInfo == null) {
+ throw new MetaException("hive object reference, principle name and type, and grant info " +
+ "must all be provided");
+ }
+ return new HiveObjectPrivilege(hiveObjectRef, principleName, principalType, grantInfo);
+ }
+}
diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveObjectRefBuilder.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveObjectRefBuilder.java
new file mode 100644
index 0000000000..62a227adf8
--- /dev/null
+++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/HiveObjectRefBuilder.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
+import org.apache.hadoop.hive.metastore.api.HiveObjectType;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A builder for {@link HiveObjectRef}. Unlike most builders (which allow a gradual building up
+ * of the values) this gives a number of methods that take the object to be referenced and then
+ * build the appropriate reference. This is intended primarily for use with
+ * {@link HiveObjectPrivilegeBuilder}
+ */
+public class HiveObjectRefBuilder {
+ private HiveObjectType objectType;
+ private String dbName, objectName, columnName;
+ private List
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.Index;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Builder for indices. You must supply the database name and table name (or table reference), a
+ * name for the index, and whatever StorageDescriptorBuilder requires. All other fields will be
+ * given reasonable defaults.
+ */
+public class IndexBuilder extends StorageDescriptorBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.Table;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Builder for {@link Partition}. The only requirements are 1. (database name and table name) or table
+ * reference; 2. partition values; 3. whatever {@link StorageDescriptorBuilder} requires.
+ */
+public class PartitionBuilder extends StorageDescriptorBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
+import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
+import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
+
+import java.io.IOException;
+
+/**
+ * Builder for {@link PrivilegeGrantInfo}. The privilege is required. If not provided the grantor
+ * is
+ * assumed to be the current user. This is really intended for use by the
+ * {@link HiveObjectPrivilegeBuilder}.
+ */
+public class PrivilegeGrantInfoBuilder {
+ private String privilege, grantor;
+ private int createTime;
+ private PrincipalType grantorType;
+ private boolean grantOption;
+
+ public PrivilegeGrantInfoBuilder() {
+ createTime = (int)(System.currentTimeMillis() / 1000);
+ grantOption = false;
+ }
+
+ public PrivilegeGrantInfoBuilder setPrivilege(String privilege) {
+ this.privilege = privilege;
+ return this;
+ }
+
+ public PrivilegeGrantInfoBuilder setGrantor(String grantor) {
+ this.grantor = grantor;
+ return this;
+ }
+
+ public PrivilegeGrantInfoBuilder setCreateTime(int createTime) {
+ this.createTime = createTime;
+ return this;
+ }
+
+ public PrivilegeGrantInfoBuilder setGrantorType(PrincipalType grantorType) {
+ this.grantorType = grantorType;
+ return this;
+ }
+
+ public PrivilegeGrantInfoBuilder setGrantOption(boolean grantOption) {
+ this.grantOption = grantOption;
+ return this;
+ }
+
+ public PrivilegeGrantInfo build() throws MetaException {
+ if (privilege == null) {
+ throw new MetaException("Privilege must be provided.");
+ }
+ if (grantor == null) {
+ try {
+ grantor = SecurityUtils.getUser();
+ grantorType = PrincipalType.USER;
+ } catch (IOException e) {
+ throw MetaStoreUtils.newMetaException(e);
+ }
+ }
+ return new PrivilegeGrantInfo(privilege, createTime, grantor, grantorType, grantOption);
+ }
+}
diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/RoleBuilder.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/RoleBuilder.java
new file mode 100644
index 0000000000..0b8d189f31
--- /dev/null
+++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/RoleBuilder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Role;
+
+/**
+ * A builder for {@link Role}. The roleName and the ownerName must be provided.
+ */
+public class RoleBuilder {
+ private String roleName, ownerName;
+ private int createTime;
+
+ public RoleBuilder() {
+ createTime = (int)(System.currentTimeMillis() / 1000);
+ }
+
+ public RoleBuilder setRoleName(String roleName) {
+ this.roleName = roleName;
+ return this;
+ }
+
+ public RoleBuilder setOwnerName(String ownerName) {
+ this.ownerName = ownerName;
+ return this;
+ }
+
+ public RoleBuilder setCreateTime(int createTime) {
+ this.createTime = createTime;
+ return this;
+ }
+
+ public Role build() throws MetaException {
+ if (roleName == null || ownerName == null) {
+ throw new MetaException("role name and owner name must be provided.");
+ }
+ return new Role(roleName, createTime, ownerName);
+ }
+}
diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/SQLForeignKeyBuilder.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/SQLForeignKeyBuilder.java
new file mode 100644
index 0000000000..a39319a1e4
--- /dev/null
+++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/SQLForeignKeyBuilder.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
+import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
+
+/**
+ * Builder for {@link SQLForeignKey}. Requires what {@link ConstraintBuilder} requires, plus
+ * primary key
+ * database, table, column and name.
+ */
+public class SQLForeignKeyBuilder extends ConstraintBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
+
+/**
+ * Builder for {@link SQLNotNullConstraint}. Only requires what {@link ConstraintBuilder} requires.
+ */
+public class SQLNotNullConstraintBuilder extends ConstraintBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
+
+/**
+ * Builder for {@link SQLPrimaryKey}. Only requires what {@link ConstraintBuilder} requires.
+ */
+public class SQLPrimaryKeyBuilder extends ConstraintBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
+
+/**
+ * Builder for {@link SQLUniqueConstraint}. Only requires what {@link ConstraintBuilder} requires.
+ */
+public class SQLUniqueConstraintBuilder extends ConstraintBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Order;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.SkewedInfo;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Builds a {@link StorageDescriptor}. Only requires that columns be set. It picks reasonable
+ * defaults for everything else. This is intended for use just by objects that have a StorageDescriptor,
+ * not direct use.
+ */
+abstract class StorageDescriptorBuilder
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
+import org.apache.hadoop.hive.metastore.utils.SecurityUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Build a {@link Table}. The database name and table name must be provided, plus whatever is
+ * needed by the underlying {@link StorageDescriptorBuilder}.
+ */
+public class TableBuilder extends StorageDescriptorBuilder> skewedColValues;
+ private Map
, String> skewedColValueLocationMaps;
+ // This enables us to return the correct type from the builder
+ private T child;
+
+ protected StorageDescriptorBuilder() {
+ // Set some reasonable defaults
+ storageDescriptorParams = new HashMap<>();
+ serdeParams = new HashMap<>();
+ bucketCols = new ArrayList<>();
+ sortCols = new ArrayList<>();
+ numBuckets = 0;
+ compressed = false;
+ inputFormat = INPUT_FORMAT;
+ outputFormat = OUTPUT_FORMAT;
+ serdeLib = SERDE_LIB;
+ skewedColNames = new ArrayList<>();
+ skewedColValues = new ArrayList<>();
+ skewedColValueLocationMaps = new HashMap<>();
+ }
+
+ protected StorageDescriptor buildSd() throws MetaException {
+ if (cols == null) throw new MetaException("You must provide the columns");
+ SerDeInfo serdeInfo = new SerDeInfo(serdeName, serdeLib, serdeParams);
+ StorageDescriptor sd = new StorageDescriptor(cols, location, inputFormat, outputFormat,
+ compressed, numBuckets, serdeInfo, bucketCols, sortCols, storageDescriptorParams);
+ sd.setStoredAsSubDirectories(storedAsSubDirectories);
+ if (skewedColNames != null) {
+ SkewedInfo skewed = new SkewedInfo(skewedColNames, skewedColValues,
+ skewedColValueLocationMaps);
+ sd.setSkewedInfo(skewed);
+ }
+ return sd;
+ }
+
+ protected void setChild(T child) {
+ this.child = child;
+ }
+
+ public T setLocation(String location) {
+ this.location = location;
+ return child;
+ }
+
+ public T setInputFormat(String inputFormat) {
+ this.inputFormat = inputFormat;
+ return child;
+ }
+
+ public T setOutputFormat(String outputFormat) {
+ this.outputFormat = outputFormat;
+ return child;
+ }
+
+ public T setSerdeName(String serdeName) {
+ this.serdeName = serdeName;
+ return child;
+ }
+
+ public T setSerdeLib(String serdeLib) {
+ this.serdeLib = serdeLib;
+ return child;
+ }
+ public T setCols(List
> skewedColValues) {
+ this.skewedColValues = skewedColValues;
+ return child;
+ }
+
+ public T setSkewedColValueLocationMaps(
+ Map
, String> skewedColValueLocationMaps) {
+ this.skewedColValueLocationMaps = skewedColValueLocationMaps;
+ return child;
+ }
+}
diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java
new file mode 100644
index 0000000000..1d457a6818
--- /dev/null
+++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *