org.apache.flink.table.expressions.TimeIntervalUnit Java Examples
The following examples show how to use
org.apache.flink.table.expressions.TimeIntervalUnit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseExpressions.java From flink with Apache License 2.0 | 5 votes |
/** * Rounds up a time point to the given unit. * * <p>e.g. lit("12:44:31").toDate().ceil(MINUTE) leads to 12:45:00 */ public OutType ceil(TimeIntervalUnit timeIntervalUnit) { return toApiSpecificExpression(unresolvedCall( CEIL, toExpr(), valueLiteral(timeIntervalUnit))); }
Example #2
Source File: ExpressionConverter.java From flink with Apache License 2.0 | 5 votes |
private static TimeUnitRange intervalUnitToUnitRange(TimeIntervalUnit intervalUnit) { switch (intervalUnit) { case YEAR: return TimeUnitRange.YEAR; case YEAR_TO_MONTH: return TimeUnitRange.YEAR_TO_MONTH; case QUARTER: return TimeUnitRange.QUARTER; case MONTH: return TimeUnitRange.MONTH; case WEEK: return TimeUnitRange.WEEK; case DAY: return TimeUnitRange.DAY; case DAY_TO_HOUR: return TimeUnitRange.DAY_TO_HOUR; case DAY_TO_MINUTE: return TimeUnitRange.DAY_TO_MINUTE; case DAY_TO_SECOND: return TimeUnitRange.DAY_TO_SECOND; case HOUR: return TimeUnitRange.HOUR; case SECOND: return TimeUnitRange.SECOND; case HOUR_TO_MINUTE: return TimeUnitRange.HOUR_TO_MINUTE; case HOUR_TO_SECOND: return TimeUnitRange.HOUR_TO_SECOND; case MINUTE: return TimeUnitRange.MINUTE; case MINUTE_TO_SECOND: return TimeUnitRange.MINUTE_TO_SECOND; default: throw new UnsupportedOperationException("TimeIntervalUnit is: " + intervalUnit); } }
Example #3
Source File: LogicalTypesTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testSymbolType() { final SymbolType<?> symbolType = new SymbolType<>(TimeIntervalUnit.class); testEquality(symbolType, new SymbolType<>(TimePointUnit.class)); testStringSummary(symbolType, "SYMBOL('" + TimeIntervalUnit.class.getName() + "')"); testNullability(symbolType); testJavaSerializability(symbolType); testConversions(symbolType, new Class[]{TimeIntervalUnit.class}, new Class[]{TimeIntervalUnit.class}); testInvalidStringSerializability(symbolType); }
Example #4
Source File: ClassDataTypeConverterTest.java From flink with Apache License 2.0 | 4 votes |
@Parameterized.Parameters(name = "[{index}] class: {0} type: {1}") public static List<Object[]> testData() { return Arrays.asList( new Object[][]{ {long.class, DataTypes.BIGINT().notNull().bridgedTo(long.class)}, {byte[].class, DataTypes.BYTES().nullable().bridgedTo(byte[].class)}, {Long.class, DataTypes.BIGINT().nullable().bridgedTo(Long.class)}, {java.sql.Time.class, DataTypes.TIME(0).nullable().bridgedTo(java.sql.Time.class)}, {BigDecimal.class, null}, { byte[][].class, DataTypes.ARRAY(DataTypes.BYTES().nullable().bridgedTo(byte[].class)) .nullable() .bridgedTo(byte[][].class) }, { Byte[].class, DataTypes.ARRAY(DataTypes.TINYINT().nullable().bridgedTo(Byte.class)) .nullable() .bridgedTo(Byte[].class) }, { Byte[][].class, DataTypes.ARRAY( DataTypes.ARRAY(DataTypes.TINYINT().nullable().bridgedTo(Byte.class)) .nullable() .bridgedTo(Byte[].class)) .nullable() .bridgedTo(Byte[][].class) }, { Integer[].class, DataTypes.ARRAY(DataTypes.INT().nullable().bridgedTo(Integer.class)) .nullable() .bridgedTo(Integer[].class) }, { int[].class, DataTypes.ARRAY(DataTypes.INT().notNull().bridgedTo(int.class)) .nullable() .bridgedTo(int[].class) }, { TimeIntervalUnit.class, new AtomicDataType(new SymbolType<>(TimeIntervalUnit.class)) .bridgedTo(TimeIntervalUnit.class) }, {Row.class, null} } ); }
Example #5
Source File: LogicalTypesTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testSymbolType() { final SymbolType<?> symbolType = new SymbolType<>(TimeIntervalUnit.class); testEquality(symbolType, new SymbolType<>(TimePointUnit.class)); testStringSummary(symbolType, "SYMBOL('" + TimeIntervalUnit.class.getName() + "')"); testNullability(symbolType); testJavaSerializability(symbolType); testConversions(symbolType, new Class[]{TimeIntervalUnit.class}, new Class[]{TimeIntervalUnit.class}); testInvalidStringSerializability(symbolType); }
Example #6
Source File: ClassDataTypeConverterTest.java From flink with Apache License 2.0 | 4 votes |
@Parameterized.Parameters(name = "[{index}] class: {0} type: {1}") public static List<Object[]> testData() { return Arrays.asList( new Object[][]{ {long.class, DataTypes.BIGINT().notNull().bridgedTo(long.class)}, {byte[].class, DataTypes.BYTES().nullable().bridgedTo(byte[].class)}, {Long.class, DataTypes.BIGINT().nullable().bridgedTo(Long.class)}, {java.sql.Time.class, DataTypes.TIME(0).nullable().bridgedTo(java.sql.Time.class)}, { java.time.Duration.class, DataTypes.INTERVAL(DataTypes.SECOND(9)) .bridgedTo(java.time.Duration.class) }, { java.time.Period.class, DataTypes.INTERVAL(DataTypes.YEAR(4), DataTypes.MONTH()) .bridgedTo(java.time.Period.class) }, {BigDecimal.class, null}, { byte[][].class, DataTypes.ARRAY(DataTypes.BYTES().nullable().bridgedTo(byte[].class)) .nullable() .bridgedTo(byte[][].class) }, { Byte[].class, DataTypes.ARRAY(DataTypes.TINYINT().nullable().bridgedTo(Byte.class)) .nullable() .bridgedTo(Byte[].class) }, { Byte[][].class, DataTypes.ARRAY( DataTypes.ARRAY(DataTypes.TINYINT().nullable().bridgedTo(Byte.class)) .nullable() .bridgedTo(Byte[].class)) .nullable() .bridgedTo(Byte[][].class) }, { Integer[].class, DataTypes.ARRAY(DataTypes.INT().nullable().bridgedTo(Integer.class)) .nullable() .bridgedTo(Integer[].class) }, { int[].class, DataTypes.ARRAY(DataTypes.INT().notNull().bridgedTo(int.class)) .nullable() .bridgedTo(int[].class) }, { TimeIntervalUnit.class, new AtomicDataType(new SymbolType<>(TimeIntervalUnit.class)) .bridgedTo(TimeIntervalUnit.class) }, {Row.class, null} } ); }
Example #7
Source File: BaseExpressions.java From flink with Apache License 2.0 | 2 votes |
/** * Extracts parts of a time point or time interval. Returns the part as a long value. * * <p>e.g. lit("2006-06-05").toDate().extract(DAY) leads to 5 */ public OutType extract(TimeIntervalUnit timeIntervalUnit) { return toApiSpecificExpression(unresolvedCall(EXTRACT, valueLiteral(timeIntervalUnit), toExpr())); }
Example #8
Source File: BaseExpressions.java From flink with Apache License 2.0 | 2 votes |
/** * Rounds down a time point to the given unit. * * <p>e.g. lit("12:44:31").toDate().floor(MINUTE) leads to 12:44:00 */ public OutType floor(TimeIntervalUnit timeIntervalUnit) { return toApiSpecificExpression(unresolvedCall(FLOOR, toExpr(), valueLiteral(timeIntervalUnit))); }