diff --git a/hive-sre/pom.xml b/hive-sre/pom.xml index 0246bb3..be23e93 100644 --- a/hive-sre/pom.xml +++ b/hive-sre/pom.xml @@ -6,7 +6,7 @@ com.streever.hive hive-sre - 2.3.2.1-SNAPSHOT + 2.3.2.2-SNAPSHOT hive diff --git a/hive-sre/src/main/java/com/streever/hive/sre/CommandReturnCheck.java b/hive-sre/src/main/java/com/streever/hive/sre/CommandReturnCheck.java index 53eb156..850ad0b 100644 --- a/hive-sre/src/main/java/com/streever/hive/sre/CommandReturnCheck.java +++ b/hive-sre/src/main/java/com/streever/hive/sre/CommandReturnCheck.java @@ -172,6 +172,7 @@ public String runCalculations(CommandReturn commandReturn) { } } catch (ScriptException e) { e.printStackTrace(); + System.err.println("Issue with script eval: " + this.getName() + ":" + calcKey); } catch (MissingFormatArgumentException mfa) { mfa.printStackTrace(); System.err.println("Bad Argument Match up for PATH check rule: " + this.getName() + ":" + calcKey); @@ -209,6 +210,7 @@ public String runCalculations(CommandReturn commandReturn) { } } catch (ScriptException e) { e.printStackTrace(); + System.err.println("Issue with script eval: " + this.getName() + ":" + calcKey); } catch (MissingFormatArgumentException mfa) { mfa.printStackTrace(); System.err.println("Bad Argument Match up for RECORDS check rule: " + this.getName() + ":" + calcKey); diff --git a/hive-sre/src/main/java/com/streever/hive/sre/Utils.java b/hive-sre/src/main/java/com/streever/hive/sre/Utils.java index a30ba4f..2e4d7d1 100644 --- a/hive-sre/src/main/java/com/streever/hive/sre/Utils.java +++ b/hive-sre/src/main/java/com/streever/hive/sre/Utils.java @@ -2,15 +2,22 @@ import org.apache.commons.lang.StringUtils; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class Utils { - public static String dirToPartitionSpec(String directoryPart) { + public static String dirToPartitionSpec(String directoryPart) throws UnsupportedEncodingException { String[] directories = directoryPart.split("\\/"); String[] partitionSpecs = new String[directories.length]; int loc = 0; for (String directory: directories) { String[] specParts = directory.split("="); - partitionSpecs[loc++] = specParts[0] + "=\"" + specParts[1] + "\""; + String partDir = null; + partDir = URLDecoder.decode(specParts[1], StandardCharsets.UTF_8.toString()); + partitionSpecs[loc++] = specParts[0] + "=\"" + partDir + "\""; } StringBuilder rtn = new StringBuilder(); rtn.append(StringUtils.join(partitionSpecs, ",")); diff --git a/hive-sre/src/test/java/com/streever/hive/sre/UtilsTest.java b/hive-sre/src/test/java/com/streever/hive/sre/UtilsTest.java index 58d61a6..abddb9c 100644 --- a/hive-sre/src/test/java/com/streever/hive/sre/UtilsTest.java +++ b/hive-sre/src/test/java/com/streever/hive/sre/UtilsTest.java @@ -2,6 +2,8 @@ import org.junit.Test; +import java.io.UnsupportedEncodingException; + import static org.junit.Assert.*; public class UtilsTest { @@ -11,8 +13,29 @@ public void dirToPartitionSpec_001() { String[] testSet = {"st=GA A/update_dt=2020-09-03"}; for (String test: testSet) { - String spec = Utils.dirToPartitionSpec(test); + String spec = null; + try { + spec = Utils.dirToPartitionSpec(test); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } System.out.println(spec); } } + + @Test + public void decodeTS_001() { + String[] testSet = {"st=GA A/update_dt=2019-09-01 12%3A31%3A44.333"}; + + for (String test: testSet) { + String spec = null; + try { + spec = Utils.dirToPartitionSpec(test); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + System.out.println(spec); + } + } + } \ No newline at end of file