aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorIgor Guzenko <ihor.huzenko.igs@gmail.com>2018-10-12 12:02:43 +0300
committerGautam Parai <gparai@apache.org>2019-01-03 16:35:30 -0800
commit7a25d9d86b9324dc4c3121a51e3d964bdb7b0284 (patch)
treec6633c2534d973feb45f48b8ec748d49d4cf3219 /common
parente65079a5d6f9b4e54783bef9f3af64a0684af3f0 (diff)
DRILL-540: Allow querying hive views in Drill
1. Added DrillHiveViewTable which allows construction of DrillViewTable based on Hive metadata 2. Added initialization of DrillHiveViewTable in HiveSchemaFactory 3. Extracted conversion of Hive data types from DrillHiveTable to HiveToRelDataTypeConverter 4. Removed throwing of UnsupportedOperationException from HiveStoragePlugin 5. Added TestHiveViewsSupport and authorization tests 6. Added closeSilently() method to AutoCloseables closes #1559
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/org/apache/drill/common/AutoCloseables.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/src/main/java/org/apache/drill/common/AutoCloseables.java b/common/src/main/java/org/apache/drill/common/AutoCloseables.java
index 8ca715e6d..4cdbded2d 100644
--- a/common/src/main/java/org/apache/drill/common/AutoCloseables.java
+++ b/common/src/main/java/org/apache/drill/common/AutoCloseables.java
@@ -19,12 +19,18 @@ package org.apache.drill.common;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Objects;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utilities for AutoCloseable classes.
*/
public class AutoCloseables {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AutoCloseables.class);
+
public interface Closeable extends AutoCloseable {
@Override
void close();
@@ -92,4 +98,20 @@ public class AutoCloseables {
throw topLevelException;
}
}
+
+ /**
+ * Close all without caring about thrown exceptions
+ * @param closeables - array containing auto closeables
+ */
+ public static void closeSilently(AutoCloseable... closeables) {
+ Arrays.stream(closeables).filter(Objects::nonNull)
+ .forEach(target -> {
+ try {
+ target.close();
+ } catch (Exception e) {
+ LOGGER.warn(String.format("Exception was thrown while closing auto closeable: %s", target), e);
+ }
+ });
+ }
+
}