AMashenkov commented on code in PR #7303:
URL: https://github.com/apache/ignite-3/pull/7303#discussion_r2646918460


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/expressions/IgnitePredicateTest.java:
##########
@@ -0,0 +1,1172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.sql.engine.expressions;
+
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import java.math.BigDecimal;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.UUID;
+import org.apache.ignite.internal.sql.engine.api.expressions.EvaluationContext;
+import 
org.apache.ignite.internal.sql.engine.api.expressions.ExpressionEvaluationException;
+import org.apache.ignite.internal.sql.engine.api.expressions.ExpressionFactory;
+import 
org.apache.ignite.internal.sql.engine.api.expressions.ExpressionParsingException;
+import 
org.apache.ignite.internal.sql.engine.api.expressions.ExpressionValidationException;
+import org.apache.ignite.internal.sql.engine.api.expressions.IgnitePredicate;
+import org.apache.ignite.internal.sql.engine.api.expressions.RowAccessor;
+import org.apache.ignite.internal.sql.engine.exec.exp.SqlExpressionFactoryImpl;
+import org.apache.ignite.internal.sql.engine.util.Commons;
+import org.apache.ignite.internal.sql.engine.util.EmptyCacheFactory;
+import org.apache.ignite.internal.type.NativeType;
+import org.apache.ignite.internal.type.NativeTypes;
+import org.apache.ignite.internal.type.StructNativeType;
+import org.apache.ignite.sql.ColumnType;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+@SuppressWarnings("ThrowableNotThrown")
+class IgnitePredicateTest extends AbstractExpressionFactoryTest {
+    private final ExpressionFactory factory = new SqlExpressionFactoryAdapter(
+            new SqlExpressionFactoryImpl(
+                    Commons.typeFactory(), 0, EmptyCacheFactory.INSTANCE
+            )
+    );
+
+    @Test
+    @TestFor(ColumnType.BOOLEAN)
+    void booleanTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.BOOLEAN);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val", inputType);
+
+            assertThat(predicate.test(context, row(true)), is(true));
+            assertThat(predicate.test(context, row(false)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val = true", 
inputType);
+
+            assertThat(predicate.test(context, row(true)), is(true));
+            assertThat(predicate.test(context, row(false)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> true", 
inputType);
+
+            assertThat(predicate.test(context, row(true)), is(false));
+            assertThat(predicate.test(context, row(false)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(true)), is(false));
+            assertThat(predicate.test(context, row(false)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(true)), is(true));
+            assertThat(predicate.test(context, row(false)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.INT8)
+    void byteTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.INT8);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(false));
+            assertThat(predicate.test(context, row((byte) 0)), is(false));
+            assertThat(predicate.test(context, row((byte) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(true));
+            assertThat(predicate.test(context, row((byte) 0)), is(false));
+            assertThat(predicate.test(context, row((byte) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(true));
+            assertThat(predicate.test(context, row((byte) 0)), is(true));
+            assertThat(predicate.test(context, row((byte) 100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(false));
+            assertThat(predicate.test(context, row((byte) 0)), is(false));
+            assertThat(predicate.test(context, row((byte) 100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(true));
+            assertThat(predicate.test(context, row((byte) 0)), is(true));
+            assertThat(predicate.test(context, row((byte) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(true));
+            assertThat(predicate.test(context, row((byte) 0)), is(true));
+            assertThat(predicate.test(context, row((byte) 100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row((byte) -100)), is(false));
+            assertThat(predicate.test(context, row((byte) 0)), is(false));
+            assertThat(predicate.test(context, row((byte) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.INT16)
+    void shortTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.INT16);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(false));
+            assertThat(predicate.test(context, row((short) 0)), is(false));
+            assertThat(predicate.test(context, row((short) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(true));
+            assertThat(predicate.test(context, row((short) 0)), is(false));
+            assertThat(predicate.test(context, row((short) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(true));
+            assertThat(predicate.test(context, row((short) 0)), is(true));
+            assertThat(predicate.test(context, row((short) 100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(false));
+            assertThat(predicate.test(context, row((short) 0)), is(false));
+            assertThat(predicate.test(context, row((short) 100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(true));
+            assertThat(predicate.test(context, row((short) 0)), is(true));
+            assertThat(predicate.test(context, row((short) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(true));
+            assertThat(predicate.test(context, row((short) 0)), is(true));
+            assertThat(predicate.test(context, row((short) 100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row((short) -100)), is(false));
+            assertThat(predicate.test(context, row((short) 0)), is(false));
+            assertThat(predicate.test(context, row((short) 100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.INT32)
+    void intTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.INT32);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(false));
+            assertThat(predicate.test(context, row(0)), is(false));
+            assertThat(predicate.test(context, row(100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(true));
+            assertThat(predicate.test(context, row(0)), is(false));
+            assertThat(predicate.test(context, row(100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(true));
+            assertThat(predicate.test(context, row(0)), is(true));
+            assertThat(predicate.test(context, row(100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(false));
+            assertThat(predicate.test(context, row(0)), is(false));
+            assertThat(predicate.test(context, row(100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(true));
+            assertThat(predicate.test(context, row(0)), is(true));
+            assertThat(predicate.test(context, row(100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(true));
+            assertThat(predicate.test(context, row(0)), is(true));
+            assertThat(predicate.test(context, row(100)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100)), is(false));
+            assertThat(predicate.test(context, row(0)), is(false));
+            assertThat(predicate.test(context, row(100)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.INT64)
+    void longTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.INT64);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(false));
+            assertThat(predicate.test(context, row(0L)), is(false));
+            assertThat(predicate.test(context, row(100L)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(true));
+            assertThat(predicate.test(context, row(0L)), is(false));
+            assertThat(predicate.test(context, row(100L)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(true));
+            assertThat(predicate.test(context, row(0L)), is(true));
+            assertThat(predicate.test(context, row(100L)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(false));
+            assertThat(predicate.test(context, row(0L)), is(false));
+            assertThat(predicate.test(context, row(100L)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(true));
+            assertThat(predicate.test(context, row(0L)), is(true));
+            assertThat(predicate.test(context, row(100L)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(true));
+            assertThat(predicate.test(context, row(0L)), is(true));
+            assertThat(predicate.test(context, row(100L)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100L)), is(false));
+            assertThat(predicate.test(context, row(0L)), is(false));
+            assertThat(predicate.test(context, row(100L)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.FLOAT)
+    void floatTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.FLOAT);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(false));
+            assertThat(predicate.test(context, row(0.0f)), is(false));
+            assertThat(predicate.test(context, row(100.5f)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(true));
+            assertThat(predicate.test(context, row(0.0f)), is(false));
+            assertThat(predicate.test(context, row(100.5f)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(true));
+            assertThat(predicate.test(context, row(0.0f)), is(true));
+            assertThat(predicate.test(context, row(100.5f)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(false));
+            assertThat(predicate.test(context, row(0.0f)), is(false));
+            assertThat(predicate.test(context, row(100.5f)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(true));
+            assertThat(predicate.test(context, row(0.0f)), is(true));
+            assertThat(predicate.test(context, row(100.5f)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(true));
+            assertThat(predicate.test(context, row(0.0f)), is(true));
+            assertThat(predicate.test(context, row(100.5f)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5f)), is(false));
+            assertThat(predicate.test(context, row(0.0f)), is(false));
+            assertThat(predicate.test(context, row(100.5f)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.DOUBLE)
+    void doubleTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.DOUBLE);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(false));
+            assertThat(predicate.test(context, row(0.0)), is(false));
+            assertThat(predicate.test(context, row(100.5)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(true));
+            assertThat(predicate.test(context, row(0.0)), is(false));
+            assertThat(predicate.test(context, row(100.5)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(true));
+            assertThat(predicate.test(context, row(0.0)), is(true));
+            assertThat(predicate.test(context, row(100.5)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(false));
+            assertThat(predicate.test(context, row(0.0)), is(false));
+            assertThat(predicate.test(context, row(100.5)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(true));
+            assertThat(predicate.test(context, row(0.0)), is(true));
+            assertThat(predicate.test(context, row(100.5)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(true));
+            assertThat(predicate.test(context, row(0.0)), is(true));
+            assertThat(predicate.test(context, row(100.5)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(-100.5)), is(false));
+            assertThat(predicate.test(context, row(0.0)), is(false));
+            assertThat(predicate.test(context, row(100.5)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.DECIMAL)
+    void decimalTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = 
singleColumnType(NativeTypes.decimalOf(19, 3));
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(false));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(false));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> 0", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(false));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= 0", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(true));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(false));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(false));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(true));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val < 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(true));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > 0.1", 
inputType);
+
+            assertThat(predicate.test(context, row(new BigDecimal("-100.5"))), 
is(false));
+            assertThat(predicate.test(context, row(BigDecimal.ZERO)), 
is(false));
+            assertThat(predicate.test(context, row(new BigDecimal("100.5"))), 
is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.DATE)
+    void dateTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.DATE);
+
+        LocalDate past = LocalDate.of(2020, 1, 1);
+        LocalDate present = LocalDate.of(2023, 6, 15);
+        LocalDate future = LocalDate.of(2025, 12, 31);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > DATE 
'2023-06-15'", inputType);
+
+            assertThat(predicate.test(context, row(past)), is(false));
+            assertThat(predicate.test(context, row(present)), is(false));
+            assertThat(predicate.test(context, row(future)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> DATE 
'2023-06-15'", inputType);
+
+            assertThat(predicate.test(context, row(past)), is(true));
+            assertThat(predicate.test(context, row(present)), is(false));
+            assertThat(predicate.test(context, row(future)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= DATE 
'2023-06-15'", inputType);
+
+            assertThat(predicate.test(context, row(past)), is(true));
+            assertThat(predicate.test(context, row(present)), is(true));
+            assertThat(predicate.test(context, row(future)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(past)), is(false));
+            assertThat(predicate.test(context, row(present)), is(false));
+            assertThat(predicate.test(context, row(future)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(past)), is(true));
+            assertThat(predicate.test(context, row(present)), is(true));
+            assertThat(predicate.test(context, row(future)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.TIME)
+    void timeTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.time(0));
+
+        LocalTime early = LocalTime.of(8, 0, 0);
+        LocalTime noon = LocalTime.of(12, 0, 0);
+        LocalTime late = LocalTime.of(18, 0, 0);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > TIME 
'12:00:00'", inputType);
+
+            assertThat(predicate.test(context, row(early)), is(false));
+            assertThat(predicate.test(context, row(noon)), is(false));
+            assertThat(predicate.test(context, row(late)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> TIME 
'12:00:00'", inputType);
+
+            assertThat(predicate.test(context, row(early)), is(true));
+            assertThat(predicate.test(context, row(noon)), is(false));
+            assertThat(predicate.test(context, row(late)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= TIME 
'12:00:00'", inputType);
+
+            assertThat(predicate.test(context, row(early)), is(true));
+            assertThat(predicate.test(context, row(noon)), is(true));
+            assertThat(predicate.test(context, row(late)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(early)), is(false));
+            assertThat(predicate.test(context, row(noon)), is(false));
+            assertThat(predicate.test(context, row(late)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(early)), is(true));
+            assertThat(predicate.test(context, row(noon)), is(true));
+            assertThat(predicate.test(context, row(late)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.DATETIME)
+    void datetimeTest() throws Exception {
+        EvaluationContext<Object[]> context = context();
+        StructNativeType inputType = singleColumnType(NativeTypes.datetime(6));
+
+        LocalDateTime past = LocalDateTime.of(2020, 1, 1, 10, 0, 0);
+        LocalDateTime present = LocalDateTime.of(2023, 6, 15, 12, 0, 0);
+        LocalDateTime future = LocalDateTime.of(2025, 12, 31, 14, 0, 0);
+
+        {
+            IgnitePredicate predicate = factory.predicate("val > TIMESTAMP 
'2023-06-15 12:00:00'", inputType);
+
+            assertThat(predicate.test(context, row(past)), is(false));
+            assertThat(predicate.test(context, row(present)), is(false));
+            assertThat(predicate.test(context, row(future)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <> TIMESTAMP 
'2023-06-15 12:00:00'", inputType);
+
+            assertThat(predicate.test(context, row(past)), is(true));
+            assertThat(predicate.test(context, row(present)), is(false));
+            assertThat(predicate.test(context, row(future)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val <= TIMESTAMP 
'2023-06-15 12:00:00'", inputType);
+
+            assertThat(predicate.test(context, row(past)), is(true));
+            assertThat(predicate.test(context, row(present)), is(true));
+            assertThat(predicate.test(context, row(future)), is(false));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(past)), is(false));
+            assertThat(predicate.test(context, row(present)), is(false));
+            assertThat(predicate.test(context, row(future)), is(false));
+            assertThat(predicate.test(context, row(null)), is(true));
+        }
+
+        {
+            IgnitePredicate predicate = factory.predicate("val IS NOT NULL", 
inputType);
+
+            assertThat(predicate.test(context, row(past)), is(true));
+            assertThat(predicate.test(context, row(present)), is(true));
+            assertThat(predicate.test(context, row(future)), is(true));
+            assertThat(predicate.test(context, row(null)), is(false));
+        }
+    }
+
+    @Test
+    @TestFor(ColumnType.TIMESTAMP)

Review Comment:
   It a TimeZone is required for interpreting such literals and have to be 
added to evaludation context?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to