Repository: drill Updated Branches: refs/heads/master 645e43fd3 -> 6813b20e7
DRILL-3635: IllegalArgumentException - not a Parquet file (too small). This closes #117. Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/6813b20e Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/6813b20e Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/6813b20e Branch: refs/heads/master Commit: 6813b20e77fb4ded1cad6169d2fd4530532801bc Parents: 645e43f Author: adeneche <adene...@gmail.com> Authored: Thu Aug 13 13:04:59 2015 -0700 Committer: Parth Chandra <par...@apache.org> Committed: Mon Aug 17 15:06:14 2015 -0700 ---------------------------------------------------------------------- .../exec/physical/impl/WriterRecordBatch.java | 21 ++++++++++++-------- .../apache/drill/jdbc/test/TestJdbcQuery.java | 19 ++++++++++++++++-- 2 files changed, 30 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/6813b20e/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java index 5fe7667..0a80b27 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java @@ -23,7 +23,6 @@ import java.io.IOException; import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.common.types.TypeProtos.MinorType; import org.apache.drill.common.types.Types; -import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.memory.OutOfMemoryException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.physical.base.Writer; @@ -126,6 +125,8 @@ public class WriterRecordBatch extends AbstractRecordBatch<Writer> { addOutputContainerData(); processed = true; + closeWriter(); + return IterOutcome.OK_NEW_SCHEMA; } @@ -169,16 +170,20 @@ public class WriterRecordBatch extends AbstractRecordBatch<Writer> { schema = container.getSchema(); } - @Override - public void close() { - try { - if (recordWriter != null) { + private void closeWriter() { + if (recordWriter != null) { + try { recordWriter.cleanup(); + recordWriter = null; + } catch(IOException ex) { + context.fail(ex); } - } catch(IOException ex) { - logger.error("Failure while closing record writer", ex); - throw new RuntimeException("Failed to close RecordWriter", ex); } + } + + @Override + public void close() { + closeWriter(); super.close(); } http://git-wip-us.apache.org/repos/asf/drill/blob/6813b20e/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java ---------------------------------------------------------------------- diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java index 926530d..ee56487 100644 --- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java +++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals; import java.sql.Connection; import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; @@ -31,7 +30,7 @@ import org.junit.Test; import com.google.common.base.Function; public class TestJdbcQuery extends JdbcTestQueryBase { - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestJdbcQuery.class); +// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestJdbcQuery.class); // TODO: Purge nextUntilEnd(...) and calls when remaining fragment race // conditions are fixed (not just DRILL-2245 fixes). @@ -44,6 +43,22 @@ public class TestJdbcQuery extends JdbcTestQueryBase { // } //} + @Test // DRILL-3635 + public void testFix3635() throws Exception { + // When we run a CTAS query, executeQuery() should return after the table has been flushed to disk even though we + // didn't yet receive a terminal message. To test this, we run CTAS then immediately run a query on the newly + // created table. + + final String tableName = "dfs_test.tmp.`testDDLs`"; + + try (Connection conn = connect("jdbc:drill:zk=local")) { + Statement s = conn.createStatement(); + s.executeQuery(String.format("CREATE TABLE %s AS SELECT * FROM cp.`employee.json`", tableName)); + } + + testQuery(String.format("SELECT * FROM %s LIMIT 1", tableName)); + } + @Test @Ignore public void testJsonQuery() throws Exception{