use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project hive by apache.
the class RexNodeExprFactory method createIntervalMinuteConstantExpr.
/**
* {@inheritDoc}
*/
@Override
protected RexLiteral createIntervalMinuteConstantExpr(String value) {
HiveIntervalDayTime v = new HiveIntervalDayTime(0, 0, Integer.parseInt(value), 0, 0);
BigDecimal secsValueBd = BigDecimal.valueOf(v.getTotalSeconds() * 1000);
BigDecimal nanosValueBd = BigDecimal.valueOf((v).getNanos(), 6);
return rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd), new SqlIntervalQualifier(TimeUnit.MILLISECOND, null, new SqlParserPos(1, 1)));
}
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());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlIntervalQualifier in project flink by apache.
the class RelDataTypeJsonSerdeTest method testRelDataTypeSerde.
// --------------------------------------------------------------------------------------------
// Test data
// --------------------------------------------------------------------------------------------
public static List<RelDataType> testRelDataTypeSerde() {
// the values in the list do not care about nullable.
final List<RelDataType> types = Arrays.asList(FACTORY.createSqlType(SqlTypeName.BOOLEAN), FACTORY.createSqlType(SqlTypeName.TINYINT), FACTORY.createSqlType(SqlTypeName.SMALLINT), FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.BIGINT), FACTORY.createSqlType(SqlTypeName.DECIMAL, 10, 3), FACTORY.createSqlType(SqlTypeName.DECIMAL, 19, 0), FACTORY.createSqlType(SqlTypeName.DECIMAL, 38, 19), FACTORY.createSqlType(SqlTypeName.FLOAT), FACTORY.createSqlType(SqlTypeName.DOUBLE), FACTORY.createSqlType(SqlTypeName.DATE), FACTORY.createSqlType(SqlTypeName.TIME), FACTORY.createSqlType(SqlTypeName.TIMESTAMP), FACTORY.createSqlType(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.DAY, 2, TimeUnit.MINUTE, RelDataType.PRECISION_NOT_SPECIFIED, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.DAY, 6, TimeUnit.SECOND, 9, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.HOUR, RelDataType.PRECISION_NOT_SPECIFIED, TimeUnit.SECOND, 9, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.MINUTE, RelDataType.PRECISION_NOT_SPECIFIED, TimeUnit.SECOND, 0, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.SECOND, RelDataType.PRECISION_NOT_SPECIFIED, TimeUnit.SECOND, 6, SqlParserPos.ZERO)), FACTORY.createSqlType(SqlTypeName.CHAR), FACTORY.createSqlType(SqlTypeName.CHAR, 0), FACTORY.createSqlType(SqlTypeName.CHAR, 32), FACTORY.createSqlType(SqlTypeName.VARCHAR), FACTORY.createSqlType(SqlTypeName.VARCHAR, 0), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10), FACTORY.createSqlType(SqlTypeName.BINARY), FACTORY.createSqlType(SqlTypeName.BINARY, 0), FACTORY.createSqlType(SqlTypeName.BINARY, 100), FACTORY.createSqlType(SqlTypeName.VARBINARY), FACTORY.createSqlType(SqlTypeName.VARBINARY, 0), FACTORY.createSqlType(SqlTypeName.VARBINARY, 1000), FACTORY.createSqlType(SqlTypeName.NULL), FACTORY.createSqlType(SqlTypeName.SYMBOL), FACTORY.createMultisetType(FACTORY.createSqlType(SqlTypeName.VARCHAR), -1), FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1), FACTORY.createArrayType(FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1), -1), FACTORY.createMapType(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), FACTORY.createMapType(FACTORY.createMapType(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), FACTORY.createArrayType(FACTORY.createMapType(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), -1)), // simple struct type
FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.DECIMAL, 10, 3)), Arrays.asList("f1", "f2")), // struct type with array type
FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createSqlType(SqlTypeName.VARCHAR), FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1)), Arrays.asList("f1", "f2")), // nested struct type
FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createSqlType(SqlTypeName.VARCHAR, 5), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), Arrays.asList("f1", "f2")), FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1)), Arrays.asList("f3", "f4")), FACTORY.createRowtimeIndicatorType(true, false), FACTORY.createRowtimeIndicatorType(true, true), FACTORY.createProctimeIndicatorType(true), FACTORY.createFieldTypeFromLogicalType(StructuredType.newBuilder(ObjectIdentifier.of("cat", "db", "structuredType"), DataTypeJsonSerdeTest.PojoClass.class).attributes(Arrays.asList(new StructuredType.StructuredAttribute("f0", new IntType(true)), new StructuredType.StructuredAttribute("f1", new BigIntType(true)), new StructuredType.StructuredAttribute("f2", new VarCharType(200), "desc"))).comparison(StructuredType.StructuredComparison.FULL).setFinal(false).setInstantiable(false).description("description for StructuredType").build()));
final List<RelDataType> mutableTypes = new ArrayList<>(types.size() * 2);
for (RelDataType type : types) {
mutableTypes.add(FACTORY.createTypeWithNullability(type, true));
mutableTypes.add(FACTORY.createTypeWithNullability(type, false));
}
mutableTypes.add(FACTORY.createTypeWithNullability(FACTORY.createFieldTypeFromLogicalType(new RawType<>(true, Void.class, VoidSerializer.INSTANCE)), true));
mutableTypes.add(FACTORY.createTypeWithNullability(FACTORY.createFieldTypeFromLogicalType(new RawType<>(false, Void.class, VoidSerializer.INSTANCE)), false));
mutableTypes.add(FACTORY.createTypeWithNullability(FACTORY.createFieldTypeFromLogicalType(new RawType<>(true, Void.class, VoidSerializer.INSTANCE)), false));
return mutableTypes;
}
Aggregations