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

The following examples show how to use org.apache.calcite.sql.validate.SqlValidatorCatalogReader. 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 File: BatsOptimizerTest.java    From Bats with 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 File: SqlValidatorImpl.java    From dremio-oss with 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 File: SqlToRelTestBase.java    From calcite with 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 File: SqlToRelTestBase.java    From calcite with 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 File: SqlValidatorFeatureTest.java    From calcite with 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 File: SqlConverter.java    From Bats with 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 File: MycatCalcitePlanner.java    From Mycat2 with 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 File: FlinkCalciteSqlValidator.java    From flink with 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 File: FlinkCalciteSqlValidator.java    From flink with 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 File: SqlTestFactory.java    From calcite with Apache License 2.0 4 votes vote down vote up
SqlValidator create(
SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlValidator.Config config);
 
Example #11
Source File: SqlToRelTestBase.java    From calcite with 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 File: SqlToRelTestBase.java    From calcite with 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 File: SqlToRelTestBase.java    From calcite with 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 File: AbstractMaterializedViewTest.java    From calcite with 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 File: SqlAdvisorValidator.java    From Bats with 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 File: SqlAdvisorValidator.java    From calcite with 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);
}