use of org.apache.calcite.sql.test.SqlTester in project calcite by apache.
the class SqlValidatorTest method testCaseInsensitiveSubQuery.
/**
* Tests referencing columns from a sub-query that has duplicate column
* names. (The standard says it should be an error, but we don't right
* now.)
*/
@Test
public void testCaseInsensitiveSubQuery() {
final SqlTester insensitive = tester.withCaseSensitive(false).withQuoting(Quoting.BRACKET);
final SqlTester sensitive = tester.withCaseSensitive(true).withQuoting(Quoting.BRACKET);
String sql = "select [e] from (\n" + "select empno as [e], deptno as d, 1 as [e] from EMP)";
sensitive.checkQuery(sql);
insensitive.checkQuery(sql);
String sql1 = "select e from (\n" + "select empno as [e], deptno as d, 1 as [E] from EMP)";
insensitive.checkQuery(sql1);
sensitive.checkQuery(sql1);
}
use of org.apache.calcite.sql.test.SqlTester in project calcite by apache.
the class SqlValidatorTest method testInsertSubsetWithCustomInitializerExpressionFactory.
@Test
public void testInsertSubsetWithCustomInitializerExpressionFactory() {
final SqlTester pragmaticTester = tester.withConformance(SqlConformanceEnum.PRAGMATIC_2003);
pragmaticTester.checkQuery("insert into empdefaults values (101)");
pragmaticTester.checkQuery("insert into empdefaults values (101, 'Coral')");
pragmaticTester.checkQueryFails("insert into empdefaults ^values (null, 'Tod')^", "Column 'EMPNO' has no default value and does not allow NULLs");
pragmaticTester.checkQueryFails("insert into empdefaults ^values (78, null)^", "Column 'ENAME' has no default value and does not allow NULLs");
}
use of org.apache.calcite.sql.test.SqlTester in project calcite by apache.
the class SqlValidatorTest method testInsertSubset.
@Test
public void testInsertSubset() {
final SqlTester pragmaticTester = tester.withConformance(SqlConformanceEnum.PRAGMATIC_2003);
final String sql1 = "insert into empnullables\n" + "values (1, 'nom', 'job', 0, timestamp '1970-01-01 00:00:00')";
pragmaticTester.checkQuery(sql1);
final String sql2 = "insert into empnullables\n" + "values (1, 'nom', null, 0, null)";
pragmaticTester.checkQuery(sql2);
}
use of org.apache.calcite.sql.test.SqlTester in project calcite by apache.
the class SqlValidatorTest method testGeometry.
/**
* Tests whether the GEOMETRY data type is allowed.
*
* @see SqlConformance#allowGeometry()
*/
@Test
public void testGeometry() {
final SqlTester lenient = tester.withConformance(SqlConformanceEnum.LENIENT);
final SqlTester strict = tester.withConformance(SqlConformanceEnum.STRICT_2003);
final String err = "Geo-spatial extensions and the GEOMETRY data type are not enabled";
sql("select cast(null as geometry) as g from emp").tester(strict).fails(err).tester(lenient).sansCarets().ok();
}
use of org.apache.calcite.sql.test.SqlTester in project calcite by apache.
the class SqlValidatorTest method testInsertBindSubsetFailNullability.
@Test
public void testInsertBindSubsetFailNullability() {
final SqlTester pragmaticTester = tester.withConformance(SqlConformanceEnum.PRAGMATIC_2003);
pragmaticTester.checkQueryFails("insert into ^empnullables^ values (?)", "Column 'ENAME' has no default value and does not allow NULLs");
pragmaticTester.checkQueryFails("insert into empnullables ^values (null, ?)^", "Column 'EMPNO' has no default value and does not allow NULLs");
pragmaticTester.checkQueryFails("insert into empnullables ^values (?, null)^", "Column 'ENAME' has no default value and does not allow NULLs");
}
Aggregations