Skip to content

Commit

Permalink
Remove usages of deprecated parseTimestampInLocalTime
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Jul 18, 2018
1 parent b62986f commit 3e2191c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 35 deletions.
4 changes: 0 additions & 4 deletions presto-product-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@

import io.prestodb.tempto.runner.TemptoRunner;
import io.prestodb.tempto.runner.TemptoRunnerCommandLineParser;
import org.joda.time.DateTimeZone;

public class TemptoProductTestRunner
{
public static final DateTimeZone PRODUCT_TESTS_TIME_ZONE = DateTimeZone.forID("Asia/Kathmandu");

public static void main(String[] args)
{
TemptoRunnerCommandLineParser parser = TemptoRunnerCommandLineParser.builder("Presto product tests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import java.math.BigInteger;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

import static com.facebook.presto.tests.TemptoProductTestRunner.PRODUCT_TESTS_TIME_ZONE;
import static com.facebook.presto.tests.cassandra.TestConstants.CONNECTOR_NAME;
import static com.facebook.presto.tests.cassandra.TestConstants.KEY_SPACE;
import static io.prestodb.tempto.util.DateTimeUtils.parseTimestampInLocalTime;

public class DataTypesTableDefinition
{
Expand All @@ -55,7 +55,7 @@ private DataTypesTableDefinition() {}
BigDecimal.ZERO, Double.MIN_VALUE, Float.MIN_VALUE, ImmutableSet.of(0),
Inet4Address.getByName("0.0.0.0"), Integer.MIN_VALUE, ImmutableList.of(0),
ImmutableMap.of("a", 0, "\0", Integer.MIN_VALUE), ImmutableSet.of(0),
"\0", parseTimestampInLocalTime("1970-01-01 00:00:00", PRODUCT_TESTS_TIME_ZONE),
"\0", Timestamp.valueOf(LocalDateTime.of(1970, 1, 1, 0, 0)),
UUID.fromString("d2177dd0-eaa2-11de-a572-001b779c76e3"),
UUID.fromString("01234567-0123-0123-0123-0123456789ab"),
"\0", BigInteger.valueOf(Long.MIN_VALUE)),
Expand All @@ -65,7 +65,7 @@ private DataTypesTableDefinition() {}
Double.MAX_VALUE, Float.MAX_VALUE, ImmutableSet.of(4, 5, 6, 7),
Inet4Address.getByName("255.255.255.255"), Integer.MAX_VALUE,
ImmutableList.of(4, 5, 6), ImmutableMap.of("a", 1, "b", 2), ImmutableSet.of(4, 5, 6),
"this is a text value", parseTimestampInLocalTime("9999-12-31 23:59:59", PRODUCT_TESTS_TIME_ZONE),
"this is a text value", Timestamp.valueOf(LocalDateTime.of(9999, 12, 31, 23, 59, 59)),
UUID.fromString("d2177dd0-eaa2-11de-a572-001b779c76e3"),
UUID.fromString("01234567-0123-0123-0123-0123456789ab"),
"abc", BigInteger.valueOf(Long.MAX_VALUE)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import io.prestodb.tempto.query.QueryResult;
import org.testng.annotations.Test;

import static com.facebook.presto.tests.TemptoProductTestRunner.PRODUCT_TESTS_TIME_ZONE;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import static com.facebook.presto.tests.TestGroups.CASSANDRA;
import static com.facebook.presto.tests.cassandra.DataTypesTableDefinition.CASSANDRA_ALL_TYPES;
import static com.facebook.presto.tests.cassandra.TestConstants.CONNECTOR_NAME;
Expand All @@ -35,7 +37,6 @@
import static io.prestodb.tempto.fulfillment.table.MutableTablesState.mutableTablesState;
import static io.prestodb.tempto.fulfillment.table.TableRequirements.mutableTable;
import static io.prestodb.tempto.query.QueryExecutor.query;
import static io.prestodb.tempto.util.DateTimeUtils.parseTimestampInLocalTime;
import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.MINUTES;

Expand Down Expand Up @@ -108,7 +109,7 @@ public void testInsertIntoValuesToCassandraTableAllSimpleTypes()
null,
null,
"text value",
parseTimestampInLocalTime("9999-12-31 23:59:59", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(9999, 12, 31, 23, 59, 59)),
null,
null,
"varchar value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import io.prestodb.tempto.query.QueryResult;
import org.testng.annotations.Test;

import static com.facebook.presto.tests.TemptoProductTestRunner.PRODUCT_TESTS_TIME_ZONE;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import static com.facebook.presto.tests.TestGroups.CASSANDRA;
import static com.facebook.presto.tests.TpchTableResults.PRESTO_NATION_RESULT;
import static com.facebook.presto.tests.cassandra.CassandraTpchTableDefinitions.CASSANDRA_NATION;
Expand All @@ -38,7 +40,6 @@
import static io.prestodb.tempto.assertions.QueryAssert.assertThat;
import static io.prestodb.tempto.fulfillment.table.TableRequirements.immutableTable;
import static io.prestodb.tempto.query.QueryExecutor.query;
import static io.prestodb.tempto.util.DateTimeUtils.parseTimestampInLocalTime;
import static java.lang.String.format;
import static java.sql.JDBCType.BIGINT;
import static java.sql.JDBCType.BOOLEAN;
Expand Down Expand Up @@ -179,13 +180,13 @@ public void testAllDataTypes()
.containsOnly(
row("\0", Long.MIN_VALUE, Bytes.fromHexString("0x00").array(), false, 0f, Double.MIN_VALUE,
Float.MIN_VALUE, "[0]", "0.0.0.0", Integer.MIN_VALUE, "[0]", "{\"\\u0000\":-2147483648,\"a\":0}",
"[0]", "\0", parseTimestampInLocalTime("1970-01-01 00:00:00.0", PRODUCT_TESTS_TIME_ZONE),
"[0]", "\0", Timestamp.valueOf(LocalDateTime.of(1970, 1, 1, 0, 0)),
"d2177dd0-eaa2-11de-a572-001b779c76e3", "01234567-0123-0123-0123-0123456789ab",
"\0", String.valueOf(Long.MIN_VALUE)),
row("the quick brown fox jumped over the lazy dog", 9223372036854775807L, "01234".getBytes(),
true, new Double("99999999999999999999999999999999999999"), Double.MAX_VALUE,
Float.MAX_VALUE, "[4,5,6,7]", "255.255.255.255", Integer.MAX_VALUE, "[4,5,6]",
"{\"a\":1,\"b\":2}", "[4,5,6]", "this is a text value", parseTimestampInLocalTime("9999-12-31 23:59:59", PRODUCT_TESTS_TIME_ZONE),
"{\"a\":1,\"b\":2}", "[4,5,6]", "this is a text value", Timestamp.valueOf(LocalDateTime.of(9999, 12, 31, 23, 59, 59)),
"d2177dd0-eaa2-11de-a572-001b779c76e3", "01234567-0123-0123-0123-0123456789ab",
"abc", String.valueOf(Long.MAX_VALUE)),
row("def", null, null, null, null, null, null, null, null, null, null, null,
Expand Down Expand Up @@ -260,7 +261,7 @@ public void testSelectAllTypePartitioningMaterializedView()
.containsOnly(
row("\0", Long.MIN_VALUE, Bytes.fromHexString("0x00").array(), false, 0f, Double.MIN_VALUE,
Float.MIN_VALUE, "[0]", "0.0.0.0", Integer.MIN_VALUE, "[0]", "{\"\\u0000\":-2147483648,\"a\":0}",
"[0]", "\0", parseTimestampInLocalTime("1970-01-01 00:00:00.0", PRODUCT_TESTS_TIME_ZONE),
"[0]", "\0", Timestamp.valueOf(LocalDateTime.of(1970, 1, 1, 0, 0)),
"d2177dd0-eaa2-11de-a572-001b779c76e3", "01234567-0123-0123-0123-0123456789ab",
"\0", String.valueOf(Long.MIN_VALUE)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import static com.facebook.presto.tests.TemptoProductTestRunner.PRODUCT_TESTS_TIME_ZONE;
import static com.facebook.presto.tests.TestGroups.HIVE_CONNECTOR;
import static com.facebook.presto.tests.TestGroups.JDBC;
import static com.facebook.presto.tests.TestGroups.POST_HIVE_1_0_1;
Expand All @@ -50,7 +51,6 @@
import static io.prestodb.tempto.fulfillment.table.TableHandle.tableHandle;
import static io.prestodb.tempto.fulfillment.table.TableRequirements.immutableTable;
import static io.prestodb.tempto.query.QueryExecutor.query;
import static io.prestodb.tempto.util.DateTimeUtils.parseTimestampInLocalTime;
import static java.lang.String.format;
import static java.sql.JDBCType.BIGINT;
import static java.sql.JDBCType.BOOLEAN;
Expand Down Expand Up @@ -145,7 +145,7 @@ public void testSelectAllDatatypesTextFile()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
Date.valueOf("2015-05-10"),
"ala ma kota",
"ala ma kot",
Expand Down Expand Up @@ -176,7 +176,7 @@ public void testSelectAllDatatypesOrc()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
Date.valueOf("2015-05-10"),
"ala ma kota",
"ala ma kot",
Expand Down Expand Up @@ -207,7 +207,7 @@ public void testSelectAllDatatypesRcfile()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
Date.valueOf("2015-05-10"),
"ala ma kota",
"ala ma kot",
Expand All @@ -229,7 +229,7 @@ public void testSelectAllDatatypesAvro()
"234.567," +
"346," +
"345.67800," +
"'" + parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE).toString() + "'," +
"'" + Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)).toString() + "'," +
"'" + Date.valueOf("2015-05-10") + "'," +
"'ala ma kota'," +
"'ala ma kot'," +
Expand Down Expand Up @@ -278,7 +278,7 @@ public void testSelectAllDatatypesAvro()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
Date.valueOf("2015-05-10"),
"ala ma kota",
"ala ma kot",
Expand Down Expand Up @@ -361,7 +361,7 @@ public void testSelectAllDatatypesParquetFile()
"234.567," +
"346," +
"345.67800," +
"'" + parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE).toString() + "'," +
"'" + Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)).toString() + "'," +
"'ala ma kota'," +
"'ala ma kot'," +
"'ala ma '," +
Expand Down Expand Up @@ -397,7 +397,7 @@ public void testSelectAllDatatypesParquetFile()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
"ala ma kota",
"ala ma kot",
"ala ma ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import static com.facebook.presto.tests.TemptoProductTestRunner.PRODUCT_TESTS_TIME_ZONE;
import static com.facebook.presto.tests.TestGroups.HIVE_CONNECTOR;
import static com.facebook.presto.tests.TestGroups.POST_HIVE_1_0_1;
import static com.facebook.presto.tests.hive.AllSimpleTypesTableDefinitions.ALL_HIVE_SIMPLE_TYPES_TEXTFILE;
Expand All @@ -36,7 +37,6 @@
import static io.prestodb.tempto.fulfillment.table.TableRequirements.immutableTable;
import static io.prestodb.tempto.fulfillment.table.TableRequirements.mutableTable;
import static io.prestodb.tempto.query.QueryExecutor.query;
import static io.prestodb.tempto.util.DateTimeUtils.parseTimestampInLocalTime;

public class TestInsertIntoHiveTable
extends ProductTest
Expand Down Expand Up @@ -107,7 +107,7 @@ public void testInsertIntoValuesToHiveTableAllHiveSimpleTypes()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
Date.valueOf("2015-05-10"),
"ala ma kota",
"ala ma kot",
Expand All @@ -132,7 +132,7 @@ public void testInsertIntoSelectToHiveTableAllHiveSimpleTypes()
234.567,
new BigDecimal("346"),
new BigDecimal("345.67800"),
parseTimestampInLocalTime("2015-05-10 12:15:35.123", PRODUCT_TESTS_TIME_ZONE),
Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)),
Date.valueOf("2015-05-10"),
"ala ma kota",
"ala ma kot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
package com.facebook.presto.tests.teradata;

import io.prestodb.tempto.ProductTest;
import org.joda.time.DateTimeZone;
import org.testng.annotations.Test;

import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import static com.facebook.presto.tests.TestGroups.FUNCTIONS;
import static com.facebook.presto.tests.utils.QueryExecutors.onPresto;
import static io.prestodb.tempto.assertions.QueryAssert.Row.row;
import static io.prestodb.tempto.assertions.QueryAssert.assertThat;
import static io.prestodb.tempto.util.DateTimeUtils.parseTimestampInLocalTime;

public class TestTeradataFunctions
extends ProductTest
Expand Down Expand Up @@ -53,7 +53,7 @@ public void testToDate()
public void testToTimestamp()
{
assertThat(onPresto().executeQuery("SELECT to_timestamp('1988/04/08;02:03:04','yyyy/mm/dd;hh24:mi:ss')"))
.contains(row(parseTimestampInLocalTime("1988-04-08 02:03:04.0", DateTimeZone.forID("Asia/Kathmandu"))));
.contains(row(Timestamp.valueOf(LocalDateTime.of(1988, 4, 8, 2, 3, 4))));
}

@Test(groups = FUNCTIONS)
Expand Down

0 comments on commit 3e2191c

Please sign in to comment.