Search in sources :

Example 1 with SqlOperatorFixture

use of org.apache.calcite.sql.test.SqlOperatorFixture in project calcite by apache.

the class SqlOperatorTest method testLeastFunc.

@Test
void testLeastFunc() {
    final SqlOperatorFixture f = fixture().setFor(SqlLibraryOperators.LEAST, VmName.EXPAND).withLibrary(SqlLibrary.ORACLE);
    f.checkString("least('on', 'earth')", "earth", "CHAR(5) NOT NULL");
    f.checkString("least('show', 'on', 'earth')", "earth", "CHAR(5) NOT NULL");
    f.checkScalar("least(12, CAST(NULL AS INTEGER), 3)", isNullValue(), "INTEGER");
    f.checkScalar("least(false, true)", false, "BOOLEAN NOT NULL");
    final SqlOperatorFixture f12 = f.forOracle(SqlConformanceEnum.ORACLE_12);
    f12.checkString("least('on', 'earth')", "earth", "VARCHAR(5) NOT NULL");
    f12.checkString("least('show', 'on', 'earth')", "earth", "VARCHAR(5) NOT NULL");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 2 with SqlOperatorFixture

use of org.apache.calcite.sql.test.SqlOperatorFixture in project calcite by apache.

the class SqlOperatorTest method testSecond.

@Test
void testSecond() {
    final SqlOperatorFixture f = fixture();
    f.setFor(SqlStdOperatorTable.SECOND, VM_FENNEL, VM_JAVA);
    f.checkScalar("second(timestamp '2008-1-23 12:34:56')", "56", "BIGINT NOT NULL");
    f.checkNull("second(cast(null as timestamp))");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 3 with SqlOperatorFixture

use of org.apache.calcite.sql.test.SqlOperatorFixture in project calcite by apache.

the class SqlOperatorTest method testSha1.

@Test
void testSha1() {
    final SqlOperatorFixture f = fixture().setFor(SqlLibraryOperators.SHA1).withLibrary(SqlLibrary.MYSQL);
    f.checkString("sha1(x'')", "da39a3ee5e6b4b0d3255bfef95601890afd80709", "VARCHAR NOT NULL");
    f.checkString("sha1('')", "da39a3ee5e6b4b0d3255bfef95601890afd80709", "VARCHAR NOT NULL");
    f.checkString("sha1('ABC')", "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8", "VARCHAR NOT NULL");
    f.checkString("sha1(x'414243')", "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8", "VARCHAR NOT NULL");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 4 with SqlOperatorFixture

use of org.apache.calcite.sql.test.SqlOperatorFixture in project calcite by apache.

the class SqlOperatorTest method testIsFalseOperator.

@Test
void testIsFalseOperator() {
    final SqlOperatorFixture f = fixture();
    f.setFor(SqlStdOperatorTable.IS_FALSE, VmName.EXPAND);
    f.checkBoolean("false is false", true);
    f.checkBoolean("true is false", false);
    f.checkBoolean("cast(null as boolean) is false", false);
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 5 with SqlOperatorFixture

use of org.apache.calcite.sql.test.SqlOperatorFixture in project calcite by apache.

the class SqlOperatorTest method testUpperFunc.

@Test
void testUpperFunc() {
    final SqlOperatorFixture f = fixture();
    f.setFor(SqlStdOperatorTable.UPPER, VmName.EXPAND);
    f.checkString("upper('a')", "A", "CHAR(1) NOT NULL");
    f.checkString("upper('A')", "A", "CHAR(1) NOT NULL");
    f.checkString("upper('1')", "1", "CHAR(1) NOT NULL");
    f.checkString("upper('aa')", "AA", "CHAR(2) NOT NULL");
    f.checkNull("upper(cast(null as varchar(1)))");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Aggregations

SqlOperatorFixture (org.apache.calcite.sql.test.SqlOperatorFixture)297 Test (org.junit.jupiter.api.Test)292 SqlString (org.apache.calcite.sql.util.SqlString)43 TimestampString (org.apache.calcite.util.TimestampString)42 RelDataType (org.apache.calcite.rel.type.RelDataType)2 SqlLiteral (org.apache.calcite.sql.SqlLiteral)2 Disabled (org.junit.jupiter.api.Disabled)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Strong (org.apache.calcite.plan.Strong)1 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)1 Hook (org.apache.calcite.runtime.Hook)1 SqlAggFunction (org.apache.calcite.sql.SqlAggFunction)1 SqlCall (org.apache.calcite.sql.SqlCall)1 SqlCallBinding (org.apache.calcite.sql.SqlCallBinding)1 SqlJdbcFunctionCall (org.apache.calcite.sql.SqlJdbcFunctionCall)1 SqlNodeList (org.apache.calcite.sql.SqlNodeList)1 SqlOperandCountRange (org.apache.calcite.sql.SqlOperandCountRange)1