From a63a9f9893b32dac5aa8950e172bd19d9177158a Mon Sep 17 00:00:00 2001 From: aleph-zero Date: Wed, 16 Sep 2015 16:24:43 -0700 Subject: [PATCH 1/3] Initial --- contrib/storage-jdbc/pom.xml | 6 ++- .../store/jdbc/TestJdbcPluginWithMySQL.java | 38 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java diff --git a/contrib/storage-jdbc/pom.xml b/contrib/storage-jdbc/pom.xml index be208114ea6..79db3d2f542 100755 --- a/contrib/storage-jdbc/pom.xml +++ b/contrib/storage-jdbc/pom.xml @@ -30,7 +30,6 @@ - org.apache.drill.exec drill-java-exec @@ -72,5 +71,10 @@ + + + + + diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java new file mode 100644 index 00000000000..da771f7ae69 --- /dev/null +++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java @@ -0,0 +1,38 @@ +/* + * 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.drill.exec.store.jdbc; + +import org.apache.drill.PlanTestBase; + +import org.junit.Test; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class TestJdbcPluginWithMySQL extends PlanTestBase { + + private static final Logger logger = LoggerFactory.getLogger(TestJdbcPluginWithMySQL.class); + + @Test + public void x() throws Exception { + logger.info("XXX"); + } +} From 17e36e99e18694a9603f2f8132c122e679ed06cf Mon Sep 17 00:00:00 2001 From: aleph-zero Date: Tue, 22 Sep 2015 16:06:47 -0700 Subject: [PATCH 2/3] Initial work on testing JDBC with MySQL --- contrib/storage-jdbc/pom.xml | 281 ++++++++++++++---- .../exec/store/jdbc/JdbcRecordReader.java | 2 + .../drill/exec/store/jdbc/TestJdbcPlugin.java | 181 ----------- .../store/jdbc/TestJdbcPluginWithDerbyIT.java | 127 ++++++++ .../store/jdbc/TestJdbcPluginWithMySQL.java | 38 --- .../store/jdbc/TestJdbcPluginWithMySQLIT.java | 74 +++++ .../resources/bootstrap-storage-plugins.json | 20 +- .../src/test/resources/derby-test-data.sql | 48 +++ .../{logback.xml => logback-test.xml} | 7 +- .../src/test/resources/mysql-test-data.sql | 52 ++++ 10 files changed, 549 insertions(+), 281 deletions(-) delete mode 100644 contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPlugin.java create mode 100644 contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java delete mode 100644 contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java create mode 100644 contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java create mode 100644 contrib/storage-jdbc/src/test/resources/derby-test-data.sql rename contrib/storage-jdbc/src/test/resources/{logback.xml => logback-test.xml} (92%) create mode 100644 contrib/storage-jdbc/src/test/resources/mysql-test-data.sql diff --git a/contrib/storage-jdbc/pom.xml b/contrib/storage-jdbc/pom.xml index 79db3d2f542..bbfe62445f9 100755 --- a/contrib/storage-jdbc/pom.xml +++ b/contrib/storage-jdbc/pom.xml @@ -15,66 +15,241 @@ See the License for the specific language governing permissions and limitations under the License. --> - - 4.0.0 - - drill-contrib-parent - org.apache.drill.contrib - 1.2.0-SNAPSHOT - + + 4.0.0 + + drill-contrib-parent + org.apache.drill.contrib + 1.2.0-SNAPSHOT + - drill-jdbc-storage + drill-jdbc-storage - contrib/jdbc-storage-plugin + contrib/jdbc-storage-plugin - + + 5.1.36 + 20000 + 20001 + drill_derby_test + drill_mysql_test + - - org.apache.drill.exec - drill-java-exec - ${project.version} - - - - - org.apache.drill.exec - drill-java-exec - tests - ${project.version} - test - - - org.apache.drill - drill-common - tests - ${project.version} - test - - - com.yammer.metrics - metrics-core - 2.1.1 - test - - - org.apache.derby - derbyclient - 10.11.1.1 - test - - - org.apache.derby - derbynet - 10.11.1.1 - test - - + + + org.apache.drill.exec + drill-java-exec + ${project.version} + + + + + org.apache.drill.exec + drill-java-exec + tests + ${project.version} + test + + + org.apache.drill + drill-common + tests + ${project.version} + test + + + com.yammer.metrics + metrics-core + 2.1.1 + test + + + org.apache.derby + derbyclient + 10.11.1.1 + test + + + org.apache.derby + derbynet + 10.11.1.1 + test + + + mysql + mysql-connector-java + ${mysql.connector.version} + test + + + + + src/test/resources + true + + - + + maven-surefire-plugin + + + **/* + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + + integration-test + verify + + + + + + maven-dependency-plugin + 2.8 + + + + unpack + + + + + com.jcabi + mysql-dist + 5.6.14 + ${mysql.classifier} + zip + false + ${project.build.directory}/mysql-dist + + + + + + + + com.btmatthews.maven.plugins.inmemdb + inmemdb-maven-plugin + 1.4.3 + + inmemdb + 11527 + + + + run + + run + + pre-integration-test + + true + derby + ${derby.database.name} + root + root + ${derby.reserved.port} + + + + + + + stop + + stop + + post-integration-test + + + + + com.jcabi + jcabi-mysql-maven-plugin + 0.8.2 + + + mysql-test + + classify + start + stop + + + ${mysql.reserved.port} + ${project.build.directory}/mysql-data + true + ${mysql.database.name} + + + + + + org.codehaus.mojo + sql-maven-plugin + 1.5 + + + mysql + mysql-connector-java + ${mysql.connector.version} + + + + com.mysql.jdbc.Driver + root + root + jdbc:mysql://localhost:${mysql.reserved.port}/${mysql.database.name} + + + + create-tables + pre-integration-test + + execute + + + ascending + + ${basedir}/src/test/resources + + mysql-test-data.sql + + + + + + + + + + maven-failsafe-plugin + + + ${derby.reserved.port} + ${mysql.reserved.port} + ${mysql.database.name} + + + **/*IT.java + + + + + - diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java index 69c45c2f474..222e269304b 100755 --- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java +++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java @@ -113,6 +113,8 @@ public JdbcRecordReader(FragmentContext fragmentContext, DataSource source, Stri .put(java.sql.Types.BOOLEAN, MinorType.BIT) + .put(java.sql.Types.BIT, MinorType.BIT) + .build(); } diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPlugin.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPlugin.java deleted file mode 100644 index 1f150682b57..00000000000 --- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPlugin.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.apache.drill.exec.store.jdbc; - -import static org.junit.Assert.assertEquals; - -import java.net.InetAddress; -import java.sql.Connection; - -import org.apache.commons.dbcp.BasicDataSource; -import org.apache.derby.drda.NetworkServerControl; -import org.apache.drill.BaseTestQuery; -import org.apache.drill.PlanTestBase; -import org.apache.drill.exec.proto.UserBitShared.QueryType; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * 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. - */ -public class TestJdbcPlugin extends PlanTestBase { - - static NetworkServerControl server; - - @BeforeClass - public static void setupDefaultTestCluster() throws Exception { - System.setProperty("derby.drda.startNetworkServer", "true"); - server = new NetworkServerControl(InetAddress.getByName("localhost"), - 20000, - "admin", - "admin"); - java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true); - server.start(consoleWriter); - - BasicDataSource source = new BasicDataSource(); - source.setUrl("jdbc:derby://localhost:20000/memory:testDB;create=true"); - source.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); - - final String insertValues1 = "INSERT INTO person VALUES (1, 'Smith', null, '{number:\"123 Main\"}','mtrx', " - + "'xy', 333.333, 444.444, 555.00, TIME('15:09:02'), DATE('1994-02-23'), TIMESTAMP('1962-09-23 03:23:34.234')," - + " 666.66, 1, -1, false)"; - final String insertValues2 = "INSERT INTO person (PersonId) VALUES (null)"; - try (Connection c = source.getConnection()) { - c.createStatement().execute("CREATE TABLE person\n" + - "(\n" + - "PersonID int,\n" + - "LastName varchar(255),\n" + - "FirstName varchar(255),\n" + - "Address varchar(255),\n" + - "City varchar(255),\n" + - "Code char(2),\n" + - "dbl double,\n" + - "flt float,\n" + - "rel real,\n" + - "tm time,\n" + - "dt date,\n" + - "tms timestamp,\n" + - "num numeric(10,2), \n" + - "sm smallint,\n" + - "bi bigint,\n" + - "bool boolean\n" + - - ")"); - - c.createStatement().execute(insertValues1); - c.createStatement().execute(insertValues2); - c.createStatement().execute(insertValues1); - } - - BaseTestQuery.setupDefaultTestCluster(); - } - - @AfterClass - public static void shutdownDb() throws Exception { - server.shutdown(); - } - - @Test - public void validateResult() throws Exception { - // we'll test data except for date, time and timestamps. Derby mangles these due to improper timezone support. - testBuilder() - .sqlQuery( - "select PERSONID, LASTNAME, FIRSTNAME, ADDRESS, CITY, CODE, DBL, FLT, REL, NUM, SM, BI, BOOL from testdb.`default`.PERSON") - .ordered() - .baselineColumns("PERSONID", "LASTNAME", "FIRSTNAME", "ADDRESS", "CITY", "CODE", "DBL", "FLT", "REL", - "NUM", "SM", "BI", "BOOL") - .baselineValues(1, "Smith", null, "{number:\"123 Main\"}", "mtrx", "xy", 333.333, 444.444, 555.00, - 666.66, 1, -1l, false) - .baselineValues(null, null, null, null, null, null, null, null, null, null, null, null, null) - .baselineValues(1, "Smith", null, "{number:\"123 Main\"}", "mtrx", "xy", 333.333, 444.444, 555.00, - 666.66, 1, -1l, false) - .build().run(); - } - - @Test - public void queryDefaultSchema() throws Exception { - testNoResult("select * from testdb.PERSON"); - } - - @Test - public void queryDifferentCase() throws Exception { - testNoResult("select * from testdb.person"); - } - - @Test - public void pushdownJoin() throws Exception { - testNoResult("use testdb"); - String query = "select x.PersonId from (select PersonId from person)x " - + "join (select PersonId from person)y on x.PersonId = y.PersonId "; - testPlanMatchingPatterns(query, new String[] {}, new String[] { "Join" }); - - } - - @Test - public void pushdownJoinAndFilterPushDown() throws Exception { - final String query = "select * from \n" + - "testdb.`default`.PERSON e\n" + - "INNER JOIN \n" + - "testdb.`default`.PERSON s\n" + - "ON e.FirstName = s.FirstName\n" + - "WHERE e.LastName > 'hello'"; - - testPlanMatchingPatterns(query, new String[] {}, new String[] { "Join", "Filter" }); - } - - @Test - public void pushdownAggregation() throws Exception { - final String query = "select count(*) from \n" + - "testdb.`default`.PERSON"; - - testPlanMatchingPatterns(query, new String[] {}, new String[] { "Aggregate" }); - } - - @Test - public void pushdownDoubleJoinAndFilter() throws Exception { - final String query = "select * from \n" + - "testdb.`default`.PERSON e\n" + - "INNER JOIN \n" + - "testdb.`default`.PERSON s\n" + - "ON e.PersonId = s.PersonId\n" + - "INNER JOIN \n" + - "testdb.`default`.PERSON ed\n" + - "ON e.PersonId = ed.PersonId\n" + - "WHERE s.FirstName > 'abc' and ed.FirstName > 'efg'"; - testPlanMatchingPatterns(query, new String[] {}, new String[] { "Join", "Filter" }); - } - - @Test - public void showTablesDefaultSchema() throws Exception { - testNoResult("use testdb"); - assertEquals(1, testRunAndPrint(QueryType.SQL, "show tables like 'PERSON'")); - } - - @Test - public void describe() throws Exception { - testNoResult("use testdb"); - assertEquals(16, testRunAndPrint(QueryType.SQL, "describe PERSON")); - } - - @Test - public void ensureDrillFunctionsAreNotPushedDown() throws Exception { - // This should verify that we're not trying to push CONVERT_FROM into the JDBC storage plugin. If were pushing - // this function down, the SQL query would fail. - testNoResult("select CONVERT_FROM(Address, 'JSON') from testdb.person where PersonId = 1"); - } - - @Test - public void pushdownFilter() throws Exception { - testNoResult("use testdb"); - String query = "select * from person where PersonId = 1"; - testPlanMatchingPatterns(query, new String[] {}, new String[] { "Filter" }); - } -} diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java new file mode 100644 index 00000000000..a9070ad41e0 --- /dev/null +++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java @@ -0,0 +1,127 @@ +/* + * 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.drill.exec.store.jdbc; + +import org.apache.drill.PlanTestBase; +import org.apache.drill.exec.proto.UserBitShared; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * JDBC storage plugin tests against Derby. + */ +public class TestJdbcPluginWithDerbyIT extends PlanTestBase { + + @Test + public void validateResult() throws Exception { + + // Skip date, time, and timestamp types since derby mangles these due to improper timezone support. + testBuilder() + .sqlQuery( + "select PERSON_ID, FIRST_NAME, LAST_NAME, ADDRESS, CITY, STATE, ZIP, JSON, BIGINT_FIELD, SMALLINT_FIELD, " + + "NUMERIC_FIELD, BOOLEAN_FIELD, DOUBLE_FIELD, FLOAT_FIELD, REAL_FIELD from derby.`default`.PERSON") + .ordered() + .baselineColumns("PERSON_ID", "FIRST_NAME", "LAST_NAME", "ADDRESS", "CITY", "STATE", "ZIP", "JSON", + "BIGINT_FIELD", "SMALLINT_FIELD", "NUMERIC_FIELD", "BOOLEAN_FIELD", "DOUBLE_FIELD", + "FLOAT_FIELD", "REAL_FIELD") + .baselineValues(1, "first_name_1", "last_name_1", "1401 John F Kennedy Blvd", "Philadelphia", "PA", 19107, "{ a : 5, b : 6 }", 123456L, 1, 10.01, false, 1.0, 1.1, 111.00) + .baselineValues(2, "first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111, "{ foo : \"abc\" }", 95949L, 2, 20.02, true, 2.0, 2.1, 222.00) + .baselineValues(3, "first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012, "{ z : [ 1, 2, 3 ] }", 45456L, 3, 30.04, true, 3.0, 3.1, 333.00) + .baselineValues(4, null, null, "2 15th St NW", "Washington", "DC", 20007, "{ z : { a : 1, b : 2, c : 3 } }", -67L, 4, 40.04, false, 4.0, 4.1, 444.00) + .baselineValues(5, null, null, null, null, null, null, null, null, null, null, null, null, null, null) + .build().run(); + } + + @Test + public void queryDefaultSchema() throws Exception { + testNoResult("select * from derby.PERSON"); + } + + @Test + public void queryDifferentCase() throws Exception { + testNoResult("select * from derby.person"); + } + + @Test + public void pushdownJoin() throws Exception { + testNoResult("use derby"); + String query = "select x.person_id from (select person_id from person) x " + + "join (select person_id from person) y on x.person_id = y.person_id "; + testPlanMatchingPatterns(query, new String[]{}, new String[]{"Join"}); + } + + @Test + public void pushdownJoinAndFilterPushDown() throws Exception { + final String query = "select * from \n" + + "derby.`default`.PERSON e\n" + + "INNER JOIN \n" + + "derby.`default`.PERSON s\n" + + "ON e.FIRST_NAME = s.FIRST_NAME\n" + + "WHERE e.LAST_NAME > 'hello'"; + + testPlanMatchingPatterns(query, new String[] {}, new String[] { "Join", "Filter" }); + } + + @Test + public void pushdownAggregation() throws Exception { + final String query = "select count(*) from derby.`default`.PERSON"; + testPlanMatchingPatterns(query, new String[] {}, new String[] { "Aggregate" }); + } + + @Test + public void pushdownDoubleJoinAndFilter() throws Exception { + final String query = "select * from \n" + + "derby.`default`.PERSON e\n" + + "INNER JOIN \n" + + "derby.`default`.PERSON s\n" + + "ON e.PERSON_ID = s.PERSON_ID\n" + + "INNER JOIN \n" + + "derby.`default`.PERSON ed\n" + + "ON e.PERSON_ID = ed.PERSON_ID\n" + + "WHERE s.FIRST_NAME > 'abc' and ed.FIRST_NAME > 'efg'"; + testPlanMatchingPatterns(query, new String[] {}, new String[] { "Join", "Filter" }); + } + + @Test + public void showTablesDefaultSchema() throws Exception { + testNoResult("use derby"); + assertEquals(1, testRunAndPrint(UserBitShared.QueryType.SQL, "show tables like 'PERSON'")); + } + + @Test + public void describe() throws Exception { + testNoResult("use derby"); + assertEquals(18, testRunAndPrint(UserBitShared.QueryType.SQL, "describe PERSON")); + } + + @Test + public void ensureDrillFunctionsAreNotPushedDown() throws Exception { + // This should verify that we're not trying to push CONVERT_FROM into the JDBC storage plugin. If were pushing + // this function down, the SQL query would fail. + testNoResult("select CONVERT_FROM(JSON, 'JSON') from derby.person where PERSON_ID = 4"); + } + + @Test + public void pushdownFilter() throws Exception { + testNoResult("use derby"); + String query = "select * from person where PERSON_ID = 1"; + testPlanMatchingPatterns(query, new String[]{}, new String[]{"Filter"}); + } +} diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java deleted file mode 100644 index da771f7ae69..00000000000 --- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQL.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.drill.exec.store.jdbc; - -import org.apache.drill.PlanTestBase; - -import org.junit.Test; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - */ -public class TestJdbcPluginWithMySQL extends PlanTestBase { - - private static final Logger logger = LoggerFactory.getLogger(TestJdbcPluginWithMySQL.class); - - @Test - public void x() throws Exception { - logger.info("XXX"); - } -} diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java new file mode 100644 index 00000000000..8e233e005ba --- /dev/null +++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java @@ -0,0 +1,74 @@ +/* + * 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.drill.exec.store.jdbc; + +import org.apache.drill.PlanTestBase; + +import org.junit.Test; + +/** + * JDBC storage plugin tests against MySQL. + */ +public class TestJdbcPluginWithMySQLIT extends PlanTestBase { + + @Test + public void validateResult() throws Exception { + + testBuilder() + .sqlQuery( + "select person_id, first_name, last_name, address, city, state, zip, json, time_field from mysql.`drill_mysql_test`.person") + .ordered() + .baselineColumns("person_id", "first_name", "last_name", "address", "city", "state", "zip", "json", "time_field") + .baselineValues(1, "first_name_1", "last_name_1", "1401 John F Kennedy Blvd", "Philadelphia", "PA", 19107, "{ a : 5, b : 6 }", "13:00:01") + .baselineValues(2, "first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111, "{ foo : \"abc\" }", "23:59:59") + .baselineValues(3, "first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012, "{ z : [ 1, 2, 3 ] }", "11:34:21") + .baselineValues(4, null, null, null, null, null, null, null, null) + .baselineValues(5, "first_name_5", "last_name_5", "Chestnut Hill", "Boston", "MA", 12467, "{ [ a, b, c ]}", "16:00:01") + .build().run(); + } + + @Test + public void queryDefaultSchema() throws Exception { + testNoResult("select * from mysql.PERSON"); + } + + @Test + public void queryDifferentCase() throws Exception { + testNoResult("select * from mysql.person"); + } + + @Test + public void pushdownJoin() throws Exception { + String query = "select x.person_id from (select person_id from mysql.`drill_mysql_test`.person) x " + + "join (select person_id from mysql.`drill_mysql_test`.person) y on x.person_id = y.person_id "; + testPlanMatchingPatterns(query, new String[]{}, new String[]{"Join"}); + } + + @Test + public void pushdownJoinAndFilterPushDown() throws Exception { + final String query = "select * from " + + "mysql.`drill_mysql_test`.person e " + + "INNER JOIN " + + "mysql.`drill_mysql_test`.person s " + + "ON e.first_name = s.first_name " + + "WHERE e.last_name > 'hello'"; + + testPlanMatchingPatterns(query, new String[] {}, new String[] { "Join", "Filter" }); + } + +} diff --git a/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json b/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json index 200ab93e4eb..2380f500256 100755 --- a/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json +++ b/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json @@ -1,10 +1,16 @@ { - "storage":{ - testdb : { - type:"jdbc", - enabled: true, - driver:"org.apache.derby.jdbc.ClientDriver", - url:"jdbc:derby://localhost:20000/memory:testDB;" - } + "storage" : { + derby : { + type : "jdbc", + enabled : true, + driver : "org.apache.derby.jdbc.ClientDriver", + url : "jdbc:derby://localhost:${derby.reserved.port}/memory:${derby.database.name};user=root;password=root" + }, + mysql : { + type : "jdbc", + enabled : true, + driver : "com.mysql.jdbc.Driver", + url : "jdbc:mysql://localhost:${mysql.reserved.port}/${mysql.database.name}?user=root&password=root" + } } } diff --git a/contrib/storage-jdbc/src/test/resources/derby-test-data.sql b/contrib/storage-jdbc/src/test/resources/derby-test-data.sql new file mode 100644 index 00000000000..bbe144115cf --- /dev/null +++ b/contrib/storage-jdbc/src/test/resources/derby-test-data.sql @@ -0,0 +1,48 @@ + + +create table person ( + person_id INT NOT NULL PRIMARY KEY, + + first_name VARCHAR(255), + last_name VARCHAR(255), + address VARCHAR(255), + city VARCHAR(255), + state CHAR(2), + zip INT, + + json VARCHAR(255), + + bigint_field BIGINT, + smallint_field SMALLINT, + numeric_field NUMERIC(10, 2), + boolean_field BOOLEAN, + double_field DOUBLE, + float_field FLOAT, + real_field REAL, + + time_field TIME NOT NUll, + timestamp_field TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + date_field DATE NOT NULL +); + +insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field) + values (1, 'first_name_1', 'last_name_1', '1401 John F Kennedy Blvd', 'Philadelphia', 'PA', 19107, + '{ a : 5, b : 6 }', 123456, 1, 10.01, false, 1.0, 1.1, 111.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + +insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field) + values (2, 'first_name_2', 'last_name_2', 'One Ferry Building', 'San Francisco', 'CA', 94111, + '{ foo : "abc" }', 95949, 2, 20.02, true, 2.0, 2.1, 222.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + +insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field) + values (3, 'first_name_3', 'last_name_3', '176 Bowery', 'New York', 'NY', 10012, + '{ z : [ 1, 2, 3 ] }', 45456, 3, 30.04, true, 3.0, 3.1, 333.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + +insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field) + values (4, NULL, NULL, '2 15th St NW', 'Washington', 'DC', 20007, + '{ z : { a : 1, b : 2, c : 3 } }', -67, 4, 40.04, false, 4.0, 4.1, 444.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + +insert into person (person_id, time_field, date_field) values (5, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); \ No newline at end of file diff --git a/contrib/storage-jdbc/src/test/resources/logback.xml b/contrib/storage-jdbc/src/test/resources/logback-test.xml similarity index 92% rename from contrib/storage-jdbc/src/test/resources/logback.xml rename to contrib/storage-jdbc/src/test/resources/logback-test.xml index 5facafe61b8..4fd5e898e0d 100644 --- a/contrib/storage-jdbc/src/test/resources/logback.xml +++ b/contrib/storage-jdbc/src/test/resources/logback-test.xml @@ -36,13 +36,16 @@ - + + + + + - diff --git a/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql b/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql new file mode 100644 index 00000000000..a98b624c8da --- /dev/null +++ b/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql @@ -0,0 +1,52 @@ + + +use drill_mysql_test; + +create table person ( + person_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + + first_name VARCHAR(255), + last_name VARCHAR(255), + address VARCHAR(255), + city VARCHAR(255), + state CHAR(2), + zip INT, + + json VARCHAR(255), + + bigint_field BIGINT, + smallint_field SMALLINT, + numeric_field NUMERIC(10, 2), + boolean_field BOOLEAN, + double_field DOUBLE, + float_field FLOAT, + real_field REAL, + + time_field TIME NOT NUll, + timestamp_field TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + date_field DATE NOT NULL, + datetime_field DATETIME NOT NULL +) +engine=InnoDB default charset=latin1; + +insert into person (first_name, last_name, address, city, state, zip, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field, datetime_field, json) + values ('first_name_1', 'last_name_1', '1401 John F Kennedy Blvd', 'Philadelphia', 'PA', 19107, 123456789, 1, 10.01, + false, 1.0, 1.1, 1.2, '13:00:01', DATE(NOW()), NOW(), '{ a : 5, b : 6 }'); + +insert into person (first_name, last_name, address, city, state, zip, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field, datetime_field, json) + values ('first_name_2', 'last_name_2', 'One Ferry Building', 'San Francisco', 'CA', 94111, 95949393, 2, 20.03, + true, 2.0, 2.1, 2.2, '23:59:59', DATE(NOW()), NOW(), '{ foo : "abc" }'); + +insert into person (first_name, last_name, address, city, state, zip, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, date_field, datetime_field, json) + values ('first_name_3', 'last_name_3', '176 Bowery', 'New York', 'NY', 10012, 45456767, 3, 30.04, + true, 3.0, 3.1, 3.2, '11:34:21', DATE(NOW()), NOW(), '{ z : [ 1, 2, 3 ] }'); + +insert into person (time_field, date_field, datetime_field) values (TIME(NOW()), DATE(NOW()), NOW()); + +insert into person (first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field, datetime_field) + values ('first_name_5', 'last_name_5', 'Chestnut Hill', 'Boston', 'MA', 12467, '{ [ a, b, c ] }', 123090, -3, 55.12, false, 5.0, + 5.1, 5.55, '16:00:01', '2015-06-01', '2015-06-02 10:01:01', '2015-09-22 15:46:10'); \ No newline at end of file From fbad0adc49391eb0eaa66f654ae23b9a35d6bd4f Mon Sep 17 00:00:00 2001 From: aleph-zero Date: Tue, 29 Sep 2015 13:27:44 -0700 Subject: [PATCH 3/3] MySQL tests for JDBC storage plugin Adds integration tests for JDBC storage plugin with MySQL. --- .../exec/store/jdbc/JdbcRecordReader.java | 15 ++++++++-- .../store/jdbc/TestJdbcPluginWithDerbyIT.java | 22 +++++++------- .../store/jdbc/TestJdbcPluginWithMySQLIT.java | 29 +++++++------------ .../resources/bootstrap-storage-plugins.json | 2 +- .../src/test/resources/derby-test-data.sql | 24 +++++++-------- .../src/test/resources/mysql-test-data.sql | 27 ++++++++--------- 6 files changed, 60 insertions(+), 59 deletions(-) diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java index 222e269304b..49ac098ab8b 100755 --- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java +++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java @@ -26,6 +26,8 @@ import java.sql.Statement; import java.sql.Time; import java.sql.Timestamp; +import java.util.Calendar; +import java.util.TimeZone; import javax.sql.DataSource; @@ -366,13 +368,15 @@ void copy(int index) throws SQLException { private class DateCopier extends Copier { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + public DateCopier(int columnIndex, ResultSet result, NullableDateVector.Mutator mutator) { super(columnIndex, result, mutator); } @Override void copy(int index) throws SQLException { - Date date = result.getDate(columnIndex); + Date date = result.getDate(columnIndex, calendar); if (date != null) { mutator.setSafe(index, date.getTime()); } @@ -382,13 +386,15 @@ void copy(int index) throws SQLException { private class TimeCopier extends Copier { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + public TimeCopier(int columnIndex, ResultSet result, NullableTimeVector.Mutator mutator) { super(columnIndex, result, mutator); } @Override void copy(int index) throws SQLException { - Time time = result.getTime(columnIndex); + Time time = result.getTime(columnIndex, calendar); if (time != null) { mutator.setSafe(index, (int) time.getTime()); } @@ -397,15 +403,18 @@ void copy(int index) throws SQLException { } + private class TimeStampCopier extends Copier { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + public TimeStampCopier(int columnIndex, ResultSet result, NullableTimeStampVector.Mutator mutator) { super(columnIndex, result, mutator); } @Override void copy(int index) throws SQLException { - Timestamp stamp = result.getTimestamp(columnIndex); + Timestamp stamp = result.getTimestamp(columnIndex, calendar); if (stamp != null) { mutator.setSafe(index, stamp.getTime()); } diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java index a9070ad41e0..4cb4b2718e8 100644 --- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java +++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithDerbyIT.java @@ -20,6 +20,8 @@ import org.apache.drill.PlanTestBase; import org.apache.drill.exec.proto.UserBitShared; +import org.joda.time.DateTime; + import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -36,26 +38,22 @@ public void validateResult() throws Exception { testBuilder() .sqlQuery( "select PERSON_ID, FIRST_NAME, LAST_NAME, ADDRESS, CITY, STATE, ZIP, JSON, BIGINT_FIELD, SMALLINT_FIELD, " + - "NUMERIC_FIELD, BOOLEAN_FIELD, DOUBLE_FIELD, FLOAT_FIELD, REAL_FIELD from derby.`default`.PERSON") + "NUMERIC_FIELD, BOOLEAN_FIELD, DOUBLE_FIELD, FLOAT_FIELD, REAL_FIELD, TIME_FIELD, TIMESTAMP_FIELD, " + + "DATE_FIELD from derby.`default`.PERSON") .ordered() .baselineColumns("PERSON_ID", "FIRST_NAME", "LAST_NAME", "ADDRESS", "CITY", "STATE", "ZIP", "JSON", "BIGINT_FIELD", "SMALLINT_FIELD", "NUMERIC_FIELD", "BOOLEAN_FIELD", "DOUBLE_FIELD", - "FLOAT_FIELD", "REAL_FIELD") - .baselineValues(1, "first_name_1", "last_name_1", "1401 John F Kennedy Blvd", "Philadelphia", "PA", 19107, "{ a : 5, b : 6 }", 123456L, 1, 10.01, false, 1.0, 1.1, 111.00) - .baselineValues(2, "first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111, "{ foo : \"abc\" }", 95949L, 2, 20.02, true, 2.0, 2.1, 222.00) - .baselineValues(3, "first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012, "{ z : [ 1, 2, 3 ] }", 45456L, 3, 30.04, true, 3.0, 3.1, 333.00) - .baselineValues(4, null, null, "2 15th St NW", "Washington", "DC", 20007, "{ z : { a : 1, b : 2, c : 3 } }", -67L, 4, 40.04, false, 4.0, 4.1, 444.00) - .baselineValues(5, null, null, null, null, null, null, null, null, null, null, null, null, null, null) + "FLOAT_FIELD", "REAL_FIELD", "TIME_FIELD", "TIMESTAMP_FIELD", "DATE_FIELD") + .baselineValues(1, "first_name_1", "last_name_1", "1401 John F Kennedy Blvd", "Philadelphia", "PA", 19107, "{ a : 5, b : 6 }", 123456L, 1, 10.01, false, 1.0, 1.1, 111.00, new DateTime(1970, 1, 1, 13, 0, 1), new DateTime(2012, 2, 29, 13, 0, 1), new DateTime(2012, 2, 29, 0, 0, 0)) + .baselineValues(2, "first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111, "{ foo : \"abc\" }", 95949L, 2, 20.02, true, 2.0, 2.1, 222.00, new DateTime(1970, 1, 1, 23, 59, 59), new DateTime(1999, 9, 9, 23, 59, 59), new DateTime(1999, 9, 9, 0, 0, 0)) + .baselineValues(3, "first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012, "{ z : [ 1, 2, 3 ] }", 45456L, 3, 30.04, true, 3.0, 3.1, 333.00, new DateTime(1970, 1, 1, 11, 34, 21), new DateTime(2011, 10, 30, 11, 34, 21), new DateTime(2011, 10, 30, 0, 0, 0)) + .baselineValues(4, null, null, "2 15th St NW", "Washington", "DC", 20007, "{ z : { a : 1, b : 2, c : 3 } }", -67L, 4, 40.04, false, 4.0, 4.1, 444.00, new DateTime(1970, 1, 1, 16, 0, 1), new DateTime(2015, 6, 1, 16, 0, 1), new DateTime(2015, 6, 1, 0, 0, 0)) + .baselineValues(5, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null) .build().run(); } @Test public void queryDefaultSchema() throws Exception { - testNoResult("select * from derby.PERSON"); - } - - @Test - public void queryDifferentCase() throws Exception { testNoResult("select * from derby.person"); } diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java index 8e233e005ba..f4c190c4e95 100644 --- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java +++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java @@ -19,8 +19,11 @@ import org.apache.drill.PlanTestBase; +import org.joda.time.DateTime; + import org.junit.Test; + /** * JDBC storage plugin tests against MySQL. */ @@ -29,29 +32,19 @@ public class TestJdbcPluginWithMySQLIT extends PlanTestBase { @Test public void validateResult() throws Exception { - testBuilder() + testBuilder() .sqlQuery( - "select person_id, first_name, last_name, address, city, state, zip, json, time_field from mysql.`drill_mysql_test`.person") + "select person_id, first_name, last_name, address, city, state, zip, json, date_field, datetime_field from mysql.`drill_mysql_test`.person") .ordered() - .baselineColumns("person_id", "first_name", "last_name", "address", "city", "state", "zip", "json", "time_field") - .baselineValues(1, "first_name_1", "last_name_1", "1401 John F Kennedy Blvd", "Philadelphia", "PA", 19107, "{ a : 5, b : 6 }", "13:00:01") - .baselineValues(2, "first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111, "{ foo : \"abc\" }", "23:59:59") - .baselineValues(3, "first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012, "{ z : [ 1, 2, 3 ] }", "11:34:21") - .baselineValues(4, null, null, null, null, null, null, null, null) - .baselineValues(5, "first_name_5", "last_name_5", "Chestnut Hill", "Boston", "MA", 12467, "{ [ a, b, c ]}", "16:00:01") + .baselineColumns("person_id", "first_name", "last_name", "address", "city", "state", "zip", "json", "date_field", "datetime_field") + .baselineValues(1, "first_name_1", "last_name_1", "1401 John F Kennedy Blvd", "Philadelphia", "PA", 19107, "{ a : 5, b : 6 }", new DateTime(2012, 2, 29, 0, 0, 0), new DateTime(2012, 2, 29, 13, 0, 1)) + .baselineValues(2, "first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111, "{ foo : \"abc\" }", new DateTime(1999, 9, 9, 0, 0, 0), new DateTime(1999, 9, 9, 23, 59, 59)) + .baselineValues(3, "first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012, "{ z : [ 1, 2, 3 ] }", new DateTime(2011, 10, 30, 0, 0, 0), new DateTime(2011, 10, 30, 11, 34, 21)) + .baselineValues(4, "first_name_5", "last_name_5", "Chestnut Hill", "Boston", "MA", 12467, "{ [ a, b, c ] }", new DateTime(2015, 6, 1, 0, 0, 0), new DateTime(2015, 9, 22, 15, 46, 10)) + .baselineValues(5, null, null, null, null, null, null, null, null, null) .build().run(); } - @Test - public void queryDefaultSchema() throws Exception { - testNoResult("select * from mysql.PERSON"); - } - - @Test - public void queryDifferentCase() throws Exception { - testNoResult("select * from mysql.person"); - } - @Test public void pushdownJoin() throws Exception { String query = "select x.person_id from (select person_id from mysql.`drill_mysql_test`.person) x " diff --git a/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json b/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json index 2380f500256..61263821e8c 100755 --- a/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json +++ b/contrib/storage-jdbc/src/test/resources/bootstrap-storage-plugins.json @@ -10,7 +10,7 @@ type : "jdbc", enabled : true, driver : "com.mysql.jdbc.Driver", - url : "jdbc:mysql://localhost:${mysql.reserved.port}/${mysql.database.name}?user=root&password=root" + url : "jdbc:mysql://localhost:${mysql.reserved.port}/${mysql.database.name}?user=root&password=root&useJDBCCompliantTimezoneShift=true" } } } diff --git a/contrib/storage-jdbc/src/test/resources/derby-test-data.sql b/contrib/storage-jdbc/src/test/resources/derby-test-data.sql index bbe144115cf..7afa1f54ed9 100644 --- a/contrib/storage-jdbc/src/test/resources/derby-test-data.sql +++ b/contrib/storage-jdbc/src/test/resources/derby-test-data.sql @@ -20,29 +20,29 @@ create table person ( float_field FLOAT, real_field REAL, - time_field TIME NOT NUll, - timestamp_field TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - date_field DATE NOT NULL + time_field TIME, + timestamp_field TIMESTAMP, + date_field DATE ); insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field) values (1, 'first_name_1', 'last_name_1', '1401 John F Kennedy Blvd', 'Philadelphia', 'PA', 19107, - '{ a : 5, b : 6 }', 123456, 1, 10.01, false, 1.0, 1.1, 111.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + '{ a : 5, b : 6 }', 123456, 1, 10.01, false, 1.0, 1.1, 111.00, '13:00:01', '2012-02-29 13:00:01', '2012-02-29'); insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field) values (2, 'first_name_2', 'last_name_2', 'One Ferry Building', 'San Francisco', 'CA', 94111, - '{ foo : "abc" }', 95949, 2, 20.02, true, 2.0, 2.1, 222.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + '{ foo : "abc" }', 95949, 2, 20.02, true, 2.0, 2.1, 222.00, '23:59:59', '1999-09-09 23:59:59', '1999-09-09'); insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field) values (3, 'first_name_3', 'last_name_3', '176 Bowery', 'New York', 'NY', 10012, - '{ z : [ 1, 2, 3 ] }', 45456, 3, 30.04, true, 3.0, 3.1, 333.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + '{ z : [ 1, 2, 3 ] }', 45456, 3, 30.04, true, 3.0, 3.1, 333.00, '11:34:21', '2011-10-30 11:34:21', '2011-10-30'); insert into person (person_id, first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field) values (4, NULL, NULL, '2 15th St NW', 'Washington', 'DC', 20007, - '{ z : { a : 1, b : 2, c : 3 } }', -67, 4, 40.04, false, 4.0, 4.1, 444.00, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); + '{ z : { a : 1, b : 2, c : 3 } }', -67, 4, 40.04, false, 4.0, 4.1, 444.00, '16:00:01', '2015-06-01 16:00:01', '2015-06-01'); -insert into person (person_id, time_field, date_field) values (5, TIME(CURRENT_TIME), DATE(CURRENT_DATE)); \ No newline at end of file +insert into person (person_id) values (5); \ No newline at end of file diff --git a/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql b/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql index a98b624c8da..11b716f124f 100644 --- a/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql +++ b/contrib/storage-jdbc/src/test/resources/mysql-test-data.sql @@ -1,4 +1,5 @@ +set global time_zone = "+00:00"; use drill_mysql_test; @@ -22,31 +23,31 @@ create table person ( float_field FLOAT, real_field REAL, - time_field TIME NOT NUll, - timestamp_field TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - date_field DATE NOT NULL, - datetime_field DATETIME NOT NULL + time_field TIME, + timestamp_field TIMESTAMP, + date_field DATE, + datetime_field DATETIME ) engine=InnoDB default charset=latin1; insert into person (first_name, last_name, address, city, state, zip, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field, datetime_field, json) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field, datetime_field, json) values ('first_name_1', 'last_name_1', '1401 John F Kennedy Blvd', 'Philadelphia', 'PA', 19107, 123456789, 1, 10.01, - false, 1.0, 1.1, 1.2, '13:00:01', DATE(NOW()), NOW(), '{ a : 5, b : 6 }'); + false, 1.0, 1.1, 1.2, '13:00:01', '2012-02-29 13:00:01', '2012-02-29', '2012-02-29 13:00:01', '{ a : 5, b : 6 }'); insert into person (first_name, last_name, address, city, state, zip, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field, datetime_field, json) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field, datetime_field, json) values ('first_name_2', 'last_name_2', 'One Ferry Building', 'San Francisco', 'CA', 94111, 95949393, 2, 20.03, - true, 2.0, 2.1, 2.2, '23:59:59', DATE(NOW()), NOW(), '{ foo : "abc" }'); + true, 2.0, 2.1, 2.2, '23:59:59', '1999-09-09 23:59:59', '1999-09-09', '1999-09-09 23:59:59', '{ foo : "abc" }'); insert into person (first_name, last_name, address, city, state, zip, bigint_field, smallint_field, numeric_field, - boolean_field, double_field, float_field, real_field, time_field, date_field, datetime_field, json) + boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field, datetime_field, json) values ('first_name_3', 'last_name_3', '176 Bowery', 'New York', 'NY', 10012, 45456767, 3, 30.04, - true, 3.0, 3.1, 3.2, '11:34:21', DATE(NOW()), NOW(), '{ z : [ 1, 2, 3 ] }'); - -insert into person (time_field, date_field, datetime_field) values (TIME(NOW()), DATE(NOW()), NOW()); + true, 3.0, 3.1, 3.2, '11:34:21', '2011-10-30 11:34:21', '2011-10-30', '2011-10-30 11:34:21', '{ z : [ 1, 2, 3 ] }'); insert into person (first_name, last_name, address, city, state, zip, json, bigint_field, smallint_field, numeric_field, boolean_field, double_field, float_field, real_field, time_field, timestamp_field, date_field, datetime_field) values ('first_name_5', 'last_name_5', 'Chestnut Hill', 'Boston', 'MA', 12467, '{ [ a, b, c ] }', 123090, -3, 55.12, false, 5.0, - 5.1, 5.55, '16:00:01', '2015-06-01', '2015-06-02 10:01:01', '2015-09-22 15:46:10'); \ No newline at end of file + 5.1, 5.55, '16:00:01', '2015-06-02 10:01:01', '2015-06-01', '2015-09-22 15:46:10'); + +insert into person (person_id) values (5);