Search in sources :

Example 96 with SqlOperatorFixture

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

the class SqlOperatorTest method testDifferenceFunc.

@Test
void testDifferenceFunc() {
    final SqlOperatorFixture f = fixture().setFor(SqlLibraryOperators.DIFFERENCE).withLibrary(SqlLibrary.POSTGRESQL);
    f.checkScalarExact("DIFFERENCE('Miller', 'miller')", 4);
    f.checkScalarExact("DIFFERENCE('Miller', 'myller')", 4);
    f.checkScalarExact("DIFFERENCE('muller', 'miller')", 4);
    f.checkScalarExact("DIFFERENCE('muller', 'miller')", 4);
    f.checkScalarExact("DIFFERENCE('muller', 'milk')", 2);
    f.checkScalarExact("DIFFERENCE('muller', 'mile')", 2);
    f.checkScalarExact("DIFFERENCE('muller', 'm')", 1);
    f.checkScalarExact("DIFFERENCE('muller', 'lee')", 0);
    f.checkNull("DIFFERENCE('muller', cast(null as varchar(1)))");
    f.checkNull("DIFFERENCE(cast(null as varchar(1)), 'muller')");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 97 with SqlOperatorFixture

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

the class SqlOperatorTest method testFromBase64.

@Test
void testFromBase64() {
    final SqlOperatorFixture f = fixture().setFor(SqlLibraryOperators.FROM_BASE64).withLibrary(SqlLibrary.MYSQL);
    f.checkString("from_base64('VGhpcyBpcyBhIHRlc3QgU3RyaW5nLg==')", "546869732069732061207465737420537472696e672e", "VARBINARY NOT NULL");
    f.checkString("from_base64('VGhpcyBpcyBhIHRlc\t3QgU3RyaW5nLg==')", "546869732069732061207465737420537472696e672e", "VARBINARY NOT NULL");
    f.checkString("from_base64('VGhpcyBpcyBhIHRlc\t3QgU3\nRyaW5nLg==')", "546869732069732061207465737420537472696e672e", "VARBINARY NOT NULL");
    f.checkString("from_base64('VGhpcyB  pcyBhIHRlc3Qg\tU3Ry\naW5nLg==')", "546869732069732061207465737420537472696e672e", "VARBINARY NOT NULL");
    f.checkNull("from_base64('-1')");
    f.checkNull("from_base64('-100')");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 98 with SqlOperatorFixture

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

the class SqlOperatorTest method testCurrentUserFunc.

@Test
void testCurrentUserFunc() {
    final SqlOperatorFixture f = fixture();
    f.setFor(SqlStdOperatorTable.CURRENT_USER, VM_FENNEL);
    f.checkString("CURRENT_USER", "sa", "VARCHAR(2000) NOT NULL");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 99 with SqlOperatorFixture

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

the class SqlOperatorTest method testLessThanOrEqualOperatorInterval.

@Test
void testLessThanOrEqualOperatorInterval() {
    final SqlOperatorFixture f = fixture();
    f.checkBoolean("interval '2' day <= interval '1' day", false);
    f.checkBoolean("interval '2' day <= interval '5' day", true);
    f.checkBoolean("interval '2 2:2:2' day to second <= interval '2' day", false);
    f.checkBoolean("interval '2' day <= interval '2' day", true);
    f.checkBoolean("interval '2' day <= interval '-2' day", false);
    f.checkBoolean("interval '2' day <= interval '2' hour", false);
    f.checkBoolean("interval '2' minute <= interval '2' hour", true);
    f.checkBoolean("interval '2' second <= interval '2' minute", true);
    f.checkNull("cast(null as interval hour) <= interval '2' minute");
    f.checkNull("interval '2:2' hour to minute " + "<= cast(null as interval second)");
}
Also used : SqlOperatorFixture(org.apache.calcite.sql.test.SqlOperatorFixture) Test(org.junit.jupiter.api.Test)

Example 100 with SqlOperatorFixture

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

the class SqlOperatorTest method testGroupConcatFunc.

@Test
void testGroupConcatFunc() {
    final SqlOperatorFixture f = fixture();
    checkGroupConcatFunc(f.withLibrary(SqlLibrary.MYSQL));
    checkGroupConcatFuncFails(f.withLibrary(SqlLibrary.BIG_QUERY));
    checkGroupConcatFuncFails(f.withLibrary(SqlLibrary.POSTGRESQL));
}
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