You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ar...@apache.org on 2019/05/20 09:10:43 UTC
[beam] branch master updated: [BEAM-7360] Fix static analysis
issues for HCatalogIO (#8617)
This is an automated email from the ASF dual-hosted git repository.
aromanenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 099fad8 [BEAM-7360] Fix static analysis issues for HCatalogIO (#8617)
099fad8 is described below
commit 099fad8c47279d71712bcf74d3d2f191c1888a43
Author: Ismaël Mejía <ie...@gmail.com>
AuthorDate: Mon May 20 11:10:30 2019 +0200
[BEAM-7360] Fix static analysis issues for HCatalogIO (#8617)
---
.../java/org/apache/beam/sdk/io/hcatalog/HCatToRow.java | 2 +-
.../apache/beam/sdk/io/hcatalog/HCatalogBeamSchema.java | 2 +-
.../org/apache/beam/sdk/io/hcatalog/HCatalogIO.java | 6 +++---
.../beam/sdk/io/hcatalog/HCatalogBeamSchemaTest.java | 13 ++++++-------
.../org/apache/beam/sdk/io/hcatalog/HCatalogIOTest.java | 17 ++++++++---------
5 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatToRow.java b/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatToRow.java
index 3afc3a0..f76b559 100644
--- a/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatToRow.java
+++ b/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatToRow.java
@@ -36,7 +36,7 @@ public class HCatToRow {
* <p>If there is a mismatch between the schema specified here and actual record schema, or
* internal representation and schema, then runtime errors will happen.
*/
- public static PTransform<PCollection<? extends HCatRecord>, PCollection<Row>> forSchema(
+ private static PTransform<PCollection<? extends HCatRecord>, PCollection<Row>> forSchema(
Schema schema) {
return ParDo.of(new HCatToRowFn(schema));
}
diff --git a/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchema.java b/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchema.java
index b43bc9e..9aaad6d 100644
--- a/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchema.java
+++ b/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchema.java
@@ -41,7 +41,7 @@ import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
@Experimental
public class HCatalogBeamSchema {
- private @Nullable IMetaStoreClient metastore;
+ private @Nullable final IMetaStoreClient metastore;
private HCatalogBeamSchema(IMetaStoreClient metastore) {
this.metastore = metastore;
diff --git a/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogIO.java b/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogIO.java
index c742185..73518f6 100644
--- a/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogIO.java
+++ b/sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogIO.java
@@ -312,7 +312,7 @@ public class HCatalogIO {
private HCatRecord current;
private Iterator<HCatRecord> hcatIterator;
- public BoundedHCatalogReader(BoundedHCatalogSource source) {
+ BoundedHCatalogReader(BoundedHCatalogSource source) {
this.source = source;
}
@@ -432,7 +432,7 @@ public class HCatalogIO {
private HCatWriter masterWriter;
private List<HCatRecord> hCatRecordsBatch;
- public WriteFn(Write spec) {
+ WriteFn(Write spec) {
this.spec = spec;
}
@@ -495,7 +495,7 @@ public class HCatalogIO {
}
@Teardown
- public void tearDown() throws Exception {
+ public void tearDown() {
if (slaveWriter != null) {
slaveWriter = null;
}
diff --git a/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchemaTest.java b/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchemaTest.java
index 3fbb016..18d25ae 100644
--- a/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchemaTest.java
+++ b/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogBeamSchemaTest.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.io.Serializable;
import org.apache.beam.sdk.io.hcatalog.test.EmbeddedMetastoreService;
import org.apache.beam.sdk.schemas.Schema;
-import org.apache.hadoop.hive.ql.CommandNeedRetryException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -66,19 +65,19 @@ public class HCatalogBeamSchemaTest implements Serializable {
}
@Test
- public void testHasDB() throws Exception {
+ public void testHasDB() {
HCatalogBeamSchema hcatSchema = HCatalogBeamSchema.create(service.getHiveConfAsMap());
assertTrue(hcatSchema.hasDatabase(TEST_DATABASE));
}
@Test
- public void testDoesntHaveDB() throws Exception {
+ public void testDoesntHaveDB() {
HCatalogBeamSchema hcatSchema = HCatalogBeamSchema.create(service.getHiveConfAsMap());
assertFalse(hcatSchema.hasDatabase("non-existent-db"));
}
@Test
- public void testGetTableSchema() throws Exception {
+ public void testGetTableSchema() {
HCatalogBeamSchema hcatSchema = HCatalogBeamSchema.create(service.getHiveConfAsMap());
Schema schema = hcatSchema.getTableSchema(TEST_DATABASE, TEST_TABLE).get();
@@ -92,7 +91,7 @@ public class HCatalogBeamSchemaTest implements Serializable {
}
@Test
- public void testGetTableSchemaForPartitionedTable() throws Exception {
+ public void testGetTableSchemaForPartitionedTable() {
HCatalogBeamSchema hcatSchema = HCatalogBeamSchema.create(service.getHiveConfAsMap());
Schema schema = hcatSchema.getTableSchema(TEST_DATABASE, TEST_TABLE_PARTITIONED).get();
@@ -108,7 +107,7 @@ public class HCatalogBeamSchemaTest implements Serializable {
}
@Test
- public void testDoesntHaveTable() throws Exception {
+ public void testDoesntHaveTable() {
HCatalogBeamSchema hcatSchema = HCatalogBeamSchema.create(service.getHiveConfAsMap());
assertFalse(hcatSchema.getTableSchema(TEST_DATABASE, "non-existent-table").isPresent());
}
@@ -118,7 +117,7 @@ public class HCatalogBeamSchemaTest implements Serializable {
insertTestData(service.getHiveConfAsMap());
}
- private void reCreateTestTable() throws CommandNeedRetryException {
+ private void reCreateTestTable() {
service.executeQuery("drop table " + TEST_TABLE);
service.executeQuery("drop table " + TEST_TABLE_PARTITIONED);
service.executeQuery("create table " + TEST_TABLE + "(mycol1 string, mycol2 int)");
diff --git a/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogIOTest.java b/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogIOTest.java
index 9297aa9..da631a3 100644
--- a/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogIOTest.java
+++ b/sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/HCatalogIOTest.java
@@ -55,7 +55,6 @@ import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.util.UserCodeException;
import org.apache.beam.sdk.values.PCollection;
import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
-import org.apache.hadoop.hive.ql.CommandNeedRetryException;
import org.apache.hive.hcatalog.data.HCatRecord;
import org.apache.hive.hcatalog.data.transfer.ReaderContext;
import org.junit.AfterClass;
@@ -132,7 +131,7 @@ public class HCatalogIOTest implements Serializable {
/** Perform end-to-end test of Write-then-Read operation. */
@Test
@NeedsEmptyTestTables
- public void testWriteThenReadSuccess() throws Exception {
+ public void testWriteThenReadSuccess() {
defaultPipeline
.apply(Create.of(buildHCatRecords(TEST_RECORDS_COUNT)))
.apply(
@@ -166,7 +165,7 @@ public class HCatalogIOTest implements Serializable {
/** Test of Write to a non-existent table. */
@Test
- public void testWriteFailureTableDoesNotExist() throws Exception {
+ public void testWriteFailureTableDoesNotExist() {
thrown.expectCause(isA(UserCodeException.class));
thrown.expectMessage(containsString("org.apache.hive.hcatalog.common.HCatException"));
thrown.expectMessage(containsString("NoSuchObjectException"));
@@ -181,7 +180,7 @@ public class HCatalogIOTest implements Serializable {
/** Test of Write without specifying a table. */
@Test
- public void testWriteFailureValidationTable() throws Exception {
+ public void testWriteFailureValidationTable() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("withTable() is required");
HCatalogIO.write()
@@ -191,7 +190,7 @@ public class HCatalogIOTest implements Serializable {
/** Test of Write without specifying configuration properties. */
@Test
- public void testWriteFailureValidationConfigProp() throws Exception {
+ public void testWriteFailureValidationConfigProp() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("withConfigProperties() is required");
HCatalogIO.write().withTable("myowntable").expand(null);
@@ -199,7 +198,7 @@ public class HCatalogIOTest implements Serializable {
/** Test of Read from a non-existent table. */
@Test
- public void testReadFailureTableDoesNotExist() throws Exception {
+ public void testReadFailureTableDoesNotExist() {
defaultPipeline.apply(
HCatalogIO.read()
.withConfigProperties(getConfigPropertiesAsMap(service.getHiveConf()))
@@ -210,7 +209,7 @@ public class HCatalogIOTest implements Serializable {
/** Test of Read without specifying configuration properties. */
@Test
- public void testReadFailureValidationConfig() throws Exception {
+ public void testReadFailureValidationConfig() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("withConfigProperties() is required");
HCatalogIO.read().withTable("myowntable").expand(null);
@@ -218,7 +217,7 @@ public class HCatalogIOTest implements Serializable {
/** Test of Read without specifying a table. */
@Test
- public void testReadFailureValidationTable() throws Exception {
+ public void testReadFailureValidationTable() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("withTable() is required");
HCatalogIO.read()
@@ -272,7 +271,7 @@ public class HCatalogIOTest implements Serializable {
SourceTestUtils.assertSourcesEqualReferenceSource(unSplitSource.get(0), splits, OPTIONS);
}
- private void reCreateTestTable() throws CommandNeedRetryException {
+ private void reCreateTestTable() {
service.executeQuery("drop table " + TEST_TABLE);
service.executeQuery("create table " + TEST_TABLE + "(mycol1 string, mycol2 int)");
}