Search in sources :

Example 96 with RexLiteral

use of org.apache.calcite.rex.RexLiteral 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)));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) SqlIntervalQualifier(org.apache.calcite.sql.SqlIntervalQualifier) SqlYearMonthInterval(com.hazelcast.sql.impl.type.SqlYearMonthInterval) RelDataType(org.apache.calcite.rel.type.RelDataType) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 97 with RexLiteral

use of org.apache.calcite.rex.RexLiteral in project hazelcast by hazelcast.

the class RexToExpressionTest method test_smallint.

@Test
public void test_smallint() {
    RexLiteral literal = literal(new BigDecimal(1), new BigDecimal(2), SqlTypeName.SMALLINT);
    Range<?> converted = convert(literal);
    assertThat(converted).isEqualToComparingFieldByField(range((short) 1, (short) 2));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 98 with RexLiteral

use of org.apache.calcite.rex.RexLiteral 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)));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) SqlIntervalQualifier(org.apache.calcite.sql.SqlIntervalQualifier) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlDaySecondInterval(com.hazelcast.sql.impl.type.SqlDaySecondInterval) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 99 with RexLiteral

use of org.apache.calcite.rex.RexLiteral in project hazelcast by hazelcast.

the class RexToExpressionTest method test_boolean.

@Test
public void test_boolean() {
    RexLiteral literal = literal(false, true, SqlTypeName.BOOLEAN);
    Range<?> converted = convert(literal);
    assertThat(converted).isEqualToComparingFieldByField(range(false, true));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) Test(org.junit.Test)

Example 100 with RexLiteral

use of org.apache.calcite.rex.RexLiteral in project hazelcast by hazelcast.

the class RexToExpressionTest method test_timestamp.

@Test
public void test_timestamp() {
    RexLiteral literal = literal(new TimestampString("2021-09-17 12:23:34"), new TimestampString("2021-09-17 12:23:35"), SqlTypeName.TIMESTAMP);
    Range<?> converted = convert(literal);
    assertThat(converted).isEqualToComparingFieldByField(range(LocalDateTime.of(2021, 9, 17, 12, 23, 34), LocalDateTime.of(2021, 9, 17, 12, 23, 35)));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) TimestampString(org.apache.calcite.util.TimestampString) Test(org.junit.Test)

Aggregations

RexLiteral (org.apache.calcite.rex.RexLiteral)150 RexNode (org.apache.calcite.rex.RexNode)92 ArrayList (java.util.ArrayList)51 RelDataType (org.apache.calcite.rel.type.RelDataType)45 RexCall (org.apache.calcite.rex.RexCall)45 Test (org.junit.Test)32 BigDecimal (java.math.BigDecimal)28 RexInputRef (org.apache.calcite.rex.RexInputRef)26 RelNode (org.apache.calcite.rel.RelNode)22 ImmutableList (com.google.common.collect.ImmutableList)18 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)17 List (java.util.List)16 Map (java.util.Map)16 RexBuilder (org.apache.calcite.rex.RexBuilder)16 AggregateCall (org.apache.calcite.rel.core.AggregateCall)15 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)12 RexLiteral (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexLiteral)11 NlsString (org.apache.calcite.util.NlsString)11 HashMap (java.util.HashMap)10 RexNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)10