Skip to content

Commit

Permalink
Fix rebases
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi committed Jul 5, 2019
1 parent ca31b33 commit 58d7331
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
Expand Up @@ -39,7 +39,6 @@
import org.apache.flink.api.common.io.InputFormat;
import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.LocalTimeTypeInfo;
import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
import org.apache.flink.api.common.typeinfo.SqlTimeTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeInfo;
Expand Down Expand Up @@ -1714,12 +1713,6 @@ private <OUT,IN1,IN2> TypeInformation<OUT> privateGetForClass(Class<OUT> clazz,
return timeTypeInfo;
}

// check for SQL time types
TypeInformation<OUT> localTimeTypeInfo = LocalTimeTypeInfo.getInfoFor(clazz);
if (localTimeTypeInfo != null) {
return localTimeTypeInfo;
}

// check for subclasses of Value
if (Value.class.isAssignableFrom(clazz)) {
Class<? extends Value> valueClass = clazz.asSubclass(Value.class);
Expand Down
Expand Up @@ -23,9 +23,6 @@
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -45,7 +42,6 @@
import org.apache.flink.api.common.functions.RuntimeContext;
import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.LocalTimeTypeInfo;
import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
import org.apache.flink.api.common.typeinfo.SqlTimeTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeHint;
Expand Down Expand Up @@ -2089,39 +2085,4 @@ public Tuple3<Date, Time, Timestamp> map(Tuple3<Date, Time, Timestamp> value) th
Assert.assertEquals(SqlTimeTypeInfo.TIME, TypeExtractor.getForObject(Time.valueOf("12:37:45")));
Assert.assertEquals(SqlTimeTypeInfo.TIMESTAMP, TypeExtractor.getForObject(Timestamp.valueOf("1998-12-12 12:37:45")));
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testLocalTimeTypes() {
MapFunction<?, ?> function = new MapFunction<Tuple3<LocalDate, LocalTime, LocalDateTime>, Tuple3<LocalDate, LocalTime, LocalDateTime>>() {
@Override
public Tuple3<LocalDate, LocalTime, LocalDateTime> map(Tuple3<LocalDate, LocalTime, LocalDateTime> value) throws Exception {
return null;
}
};

TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(
function,
(TypeInformation) TypeInformation.of(new TypeHint<Tuple3<LocalDate, LocalTime, LocalDateTime>>() {
}));

Assert.assertTrue(ti.isTupleType());
TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
Assert.assertEquals(LocalTimeTypeInfo.LOCAL_DATE, tti.getTypeAt(0));
Assert.assertEquals(LocalTimeTypeInfo.LOCAL_TIME, tti.getTypeAt(1));
Assert.assertEquals(LocalTimeTypeInfo.LOCAL_DATE_TIME, tti.getTypeAt(2));

// use getForClass()
Assert.assertEquals(tti.getTypeAt(0), TypeExtractor.getForClass(LocalDate.class));
Assert.assertEquals(tti.getTypeAt(1), TypeExtractor.getForClass(LocalTime.class));
Assert.assertEquals(tti.getTypeAt(2), TypeExtractor.getForClass(LocalDateTime.class));

// use getForObject()
Assert.assertEquals(LocalTimeTypeInfo.LOCAL_DATE,
TypeExtractor.getForObject(LocalDate.of(1998, 12, 12)));
Assert.assertEquals(LocalTimeTypeInfo.LOCAL_TIME,
TypeExtractor.getForObject(LocalTime.of(12, 37, 45)));
Assert.assertEquals(LocalTimeTypeInfo.LOCAL_DATE_TIME,
TypeExtractor.getForObject(LocalDateTime.of(1998, 12, 12, 12, 37, 45)));
}
}

0 comments on commit 58d7331

Please sign in to comment.