use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project hazelcast by hazelcast.
the class RexToExpressionTest method test_intervalYearMonth.
@Test
public void test_intervalYearMonth() {
RelDataType type = FACTORY.createSqlIntervalType(new SqlIntervalQualifier(YEAR, MONTH, SqlParserPos.ZERO));
RexLiteral literal = BUILDER.makeSearchArgumentLiteral(sarg(new BigDecimal(1), new BigDecimal(2)), type);
Range<?> converted = convert(literal);
assertThat(converted).isEqualToComparingFieldByField(range(new SqlYearMonthInterval(1), new SqlYearMonthInterval(2)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project hazelcast by hazelcast.
the class RexToExpressionTest method test_intervalDaySecond.
@Test
public void test_intervalDaySecond() {
RelDataType type = FACTORY.createSqlIntervalType(new SqlIntervalQualifier(DAY, SECOND, SqlParserPos.ZERO));
RexLiteral literal = BUILDER.makeSearchArgumentLiteral(sarg(new BigDecimal(1), new BigDecimal(2)), type);
Range<?> converted = convert(literal);
assertThat(converted).isEqualToComparingFieldByField(range(new SqlDaySecondInterval(1), new SqlDaySecondInterval(2)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project druid by druid-io.
the class ExpressionsTest method testTimeMinusYearMonthInterval.
@Test
public void testTimeMinusYearMonthInterval() {
final Period period = new Period("P1Y1M");
testHelper.testExpression(SqlTypeName.TIMESTAMP, SqlStdOperatorTable.MINUS_DATE, ImmutableList.of(testHelper.makeInputRef("t"), testHelper.makeLiteral(// YEAR-MONTH literals value is months
new BigDecimal(13), new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, SqlParserPos.ZERO))), DruidExpression.ofExpression(ColumnType.LONG, DruidExpression.functionCall("timestamp_shift"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.LONG, "t"), // RexNode type "interval year to month" is not reported as ColumnType.STRING
DruidExpression.ofLiteral(null, DruidExpression.stringLiteral("P13M")), DruidExpression.ofLiteral(ColumnType.LONG, DruidExpression.numberLiteral(-1)), DruidExpression.ofStringLiteral("UTC"))), DateTimes.of("2000-02-03T04:05:06").minus(period).getMillis());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project druid by druid-io.
the class GreatestExpressionTest method testInvalidType.
@Test
public void testInvalidType() {
expectException(IllegalArgumentException.class, "Argument 0 has invalid type: INTERVAL_YEAR_MONTH");
testExpression(Collections.singletonList(testHelper.makeLiteral(// YEAR-MONTH literals value is months
new BigDecimal(13), new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, SqlParserPos.ZERO))), null, null);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project druid by druid-io.
the class ExpressionsTest method testTimePlusDayTimeInterval.
@Test
public void testTimePlusDayTimeInterval() {
final Period period = new Period("P1DT1H1M");
testHelper.testExpressionString(SqlStdOperatorTable.DATETIME_PLUS, ImmutableList.of(testHelper.makeInputRef("t"), testHelper.makeLiteral(// DAY-TIME literals value is millis
new BigDecimal(period.toStandardDuration().getMillis()), new SqlIntervalQualifier(TimeUnit.DAY, TimeUnit.MINUTE, SqlParserPos.ZERO))), makeExpression(ColumnType.LONG, "(\"t\" + 90060000)"), DateTimes.of("2000-02-03T04:05:06").plus(period).getMillis());
}
Aggregations