Java Code Examples for org.apache.calcite.sql.validate.SqlValidatorCatalogReader

The following examples show how to use org.apache.calcite.sql.validate.SqlValidatorCatalogReader. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Bats   Source File: BatsOptimizerTest.java    License: Apache License 2.0 5 votes vote down vote up
static Pair<SqlNode, SqlValidator> testSqlValidator() throws Exception {
    String sql = "select * from my_schema.test where f1=1 or f2=2 order by f3 limit 2";
    sql = "select * from test";
    sql = "select * from my_schema2.test2";
    sql = "select sum(f1),max(f2) from test";

    sql = "select t1.f1,sum(Distinct f1) as sumf1 from test as t1 "
            + "where f2>20 group by f1 having f1>10 order by f1 limit 2";
    // sql = "insert into test(f1,f2,f3) values(1,2,3)";
    // sql = "update test set f1=100 where f2>10";
    // sql = "delete from test where f2>10";
    SqlNode sqlNode = parse(sql);

    SqlOperatorTable opTab = SqlStdOperatorTable.instance();
    RelDataTypeFactory typeFactory = createJavaTypeFactory();
    SqlValidatorCatalogReader catalogReader = createCalciteCatalogReader(typeFactory);
    SqlConformance conformance = SqlConformanceEnum.DEFAULT;

    List<String> names = new ArrayList<>();
    names.add("my_schema");
    names.add("test");
    catalogReader.getTable(names);

    SqlValidator sqlValidator = SqlValidatorUtil.newValidator(opTab, catalogReader, typeFactory, conformance);
    sqlNode = sqlValidator.validate(sqlNode);
    // System.out.println(sqlNode);

    sql = "insert into test(f1,f2,f3) values(1,2,3)";
    // sqlNode = parse(sql);
    // sqlNode = sqlValidator.validate(sqlNode);

    return new Pair<>(sqlNode, sqlValidator);
}
 
Example 2
Source Project: dremio-oss   Source File: SqlValidatorImpl.java    License: Apache License 2.0 5 votes vote down vote up
protected SqlValidatorImpl(
    FlattenOpCounter flattenCount,
    SqlOperatorTable opTab,
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    SqlConformance conformance) {
  super(opTab, catalogReader, typeFactory, conformance);
  this.flattenCount = flattenCount;
}
 
Example 3
Source Project: calcite   Source File: SqlToRelTestBase.java    License: Apache License 2.0 5 votes vote down vote up
public SqlValidator createValidator(
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory) {
  return new FarragoTestValidator(
      getOperatorTable(),
      catalogReader,
      typeFactory,
      SqlValidator.Config.DEFAULT
          .withSqlConformance(conformance)
          .withTypeCoercionEnabled(enableTypeCoercion)
          .withIdentifierExpansion(true));
}
 
Example 4
Source Project: calcite   Source File: SqlToRelTestBase.java    License: Apache License 2.0 5 votes vote down vote up
FarragoTestValidator(
    SqlOperatorTable opTab,
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    Config config) {
  super(opTab, catalogReader, typeFactory, config);
}
 
Example 5
Source Project: calcite   Source File: SqlValidatorFeatureTest.java    License: Apache License 2.0 5 votes vote down vote up
protected FeatureValidator(
    SqlOperatorTable opTab,
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    Config config) {
  super(opTab, catalogReader, typeFactory, config);
}
 
Example 6
Source Project: Bats   Source File: SqlConverter.java    License: Apache License 2.0 4 votes vote down vote up
DrillValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory, SqlConformance conformance) {
  super(opTab, catalogReader, typeFactory, conformance);
}
 
Example 7
Source Project: Mycat2   Source File: MycatCalcitePlanner.java    License: GNU General Public License v3.0 4 votes vote down vote up
public SqlValidatorImpl getSqlValidator() {
    SqlOperatorTable opTab = MycatCalciteSupport.INSTANCE.config.getOperatorTable();
    SqlValidatorCatalogReader catalogReader = createCalciteCatalogReader();
    RelDataTypeFactory typeFactory = MycatCalciteSupport.INSTANCE.TypeFactory;
    return (SqlValidatorImpl) SqlValidatorUtil.newValidator(opTab, catalogReader, typeFactory, MycatCalciteSupport.INSTANCE.getValidatorConfig());
}
 
Example 8
Source Project: flink   Source File: FlinkCalciteSqlValidator.java    License: Apache License 2.0 4 votes vote down vote up
public FlinkCalciteSqlValidator(
		SqlOperatorTable opTab,
		SqlValidatorCatalogReader catalogReader,
		RelDataTypeFactory typeFactory) {
	super(opTab, catalogReader, typeFactory, SqlConformanceEnum.DEFAULT);
}
 
Example 9
Source Project: flink   Source File: FlinkCalciteSqlValidator.java    License: Apache License 2.0 4 votes vote down vote up
public FlinkCalciteSqlValidator(
		SqlOperatorTable opTab,
		SqlValidatorCatalogReader catalogReader,
		RelDataTypeFactory typeFactory) {
	super(opTab, catalogReader, typeFactory, SqlConformanceEnum.DEFAULT);
}
 
Example 10
Source Project: calcite   Source File: SqlTestFactory.java    License: Apache License 2.0 4 votes vote down vote up
SqlValidator create(
SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlValidator.Config config);
 
Example 11
Source Project: calcite   Source File: SqlToRelTestBase.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Factory method to create a {@link SqlValidator}.
 */
SqlValidator createValidator(
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory);
 
Example 12
Source Project: calcite   Source File: SqlToRelTestBase.java    License: Apache License 2.0 4 votes vote down vote up
public MockRelOptSchema(
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory) {
  this.catalogReader = catalogReader;
  this.typeFactory = typeFactory;
}
 
Example 13
Source Project: calcite   Source File: SqlToRelTestBase.java    License: Apache License 2.0 4 votes vote down vote up
public SqlValidator getValidator() {
  final RelDataTypeFactory typeFactory = getTypeFactory();
  final SqlValidatorCatalogReader catalogReader =
      createCatalogReader(typeFactory);
  return createValidator(catalogReader, typeFactory);
}
 
Example 14
Source Project: calcite   Source File: AbstractMaterializedViewTest.java    License: Apache License 2.0 4 votes vote down vote up
ValidatorForTest(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory, SqlConformance conformance) {
  super(opTab, catalogReader, typeFactory, Config.DEFAULT.withSqlConformance(conformance));
}
 
Example 15
Source Project: Bats   Source File: SqlAdvisorValidator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates a SqlAdvisor validator.
 *
 * @param opTab         Operator table
 * @param catalogReader Catalog reader
 * @param typeFactory   Type factory
 * @param conformance   Compatibility mode
 */
public SqlAdvisorValidator(
    SqlOperatorTable opTab,
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    SqlConformance conformance) {
  super(opTab, catalogReader, typeFactory, conformance);
}
 
Example 16
Source Project: calcite   Source File: SqlAdvisorValidator.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates a SqlAdvisor validator.
 *
 * @param opTab         Operator table
 * @param catalogReader Catalog reader
 * @param typeFactory   Type factory
 * @param config        Config
 */
public SqlAdvisorValidator(
    SqlOperatorTable opTab,
    SqlValidatorCatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    Config config) {
  super(opTab, catalogReader, typeFactory, config);
}